1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
14 #include "tf_project.h"
19 * Truflow Core API Header File
22 /********** BEGIN Truflow Core DEFINITIONS **********/
28 TF_DIR_RX, /**< Receive */
29 TF_DIR_TX, /**< Transmit */
36 * Defines a single pool of external action records of
37 * fixed size. Currently, this is an index.
39 #define TF_EXT_POOL_ENTRY_SZ_BYTES 1
42 * External pool entry count
44 * Defines the number of entries in the external action pool
46 #define TF_EXT_POOL_ENTRY_CNT (1 * 1024)
49 * Number of external pools
51 #define TF_EXT_POOL_CNT_MAX 1
56 #define TF_EXT_POOL_0 0 /**< matches TF_TBL_TYPE_EXT */
57 #define TF_EXT_POOL_1 1 /**< matches TF_TBL_TYPE_EXT_0 */
59 /********** BEGIN API FUNCTION PROTOTYPES/PARAMETERS **********/
62 * @page general General
64 * @ref tf_open_session
66 * @ref tf_attach_session
68 * @ref tf_close_session
72 /** Session Version defines
74 * The version controls the format of the tf_session and
75 * tf_session_info structure. This is to assure upgrade between
76 * versions can be supported.
78 #define TF_SESSION_VER_MAJOR 1 /**< Major Version */
79 #define TF_SESSION_VER_MINOR 0 /**< Minor Version */
80 #define TF_SESSION_VER_UPDATE 0 /**< Update Version */
84 * Name of the TruFlow control channel interface. Expects
85 * format to be RTE Name specific, i.e. rte_eth_dev_get_name_by_port()
87 #define TF_SESSION_NAME_MAX 64
89 #define TF_FW_SESSION_ID_INVALID 0xFF /**< Invalid FW Session ID define */
91 /** Session Identifier
93 * Unique session identifier which includes PCIe bus info to
94 * distinguish the PF and session info to identify the associated
95 * TruFlow session. Session ID is constructed from the passed in
96 * ctrl_chan_name in tf_open_session() together with an allocated
97 * fw_session_id. Done by TruFlow on tf_open_session().
105 uint8_t fw_session_id;
111 * The version controls the format of the tf_session and
112 * tf_session_info structure. This is to assure upgrade between
113 * versions can be supported.
115 * Please see the TF_VER_MAJOR/MINOR and UPDATE defines.
117 struct tf_session_version {
123 /** Session supported device types
126 enum tf_device_type {
127 TF_DEVICE_TYPE_WH = 0, /**< Whitney+ */
128 TF_DEVICE_TYPE_BRD2, /**< TBD */
129 TF_DEVICE_TYPE_BRD3, /**< TBD */
130 TF_DEVICE_TYPE_BRD4, /**< TBD */
131 TF_DEVICE_TYPE_MAX /**< Maximum */
134 /** TruFlow Session Information
136 * Structure defining a TruFlow Session, also known as a Management
137 * session. This structure is initialized at time of
138 * tf_open_session(). It is passed to all of the TruFlow APIs as way
139 * to prescribe and isolate resources between different TruFlow ULP
142 struct tf_session_info {
144 * TrueFlow Version. Used to control the structure layout when
145 * sharing sessions. No guarantee that a secondary process
146 * would come from the same version of an executable.
147 * TruFlow initializes this variable on tf_open_session().
152 struct tf_session_version ver;
154 * will be STAILQ_ENTRY(tf_session_info) next
161 * Session ID is a unique identifier for the session. TruFlow
162 * initializes this variable during tf_open_session()
166 * Access: Truflow & ULP
168 union tf_session_id session_id;
170 * Protects access to core_data. Lock is initialized and owned
171 * by ULP. TruFlow can access the core_data without checking
179 * The core_data holds the TruFlow tf_session data
180 * structure. This memory is allocated and owned by TruFlow on
183 * TruFlow uses this memory for session management control
184 * until the session is closed by ULP. Access control is done
185 * by the spin_lock which ULP controls ahead of TruFlow API
188 * Please see tf_open_session_parms for specification details
196 * The core_data_sz_bytes specifies the size of core_data in
199 * The size is set by TruFlow on tf_open_session().
201 * Please see tf_open_session_parms for specification details
207 uint32_t core_data_sz_bytes;
212 * Contains a pointer to the session info. Allocated by ULP and passed
213 * to TruFlow using tf_open_session(). TruFlow will populate the
214 * session info at that time. Additional 'opens' can be done using
215 * same session_info by using tf_attach_session().
217 * It is expected that ULP allocates this memory as shared memory.
219 * NOTE: This struct must be within the BNXT PMD struct bnxt
220 * (bp). This allows use of container_of() to get access to the PMD.
223 struct tf_session_info *session;
228 * tf_open_session parameters definition.
230 struct tf_open_session_parms {
231 /** [in] ctrl_chan_name
233 * String containing name of control channel interface to be
234 * used for this session to communicate with firmware.
236 * The ctrl_chan_name can be looked up by using
237 * rte_eth_dev_get_name_by_port() within the ULP.
239 * ctrl_chan_name will be used as part of a name for any
240 * shared memory allocation.
242 char ctrl_chan_name[TF_SESSION_NAME_MAX];
245 * Boolean controlling the use and availability of shadow
246 * copy. Shadow copy will allow the TruFlow to keep track of
247 * resource content on the firmware side without having to
248 * query firmware. Additional private session core_data will
249 * be allocated if this boolean is set to 'true', default
252 * Size of memory depends on the NVM Resource settings for the
256 /** [in/out] session_id
258 * Session_id is unique per session.
260 * Session_id is composed of domain, bus, device and
261 * fw_session_id. The construction is done by parsing the
262 * ctrl_chan_name together with allocation of a fw_session_id.
264 * The session_id allows a session to be shared between devices.
266 union tf_session_id session_id;
269 * Device type is passed, one of Wh+, Brd2, Brd3, Brd4
271 enum tf_device_type device_type;
275 * Opens a new TruFlow management session.
277 * TruFlow will allocate session specific memory, shared memory, to
278 * hold its session data. This data is private to TruFlow.
280 * Multiple PFs can share the same session. An association, refcount,
281 * between session and PFs is maintained within TruFlow. Thus, a PF
282 * can attach to an existing session, see tf_attach_session().
284 * No other TruFlow APIs will succeed unless this API is first called and
287 * tf_open_session() returns a session id that can be used on attach.
290 * Pointer to TF handle
292 * Pointer to open parameters
295 * - (0) if successful.
296 * - (-EINVAL) on failure.
298 int tf_open_session(struct tf *tfp,
299 struct tf_open_session_parms *parms);
301 struct tf_attach_session_parms {
302 /** [in] ctrl_chan_name
304 * String containing name of control channel interface to be
305 * used for this session to communicate with firmware.
307 * The ctrl_chan_name can be looked up by using
308 * rte_eth_dev_get_name_by_port() within the ULP.
310 * ctrl_chan_name will be used as part of a name for any
311 * shared memory allocation.
313 char ctrl_chan_name[TF_SESSION_NAME_MAX];
315 /** [in] attach_chan_name
317 * String containing name of attach channel interface to be
318 * used for this session.
320 * The attach_chan_name must be given to a 2nd process after
321 * the primary process has been created. This is the
322 * ctrl_chan_name of the primary process and is used to find
323 * the shared memory for the session that the attach is going
326 char attach_chan_name[TF_SESSION_NAME_MAX];
330 * Session_id is unique per session. For Attach the session_id
331 * should be the session_id that was returned on the first
334 * Session_id is composed of domain, bus, device and
335 * fw_session_id. The construction is done by parsing the
336 * ctrl_chan_name together with allocation of a fw_session_id
337 * during tf_open_session().
339 * A reference count will be incremented on attach. A session
340 * is first fully closed when reference count is zero by
341 * calling tf_close_session().
343 union tf_session_id session_id;
347 * Attaches to an existing session. Used when more than one PF wants
348 * to share a single session. In that case all TruFlow management
349 * traffic will be sent to the TruFlow firmware using the 'PF' that
350 * did the attach not the session ctrl channel.
352 * Attach will increment a ref count as to manage the shared session data.
354 * [in] tfp, pointer to TF handle
355 * [in] parms, pointer to attach parameters
358 * - (0) if successful.
359 * - (-EINVAL) on failure.
361 int tf_attach_session(struct tf *tfp,
362 struct tf_attach_session_parms *parms);
365 * Closes an existing session. Cleans up all hardware and firmware
366 * state associated with the TruFlow application session when the last
367 * PF associated with the session results in refcount to be zero.
369 * Returns success or failure code.
371 int tf_close_session(struct tf *tfp);
374 * @page ident Identity Management
376 * @ref tf_alloc_identifier
378 * @ref tf_free_identifier
380 enum tf_identifier_type {
381 /** The L2 Context is returned from the L2 Ctxt TCAM lookup
382 * and can be used in WC TCAM or EM keys to virtualize further
385 TF_IDENT_TYPE_L2_CTXT,
386 /** The WC profile func is returned from the L2 Ctxt TCAM lookup
387 * to enable virtualization of the profile TCAM.
389 TF_IDENT_TYPE_PROF_FUNC,
390 /** The WC profile ID is included in the WC lookup key
391 * to enable virtualization of the WC TCAM hardware.
393 TF_IDENT_TYPE_WC_PROF,
394 /** The EM profile ID is included in the EM lookup key
395 * to enable virtualization of the EM hardware. (not required for Brd4
396 * as it has table scope)
398 TF_IDENT_TYPE_EM_PROF,
399 /** The L2 func is included in the ILT result and from recycling to
400 * enable virtualization of further lookups.
402 TF_IDENT_TYPE_L2_FUNC
405 /** tf_alloc_identifier parameter definition
407 struct tf_alloc_identifier_parms {
409 * [in] receive or transmit direction
413 * [in] Identifier type
415 enum tf_identifier_type ident_type;
417 * [out] Identifier allocated
422 /** tf_free_identifier parameter definition
424 struct tf_free_identifier_parms {
426 * [in] receive or transmit direction
430 * [in] Identifier type
432 enum tf_identifier_type ident_type;
439 /** allocate identifier resource
441 * TruFlow core will allocate a free id from the per identifier resource type
442 * pool reserved for the session during tf_open(). No firmware is involved.
444 * Returns success or failure code.
446 int tf_alloc_identifier(struct tf *tfp,
447 struct tf_alloc_identifier_parms *parms);
449 /** free identifier resource
451 * TruFlow core will return an id back to the per identifier resource type pool
452 * reserved for the session. No firmware is involved. During tf_close, the
453 * complete pool is returned to the firmware.
455 * Returns success or failure code.
457 int tf_free_identifier(struct tf *tfp,
458 struct tf_free_identifier_parms *parms);
463 enum tf_tcam_tbl_type {
464 TF_TCAM_TBL_TYPE_L2_CTXT_TCAM,
465 TF_TCAM_TBL_TYPE_PROF_TCAM,
466 TF_TCAM_TBL_TYPE_WC_TCAM,
467 TF_TCAM_TBL_TYPE_SP_TCAM,
468 TF_TCAM_TBL_TYPE_CT_RULE_TCAM,
469 TF_TCAM_TBL_TYPE_VEB_TCAM,
475 * Enumeration of TruFlow table types. A table type is used to identify a
478 * NOTE: The table type TF_TBL_TYPE_EXT is unique in that it is
479 * the only table type that is connected with a table scope.
482 /** Wh+/Brd2 Action Record */
483 TF_TBL_TYPE_FULL_ACT_RECORD,
484 /** Multicast Groups */
485 TF_TBL_TYPE_MCAST_GROUPS,
486 /** Action Encap 8 Bytes */
487 TF_TBL_TYPE_ACT_ENCAP_8B,
488 /** Action Encap 16 Bytes */
489 TF_TBL_TYPE_ACT_ENCAP_16B,
490 /** Action Encap 64 Bytes */
491 TF_TBL_TYPE_ACT_ENCAP_32B,
492 /** Action Encap 64 Bytes */
493 TF_TBL_TYPE_ACT_ENCAP_64B,
494 /** Action Source Properties SMAC */
495 TF_TBL_TYPE_ACT_SP_SMAC,
496 /** Action Source Properties SMAC IPv4 */
497 TF_TBL_TYPE_ACT_SP_SMAC_IPV4,
498 /** Action Source Properties SMAC IPv6 */
499 TF_TBL_TYPE_ACT_SP_SMAC_IPV6,
500 /** Action Statistics 64 Bits */
501 TF_TBL_TYPE_ACT_STATS_64,
502 /** Action Modify L4 Src Port */
503 TF_TBL_TYPE_ACT_MODIFY_SPORT,
504 /** Action Modify L4 Dest Port */
505 TF_TBL_TYPE_ACT_MODIFY_DPORT,
506 /** Action Modify IPv4 Source */
507 TF_TBL_TYPE_ACT_MODIFY_IPV4_SRC,
508 /** Action _Modify L4 Dest Port */
509 TF_TBL_TYPE_ACT_MODIFY_IPV4_DEST,
510 /** Action Modify IPv6 Source */
511 TF_TBL_TYPE_ACT_MODIFY_IPV6_SRC,
512 /** Action Modify IPv6 Destination */
513 TF_TBL_TYPE_ACT_MODIFY_IPV6_DEST,
517 /** Meter Profiles */
518 TF_TBL_TYPE_METER_PROF,
519 /** Meter Instance */
520 TF_TBL_TYPE_METER_INST,
522 TF_TBL_TYPE_MIRROR_CONFIG,
525 /** Brd4 Epoch 0 table */
527 /** Brd4 Epoch 1 table */
530 TF_TBL_TYPE_METADATA,
532 TF_TBL_TYPE_CT_STATE,
533 /** Brd4 Range Profile */
534 TF_TBL_TYPE_RANGE_PROF,
535 /** Brd4 Range Entry */
536 TF_TBL_TYPE_RANGE_ENTRY,
537 /** Brd4 LAG Entry */
539 /** Brd4 only VNIC/SVIF Table */
540 TF_TBL_TYPE_VNIC_SVIF,
544 /** External table type - initially 1 poolsize entries.
545 * All External table types are associated with a table
546 * scope. Internal types are not.
549 /** Future - external pool of size0 entries */
553 #endif /* _TF_CORE_H_ */