1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2019-2021 Broadcom 3 * All rights reserved. 4 */ 5 6 #ifndef _TF_CORE_H_ 7 #define _TF_CORE_H_ 8 9 #include <stdint.h> 10 #include <stdlib.h> 11 #include <stdbool.h> 12 #include <stdio.h> 13 #include "hcapi_cfa_defs.h" 14 #include "tf_project.h" 15 16 /** 17 * @file 18 * 19 * Truflow Core API Header File 20 */ 21 22 /********** BEGIN Truflow Core DEFINITIONS **********/ 23 24 #define TF_KILOBYTE 1024 25 #define TF_MEGABYTE (1024 * 1024) 26 27 /** 28 * direction 29 */ 30 enum tf_dir { 31 TF_DIR_RX, /**< Receive */ 32 TF_DIR_TX, /**< Transmit */ 33 TF_DIR_MAX 34 }; 35 36 /** 37 * memory choice 38 */ 39 enum tf_mem { 40 TF_MEM_INTERNAL, /**< Internal */ 41 TF_MEM_EXTERNAL, /**< External */ 42 TF_MEM_MAX 43 }; 44 45 /** 46 * External memory control channel type 47 */ 48 enum tf_ext_mem_chan_type { 49 /** 50 * Direct memory write(Wh+/SR) 51 */ 52 TF_EXT_MEM_CHAN_TYPE_DIRECT = 0, 53 /** 54 * Ring interface MPC 55 */ 56 TF_EXT_MEM_CHAN_TYPE_RING_IF, 57 /** 58 * Use HWRM message to firmware 59 */ 60 TF_EXT_MEM_CHAN_TYPE_FW, 61 /** 62 * Use ring_if message to firmware 63 */ 64 TF_EXT_MEM_CHAN_TYPE_RING_IF_FW, 65 TF_EXT_MEM_CHAN_TYPE_MAX 66 }; 67 68 /** 69 * WC TCAM number of slice per row that devices supported 70 */ 71 enum tf_wc_num_slice { 72 TF_WC_TCAM_1_SLICE_PER_ROW = 1, 73 TF_WC_TCAM_2_SLICE_PER_ROW = 2, 74 TF_WC_TCAM_4_SLICE_PER_ROW = 4, 75 TF_WC_TCAM_8_SLICE_PER_ROW = 8, 76 }; 77 78 /** 79 * Bank identifier 80 */ 81 enum tf_sram_bank_id { 82 TF_SRAM_BANK_ID_0, /**< SRAM Bank 0 id */ 83 TF_SRAM_BANK_ID_1, /**< SRAM Bank 1 id */ 84 TF_SRAM_BANK_ID_2, /**< SRAM Bank 2 id */ 85 TF_SRAM_BANK_ID_3, /**< SRAM Bank 3 id */ 86 TF_SRAM_BANK_ID_MAX /**< SRAM Bank index limit */ 87 }; 88 89 /** 90 * EEM record AR helper 91 * 92 * Helper to handle the Action Record Pointer in the EEM Record Entry. 93 * 94 * Convert absolute offset to action record pointer in EEM record entry 95 * Convert action record pointer in EEM record entry to absolute offset 96 */ 97 #define TF_ACT_REC_OFFSET_2_PTR(offset) ((offset) >> 4) 98 #define TF_ACT_REC_PTR_2_OFFSET(offset) ((offset) << 4) 99 100 /* 101 * Helper Macros 102 */ 103 #define TF_BITS_2_BYTES(num_bits) (((num_bits) + 7) / 8) 104 105 /********** BEGIN API FUNCTION PROTOTYPES/PARAMETERS **********/ 106 107 /** 108 * @page general General 109 * 110 * @ref tf_open_session 111 * 112 * @ref tf_attach_session 113 * 114 * @ref tf_close_session 115 */ 116 117 /** 118 * Session Version defines 119 * 120 * The version controls the format of the tf_session and 121 * tf_session_info structure. This is to assure upgrade between 122 * versions can be supported. 123 */ 124 #define TF_SESSION_VER_MAJOR 1 /**< Major Version */ 125 #define TF_SESSION_VER_MINOR 0 /**< Minor Version */ 126 #define TF_SESSION_VER_UPDATE 0 /**< Update Version */ 127 128 /** 129 * Session Name 130 * 131 * Name of the TruFlow control channel interface. Expects 132 * format to be RTE Name specific, i.e. rte_eth_dev_get_name_by_port() 133 */ 134 #define TF_SESSION_NAME_MAX 64 135 136 #define TF_FW_SESSION_ID_INVALID 0xFF /**< Invalid FW Session ID define */ 137 138 /** 139 * Session Identifier 140 * 141 * Unique session identifier which includes PCIe bus info to 142 * distinguish the PF and session info to identify the associated 143 * TruFlow session. Session ID is constructed from the passed in 144 * ctrl_chan_name in tf_open_session() together with an allocated 145 * fw_session_id. Done by TruFlow on tf_open_session(). 146 */ 147 union tf_session_id { 148 uint32_t id; 149 struct { 150 uint8_t domain; 151 uint8_t bus; 152 uint8_t device; 153 uint8_t fw_session_id; 154 } internal; 155 }; 156 157 /** 158 * Session Client Identifier 159 * 160 * Unique identifier for a client within a session. Session Client ID 161 * is constructed from the passed in session and a firmware allocated 162 * fw_session_client_id. Done by TruFlow on tf_open_session(). 163 */ 164 union tf_session_client_id { 165 uint16_t id; 166 struct { 167 uint8_t fw_session_id; 168 uint8_t fw_session_client_id; 169 } internal; 170 }; 171 172 /** 173 * Session Version 174 * 175 * The version controls the format of the tf_session and 176 * tf_session_info structure. This is to assure upgrade between 177 * versions can be supported. 178 * 179 * Please see the TF_VER_MAJOR/MINOR and UPDATE defines. 180 */ 181 struct tf_session_version { 182 uint8_t major; 183 uint8_t minor; 184 uint8_t update; 185 }; 186 187 /** 188 * Session supported device types 189 */ 190 enum tf_device_type { 191 TF_DEVICE_TYPE_WH = 0, /**< Whitney+ */ 192 TF_DEVICE_TYPE_SR, /**< Stingray */ 193 TF_DEVICE_TYPE_THOR, /**< Thor */ 194 TF_DEVICE_TYPE_MAX /**< Maximum */ 195 }; 196 197 /** 198 * Module types 199 */ 200 enum tf_module_type { 201 /** 202 * Identifier module 203 */ 204 TF_MODULE_TYPE_IDENTIFIER, 205 /** 206 * Table type module 207 */ 208 TF_MODULE_TYPE_TABLE, 209 /** 210 * TCAM module 211 */ 212 TF_MODULE_TYPE_TCAM, 213 /** 214 * EM module 215 */ 216 TF_MODULE_TYPE_EM, 217 TF_MODULE_TYPE_MAX 218 }; 219 220 /** 221 * Identifier resource types 222 */ 223 enum tf_identifier_type { 224 /** 225 * WH/SR/TH 226 * The L2 Context is returned from the L2 Ctxt TCAM lookup 227 * and can be used in WC TCAM or EM keys to virtualize further 228 * lookups. 229 */ 230 TF_IDENT_TYPE_L2_CTXT_HIGH, 231 /** 232 * WH/SR/TH 233 * The L2 Context is returned from the L2 Ctxt TCAM lookup 234 * and can be used in WC TCAM or EM keys to virtualize further 235 * lookups. 236 */ 237 TF_IDENT_TYPE_L2_CTXT_LOW, 238 /** 239 * WH/SR/TH 240 * The WC profile func is returned from the L2 Ctxt TCAM lookup 241 * to enable virtualization of the profile TCAM. 242 */ 243 TF_IDENT_TYPE_PROF_FUNC, 244 /** 245 * WH/SR/TH 246 * The WC profile ID is included in the WC lookup key 247 * to enable virtualization of the WC TCAM hardware. 248 */ 249 TF_IDENT_TYPE_WC_PROF, 250 /** 251 * WH/SR/TH 252 * The EM profile ID is included in the EM lookup key 253 * to enable virtualization of the EM hardware. 254 */ 255 TF_IDENT_TYPE_EM_PROF, 256 /** 257 * (Future) 258 * The L2 func is included in the ILT result and from recycling to 259 * enable virtualization of further lookups. 260 */ 261 TF_IDENT_TYPE_L2_FUNC, 262 TF_IDENT_TYPE_MAX 263 }; 264 265 /** 266 * Enumeration of TruFlow table types. A table type is used to identify a 267 * resource object. 268 * 269 * NOTE: The table type TF_TBL_TYPE_EXT is unique in that it is 270 * the only table type that is connected with a table scope. 271 */ 272 enum tf_tbl_type { 273 /* Internal */ 274 275 /** Wh+/SR/TH Action Record */ 276 TF_TBL_TYPE_FULL_ACT_RECORD, 277 /** TH Compact Action Record */ 278 TF_TBL_TYPE_COMPACT_ACT_RECORD, 279 /** (Future) Multicast Groups */ 280 TF_TBL_TYPE_MCAST_GROUPS, 281 /** Wh+/SR/TH Action Encap 8 Bytes */ 282 TF_TBL_TYPE_ACT_ENCAP_8B, 283 /** Wh+/SR/TH Action Encap 16 Bytes */ 284 TF_TBL_TYPE_ACT_ENCAP_16B, 285 /** WH+/SR/TH Action Encap 32 Bytes */ 286 TF_TBL_TYPE_ACT_ENCAP_32B, 287 /** Wh+/SR/TH Action Encap 64 Bytes */ 288 TF_TBL_TYPE_ACT_ENCAP_64B, 289 /** WH+/SR/TH Action Source Properties SMAC */ 290 TF_TBL_TYPE_ACT_SP_SMAC, 291 /** Wh+/SR/TH Action Source Properties SMAC IPv4 */ 292 TF_TBL_TYPE_ACT_SP_SMAC_IPV4, 293 /** WH+/SR/TH Action Source Properties SMAC IPv6 */ 294 TF_TBL_TYPE_ACT_SP_SMAC_IPV6, 295 /** Wh+/SR/TH Action Statistics 64 Bits */ 296 TF_TBL_TYPE_ACT_STATS_64, 297 /** Wh+/SR Action Modify IPv4 Source */ 298 TF_TBL_TYPE_ACT_MODIFY_IPV4, 299 /** TH 8B Modify Record */ 300 TF_TBL_TYPE_ACT_MODIFY_8B, 301 /** TH 16B Modify Record */ 302 TF_TBL_TYPE_ACT_MODIFY_16B, 303 /** TH 32B Modify Record */ 304 TF_TBL_TYPE_ACT_MODIFY_32B, 305 /** TH 64B Modify Record */ 306 TF_TBL_TYPE_ACT_MODIFY_64B, 307 /** Meter Profiles */ 308 TF_TBL_TYPE_METER_PROF, 309 /** Meter Instance */ 310 TF_TBL_TYPE_METER_INST, 311 /** Wh+/SR/Th Mirror Config */ 312 TF_TBL_TYPE_MIRROR_CONFIG, 313 /** (Future) UPAR */ 314 TF_TBL_TYPE_UPAR, 315 /** (Future) TH Metadata */ 316 TF_TBL_TYPE_METADATA, 317 /** (Future) TH CT State */ 318 TF_TBL_TYPE_CT_STATE, 319 /** (Future) TH Range Profile */ 320 TF_TBL_TYPE_RANGE_PROF, 321 /** TH EM Flexible Key builder */ 322 TF_TBL_TYPE_EM_FKB, 323 /** TH WC Flexible Key builder */ 324 TF_TBL_TYPE_WC_FKB, 325 /** Meter Drop Counter */ 326 TF_TBL_TYPE_METER_DROP_CNT, 327 328 /* External */ 329 330 /** 331 * External table type - initially 1 poolsize entries. 332 * All External table types are associated with a table 333 * scope. Internal types are not. Currently this is 334 * a pool of 64B entries. 335 */ 336 TF_TBL_TYPE_EXT, 337 TF_TBL_TYPE_MAX 338 }; 339 340 /** Enable Shared TCAM Management 341 * 342 * This feature allows for management of high and low pools within 343 * the WC TCAM. These pools are only valid when this feature is enabled. 344 * 345 * For normal OVS-DPDK operation, this feature is not required and can 346 * be disabled by commenting out TF_TCAM_SHARED in this header file. 347 * 348 * Operation: 349 * 350 * When a shared session is created with WC TCAM entries allocated during 351 * tf_open_session(), the TF_TCAM_TBL_TYPE_WC_TCAM pool entries will be divided 352 * into 2 equal pools - TF_TCAM_TBL_TYPE_WC_TCAM_HIGH and 353 * TF_TCAM_TBL_TYPE_WC_TCAM_LOW. 354 * 355 * The user will allocate and free entries from either of these pools to obtain 356 * WC_TCAM entry offsets. For the WC_TCAM_HI/LO management, alloc/free is done 357 * using the tf_alloc_tcam_entry()/tf_free_tcam_entry() APIs for the shared 358 * session. 359 * 360 * The use case for this feature is so that applications can have a shared 361 * session and use the TF core to allocate/set/free entries within a given 362 * region of the WC_TCAM within the shared session. Application A only writes 363 * to the LOW region for example and Application B only writes to the HIGH 364 * region during normal operation. After Application A goes down, Application 365 * B may decide to overwrite the LOW region with the HIGH region's entries 366 * and switch to the low region. 367 * 368 * For other TCAM types in the shared session, no alloc/free operations are 369 * permitted. Only set should be used for other TCAM table types after getting 370 * the range as provided by the tf_get_resource_info() API. 371 * 372 */ 373 #define TF_TCAM_SHARED 1 374 375 /** 376 * TCAM table type 377 */ 378 enum tf_tcam_tbl_type { 379 /** L2 Context TCAM */ 380 TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_HIGH, 381 /** L2 Context TCAM */ 382 TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_LOW, 383 /** Profile TCAM */ 384 TF_TCAM_TBL_TYPE_PROF_TCAM, 385 /** Wildcard TCAM */ 386 TF_TCAM_TBL_TYPE_WC_TCAM, 387 /** Source Properties TCAM */ 388 TF_TCAM_TBL_TYPE_SP_TCAM, 389 /** Connection Tracking Rule TCAM */ 390 TF_TCAM_TBL_TYPE_CT_RULE_TCAM, 391 /** Virtual Edge Bridge TCAM */ 392 TF_TCAM_TBL_TYPE_VEB_TCAM, 393 #ifdef TF_TCAM_SHARED 394 /** Wildcard TCAM HI Priority */ 395 TF_TCAM_TBL_TYPE_WC_TCAM_HIGH, 396 /** Wildcard TCAM Low Priority */ 397 TF_TCAM_TBL_TYPE_WC_TCAM_LOW, 398 #endif /* TF_TCAM_SHARED */ 399 TF_TCAM_TBL_TYPE_MAX 400 }; 401 402 /** 403 * SEARCH STATUS 404 */ 405 enum tf_search_status { 406 /** The entry was not found, but an idx was allocated if requested. */ 407 MISS, 408 /** The entry was found, and the result/idx are valid */ 409 HIT, 410 /** The entry was not found and the table is full */ 411 REJECT 412 }; 413 414 /** 415 * EM Resources 416 * These defines are provisioned during 417 * tf_open_session() 418 */ 419 enum tf_em_tbl_type { 420 /** The number of internal EM records for the session */ 421 TF_EM_TBL_TYPE_EM_RECORD, 422 /** The number of table scopes requested */ 423 TF_EM_TBL_TYPE_TBL_SCOPE, 424 TF_EM_TBL_TYPE_MAX 425 }; 426 427 /** 428 * TruFlow Session Information 429 * 430 * Structure defining a TruFlow Session, also known as a Management 431 * session. This structure is initialized at time of 432 * tf_open_session(). It is passed to all of the TruFlow APIs as way 433 * to prescribe and isolate resources between different TruFlow ULP 434 * Applications. 435 * 436 * Ownership of the elements is split between ULP and TruFlow. Please 437 * see the individual elements. 438 */ 439 struct tf_session_info { 440 /** 441 * TruFlow Version. Used to control the structure layout when 442 * sharing sessions. No guarantee that a secondary process 443 * would come from the same version of an executable. 444 * TruFlow initializes this variable on tf_open_session(). 445 * 446 * Owner: TruFlow 447 * Access: TruFlow 448 */ 449 struct tf_session_version ver; 450 /** 451 * will be STAILQ_ENTRY(tf_session_info) next 452 * 453 * Owner: ULP 454 * Access: ULP 455 */ 456 void *next; 457 /** 458 * Session ID is a unique identifier for the session. TruFlow 459 * initializes this variable during tf_open_session() 460 * processing. 461 * 462 * Owner: TruFlow 463 * Access: Truflow & ULP 464 */ 465 union tf_session_id session_id; 466 /** 467 * Protects access to core_data. Lock is initialized and owned 468 * by ULP. TruFlow can access the core_data without checking 469 * the lock. 470 * 471 * Owner: ULP 472 * Access: ULP 473 */ 474 uint8_t spin_lock; 475 /** 476 * The core_data holds the TruFlow tf_session data 477 * structure. This memory is allocated and owned by TruFlow on 478 * tf_open_session(). 479 * 480 * TruFlow uses this memory for session management control 481 * until the session is closed by ULP. Access control is done 482 * by the spin_lock which ULP controls ahead of TruFlow API 483 * calls. 484 * 485 * Please see tf_open_session_parms for specification details 486 * on this variable. 487 * 488 * Owner: TruFlow 489 * Access: TruFlow 490 */ 491 void *core_data; 492 /** 493 * The core_data_sz_bytes specifies the size of core_data in 494 * bytes. 495 * 496 * The size is set by TruFlow on tf_open_session(). 497 * 498 * Please see tf_open_session_parms for specification details 499 * on this variable. 500 * 501 * Owner: TruFlow 502 * Access: TruFlow 503 */ 504 uint32_t core_data_sz_bytes; 505 }; 506 507 /** 508 * TruFlow handle 509 * 510 * Contains a pointer to the session info. Allocated by ULP and passed 511 * to TruFlow using tf_open_session(). TruFlow will populate the 512 * session info at that time. A TruFlow Session can be used by more 513 * than one PF/VF by using the tf_open_session(). 514 * 515 * It is expected that ULP allocates this memory as shared memory. 516 * 517 * NOTE: This struct must be within the BNXT PMD struct bnxt 518 * (bp). This allows use of container_of() to get access to the PMD. 519 */ 520 struct tf { 521 struct tf_session_info *session; 522 /** 523 * the pointer to the parent bp struct 524 */ 525 void *bp; 526 }; 527 528 /** 529 * Identifier resource definition 530 */ 531 struct tf_identifier_resources { 532 /** 533 * Array of TF Identifiers where each entry is expected to be 534 * set to the requested resource number of that specific type. 535 * The index used is tf_identifier_type. 536 */ 537 uint16_t cnt[TF_IDENT_TYPE_MAX]; 538 }; 539 540 /** 541 * Table type resource definition 542 */ 543 struct tf_tbl_resources { 544 /** 545 * Array of TF Table types where each entry is expected to be 546 * set to the requested resource number of that specific 547 * type. The index used is tf_tbl_type. 548 */ 549 uint16_t cnt[TF_TBL_TYPE_MAX]; 550 }; 551 552 /** 553 * TCAM type resource definition 554 */ 555 struct tf_tcam_resources { 556 /** 557 * Array of TF TCAM types where each entry is expected to be 558 * set to the requested resource number of that specific 559 * type. The index used is tf_tcam_tbl_type. 560 */ 561 uint16_t cnt[TF_TCAM_TBL_TYPE_MAX]; 562 }; 563 564 /** 565 * EM type resource definition 566 */ 567 struct tf_em_resources { 568 /** 569 * Array of TF EM table types where each entry is expected to 570 * be set to the requested resource number of that specific 571 * type. The index used is tf_em_tbl_type. 572 */ 573 uint16_t cnt[TF_EM_TBL_TYPE_MAX]; 574 }; 575 576 /** 577 * tf_session_resources parameter definition. 578 */ 579 struct tf_session_resources { 580 /** 581 * [in] Requested Identifier Resources 582 * 583 * Number of identifier resources requested for the 584 * session. 585 */ 586 struct tf_identifier_resources ident_cnt[TF_DIR_MAX]; 587 /** 588 * [in] Requested Index Table resource counts 589 * 590 * The number of index table resources requested for the 591 * session. 592 */ 593 struct tf_tbl_resources tbl_cnt[TF_DIR_MAX]; 594 /** 595 * [in] Requested TCAM Table resource counts 596 * 597 * The number of TCAM table resources requested for the 598 * session. 599 */ 600 601 struct tf_tcam_resources tcam_cnt[TF_DIR_MAX]; 602 /** 603 * [in] Requested EM resource counts 604 * 605 * The number of internal EM table resources requested for the 606 * session. 607 */ 608 struct tf_em_resources em_cnt[TF_DIR_MAX]; 609 }; 610 611 /** 612 * tf_open_session parameters definition. 613 */ 614 struct tf_open_session_parms { 615 /** 616 * [in] ctrl_chan_name 617 * 618 * String containing name of control channel interface to be 619 * used for this session to communicate with firmware. 620 * 621 * The ctrl_chan_name can be looked up by using 622 * rte_eth_dev_get_name_by_port() within the ULP. 623 * 624 * ctrl_chan_name will be used as part of a name for any 625 * shared memory allocation. The ctrl_chan_name is usually in format 626 * 0000:02:00.0. The name for shared session is 0000:02:00.0-tf_shared. 627 */ 628 char ctrl_chan_name[TF_SESSION_NAME_MAX]; 629 /** 630 * [in] shadow_copy 631 * 632 * Boolean controlling the use and availability of shadow 633 * copy. Shadow copy will allow the TruFlow to keep track of 634 * resource content on the firmware side without having to 635 * query firmware. Additional private session core_data will 636 * be allocated if this boolean is set to 'true', default 637 * 'false'. 638 * 639 * Size of memory depends on the NVM Resource settings for the 640 * control channel. 641 */ 642 bool shadow_copy; 643 /** 644 * [in/out] session_id 645 * 646 * Session_id is unique per session. 647 * 648 * Session_id is composed of domain, bus, device and 649 * fw_session_id. The construction is done by parsing the 650 * ctrl_chan_name together with allocation of a fw_session_id. 651 * 652 * The session_id allows a session to be shared between devices. 653 */ 654 union tf_session_id session_id; 655 /** 656 * [in/out] session_client_id 657 * 658 * Session_client_id is unique per client. 659 * 660 * Session_client_id is composed of session_id and the 661 * fw_session_client_id fw_session_id. The construction is 662 * done by parsing the ctrl_chan_name together with allocation 663 * of a fw_session_client_id during tf_open_session(). 664 * 665 * A reference count will be incremented in the session on 666 * which a client is created. 667 * 668 * A session can first be closed if there is one Session 669 * Client left. Session Clients should closed using 670 * tf_close_session(). 671 */ 672 union tf_session_client_id session_client_id; 673 /** 674 * [in] device type 675 * 676 * Device type for the session. 677 */ 678 enum tf_device_type device_type; 679 /** 680 * [in] resources 681 * 682 * Resource allocation for the session. 683 */ 684 struct tf_session_resources resources; 685 686 /** 687 * [in] bp 688 * The pointer to the parent bp struct. This is only used for HWRM 689 * message passing within the portability layer. The type is struct 690 * bnxt. 691 */ 692 void *bp; 693 694 /** 695 * [in] 696 * 697 * The number of slices per row for WC TCAM entry. 698 */ 699 enum tf_wc_num_slice wc_num_slices; 700 701 /** 702 * [out] shared_session_creator 703 * 704 * Indicates whether the application created the session if set. 705 * Otherwise the shared session already existed. Just for information 706 * purposes. 707 */ 708 int shared_session_creator; 709 }; 710 711 /** 712 * Opens a new TruFlow Session or session client. 713 * 714 * What gets created depends on the passed in tfp content. If the tfp does not 715 * have prior session data a new session with associated session client. If tfp 716 * has a session already a session client will be created. In both cases the 717 * session client is created using the provided ctrl_chan_name. 718 * 719 * In case of session creation TruFlow will allocate session specific memory to 720 * hold its session data. This data is private to TruFlow. 721 * 722 * No other TruFlow APIs will succeed unless this API is first called 723 * and succeeds. 724 * 725 * tf_open_session() returns a session id and session client id. These are 726 * also stored within the tfp structure passed in to all other APIs. 727 * 728 * A Session or session client can be closed using tf_close_session(). 729 * 730 * There are 2 types of sessions - shared and not. For non-shared all 731 * the allocated resources are owned and managed by a single session instance. 732 * No other applications have access to the resources owned by the non-shared 733 * session. For a shared session, resources are shared between 2 applications. 734 * 735 * When the caller of tf_open_session() sets the ctrl_chan_name[] to a name 736 * like "0000:02:00.0-tf_shared", it is a request to create a new "shared" 737 * session in the firmware or access the existing shared session. There is 738 * only 1 shared session that can be created. If the shared session has 739 * already been created in the firmware, this API will return this indication 740 * by clearing the shared_session_creator flag. Only the first shared session 741 * create will have the shared_session_creator flag set. 742 * 743 * The shared session should always be the first session to be created by 744 * application and the last session closed due to RM management preference. 745 * 746 * Sessions remain open in the firmware until the last client of the session 747 * closes the session (tf_close_session()). 748 * 749 * [in] tfp 750 * Pointer to TF handle 751 * 752 * [in] parms 753 * Pointer to open parameters 754 * 755 * Returns 756 * - (0) if successful. 757 * - (-EINVAL) on failure. 758 */ 759 int tf_open_session(struct tf *tfp, 760 struct tf_open_session_parms *parms); 761 762 /** 763 * General internal resource info 764 * 765 */ 766 struct tf_resource_info { 767 uint16_t start; 768 uint16_t stride; 769 }; 770 771 /** 772 * Identifier resource definition 773 */ 774 struct tf_identifier_resource_info { 775 /** 776 * Array of TF Identifiers. The index used is tf_identifier_type. 777 */ 778 struct tf_resource_info info[TF_IDENT_TYPE_MAX]; 779 }; 780 781 /** 782 * Table type resource info definition 783 */ 784 struct tf_tbl_resource_info { 785 /** 786 * Array of TF Table types. The index used is tf_tbl_type. 787 */ 788 struct tf_resource_info info[TF_TBL_TYPE_MAX]; 789 }; 790 791 /** 792 * TCAM type resource definition 793 */ 794 struct tf_tcam_resource_info { 795 /** 796 * Array of TF TCAM types. The index used is tf_tcam_tbl_type. 797 */ 798 struct tf_resource_info info[TF_TCAM_TBL_TYPE_MAX]; 799 }; 800 801 /** 802 * EM type resource definition 803 */ 804 struct tf_em_resource_info { 805 /** 806 * Array of TF EM table types. The index used is tf_em_tbl_type. 807 */ 808 struct tf_resource_info info[TF_EM_TBL_TYPE_MAX]; 809 }; 810 811 /** 812 * tf_session_resources parameter definition. 813 */ 814 struct tf_session_resource_info { 815 /** 816 * [in] Requested Identifier Resources 817 * 818 * Number of identifier resources requested for the 819 * session. 820 */ 821 struct tf_identifier_resource_info ident[TF_DIR_MAX]; 822 /** 823 * [in] Requested Index Table resource counts 824 * 825 * The number of index table resources requested for the 826 * session. 827 */ 828 struct tf_tbl_resource_info tbl[TF_DIR_MAX]; 829 /** 830 * [in] Requested TCAM Table resource counts 831 * 832 * The number of TCAM table resources requested for the 833 * session. 834 */ 835 836 struct tf_tcam_resource_info tcam[TF_DIR_MAX]; 837 /** 838 * [in] Requested EM resource counts 839 * 840 * The number of internal EM table resources requested for the 841 * session. 842 */ 843 struct tf_em_resource_info em[TF_DIR_MAX]; 844 }; 845 846 /** 847 * tf_get_session_resources parameter definition. 848 */ 849 struct tf_get_session_info_parms { 850 /** 851 * [out] the structure is used to return the information of 852 * allocated resources. 853 * 854 */ 855 struct tf_session_resource_info session_info; 856 }; 857 858 /** (experimental) 859 * Gets info about a TruFlow Session 860 * 861 * Get info about the session which has been created. Whether it exists and 862 * what resource start and stride offsets are in use. This API is primarily 863 * intended to be used by an application which has created a shared session 864 * This application needs to obtain the resources which have already been 865 * allocated for the shared session. 866 * 867 * [in] tfp 868 * Pointer to TF handle 869 * 870 * [in] parms 871 * Pointer to get parameters 872 * 873 * Returns 874 * - (0) if successful. 875 * - (-EINVAL) on failure. 876 */ 877 int tf_get_session_info(struct tf *tfp, 878 struct tf_get_session_info_parms *parms); 879 /** 880 * Experimental 881 * 882 * tf_attach_session parameters definition. 883 */ 884 struct tf_attach_session_parms { 885 /** 886 * [in] ctrl_chan_name 887 * 888 * String containing name of control channel interface to be 889 * used for this session to communicate with firmware. 890 * 891 * The ctrl_chan_name can be looked up by using 892 * rte_eth_dev_get_name_by_port() within the ULP. 893 * 894 * ctrl_chan_name will be used as part of a name for any 895 * shared memory allocation. 896 */ 897 char ctrl_chan_name[TF_SESSION_NAME_MAX]; 898 899 /** 900 * [in] attach_chan_name 901 * 902 * String containing name of attach channel interface to be 903 * used for this session. 904 * 905 * The attach_chan_name must be given to a 2nd process after 906 * the primary process has been created. This is the 907 * ctrl_chan_name of the primary process and is used to find 908 * the shared memory for the session that the attach is going 909 * to use. 910 */ 911 char attach_chan_name[TF_SESSION_NAME_MAX]; 912 913 /** 914 * [in] session_id 915 * 916 * Session_id is unique per session. For Attach the session_id 917 * should be the session_id that was returned on the first 918 * open. 919 * 920 * Session_id is composed of domain, bus, device and 921 * fw_session_id. The construction is done by parsing the 922 * ctrl_chan_name together with allocation of a fw_session_id 923 * during tf_open_session(). 924 * 925 * A reference count will be incremented on attach. A session 926 * is first fully closed when reference count is zero by 927 * calling tf_close_session(). 928 */ 929 union tf_session_id session_id; 930 }; 931 932 /** 933 * Experimental 934 * 935 * Allows a 2nd application instance to attach to an existing 936 * session. Used when a session is to be shared between two processes. 937 * 938 * Attach will increment a ref count as to manage the shared session data. 939 * 940 * [in] tfp 941 * Pointer to TF handle 942 * 943 * [in] parms 944 * Pointer to attach parameters 945 * 946 * Returns 947 * - (0) if successful. 948 * - (-EINVAL) on failure. 949 */ 950 int tf_attach_session(struct tf *tfp, 951 struct tf_attach_session_parms *parms); 952 953 /** 954 * Closes an existing session client or the session it self. The 955 * session client is default closed and if the session reference count 956 * is 0 then the session is closed as well. 957 * 958 * On session close all hardware and firmware state associated with 959 * the TruFlow application is cleaned up. 960 * 961 * The session client is extracted from the tfp. Thus tf_close_session() 962 * cannot close a session client on behalf of another function. 963 * 964 * Returns success or failure code. 965 */ 966 int tf_close_session(struct tf *tfp); 967 968 /** 969 * @page ident Identity Management 970 * 971 * @ref tf_alloc_identifier 972 * 973 * @ref tf_free_identifier 974 */ 975 /** 976 * tf_alloc_identifier parameter definition 977 */ 978 struct tf_alloc_identifier_parms { 979 /** 980 * [in] receive or transmit direction 981 */ 982 enum tf_dir dir; 983 /** 984 * [in] Identifier type 985 */ 986 enum tf_identifier_type ident_type; 987 /** 988 * [out] Allocated identifier 989 */ 990 uint32_t id; 991 }; 992 993 /** 994 * tf_free_identifier parameter definition 995 */ 996 struct tf_free_identifier_parms { 997 /** 998 * [in] receive or transmit direction 999 */ 1000 enum tf_dir dir; 1001 /** 1002 * [in] Identifier type 1003 */ 1004 enum tf_identifier_type ident_type; 1005 /** 1006 * [in] ID to free 1007 */ 1008 uint32_t id; 1009 /** 1010 * (experimental) 1011 * [out] Current refcnt after free 1012 */ 1013 uint32_t ref_cnt; 1014 }; 1015 1016 /** 1017 * tf_search_identifier parameter definition (experimental) 1018 */ 1019 struct tf_search_identifier_parms { 1020 /** 1021 * [in] receive or transmit direction 1022 */ 1023 enum tf_dir dir; 1024 /** 1025 * [in] Identifier type 1026 */ 1027 enum tf_identifier_type ident_type; 1028 /** 1029 * [in] Identifier data to search for 1030 */ 1031 uint32_t search_id; 1032 /** 1033 * [out] Set if matching identifier found 1034 */ 1035 bool hit; 1036 /** 1037 * [out] Current ref count after allocation 1038 */ 1039 uint32_t ref_cnt; 1040 }; 1041 1042 /** 1043 * allocate identifier resource 1044 * 1045 * TruFlow core will allocate a free id from the per identifier resource type 1046 * pool reserved for the session during tf_open(). No firmware is involved. 1047 * 1048 * If shadow copy is enabled, the internal ref_cnt is set to 1 in the 1049 * shadow table for a newly allocated resource. 1050 * 1051 * Returns success or failure code. 1052 */ 1053 int tf_alloc_identifier(struct tf *tfp, 1054 struct tf_alloc_identifier_parms *parms); 1055 1056 /** 1057 * free identifier resource 1058 * 1059 * TruFlow core will return an id back to the per identifier resource type pool 1060 * reserved for the session. No firmware is involved. During tf_close, the 1061 * complete pool is returned to the firmware. 1062 * 1063 * additional operation (experimental) 1064 * Decrement reference count. Only release resource once refcnt goes to 0 if 1065 * shadow copy is enabled. 1066 * 1067 * Returns success or failure code. 1068 */ 1069 int tf_free_identifier(struct tf *tfp, 1070 struct tf_free_identifier_parms *parms); 1071 1072 /** 1073 * Search identifier resource (experimental) 1074 * 1075 * If the shadow copy is enabled search_id is used to search for a matching 1076 * entry in the shadow table. The shadow table consists of an array of 1077 * reference counts indexed by identifier. If a matching entry is found hit is 1078 * set to TRUE, refcnt is increased by 1 and returned. Otherwise, hit is 1079 * set to false and refcnt is set to 0. 1080 * 1081 * TODO: we may need a per table internal shadow copy enable flag to stage 1082 * the shadow table implementation. We do not need the shadow table for other 1083 * tables at this time so we may only want to enable the identifier shadow. 1084 * 1085 * TODO: remove this pseudocode below added to show that if search fails 1086 * we shouldn't allocate a new entry but return. 1087 * 1088 * identifier alloc (search_en=1) 1089 * if (ident is allocated and ref_cnt >=1) 1090 * return ident - hit is set, incr refcnt 1091 * else (not found) 1092 * return 1093 * 1094 */ 1095 int tf_search_identifier(struct tf *tfp, 1096 struct tf_search_identifier_parms *parms); 1097 1098 /** 1099 * @page dram_table DRAM Table Scope Interface 1100 * 1101 * @ref tf_alloc_tbl_scope 1102 * 1103 * @ref tf_free_tbl_scope 1104 * 1105 * If we allocate the EEM memory from the core, we need to store it in 1106 * the shared session data structure to make sure it can be freed later. 1107 * (for example if the PF goes away) 1108 * 1109 * Current thought is that memory is allocated within core. 1110 */ 1111 1112 /** 1113 * tf_alloc_tbl_scope_parms definition 1114 */ 1115 struct tf_alloc_tbl_scope_parms { 1116 /** 1117 * [in] All Maximum key size required. 1118 */ 1119 uint16_t rx_max_key_sz_in_bits; 1120 /** 1121 * [in] Maximum Action size required (includes inlined items) 1122 */ 1123 uint16_t rx_max_action_entry_sz_in_bits; 1124 /** 1125 * [in] Memory size in Megabytes 1126 * Total memory size allocated by user to be divided 1127 * up for actions, hash, counters. Only inline external actions. 1128 * Use this variable or the number of flows, do not set both. 1129 */ 1130 uint32_t rx_mem_size_in_mb; 1131 /** 1132 * [in] Number of flows * 1000. If set, rx_mem_size_in_mb must equal 0. 1133 */ 1134 uint32_t rx_num_flows_in_k; 1135 /** 1136 * [in] All Maximum key size required. 1137 */ 1138 uint16_t tx_max_key_sz_in_bits; 1139 /** 1140 * [in] Maximum Action size required (includes inlined items) 1141 */ 1142 uint16_t tx_max_action_entry_sz_in_bits; 1143 /** 1144 * [in] Memory size in Megabytes 1145 * Total memory size allocated by user to be divided 1146 * up for actions, hash, counters. Only inline external actions. 1147 */ 1148 uint32_t tx_mem_size_in_mb; 1149 /** 1150 * [in] Number of flows * 1000 1151 */ 1152 uint32_t tx_num_flows_in_k; 1153 /** 1154 * [in] Flush pending HW cached flows every 1/10th of value 1155 * set in seconds, both idle and active flows are flushed 1156 * from the HW cache. If set to 0, this feature will be disabled. 1157 */ 1158 uint8_t hw_flow_cache_flush_timer; 1159 /** 1160 * [out] table scope identifier 1161 */ 1162 uint32_t tbl_scope_id; 1163 }; 1164 /** 1165 * tf_free_tbl_scope_parms definition 1166 */ 1167 struct tf_free_tbl_scope_parms { 1168 /** 1169 * [in] table scope identifier 1170 */ 1171 uint32_t tbl_scope_id; 1172 }; 1173 1174 /** 1175 * tf_map_tbl_scope_parms definition 1176 */ 1177 struct tf_map_tbl_scope_parms { 1178 /** 1179 * [in] table scope identifier 1180 */ 1181 uint32_t tbl_scope_id; 1182 /** 1183 * [in] Which parifs are associated with this table scope. Bit 0 1184 * indicates parif 0. 1185 */ 1186 uint16_t parif_bitmask; 1187 }; 1188 1189 /** 1190 * allocate a table scope 1191 * 1192 * The scope is a software construct to identify an EEM table. This function will 1193 * divide the hash memory/buckets and records according to the device 1194 * device constraints based upon calculations using either the number of flows 1195 * requested or the size of memory indicated. Other parameters passed in 1196 * determine the configuration (maximum key size, maximum external action record 1197 * size). 1198 * 1199 * A single API is used to allocate a common table scope identifier in both 1200 * receive and transmit CFA. The scope identifier is common due to nature of 1201 * connection tracking sending notifications between RX and TX direction. 1202 * 1203 * The receive and transmit table access identifiers specify which rings will 1204 * be used to initialize table DRAM. The application must ensure mutual 1205 * exclusivity of ring usage for table scope allocation and any table update 1206 * operations. 1207 * 1208 * The hash table buckets, EM keys, and EM lookup results are stored in the 1209 * memory allocated based on the rx_em_hash_mb/tx_em_hash_mb parameters. The 1210 * hash table buckets are stored at the beginning of that memory. 1211 * 1212 * NOTE: No EM internal setup is done here. On chip EM records are managed 1213 * internally by TruFlow core. 1214 * 1215 * Returns success or failure code. 1216 */ 1217 int tf_alloc_tbl_scope(struct tf *tfp, 1218 struct tf_alloc_tbl_scope_parms *parms); 1219 1220 /** 1221 * map a table scope (legacy device only Wh+/SR) 1222 * 1223 * Map a table scope to one or more partition interfaces (parifs). 1224 * The parif can be remapped in the L2 context lookup for legacy devices. This 1225 * API allows a number of parifs to be mapped to the same table scope. On 1226 * legacy devices a table scope identifies one of 16 sets of EEM table base 1227 * addresses and is associated with a PF communication channel. The associated 1228 * PF must be configured for the table scope to operate. 1229 * 1230 * An L2 context TCAM lookup returns a remapped parif value used to 1231 * index into the set of 16 parif_to_pf registers which are used to map to one 1232 * of the 16 table scopes. This API allows the user to map the parifs in the 1233 * mask to the previously allocated table scope (EEM table). 1234 1235 * Returns success or failure code. 1236 */ 1237 int tf_map_tbl_scope(struct tf *tfp, 1238 struct tf_map_tbl_scope_parms *parms); 1239 /** 1240 * free a table scope 1241 * 1242 * Firmware checks that the table scope ID is owned by the TruFlow 1243 * session, verifies that no references to this table scope remains 1244 * or Profile TCAM entries for either CFA (RX/TX) direction, 1245 * then frees the table scope ID. 1246 * 1247 * Returns success or failure code. 1248 */ 1249 int tf_free_tbl_scope(struct tf *tfp, 1250 struct tf_free_tbl_scope_parms *parms); 1251 1252 /** 1253 * @page tcam TCAM Access 1254 * 1255 * @ref tf_search_tcam_entry 1256 * 1257 * @ref tf_alloc_tcam_entry 1258 * 1259 * @ref tf_set_tcam_entry 1260 * 1261 * @ref tf_get_tcam_entry 1262 * 1263 * @ref tf_free_tcam_entry 1264 * 1265 #ifdef TF_TCAM_SHARED 1266 * @ref tf_move_tcam_shared_entries 1267 * 1268 * @ref tf_clear_tcam_shared_entries 1269 #endif 1270 */ 1271 1272 /** 1273 * tf_search_tcam_entry parameter definition (experimental) 1274 */ 1275 struct tf_search_tcam_entry_parms { 1276 /** 1277 * [in] receive or transmit direction 1278 */ 1279 enum tf_dir dir; 1280 /** 1281 * [in] TCAM table type 1282 */ 1283 enum tf_tcam_tbl_type tcam_tbl_type; 1284 /** 1285 * [in] Key data to match on 1286 */ 1287 uint8_t *key; 1288 /** 1289 * [in] key size in bits 1290 */ 1291 uint16_t key_sz_in_bits; 1292 /** 1293 * [in] Mask data to match on 1294 */ 1295 uint8_t *mask; 1296 /** 1297 * [in] Priority of entry requested (definition TBD) 1298 */ 1299 uint32_t priority; 1300 /** 1301 * [in] Allocate on miss. 1302 */ 1303 uint8_t alloc; 1304 /** 1305 * [out] Set if matching entry found 1306 */ 1307 uint8_t hit; 1308 /** 1309 * [out] Search result status (hit, miss, reject) 1310 */ 1311 enum tf_search_status search_status; 1312 /** 1313 * [out] Current refcnt after allocation 1314 */ 1315 uint16_t ref_cnt; 1316 /** 1317 * [in out] The result data from the search is copied here 1318 */ 1319 uint8_t *result; 1320 /** 1321 * [in out] result size in bits for the result data 1322 */ 1323 uint16_t result_sz_in_bits; 1324 /** 1325 * [out] Index found 1326 */ 1327 uint16_t idx; 1328 }; 1329 1330 /** 1331 * search TCAM entry (experimental) 1332 * 1333 * Search for a TCAM entry 1334 * 1335 * This function searches the shadow copy of the TCAM table for a matching 1336 * entry. Key and mask must match for hit to be set. Only TruFlow core data 1337 * is accessed. If shadow_copy is not enabled, an error is returned. 1338 * 1339 * Implementation: 1340 * 1341 * A hash is performed on the key/mask data and mapped to a shadow copy entry 1342 * where the full key/mask is populated. If the full key/mask matches the 1343 * entry, hit is set, ref_cnt is incremented, and search_status indicates what 1344 * action the caller can take regarding setting the entry. 1345 * 1346 * search_status should be used as follows: 1347 * - On Miss, the caller should create a result and call tf_set_tcam_entry with 1348 * returned index. 1349 * 1350 * - On Reject, the hash table is full and the entry cannot be added. 1351 * 1352 * - On Hit, the result data is returned to the caller. Additionally, the 1353 * ref_cnt is updated. 1354 * 1355 * Also returns success or failure code. 1356 */ 1357 int tf_search_tcam_entry(struct tf *tfp, 1358 struct tf_search_tcam_entry_parms *parms); 1359 1360 /** 1361 * tf_alloc_tcam_entry parameter definition 1362 */ 1363 struct tf_alloc_tcam_entry_parms { 1364 /** 1365 * [in] receive or transmit direction 1366 */ 1367 enum tf_dir dir; 1368 /** 1369 * [in] TCAM table type 1370 */ 1371 enum tf_tcam_tbl_type tcam_tbl_type; 1372 /** 1373 * [in] Enable search for matching entry 1374 */ 1375 uint8_t search_enable; 1376 /** 1377 * [in] Key data to match on (if search) 1378 */ 1379 uint8_t *key; 1380 /** 1381 * [in] key size in bits (if search) 1382 */ 1383 uint16_t key_sz_in_bits; 1384 /** 1385 * [in] Mask data to match on (if search) 1386 */ 1387 uint8_t *mask; 1388 /** 1389 * [in] Priority of entry requested (definition TBD) 1390 */ 1391 uint32_t priority; 1392 /** 1393 * [out] If search, set if matching entry found 1394 */ 1395 uint8_t hit; 1396 /** 1397 * [out] Current refcnt after allocation 1398 */ 1399 uint16_t ref_cnt; 1400 /** 1401 * [out] Idx allocated 1402 * 1403 */ 1404 uint16_t idx; 1405 }; 1406 1407 /** 1408 * allocate TCAM entry 1409 * 1410 * Allocate a TCAM entry - one of these types: 1411 * 1412 * L2 Context 1413 * Profile TCAM 1414 * WC TCAM 1415 * VEB TCAM 1416 * 1417 * This function allocates a TCAM table record. This function 1418 * will attempt to allocate a TCAM table entry from the session 1419 * owned TCAM entries or search a shadow copy of the TCAM table for a 1420 * matching entry if search is enabled. Key, mask and result must match for 1421 * hit to be set. Only TruFlow core data is accessed. 1422 * A hash table to entry mapping is maintained for search purposes. If 1423 * search is not enabled, the first available free entry is returned based 1424 * on priority and alloc_cnt is set to 1. If search is enabled and a matching 1425 * entry to entry_data is found, hit is set to TRUE and alloc_cnt is set to 1. 1426 * RefCnt is also returned. 1427 * 1428 * Also returns success or failure code. 1429 */ 1430 int tf_alloc_tcam_entry(struct tf *tfp, 1431 struct tf_alloc_tcam_entry_parms *parms); 1432 1433 /** 1434 * tf_set_tcam_entry parameter definition 1435 */ 1436 struct tf_set_tcam_entry_parms { 1437 /** 1438 * [in] receive or transmit direction 1439 */ 1440 enum tf_dir dir; 1441 /** 1442 * [in] TCAM table type 1443 */ 1444 enum tf_tcam_tbl_type tcam_tbl_type; 1445 /** 1446 * [in] base index of the entry to program 1447 */ 1448 uint16_t idx; 1449 /** 1450 * [in] struct containing key 1451 */ 1452 uint8_t *key; 1453 /** 1454 * [in] struct containing mask fields 1455 */ 1456 uint8_t *mask; 1457 /** 1458 * [in] key size in bits (if search) 1459 */ 1460 uint16_t key_sz_in_bits; 1461 /** 1462 * [in] struct containing result 1463 */ 1464 uint8_t *result; 1465 /** 1466 * [in] struct containing result size in bits 1467 */ 1468 uint16_t result_sz_in_bits; 1469 }; 1470 1471 /** 1472 * set TCAM entry 1473 * 1474 * Program a TCAM table entry for a TruFlow session. 1475 * 1476 * If the entry has not been allocated, an error will be returned. 1477 * 1478 * Returns success or failure code. 1479 */ 1480 int tf_set_tcam_entry(struct tf *tfp, 1481 struct tf_set_tcam_entry_parms *parms); 1482 1483 /** 1484 * tf_get_tcam_entry parameter definition 1485 */ 1486 struct tf_get_tcam_entry_parms { 1487 /** 1488 * [in] receive or transmit direction 1489 */ 1490 enum tf_dir dir; 1491 /** 1492 * [in] TCAM table type 1493 */ 1494 enum tf_tcam_tbl_type tcam_tbl_type; 1495 /** 1496 * [in] index of the entry to get 1497 */ 1498 uint16_t idx; 1499 /** 1500 * [out] struct containing key 1501 */ 1502 uint8_t *key; 1503 /** 1504 * [out] struct containing mask fields 1505 */ 1506 uint8_t *mask; 1507 /** 1508 * [in/out] key size in bits 1509 */ 1510 uint16_t key_sz_in_bits; 1511 /** 1512 * [out] struct containing result 1513 */ 1514 uint8_t *result; 1515 /** 1516 * [in/out] struct containing result size in bits 1517 */ 1518 uint16_t result_sz_in_bits; 1519 }; 1520 1521 /** 1522 * get TCAM entry 1523 * 1524 * Program a TCAM table entry for a TruFlow session. 1525 * 1526 * If the entry has not been allocated, an error will be returned. 1527 * 1528 * Returns success or failure code. 1529 */ 1530 int tf_get_tcam_entry(struct tf *tfp, 1531 struct tf_get_tcam_entry_parms *parms); 1532 1533 /** 1534 * tf_free_tcam_entry parameter definition 1535 */ 1536 struct tf_free_tcam_entry_parms { 1537 /** 1538 * [in] receive or transmit direction 1539 */ 1540 enum tf_dir dir; 1541 /** 1542 * [in] TCAM table type 1543 */ 1544 enum tf_tcam_tbl_type tcam_tbl_type; 1545 /** 1546 * [in] Index to free 1547 */ 1548 uint16_t idx; 1549 /** 1550 * [out] reference count after free 1551 */ 1552 uint16_t ref_cnt; 1553 }; 1554 1555 /** 1556 * free TCAM entry 1557 * 1558 * Free TCAM entry. 1559 * 1560 * Firmware checks to ensure the TCAM entries are owned by the TruFlow 1561 * session. TCAM entry will be invalidated. All-ones mask. 1562 * writes to hw. 1563 * 1564 * WCTCAM profile id of 0 must be used to invalidate an entry. 1565 * 1566 * Returns success or failure code. 1567 */ 1568 int tf_free_tcam_entry(struct tf *tfp, 1569 struct tf_free_tcam_entry_parms *parms); 1570 1571 #ifdef TF_TCAM_SHARED 1572 /** 1573 * tf_move_tcam_shared_entries parameter definition 1574 */ 1575 struct tf_move_tcam_shared_entries_parms { 1576 /** 1577 * [in] receive or transmit direction 1578 */ 1579 enum tf_dir dir; 1580 /** 1581 * [in] TCAM table type 1582 */ 1583 enum tf_tcam_tbl_type tcam_tbl_type; 1584 }; 1585 1586 /** 1587 * Move TCAM entries 1588 * 1589 * This API only affects the following TCAM pools within a shared session: 1590 * 1591 * TF_TCAM_TBL_TYPE_WC_TCAM_HIGH 1592 * TF_TCAM_TBL_TYPE_WC_TCAM_LOW 1593 * 1594 * When called, all allocated entries from the high pool will be moved to 1595 * the low pool. Then the allocated entries in the high pool will be 1596 * cleared and freed. 1597 * 1598 * This API is not supported on a non-shared session. 1599 * 1600 * Returns success or failure code. 1601 */ 1602 int tf_move_tcam_shared_entries(struct tf *tfp, 1603 struct tf_move_tcam_shared_entries_parms *parms); 1604 1605 /** 1606 * tf_clear_tcam_shared_entries parameter definition 1607 */ 1608 struct tf_clear_tcam_shared_entries_parms { 1609 /** 1610 * [in] receive or transmit direction 1611 */ 1612 enum tf_dir dir; 1613 /** 1614 * [in] TCAM table type 1615 */ 1616 enum tf_tcam_tbl_type tcam_tbl_type; 1617 }; 1618 1619 /** 1620 * Clear TCAM shared entries pool 1621 * 1622 * This API only affects the following TCAM pools within a shared session: 1623 * 1624 * TF_TCAM_TBL_TYPE_WC_TCAM_HIGH 1625 * TF_TCAM_TBL_TYPE_WC_TCAM_LOW 1626 * 1627 * When called, the indicated WC TCAM high or low pool will be cleared. 1628 * 1629 * This API is not supported on a non-shared session. 1630 * 1631 * Returns success or failure code. 1632 */ 1633 int tf_clear_tcam_shared_entries(struct tf *tfp, 1634 struct tf_clear_tcam_shared_entries_parms *parms); 1635 1636 #endif /* TF_TCAM_SHARED */ 1637 /** 1638 * @page table Table Access 1639 * 1640 * @ref tf_alloc_tbl_entry 1641 * 1642 * @ref tf_free_tbl_entry 1643 * 1644 * @ref tf_set_tbl_entry 1645 * 1646 * @ref tf_get_tbl_entry 1647 * 1648 * @ref tf_bulk_get_tbl_entry 1649 * 1650 * @ref tf_get_shared_tbl_increment 1651 */ 1652 1653 /** 1654 * tf_alloc_tbl_entry parameter definition 1655 */ 1656 struct tf_alloc_tbl_entry_parms { 1657 /** 1658 * [in] Receive or transmit direction 1659 */ 1660 enum tf_dir dir; 1661 /** 1662 * [in] Type of the allocation 1663 */ 1664 enum tf_tbl_type type; 1665 /** 1666 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT) 1667 */ 1668 uint32_t tbl_scope_id; 1669 1670 /** 1671 * [out] Idx of allocated entry 1672 */ 1673 uint32_t idx; 1674 }; 1675 1676 /** 1677 * allocate index table entries 1678 * 1679 * Internal types: 1680 * 1681 * Allocate an on chip index table entry or search for a matching 1682 * entry of the indicated type for this TruFlow session. 1683 * 1684 * Allocates an index table record. This function will attempt to 1685 * allocate an index table entry. 1686 * 1687 * External types: 1688 * 1689 * These are used to allocate inlined action record memory. 1690 * 1691 * Allocates an external index table action record. 1692 * 1693 * NOTE: 1694 * Implementation of the internals of the external function will be a stack with 1695 * push and pop. 1696 * 1697 * Returns success or failure code. 1698 */ 1699 int tf_alloc_tbl_entry(struct tf *tfp, 1700 struct tf_alloc_tbl_entry_parms *parms); 1701 1702 /** 1703 * tf_free_tbl_entry parameter definition 1704 */ 1705 struct tf_free_tbl_entry_parms { 1706 /** 1707 * [in] Receive or transmit direction 1708 */ 1709 enum tf_dir dir; 1710 /** 1711 * [in] Type of the allocation type 1712 */ 1713 enum tf_tbl_type type; 1714 /** 1715 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT) 1716 */ 1717 uint32_t tbl_scope_id; 1718 /** 1719 * [in] Index to free 1720 */ 1721 uint32_t idx; 1722 }; 1723 1724 /** 1725 * free index table entry 1726 * 1727 * Used to free a previously allocated table entry. 1728 * 1729 * Internal types: 1730 * 1731 * The element is freed and given back to the session pool. 1732 * 1733 * External types: 1734 * 1735 * Frees an external index table action record. 1736 * 1737 * NOTE: 1738 * Implementation of the internals of the external table will be a stack with 1739 * push and pop. 1740 * 1741 * Returns success or failure code. 1742 */ 1743 int tf_free_tbl_entry(struct tf *tfp, 1744 struct tf_free_tbl_entry_parms *parms); 1745 1746 /** 1747 * tf_set_tbl_entry parameter definition 1748 */ 1749 struct tf_set_tbl_entry_parms { 1750 /** 1751 * [in] Table scope identifier 1752 */ 1753 uint32_t tbl_scope_id; 1754 /** 1755 * [in] Receive or transmit direction 1756 */ 1757 enum tf_dir dir; 1758 /** 1759 * [in] Type of object to set 1760 */ 1761 enum tf_tbl_type type; 1762 /** 1763 * [in] Entry data 1764 */ 1765 uint8_t *data; 1766 /** 1767 * [in] Entry size 1768 */ 1769 uint16_t data_sz_in_bytes; 1770 /** 1771 * [in] External memory channel type to use 1772 */ 1773 enum tf_ext_mem_chan_type chan_type; 1774 /** 1775 * [in] Entry index to write to 1776 */ 1777 uint32_t idx; 1778 }; 1779 1780 /** 1781 * set index table entry 1782 * 1783 * Used to set an application programmed index table entry into a 1784 * previous allocated table location. 1785 * 1786 * Returns success or failure code. 1787 */ 1788 int tf_set_tbl_entry(struct tf *tfp, 1789 struct tf_set_tbl_entry_parms *parms); 1790 1791 /** 1792 * tf_get_shared_tbl_increment parameter definition 1793 */ 1794 struct tf_get_shared_tbl_increment_parms { 1795 /** 1796 * [in] Receive or transmit direction 1797 */ 1798 enum tf_dir dir; 1799 /** 1800 * [in] Type of object to set 1801 */ 1802 enum tf_tbl_type type; 1803 /** 1804 * [out] Value to increment by for resource type 1805 */ 1806 uint32_t increment_cnt; 1807 }; 1808 1809 /** 1810 * tf_get_shared_tbl_increment 1811 * 1812 * This API is currently only required for use in the shared 1813 * session for Thor (p58) actions. An increment count is returned per 1814 * type to indicate how much to increment the start by for each 1815 * entry (see tf_resource_info) 1816 * 1817 * Returns success or failure code. 1818 */ 1819 int tf_get_shared_tbl_increment(struct tf *tfp, 1820 struct tf_get_shared_tbl_increment_parms *parms); 1821 1822 /** 1823 * tf_get_tbl_entry parameter definition 1824 */ 1825 struct tf_get_tbl_entry_parms { 1826 /** 1827 * [in] Receive or transmit direction 1828 */ 1829 enum tf_dir dir; 1830 /** 1831 * [in] Type of object to get 1832 */ 1833 enum tf_tbl_type type; 1834 /** 1835 * [out] Entry data 1836 */ 1837 uint8_t *data; 1838 /** 1839 * [in] Entry size 1840 */ 1841 uint16_t data_sz_in_bytes; 1842 /** 1843 * [in] External memory channel type to use 1844 */ 1845 enum tf_ext_mem_chan_type chan_type; 1846 /** 1847 * [in] Entry index to read 1848 */ 1849 uint32_t idx; 1850 }; 1851 1852 /** 1853 * get index table entry 1854 * 1855 * Used to retrieve a previous set index table entry. 1856 * 1857 * Reads and compares with the shadow table copy (if enabled) (only 1858 * for internal objects). 1859 * 1860 * Returns success or failure code. Failure will be returned if the 1861 * provided data buffer is too small for the data type requested. 1862 */ 1863 int tf_get_tbl_entry(struct tf *tfp, 1864 struct tf_get_tbl_entry_parms *parms); 1865 1866 /** 1867 * tf_bulk_get_tbl_entry parameter definition 1868 */ 1869 struct tf_bulk_get_tbl_entry_parms { 1870 /** 1871 * [in] Receive or transmit direction 1872 */ 1873 enum tf_dir dir; 1874 /** 1875 * [in] Type of object to get 1876 */ 1877 enum tf_tbl_type type; 1878 /** 1879 * [in] Starting index to read from 1880 */ 1881 uint32_t starting_idx; 1882 /** 1883 * [in] Number of sequential entries 1884 */ 1885 uint16_t num_entries; 1886 /** 1887 * [in] Size of the single entry 1888 */ 1889 uint16_t entry_sz_in_bytes; 1890 /** 1891 * [out] Host physical address, where the data 1892 * will be copied to by the firmware. 1893 * Use tfp_calloc() API and mem_pa 1894 * variable of the tfp_calloc_parms 1895 * structure for the physical address. 1896 */ 1897 uint64_t physical_mem_addr; 1898 /** 1899 * [in] External memory channel type to use 1900 */ 1901 enum tf_ext_mem_chan_type chan_type; 1902 }; 1903 1904 /** 1905 * Bulk get index table entry 1906 * 1907 * Used to retrieve a set of index table entries. 1908 * 1909 * Entries within the range may not have been allocated using 1910 * tf_alloc_tbl_entry() at the time of access. But the range must 1911 * be within the bounds determined from tf_open_session() for the 1912 * given table type. Currently, this is only used for collecting statistics. 1913 * 1914 * Returns success or failure code. Failure will be returned if the 1915 * provided data buffer is too small for the data type requested. 1916 */ 1917 int tf_bulk_get_tbl_entry(struct tf *tfp, 1918 struct tf_bulk_get_tbl_entry_parms *parms); 1919 1920 /** 1921 * @page exact_match Exact Match Table 1922 * 1923 * @ref tf_insert_em_entry 1924 * 1925 * @ref tf_delete_em_entry 1926 * 1927 * @ref tf_search_em_entry 1928 * 1929 */ 1930 /** 1931 * tf_insert_em_entry parameter definition 1932 */ 1933 struct tf_insert_em_entry_parms { 1934 /** 1935 * [in] receive or transmit direction 1936 */ 1937 enum tf_dir dir; 1938 /** 1939 * [in] internal or external 1940 */ 1941 enum tf_mem mem; 1942 /** 1943 * [in] ID of table scope to use (external only) 1944 */ 1945 uint32_t tbl_scope_id; 1946 /** 1947 * [in] ptr to structure containing key fields 1948 */ 1949 uint8_t *key; 1950 /** 1951 * [in] key bit length 1952 */ 1953 uint16_t key_sz_in_bits; 1954 /** 1955 * [in] ptr to structure containing result field 1956 */ 1957 uint8_t *em_record; 1958 /** 1959 * [out] result size in bits 1960 */ 1961 uint16_t em_record_sz_in_bits; 1962 /** 1963 * [in] duplicate check flag 1964 */ 1965 uint8_t dup_check; 1966 /** 1967 * [in] External memory channel type to use 1968 */ 1969 enum tf_ext_mem_chan_type chan_type; 1970 /** 1971 * [out] Flow handle value for the inserted entry. This is encoded 1972 * as the entries[4]:bucket[2]:hashId[1]:hash[14] 1973 */ 1974 uint64_t flow_handle; 1975 /** 1976 * [out] Flow id is returned as null (internal) 1977 * Flow id is the GFID value for the inserted entry (external) 1978 * This is the value written to the BD and useful information for mark. 1979 */ 1980 uint64_t flow_id; 1981 }; 1982 /** 1983 * tf_delete_em_entry parameter definition 1984 */ 1985 struct tf_delete_em_entry_parms { 1986 /** 1987 * [in] receive or transmit direction 1988 */ 1989 enum tf_dir dir; 1990 /** 1991 * [in] internal or external 1992 */ 1993 enum tf_mem mem; 1994 /** 1995 * [in] ID of table scope to use (external only) 1996 */ 1997 uint32_t tbl_scope_id; 1998 /** 1999 * [out] The index of the entry 2000 */ 2001 uint16_t index; 2002 /** 2003 * [in] External memory channel type to use 2004 */ 2005 enum tf_ext_mem_chan_type chan_type; 2006 /** 2007 * [in] structure containing flow delete handle information 2008 */ 2009 uint64_t flow_handle; 2010 }; 2011 /** 2012 * tf_move_em_entry parameter definition 2013 */ 2014 struct tf_move_em_entry_parms { 2015 /** 2016 * [in] receive or transmit direction 2017 */ 2018 enum tf_dir dir; 2019 /** 2020 * [in] internal or external 2021 */ 2022 enum tf_mem mem; 2023 /** 2024 * [in] ID of table scope to use (external only) 2025 */ 2026 uint32_t tbl_scope_id; 2027 /** 2028 * [in] ID of table interface to use (SR2 only) 2029 */ 2030 uint32_t tbl_if_id; 2031 /** 2032 * [in] epoch group IDs of entry to delete 2033 * 2 element array with 2 ids. (SR2 only) 2034 */ 2035 uint16_t *epochs; 2036 /** 2037 * [out] The index of the entry 2038 */ 2039 uint16_t index; 2040 /** 2041 * [in] External memory channel type to use 2042 */ 2043 enum tf_ext_mem_chan_type chan_type; 2044 /** 2045 * [in] The index of the new EM record 2046 */ 2047 uint32_t new_index; 2048 /** 2049 * [in] structure containing flow delete handle information 2050 */ 2051 uint64_t flow_handle; 2052 }; 2053 /** 2054 * tf_search_em_entry parameter definition (Future) 2055 */ 2056 struct tf_search_em_entry_parms { 2057 /** 2058 * [in] receive or transmit direction 2059 */ 2060 enum tf_dir dir; 2061 /** 2062 * [in] internal or external 2063 */ 2064 enum tf_mem mem; 2065 /** 2066 * [in] ID of table scope to use (external only) 2067 */ 2068 uint32_t tbl_scope_id; 2069 /** 2070 * [in] ptr to structure containing key fields 2071 */ 2072 uint8_t *key; 2073 /** 2074 * [in] key bit length 2075 */ 2076 uint16_t key_sz_in_bits; 2077 /** 2078 * [in/out] ptr to structure containing EM record fields 2079 */ 2080 uint8_t *em_record; 2081 /** 2082 * [out] result size in bits 2083 */ 2084 uint16_t em_record_sz_in_bits; 2085 /** 2086 * [in] External memory channel type to use 2087 */ 2088 enum tf_ext_mem_chan_type chan_type; 2089 /** 2090 * [in] ptr to structure containing flow delete handle 2091 */ 2092 uint64_t flow_handle; 2093 }; 2094 2095 /** 2096 * insert em hash entry in internal table memory 2097 * 2098 * Internal: 2099 * 2100 * This API inserts an exact match entry into internal EM table memory 2101 * of the specified direction. 2102 * 2103 * Note: The EM record is managed within the TruFlow core and not the 2104 * application. 2105 * 2106 * Shadow copy of internal record table an association with hash and 1,2, or 4 2107 * associated buckets 2108 * 2109 * External: 2110 * This API inserts an exact match entry into DRAM EM table memory of the 2111 * specified direction and table scope. 2112 * 2113 * The insertion of duplicate entries in an EM table is not permitted. If a 2114 * TruFlow application can guarantee that it will never insert duplicates, it 2115 * can disable duplicate checking by passing a zero value in the dup_check 2116 * parameter to this API. This will optimize performance. Otherwise, the 2117 * TruFlow library will enforce protection against inserting duplicate entries. 2118 * 2119 * Flow handle is defined in this document: 2120 * 2121 * https://docs.google.com 2122 * /document/d/1NESu7RpTN3jwxbokaPfYORQyChYRmJgs40wMIRe8_-Q/edit 2123 * 2124 * Returns success or busy code. 2125 * 2126 */ 2127 int tf_insert_em_entry(struct tf *tfp, 2128 struct tf_insert_em_entry_parms *parms); 2129 2130 /** 2131 * delete em hash entry table memory 2132 * 2133 * Internal: 2134 * 2135 * This API deletes an exact match entry from internal EM table memory of the 2136 * specified direction. If a valid flow ptr is passed in then that takes 2137 * precedence over the pointer to the complete key passed in. 2138 * 2139 * 2140 * External: 2141 * 2142 * This API deletes an exact match entry from EM table memory of the specified 2143 * direction and table scope. If a valid flow handle is passed in then that 2144 * takes precedence over the pointer to the complete key passed in. 2145 * 2146 * The TruFlow library may release a dynamic bucket when an entry is deleted. 2147 * 2148 * 2149 * Returns success or not found code 2150 * 2151 * 2152 */ 2153 int tf_delete_em_entry(struct tf *tfp, 2154 struct tf_delete_em_entry_parms *parms); 2155 2156 /** 2157 * search em hash entry table memory (Future) 2158 * 2159 * Internal: 2160 2161 * This API looks up an EM entry in table memory with the specified EM 2162 * key or flow (flow takes precedence) and direction. 2163 * 2164 * The status will be one of: success or entry not found. If the lookup 2165 * succeeds, a pointer to the matching entry and the result record associated 2166 * with the matching entry will be provided. 2167 * 2168 * If flow_handle is set, search shadow copy. 2169 * 2170 * Otherwise, query the fw with key to get result. 2171 * 2172 * External: 2173 * 2174 * This API looks up an EM entry in table memory with the specified EM 2175 * key or flow_handle (flow takes precedence), direction and table scope. 2176 * 2177 * The status will be one of: success or entry not found. If the lookup 2178 * succeeds, a pointer to the matching entry and the result record associated 2179 * with the matching entry will be provided. 2180 * 2181 * Returns success or not found code 2182 * 2183 */ 2184 int tf_search_em_entry(struct tf *tfp, 2185 struct tf_search_em_entry_parms *parms); 2186 2187 /** 2188 * @page global Global Configuration 2189 * 2190 * @ref tf_set_global_cfg 2191 * 2192 * @ref tf_get_global_cfg 2193 */ 2194 /** 2195 * Tunnel Encapsulation Offsets 2196 */ 2197 enum tf_tunnel_encap_offsets { 2198 TF_TUNNEL_ENCAP_L2, 2199 TF_TUNNEL_ENCAP_NAT, 2200 TF_TUNNEL_ENCAP_MPLS, 2201 TF_TUNNEL_ENCAP_VXLAN, 2202 TF_TUNNEL_ENCAP_GENEVE, 2203 TF_TUNNEL_ENCAP_NVGRE, 2204 TF_TUNNEL_ENCAP_GRE, 2205 TF_TUNNEL_ENCAP_FULL_GENERIC 2206 }; 2207 /** 2208 * Global Configuration Table Types 2209 */ 2210 enum tf_global_config_type { 2211 TF_TUNNEL_ENCAP, /**< Tunnel Encap Config(TECT) */ 2212 TF_ACTION_BLOCK, /**< Action Block Config(ABCR) */ 2213 TF_COUNTER_CFG, /**< Counter Configuration (CNTRS_CTRL) */ 2214 TF_METER_CFG, /**< Meter Config(ACTP4_FMTCR) */ 2215 TF_METER_INTERVAL_CFG, /**< Meter Interval Config(FMTCR_INTERVAL) */ 2216 TF_GLOBAL_CFG_TYPE_MAX 2217 }; 2218 2219 /** 2220 * tf_global_cfg parameter definition 2221 */ 2222 struct tf_global_cfg_parms { 2223 /** 2224 * [in] receive or transmit direction 2225 */ 2226 enum tf_dir dir; 2227 /** 2228 * [in] Global config type 2229 */ 2230 enum tf_global_config_type type; 2231 /** 2232 * [in] Offset @ the type 2233 */ 2234 uint32_t offset; 2235 /** 2236 * [in/out] Value of the configuration 2237 * set - Read, Modify and Write 2238 * get - Read the full configuration 2239 */ 2240 uint8_t *config; 2241 /** 2242 * [in] Configuration mask 2243 * set - Read, Modify with mask and Write 2244 * get - unused 2245 */ 2246 uint8_t *config_mask; 2247 /** 2248 * [in] struct containing size 2249 */ 2250 uint16_t config_sz_in_bytes; 2251 }; 2252 2253 /** 2254 * Get global configuration 2255 * 2256 * Retrieve the configuration 2257 * 2258 * Returns success or failure code. 2259 */ 2260 int tf_get_global_cfg(struct tf *tfp, 2261 struct tf_global_cfg_parms *parms); 2262 2263 /** 2264 * Update the global configuration table 2265 * 2266 * Read, modify write the value. 2267 * 2268 * Returns success or failure code. 2269 */ 2270 int tf_set_global_cfg(struct tf *tfp, 2271 struct tf_global_cfg_parms *parms); 2272 2273 /** 2274 * @page if_tbl Interface Table Access 2275 * 2276 * @ref tf_set_if_tbl_entry 2277 * 2278 * @ref tf_get_if_tbl_entry 2279 * 2280 * @ref tf_restore_if_tbl_entry 2281 */ 2282 /** 2283 * Enumeration of TruFlow interface table types. 2284 */ 2285 enum tf_if_tbl_type { 2286 /** Default Profile L2 Context Entry */ 2287 TF_IF_TBL_TYPE_PROF_SPIF_DFLT_L2_CTXT, 2288 /** Default Profile TCAM/Lookup Action Record Pointer Table */ 2289 TF_IF_TBL_TYPE_PROF_PARIF_DFLT_ACT_REC_PTR, 2290 /** Error Profile TCAM Miss Action Record Pointer Table */ 2291 TF_IF_TBL_TYPE_PROF_PARIF_ERR_ACT_REC_PTR, 2292 /** Default Error Profile TCAM Miss Action Record Pointer Table */ 2293 TF_IF_TBL_TYPE_LKUP_PARIF_DFLT_ACT_REC_PTR, 2294 /** Ingress lookup table */ 2295 TF_IF_TBL_TYPE_ILT, 2296 /** VNIC/SVIF Properties Table */ 2297 TF_IF_TBL_TYPE_VSPT, 2298 TF_IF_TBL_TYPE_MAX 2299 }; 2300 2301 /** 2302 * tf_set_if_tbl_entry parameter definition 2303 */ 2304 struct tf_set_if_tbl_entry_parms { 2305 /** 2306 * [in] Receive or transmit direction 2307 */ 2308 enum tf_dir dir; 2309 /** 2310 * [in] Type of object to set 2311 */ 2312 enum tf_if_tbl_type type; 2313 /** 2314 * [in] Entry data 2315 */ 2316 uint8_t *data; 2317 /** 2318 * [in] Entry size 2319 */ 2320 uint16_t data_sz_in_bytes; 2321 /** 2322 * [in] Interface to write 2323 */ 2324 uint32_t idx; 2325 }; 2326 2327 /** 2328 * set interface table entry 2329 * 2330 * Used to set an interface table. This API is used for managing tables indexed 2331 * by SVIF/SPIF/PARIF interfaces. In current implementation only the value is 2332 * set. 2333 * Returns success or failure code. 2334 */ 2335 int tf_set_if_tbl_entry(struct tf *tfp, 2336 struct tf_set_if_tbl_entry_parms *parms); 2337 2338 /** 2339 * tf_get_if_tbl_entry parameter definition 2340 */ 2341 struct tf_get_if_tbl_entry_parms { 2342 /** 2343 * [in] Receive or transmit direction 2344 */ 2345 enum tf_dir dir; 2346 /** 2347 * [in] Type of table to get 2348 */ 2349 enum tf_if_tbl_type type; 2350 /** 2351 * [out] Entry data 2352 */ 2353 uint8_t *data; 2354 /** 2355 * [in] Entry size 2356 */ 2357 uint16_t data_sz_in_bytes; 2358 /** 2359 * [in] Entry index to read 2360 */ 2361 uint32_t idx; 2362 }; 2363 2364 /** 2365 * get interface table entry 2366 * 2367 * Used to retrieve an interface table entry. 2368 * 2369 * Reads the interface table entry value 2370 * 2371 * Returns success or failure code. Failure will be returned if the 2372 * provided data buffer is too small for the data type requested. 2373 */ 2374 int tf_get_if_tbl_entry(struct tf *tfp, 2375 struct tf_get_if_tbl_entry_parms *parms); 2376 2377 /** 2378 * tf_get_version parameters definition. 2379 */ 2380 struct tf_get_version_parms { 2381 /** 2382 * [in] device type 2383 * 2384 * Device type for the session. 2385 */ 2386 enum tf_device_type device_type; 2387 2388 /** 2389 * [in] bp 2390 * The pointer to the parent bp struct. This is only used for HWRM 2391 * message passing within the portability layer. The type is struct 2392 * bnxt. 2393 */ 2394 void *bp; 2395 2396 /* [out] major 2397 * 2398 * Version Major number. 2399 */ 2400 uint8_t major; 2401 2402 /* [out] minor 2403 * 2404 * Version Minor number. 2405 */ 2406 uint8_t minor; 2407 2408 /* [out] update 2409 * 2410 * Version Update number. 2411 */ 2412 uint8_t update; 2413 2414 /** 2415 * [out] dev_ident_caps 2416 * 2417 * fw available identifier resource list 2418 */ 2419 uint32_t dev_ident_caps; 2420 2421 /** 2422 * [out] dev_tbl_caps 2423 * 2424 * fw available table resource list 2425 */ 2426 uint32_t dev_tbl_caps; 2427 2428 /** 2429 * [out] dev_tcam_caps 2430 * 2431 * fw available tcam resource list 2432 */ 2433 uint32_t dev_tcam_caps; 2434 2435 /** 2436 * [out] dev_em_caps 2437 * 2438 * fw available em resource list 2439 */ 2440 uint32_t dev_em_caps; 2441 }; 2442 2443 /** 2444 * Get tf fw version 2445 * 2446 * Used to retrieve Truflow fw version information. 2447 * 2448 * Returns success or failure code. 2449 */ 2450 int tf_get_version(struct tf *tfp, 2451 struct tf_get_version_parms *parms); 2452 2453 /** 2454 * tf_query_sram_resources parameter definition 2455 */ 2456 struct tf_query_sram_resources_parms { 2457 /** 2458 * [in] Device type 2459 * 2460 * Device type for the session. 2461 */ 2462 enum tf_device_type device_type; 2463 2464 /** 2465 * [in] bp 2466 * The pointer to the parent bp struct. This is only used for HWRM 2467 * message passing within the portability layer. The type is struct 2468 * bnxt. 2469 */ 2470 void *bp; 2471 2472 /** 2473 * [in] Receive or transmit direction 2474 */ 2475 enum tf_dir dir; 2476 2477 /** 2478 * [out] Bank resource count in 8 bytes entry 2479 */ 2480 2481 uint32_t bank_resc_count[TF_SRAM_BANK_ID_MAX]; 2482 2483 /** 2484 * [out] Dynamic SRAM Enable 2485 */ 2486 bool dynamic_sram_capable; 2487 2488 /** 2489 * [out] SRAM profile 2490 */ 2491 uint8_t sram_profile; 2492 }; 2493 2494 /** 2495 * Get SRAM resources information 2496 * 2497 * Used to retrieve sram bank partition information 2498 * 2499 * Returns success or failure code. 2500 */ 2501 int tf_query_sram_resources(struct tf *tfp, 2502 struct tf_query_sram_resources_parms *parms); 2503 2504 /** 2505 * tf_set_sram_policy parameter definition 2506 */ 2507 struct tf_set_sram_policy_parms { 2508 /** 2509 * [in] Device type 2510 * 2511 * Device type for the session. 2512 */ 2513 enum tf_device_type device_type; 2514 2515 /** 2516 * [in] Receive or transmit direction 2517 */ 2518 enum tf_dir dir; 2519 2520 /** 2521 * [in] Array of Bank id for each truflow tbl type 2522 */ 2523 enum tf_sram_bank_id bank_id[TF_TBL_TYPE_ACT_MODIFY_64B + 1]; 2524 }; 2525 2526 /** 2527 * Set SRAM policy 2528 * 2529 * Used to assign SRAM bank index to all truflow table type. 2530 * 2531 * Returns success or failure code. 2532 */ 2533 int tf_set_sram_policy(struct tf *tfp, 2534 struct tf_set_sram_policy_parms *parms); 2535 2536 /** 2537 * tf_get_sram_policy parameter definition 2538 */ 2539 struct tf_get_sram_policy_parms { 2540 /** 2541 * [in] Device type 2542 * 2543 * Device type for the session. 2544 */ 2545 enum tf_device_type device_type; 2546 2547 /** 2548 * [in] Receive or transmit direction 2549 */ 2550 enum tf_dir dir; 2551 2552 /** 2553 * [out] Array of Bank id for each truflow tbl type 2554 */ 2555 enum tf_sram_bank_id bank_id[TF_TBL_TYPE_ACT_MODIFY_64B + 1]; 2556 }; 2557 2558 /** 2559 * Get SRAM policy 2560 * 2561 * Used to get the assigned bank of table types. 2562 * 2563 * Returns success or failure code. 2564 */ 2565 int tf_get_sram_policy(struct tf *tfp, 2566 struct tf_get_sram_policy_parms *parms); 2567 2568 #endif /* _TF_CORE_H_ */ 2569