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 */
33 /********** BEGIN API FUNCTION PROTOTYPES/PARAMETERS **********/
36 * @page general General
38 * @ref tf_open_session
40 * @ref tf_attach_session
42 * @ref tf_close_session
46 /** Session Version defines
48 * The version controls the format of the tf_session and
49 * tf_session_info structure. This is to assure upgrade between
50 * versions can be supported.
52 #define TF_SESSION_VER_MAJOR 1 /**< Major Version */
53 #define TF_SESSION_VER_MINOR 0 /**< Minor Version */
54 #define TF_SESSION_VER_UPDATE 0 /**< Update Version */
58 * Name of the TruFlow control channel interface. Expects
59 * format to be RTE Name specific, i.e. rte_eth_dev_get_name_by_port()
61 #define TF_SESSION_NAME_MAX 64
63 #define TF_FW_SESSION_ID_INVALID 0xFF /**< Invalid FW Session ID define */
65 /** Session Identifier
67 * Unique session identifier which includes PCIe bus info to
68 * distinguish the PF and session info to identify the associated
69 * TruFlow session. Session ID is constructed from the passed in
70 * ctrl_chan_name in tf_open_session() together with an allocated
71 * fw_session_id. Done by TruFlow on tf_open_session().
79 uint8_t fw_session_id;
85 * The version controls the format of the tf_session and
86 * tf_session_info structure. This is to assure upgrade between
87 * versions can be supported.
89 * Please see the TF_VER_MAJOR/MINOR and UPDATE defines.
91 struct tf_session_version {
97 /** Session supported device types
100 enum tf_device_type {
101 TF_DEVICE_TYPE_WH = 0, /**< Whitney+ */
102 TF_DEVICE_TYPE_BRD2, /**< TBD */
103 TF_DEVICE_TYPE_BRD3, /**< TBD */
104 TF_DEVICE_TYPE_BRD4, /**< TBD */
105 TF_DEVICE_TYPE_MAX /**< Maximum */
108 /** TruFlow Session Information
110 * Structure defining a TruFlow Session, also known as a Management
111 * session. This structure is initialized at time of
112 * tf_open_session(). It is passed to all of the TruFlow APIs as way
113 * to prescribe and isolate resources between different TruFlow ULP
116 struct tf_session_info {
118 * TrueFlow Version. Used to control the structure layout when
119 * sharing sessions. No guarantee that a secondary process
120 * would come from the same version of an executable.
121 * TruFlow initializes this variable on tf_open_session().
126 struct tf_session_version ver;
128 * will be STAILQ_ENTRY(tf_session_info) next
135 * Session ID is a unique identifier for the session. TruFlow
136 * initializes this variable during tf_open_session()
140 * Access: Truflow & ULP
142 union tf_session_id session_id;
144 * Protects access to core_data. Lock is initialized and owned
145 * by ULP. TruFlow can access the core_data without checking
153 * The core_data holds the TruFlow tf_session data
154 * structure. This memory is allocated and owned by TruFlow on
157 * TruFlow uses this memory for session management control
158 * until the session is closed by ULP. Access control is done
159 * by the spin_lock which ULP controls ahead of TruFlow API
162 * Please see tf_open_session_parms for specification details
170 * The core_data_sz_bytes specifies the size of core_data in
173 * The size is set by TruFlow on tf_open_session().
175 * Please see tf_open_session_parms for specification details
181 uint32_t core_data_sz_bytes;
186 * Contains a pointer to the session info. Allocated by ULP and passed
187 * to TruFlow using tf_open_session(). TruFlow will populate the
188 * session info at that time. Additional 'opens' can be done using
189 * same session_info by using tf_attach_session().
191 * It is expected that ULP allocates this memory as shared memory.
193 * NOTE: This struct must be within the BNXT PMD struct bnxt
194 * (bp). This allows use of container_of() to get access to the PMD.
197 struct tf_session_info *session;
202 * tf_open_session parameters definition.
204 struct tf_open_session_parms {
205 /** [in] ctrl_chan_name
207 * String containing name of control channel interface to be
208 * used for this session to communicate with firmware.
210 * The ctrl_chan_name can be looked up by using
211 * rte_eth_dev_get_name_by_port() within the ULP.
213 * ctrl_chan_name will be used as part of a name for any
214 * shared memory allocation.
216 char ctrl_chan_name[TF_SESSION_NAME_MAX];
219 * Boolean controlling the use and availability of shadow
220 * copy. Shadow copy will allow the TruFlow to keep track of
221 * resource content on the firmware side without having to
222 * query firmware. Additional private session core_data will
223 * be allocated if this boolean is set to 'true', default
226 * Size of memory depends on the NVM Resource settings for the
230 /** [in/out] session_id
232 * Session_id is unique per session.
234 * Session_id is composed of domain, bus, device and
235 * fw_session_id. The construction is done by parsing the
236 * ctrl_chan_name together with allocation of a fw_session_id.
238 * The session_id allows a session to be shared between devices.
240 union tf_session_id session_id;
243 * Device type is passed, one of Wh+, Brd2, Brd3, Brd4
245 enum tf_device_type device_type;
249 * Opens a new TruFlow management session.
251 * TruFlow will allocate session specific memory, shared memory, to
252 * hold its session data. This data is private to TruFlow.
254 * Multiple PFs can share the same session. An association, refcount,
255 * between session and PFs is maintained within TruFlow. Thus, a PF
256 * can attach to an existing session, see tf_attach_session().
258 * No other TruFlow APIs will succeed unless this API is first called and
261 * tf_open_session() returns a session id that can be used on attach.
264 * Pointer to TF handle
266 * Pointer to open parameters
269 * - (0) if successful.
270 * - (-EINVAL) on failure.
272 int tf_open_session(struct tf *tfp,
273 struct tf_open_session_parms *parms);
275 struct tf_attach_session_parms {
276 /** [in] ctrl_chan_name
278 * String containing name of control channel interface to be
279 * used for this session to communicate with firmware.
281 * The ctrl_chan_name can be looked up by using
282 * rte_eth_dev_get_name_by_port() within the ULP.
284 * ctrl_chan_name will be used as part of a name for any
285 * shared memory allocation.
287 char ctrl_chan_name[TF_SESSION_NAME_MAX];
289 /** [in] attach_chan_name
291 * String containing name of attach channel interface to be
292 * used for this session.
294 * The attach_chan_name must be given to a 2nd process after
295 * the primary process has been created. This is the
296 * ctrl_chan_name of the primary process and is used to find
297 * the shared memory for the session that the attach is going
300 char attach_chan_name[TF_SESSION_NAME_MAX];
304 * Session_id is unique per session. For Attach the session_id
305 * should be the session_id that was returned on the first
308 * Session_id is composed of domain, bus, device and
309 * fw_session_id. The construction is done by parsing the
310 * ctrl_chan_name together with allocation of a fw_session_id
311 * during tf_open_session().
313 * A reference count will be incremented on attach. A session
314 * is first fully closed when reference count is zero by
315 * calling tf_close_session().
317 union tf_session_id session_id;
321 * Attaches to an existing session. Used when more than one PF wants
322 * to share a single session. In that case all TruFlow management
323 * traffic will be sent to the TruFlow firmware using the 'PF' that
324 * did the attach not the session ctrl channel.
326 * Attach will increment a ref count as to manage the shared session data.
328 * [in] tfp, pointer to TF handle
329 * [in] parms, pointer to attach parameters
332 * - (0) if successful.
333 * - (-EINVAL) on failure.
335 int tf_attach_session(struct tf *tfp,
336 struct tf_attach_session_parms *parms);
339 * Closes an existing session. Cleans up all hardware and firmware
340 * state associated with the TruFlow application session when the last
341 * PF associated with the session results in refcount to be zero.
343 * Returns success or failure code.
345 int tf_close_session(struct tf *tfp);
348 * @page ident Identity Management
350 * @ref tf_alloc_identifier
352 * @ref tf_free_identifier
354 enum tf_identifier_type {
355 /** The L2 Context is returned from the L2 Ctxt TCAM lookup
356 * and can be used in WC TCAM or EM keys to virtualize further
359 TF_IDENT_TYPE_L2_CTXT,
360 /** The WC profile func is returned from the L2 Ctxt TCAM lookup
361 * to enable virtualization of the profile TCAM.
363 TF_IDENT_TYPE_PROF_FUNC,
364 /** The WC profile ID is included in the WC lookup key
365 * to enable virtualization of the WC TCAM hardware.
367 TF_IDENT_TYPE_WC_PROF,
368 /** The EM profile ID is included in the EM lookup key
369 * to enable virtualization of the EM hardware. (not required for Brd4
370 * as it has table scope)
372 TF_IDENT_TYPE_EM_PROF,
373 /** The L2 func is included in the ILT result and from recycling to
374 * enable virtualization of further lookups.
376 TF_IDENT_TYPE_L2_FUNC
382 enum tf_tcam_tbl_type {
383 TF_TCAM_TBL_TYPE_L2_CTXT_TCAM,
384 TF_TCAM_TBL_TYPE_PROF_TCAM,
385 TF_TCAM_TBL_TYPE_WC_TCAM,
386 TF_TCAM_TBL_TYPE_SP_TCAM,
387 TF_TCAM_TBL_TYPE_CT_RULE_TCAM,
388 TF_TCAM_TBL_TYPE_VEB_TCAM,
394 * Enumeration of TruFlow table types. A table type is used to identify a
397 * NOTE: The table type TF_TBL_TYPE_EXT is unique in that it is
398 * the only table type that is connected with a table scope.
401 /** Wh+/Brd2 Action Record */
402 TF_TBL_TYPE_FULL_ACT_RECORD,
403 /** Multicast Groups */
404 TF_TBL_TYPE_MCAST_GROUPS,
405 /** Action Encap 8 Bytes */
406 TF_TBL_TYPE_ACT_ENCAP_8B,
407 /** Action Encap 16 Bytes */
408 TF_TBL_TYPE_ACT_ENCAP_16B,
409 /** Action Encap 64 Bytes */
410 TF_TBL_TYPE_ACT_ENCAP_32B,
411 /** Action Encap 64 Bytes */
412 TF_TBL_TYPE_ACT_ENCAP_64B,
413 /** Action Source Properties SMAC */
414 TF_TBL_TYPE_ACT_SP_SMAC,
415 /** Action Source Properties SMAC IPv4 */
416 TF_TBL_TYPE_ACT_SP_SMAC_IPV4,
417 /** Action Source Properties SMAC IPv6 */
418 TF_TBL_TYPE_ACT_SP_SMAC_IPV6,
419 /** Action Statistics 64 Bits */
420 TF_TBL_TYPE_ACT_STATS_64,
421 /** Action Modify L4 Src Port */
422 TF_TBL_TYPE_ACT_MODIFY_SPORT,
423 /** Action Modify L4 Dest Port */
424 TF_TBL_TYPE_ACT_MODIFY_DPORT,
425 /** Action Modify IPv4 Source */
426 TF_TBL_TYPE_ACT_MODIFY_IPV4_SRC,
427 /** Action _Modify L4 Dest Port */
428 TF_TBL_TYPE_ACT_MODIFY_IPV4_DEST,
429 /** Action Modify IPv6 Source */
430 TF_TBL_TYPE_ACT_MODIFY_IPV6_SRC,
431 /** Action Modify IPv6 Destination */
432 TF_TBL_TYPE_ACT_MODIFY_IPV6_DEST,
436 /** Meter Profiles */
437 TF_TBL_TYPE_METER_PROF,
438 /** Meter Instance */
439 TF_TBL_TYPE_METER_INST,
441 TF_TBL_TYPE_MIRROR_CONFIG,
444 /** Brd4 Epoch 0 table */
446 /** Brd4 Epoch 1 table */
449 TF_TBL_TYPE_METADATA,
451 TF_TBL_TYPE_CT_STATE,
452 /** Brd4 Range Profile */
453 TF_TBL_TYPE_RANGE_PROF,
454 /** Brd4 Range Entry */
455 TF_TBL_TYPE_RANGE_ENTRY,
456 /** Brd4 LAG Entry */
458 /** Brd4 only VNIC/SVIF Table */
459 TF_TBL_TYPE_VNIC_SVIF,
463 /** External table type - initially 1 poolsize entries.
464 * All External table types are associated with a table
465 * scope. Internal types are not.
468 /** Future - external pool of size0 entries */
472 #endif /* _TF_CORE_H_ */