keygen_api.h (52487B)
1 /* 2 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 3 * 4 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 5 */ 6 7 #ifndef _BCM_INT_FIELD_KEYGEN_API_H 8 #define _BCM_INT_FIELD_KEYGEN_API_H 9 10 #include <sal/types.h> 11 #include <shared/bsl.h> 12 #include <shared/bitop.h> 13 #include <bcm/field.h> 14 #include <bcm/types.h> 15 #include <bcm/error.h> 16 #include <sal/core/libc.h> 17 #include <sal/core/alloc.h> 18 #include <bcm_int/esw/keygen_error.h> 19 20 /* Maxmimum number of slices occupied by any 21 * keygen mode in any device. 22 */ 23 #define BCMI_KEYGEN_ENTRY_PARTS_MAX 4 24 25 /* Different keygen modes */ 26 typedef enum bcmi_keygen_mode_e { 27 /* Mode HALF. This mode will have half of the key 28 * size of SINGLE mode. 29 */ 30 BCMI_KEYGEN_MODE_HALF = 0, 31 /* Single wide mode which uses one slice only */ 32 BCMI_KEYGEN_MODE_SINGLE = 1, 33 /* Single wide mode which uses one slice only, 34 * but have narrow ASET. Used in EM HASH FP. 35 */ 36 BCMI_KEYGEN_MODE_SINGLE_ASET_NARROW = 2, 37 /* Single wide mode which uses one slice only, 38 * but have wider ASET. Used in EM HASH FP. 39 */ 40 BCMI_KEYGEN_MODE_SINGLE_ASET_WIDE = 3, 41 /* Uses single slice but key size is double the key 42 * size of SINGLE mode. 43 */ 44 BCMI_KEYGEN_MODE_DBLINTRA = 4, 45 /* Uses two slices and key size is double the key 46 * size of SINGLE mode. 47 */ 48 BCMI_KEYGEN_MODE_DBLINTER = 5, 49 /* Uses two slices and key size is triple the key 50 * size of SINGLE mode. 51 */ 52 BCMI_KEYGEN_MODE_TRIPLE = 6, 53 /* Uses two slices and key size is four times the key 54 * size of SINGLE mode. 55 */ 56 BCMI_KEYGEN_MODE_QUAD = 7, 57 /* Always Last. Not a usable value. */ 58 BCMI_KEYGEN_MODE_COUNT = 8 59 } bcmi_keygen_mode_t; 60 61 /* extractor attributes used to validity of extractor configuration 62 * for a given keygen mode and qualifer list. 63 * Note: enumerations in bcmi_keygen_ext_attr_t must have 1-to-1 64 * mapping with enumerations in bcmi_keygen_acl_attr_t. 65 */ 66 typedef enum bcmi_keygen_ext_attr_s { 67 /* Extractor can operate in multiple granularities. */ 68 BCMI_KEYGEN_EXT_ATTR_MULTI_GRAN = 0, 69 /* Extractor can operate in granularity 1 */ 70 BCMI_KEYGEN_EXT_ATTR_MULTI_GRAN_1, 71 /* Extractor can operate in granularity 2 */ 72 BCMI_KEYGEN_EXT_ATTR_MULTI_GRAN_2, 73 /* Extractor can operate in granularity 4 */ 74 BCMI_KEYGEN_EXT_ATTR_MULTI_GRAN_4, 75 /* Extractor can operate in granularity 8 */ 76 BCMI_KEYGEN_EXT_ATTR_MULTI_GRAN_8, 77 /* Extractor can operate in granularity 16 */ 78 BCMI_KEYGEN_EXT_ATTR_MULTI_GRAN_16, 79 /* Extractor can operate in granularity 32 */ 80 BCMI_KEYGEN_EXT_ATTR_MULTI_GRAN_32, 81 /* Extractor is extracts bits from the pass through section. */ 82 BCMI_KEYGEN_EXT_ATTR_PASS_THRU, 83 /* Extractor cannot be used when keygen mode is HALF */ 84 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_MODE_HALF, 85 /* Extractor cannot be used if IPBM is part of final key. */ 86 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_IPBM, 87 /* Extractor cannot be used if SRC_DST_CONT_0 LSB 16bits 88 * (Total length is 17 bits), is part of final key. 89 */ 90 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_SRC_DST_CONT_0, 91 /* Extractor cannot be used if SRC_DST_CONT_1 LSB 16bits 92 * (Total length is 17 bits), is part of final key. 93 */ 94 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_SRC_DST_CONT_1, 95 /* Extractor cannot be used if MSB bits of SRC_DST_CONT_0 96 * (or) SRC_DST_CONT_1, is part of the final key. 97 */ 98 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_SRC_DST_CONT_MSB, 99 /* Extractor cannot be used if SRC_DST_CONT_0 LSB 16bits 100 * (Total length is 17 bits), is part of final key of 101 * HALF(80bit) mode group. 102 */ 103 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_SRC_DST_CONT_0_HM, 104 /* Extractor cannot be used if SRC_DST_CONT_1 LSB 16bits 105 * (Total length is 17 bits), is part of final key of 106 * HALF(80bit) mode group. 107 */ 108 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_SRC_DST_CONT_1_HM, 109 /* Extractor cannot be used if MSB bits of SRC_DST_CONT_0 110 * (or) SRC_DST_CONT_1, is part of the final key of HALF 111 * (80bit) mode group. 112 */ 113 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_SRC_DST_CONT_MSB_HM, 114 /* Extractor cannot be used if post mux qualifier, Drop, 115 * is present in the QSET. 116 */ 117 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_DROP, 118 /* Extractor cannot be used if LSB 4 bits of class id, generated 119 * in second lookup of Exact Match Rules, are part of the final key. 120 */ 121 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_EM_SECOND_LOOKUP_CLASSID_BITS_0_3, 122 /* Extractor cannot be used if middle 4 bits of class id, generated 123 * in second lookup of Exact Match Rules, are part of the final key. 124 */ 125 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_EM_SECOND_LOOKUP_CLASSID_BITS_4_7, 126 /* Extractor cannot be used if MSB 4 bits of class id, generated 127 * in second lookup of Exact Match Rules, are part of the final key. 128 */ 129 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_EM_SECOND_LOOKUP_CLASSID_BITS_8_11, 130 /* Extractor cannot be used if LSB 4 bits of class id, generated 131 * in first lookup of Exact Match Rules, are part of the final key. 132 */ 133 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_EM_FIRST_LOOKUP_CLASSID_BITS_0_3, 134 /* Extractor cannot be used if middle 4 bits of class id, generated 135 * in first lookup of Exact Match Rules, are part of the final key. 136 */ 137 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_EM_FIRST_LOOKUP_CLASSID_BITS_4_7, 138 /* Extractor cannot be used if MSB 4 bits of class id, generated 139 * in first lookup of Exact Match Rules, are part of the final key. 140 */ 141 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_EM_FIRST_LOOKUP_CLASSID_BITS_8_11, 142 /* Extractor cannot be used if post mux qualifier, HIT status from Exact 143 * Match first lookup, is present in the QSET. 144 */ 145 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_EM_FIRST_LOOKUP_HIT, 146 /* Extractor cannot be used if post mux qualifier, HIT status from Exact 147 * Match second lookup, is present in the QSET. 148 */ 149 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_EM_SECOND_LOOKUP_HIT, 150 /* Extractor cannot be used if post mux qualifier, NatNeeded, 151 * is present in the QSET. 152 */ 153 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_NAT_NEEDED, 154 /* Extractor cannot be used if post mux qualifier, NatDstRealmId, 155 * is present in the QSET. 156 */ 157 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_NAT_DST_REALM_ID, 158 /* Extractor cannot be used if LSB 4 bits of lookup status vector, 159 * are part of the final key. 160 */ 161 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_LOOKUP_STATUS_VECTOR_BITS_0_3, 162 /* Extractor cannot be used if MSB 4 bits of lookup status vector, 163 * are part of the final key. 164 */ 165 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_LOOKUP_STATUS_VECTOR_BITS_4_7, 166 /* Extractor cannot be used if 17 bits of SRC_DST_CONT_A 167 * is part of the final key. 168 */ 169 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_DST_CONTAINER_A, 170 /* Extractor cannot be used if 17 bits of SRC_DST_CONT_B 171 * is part of the final key. 172 */ 173 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_DST_CONTAINER_B, 174 /* Extractor cannot be used if post mux qualifier, PacketRes, 175 * is present in the QSET. 176 */ 177 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_PKT_RESOLUTION, 178 /* Extractor cannot be used if 16 bits of CLASS_ID C 179 * container is part of the final key. 180 */ 181 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_CLASS_ID_C, 182 /* Extractor cannot be used if 16 bits of CLASS_ID D 183 * container is part of the final key. 184 */ 185 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_CLASS_ID_D, 186 /* Extractor cannot be used if post mux qualifier, 187 * Internal Priority, is present in the QSET. 188 */ 189 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_INT_PRI, 190 /* Extractor cannot be used if drop Reasons generated in 191 * ingress pipeline before IFP are part of final key. 192 */ 193 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_IFP_DROP_VECTOR, 194 /* Extractor cannot be used if post mux qualifier, 195 * HiGiG header opcode, is present in the QSET. 196 */ 197 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_MH_OPCODE, 198 /* Extractor cannot be used if keygen mode is EM_128. */ 199 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_MODE_SINGLE_ASET_WIDE, 200 /* Extractor cannot be used if keygen algorithm is called for 201 * QSET update. 202 */ 203 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_QSET_UPDATE, 204 205 BCMI_KEYGEN_EXT_ATTR_NOT_WITH_PMUX_LTID, 206 /* Always Last. Not a usable value. */ 207 BCMI_KEYGEN_EXT_ATTR_COUNT 208 } bcmi_keygen_ext_attr_t; 209 210 /* Bitmap of extractor attributes. */ 211 typedef struct bcmi_keygen_ext_attrs_s { 212 SHR_BITDCL w[_SHR_BITDCLSIZE(BCMI_KEYGEN_EXT_ATTR_COUNT)]; 213 } bcmi_keygen_ext_attrs_t; 214 215 /* All the different qualifier controls to serve all keygen blocks 216 * in different chips. 217 */ 218 typedef enum bcmi_keygen_ext_ctrl_sel_e { 219 /* Selector disabled. */ 220 BCMI_KEYGEN_EXT_CTRL_SEL_DISABLE = 0, 221 /* Auxiliary Tag A selector. */ 222 BCMI_KEYGEN_EXT_CTRL_SEL_AUX_TAG_A = 1, 223 /* Auxiliary Tag B selector. */ 224 BCMI_KEYGEN_EXT_CTRL_SEL_AUX_TAG_B = 2, 225 /* Auxiliary Tag C selector. */ 226 BCMI_KEYGEN_EXT_CTRL_SEL_AUX_TAG_C = 3, 227 /* Auxiliary Tag D selector. */ 228 BCMI_KEYGEN_EXT_CTRL_SEL_AUX_TAG_D = 4, 229 /* TCP function selector. */ 230 BCMI_KEYGEN_EXT_CTRL_SEL_TCP_FN = 5, 231 /* ToS function selector. */ 232 BCMI_KEYGEN_EXT_CTRL_SEL_TOS_FN = 6, 233 /* TTL function selector. */ 234 BCMI_KEYGEN_EXT_CTRL_SEL_TTL_FN = 7, 235 /* Class ID container A selector. */ 236 BCMI_KEYGEN_EXT_CTRL_SEL_CLASSID_A = 8, 237 /* Class ID container B selector. */ 238 BCMI_KEYGEN_EXT_CTRL_SEL_CLASSID_B = 9, 239 /* Class ID container C selector. */ 240 BCMI_KEYGEN_EXT_CTRL_SEL_CLASSID_C = 10, 241 /* Class ID container D selector. */ 242 BCMI_KEYGEN_EXT_CTRL_SEL_CLASSID_D = 11, 243 /* Source Container A selector. */ 244 BCMI_KEYGEN_EXT_CTRL_SEL_SRC_A = 12, 245 /* Source Container B selector. */ 246 BCMI_KEYGEN_EXT_CTRL_SEL_SRC_B = 13, 247 /* Src/Dst Container 0 selector. */ 248 BCMI_KEYGEN_EXT_CTRL_SEL_SRC_DST_0 = 14, 249 /* Src/Dst Container 1 selector. */ 250 BCMI_KEYGEN_EXT_CTRL_SEL_SRC_DST_1 = 15, 251 /* IPBM Source. */ 252 BCMI_KEYGEN_EXT_CTRL_SEL_IPBM_PRESENT = 16, 253 /* Multiplexer in extractor hierarchy. */ 254 BCMI_KEYGEN_EXT_CTRL_SEL_MULTIPLEXER = 17, 255 /* Normalize L3 and L4 addresses. */ 256 BCMI_KEYGEN_EXT_CTRL_SEL_L3_L4_NORM = 18, 257 /* Normalize Mac address. */ 258 BCMI_KEYGEN_EXT_CTRL_SEL_MAC_NORM = 19, 259 /* PostMux Qualifier. */ 260 BCMI_KEYGEN_EXT_CTRL_SEL_PMUX = 20, 261 /* UDF Qualifiers. */ 262 BCMI_KEYGEN_EXT_CTRL_SEL_UDF = 21, 263 /* Destination Container A selector. */ 264 BCMI_KEYGEN_EXT_CTRL_SEL_DST_A = 22, 265 /* Destination Container B selector. */ 266 BCMI_KEYGEN_EXT_CTRL_SEL_DST_B = 23, 267 /* ALT TTL function selector. */ 268 BCMI_KEYGEN_EXT_CTRL_SEL_ALT_TTL_FN = 24, 269 /* LTID function selector. */ 270 BCMI_KEYGEN_EXT_CTRL_SEL_LTID = 25, 271 /* ING_FIELD_BUS Container selector. */ 272 BCMI_KEYGEN_EXT_CTRL_SEL_ING_FBUS_CONT = 26, 273 /* Always Last. Not a usable value. */ 274 BCMI_KEYGEN_EXT_CTRL_SEL_COUNT = 27 275 } bcmi_keygen_ext_ctrl_sel_t; 276 277 /* All the different hairarchical bus sections to 278 * serve all keygen blocks in different chips. 279 */ 280 typedef enum bcmi_keygen_ext_section_e { 281 /* Selector disabled. */ 282 BCMI_KEYGEN_EXT_SECTION_DISABLE = 0, 283 /* Level-1 32 bit extractor. */ 284 BCMI_KEYGEN_EXT_SECTION_L1E32, 285 /* Level-1 16 bit extractor. */ 286 BCMI_KEYGEN_EXT_SECTION_L1E16, 287 /* Level-1 8 bit extractor. */ 288 BCMI_KEYGEN_EXT_SECTION_L1E8, 289 /* Level-1 4 bit extractor. */ 290 BCMI_KEYGEN_EXT_SECTION_L1E4, 291 /* Level-1 2 bit extractor. */ 292 BCMI_KEYGEN_EXT_SECTION_L1E2, 293 /* Level-2 1st extractor section. */ 294 BCMI_KEYGEN_EXT_SECTION_L2S1, 295 /* Level-2 2nd extractor section. */ 296 BCMI_KEYGEN_EXT_SECTION_L2S2, 297 /* Level-2 3rd extractor section. */ 298 BCMI_KEYGEN_EXT_SECTION_L2S3, 299 /* Level-2 4th extractor section. */ 300 BCMI_KEYGEN_EXT_SECTION_L2S4, 301 /* Level-2 5th extractor section. */ 302 BCMI_KEYGEN_EXT_SECTION_L2S5, 303 /* Level-2 6th extractor section. */ 304 BCMI_KEYGEN_EXT_SECTION_L2S6, 305 /* Level-2 7th extractor section. */ 306 BCMI_KEYGEN_EXT_SECTION_L2S7, 307 /* Level-2 8th extractor section. */ 308 BCMI_KEYGEN_EXT_SECTION_L2S8, 309 /* Level-2 9th extractor section. */ 310 BCMI_KEYGEN_EXT_SECTION_L2S9, 311 /* Level-2 10th extractor section. */ 312 BCMI_KEYGEN_EXT_SECTION_L2S10, 313 /* Level-3 1st extractor section. */ 314 BCMI_KEYGEN_EXT_SECTION_L3S1, 315 /* Level-3 2nd extractor section. */ 316 BCMI_KEYGEN_EXT_SECTION_L3S2, 317 /* Level-3 3rd extractor section. */ 318 BCMI_KEYGEN_EXT_SECTION_L3S3, 319 /* Level-3 4th extractor section. */ 320 BCMI_KEYGEN_EXT_SECTION_L3S4, 321 /* Level-3 5th extractor section. */ 322 BCMI_KEYGEN_EXT_SECTION_L3S5, 323 /* Level-3 6th extractor section. */ 324 BCMI_KEYGEN_EXT_SECTION_L3S6, 325 /* Level-3 7th extractor section. */ 326 BCMI_KEYGEN_EXT_SECTION_L3S7, 327 /* Level-3 8th extractor section. */ 328 BCMI_KEYGEN_EXT_SECTION_L3S8, 329 /* Level-3 9th extractor section. */ 330 BCMI_KEYGEN_EXT_SECTION_L3S9, 331 /* Level-3 10th extractor section. */ 332 BCMI_KEYGEN_EXT_SECTION_L3S10, 333 /* Level-2 Slice A 1st extractor section. */ 334 BCMI_KEYGEN_EXT_SECTION_L2AS1, 335 /* Level-2 Slice A 2nd extractor section. */ 336 BCMI_KEYGEN_EXT_SECTION_L2AS2, 337 /* Level-2 Slice A 3rd extractor section. */ 338 BCMI_KEYGEN_EXT_SECTION_L2AS3, 339 /* Level-2 Slice A 4th extractor section. */ 340 BCMI_KEYGEN_EXT_SECTION_L2AS4, 341 /* Level-2 Slice A 5th extractor section. */ 342 BCMI_KEYGEN_EXT_SECTION_L2AS5, 343 /* Level-2 Slice A 6th extractor section. */ 344 BCMI_KEYGEN_EXT_SECTION_L2AS6, 345 /* Level-2 Slice A 7th extractor section. */ 346 BCMI_KEYGEN_EXT_SECTION_L2AS7, 347 /* Level-2 Slice A 8th extractor section. */ 348 BCMI_KEYGEN_EXT_SECTION_L2AS8, 349 /* Level-2 Slice A 9th extractor section. */ 350 BCMI_KEYGEN_EXT_SECTION_L2AS9, 351 /* Level-2 Slice A 10th extractor section. */ 352 BCMI_KEYGEN_EXT_SECTION_L2AS10, 353 /* Level-2 Slice B 1st extractor section. */ 354 BCMI_KEYGEN_EXT_SECTION_L2BS1, 355 /* Level-2 Slice B 2nd extractor section. */ 356 BCMI_KEYGEN_EXT_SECTION_L2BS2, 357 /* Level-2 Slice B 3rd extractor section. */ 358 BCMI_KEYGEN_EXT_SECTION_L2BS3, 359 /* Level-2 Slice B 4th extractor section. */ 360 BCMI_KEYGEN_EXT_SECTION_L2BS4, 361 /* Level-2 Slice B 5th extractor section. */ 362 BCMI_KEYGEN_EXT_SECTION_L2BS5, 363 /* Level-2 Slice B 6th extractor section. */ 364 BCMI_KEYGEN_EXT_SECTION_L2BS6, 365 /* Level-2 Slice B 7th extractor section. */ 366 BCMI_KEYGEN_EXT_SECTION_L2BS7, 367 /* Level-2 Slice B 8th extractor section. */ 368 BCMI_KEYGEN_EXT_SECTION_L2BS8, 369 /* Level-2 Slice B 9th extractor section. */ 370 BCMI_KEYGEN_EXT_SECTION_L2BS9, 371 /* Level-2 Slice B 10th extractor section. */ 372 BCMI_KEYGEN_EXT_SECTION_L2BS10, 373 /* Level-2 Slice C 1st extractor section. */ 374 BCMI_KEYGEN_EXT_SECTION_L2CS1, 375 /* Level-2 Slice C 2nd extractor section. */ 376 BCMI_KEYGEN_EXT_SECTION_L2CS2, 377 /* Level-2 Slice C 3rd extractor section. */ 378 BCMI_KEYGEN_EXT_SECTION_L2CS3, 379 /* Level-2 Slice C 4th extractor section. */ 380 BCMI_KEYGEN_EXT_SECTION_L2CS4, 381 /* Level-2 Slice C 5th extractor section. */ 382 BCMI_KEYGEN_EXT_SECTION_L2CS5, 383 /* Level-2 Slice C 6th extractor section. */ 384 BCMI_KEYGEN_EXT_SECTION_L2CS6, 385 /* Level-2 Slice C 7th extractor section. */ 386 BCMI_KEYGEN_EXT_SECTION_L2CS7, 387 /* Level-2 Slice C 8th extractor section. */ 388 BCMI_KEYGEN_EXT_SECTION_L2CS8, 389 /* Level-2 Slice C 9th extractor section. */ 390 BCMI_KEYGEN_EXT_SECTION_L2CS9, 391 /* Level-2 Slice C 10th extractor section. */ 392 BCMI_KEYGEN_EXT_SECTION_L2CS10, 393 /* Level-3 Slice A 1st extractor section. */ 394 BCMI_KEYGEN_EXT_SECTION_L3AS1, 395 /* Level-3 Slice A 2nd extractor section. */ 396 BCMI_KEYGEN_EXT_SECTION_L3AS2, 397 /* Level-3 Slice A 3rd extractor section. */ 398 BCMI_KEYGEN_EXT_SECTION_L3AS3, 399 /* Level-3 Slice A 4th extractor section. */ 400 BCMI_KEYGEN_EXT_SECTION_L3AS4, 401 /* Level-3 Slice A 5th extractor section. */ 402 BCMI_KEYGEN_EXT_SECTION_L3AS5, 403 /* Level-3 Slice A 6th extractor section. */ 404 BCMI_KEYGEN_EXT_SECTION_L3AS6, 405 /* Level-3 Slice A 7th extractor section. */ 406 BCMI_KEYGEN_EXT_SECTION_L3AS7, 407 /* Level-3 Slice A 8th extractor section. */ 408 BCMI_KEYGEN_EXT_SECTION_L3AS8, 409 /* Level-3 Slice A 9th extractor section. */ 410 BCMI_KEYGEN_EXT_SECTION_L3AS9, 411 /* Level-3 Slice A 10th extractor section. */ 412 BCMI_KEYGEN_EXT_SECTION_L3AS10, 413 /* Level-3 Slice B 1st extractor section. */ 414 BCMI_KEYGEN_EXT_SECTION_L3BS1, 415 /* Level-3 Slice B 2nd extractor section. */ 416 BCMI_KEYGEN_EXT_SECTION_L3BS2, 417 /* Level-3 Slice B 3rd extractor section. */ 418 BCMI_KEYGEN_EXT_SECTION_L3BS3, 419 /* Level-3 Slice B 4th extractor section. */ 420 BCMI_KEYGEN_EXT_SECTION_L3BS4, 421 /* Level-3 Slice B 5th extractor section. */ 422 BCMI_KEYGEN_EXT_SECTION_L3BS5, 423 /* Level-3 Slice B 6th extractor section. */ 424 BCMI_KEYGEN_EXT_SECTION_L3BS6, 425 /* Level-3 Slice B 7th extractor section. */ 426 BCMI_KEYGEN_EXT_SECTION_L3BS7, 427 /* Level-3 Slice B 8th extractor section. */ 428 BCMI_KEYGEN_EXT_SECTION_L3BS8, 429 /* Level-3 Slice B 9th extractor section. */ 430 BCMI_KEYGEN_EXT_SECTION_L3BS9, 431 /* Level-3 Slice B 10th extractor section. */ 432 BCMI_KEYGEN_EXT_SECTION_L3BS10, 433 /* Level3 Slice C 1st extractor section. */ 434 BCMI_KEYGEN_EXT_SECTION_L3CS1, 435 /* Level-3 Slice C 2nd extractor section. */ 436 BCMI_KEYGEN_EXT_SECTION_L3CS2, 437 /* Level-3 Slice C 3rd extractor section. */ 438 BCMI_KEYGEN_EXT_SECTION_L3CS3, 439 /* Level-3 Slice C 4th extractor section. */ 440 BCMI_KEYGEN_EXT_SECTION_L3CS4, 441 /* Level-3 Slice C 5th extractor section. */ 442 BCMI_KEYGEN_EXT_SECTION_L3CS5, 443 /* Level-3 Slice C 6th extractor section. */ 444 BCMI_KEYGEN_EXT_SECTION_L3CS6, 445 /* Level-3 Slice C 7th extractor section. */ 446 BCMI_KEYGEN_EXT_SECTION_L3CS7, 447 /* Level-3 Slice C 8th extractor section. */ 448 BCMI_KEYGEN_EXT_SECTION_L3CS8, 449 /* Level-3 Slice C 9th extractor section. */ 450 BCMI_KEYGEN_EXT_SECTION_L3CS9, 451 /* Level-3 Slice C 10th extractor section. */ 452 BCMI_KEYGEN_EXT_SECTION_L3CS10, 453 /* Final Key Section. */ 454 BCMI_KEYGEN_EXT_SECTION_FK, 455 /* Slice A Final Key section. */ 456 BCMI_KEYGEN_EXT_SECTION_FKA, 457 /* Slice B Final Key section. */ 458 BCMI_KEYGEN_EXT_SECTION_FKB, 459 /* Slice C Final Key section. */ 460 BCMI_KEYGEN_EXT_SECTION_FKC, 461 /* Section for post Mux qualifier "Ingress Port bitmap" 462 * in the final key. */ 463 BCMI_KEYGEN_EXT_SECTION_IPBM, 464 /* Section for post Mux qualifier "DROP" 465 * in the final key. */ 466 BCMI_KEYGEN_EXT_SECTION_DROP, 467 /* Section for post Mux qualifier "NAT Needed" 468 * in the final key. */ 469 BCMI_KEYGEN_EXT_SECTION_NAT_NEEDED, 470 /* Section for post Mux qualifier "NAT destination realm Id" 471 * in the final key. */ 472 BCMI_KEYGEN_EXT_SECTION_NAT_DST_REALMID, 473 /* Section for post Mux qualifier "HIT status of first 474 * lookup in Exact Match rules" in the final key. 475 */ 476 BCMI_KEYGEN_EXT_SECTION_EM_FIRST_LOOKUP_HIT, 477 /* Section for post Mux qualifier "HIT status of second 478 * lookup in Exact Match rules" in the final key. 479 */ 480 BCMI_KEYGEN_EXT_SECTION_EM_SECOND_LOOKUP_HIT, 481 /* Section for post Mux qualifier "LSB 4 bits of 12 Class Id 482 * generated in first lookup in Exact Match rules" in the 483 * final key. 484 */ 485 BCMI_KEYGEN_EXT_SECTION_EM_FIRST_LOOKUP_CLASSID_BITS_0_3, 486 /* Section for post Mux qualifier "bits 4 - 7 of 12 Class Id 487 * generated in first lookup in Exact Match rules" in the 488 * final key. 489 */ 490 BCMI_KEYGEN_EXT_SECTION_EM_FIRST_LOOKUP_CLASSID_BITS_4_7, 491 /* Section for post Mux qualifier "bits 8 - 11 of 12 Class Id 492 * generated in first lookup in Exact Match rules" in the 493 * final key. 494 */ 495 BCMI_KEYGEN_EXT_SECTION_EM_SECOND_LOOKUP_CLASSID_BITS_8_11, 496 /* Section for post Mux qualifier "LSB 4 bits of 12 Class Id 497 * generated in second lookup in Exact Match rules" in the 498 * final key. 499 */ 500 BCMI_KEYGEN_EXT_SECTION_EM_SECOND_LOOKUP_CLASSID_BITS_0_3, 501 /* Section for post Mux qualifier "bits 4 - 7 of 12 Class Id 502 * generated in second lookup in Exact Match rules" in the 503 * final key. 504 */ 505 BCMI_KEYGEN_EXT_SECTION_EM_SECOND_LOOKUP_CLASSID_BITS_4_7, 506 /* Section for post Mux qualifier "bits 8 - 11 of 12 Class Id 507 * generated in second lookup in Exact Match rules" in the 508 * final key. 509 */ 510 BCMI_KEYGEN_EXT_SECTION_EM_FIRST_LOOKUP_CLASSID_BITS_8_11, 511 /* Section for post Mux qualifiers LSB 16 bits, sharing the 512 * source destination container 0, in the final key. 513 */ 514 BCMI_KEYGEN_EXT_SECTION_SRC_DST_CONTAINER_0, 515 /* Section for post Mux qualifiers LSB 16 bits, sharing the 516 * source destination container 1, in the final key. 517 */ 518 BCMI_KEYGEN_EXT_SECTION_SRC_DST_CONTAINER_1, 519 /* Section for post Mux qualifiers MSB bit, sharing the source 520 * destination container 0/1, in the final key. 521 */ 522 BCMI_KEYGEN_EXT_SECTION_SRC_DST_CONTAINERS_MSB, 523 /* Section for post Mux qualifier Lookup up status vectors 524 * LSB 4 bits in the final key. 525 */ 526 BCMI_KEYGEN_EXT_SECTION_LOOKUP_STATUS_VECTOR_BITS_0_3, 527 /* Section for post Mux qualifier Lookup up status vectors 528 * MSB 4 bits in the final key. 529 */ 530 BCMI_KEYGEN_EXT_SECTION_LOOKUP_STATUS_VECTOR_BITS_4_7, 531 /* Section for post Mux qualifiers, sharing the destination 532 * container 0(all 17 bits), in the final key. 533 */ 534 BCMI_KEYGEN_EXT_SECTION_DST_CONTAINER_A, 535 /* Section for post Mux qualifiers, sharing the destination 536 * container 1(all 17 bits), in the final key. 537 */ 538 BCMI_KEYGEN_EXT_SECTION_DST_CONTAINER_B, 539 /* Section for post Mux qualifier packet resolution 540 * in the final key. 541 */ 542 BCMI_KEYGEN_EXT_SECTION_PKT_RESOLUTION, 543 /* Section for post Mux qualifiers, sharing the class id 544 * container C, in the final key. 545 */ 546 BCMI_KEYGEN_EXT_SECTION_CLASS_ID_C, 547 /* Section for post Mux qualifiers, sharing the class id 548 * container D, in the final key. 549 */ 550 BCMI_KEYGEN_EXT_SECTION_CLASS_ID_D, 551 /* Section for post Mux qualifier internal priority 552 * in the final key. 553 */ 554 BCMI_KEYGEN_EXT_SECTION_INT_PRI, 555 /* Section for post Mux qualifier "drop reason codes in 556 * pipeline fed to IFP" in the final key. 557 */ 558 BCMI_KEYGEN_EXT_SECTION_IFP_DROP_VECTOR, 559 /* Section for post Mux qualifier "HiGiG header opcode" 560 * in the final key. 561 */ 562 BCMI_KEYGEN_EXT_SECTION_MH_OPCODE, 563 /* Section for post Mux qualifier "IP Type" 564 * in the final key. */ 565 BCMI_KEYGEN_EXT_SECTION_LTID, 566 /* Always Last. Not a usable value. */ 567 BCMI_KEYGEN_EXT_SECTION_COUNT 568 } bcmi_keygen_ext_section_t; 569 570 /* extractor control information */ 571 typedef struct bcmi_keygen_ext_ctrl_sel_info_s { 572 /* Extractor control type. */ 573 bcmi_keygen_ext_ctrl_sel_t ctrl_sel; 574 /* Selector value */ 575 uint8 ctrl_sel_val; 576 /* part to which this selector belongs to */ 577 uint8 part; 578 /* extractor hierarchy level. May not be required for all types 579 * of extractor controls. 580 */ 581 uint8 level; 582 /* Granularity of the extractor. May not be required for all types 583 * of extractor controls. 584 */ 585 uint8 gran; 586 /* Extractor number. May not be required for all types 587 * of extractor controls. 588 */ 589 uint16 ext_num; 590 } bcmi_keygen_ext_ctrl_sel_info_t; 591 592 /* Maximum number of extractor hirerachy levels on any device */ 593 #define BCMI_KEYGEN_EXT_LEVEL_COUNT 5 594 595 /* Single extractor configuration. */ 596 typedef struct bcmi_keygen_ext_cfg_s { 597 /* Run time field used to know whether the extractor 598 * is already used or not. By default it is set to zero. 599 */ 600 uint8 in_use; 601 /* Extractor Id which holds 4 tuple (part, level, granularity, extractor number) 602 * information of an extractor. 603 * 10 bits[0 - 9] = entractor number. 604 * 8 bits[10 - 17] = granularity. 605 * 4 bits[18 - 21] = hierarchy level. 606 * 2 bits[29 - 31] = part(If extractor database is for multi wide modes). 607 */ 608 uint32 ext_id; 609 /* Input section from which this extractor will extract fields. */ 610 bcmi_keygen_ext_section_t in_sec; 611 /* Output section to which this extractor will fed fields. */ 612 bcmi_keygen_ext_section_t out_sec; 613 /* Offset of the extracted field in the output section */ 614 uint16 offset; 615 /* Extractor attributes used to validate the extractor configuration 616 * for the given keygen mode and qualifiers that needs to be extracted. 617 */ 618 bcmi_keygen_ext_attrs_t ext_attrs; 619 620 /* Used internally by the keygen algorithm. */ 621 void *finfo; 622 } bcmi_keygen_ext_cfg_t; 623 624 /* Extractor section Configuration */ 625 typedef struct bcmi_keygen_ext_section_cfg_s { 626 /* Section Flags. Currently there is one flag created 627 * BCMI_KEYGEN_EXT_SECTION_PASS_THRU. 628 */ 629 uint32 flags; 630 /* Section identifier. */ 631 bcmi_keygen_ext_section_t sec; 632 /* Section size in bits */ 633 /* Parent section identifier */ 634 bcmi_keygen_ext_section_t parent_sec; 635 int drain_bits; 636 /* This field is used in runtime to avoid pushing more bits 637 * than drain_bits. 638 */ 639 int fill_bits; 640 /* Generally it is set to 1. If section has any extractor 641 * which can operate in multiple granularities, then this can 642 * be more than 1. 643 */ 644 uint16 ext_cfg_combinations; 645 } bcmi_keygen_ext_section_cfg_t; 646 647 /* Extractor database for a particular keygen mode */ 648 typedef struct bcmi_keygen_ext_cfg_db_s { 649 /* Total number of extractor levels */ 650 uint8 num_ext_levels; 651 /* keygen mode for which this extractor database is used. */ 652 bcmi_keygen_mode_t mode; 653 /* Extractors configuration in each extractor hierarchy. */ 654 bcmi_keygen_ext_cfg_t *ext_cfg[BCMI_KEYGEN_EXT_LEVEL_COUNT]; 655 /* Number of extractor configurations in each extractor hierarchy. */ 656 uint16 conf_size[BCMI_KEYGEN_EXT_LEVEL_COUNT]; 657 /* Extractor sections configuration */ 658 bcmi_keygen_ext_section_cfg_t *sec_cfg[BCMI_KEYGEN_EXT_SECTION_COUNT]; 659 /* Number of valid section configurations in this database. */ 660 uint16 num_sec; 661 } bcmi_keygen_ext_cfg_db_t; 662 663 /* 664 * Extractor ID construction macro. 665 */ 666 #define BCMI_KEYGEN_EXT_ID_CREATE(_p_, _l_, _g_, _e_num_, _e_id_) \ 667 (_e_id_) = (((_p_) << 28) | ((_l_) << 18) | ((_g_) << 10) | (_e_num_)) 668 669 /* 670 * Parse an Extractor ID and get the extractor level, granularity and 671 * extractor number information. 672 */ 673 #define BCMI_KEYGEN_EXT_ID_PARSE(_e_id_, _p_, _l_, _g_, _e_num_) \ 674 (_e_num_) = ((_e_id_) & 0x3ff); \ 675 (_g_) = (((_e_id_) >> 10) & 0xff); \ 676 (_l_) = (((_e_id_) >> 18) & 0xf); \ 677 (_p_) = (((_e_id_) >> 28) & 0x3) 678 679 #define BCMI_KEYGEN_EXT_ID_PART_GET(_ext_id_) (((_ext_id_) >> 28) & 0x3) 680 #define BCMI_KEYGEN_EXT_ID_GRAN_GET(_ext_id_) (((_ext_id_) >> 10) & 0xff) 681 #define BCMI_KEYGEN_EXT_ID_LEVEL_GET(_ext_id_) (((_ext_id_) >> 18) & 0xf) 682 #define BCMI_KEYGEN_EXT_ID_NUM_GET(_ext_id_) ((_ext_id_) & 0x3ff) 683 684 #define BCMI_KEYGEN_EXT_ID_GRAN_SET(_ext_id_, gran) \ 685 (_ext_id_) &= ~(0xFF << 10); \ 686 (_ext_id_) |= ((gran & 0xff) << 10) 687 688 #define BCMI_KEYGEN_EXT_ATTR_IDX_TO_GRAN(attr_idx, gran) \ 689 switch (attr_idx) { \ 690 case 0: \ 691 gran = 1; \ 692 break; \ 693 case 1: \ 694 gran = 2; \ 695 break; \ 696 case 2: \ 697 gran = 4; \ 698 break; \ 699 case 3: \ 700 gran = 8; \ 701 break; \ 702 case 4: \ 703 gran = 16; \ 704 break; \ 705 case 5: \ 706 gran = 32; \ 707 break; \ 708 default: \ 709 BCMI_KEYGEN_RETURN_VAL_EXIT(BCM_E_INTERNAL); \ 710 } 711 712 #define BCMI_KEYGEN_EXT_GRAN_TO_ATTR_IDX(gran, attr_idx) \ 713 switch (gran) { \ 714 case 1: \ 715 attr_idx = 0; \ 716 break; \ 717 case 2: \ 718 attr_idx = 1; \ 719 break; \ 720 case 4: \ 721 attr_idx = 2; \ 722 break; \ 723 case 8: \ 724 attr_idx = 3; \ 725 break; \ 726 case 16: \ 727 attr_idx = 4; \ 728 break; \ 729 case 32: \ 730 attr_idx = 5; \ 731 break; \ 732 default: \ 733 BCMI_KEYGEN_RETURN_VAL_EXIT(BCM_E_INTERNAL); \ 734 } 735 736 /* BCMI_KEYGEN_EXT_CFG_ADD macro needs the following declaration 737 * in any function that uses it. 738 */ 739 #define BCMI_KEYGEN_EXT_CFG_DECL \ 740 int _rv_; \ 741 int _ext_id_ = 0; \ 742 bcmi_keygen_ext_cfg_t _ext_cfg_ 743 744 /* 745 * Extractor hierarcy construction utility macro. 746 */ 747 #define BCMI_KEYGEN_EXT_CFG_ADD(_unit_, _ext_cfg_db_, \ 748 _p_, _l_, _g_, _e_num_, \ 749 _in_sec_, _out_sec_, \ 750 _offset_, _ext_attrs_) \ 751 do { \ 752 _rv_ = bcmi_keygen_ext_cfg_t_init(unit, &_ext_cfg_); \ 753 if (BCMI_KEYGEN_FAILURE(_rv_)) { \ 754 BCMI_KEYGEN_RETURN_VAL_EXIT(_rv_); \ 755 } \ 756 BCMI_KEYGEN_EXT_ID_CREATE(_p_, _l_, _g_, _e_num_, _ext_id_); \ 757 (_ext_cfg_).ext_id = (_ext_id_); \ 758 (_ext_cfg_).in_sec = (_in_sec_); \ 759 (_ext_cfg_).out_sec = (_out_sec_); \ 760 (_ext_cfg_).in_use = 0; \ 761 (_ext_cfg_).offset = (_offset_); \ 762 sal_memcpy(&((_ext_cfg_).ext_attrs), \ 763 (_ext_attrs_), \ 764 sizeof(bcmi_keygen_ext_attrs_t)); \ 765 _rv_ = bcmi_keygen_ext_cfg_insert((_unit_), (_l_), \ 766 &(_ext_cfg_), (_ext_cfg_db_)); \ 767 if (BCMI_KEYGEN_FAILURE(_rv_)) { \ 768 BCMI_KEYGEN_RETURN_VAL_EXIT(_rv_); \ 769 } \ 770 } while(0) 771 772 /* 773 * By default, sum of granularity of all extractors going out of the section 774 * is set to drain bits of a section. In some special scenarios (when extractor 775 * with programmable granularity is present in sections outgoing extractors), 776 * drain bits of section may be less than the sum calculated. In such cases, 777 * section drain bits needs to be overwritten with correct value after 778 * (strictly) initializing all the extractors using BCMI_KEYGEN_EXT_CFG_ADD. 779 */ 780 #define BCMI_KEYGEN_EXT_SECTION_DBITS_SET(_unit_, _ext_cfg_db_, \ 781 _sec_, _drain_bits_) \ 782 do { \ 783 _rv_ = bcmi_keygen_ext_sec_dbit_set((_unit_), (_sec_), \ 784 (_drain_bits_), (_ext_cfg_db_)); \ 785 if (BCMI_KEYGEN_FAILURE(_rv_)) { \ 786 BCMI_KEYGEN_RETURN_VAL_EXIT(_rv_); \ 787 } \ 788 } while(0) 789 790 /* 791 * By default, each section have parents section set to its own section. 792 * So each section and its parent section will have same drain bits. 793 * But in some cases, section will have its own drain bits and group of 794 * sections together should have drain bits less than the sum of all the 795 * sections drain bits. In order to manage such hierarchical levels of drain 796 * bits, a common parent section can be assigned to a group of sections. 797 */ 798 #define BCMI_KEYGEN_EXT_SECTION_PARENT_SET(_unit_, _ext_cfg_db_, \ 799 _sec_, _parent_sec_) \ 800 do { \ 801 _rv_ = bcmi_keygen_ext_sec_parent_set((_unit_), (_sec_), \ 802 (_parent_sec_), (_ext_cfg_db_)); \ 803 if (BCMI_KEYGEN_FAILURE(_rv_)) { \ 804 BCMI_KEYGEN_RETURN_VAL_EXIT(_rv_); \ 805 } \ 806 } while(0) 807 808 /* Max number of chunks a qualifer can have in any of 809 * its configurations of type bcmi_keygen_qual_cfg_t. 810 */ 811 #define BCMI_KEYGEN_QUAL_MAX_CHUNKS 32 812 813 /* Maximum offsets any qualifier can have in final key */ 814 #define BCMI_KEYGEN_QUAL_OFFSETS_MAX 64 815 816 /* */ 817 #define BCMI_KEYGEN_QUAL_BITMAP_MAX_WORDS 8 818 819 typedef enum bcmi_keygen_qual_flags_e { 820 /* Qualifier is configuration is post muxed. */ 821 BCMI_KEYGEN_QUAL_FLAGS_PMUX = 0, 822 /* Qualifier configuration is not valid if 823 * keygen is in mode "SINGLE". 824 */ 825 BCMI_KEYGEN_QUAL_FLAGS_NOT_IN_SINGLE, 826 /* Qualifier configuration is not valid if 827 * keygen is in mode "DBLINTRA". 828 */ 829 BCMI_KEYGEN_QUAL_FLAGS_NOT_IN_DBLINTRA, 830 /* Qualifier configuration is not valid for 831 * Exact Match. 832 */ 833 BCMI_KEYGEN_QUAL_FLAGS_NOT_IN_EM, 834 /* Always Last. Not a usable value. */ 835 BCMI_KEYGEN_QUAL_FLAGS_COUNT 836 } bcmi_keygen_qual_flags_t; 837 838 /* Qualifier flags set used in key generation algorithm to 839 * validate the qualifier configuration. 840 */ 841 typedef struct bcmi_keygen_qual_flags_bmp_s { 842 SHR_BITDCL w[_SHR_BITDCLSIZE(BCMI_KEYGEN_QUAL_FLAGS_COUNT)]; 843 } bcmi_keygen_qual_flags_bmp_t; 844 845 /* Qualifier chunk information. */ 846 typedef struct bcmi_keygen_qual_offset_cfg_s { 847 /* section in input bus from which this chunk is fed to extraction. */ 848 bcmi_keygen_ext_section_t section; 849 /* chunk number. For example , if a section has 10 chunks, 850 * then this field will be set to any one value from 0 to 9 which 851 * is appropriate to this chunk. 852 */ 853 uint16 sec_val; 854 /* Required number bits in this chunk for the qualifier this chunk 855 * information belongs to. This will be any value between 1 to ?size?. 856 */ 857 uint16 width; 858 /* start bit(w.r.t total width of the section) from where ?width? 859 * number of bits in this chunk are required for the qualifier. 860 */ 861 uint16 offset; 862 /* Size of the chunk. Generally all chunks in a section will 863 * have the same size. 864 */ 865 uint16 size; 866 } bcmi_keygen_qual_offset_cfg_t; 867 868 /* Qualifier configuration */ 869 typedef struct bcmi_keygen_qual_cfg_s { 870 /* keygen algorithm uses these flags to validate this configuration 871 * for the given keygen mode(bcmi_keygen_mode_t). 872 */ 873 bcmi_keygen_qual_flags_bmp_t qual_flags; 874 /* Qualifier control to be reserved in case keygen algorithm is using 875 * this qualifier configuration. 876 */ 877 bcmi_keygen_ext_ctrl_sel_t pri_ctrl_sel; 878 /* "ctrl_sel" should be set to this value in case this configuration is 879 * successfully used by keygen algorithm. 880 */ 881 uint16 pri_ctrl_sel_val; 882 /* Secondary control to be reserved for given primary ctrl 883 * Not applicable in keygen alogrithm. 884 */ 885 bcmi_keygen_ext_ctrl_sel_t sec_ctrl_sel; 886 /* "sec_ctrl_sel" should be set to this value. */ 887 uint16 sec_ctrl_sel_val; 888 /* Qualifer chunk information for different chunks belongs to this 889 * qualifier configuration. Chunks may either come from same section 890 * or from different sections in the input bus. 891 */ 892 bcmi_keygen_qual_offset_cfg_t e_params[BCMI_KEYGEN_QUAL_MAX_CHUNKS]; 893 /* number of valid elements in the e_params array. Valid values of this 894 * field ranges between 1 to BCMI_KEYGEN_QUAL_MAX_CHUNKS. 895 */ 896 uint8 num_chunks; 897 /* Size of all valid chunks together. */ 898 uint32 size; 899 900 uint8 update_count; 901 } bcmi_keygen_qual_cfg_t; 902 903 /* All possible qualifiers configurations of a single qualifier. */ 904 typedef struct bcmi_keygen_qual_cfg_info_s { 905 /* Qualifier Identifier. Keygen library uses qualifier identifiers 906 * created in field module. 907 */ 908 bcm_field_qualify_t qual; 909 /* Array of qualifier configurations of a qualifier. Most of the 910 * qualifiers have single configurations but some have more 911 * than one configuration to choose. 912 */ 913 bcmi_keygen_qual_cfg_t *qual_cfg_arr; 914 /* "qual_cfg_arr" size */ 915 uint8 num_qual_cfg; 916 } bcmi_keygen_qual_cfg_info_t; 917 918 /* Qualifier configuration information of all qualifiers supported 919 * on the device. 920 */ 921 typedef struct bcmi_keygen_qual_cfg_info_db_s { 922 /* Number of valid qualifiers in the database. This value is anywhere 923 * in between 1 to BCM_FIELD_QUALIFY_MAX. 924 */ 925 int num_quals; 926 /* Holds pointers to Qualifier Configuration information for 927 * each supported qualifier. If some qualifier is not supported 928 * on the device then it?s pointer is set to NULL. 929 */ 930 bcmi_keygen_qual_cfg_info_t *qual_cfg_info[BCM_FIELD_QUALIFY_MAX]; 931 } bcmi_keygen_qual_cfg_info_db_t; 932 933 /* BCMI_KEYGEN_QUAL_CFG_XXX macros require the following declaration in any 934 * function which uses them. 935 */ 936 #define BCMI_KEYGEN_QUAL_CFG_DECL \ 937 int _rv_; \ 938 bcmi_keygen_qual_cfg_t _qual_cfg_ 939 940 /* To re-init the bcmi_keygen_qual_cfg_t structure. */ 941 #define BCMI_KEYGEN_QUAL_CFG_INIT(_unit_) \ 942 _rv_ = bcmi_keygen_qual_cfg_t_init(_unit_, &(_qual_cfg_)); \ 943 if (BCMI_KEYGEN_FAILURE(_rv_)) { \ 944 BCMI_KEYGEN_RETURN_VAL_EXIT(_rv_); \ 945 } 946 947 /* To update the selectors, offset and width of the 948 * bcmi_keygen_qual_cfg_t variable based on the index. 949 */ 950 #define BCMI_KEYGEN_QUAL_CFG_OFFSET_ADD(_index_, \ 951 _section_, \ 952 _sec_val_, \ 953 _offset_, \ 954 _width_) \ 955 (_qual_cfg_).e_params[_index_].section = (_section_); \ 956 (_qual_cfg_).e_params[_index_].sec_val = (_sec_val_); \ 957 (_qual_cfg_).e_params[_index_].offset = (_offset_); \ 958 (_qual_cfg_).e_params[_index_].width = (_width_); \ 959 (_qual_cfg_).num_chunks++; 960 961 /* To update the control selectors and its value in the 962 * bcmi_keygen_qual_cfg_t structure. 963 */ 964 #define BCMI_KEYGEN_QUAL_CFG_PRI_CTRL_SEL_ADD(_ctrl_sel_, _ctrl_sel_val_) \ 965 (_qual_cfg_).pri_ctrl_sel = (_ctrl_sel_); \ 966 (_qual_cfg_).pri_ctrl_sel_val = (_ctrl_sel_val_); \ 967 968 /* To update the secondary control selectors and its value. */ 969 #define BCMI_KEYGEN_QUAL_CFG_SEC_CTRL_SEL_ADD(_ctrl_sel_, _ctrl_sel_val_) \ 970 (_qual_cfg_).sec_ctrl_sel = (_ctrl_sel_); \ 971 (_qual_cfg_).sec_ctrl_sel_val = (_ctrl_sel_val_); \ 972 973 /* To update the control selectors and its value in the 974 * bcmi_keygen_qual_cfg_t structure. 975 */ 976 #define BCMI_KEYGEN_QUAL_CFG_INSERT(_unit_, _qual_cfg_info_db_, \ 977 _qual_id_, _qual_flags_) \ 978 sal_memcpy(&((_qual_cfg_).qual_flags), \ 979 &(_qual_flags_), \ 980 sizeof(bcmi_keygen_qual_flags_bmp_t)); \ 981 _rv_ = bcmi_keygen_qual_cfg_insert((_unit_), \ 982 (_qual_id_), \ 983 &(_qual_cfg_), \ 984 (_qual_cfg_info_db_)); \ 985 if (BCMI_KEYGEN_FAILURE(_rv_)) { \ 986 BCMI_KEYGEN_RETURN_VAL_EXIT(_rv_); \ 987 } 988 989 /* Qualifier flag to use new finfo while converting this qualifier 990 * bitmap to finfo. Default behavior of algorithm is to search in 991 * assigned finfo for given section/sec_val/pri_ctrl_sel/ 992 * pri_ctrl_sel_val. If a match is found, that finfo is updated with 993 * bitmap of this new qualifer. This flag override this default behavior 994 * and valid only for flowtracker style extractors. Using this flag 995 * in ifp style extractors will give unexpected results. 996 */ 997 #define BCMI_KEYGEN_QUAL_F_USE_FINFO_NEW (1 << 0) 998 999 /* Qualifier flags to use extractor of granularity 16 at level 2 1000 * to extract this qualifier bitmap. Default behavior is to loop 1001 * through all extractors at given level and try to extract all 1002 * required bit in given finfo using extractors of any granularity 1003 * available at given section in given level. This flags override 1004 * this behavior and valid only for flowtracker style extractors. 1005 * To use this flag, 1006 * a. Qualifier size must be equal or less than 16 bits. 1007 * 1008 * Qual flags BCMI_KEYGEN_QUAL_F_USE_FINFO_NEW can also be 1009 * combined with this flag. Using this flag in ifp style extractors 1010 * will give unexpected results. 1011 */ 1012 #define BCMI_KEYGEN_QUAL_F_USE_L2_EXT_GRAN16 (1 << 1) 1013 1014 /* Qualifier flags to use extractor of granularity 8 at level 2 1015 * to extract this qualifier bitmap. Default behavior is to loop 1016 * through all extractors at given level and try to extract all 1017 * required bit in given finfo using extractors of any granularity 1018 * available at given section in given level. This flags override 1019 * this behavior and valid only for flowtracker style extractors. 1020 * To use this flag, 1021 * a. Qualifier size must be less than 8 bits. 1022 * b. Either or both of qual flag BCMI_KEYGEN_QUAL_F_USE_FINFO_NEW 1023 * and BCMI_KEYGEN_QUAL_F_USE_L2_EXT_GRAN16 can be used. 1024 * c. DO NOT use only this flag alone. It might fail to allocate 1025 * extractors even if extraction is possible. 1026 * 1027 * Using this flag in ifp style extractors will give unexpected 1028 * results. 1029 */ 1030 #define BCMI_KEYGEN_QUAL_F_USE_L2_EXT_GRAN8 (1 << 2) 1031 1032 /* Qualifier has to be extrctaed to modulo 32 offsets in the final 1033 * key.In general keygen algorithm doesnot give any preference to 1034 * any qualifier while placing it in the final key. But this flag 1035 * ovverrides this behaviour. 1036 */ 1037 #define BCMI_KEYGEN_QUAL_F_EXTRACT_TO_MODULO_32_OFFSET (1 << 3) 1038 1039 /* This flag will make sure that all input bus containers related to 1040 * a qualifier are extrcted by consecutive muxers of same part of the 1041 * muxer hierarchy. 1042 */ 1043 #define BCMI_KEYGEN_QUAL_F_STICKY_CONTAINERS (1 << 4) 1044 1045 /* Qualifier information */ 1046 typedef struct bcmi_keygen_qual_info_s { 1047 /* Qualifier flags */ 1048 uint32 flags; 1049 /* Need to extract all bits in the qualifier or some? */ 1050 uint8 partial; 1051 /* Qualifier Id. */ 1052 bcm_field_qualify_t qual_id; 1053 /* bits required if partial is set to TRUE. otherwise, 1054 * ignore this field. 1055 */ 1056 uint32 bitmap[BCMI_KEYGEN_QUAL_BITMAP_MAX_WORDS]; 1057 } bcmi_keygen_qual_info_t; 1058 1059 /* Offset and width information of a qualifer in final key of a given part */ 1060 typedef struct bcmi_keygen_qual_offset_s { 1061 /* Number of Offsets. */ 1062 uint8 num_offsets; 1063 /* offset. */ 1064 uint16 offset[BCMI_KEYGEN_QUAL_OFFSETS_MAX]; 1065 /* width from the corresponding offset. */ 1066 uint8 width[BCMI_KEYGEN_QUAL_OFFSETS_MAX]; 1067 } bcmi_keygen_qual_offset_t; 1068 1069 /* All qualifiers offset and width information in final key of a given part */ 1070 typedef struct bcmi_keygen_qual_offset_info_s { 1071 /* Array qualifiers present in the part given */ 1072 bcm_field_qualify_t *qid_arr; 1073 /* offset and width information corresponding to qualifiers in qid_arr. */ 1074 bcmi_keygen_qual_offset_t *offset_arr; 1075 /* Size of the qid_arr and offset_arr arrays */ 1076 uint16 size; 1077 } bcmi_keygen_qual_offset_info_t; 1078 1079 /* Validate whether extractors can be allocated for all 1080 * qualifiers in the given keygen mode. Dont need to generate 1081 * the offsets of qualifiers in the final key. 1082 */ 1083 #define BCMI_KEYGEN_CFG_FLAGS_VALIDATE_ONLY (1 << 0) 1084 /* Keygen algorithm has generated operation information for the given 1085 * keygen configuration but applicatipon wants to add more configuration 1086 * (like adding more qualifiers) to it and keygen algorithm has regenerate 1087 * the operational information for the newly added configuration. During 1088 * this process keygen algorithm should not use resources(like multiplexers) 1089 * that are in use for old keygen configuration. 1090 */ 1091 #define BCMI_KEYGEN_CFG_FLAGS_QSET_UPDATE (1 << 1) 1092 1093 /* When num_parts in keygen configuration is more than one, then input bus 1094 * containers corresponding to all qualifiers are distributed to all parts 1095 * symmetrically. That means if two 16 bit container needs to be extracted 1096 * from two parts, first container is extracted from part one and second one 1097 * is extracted from part2 instead of extracting both containers from first 1098 * part. If this flag is set, then all muxers are used in part one first and 1099 * then go to 2nd part, 3rd part and so on. 1100 */ 1101 #define BCMI_KEYGEN_CFG_FLAGS_SERIAL_MUX_ALLOC (1 << 2) 1102 1103 /* Keygen algorithm builds list of containers corresponding to all 1104 * qualifiers and sort the list in the descending order based on the 1105 * container size. This flag will voids the sorting of the containers. 1106 * This is the requirement for FlowTracker groups in some cases. 1107 */ 1108 #define BCMI_KEYGEN_CFG_FLAGS_SERIAL_QUAL_CONTAINERS (1 << 3) 1109 1110 /* Keygen Configuration to be used to allocate multiplexers */ 1111 typedef struct bcmi_keygen_cfg_s { 1112 /* Flags(BCMI_KEYGEN_CFG_FLAGS_XXX). */ 1113 uint32 flags; 1114 /* keygen mode */ 1115 bcmi_keygen_mode_t mode; 1116 /* Information about the qualifiers in the final key */ 1117 bcmi_keygen_qual_info_t *qual_info_arr; 1118 /* size of qual_info_arr array */ 1119 uint8 qual_info_count; 1120 /* Number of parts. Generally it depends on keygen mode. 1121 * 1 in case of keygen mode SINGLE, 2 in case of DBLINTRA, 1122 * 3 in case of TRIPLE. But there are other modes as well for 1123 * which num parts cannot be assumed by keygen library so is 1124 * the reason for creation of this field. 1125 */ 1126 uint8 num_parts; 1127 /* Qualifiers configuration information database */ 1128 bcmi_keygen_qual_cfg_info_db_t *qual_cfg_info_db; 1129 /* Extractor configuration database. Applications may have multiple 1130 * extractor databases but need to pass the right pointer for keygen mode. 1131 */ 1132 bcmi_keygen_ext_cfg_db_t *ext_cfg_db; 1133 /* Different controls generated by the keygen algorithm. This is required 1134 * if application need to update the existing QSET. 1135 */ 1136 bcmi_keygen_ext_ctrl_sel_info_t *ext_ctrl_sel_info; 1137 /* Size of ext_ctrl_sel_info array */ 1138 uint16 ext_ctrl_sel_info_count; 1139 } bcmi_keygen_cfg_t; 1140 1141 /* Operational data generated by keygen algorithm */ 1142 typedef struct bcmi_keygen_oper_s { 1143 /* Final key offset information of each qualifier specified 1144 * in keygen_cfg. 1145 */ 1146 bcmi_keygen_qual_offset_info_t *qual_offset_info; 1147 /* Different controls generated by the keygen algorithm. 1148 * Calling module should push this information to h/w. 1149 */ 1150 bcmi_keygen_ext_ctrl_sel_info_t *ext_ctrl_sel_info; 1151 /* Size of ext_ctrl_sel_info array */ 1152 uint16 ext_ctrl_sel_info_count; 1153 } bcmi_keygen_oper_t; 1154 1155 extern int 1156 bcmi_keygen_cfg_process(int unit, 1157 bcmi_keygen_cfg_t *keygen_cfg, 1158 bcmi_keygen_oper_t *keygen_oper); 1159 extern int 1160 bcmi_keygen_qual_cfg_t_init(int unit, 1161 bcmi_keygen_qual_cfg_t *qual_cfg); 1162 extern int 1163 bcmi_keygen_qual_cfg_insert(int unit, 1164 bcm_field_qualify_t qual_id, 1165 bcmi_keygen_qual_cfg_t *new_qual_cfg, 1166 bcmi_keygen_qual_cfg_info_db_t *qual_cfg_info_db); 1167 extern int 1168 bcmi_keygen_ext_cfg_insert(int unit, 1169 uint8 level, 1170 bcmi_keygen_ext_cfg_t *ext_cfg, 1171 bcmi_keygen_ext_cfg_db_t *ext_cfg_db); 1172 extern int 1173 bcmi_keygen_ext_cfg_t_init(int unit, 1174 bcmi_keygen_ext_cfg_t *ext_cfg); 1175 1176 extern int 1177 bcmi_keygen_ext_cfg_db_free(int unit, bcmi_keygen_ext_cfg_db_t *ext_cfg_db); 1178 1179 extern int 1180 bcmi_keygen_oper_free(int unit, 1181 uint16 num_parts, 1182 bcmi_keygen_oper_t *keygen_oper); 1183 extern int 1184 bcmi_keygen_keysize_get(int unit, 1185 bcmi_keygen_cfg_t *keygen_cfg, 1186 uint16 *rkey_size); 1187 1188 /* 1189 * Overwrite drain bits for given section. 1190 */ 1191 extern int 1192 bcmi_keygen_ext_sec_dbit_set(int unit, 1193 bcmi_keygen_ext_section_t sec, 1194 int drain_bits, 1195 bcmi_keygen_ext_cfg_db_t *ext_cfg_db); 1196 1197 /* 1198 * Overwrite parent section for given section. 1199 */ 1200 extern int 1201 bcmi_keygen_ext_sec_parent_set(int unit, 1202 bcmi_keygen_ext_section_t sec, 1203 bcmi_keygen_ext_section_t parent_sec, 1204 bcmi_keygen_ext_cfg_db_t *ext_cfg_db); 1205 1206 /* 1207 * Free Extractor config database. 1208 */ 1209 extern int 1210 bcmi_keygen_ext_cfg_db_cleanup(int unit, 1211 bcmi_keygen_ext_cfg_db_t *ext_cfg_db); 1212 1213 /* 1214 * Free Qualifier config database. 1215 */ 1216 extern int 1217 bcmi_keygen_qual_cfg_info_db_free(int unit, 1218 bcmi_keygen_qual_cfg_info_db_t *qual_cfg_info_db); 1219 1220 /* 1221 * Max size of qualifier 1222 */ 1223 extern int 1224 bcmi_keygen_qual_cfg_max_size_get(int unit, 1225 bcmi_keygen_cfg_t *keygen_cfg, 1226 bcm_field_qualify_t qual_id, 1227 uint16 *qual_cfg_max_size); 1228 1229 #endif 1230