bcmgene.h (11260B)
1 /*! \file bcmgene_db.h 2 * 3 * Broadcom Generic Extensible NPL Encapsulation (GENE) header file. 4 * This file contains GENE definitions internal to the BCM library. 5 */ 6 /* 7 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 8 * 9 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 10 */ 11 12 #ifndef BCMINT_LTSW_GENE_H 13 #define BCMINT_LTSW_GENE_H 14 15 #include <bcm_int/ltsw/chip/bcmgene_db.h> 16 #include <bcm_int/ltsw/chip/bcmgene_editor.h> 17 /*! 18 * \brief Get the GENE database for a device. 19 * 20 * \param [in] unit Unit Number. 21 * 22 * \retval !NULL Success. 23 * \retval NULL Failure. 24 */ 25 extern bcmgene_db_t * 26 bcm56780_a0_gene_db_get(int unit); 27 28 /*! 29 * \brief GENE extractor. 30 * 31 * \param [in] unit Unit Number. 32 * \param [in] gene_name GENE name. 33 * 34 * \retval !NULL Success. 35 * \retval NULL Failure. 36 */ 37 extern bcmgene_desc_t * 38 bcm56780_a0_gene_extractor( 39 int unit, 40 const char *gene_name); 41 42 /*! 43 * \brief Add GENE features into device-based feature list. 44 * 45 * \param [in] unit Unit Number. 46 * 47 * \retval SHR_E_NONE Success. 48 * \retval !SHR_E_NONE Failure. 49 */ 50 extern int 51 bcm56780_a0_gene_feature_init(int unit); 52 53 /*! 54 * \brief Add GENE sub-features by functionality. 55 * 56 * \param [in] unit Unit Number. 57 * \param [in] gene The GENE descriptor. 58 * \param [in] func The GENE functionality. 59 * \param [out] sub_f The GENE sub-features. 60 * 61 * \retval SHR_E_NONE Success. 62 * \retval !SHR_E_NONE Failure. 63 */ 64 extern int 65 bcm56780_a0_gene_sub_feature_get( 66 int unit, 67 bcmgene_desc_t *gene, 68 uint32_t func, 69 uint32_t *sub_f); 70 71 /*! 72 * \brief Targeting the GENE table into GENE handler. 73 * 74 * \param [in] unit Unit Number. 75 * \param [in] gene The GENE descriptor. 76 * \param [in] func The GENE functionality. 77 * \param [in] sub_f The GENE sub-features. 78 * \param [out] hndl The GENE handler. 79 * 80 * \retval SHR_E_NONE Success. 81 * \retval !SHR_E_NONE Failure. 82 */ 83 extern int 84 bcm56780_a0_gene_targeting( 85 int unit, 86 bcmgene_desc_t *gene, 87 uint32_t func, 88 uint32_t sub_f, 89 bcmgene_handle_t *hndl); 90 91 /*! 92 * \brief Create the GENE batch handler. 93 * 94 * \param [in/out] hndl The GENE handler. 95 * 96 * \retval SHR_E_NONE Success. 97 * \retval !SHR_E_NONE Failure. 98 */ 99 extern int 100 bcm56780_a0_gene_batch_handle_create(bcmgene_handle_t *hndl); 101 102 /*! 103 * \brief Destroy the GENE batch handler. 104 * 105 * \param [in] hndl The GENE handler. 106 * 107 * \retval SHR_E_NONE Success. 108 * \retval !SHR_E_NONE Failure. 109 */ 110 extern int 111 bcm56780_a0_gene_batch_handle_destroy(bcmgene_handle_t *hndl); 112 113 /*! 114 * \brief Create the GENE handler. 115 * 116 * \param [in/out] hndl The GENE handler. 117 * 118 * \retval SHR_E_NONE Success. 119 * \retval !SHR_E_NONE Failure. 120 */ 121 extern int 122 bcm56780_a0_gene_handle_create(bcmgene_handle_t *hndl); 123 124 /*! 125 * \brief Destroy the GENE handler. 126 * 127 * \param [in] hndl The GENE handler. 128 * 129 * \retval SHR_E_NONE Success. 130 * \retval !SHR_E_NONE Failure. 131 */ 132 extern int 133 bcm56780_a0_gene_handle_destroy(bcmgene_handle_t *hndl); 134 135 /*! 136 * \brief Validate the GENE tag: blk and offset. 137 * 138 * \param [in] hndl The GENE handler. 139 * \param [in] blk The GENE block. 140 * \param [in] offset The GENE offset in block. 141 * 142 * \retval SHR_E_NONE Success. 143 * \retval !SHR_E_NONE Failure. 144 */ 145 extern int 146 bcm56780_a0_gene_validate_tag( 147 bcmgene_handle_t *hndl, 148 int blk, 149 int offset); 150 151 /*! 152 * \brief Validate the GENE field and input value. 153 * 154 * \param [in] hndl The GENE handler. 155 * \param [in] blk The GENE block. 156 * \param [in] offset The GENE offset in block. 157 * \param [in] value The input value of the GENE field. 158 * 159 * \retval SHR_E_NONE Success. 160 * \retval !SHR_E_NONE Failure. 161 */ 162 extern int 163 bcm56780_a0_gene_validate_field( 164 bcmgene_handle_t *hndl, 165 int blk, 166 int offset, 167 uint64_t value); 168 169 /*! 170 * \brief Validate the GENE field of an array and input value. 171 * 172 * \param [in] hndl The GENE handler. 173 * \param [in] blk The GENE block. 174 * \param [in] offset The GENE offset in block. 175 * \param [in] index The index in the GENE Array. 176 * \param [in] value The input value of the GENE field. 177 * 178 * \retval SHR_E_NONE Success. 179 * \retval !SHR_E_NONE Failure. 180 */ 181 extern int 182 bcm56780_a0_gene_validate_field_array( 183 bcmgene_handle_t *hndl, 184 int blk, 185 int offset, 186 int index, 187 uint64_t value); 188 189 /*! 190 * \brief Fill the flags in the GENE handler. 191 * 192 * \param [in] hndl The GENE handler. 193 * \param [in] flags The GENE handler flags. 194 * 195 * \retval SHR_E_NONE Success. 196 * \retval !SHR_E_NONE Failure. 197 */ 198 extern int 199 bcm56780_a0_gene_fill_flags( 200 bcmgene_handle_t *hndl, 201 uint32_t flags); 202 203 /*! 204 * \brief Fill the key of the GENE table. 205 * 206 * \param [in] hndl The GENE handler. 207 * \param [in] index The key index of the GENE table. 208 * \param [in] value The input value. 209 * 210 * \retval SHR_E_NONE Success. 211 * \retval !SHR_E_NONE Failure. 212 */ 213 extern int 214 bcm56780_a0_gene_fill_key( 215 bcmgene_handle_t *hndl, 216 int index, 217 uint64_t value); 218 219 /*! 220 * \brief Fill the field of the GENE table. 221 * 222 * \param [in] hndl The GENE handler. 223 * \param [in] blk The GENE block. 224 * \param [in] offset The GENE offset in block. 225 * \param [in] value The input value. 226 * 227 * \retval SHR_E_NONE Success. 228 * \retval !SHR_E_NONE Failure. 229 */ 230 extern int 231 bcm56780_a0_gene_fill_field( 232 bcmgene_handle_t *hndl, 233 int blk, 234 int offset, 235 uint64_t value); 236 237 /*! 238 * \brief Fill the field array of the GENE table. 239 * 240 * \param [in] hndl The GENE handler. 241 * \param [in] blk The GENE block. 242 * \param [in] offset The GENE offset in block. 243 * \param [in] index The start index of the GENE field. 244 * \param [in] value The input value array. 245 * \param [in] count The array count. 246 * 247 * \retval SHR_E_NONE Success. 248 * \retval !SHR_E_NONE Failure. 249 */ 250 extern int 251 bcm56780_a0_gene_fill_field_array( 252 bcmgene_handle_t *hndl, 253 int blk, 254 int offset, 255 uint32_t index, 256 uint64_t *value, 257 uint32_t count); 258 259 /*! 260 * \brief Fill the callback function of the GENE table. 261 * 262 * \param [in] hndl The GENE handler. 263 * \param [in] cb The callback function. 264 * 265 * \retval SHR_E_NONE Success. 266 * \retval !SHR_E_NONE Failure. 267 */ 268 extern int 269 bcm56780_a0_gene_fill_callback( 270 bcmgene_handle_t *hndl, 271 int (*cb)(bcmgene_handle_t *hndl, void *user_data)); 272 273 /*! 274 * \brief Fill the LT handler priority. 275 * 276 * \param [in] hndl The GENE handler. 277 * \param [in] priority The handler priority. 278 * 279 * \retval SHR_E_NONE Success. 280 * \retval !SHR_E_NONE Failure. 281 */ 282 extern int 283 bcm56780_a0_gene_fill_priority( 284 bcmgene_handle_t *hndl, 285 int priority); 286 287 /*! 288 * \brief Fill the LT handler opcode. 289 * 290 * \param [in] hndl The GENE handler. 291 * \param [in] opcode The handler opcode. 292 * 293 * \retval SHR_E_NONE Success. 294 * \retval !SHR_E_NONE Failure. 295 */ 296 extern int 297 bcm56780_a0_gene_fill_opcode( 298 bcmgene_handle_t *hndl, 299 int opcode); 300 301 /*! 302 * \brief Fill the LT handler into batch handler. 303 * 304 * \param [in] hndl The GENE handler. 305 * 306 * \retval SHR_E_NONE Success. 307 * \retval !SHR_E_NONE Failure. 308 */ 309 extern int 310 bcm56780_a0_gene_fill_batch_handle(bcmgene_handle_t *hndl); 311 312 /*! 313 * \brief Commit the LT entry. 314 * 315 * \param [in] hndl The GENE handler. 316 * 317 * \retval SHR_E_NONE Success. 318 * \retval !SHR_E_NONE Failure. 319 */ 320 extern int 321 bcm56780_a0_gene_commit(bcmgene_handle_t *hndl); 322 323 /*! 324 * \brief The LT entry commit done. 325 * 326 * \param [in] hndl The GENE handler. 327 * 328 * \retval SHR_E_NONE Success. 329 * \retval !SHR_E_NONE Failure. 330 */ 331 extern int 332 bcm56780_a0_gene_commit_done(bcmgene_handle_t *hndl); 333 334 /*! 335 * \brief Commit the batch LT entries. 336 * 337 * \param [in] hndl The GENE handler. 338 * 339 * \retval SHR_E_NONE Success. 340 * \retval !SHR_E_NONE Failure. 341 */ 342 extern int 343 bcm56780_a0_gene_commit_batch(bcmgene_handle_t *hndl); 344 345 /*! 346 * \brief Edit the LT entry. 347 * 348 * \param [in] hndl The GENE handler. 349 * 350 * \retval SHR_E_NONE Success. 351 * \retval !SHR_E_NONE Failure. 352 */ 353 extern int 354 bcm56780_a0_gene_edit(bcmgene_handle_t *hndl); 355 356 /*! 357 * \brief Unset the LT entry. 358 * 359 * \param [in] hndl The GENE handler. 360 * 361 * \retval SHR_E_NONE Success. 362 * \retval !SHR_E_NONE Failure. 363 */ 364 extern int 365 bcm56780_a0_gene_unset(bcmgene_handle_t *hndl); 366 367 /*! 368 * \brief Lookup the LT entry. 369 * 370 * \param [in] hndl The GENE handler. 371 * 372 * \retval SHR_E_NONE Success. 373 * \retval !SHR_E_NONE Failure. 374 */ 375 extern int 376 bcm56780_a0_gene_lookup(bcmgene_handle_t *hndl); 377 378 /*! 379 * \brief Lookup the key of LT entry. 380 * 381 * \param [in] hndl The GENE handler. 382 * \param [in] index The key index of the GENE table. 383 * \param [out] value The field value. 384 * 385 * \retval SHR_E_NONE Success. 386 * \retval !SHR_E_NONE Failure. 387 */ 388 extern int 389 bcm56780_a0_gene_lookup_key( 390 bcmgene_handle_t *hndl, 391 int index, 392 uint64_t *value); 393 394 /*! 395 * \brief Lookup the field value of the GENE table. 396 * 397 * \param [in] hndl The GENE handler. 398 * \param [in] blk The GENE block. 399 * \param [in] offset The GENE offset in block. 400 * \param [out] value The field value. 401 * 402 * \retval SHR_E_NONE Success. 403 * \retval !SHR_E_NONE Failure. 404 */ 405 extern int 406 bcm56780_a0_gene_lookup_field( 407 bcmgene_handle_t *hndl, 408 int blk, 409 int offset, 410 uint64_t *value); 411 412 /*! 413 * \brief Lookup the field array values of the GENE table. 414 * 415 * \param [in] hndl The GENE handler. 416 * \param [in] blk The GENE block. 417 * \param [in] offset The GENE offset in block. 418 * \param [in] index The start field index of the GENE table. 419 * \param [out] value The field value. 420 * \param [in] count The array count. 421 * \param [out] depth The array depth. 422 * 423 * \retval SHR_E_NONE Success. 424 * \retval !SHR_E_NONE Failure. 425 */ 426 extern int 427 bcm56780_a0_gene_lookup_field_array( 428 bcmgene_handle_t *hndl, 429 int blk, 430 int offset, 431 uint32_t index, 432 uint64_t *value, 433 uint32_t count, 434 uint32_t *depth); 435 436 /*! 437 * \brief The LT entry lookup done. 438 * 439 * \param [in] hndl The GENE handler. 440 * 441 * \retval SHR_E_NONE Success. 442 * \retval !SHR_E_NONE Failure. 443 */ 444 extern int 445 bcm56780_a0_gene_lookup_done(bcmgene_handle_t *hndl); 446 447 /*! 448 * \brief The LT entry lookup done. 449 * 450 * \param [in] hndl The GENE handler. 451 * \param [in] user_data The input of user data. 452 * 453 * \retval SHR_E_NONE Success. 454 * \retval !SHR_E_NONE Failure. 455 */ 456 extern int 457 bcm56780_a0_gene_traverse( 458 bcmgene_handle_t *hndl, 459 void *user_data); 460 461 /*! 462 * \brief Clear the GENE tables. 463 * 464 * \param [in] unit The unit number. 465 * \param [in] gene The GENE descriptor. 466 * 467 * \retval SHR_E_NONE Success. 468 * \retval !SHR_E_NONE Failure. 469 */ 470 extern int 471 bcm56780_a0_gene_clear( 472 int unit, 473 bcmgene_desc_t *gene); 474 475 /*! 476 * \brief Free handlers and return errors if rv is failed. 477 * 478 * \param [in] hndl The GENE handler. 479 * \param [in] rv The return value. 480 * 481 * \retval SHR_E_NONE Success. 482 * \retval !SHR_E_NONE Failure. 483 */ 484 extern int 485 bcm56780_a0_gene_error_return( 486 bcmgene_handle_t *hndl, 487 int rv); 488 489 /*! 490 * \brief The GENE function traverse interface. 491 * 492 * \param [in] gene The GENE descriptor. 493 * \param [in] func The GENE functionality. 494 * \param [in] hndl The GENE handler. 495 * \param [in] user_data The input of user data. 496 * 497 * \retval SHR_E_NONE Success. 498 * \retval !SHR_E_NONE Failure. 499 */ 500 int 501 bcm56780_a0_gene_func_traverse( 502 int unit, 503 bcmgene_desc_t *gene, 504 uint32_t function, 505 int (*cb)(bcmgene_handle_t *hndl, void *user_data), 506 void *user_data); 507 508 #endif /* BCMINT_LTSW_GENE_DB_H */