net/bnxt: support exact match

- Add Exact Match support
- Create EM table pool of memory indices
- Insert exact match internal entry API
- Sends EM internal insert and delete request to firmware

Signed-off-by: Peter Spreadborough <peter.spreadborough@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
This commit is contained in:
Peter Spreadborough 2020-07-02 16:27:56 -07:00 committed by Ferruh Yigit
parent 35a7fe80c2
commit ae2ebb9840
16 changed files with 3255 additions and 452 deletions

File diff suppressed because it is too large Load Diff

View File

@ -86,6 +86,7 @@ struct tf_tbl_type_get_output;
struct tf_em_internal_insert_input;
struct tf_em_internal_insert_output;
struct tf_em_internal_delete_input;
struct tf_em_internal_delete_output;
/* Input params for session attach */
typedef struct tf_session_attach_input {
/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent */
@ -949,6 +950,8 @@ typedef struct tf_em_internal_insert_output {
uint16_t rptr_index;
/* EM record offset 0~3 */
uint8_t rptr_entry;
/* Number of word entries consumed by the key */
uint8_t num_of_entries;
} tf_em_internal_insert_output_t, *ptf_em_internal_insert_output_t;
/* Input params for EM INTERNAL rule delete */
@ -969,4 +972,10 @@ typedef struct tf_em_internal_delete_input {
uint16_t em_key_bitlen;
} tf_em_internal_delete_input_t, *ptf_em_internal_delete_input_t;
/* Input params for EM INTERNAL rule delete */
typedef struct tf_em_internal_delete_output {
/* Original stack allocation index */
uint16_t em_index;
} tf_em_internal_delete_output_t, *ptf_em_internal_delete_output_t;
#endif /* _HWRM_TF_H_ */

View File

@ -152,7 +152,6 @@ static inline uint32_t hashword(const uint32_t *k,
final(a, b, c);
/* Falls through. */
case 0: /* case 0: nothing left to add */
/* FALLTHROUGH */
break;
}
/*------------------------------------------------- report the result */

View File

@ -27,6 +27,14 @@ stack_init(int num_entries, uint32_t *items, struct stack *st)
return 0;
}
/*
* Return the address of the items
*/
uint32_t *stack_items(struct stack *st)
{
return st->items;
}
/* Return the size of the stack
*/
int32_t

View File

@ -36,6 +36,16 @@ int stack_init(int num_entries,
uint32_t *items,
struct stack *st);
/** Return the address of the stack contents
*
* [in] st
* pointer to the stack
*
* return
* pointer to the stack contents
*/
uint32_t *stack_items(struct stack *st);
/** Return the size of the stack
*
* [in] st

View File

@ -45,6 +45,100 @@ static void tf_seeds_init(struct tf_session *session)
}
}
/**
* Create EM Tbl pool of memory indexes.
*
* [in] session
* Pointer to session
* [in] dir
* direction
* [in] num_entries
* number of entries to write
*
* Return:
* 0 - Success, entry allocated - no search support
* -ENOMEM -EINVAL -EOPNOTSUPP
* - Failure, entry not allocated, out of resources
*/
static int
tf_create_em_pool(struct tf_session *session,
enum tf_dir dir,
uint32_t num_entries)
{
struct tfp_calloc_parms parms;
uint32_t i, j;
int rc = 0;
struct stack *pool = &session->em_pool[dir];
parms.nitems = num_entries;
parms.size = sizeof(uint32_t);
parms.alignment = 0;
if (tfp_calloc(&parms) != 0) {
TFP_DRV_LOG(ERR, "EM pool allocation failure %s\n",
strerror(-ENOMEM));
return -ENOMEM;
}
/* Create empty stack
*/
rc = stack_init(num_entries, parms.mem_va, pool);
if (rc != 0) {
TFP_DRV_LOG(ERR, "EM pool stack init failure %s\n",
strerror(-rc));
goto cleanup;
}
/* Fill pool with indexes
*/
j = num_entries - 1;
for (i = 0; i < num_entries; i++) {
rc = stack_push(pool, j);
if (rc != 0) {
TFP_DRV_LOG(ERR, "EM pool stack push failure %s\n",
strerror(-rc));
goto cleanup;
}
j--;
}
if (!stack_is_full(pool)) {
rc = -EINVAL;
TFP_DRV_LOG(ERR, "EM pool stack failure %s\n",
strerror(-rc));
goto cleanup;
}
return 0;
cleanup:
tfp_free((void *)parms.mem_va);
return rc;
}
/**
* Create EM Tbl pool of memory indexes.
*
* [in] session
* Pointer to session
* [in] dir
* direction
*
* Return:
*/
static void
tf_free_em_pool(struct tf_session *session,
enum tf_dir dir)
{
struct stack *pool = &session->em_pool[dir];
uint32_t *ptr;
ptr = stack_items(pool);
tfp_free(ptr);
}
int
tf_open_session(struct tf *tfp,
struct tf_open_session_parms *parms)
@ -54,6 +148,7 @@ tf_open_session(struct tf *tfp,
struct tfp_calloc_parms alloc_parms;
unsigned int domain, bus, slot, device;
uint8_t fw_session_id;
int dir;
if (tfp == NULL || parms == NULL)
return -EINVAL;
@ -110,7 +205,7 @@ tf_open_session(struct tf *tfp,
goto cleanup;
}
tfp->session = (struct tf_session_info *)alloc_parms.mem_va;
tfp->session = alloc_parms.mem_va;
/* Allocate core data for the session */
alloc_parms.nitems = 1;
@ -175,6 +270,16 @@ tf_open_session(struct tf *tfp,
/* Setup hash seeds */
tf_seeds_init(session);
/* Initialize EM pool */
for (dir = 0; dir < TF_DIR_MAX; dir++) {
rc = tf_create_em_pool(session, dir, TF_SESSION_EM_POOL_SIZE);
if (rc) {
TFP_DRV_LOG(ERR,
"EM Pool initialization failed\n");
goto cleanup_close;
}
}
session->ref_count++;
/* Return session ID */
@ -239,6 +344,7 @@ tf_close_session(struct tf *tfp)
int rc_close = 0;
struct tf_session *tfs;
union tf_session_id session_id;
int dir;
if (tfp == NULL || tfp->session == NULL)
return -EINVAL;
@ -268,6 +374,10 @@ tf_close_session(struct tf *tfp)
/* Final cleanup as we're last user of the session */
if (tfs->ref_count == 0) {
/* Free EM pool */
for (dir = 0; dir < TF_DIR_MAX; dir++)
tf_free_em_pool(tfs, dir);
tfp_free(tfp->session->core_data);
tfp_free(tfp->session);
tfp->session = NULL;
@ -301,16 +411,25 @@ int tf_insert_em_entry(struct tf *tfp,
if (tfp == NULL || parms == NULL)
return -EINVAL;
tbl_scope_cb =
tbl_scope_cb_find((struct tf_session *)tfp->session->core_data,
parms->tbl_scope_id);
tbl_scope_cb = tbl_scope_cb_find((struct tf_session *)
(tfp->session->core_data),
parms->tbl_scope_id);
if (tbl_scope_cb == NULL)
return -EINVAL;
/* Process the EM entry per Table Scope type */
return tf_insert_eem_entry((struct tf_session *)tfp->session->core_data,
tbl_scope_cb,
parms);
if (parms->mem == TF_MEM_EXTERNAL) {
/* External EEM */
return tf_insert_eem_entry((struct tf_session *)
(tfp->session->core_data),
tbl_scope_cb,
parms);
} else if (parms->mem == TF_MEM_INTERNAL) {
/* Internal EM */
return tf_insert_em_internal_entry(tfp, parms);
}
return -EINVAL;
}
/** Delete EM hash entry API
@ -327,13 +446,16 @@ int tf_delete_em_entry(struct tf *tfp,
if (tfp == NULL || parms == NULL)
return -EINVAL;
tbl_scope_cb =
tbl_scope_cb_find((struct tf_session *)tfp->session->core_data,
parms->tbl_scope_id);
tbl_scope_cb = tbl_scope_cb_find((struct tf_session *)
(tfp->session->core_data),
parms->tbl_scope_id);
if (tbl_scope_cb == NULL)
return -EINVAL;
return tf_delete_eem_entry(tfp, parms);
if (parms->mem == TF_MEM_EXTERNAL)
return tf_delete_eem_entry(tfp, parms);
else
return tf_delete_em_internal_entry(tfp, parms);
}
/** allocate identifier resource

View File

@ -44,44 +44,7 @@ enum tf_mem {
};
/**
* The size of the external action record (Wh+/Brd2)
*
* Currently set to 512.
*
* AR (16B) + encap (256B) + stats_ptrs (8) + resvd (8)
* + stats (16) = 304 aligned on a 16B boundary
*
* Theoretically, the size should be smaller. ~304B
*/
#define TF_ACTION_RECORD_SZ 512
/**
* External pool size
*
* Defines a single pool of external action records of
* fixed size. Currently, this is an index.
*/
#define TF_EXT_POOL_ENTRY_SZ_BYTES 1
/**
* External pool entry count
*
* Defines the number of entries in the external action pool
*/
#define TF_EXT_POOL_ENTRY_CNT (1 * 1024)
/**
* Number of external pools
*/
#define TF_EXT_POOL_CNT_MAX 1
/**
* External pool Id
*/
#define TF_EXT_POOL_0 0 /**< matches TF_TBL_TYPE_EXT */
#define TF_EXT_POOL_1 1 /**< matches TF_TBL_TYPE_EXT_0 */
/** EEM record AR helper
* EEM record AR helper
*
* Helper to handle the Action Record Pointer in the EEM Record Entry.
*
@ -109,7 +72,8 @@ enum tf_mem {
*/
/** Session Version defines
/**
* Session Version defines
*
* The version controls the format of the tf_session and
* tf_session_info structure. This is to assure upgrade between
@ -119,7 +83,8 @@ enum tf_mem {
#define TF_SESSION_VER_MINOR 0 /**< Minor Version */
#define TF_SESSION_VER_UPDATE 0 /**< Update Version */
/** Session Name
/**
* Session Name
*
* Name of the TruFlow control channel interface. Expects
* format to be RTE Name specific, i.e. rte_eth_dev_get_name_by_port()
@ -128,7 +93,8 @@ enum tf_mem {
#define TF_FW_SESSION_ID_INVALID 0xFF /**< Invalid FW Session ID define */
/** Session Identifier
/**
* Session Identifier
*
* Unique session identifier which includes PCIe bus info to
* distinguish the PF and session info to identify the associated
@ -146,7 +112,8 @@ union tf_session_id {
} internal;
};
/** Session Version
/**
* Session Version
*
* The version controls the format of the tf_session and
* tf_session_info structure. This is to assure upgrade between
@ -160,8 +127,8 @@ struct tf_session_version {
uint8_t update;
};
/** Session supported device types
*
/**
* Session supported device types
*/
enum tf_device_type {
TF_DEVICE_TYPE_WH = 0, /**< Whitney+ */
@ -171,6 +138,147 @@ enum tf_device_type {
TF_DEVICE_TYPE_MAX /**< Maximum */
};
/** Identifier resource types
*/
enum tf_identifier_type {
/** The L2 Context is returned from the L2 Ctxt TCAM lookup
* and can be used in WC TCAM or EM keys to virtualize further
* lookups.
*/
TF_IDENT_TYPE_L2_CTXT,
/** The WC profile func is returned from the L2 Ctxt TCAM lookup
* to enable virtualization of the profile TCAM.
*/
TF_IDENT_TYPE_PROF_FUNC,
/** The WC profile ID is included in the WC lookup key
* to enable virtualization of the WC TCAM hardware.
*/
TF_IDENT_TYPE_WC_PROF,
/** The EM profile ID is included in the EM lookup key
* to enable virtualization of the EM hardware. (not required for SR2
* as it has table scope)
*/
TF_IDENT_TYPE_EM_PROF,
/** The L2 func is included in the ILT result and from recycling to
* enable virtualization of further lookups.
*/
TF_IDENT_TYPE_L2_FUNC,
TF_IDENT_TYPE_MAX
};
/**
* Enumeration of TruFlow table types. A table type is used to identify a
* resource object.
*
* NOTE: The table type TF_TBL_TYPE_EXT is unique in that it is
* the only table type that is connected with a table scope.
*/
enum tf_tbl_type {
/* Internal */
/** Wh+/SR Action Record */
TF_TBL_TYPE_FULL_ACT_RECORD,
/** Wh+/SR/Th Multicast Groups */
TF_TBL_TYPE_MCAST_GROUPS,
/** Wh+/SR Action Encap 8 Bytes */
TF_TBL_TYPE_ACT_ENCAP_8B,
/** Wh+/SR Action Encap 16 Bytes */
TF_TBL_TYPE_ACT_ENCAP_16B,
/** Action Encap 32 Bytes */
TF_TBL_TYPE_ACT_ENCAP_32B,
/** Wh+/SR Action Encap 64 Bytes */
TF_TBL_TYPE_ACT_ENCAP_64B,
/** Action Source Properties SMAC */
TF_TBL_TYPE_ACT_SP_SMAC,
/** Wh+/SR Action Source Properties SMAC IPv4 */
TF_TBL_TYPE_ACT_SP_SMAC_IPV4,
/** Action Source Properties SMAC IPv6 */
TF_TBL_TYPE_ACT_SP_SMAC_IPV6,
/** Wh+/SR Action Statistics 64 Bits */
TF_TBL_TYPE_ACT_STATS_64,
/** Wh+/SR Action Modify L4 Src Port */
TF_TBL_TYPE_ACT_MODIFY_SPORT,
/** Wh+/SR Action Modify L4 Dest Port */
TF_TBL_TYPE_ACT_MODIFY_DPORT,
/** Wh+/SR Action Modify IPv4 Source */
TF_TBL_TYPE_ACT_MODIFY_IPV4_SRC,
/** Wh+/SR Action _Modify L4 Dest Port */
TF_TBL_TYPE_ACT_MODIFY_IPV4_DEST,
/** Action Modify IPv6 Source */
TF_TBL_TYPE_ACT_MODIFY_IPV6_SRC,
/** Action Modify IPv6 Destination */
TF_TBL_TYPE_ACT_MODIFY_IPV6_DEST,
/** Meter Profiles */
TF_TBL_TYPE_METER_PROF,
/** Meter Instance */
TF_TBL_TYPE_METER_INST,
/** Mirror Config */
TF_TBL_TYPE_MIRROR_CONFIG,
/** UPAR */
TF_TBL_TYPE_UPAR,
/** SR2 Epoch 0 table */
TF_TBL_TYPE_EPOCH0,
/** SR2 Epoch 1 table */
TF_TBL_TYPE_EPOCH1,
/** SR2 Metadata */
TF_TBL_TYPE_METADATA,
/** SR2 CT State */
TF_TBL_TYPE_CT_STATE,
/** SR2 Range Profile */
TF_TBL_TYPE_RANGE_PROF,
/** SR2 Range Entry */
TF_TBL_TYPE_RANGE_ENTRY,
/** SR2 LAG Entry */
TF_TBL_TYPE_LAG,
/** SR2 VNIC/SVIF Table */
TF_TBL_TYPE_VNIC_SVIF,
/** Th/SR2 EM Flexible Key builder */
TF_TBL_TYPE_EM_FKB,
/** Th/SR2 WC Flexible Key builder */
TF_TBL_TYPE_WC_FKB,
/* External */
/** External table type - initially 1 poolsize entries.
* All External table types are associated with a table
* scope. Internal types are not.
*/
TF_TBL_TYPE_EXT,
TF_TBL_TYPE_MAX
};
/**
* TCAM table type
*/
enum tf_tcam_tbl_type {
/** L2 Context TCAM */
TF_TCAM_TBL_TYPE_L2_CTXT_TCAM,
/** Profile TCAM */
TF_TCAM_TBL_TYPE_PROF_TCAM,
/** Wildcard TCAM */
TF_TCAM_TBL_TYPE_WC_TCAM,
/** Source Properties TCAM */
TF_TCAM_TBL_TYPE_SP_TCAM,
/** Connection Tracking Rule TCAM */
TF_TCAM_TBL_TYPE_CT_RULE_TCAM,
/** Virtual Edge Bridge TCAM */
TF_TCAM_TBL_TYPE_VEB_TCAM,
TF_TCAM_TBL_TYPE_MAX
};
/**
* EM Resources
* These defines are provisioned during
* tf_open_session()
*/
enum tf_em_tbl_type {
/** The number of internal EM records for the session */
TF_EM_TBL_TYPE_EM_RECORD,
/** The number of table scopes reequested */
TF_EM_TBL_TYPE_TBL_SCOPE,
TF_EM_TBL_TYPE_MAX
};
/** TruFlow Session Information
*
* Structure defining a TruFlow Session, also known as a Management
@ -309,6 +417,30 @@ struct tf_open_session_parms {
* Device type is passed, one of Wh+, Brd2, Brd3, Brd4
*/
enum tf_device_type device_type;
/** [in] Requested Identifier Resources
*
* The number of identifier resources requested for the session.
* The index used is tf_identifier_type.
*/
uint16_t identifer_cnt[TF_IDENT_TYPE_MAX];
/** [in] Requested Index Table resource counts
*
* The number of index table resources requested for the session.
* The index used is tf_tbl_type.
*/
uint16_t tbl_cnt[TF_TBL_TYPE_MAX];
/** [in] Requested TCAM Table resource counts
*
* The number of TCAM table resources requested for the session.
* The index used is tf_tcam_tbl_type.
*/
uint16_t tcam_tbl_cnt[TF_TCAM_TBL_TYPE_MAX];
/** [in] Requested EM resource counts
*
* The number of internal EM table resources requested for the session
* The index used is tf_em_tbl_type.
*/
uint16_t em_tbl_cnt[TF_EM_TBL_TYPE_MAX];
};
/**
@ -417,31 +549,6 @@ int tf_close_session(struct tf *tfp);
*
* @ref tf_free_identifier
*/
enum tf_identifier_type {
/** The L2 Context is returned from the L2 Ctxt TCAM lookup
* and can be used in WC TCAM or EM keys to virtualize further
* lookups.
*/
TF_IDENT_TYPE_L2_CTXT,
/** The WC profile func is returned from the L2 Ctxt TCAM lookup
* to enable virtualization of the profile TCAM.
*/
TF_IDENT_TYPE_PROF_FUNC,
/** The WC profile ID is included in the WC lookup key
* to enable virtualization of the WC TCAM hardware.
*/
TF_IDENT_TYPE_WC_PROF,
/** The EM profile ID is included in the EM lookup key
* to enable virtualization of the EM hardware. (not required for Brd4
* as it has table scope)
*/
TF_IDENT_TYPE_EM_PROF,
/** The L2 func is included in the ILT result and from recycling to
* enable virtualization of further lookups.
*/
TF_IDENT_TYPE_L2_FUNC
};
/** tf_alloc_identifier parameter definition
*/
struct tf_alloc_identifier_parms {
@ -631,19 +738,6 @@ int tf_alloc_tbl_scope(struct tf *tfp,
int tf_free_tbl_scope(struct tf *tfp,
struct tf_free_tbl_scope_parms *parms);
/**
* TCAM table type
*/
enum tf_tcam_tbl_type {
TF_TCAM_TBL_TYPE_L2_CTXT_TCAM,
TF_TCAM_TBL_TYPE_PROF_TCAM,
TF_TCAM_TBL_TYPE_WC_TCAM,
TF_TCAM_TBL_TYPE_SP_TCAM,
TF_TCAM_TBL_TYPE_CT_RULE_TCAM,
TF_TCAM_TBL_TYPE_VEB_TCAM,
TF_TCAM_TBL_TYPE_MAX
};
/**
* @page tcam TCAM Access
@ -813,7 +907,8 @@ struct tf_get_tcam_entry_parms {
uint16_t result_sz_in_bits;
};
/** get TCAM entry
/*
* get TCAM entry
*
* Program a TCAM table entry for a TruFlow session.
*
@ -824,7 +919,8 @@ struct tf_get_tcam_entry_parms {
int tf_get_tcam_entry(struct tf *tfp,
struct tf_get_tcam_entry_parms *parms);
/** tf_free_tcam_entry parameter definition
/*
* tf_free_tcam_entry parameter definition
*/
struct tf_free_tcam_entry_parms {
/**
@ -845,8 +941,7 @@ struct tf_free_tcam_entry_parms {
uint16_t ref_cnt;
};
/** free TCAM entry
*
/*
* Free TCAM entry.
*
* Firmware checks to ensure the TCAM entries are owned by the TruFlow
@ -873,84 +968,7 @@ int tf_free_tcam_entry(struct tf *tfp,
*/
/**
* Enumeration of TruFlow table types. A table type is used to identify a
* resource object.
*
* NOTE: The table type TF_TBL_TYPE_EXT is unique in that it is
* the only table type that is connected with a table scope.
*/
enum tf_tbl_type {
/** Wh+/Brd2 Action Record */
TF_TBL_TYPE_FULL_ACT_RECORD,
/** Multicast Groups */
TF_TBL_TYPE_MCAST_GROUPS,
/** Action Encap 8 Bytes */
TF_TBL_TYPE_ACT_ENCAP_8B,
/** Action Encap 16 Bytes */
TF_TBL_TYPE_ACT_ENCAP_16B,
/** Action Encap 64 Bytes */
TF_TBL_TYPE_ACT_ENCAP_32B,
/** Action Encap 64 Bytes */
TF_TBL_TYPE_ACT_ENCAP_64B,
/** Action Source Properties SMAC */
TF_TBL_TYPE_ACT_SP_SMAC,
/** Action Source Properties SMAC IPv4 */
TF_TBL_TYPE_ACT_SP_SMAC_IPV4,
/** Action Source Properties SMAC IPv6 */
TF_TBL_TYPE_ACT_SP_SMAC_IPV6,
/** Action Statistics 64 Bits */
TF_TBL_TYPE_ACT_STATS_64,
/** Action Modify L4 Src Port */
TF_TBL_TYPE_ACT_MODIFY_SPORT,
/** Action Modify L4 Dest Port */
TF_TBL_TYPE_ACT_MODIFY_DPORT,
/** Action Modify IPv4 Source */
TF_TBL_TYPE_ACT_MODIFY_IPV4_SRC,
/** Action _Modify L4 Dest Port */
TF_TBL_TYPE_ACT_MODIFY_IPV4_DEST,
/** Action Modify IPv6 Source */
TF_TBL_TYPE_ACT_MODIFY_IPV6_SRC,
/** Action Modify IPv6 Destination */
TF_TBL_TYPE_ACT_MODIFY_IPV6_DEST,
/* HW */
/** Meter Profiles */
TF_TBL_TYPE_METER_PROF,
/** Meter Instance */
TF_TBL_TYPE_METER_INST,
/** Mirror Config */
TF_TBL_TYPE_MIRROR_CONFIG,
/** UPAR */
TF_TBL_TYPE_UPAR,
/** Brd4 Epoch 0 table */
TF_TBL_TYPE_EPOCH0,
/** Brd4 Epoch 1 table */
TF_TBL_TYPE_EPOCH1,
/** Brd4 Metadata */
TF_TBL_TYPE_METADATA,
/** Brd4 CT State */
TF_TBL_TYPE_CT_STATE,
/** Brd4 Range Profile */
TF_TBL_TYPE_RANGE_PROF,
/** Brd4 Range Entry */
TF_TBL_TYPE_RANGE_ENTRY,
/** Brd4 LAG Entry */
TF_TBL_TYPE_LAG,
/** Brd4 only VNIC/SVIF Table */
TF_TBL_TYPE_VNIC_SVIF,
/* External */
/** External table type - initially 1 poolsize entries.
* All External table types are associated with a table
* scope. Internal types are not.
*/
TF_TBL_TYPE_EXT,
TF_TBL_TYPE_MAX
};
/** tf_alloc_tbl_entry parameter definition
* tf_alloc_tbl_entry parameter definition
*/
struct tf_alloc_tbl_entry_parms {
/**
@ -993,7 +1011,8 @@ struct tf_alloc_tbl_entry_parms {
uint32_t idx;
};
/** allocate index table entries
/**
* allocate index table entries
*
* Internal types:
*
@ -1023,7 +1042,8 @@ struct tf_alloc_tbl_entry_parms {
int tf_alloc_tbl_entry(struct tf *tfp,
struct tf_alloc_tbl_entry_parms *parms);
/** tf_free_tbl_entry parameter definition
/**
* tf_free_tbl_entry parameter definition
*/
struct tf_free_tbl_entry_parms {
/**
@ -1049,7 +1069,8 @@ struct tf_free_tbl_entry_parms {
uint16_t ref_cnt;
};
/** free index table entry
/**
* free index table entry
*
* Used to free a previously allocated table entry.
*
@ -1075,7 +1096,8 @@ struct tf_free_tbl_entry_parms {
int tf_free_tbl_entry(struct tf *tfp,
struct tf_free_tbl_entry_parms *parms);
/** tf_set_tbl_entry parameter definition
/**
* tf_set_tbl_entry parameter definition
*/
struct tf_set_tbl_entry_parms {
/**
@ -1104,7 +1126,8 @@ struct tf_set_tbl_entry_parms {
uint32_t idx;
};
/** set index table entry
/**
* set index table entry
*
* Used to insert an application programmed index table entry into a
* previous allocated table location. A shadow copy of the table
@ -1115,7 +1138,8 @@ struct tf_set_tbl_entry_parms {
int tf_set_tbl_entry(struct tf *tfp,
struct tf_set_tbl_entry_parms *parms);
/** tf_get_tbl_entry parameter definition
/**
* tf_get_tbl_entry parameter definition
*/
struct tf_get_tbl_entry_parms {
/**
@ -1140,7 +1164,8 @@ struct tf_get_tbl_entry_parms {
uint32_t idx;
};
/** get index table entry
/**
* get index table entry
*
* Used to retrieve a previous set index table entry.
*
@ -1163,7 +1188,8 @@ int tf_get_tbl_entry(struct tf *tfp,
* @ref tf_search_em_entry
*
*/
/** tf_insert_em_entry parameter definition
/**
* tf_insert_em_entry parameter definition
*/
struct tf_insert_em_entry_parms {
/**
@ -1239,6 +1265,10 @@ struct tf_delete_em_entry_parms {
* 2 element array with 2 ids. (Brd4 only)
*/
uint16_t *epochs;
/**
* [out] The index of the entry
*/
uint16_t index;
/**
* [in] structure containing flow delete handle information
*/
@ -1291,7 +1321,8 @@ struct tf_search_em_entry_parms {
uint64_t flow_handle;
};
/** insert em hash entry in internal table memory
/**
* insert em hash entry in internal table memory
*
* Internal:
*
@ -1328,7 +1359,8 @@ struct tf_search_em_entry_parms {
int tf_insert_em_entry(struct tf *tfp,
struct tf_insert_em_entry_parms *parms);
/** delete em hash entry table memory
/**
* delete em hash entry table memory
*
* Internal:
*
@ -1353,7 +1385,8 @@ int tf_insert_em_entry(struct tf *tfp,
int tf_delete_em_entry(struct tf *tfp,
struct tf_delete_em_entry_parms *parms);
/** search em hash entry table memory
/**
* search em hash entry table memory
*
* Internal:

View File

@ -287,7 +287,7 @@ static int tf_em_entry_exists(struct tf_tbl_scope_cb *tbl_scope_cb,
}
static void tf_em_create_key_entry(struct tf_eem_entry_hdr *result,
uint8_t *in_key,
uint8_t *in_key,
struct tf_eem_64b_entry *key_entry)
{
key_entry->hdr.word1 = result->word1;
@ -308,7 +308,7 @@ static void tf_em_create_key_entry(struct tf_eem_entry_hdr *result,
* EEXIST - Key does exist in table at "index" in table "table".
* TF_ERR - Something went horribly wrong.
*/
static int tf_em_select_inject_table(struct tf_tbl_scope_cb *tbl_scope_cb,
static int tf_em_select_inject_table(struct tf_tbl_scope_cb *tbl_scope_cb,
enum tf_dir dir,
struct tf_eem_64b_entry *entry,
uint32_t key0_hash,
@ -368,8 +368,8 @@ static int tf_em_select_inject_table(struct tf_tbl_scope_cb *tbl_scope_cb,
* 0
* TF_ERR_EM_DUP - key is already in table
*/
int tf_insert_eem_entry(struct tf_session *session,
struct tf_tbl_scope_cb *tbl_scope_cb,
int tf_insert_eem_entry(struct tf_session *session,
struct tf_tbl_scope_cb *tbl_scope_cb,
struct tf_insert_em_entry_parms *parms)
{
uint32_t mask;
@ -457,6 +457,96 @@ int tf_insert_eem_entry(struct tf_session *session,
return -EINVAL;
}
/**
* Insert EM internal entry API
*
* returns:
* 0 - Success
*/
int tf_insert_em_internal_entry(struct tf *tfp,
struct tf_insert_em_entry_parms *parms)
{
int rc;
uint32_t gfid;
uint16_t rptr_index = 0;
uint8_t rptr_entry = 0;
uint8_t num_of_entries = 0;
struct tf_session *session =
(struct tf_session *)(tfp->session->core_data);
struct stack *pool = &session->em_pool[parms->dir];
uint32_t index;
rc = stack_pop(pool, &index);
if (rc != 0) {
PMD_DRV_LOG
(ERR,
"dir:%d, EM entry index allocation failed\n",
parms->dir);
return rc;
}
rptr_index = index * TF_SESSION_EM_ENTRY_SIZE;
rc = tf_msg_insert_em_internal_entry(tfp,
parms,
&rptr_index,
&rptr_entry,
&num_of_entries);
if (rc != 0)
return -1;
PMD_DRV_LOG
(ERR,
"Internal entry @ Index:%d rptr_index:0x%x rptr_entry:0x%x num_of_entries:%d\n",
index * TF_SESSION_EM_ENTRY_SIZE,
rptr_index,
rptr_entry,
num_of_entries);
TF_SET_GFID(gfid,
((rptr_index << TF_EM_INTERNAL_INDEX_SHIFT) |
rptr_entry),
0); /* N/A for internal table */
TF_SET_FLOW_ID(parms->flow_id,
gfid,
TF_GFID_TABLE_INTERNAL,
parms->dir);
TF_SET_FIELDS_IN_FLOW_HANDLE(parms->flow_handle,
num_of_entries,
0,
0,
rptr_index,
rptr_entry,
0);
return 0;
}
/** Delete EM internal entry API
*
* returns:
* 0
* -EINVAL
*/
int tf_delete_em_internal_entry(struct tf *tfp,
struct tf_delete_em_entry_parms *parms)
{
int rc;
struct tf_session *session =
(struct tf_session *)(tfp->session->core_data);
struct stack *pool = &session->em_pool[parms->dir];
rc = tf_msg_delete_em_entry(tfp, parms);
/* Return resource to pool */
if (rc == 0)
stack_push(pool, parms->index / TF_SESSION_EM_ENTRY_SIZE);
return rc;
}
/** delete EEM hash entry API
*
* returns:

View File

@ -12,6 +12,20 @@
#define TF_HW_EM_KEY_MAX_SIZE 52
#define TF_EM_KEY_RECORD_SIZE 64
/*
* Used to build GFID:
*
* 15 2 0
* +--------------+--+
* | Index |E |
* +--------------+--+
*
* E = Entry (bucket inndex)
*/
#define TF_EM_INTERNAL_INDEX_SHIFT 2
#define TF_EM_INTERNAL_INDEX_MASK 0xFFFC
#define TF_EM_INTERNAL_ENTRY_MASK 0x3
/** EEM Entry header
*
*/
@ -53,6 +67,17 @@ struct tf_eem_64b_entry {
struct tf_eem_entry_hdr hdr;
};
/** EM Entry
* Each EM entry is 512-bit (64-bytes) but ordered differently to
* EEM.
*/
struct tf_em_64b_entry {
/** Header is 8 bytes long */
struct tf_eem_entry_hdr hdr;
/** Key is 448 bits - 56 bytes */
uint8_t key[TF_EM_KEY_RECORD_SIZE - sizeof(struct tf_eem_entry_hdr)];
};
/**
* Allocates EEM Table scope
*
@ -106,9 +131,15 @@ int tf_insert_eem_entry(struct tf_session *session,
struct tf_tbl_scope_cb *tbl_scope_cb,
struct tf_insert_em_entry_parms *parms);
int tf_insert_em_internal_entry(struct tf *tfp,
struct tf_insert_em_entry_parms *parms);
int tf_delete_eem_entry(struct tf *tfp,
struct tf_delete_em_entry_parms *parms);
int tf_delete_em_internal_entry(struct tf *tfp,
struct tf_delete_em_entry_parms *parms);
void *tf_em_get_table_page(struct tf_tbl_scope_cb *tbl_scope_cb,
enum tf_dir dir,
uint32_t offset,

View File

@ -90,6 +90,18 @@ do { \
TF_HASH_TYPE_FLOW_HANDLE_SFT); \
} while (0)
#define TF_GET_NUM_KEY_ENTRIES_FROM_FLOW_HANDLE(flow_handle, \
num_key_entries) \
(num_key_entries = \
(((flow_handle) & TF_NUM_KEY_ENTRIES_FLOW_HANDLE_MASK) >> \
TF_NUM_KEY_ENTRIES_FLOW_HANDLE_SFT)) \
#define TF_GET_ENTRY_NUM_FROM_FLOW_HANDLE(flow_handle, \
entry_num) \
(entry_num = \
(((flow_handle) & TF_ENTRY_NUM_FLOW_HANDLE_MASK) >> \
TF_ENTRY_NUM_FLOW_HANDLE_SFT)) \
/*
* 32 bit Flow ID handlers
*/

View File

@ -16,6 +16,7 @@
#include "tf_msg.h"
#include "hsi_struct_def_dpdk.h"
#include "hwrm_tf.h"
#include "tf_em.h"
/**
* Endian converts min and max values from the HW response to the query
@ -1013,15 +1014,94 @@ int tf_msg_em_cfg(struct tf *tfp,
return rc;
}
/**
* Sends EM internal insert request to Firmware
*/
int tf_msg_insert_em_internal_entry(struct tf *tfp,
struct tf_insert_em_entry_parms *em_parms,
uint16_t *rptr_index,
uint8_t *rptr_entry,
uint8_t *num_of_entries)
{
int rc;
struct tfp_send_msg_parms parms = { 0 };
struct tf_em_internal_insert_input req = { 0 };
struct tf_em_internal_insert_output resp = { 0 };
struct tf_session *tfs = (struct tf_session *)(tfp->session->core_data);
struct tf_em_64b_entry *em_result =
(struct tf_em_64b_entry *)em_parms->em_record;
req.fw_session_id =
tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
memcpy(req.em_key, em_parms->key, ((em_parms->key_sz_in_bits + 7) / 8));
req.flags = tfp_cpu_to_le_16(em_parms->dir);
req.strength = (em_result->hdr.word1 & TF_LKUP_RECORD_STRENGTH_MASK) >>
TF_LKUP_RECORD_STRENGTH_SHIFT;
req.em_key_bitlen = em_parms->key_sz_in_bits;
req.action_ptr = em_result->hdr.pointer;
req.em_record_idx = *rptr_index;
MSG_PREP(parms,
TF_KONG_MB,
HWRM_TF,
HWRM_TFT_EM_RULE_INSERT,
req,
resp);
rc = tfp_send_msg_tunneled(tfp, &parms);
if (rc)
return rc;
*rptr_entry = resp.rptr_entry;
*rptr_index = resp.rptr_index;
*num_of_entries = resp.num_of_entries;
return tfp_le_to_cpu_32(parms.tf_resp_code);
}
/**
* Sends EM delete insert request to Firmware
*/
int tf_msg_delete_em_entry(struct tf *tfp,
struct tf_delete_em_entry_parms *em_parms)
{
int rc;
struct tfp_send_msg_parms parms = { 0 };
struct tf_em_internal_delete_input req = { 0 };
struct tf_em_internal_delete_output resp = { 0 };
struct tf_session *tfs =
(struct tf_session *)(tfp->session->core_data);
req.tf_session_id =
tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
req.flags = tfp_cpu_to_le_16(em_parms->dir);
req.flow_handle = tfp_cpu_to_le_64(em_parms->flow_handle);
MSG_PREP(parms,
TF_KONG_MB,
HWRM_TF,
HWRM_TFT_EM_RULE_DELETE,
req,
resp);
rc = tfp_send_msg_tunneled(tfp, &parms);
if (rc)
return rc;
em_parms->index = tfp_le_to_cpu_16(resp.em_index);
return tfp_le_to_cpu_32(parms.tf_resp_code);
}
/**
* Sends EM operation request to Firmware
*/
int tf_msg_em_op(struct tf *tfp,
int dir,
uint16_t op)
int dir,
uint16_t op)
{
int rc;
struct hwrm_tf_ext_em_op_input req = {0};
struct hwrm_tf_ext_em_op_input req = {0};
struct hwrm_tf_ext_em_op_output resp = {0};
uint32_t flags;
struct tfp_send_msg_parms parms = { 0 };

View File

@ -121,6 +121,19 @@ int tf_msg_session_sram_resc_flush(struct tf *tfp,
enum tf_dir dir,
struct tf_rm_entry *sram_entry);
/**
* Sends EM internal insert request to Firmware
*/
int tf_msg_insert_em_internal_entry(struct tf *tfp,
struct tf_insert_em_entry_parms *params,
uint16_t *rptr_index,
uint8_t *rptr_entry,
uint8_t *num_of_entries);
/**
* Sends EM internal delete request to Firmware
*/
int tf_msg_delete_em_entry(struct tf *tfp,
struct tf_delete_em_entry_parms *em_parms);
/**
* Sends EM mem register request to Firmware
*/

View File

@ -13,12 +13,25 @@
#include "tf_core.h"
#include "tf_rm.h"
#include "tf_tbl.h"
#include "stack.h"
/** Session defines
*/
#define TF_SESSIONS_MAX 1 /** max # sessions */
#define TF_SESSION_ID_INVALID 0xFFFFFFFF /** Invalid Session ID define */
/**
* Number of EM entries. Static for now will be removed
* when parameter added at a later date. At this stage we
* are using fixed size entries so that each stack entry
* represents 4 RT (f/n)blocks. So we take the total block
* allocation for truflow and divide that by 4.
*/
#define TF_SESSION_TOTAL_FN_BLOCKS (1024 * 8) /* 8K blocks */
#define TF_SESSION_EM_ENTRY_SIZE 4 /* 4 blocks per entry */
#define TF_SESSION_EM_POOL_SIZE \
(TF_SESSION_TOTAL_FN_BLOCKS / TF_SESSION_EM_ENTRY_SIZE)
/** Session
*
* Shared memory containing private TruFlow session information.
@ -289,6 +302,11 @@ struct tf_session {
/** Table scope array */
struct tf_tbl_scope_cb tbl_scopes[TF_NUM_TBL_SCOPE];
/**
* EM Pools
*/
struct stack em_pool[TF_DIR_MAX];
};
#endif /* _TF_SESSION_H_ */

View File

@ -156,7 +156,7 @@ tf_em_alloc_pg_tbl(struct tf_em_page_tbl *tp,
if (tfp_calloc(&parms) != 0)
goto cleanup;
tp->pg_pa_tbl[i] = (uint64_t)(uintptr_t)parms.mem_pa;
tp->pg_pa_tbl[i] = (uintptr_t)parms.mem_pa;
tp->pg_va_tbl[i] = parms.mem_va;
memset(tp->pg_va_tbl[i], 0, pg_size);
@ -792,7 +792,8 @@ tf_set_tbl_entry_internal(struct tf *tfp,
index = parms->idx;
if (parms->type != TF_TBL_TYPE_FULL_ACT_RECORD &&
parms->type != TF_TBL_TYPE_ACT_SP_SMAC_IPV4) {
parms->type != TF_TBL_TYPE_ACT_SP_SMAC_IPV4 &&
parms->type != TF_TBL_TYPE_ACT_STATS_64) {
PMD_DRV_LOG(ERR,
"dir:%d, Type not supported, type:%d\n",
parms->dir,
@ -1179,7 +1180,8 @@ tf_alloc_tbl_entry_pool_internal(struct tf *tfp,
parms->type != TF_TBL_TYPE_ACT_SP_SMAC_IPV4 &&
parms->type != TF_TBL_TYPE_ACT_ENCAP_8B &&
parms->type != TF_TBL_TYPE_ACT_ENCAP_16B &&
parms->type != TF_TBL_TYPE_ACT_ENCAP_64B) {
parms->type != TF_TBL_TYPE_ACT_ENCAP_64B &&
parms->type != TF_TBL_TYPE_ACT_STATS_64) {
PMD_DRV_LOG(ERR,
"dir:%d, Type not supported, type:%d\n",
parms->dir,
@ -1330,7 +1332,8 @@ tf_free_tbl_entry_pool_internal(struct tf *tfp,
parms->type != TF_TBL_TYPE_ACT_SP_SMAC_IPV4 &&
parms->type != TF_TBL_TYPE_ACT_ENCAP_8B &&
parms->type != TF_TBL_TYPE_ACT_ENCAP_16B &&
parms->type != TF_TBL_TYPE_ACT_ENCAP_64B) {
parms->type != TF_TBL_TYPE_ACT_ENCAP_64B &&
parms->type != TF_TBL_TYPE_ACT_STATS_64) {
PMD_DRV_LOG(ERR,
"dir:%d, Type not supported, type:%d\n",
parms->dir,
@ -1801,3 +1804,91 @@ tf_free_tbl_entry(struct tf *tfp,
rc);
return rc;
}
static void
tf_dump_link_page_table(struct tf_em_page_tbl *tp,
struct tf_em_page_tbl *tp_next)
{
uint64_t *pg_va;
uint32_t i;
uint32_t j;
uint32_t k = 0;
printf("pg_count:%d pg_size:0x%x\n",
tp->pg_count,
tp->pg_size);
for (i = 0; i < tp->pg_count; i++) {
pg_va = tp->pg_va_tbl[i];
printf("\t%p\n", (void *)pg_va);
for (j = 0; j < MAX_PAGE_PTRS(tp->pg_size); j++) {
printf("\t\t%p\n", (void *)(uintptr_t)pg_va[j]);
if (((pg_va[j] & 0x7) ==
tfp_cpu_to_le_64(PTU_PTE_LAST |
PTU_PTE_VALID)))
return;
if (!(pg_va[j] & tfp_cpu_to_le_64(PTU_PTE_VALID))) {
printf("** Invalid entry **\n");
return;
}
if (++k >= tp_next->pg_count) {
printf("** Shouldn't get here **\n");
return;
}
}
}
}
void tf_dump_dma(struct tf *tfp, uint32_t tbl_scope_id);
void tf_dump_dma(struct tf *tfp, uint32_t tbl_scope_id)
{
struct tf_session *session;
struct tf_tbl_scope_cb *tbl_scope_cb;
struct tf_em_page_tbl *tp;
struct tf_em_page_tbl *tp_next;
struct tf_em_table *tbl;
int i;
int j;
int dir;
printf("called %s\n", __func__);
/* find session struct */
session = (struct tf_session *)tfp->session->core_data;
/* find control block for table scope */
tbl_scope_cb = tbl_scope_cb_find(session,
tbl_scope_id);
if (tbl_scope_cb == NULL)
PMD_DRV_LOG(ERR, "No table scope\n");
for (dir = 0; dir < TF_DIR_MAX; dir++) {
printf("Direction %s:\n", (dir == TF_DIR_RX ? "Rx" : "Tx"));
for (j = KEY0_TABLE; j < MAX_TABLE; j++) {
tbl = &tbl_scope_cb->em_ctx_info[dir].em_tables[j];
printf
("Table: j:%d type:%d num_entries:%d entry_size:0x%x num_lvl:%d ",
j,
tbl->type,
tbl->num_entries,
tbl->entry_size,
tbl->num_lvl);
if (tbl->pg_tbl[0].pg_va_tbl &&
tbl->pg_tbl[0].pg_pa_tbl)
printf("%p %p\n",
tbl->pg_tbl[0].pg_va_tbl[0],
(void *)(uintptr_t)tbl->pg_tbl[0].pg_pa_tbl[0]);
for (i = 0; i < tbl->num_lvl - 1; i++) {
printf("Level:%d\n", i);
tp = &tbl->pg_tbl[i];
tp_next = &tbl->pg_tbl[i + 1];
tf_dump_link_page_table(tp, tp_next);
}
printf("\n");
}
}
}

View File

@ -76,38 +76,51 @@ struct tf_tbl_scope_cb {
uint32_t *ext_act_pool_mem[TF_DIR_MAX];
};
/** Hardware Page sizes supported for EEM: 4K, 8K, 64K, 256K, 1M, 2M, 4M, 1G.
* Round-down other page sizes to the lower hardware page size supported.
/**
* Hardware Page sizes supported for EEM:
* 4K, 8K, 64K, 256K, 1M, 2M, 4M, 1G.
*
* Round-down other page sizes to the lower hardware page
* size supported.
*/
#define BNXT_PAGE_SHIFT 22 /** 2M */
#define TF_EM_PAGE_SIZE_4K 12
#define TF_EM_PAGE_SIZE_8K 13
#define TF_EM_PAGE_SIZE_64K 16
#define TF_EM_PAGE_SIZE_256K 18
#define TF_EM_PAGE_SIZE_1M 20
#define TF_EM_PAGE_SIZE_2M 21
#define TF_EM_PAGE_SIZE_4M 22
#define TF_EM_PAGE_SIZE_1G 30
#if (BNXT_PAGE_SHIFT < 12) /** < 4K >> 4K */
#define TF_EM_PAGE_SHIFT 12
/* Set page size */
#define BNXT_TF_PAGE_SIZE TF_EM_PAGE_SIZE_2M
#if (BNXT_TF_PAGE_SIZE == TF_EM_PAGE_SIZE_4K) /** 4K */
#define TF_EM_PAGE_SHIFT TF_EM_PAGE_SIZE_4K
#define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_4K
#elif (BNXT_PAGE_SHIFT <= 13) /** 4K, 8K */
#define TF_EM_PAGE_SHIFT 13
#elif (BNXT_TF_PAGE_SIZE == TF_EM_PAGE_SIZE_8K) /** 8K */
#define TF_EM_PAGE_SHIFT TF_EM_PAGE_SIZE_8K
#define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_8K
#elif (BNXT_PAGE_SHIFT < 16) /** 16K, 32K >> 8K */
#define TF_EM_PAGE_SHIFT 15
#define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_32K
#elif (BNXT_PAGE_SHIFT <= 17) /** 64K, 128K >> 64K */
#define TF_EM_PAGE_SHIFT 16
#elif (BNXT_TF_PAGE_SIZE == TF_EM_PAGE_SIZE_64K) /** 64K */
#define TF_EM_PAGE_SHIFT TF_EM_PAGE_SIZE_64K
#define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_64K
#elif (BNXT_PAGE_SHIFT <= 19) /** 256K, 512K >> 256K */
#define TF_EM_PAGE_SHIFT 18
#elif (BNXT_TF_PAGE_SIZE == TF_EM_PAGE_SIZE_256K) /** 256K */
#define TF_EM_PAGE_SHIFT TF_EM_PAGE_SIZE_256K
#define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_256K
#elif (BNXT_PAGE_SHIFT <= 21) /** 1M */
#define TF_EM_PAGE_SHIFT 20
#elif (BNXT_TF_PAGE_SIZE == TF_EM_PAGE_SIZE_1M) /** 1M */
#define TF_EM_PAGE_SHIFT TF_EM_PAGE_SIZE_1M
#define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_1M
#elif (BNXT_PAGE_SHIFT <= 22) /** 2M, 4M */
#define TF_EM_PAGE_SHIFT 21
#elif (BNXT_TF_PAGE_SIZE == TF_EM_PAGE_SIZE_2M) /** 2M */
#define TF_EM_PAGE_SHIFT TF_EM_PAGE_SIZE_2M
#define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_2M
#elif (BNXT_PAGE_SHIFT <= 29) /** 8M ... 512M >> 4M */
#define TF_EM_PAGE_SHIFT 22
#elif (BNXT_TF_PAGE_SIZE == TF_EM_PAGE_SIZE_4M) /** 4M */
#define TF_EM_PAGE_SHIFT TF_EM_PAGE_SIZE_4M
#define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_4M
#else /** >= 1G >> 1G */
#define TF_EM_PAGE_SHIFT 30
#elif (BNXT_TF_PAGE_SIZE == TF_EM_PAGE_SIZE_1G) /** 1G */
#define TF_EM_PAGE_SHIFT TF_EM_PAGE_SIZE_1G
#define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_1G
#else
#error "Invalid Page Size specified. Please use a TF_EM_PAGE_SIZE_n define"
#endif
#define TF_EM_PAGE_SIZE (1 << TF_EM_PAGE_SHIFT)

View File

@ -3,14 +3,23 @@
* All rights reserved.
*/
/* This header file defines the Portability structures and APIs for
/*
* This header file defines the Portability structures and APIs for
* TruFlow.
*/
#ifndef _TFP_H_
#define _TFP_H_
#include <rte_config.h>
#include <rte_spinlock.h>
#include <rte_log.h>
#include <rte_byteorder.h>
/**
* DPDK/Driver specific log level for the BNXT Eth driver.
*/
extern int bnxt_logtype_driver;
/** Spinlock
*/
@ -18,13 +27,21 @@ struct tfp_spinlock_parms {
rte_spinlock_t slock;
};
#define TFP_DRV_LOG_RAW(level, fmt, args...) \
rte_log(RTE_LOG_ ## level, bnxt_logtype_driver, "%s(): " fmt, \
__func__, ## args)
#define TFP_DRV_LOG(level, fmt, args...) \
TFP_DRV_LOG_RAW(level, fmt, ## args)
/**
* @file
*
* TrueFlow Portability API Header File
*/
/** send message parameter definition
/**
* send message parameter definition
*/
struct tfp_send_msg_parms {
/**
@ -62,7 +79,8 @@ struct tfp_send_msg_parms {
uint32_t *resp_data;
};
/** calloc parameter definition
/**
* calloc parameter definition
*/
struct tfp_calloc_parms {
/**
@ -96,43 +114,15 @@ struct tfp_calloc_parms {
* @ref tfp_send_msg_tunneled
*
* @ref tfp_calloc
* @ref tfp_free
* @ref tfp_memcpy
* @ref tfp_free
*
* @ref tfp_spinlock_init
* @ref tfp_spinlock_lock
* @ref tfp_spinlock_unlock
*
* @ref tfp_cpu_to_le_16
* @ref tfp_le_to_cpu_16
* @ref tfp_cpu_to_le_32
* @ref tfp_le_to_cpu_32
* @ref tfp_cpu_to_le_64
* @ref tfp_le_to_cpu_64
* @ref tfp_cpu_to_be_16
* @ref tfp_be_to_cpu_16
* @ref tfp_cpu_to_be_32
* @ref tfp_be_to_cpu_32
* @ref tfp_cpu_to_be_64
* @ref tfp_be_to_cpu_64
*/
#define tfp_cpu_to_le_16(val) rte_cpu_to_le_16(val)
#define tfp_le_to_cpu_16(val) rte_le_to_cpu_16(val)
#define tfp_cpu_to_le_32(val) rte_cpu_to_le_32(val)
#define tfp_le_to_cpu_32(val) rte_le_to_cpu_32(val)
#define tfp_cpu_to_le_64(val) rte_cpu_to_le_64(val)
#define tfp_le_to_cpu_64(val) rte_le_to_cpu_64(val)
#define tfp_cpu_to_be_16(val) rte_cpu_to_be_16(val)
#define tfp_be_to_cpu_16(val) rte_be_to_cpu_16(val)
#define tfp_cpu_to_be_32(val) rte_cpu_to_be_32(val)
#define tfp_be_to_cpu_32(val) rte_be_to_cpu_32(val)
#define tfp_cpu_to_be_64(val) rte_cpu_to_be_64(val)
#define tfp_be_to_cpu_64(val) rte_be_to_cpu_64(val)
#define tfp_bswap_16(val) rte_bswap16(val)
#define tfp_bswap_32(val) rte_bswap32(val)
#define tfp_bswap_64(val) rte_bswap64(val)
/**
* Provides communication capability from the TrueFlow API layer to
* the TrueFlow firmware. The portability layer internally provides
@ -162,9 +152,24 @@ int tfp_send_msg_direct(struct tf *tfp,
* -1 - Global error like not supported
* -EINVAL - Parameter Error
*/
int tfp_send_msg_tunneled(struct tf *tfp,
int tfp_send_msg_tunneled(struct tf *tfp,
struct tfp_send_msg_parms *parms);
/**
* Sends OEM command message to Chimp
*
* [in] session, pointer to session handle
* [in] max_flows, max number of flows requested
*
* Returns:
* 0 - Success
* -1 - Global error like not supported
* -EINVAL - Parameter Error
*/
int
tfp_msg_hwrm_oem_cmd(struct tf *tfp,
uint32_t max_flows);
/**
* Allocates zero'ed memory from the heap.
*
@ -179,10 +184,58 @@ int tfp_send_msg_tunneled(struct tf *tfp,
* -EINVAL - Parameter error
*/
int tfp_calloc(struct tfp_calloc_parms *parms);
void tfp_free(void *addr);
void tfp_memcpy(void *dest, void *src, size_t n);
void tfp_free(void *addr);
void tfp_spinlock_init(struct tfp_spinlock_parms *slock);
void tfp_spinlock_lock(struct tfp_spinlock_parms *slock);
void tfp_spinlock_unlock(struct tfp_spinlock_parms *slock);
/**
* Lookup of the FID in the platform specific structure.
*
* [in] session
* Pointer to session handle
*
* [out] fw_fid
* Pointer to the fw_fid
*
* Returns:
* 0 - Success
* -EINVAL - Parameter error
*/
int tfp_get_fid(struct tf *tfp, uint16_t *fw_fid);
/*
* @ref tfp_cpu_to_le_16
* @ref tfp_le_to_cpu_16
* @ref tfp_cpu_to_le_32
* @ref tfp_le_to_cpu_32
* @ref tfp_cpu_to_le_64
* @ref tfp_le_to_cpu_64
* @ref tfp_cpu_to_be_16
* @ref tfp_be_to_cpu_16
* @ref tfp_cpu_to_be_32
* @ref tfp_be_to_cpu_32
* @ref tfp_cpu_to_be_64
* @ref tfp_be_to_cpu_64
*/
#define tfp_cpu_to_le_16(val) rte_cpu_to_le_16(val)
#define tfp_le_to_cpu_16(val) rte_le_to_cpu_16(val)
#define tfp_cpu_to_le_32(val) rte_cpu_to_le_32(val)
#define tfp_le_to_cpu_32(val) rte_le_to_cpu_32(val)
#define tfp_cpu_to_le_64(val) rte_cpu_to_le_64(val)
#define tfp_le_to_cpu_64(val) rte_le_to_cpu_64(val)
#define tfp_cpu_to_be_16(val) rte_cpu_to_be_16(val)
#define tfp_be_to_cpu_16(val) rte_be_to_cpu_16(val)
#define tfp_cpu_to_be_32(val) rte_cpu_to_be_32(val)
#define tfp_be_to_cpu_32(val) rte_be_to_cpu_32(val)
#define tfp_cpu_to_be_64(val) rte_cpu_to_be_64(val)
#define tfp_be_to_cpu_64(val) rte_be_to_cpu_64(val)
#define tfp_bswap_16(val) rte_bswap16(val)
#define tfp_bswap_32(val) rte_bswap32(val)
#define tfp_bswap_64(val) rte_bswap64(val)
#endif /* _TFP_H_ */