net/bnxt: implement IF tables set and get

- Implement set/get for PROF_SPIF_CTXT, LKUP_PF_DFLT_ARP,
  PROF_PF_ERR_ARP with tunneled HWRM messages
- Add IF table for PROF_PARIF_DFLT_ARP
- Fix page size offset in the HCAPI code
- Fix Entry offset calculation

Signed-off-by: Jay Ding <jay.ding@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:
Jay Ding 2020-07-02 16:28:15 -07:00 committed by Ferruh Yigit
parent d0d22f1f06
commit f3502f5cd2
21 changed files with 1059 additions and 57 deletions

View File

@ -127,6 +127,11 @@ const struct hcapi_cfa_field cfa_p40_prof_profile_tcam_remap_mem_layout[] = {
CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_PROFILE_ID_NUM_BITS},
{CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_KEY_ID_BITPOS,
CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_KEY_ID_NUM_BITS},
/* Fields below not generated through automation */
{CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_BYPASS_OPT_BITPOS,
CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_BYPASS_OPT_NUM_BITS},
{CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_ACT_REC_PTR_BITPOS,
CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_ACT_REC_PTR_NUM_BITS},
};
const struct hcapi_cfa_field cfa_p40_prof_profile_tcam_layout[] = {
@ -247,4 +252,52 @@ const struct hcapi_cfa_field cfa_p40_eem_key_tbl_layout[] = {
CFA_P40_EEM_KEY_TBL_AR_PTR_NUM_BITS},
};
const struct hcapi_cfa_field cfa_p40_mirror_tbl_layout[] = {
{CFA_P40_MIRROR_TBL_SP_PTR_BITPOS,
CFA_P40_MIRROR_TBL_SP_PTR_NUM_BITS},
{CFA_P40_MIRROR_TBL_IGN_DROP_BITPOS,
CFA_P40_MIRROR_TBL_IGN_DROP_NUM_BITS},
{CFA_P40_MIRROR_TBL_COPY_BITPOS,
CFA_P40_MIRROR_TBL_COPY_NUM_BITS},
{CFA_P40_MIRROR_TBL_EN_BITPOS,
CFA_P40_MIRROR_TBL_EN_NUM_BITS},
{CFA_P40_MIRROR_TBL_AR_PTR_BITPOS,
CFA_P40_MIRROR_TBL_AR_PTR_NUM_BITS},
};
/* P45 Defines */
const struct hcapi_cfa_field cfa_p45_prof_l2_ctxt_tcam_layout[] = {
{CFA_P45_PROF_L2_CTXT_TCAM_VALID_BITPOS,
CFA_P45_PROF_L2_CTXT_TCAM_VALID_NUM_BITS},
{CFA_P45_PROF_L2_CTXT_TCAM_SPARIF_BITPOS,
CFA_P45_PROF_L2_CTXT_TCAM_SPARIF_NUM_BITS},
{CFA_P40_PROF_L2_CTXT_TCAM_KEY_TYPE_BITPOS,
CFA_P40_PROF_L2_CTXT_TCAM_KEY_TYPE_NUM_BITS},
{CFA_P40_PROF_L2_CTXT_TCAM_TUN_HDR_TYPE_BITPOS,
CFA_P40_PROF_L2_CTXT_TCAM_TUN_HDR_TYPE_NUM_BITS},
{CFA_P40_PROF_L2_CTXT_TCAM_T_L2_NUMTAGS_BITPOS,
CFA_P40_PROF_L2_CTXT_TCAM_T_L2_NUMTAGS_NUM_BITS},
{CFA_P40_PROF_L2_CTXT_TCAM_L2_NUMTAGS_BITPOS,
CFA_P40_PROF_L2_CTXT_TCAM_L2_NUMTAGS_NUM_BITS},
{CFA_P40_PROF_L2_CTXT_TCAM_MAC1_BITPOS,
CFA_P40_PROF_L2_CTXT_TCAM_MAC1_NUM_BITS},
{CFA_P40_PROF_L2_CTXT_TCAM_T_OVID_BITPOS,
CFA_P40_PROF_L2_CTXT_TCAM_T_OVID_NUM_BITS},
{CFA_P40_PROF_L2_CTXT_TCAM_T_IVID_BITPOS,
CFA_P40_PROF_L2_CTXT_TCAM_T_IVID_NUM_BITS},
{CFA_P45_PROF_L2_CTXT_TCAM_SVIF_BITPOS,
CFA_P45_PROF_L2_CTXT_TCAM_SVIF_NUM_BITS},
{CFA_P40_PROF_L2_CTXT_TCAM_MAC0_BITPOS,
CFA_P40_PROF_L2_CTXT_TCAM_MAC0_NUM_BITS},
{CFA_P40_PROF_L2_CTXT_TCAM_OVID_BITPOS,
CFA_P40_PROF_L2_CTXT_TCAM_OVID_NUM_BITS},
{CFA_P40_PROF_L2_CTXT_TCAM_IVID_BITPOS,
CFA_P40_PROF_L2_CTXT_TCAM_IVID_NUM_BITS},
};
#endif /* _CFA_P40_TBL_H_ */

View File

@ -35,10 +35,6 @@
#define CFA_GLOBAL_CFG_DATA_SZ (100)
#if SUPPORT_CFA_HW_P4 && SUPPORT_CFA_HW_P58 && SUPPORT_CFA_HW_P59
#define SUPPORT_CFA_HW_ALL (1)
#endif
#include "hcapi_cfa_p4.h"
#define CFA_PROF_L2CTXT_TCAM_MAX_FIELD_CNT CFA_P40_PROF_L2_CTXT_TCAM_MAX_FLD
#define CFA_PROF_L2CTXT_REMAP_MAX_FIELD_CNT CFA_P40_PROF_L2_CTXT_RMP_DR_MAX_FLD
@ -121,6 +117,8 @@ struct hcapi_cfa_layout {
const struct hcapi_cfa_field *field_array;
/** [out] number of HW field entries in the HW layout field array */
uint32_t array_sz;
/** [out] layout_id - layout id associated with the layout */
uint16_t layout_id;
};
/**
@ -247,6 +245,8 @@ struct hcapi_cfa_key_tbl {
* applicable for newer chip
*/
uint8_t *base1;
/** [in] Page size for EEM tables */
uint32_t page_size;
};
/**
@ -267,7 +267,7 @@ struct hcapi_cfa_key_obj {
struct hcapi_cfa_key_data {
/** [in] For on-chip key table, it is the offset in unit of smallest
* key. For off-chip key table, it is the byte offset relative
* to the key record memory base.
* to the key record memory base and adjusted for page and entry size.
*/
uint32_t offset;
/** [in] HW key data buffer pointer */
@ -668,5 +668,5 @@ int hcapi_cfa_key_hw_op(struct hcapi_cfa_hwop *op,
struct hcapi_cfa_key_loc *key_loc);
uint64_t hcapi_get_table_page(struct hcapi_cfa_em_table *mem,
uint32_t offset);
uint32_t page);
#endif /* HCAPI_CFA_DEFS_H_ */

View File

@ -13,7 +13,6 @@
#include "hcapi_cfa_defs.h"
#define HCAPI_CFA_LKUP_SEED_MEM_SIZE 512
#define TF_EM_PAGE_SIZE (1 << 21)
uint32_t hcapi_cfa_lkup_lkup3_init_cfg;
uint32_t hcapi_cfa_lkup_em_seed_mem[HCAPI_CFA_LKUP_SEED_MEM_SIZE];
bool hcapi_cfa_lkup_init;
@ -199,10 +198,9 @@ static uint32_t hcapi_cfa_lookup3_hash(uint8_t *in_key)
uint64_t hcapi_get_table_page(struct hcapi_cfa_em_table *mem,
uint32_t offset)
uint32_t page)
{
int level = 0;
int page = offset / TF_EM_PAGE_SIZE;
uint64_t addr;
if (mem == NULL)
@ -362,7 +360,9 @@ int hcapi_cfa_key_hw_op(struct hcapi_cfa_hwop *op,
op->hw.base_addr =
hcapi_get_table_page((struct hcapi_cfa_em_table *)
key_tbl->base0,
key_obj->offset);
key_obj->offset / key_tbl->page_size);
/* Offset is adjusted to be the offset into the page */
key_obj->offset = key_obj->offset % key_tbl->page_size;
if (op->hw.base_addr == 0)
return -1;

View File

@ -21,6 +21,10 @@ enum cfa_p4_tbl_id {
CFA_P4_TBL_WC_TCAM_REMAP,
CFA_P4_TBL_VEB_TCAM,
CFA_P4_TBL_SP_TCAM,
CFA_P4_TBL_PROF_SPIF_DFLT_L2CTXT,
CFA_P4_TBL_PROF_PARIF_DFLT_ACT_REC_PTR,
CFA_P4_TBL_PROF_PARIF_ERR_ACT_REC_PTR,
CFA_P4_TBL_LKUP_PARIF_DFLT_ACT_REC_PTR,
CFA_P4_TBL_MAX
};
@ -333,17 +337,29 @@ enum cfa_p4_action_sram_entry_type {
*/
/** SRAM Action Record */
CFA_P4_ACTION_SRAM_ENTRY_TYPE_ACT,
CFA_P4_ACTION_SRAM_ENTRY_TYPE_FULL_ACTION,
CFA_P4_ACTION_SRAM_ENTRY_TYPE_FORMAT_0_ACTION,
CFA_P4_ACTION_SRAM_ENTRY_TYPE_FORMAT_1_ACTION,
CFA_P4_ACTION_SRAM_ENTRY_TYPE_FORMAT_2_ACTION,
CFA_P4_ACTION_SRAM_ENTRY_TYPE_FORMAT_3_ACTION,
CFA_P4_ACTION_SRAM_ENTRY_TYPE_FORMAT_4_ACTION,
/** SRAM Action Encap 8 Bytes */
CFA_P4_ACTION_SRAM_ENTRY_TYPE_ENCAP_8B,
/** SRAM Action Encap 16 Bytes */
CFA_P4_ACTION_SRAM_ENTRY_TYPE_ENCAP_16B,
/** SRAM Action Encap 64 Bytes */
CFA_P4_ACTION_SRAM_ENTRY_TYPE_ENCAP_64B,
CFA_P4_ACTION_SRAM_ENTRY_TYPE_MODIFY_PORT_SRC,
CFA_P4_ACTION_SRAM_ENTRY_TYPE_MODIFY_PORT_DEST,
/** SRAM Action Modify IPv4 Source */
CFA_P4_ACTION_SRAM_ENTRY_TYPE_MODIFY_IPV4_SRC,
/** SRAM Action Modify IPv4 Destination */
CFA_P4_ACTION_SRAM_ENTRY_TYPE_MODIFY_IPV4_DEST,
/** SRAM Action Source Properties SMAC */
CFA_P4_ACTION_SRAM_ENTRY_TYPE_SP_SMAC,
/** SRAM Action Source Properties SMAC IPv4 */

View File

@ -43,7 +43,7 @@ sources = files('bnxt_cpr.c',
'tf_core/tf_shadow_tcam.c',
'tf_core/tf_tcam.c',
'tf_core/tf_util.c',
'tf_core/tf_rm.c',
'tf_core/tf_if_tbl.c',
'hcapi/hcapi_cfa_p4.c',

View File

@ -25,3 +25,4 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_shadow_tbl.c
SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_shadow_tcam.c
SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_tcam.c
SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_util.c
SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_if_tbl.c

View File

@ -16,7 +16,9 @@ typedef enum tf_subtype {
HWRM_TFT_REG_GET = 821,
HWRM_TFT_REG_SET = 822,
HWRM_TFT_TBL_TYPE_BULK_GET = 825,
TF_SUBTYPE_LAST = HWRM_TFT_TBL_TYPE_BULK_GET,
HWRM_TFT_IF_TBL_SET = 827,
HWRM_TFT_IF_TBL_GET = 828,
TF_SUBTYPE_LAST = HWRM_TFT_IF_TBL_GET,
} tf_subtype_t;
/* Request and Response compile time checking */
@ -46,7 +48,17 @@ typedef enum tf_subtype {
/* WC DMA Address Type */
#define TF_DEV_DATA_TYPE_TF_WC_DMA_ADDR 0x30d0UL
/* WC Entry */
#define TF_DEV_DATA_TYPE_TF_WC_ENTRY 0x30d1UL
#define TF_DEV_DATA_TYPE_TF_WC_ENTRY 0x30d1UL
/* SPIF DFLT L2 CTXT Entry */
#define TF_DEV_DATA_TYPE_SPIF_DFLT_L2_CTXT 0x3131UL
/* PARIF DFLT ACT REC PTR Entry */
#define TF_DEV_DATA_TYPE_PARIF_DFLT_ACT_REC 0x3132UL
/* PARIF ERR DFLT ACT REC PTR Entry */
#define TF_DEV_DATA_TYPE_PARIF_ERR_DFLT_ACT_REC 0x3133UL
/* ILT Entry */
#define TF_DEV_DATA_TYPE_ILT 0x3134UL
/* VNIC SVIF entry */
#define TF_DEV_DATA_TYPE_VNIC_SVIF 0x3135UL
/* Action Data */
#define TF_DEV_DATA_TYPE_TF_ACTION_DATA 0x3170UL
#define TF_DEV_DATA_TYPE_LAST TF_DEV_DATA_TYPE_TF_ACTION_DATA
@ -56,6 +68,9 @@ typedef enum tf_subtype {
struct tf_tbl_type_bulk_get_input;
struct tf_tbl_type_bulk_get_output;
struct tf_if_tbl_set_input;
struct tf_if_tbl_get_input;
struct tf_if_tbl_get_output;
/* Input params for table type get */
typedef struct tf_tbl_type_bulk_get_input {
@ -85,4 +100,48 @@ typedef struct tf_tbl_type_bulk_get_output {
uint16_t size;
} tf_tbl_type_bulk_get_output_t, *ptf_tbl_type_bulk_get_output_t;
/* Input params for if tbl set */
typedef struct tf_if_tbl_set_input {
/* Session Id */
uint32_t fw_session_id;
/* flags */
uint16_t flags;
/* When set to 0, indicates the query apply to RX */
#define TF_IF_TBL_SET_INPUT_FLAGS_DIR_RX (0x0)
/* When set to 1, indicates the query apply to TX */
#define TF_IF_TBL_SET_INPUT_FLAGS_DIR_TX (0x1)
/* if table type */
uint16_t tf_if_tbl_type;
/* index of table entry */
uint16_t idx;
/* size of the data write to table entry */
uint32_t data_sz_in_bytes;
/* data to write into table entry */
uint32_t data[2];
} tf_if_tbl_set_input_t, *ptf_if_tbl_set_input_t;
/* Input params for if tbl get */
typedef struct tf_if_tbl_get_input {
/* Session Id */
uint32_t fw_session_id;
/* flags */
uint16_t flags;
/* When set to 0, indicates the query apply to RX */
#define TF_IF_TBL_GET_INPUT_FLAGS_DIR_RX (0x0)
/* When set to 1, indicates the query apply to TX */
#define TF_IF_TBL_GET_INPUT_FLAGS_DIR_TX (0x1)
/* if table type */
uint16_t tf_if_tbl_type;
/* size of the data get from table entry */
uint32_t data_sz_in_bytes;
/* index of table entry */
uint16_t idx;
} tf_if_tbl_get_input_t, *ptf_if_tbl_get_input_t;
/* output params for if tbl get */
typedef struct tf_if_tbl_get_output {
/* Value read from table entry */
uint32_t data[2];
} tf_if_tbl_get_output_t, *ptf_if_tbl_get_output_t;
#endif /* _HWRM_TF_H_ */

View File

@ -1039,3 +1039,119 @@ tf_free_tbl_scope(struct tf *tfp,
return rc;
}
int
tf_set_if_tbl_entry(struct tf *tfp,
struct tf_set_if_tbl_entry_parms *parms)
{
int rc;
struct tf_session *tfs;
struct tf_dev_info *dev;
struct tf_if_tbl_set_parms sparms = { 0 };
TF_CHECK_PARMS2(tfp, parms);
/* Retrieve the session information */
rc = tf_session_get_session(tfp, &tfs);
if (rc) {
TFP_DRV_LOG(ERR,
"%s: Failed to lookup session, rc:%s\n",
tf_dir_2_str(parms->dir),
strerror(-rc));
return rc;
}
/* Retrieve the device information */
rc = tf_session_get_device(tfs, &dev);
if (rc) {
TFP_DRV_LOG(ERR,
"%s: Failed to lookup device, rc:%s\n",
tf_dir_2_str(parms->dir),
strerror(-rc));
return rc;
}
if (dev->ops->tf_dev_set_if_tbl == NULL) {
rc = -EOPNOTSUPP;
TFP_DRV_LOG(ERR,
"%s: Operation not supported, rc:%s\n",
tf_dir_2_str(parms->dir),
strerror(-rc));
return rc;
}
sparms.dir = parms->dir;
sparms.type = parms->type;
sparms.idx = parms->idx;
sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
sparms.data = parms->data;
rc = dev->ops->tf_dev_set_if_tbl(tfp, &sparms);
if (rc) {
TFP_DRV_LOG(ERR,
"%s: If_tbl set failed, rc:%s\n",
tf_dir_2_str(parms->dir),
strerror(-rc));
return rc;
}
return 0;
}
int
tf_get_if_tbl_entry(struct tf *tfp,
struct tf_get_if_tbl_entry_parms *parms)
{
int rc;
struct tf_session *tfs;
struct tf_dev_info *dev;
struct tf_if_tbl_get_parms gparms = { 0 };
TF_CHECK_PARMS2(tfp, parms);
/* Retrieve the session information */
rc = tf_session_get_session(tfp, &tfs);
if (rc) {
TFP_DRV_LOG(ERR,
"%s: Failed to lookup session, rc:%s\n",
tf_dir_2_str(parms->dir),
strerror(-rc));
return rc;
}
/* Retrieve the device information */
rc = tf_session_get_device(tfs, &dev);
if (rc) {
TFP_DRV_LOG(ERR,
"%s: Failed to lookup device, rc:%s\n",
tf_dir_2_str(parms->dir),
strerror(-rc));
return rc;
}
if (dev->ops->tf_dev_get_if_tbl == NULL) {
rc = -EOPNOTSUPP;
TFP_DRV_LOG(ERR,
"%s: Operation not supported, rc:%s\n",
tf_dir_2_str(parms->dir),
strerror(-rc));
return rc;
}
gparms.dir = parms->dir;
gparms.type = parms->type;
gparms.idx = parms->idx;
gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
gparms.data = parms->data;
rc = dev->ops->tf_dev_get_if_tbl(tfp, &gparms);
if (rc) {
TFP_DRV_LOG(ERR,
"%s: If_tbl get failed, rc:%s\n",
tf_dir_2_str(parms->dir),
strerror(-rc));
return rc;
}
return 0;
}

View File

@ -1556,4 +1556,108 @@ int tf_delete_em_entry(struct tf *tfp,
int tf_search_em_entry(struct tf *tfp,
struct tf_search_em_entry_parms *parms);
/**
* @page if_tbl Interface Table Access
*
* @ref tf_set_if_tbl_entry
*
* @ref tf_get_if_tbl_entry
*
* @ref tf_restore_if_tbl_entry
*/
/**
* Enumeration of TruFlow interface table types.
*/
enum tf_if_tbl_type {
/** Default Profile L2 Context Entry */
TF_IF_TBL_TYPE_PROF_SPIF_DFLT_L2_CTXT,
/** Default Profile TCAM/Lookup Action Record Pointer Table */
TF_IF_TBL_TYPE_PROF_PARIF_DFLT_ACT_REC_PTR,
/** Error Profile TCAM Miss Action Record Pointer Table */
TF_IF_TBL_TYPE_PROF_PARIF_ERR_ACT_REC_PTR,
/** Default Error Profile TCAM Miss Action Record Pointer Table */
TF_IF_TBL_TYPE_LKUP_PARIF_DFLT_ACT_REC_PTR,
/** SR2 Ingress lookup table */
TF_IF_TBL_TYPE_ILT,
/** SR2 VNIC/SVIF Table */
TF_IF_TBL_TYPE_VNIC_SVIF,
TF_IF_TBL_TYPE_MAX
};
/**
* tf_set_if_tbl_entry parameter definition
*/
struct tf_set_if_tbl_entry_parms {
/**
* [in] Receive or transmit direction
*/
enum tf_dir dir;
/**
* [in] Type of object to set
*/
enum tf_if_tbl_type type;
/**
* [in] Entry data
*/
uint32_t *data;
/**
* [in] Entry size
*/
uint16_t data_sz_in_bytes;
/**
* [in] Interface to write
*/
uint32_t idx;
};
/**
* set interface table entry
*
* Used to set an interface table. This API is used for managing tables indexed
* by SVIF/SPIF/PARIF interfaces. In current implementation only the value is
* set.
* Returns success or failure code.
*/
int tf_set_if_tbl_entry(struct tf *tfp,
struct tf_set_if_tbl_entry_parms *parms);
/**
* tf_get_if_tbl_entry parameter definition
*/
struct tf_get_if_tbl_entry_parms {
/**
* [in] Receive or transmit direction
*/
enum tf_dir dir;
/**
* [in] Type of table to get
*/
enum tf_if_tbl_type type;
/**
* [out] Entry data
*/
uint32_t *data;
/**
* [in] Entry size
*/
uint16_t data_sz_in_bytes;
/**
* [in] Entry index to read
*/
uint32_t idx;
};
/**
* get interface table entry
*
* Used to retrieve an interface table entry.
*
* Reads the interface table entry value
*
* Returns success or failure code. Failure will be returned if the
* provided data buffer is too small for the data type requested.
*/
int tf_get_if_tbl_entry(struct tf *tfp,
struct tf_get_if_tbl_entry_parms *parms);
#endif /* _TF_CORE_H_ */

View File

@ -44,6 +44,7 @@ tf_dev_bind_p4(struct tf *tfp,
struct tf_tbl_cfg_parms tbl_cfg;
struct tf_tcam_cfg_parms tcam_cfg;
struct tf_em_cfg_parms em_cfg;
struct tf_if_tbl_cfg_parms if_tbl_cfg;
dev_handle->type = TF_DEVICE_TYPE_WH;
/* Initial function initialization */
@ -114,6 +115,19 @@ tf_dev_bind_p4(struct tf *tfp,
goto fail;
}
/*
* IF_TBL
*/
if_tbl_cfg.num_elements = TF_IF_TBL_TYPE_MAX;
if_tbl_cfg.cfg = tf_if_tbl_p4;
if_tbl_cfg.shadow_copy = shadow_copy;
rc = tf_if_tbl_bind(tfp, &if_tbl_cfg);
if (rc) {
TFP_DRV_LOG(ERR,
"IF Table initialization failure\n");
goto fail;
}
/* Final function initialization */
dev_handle->ops = &tf_dev_ops_p4;
@ -186,6 +200,13 @@ tf_dev_unbind_p4(struct tf *tfp)
fail = true;
}
rc = tf_if_tbl_unbind(tfp);
if (rc) {
TFP_DRV_LOG(ERR,
"Device unbind failed, IF Table Type\n");
fail = true;
}
if (fail)
return -1;

View File

@ -10,6 +10,7 @@
#include "tf_identifier.h"
#include "tf_tbl.h"
#include "tf_tcam.h"
#include "tf_if_tbl.h"
struct tf;
struct tf_session;
@ -567,6 +568,44 @@ struct tf_dev_ops {
*/
int (*tf_dev_free_tbl_scope)(struct tf *tfp,
struct tf_free_tbl_scope_parms *parms);
/**
* Sets the specified interface table type element.
*
* This API sets the specified element data by invoking the
* firmware.
*
* [in] tfp
* Pointer to TF handle
*
* [in] parms
* Pointer to interface table set parameters
*
* Returns
* - (0) if successful.
* - (-EINVAL) on failure.
*/
int (*tf_dev_set_if_tbl)(struct tf *tfp,
struct tf_if_tbl_set_parms *parms);
/**
* Retrieves the specified interface table type element.
*
* This API retrieves the specified element data by invoking the
* firmware.
*
* [in] tfp
* Pointer to TF handle
*
* [in] parms
* Pointer to table get parameters
*
* Returns
* - (0) if successful.
* - (-EINVAL) on failure.
*/
int (*tf_dev_get_if_tbl)(struct tf *tfp,
struct tf_if_tbl_get_parms *parms);
};
/**

View File

@ -11,6 +11,7 @@
#include "tf_tbl.h"
#include "tf_tcam.h"
#include "tf_em.h"
#include "tf_if_tbl.h"
/**
* Device specific function that retrieves the MAX number of HCAPI
@ -105,6 +106,8 @@ const struct tf_dev_ops tf_dev_ops_p4_init = {
.tf_dev_delete_ext_em_entry = NULL,
.tf_dev_alloc_tbl_scope = NULL,
.tf_dev_free_tbl_scope = NULL,
.tf_dev_set_if_tbl = NULL,
.tf_dev_get_if_tbl = NULL,
};
/**
@ -135,4 +138,6 @@ const struct tf_dev_ops tf_dev_ops_p4 = {
.tf_dev_delete_ext_em_entry = tf_em_delete_ext_entry,
.tf_dev_alloc_tbl_scope = tf_em_ext_common_alloc,
.tf_dev_free_tbl_scope = tf_em_ext_common_free,
.tf_dev_set_if_tbl = tf_if_tbl_set,
.tf_dev_get_if_tbl = tf_if_tbl_get,
};

View File

@ -10,6 +10,7 @@
#include "tf_core.h"
#include "tf_rm.h"
#include "tf_if_tbl.h"
struct tf_rm_element_cfg tf_ident_p4[TF_IDENT_TYPE_MAX] = {
{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP },
@ -86,4 +87,13 @@ struct tf_rm_element_cfg tf_em_int_p4[TF_EM_TBL_TYPE_MAX] = {
{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
};
struct tf_if_tbl_cfg tf_if_tbl_p4[TF_IF_TBL_TYPE_MAX] = {
{ TF_IF_TBL_CFG, CFA_P4_TBL_PROF_SPIF_DFLT_L2CTXT },
{ TF_IF_TBL_CFG, CFA_P4_TBL_PROF_PARIF_DFLT_ACT_REC_PTR },
{ TF_IF_TBL_CFG, CFA_P4_TBL_PROF_PARIF_ERR_ACT_REC_PTR },
{ TF_IF_TBL_CFG, CFA_P4_TBL_LKUP_PARIF_DFLT_ACT_REC_PTR },
{ TF_IF_TBL_CFG_NULL, CFA_IF_TBL_TYPE_INVALID },
{ TF_IF_TBL_CFG_NULL, CFA_IF_TBL_TYPE_INVALID }
};
#endif /* _TF_DEVICE_P4_H_ */

View File

@ -337,11 +337,10 @@ tf_em_ext_common_bind(struct tf *tfp,
db_exists = 1;
}
if (db_exists) {
mem_type = parms->mem_type;
if (db_exists)
init = 1;
}
mem_type = parms->mem_type;
return 0;
}

View File

@ -831,7 +831,8 @@ tf_insert_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb,
op.opcode = HCAPI_CFA_HWOPS_ADD;
key_tbl.base0 = (uint8_t *)
&tbl_scope_cb->em_ctx_info[parms->dir].em_tables[TF_KEY0_TABLE];
key_obj.offset = (index * TF_EM_KEY_RECORD_SIZE) % TF_EM_PAGE_SIZE;
key_tbl.page_size = TF_EM_PAGE_SIZE;
key_obj.offset = index * TF_EM_KEY_RECORD_SIZE;
key_obj.data = (uint8_t *)&key_entry;
key_obj.size = TF_EM_KEY_RECORD_SIZE;
@ -847,8 +848,7 @@ tf_insert_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb,
key_tbl.base0 = (uint8_t *)
&tbl_scope_cb->em_ctx_info[parms->dir].em_tables[TF_KEY1_TABLE];
key_obj.offset =
(index * TF_EM_KEY_RECORD_SIZE) % TF_EM_PAGE_SIZE;
key_obj.offset = index * TF_EM_KEY_RECORD_SIZE;
rc = hcapi_cfa_key_hw_op(&op,
&key_tbl,
@ -914,7 +914,8 @@ tf_delete_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb,
&tbl_scope_cb->em_ctx_info[parms->dir].em_tables[(hash_type == 0 ?
TF_KEY0_TABLE :
TF_KEY1_TABLE)];
key_obj.offset = (index * TF_EM_KEY_RECORD_SIZE) % TF_EM_PAGE_SIZE;
key_tbl.page_size = TF_EM_PAGE_SIZE;
key_obj.offset = index * TF_EM_KEY_RECORD_SIZE;
key_obj.data = NULL;
key_obj.size = TF_EM_KEY_RECORD_SIZE;
@ -1195,7 +1196,8 @@ int tf_tbl_ext_host_set(struct tf *tfp,
op.opcode = HCAPI_CFA_HWOPS_PUT;
key_tbl.base0 =
(uint8_t *)&tbl_scope_cb->em_ctx_info[parms->dir].em_tables[TF_RECORD_TABLE];
key_obj.offset = parms->idx % TF_EM_PAGE_SIZE;
key_tbl.page_size = TF_EM_PAGE_SIZE;
key_obj.offset = parms->idx;
key_obj.data = parms->data;
key_obj.size = parms->data_sz_in_bytes;

View File

@ -68,7 +68,7 @@ tf_ident_bind(struct tf *tfp,
int
tf_ident_unbind(struct tf *tfp)
{
int rc;
int rc = 0;
int i;
struct tf_rm_free_db_parms fparms = { 0 };
@ -89,7 +89,6 @@ tf_ident_unbind(struct tf *tfp)
TFP_DRV_LOG(ERR,
"rm free failed on unbind\n");
}
ident_db[i] = NULL;
}

View File

@ -0,0 +1,178 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2019-2020 Broadcom
* All rights reserved.
*/
#include <rte_common.h>
#include "tf_if_tbl.h"
#include "tf_common.h"
#include "tf_rm.h"
#include "tf_util.h"
#include "tf_msg.h"
#include "tfp.h"
struct tf;
/**
* IF Table DBs.
*/
static void *if_tbl_db[TF_DIR_MAX];
/**
* IF Table Shadow DBs
*/
/* static void *shadow_if_tbl_db[TF_DIR_MAX]; */
/**
* Init flag, set on bind and cleared on unbind
*/
static uint8_t init;
/**
* Shadow init flag, set on bind and cleared on unbind
*/
/* static uint8_t shadow_init; */
/**
* Convert if_tbl_type to hwrm type.
*
* [in] if_tbl_type
* Interface table type
*
* [out] hwrm_type
* HWRM device data type
*
* Returns:
* 0 - Success
* -EOPNOTSUPP - Type not supported
*/
static int
tf_if_tbl_get_hcapi_type(struct tf_if_tbl_get_hcapi_parms *parms)
{
struct tf_if_tbl_cfg *tbl_cfg;
enum tf_if_tbl_cfg_type cfg_type;
tbl_cfg = (struct tf_if_tbl_cfg *)parms->tbl_db;
cfg_type = tbl_cfg[parms->db_index].cfg_type;
if (cfg_type != TF_IF_TBL_CFG)
return -ENOTSUP;
*parms->hcapi_type = tbl_cfg[parms->db_index].hcapi_type;
return 0;
}
int
tf_if_tbl_bind(struct tf *tfp __rte_unused,
struct tf_if_tbl_cfg_parms *parms)
{
TF_CHECK_PARMS2(tfp, parms);
if (init) {
TFP_DRV_LOG(ERR,
"IF TBL DB already initialized\n");
return -EINVAL;
}
if_tbl_db[TF_DIR_RX] = parms->cfg;
if_tbl_db[TF_DIR_TX] = parms->cfg;
init = 1;
TFP_DRV_LOG(INFO,
"Table Type - initialized\n");
return 0;
}
int
tf_if_tbl_unbind(struct tf *tfp __rte_unused)
{
/* Bail if nothing has been initialized */
if (!init) {
TFP_DRV_LOG(INFO,
"No Table DBs created\n");
return 0;
}
if_tbl_db[TF_DIR_RX] = NULL;
if_tbl_db[TF_DIR_TX] = NULL;
init = 0;
return 0;
}
int
tf_if_tbl_set(struct tf *tfp,
struct tf_if_tbl_set_parms *parms)
{
int rc;
struct tf_if_tbl_get_hcapi_parms hparms;
TF_CHECK_PARMS3(tfp, parms, parms->data);
if (!init) {
TFP_DRV_LOG(ERR,
"%s: No Table DBs created\n",
tf_dir_2_str(parms->dir));
return -EINVAL;
}
/* Convert TF type to HCAPI type */
hparms.tbl_db = if_tbl_db[parms->dir];
hparms.db_index = parms->type;
hparms.hcapi_type = &parms->hcapi_type;
rc = tf_if_tbl_get_hcapi_type(&hparms);
if (rc)
return rc;
rc = tf_msg_set_if_tbl_entry(tfp, parms);
if (rc) {
TFP_DRV_LOG(ERR,
"%s, If Tbl set failed, type:%d, rc:%s\n",
tf_dir_2_str(parms->dir),
parms->type,
strerror(-rc));
}
return 0;
}
int
tf_if_tbl_get(struct tf *tfp,
struct tf_if_tbl_get_parms *parms)
{
int rc;
struct tf_if_tbl_get_hcapi_parms hparms;
TF_CHECK_PARMS3(tfp, parms, parms->data);
if (!init) {
TFP_DRV_LOG(ERR,
"%s: No Table DBs created\n",
tf_dir_2_str(parms->dir));
return -EINVAL;
}
/* Convert TF type to HCAPI type */
hparms.tbl_db = if_tbl_db[parms->dir];
hparms.db_index = parms->type;
hparms.hcapi_type = &parms->hcapi_type;
rc = tf_if_tbl_get_hcapi_type(&hparms);
if (rc)
return rc;
/* Get the entry */
rc = tf_msg_get_if_tbl_entry(tfp, parms);
if (rc) {
TFP_DRV_LOG(ERR,
"%s, If Tbl get failed, type:%d, rc:%s\n",
tf_dir_2_str(parms->dir),
parms->type,
strerror(-rc));
}
return 0;
}

View File

@ -0,0 +1,236 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2019-2020 Broadcom
* All rights reserved.
*/
#ifndef TF_IF_TBL_TYPE_H_
#define TF_IF_TBL_TYPE_H_
#include "tf_core.h"
#include "stack.h"
/*
* This is the constant used to define invalid CFA
* types across all devices.
*/
#define CFA_IF_TBL_TYPE_INVALID 65535
struct tf;
/**
* The IF Table module provides processing of Internal TF interface table types.
*/
/**
* IF table configuration enumeration.
*/
enum tf_if_tbl_cfg_type {
/**
* No configuration
*/
TF_IF_TBL_CFG_NULL,
/**
* HCAPI 'controlled'
*/
TF_IF_TBL_CFG,
};
/**
* IF table configuration structure, used by the Device to configure
* how an individual TF type is configured in regard to the HCAPI type.
*/
struct tf_if_tbl_cfg {
/**
* IF table config controls how the DB for that element is
* processed.
*/
enum tf_if_tbl_cfg_type cfg_type;
/**
* HCAPI Type for the element. Used for TF to HCAPI type
* conversion.
*/
uint16_t hcapi_type;
};
/**
* Get HCAPI type parameters for a single element
*/
struct tf_if_tbl_get_hcapi_parms {
/**
* [in] IF Tbl DB Handle
*/
void *tbl_db;
/**
* [in] DB Index, indicates which DB entry to perform the
* action on.
*/
uint16_t db_index;
/**
* [out] Pointer to the hcapi type for the specified db_index
*/
uint16_t *hcapi_type;
};
/**
* Table configuration parameters
*/
struct tf_if_tbl_cfg_parms {
/**
* Number of table types in each of the configuration arrays
*/
uint16_t num_elements;
/**
* Table Type element configuration array
*/
struct tf_if_tbl_cfg *cfg;
/**
* Shadow table type configuration array
*/
struct tf_shadow_if_tbl_cfg *shadow_cfg;
/**
* Boolean controlling the request shadow copy.
*/
bool shadow_copy;
};
/**
* IF Table set parameters
*/
struct tf_if_tbl_set_parms {
/**
* [in] Receive or transmit direction
*/
enum tf_dir dir;
/**
* [in] Type of object to set
*/
enum tf_if_tbl_type type;
/**
* [in] Type of HCAPI
*/
uint16_t hcapi_type;
/**
* [in] Entry data
*/
uint32_t *data;
/**
* [in] Entry size
*/
uint16_t data_sz_in_bytes;
/**
* [in] Entry index to write to
*/
uint32_t idx;
};
/**
* IF Table get parameters
*/
struct tf_if_tbl_get_parms {
/**
* [in] Receive or transmit direction
*/
enum tf_dir dir;
/**
* [in] Type of object to get
*/
enum tf_if_tbl_type type;
/**
* [in] Type of HCAPI
*/
uint16_t hcapi_type;
/**
* [out] Entry data
*/
uint32_t *data;
/**
* [out] Entry size
*/
uint16_t data_sz_in_bytes;
/**
* [in] Entry index to read
*/
uint32_t idx;
};
/**
* @page if tbl Table
*
* @ref tf_if_tbl_bind
*
* @ref tf_if_tbl_unbind
*
* @ref tf_tbl_set
*
* @ref tf_tbl_get
*
* @ref tf_tbl_restore
*/
/**
* Initializes the Table module with the requested DBs. Must be
* invoked as the first thing before any of the access functions.
*
* [in] tfp
* Pointer to TF handle, used for HCAPI communication
*
* [in] parms
* Pointer to Table configuration parameters
*
* Returns
* - (0) if successful.
* - (-EINVAL) on failure.
*/
int tf_if_tbl_bind(struct tf *tfp,
struct tf_if_tbl_cfg_parms *parms);
/**
* Cleans up the private DBs and releases all the data.
*
* [in] tfp
* Pointer to TF handle, used for HCAPI communication
*
* [in] parms
* Pointer to parameters
*
* Returns
* - (0) if successful.
* - (-EINVAL) on failure.
*/
int tf_if_tbl_unbind(struct tf *tfp);
/**
* Configures the requested element by sending a firmware request which
* then installs it into the device internal structures.
*
* [in] tfp
* Pointer to TF handle, used for HCAPI communication
*
* [in] parms
* Pointer to Interface Table set parameters
*
* Returns
* - (0) if successful.
* - (-EINVAL) on failure.
*/
int tf_if_tbl_set(struct tf *tfp,
struct tf_if_tbl_set_parms *parms);
/**
* Retrieves the requested element by sending a firmware request to get
* the element.
*
* [in] tfp
* Pointer to TF handle, used for HCAPI communication
*
* [in] parms
* Pointer to Table get parameters
*
* Returns
* - (0) if successful.
* - (-EINVAL) on failure.
*/
int tf_if_tbl_get(struct tf *tfp,
struct tf_if_tbl_get_parms *parms);
#endif /* TF_IF_TBL_TYPE_H */

View File

@ -125,12 +125,19 @@ tf_msg_session_close(struct tf *tfp)
int rc;
struct hwrm_tf_session_close_input req = { 0 };
struct hwrm_tf_session_close_output resp = { 0 };
struct tf_session *tfs = (struct tf_session *)(tfp->session->core_data);
struct tfp_send_msg_parms parms = { 0 };
uint8_t fw_session_id;
rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
if (rc) {
TFP_DRV_LOG(ERR,
"Unable to lookup FW id, rc:%s\n",
strerror(-rc));
return rc;
}
/* Populate the request */
req.fw_session_id =
tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
parms.tf_type = HWRM_TF_SESSION_CLOSE;
parms.req_data = (uint32_t *)&req;
@ -150,12 +157,19 @@ tf_msg_session_qcfg(struct tf *tfp)
int rc;
struct hwrm_tf_session_qcfg_input req = { 0 };
struct hwrm_tf_session_qcfg_output resp = { 0 };
struct tf_session *tfs = (struct tf_session *)(tfp->session->core_data);
struct tfp_send_msg_parms parms = { 0 };
uint8_t fw_session_id;
rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
if (rc) {
TFP_DRV_LOG(ERR,
"Unable to lookup FW id, rc:%s\n",
strerror(-rc));
return rc;
}
/* Populate the request */
req.fw_session_id =
tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
parms.tf_type = HWRM_TF_SESSION_QCFG,
parms.req_data = (uint32_t *)&req;
@ -448,13 +462,22 @@ tf_msg_insert_em_internal_entry(struct tf *tfp,
struct tfp_send_msg_parms parms = { 0 };
struct hwrm_tf_em_insert_input req = { 0 };
struct hwrm_tf_em_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;
uint16_t flags;
uint8_t fw_session_id;
req.fw_session_id =
tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
if (rc) {
TFP_DRV_LOG(ERR,
"%s: Unable to lookup FW id, rc:%s\n",
tf_dir_2_str(em_parms->dir),
strerror(-rc));
return rc;
}
/* Populate the request */
req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
tfp_memcpy(req.em_key,
em_parms->key,
((em_parms->key_sz_in_bits + 7) / 8));
@ -498,11 +521,19 @@ tf_msg_delete_em_entry(struct tf *tfp,
struct hwrm_tf_em_delete_input req = { 0 };
struct hwrm_tf_em_delete_output resp = { 0 };
uint16_t flags;
struct tf_session *tfs =
(struct tf_session *)(tfp->session->core_data);
uint8_t fw_session_id;
req.fw_session_id =
tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
if (rc) {
TFP_DRV_LOG(ERR,
"%s: Unable to lookup FW id, rc:%s\n",
tf_dir_2_str(em_parms->dir),
strerror(-rc));
return rc;
}
/* Populate the request */
req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
flags = (em_parms->dir == TF_DIR_TX ?
HWRM_TF_EM_DELETE_INPUT_FLAGS_DIR_TX :
@ -789,21 +820,19 @@ tf_msg_set_tbl_entry(struct tf *tfp,
struct hwrm_tf_tbl_type_set_input req = { 0 };
struct hwrm_tf_tbl_type_set_output resp = { 0 };
struct tfp_send_msg_parms parms = { 0 };
struct tf_session *tfs;
uint8_t fw_session_id;
/* Retrieve the session information */
rc = tf_session_get_session(tfp, &tfs);
rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
if (rc) {
TFP_DRV_LOG(ERR,
"%s: Failed to lookup session, rc:%s\n",
"%s: Unable to lookup FW id, rc:%s\n",
tf_dir_2_str(dir),
strerror(-rc));
return rc;
}
/* Populate the request */
req.fw_session_id =
tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
req.flags = tfp_cpu_to_le_16(dir);
req.type = tfp_cpu_to_le_32(hcapi_type);
req.size = tfp_cpu_to_le_16(size);
@ -840,21 +869,19 @@ tf_msg_get_tbl_entry(struct tf *tfp,
struct hwrm_tf_tbl_type_get_input req = { 0 };
struct hwrm_tf_tbl_type_get_output resp = { 0 };
struct tfp_send_msg_parms parms = { 0 };
struct tf_session *tfs;
uint8_t fw_session_id;
/* Retrieve the session information */
rc = tf_session_get_session(tfp, &tfs);
rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
if (rc) {
TFP_DRV_LOG(ERR,
"%s: Failed to lookup session, rc:%s\n",
"%s: Unable to lookup FW id, rc:%s\n",
tf_dir_2_str(dir),
strerror(-rc));
return rc;
}
/* Populate the request */
req.fw_session_id =
tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
req.flags = tfp_cpu_to_le_16(dir);
req.type = tfp_cpu_to_le_32(hcapi_type);
req.index = tfp_cpu_to_le_32(index);
@ -897,22 +924,20 @@ tf_msg_bulk_get_tbl_entry(struct tf *tfp,
struct tfp_send_msg_parms parms = { 0 };
struct tf_tbl_type_bulk_get_input req = { 0 };
struct tf_tbl_type_bulk_get_output resp = { 0 };
struct tf_session *tfs;
int data_size = 0;
uint8_t fw_session_id;
/* Retrieve the session information */
rc = tf_session_get_session(tfp, &tfs);
rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
if (rc) {
TFP_DRV_LOG(ERR,
"%s: Failed to lookup session, rc:%s\n",
"%s: Unable to lookup FW id, rc:%s\n",
tf_dir_2_str(dir),
strerror(-rc));
return rc;
}
/* Populate the request */
req.fw_session_id =
tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
req.flags = tfp_cpu_to_le_16(dir);
req.type = tfp_cpu_to_le_32(hcapi_type);
req.start_index = tfp_cpu_to_le_32(starting_idx);
@ -939,3 +964,102 @@ tf_msg_bulk_get_tbl_entry(struct tf *tfp,
return tfp_le_to_cpu_32(parms.tf_resp_code);
}
int
tf_msg_get_if_tbl_entry(struct tf *tfp,
struct tf_if_tbl_get_parms *params)
{
int rc = 0;
struct tfp_send_msg_parms parms = { 0 };
tf_if_tbl_get_input_t req = { 0 };
tf_if_tbl_get_output_t resp;
uint32_t flags = 0;
struct tf_session *tfs;
/* Retrieve the session information */
rc = tf_session_get_session(tfp, &tfs);
if (rc) {
TFP_DRV_LOG(ERR,
"%s: Failed to lookup session, rc:%s\n",
tf_dir_2_str(params->dir),
strerror(-rc));
return rc;
}
flags = (params->dir == TF_DIR_TX ? TF_IF_TBL_SET_INPUT_FLAGS_DIR_TX :
TF_IF_TBL_SET_INPUT_FLAGS_DIR_RX);
/* Populate the request */
req.fw_session_id =
tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
req.flags = flags;
req.tf_if_tbl_type = params->hcapi_type;
req.idx = tfp_cpu_to_le_16(params->idx);
req.data_sz_in_bytes = tfp_cpu_to_le_16(params->data_sz_in_bytes);
MSG_PREP(parms,
TF_KONG_MB,
HWRM_TF,
HWRM_TFT_IF_TBL_GET,
req,
resp);
rc = tfp_send_msg_tunneled(tfp, &parms);
if (rc != 0)
return rc;
if (parms.tf_resp_code != 0)
return tfp_le_to_cpu_32(parms.tf_resp_code);
tfp_memcpy(&params->data[0], resp.data, req.data_sz_in_bytes);
return tfp_le_to_cpu_32(parms.tf_resp_code);
}
int
tf_msg_set_if_tbl_entry(struct tf *tfp,
struct tf_if_tbl_set_parms *params)
{
int rc = 0;
struct tfp_send_msg_parms parms = { 0 };
tf_if_tbl_set_input_t req = { 0 };
uint32_t flags = 0;
struct tf_session *tfs;
/* Retrieve the session information */
rc = tf_session_get_session(tfp, &tfs);
if (rc) {
TFP_DRV_LOG(ERR,
"%s: Failed to lookup session, rc:%s\n",
tf_dir_2_str(params->dir),
strerror(-rc));
return rc;
}
flags = (params->dir == TF_DIR_TX ? TF_IF_TBL_SET_INPUT_FLAGS_DIR_TX :
TF_IF_TBL_SET_INPUT_FLAGS_DIR_RX);
/* Populate the request */
req.fw_session_id =
tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
req.flags = flags;
req.tf_if_tbl_type = params->hcapi_type;
req.idx = tfp_cpu_to_le_32(params->idx);
req.data_sz_in_bytes = tfp_cpu_to_le_32(params->data_sz_in_bytes);
tfp_memcpy(&req.data[0], params->data, params->data_sz_in_bytes);
MSG_PREP_NO_RESP(parms,
TF_KONG_MB,
HWRM_TF,
HWRM_TFT_IF_TBL_SET,
req);
rc = tfp_send_msg_tunneled(tfp, &parms);
if (rc != 0)
return rc;
return tfp_le_to_cpu_32(parms.tf_resp_code);
}

View File

@ -428,4 +428,34 @@ int tf_msg_bulk_get_tbl_entry(struct tf *tfp,
uint16_t entry_sz_in_bytes,
uint64_t physical_mem_addr);
/**
* Sends Set message of a IF Table Type element to the firmware.
*
* [in] tfp
* Pointer to session handle
*
* [in] parms
* Pointer to IF table set parameters
*
* Returns:
* 0 on Success else internal Truflow error
*/
int tf_msg_set_if_tbl_entry(struct tf *tfp,
struct tf_if_tbl_set_parms *params);
/**
* Sends get message of a IF Table Type element to the firmware.
*
* [in] tfp
* Pointer to session handle
*
* [in] parms
* Pointer to IF table get parameters
*
* Returns:
* 0 on Success else internal Truflow error
*/
int tf_msg_get_if_tbl_entry(struct tf *tfp,
struct tf_if_tbl_get_parms *params);
#endif /* _TF_MSG_H_ */

View File

@ -70,14 +70,24 @@ tf_session_open_session(struct tf *tfp,
goto cleanup;
}
tfp->session->core_data = cparms.mem_va;
session_id = &parms->open_cfg->session_id;
/* Initialize Session and Device */
/* Update Session Info, which is what is visible to the caller */
tfp->session->ver.major = 0;
tfp->session->ver.minor = 0;
tfp->session->ver.update = 0;
tfp->session->session_id.internal.domain = session_id->internal.domain;
tfp->session->session_id.internal.bus = session_id->internal.bus;
tfp->session->session_id.internal.device = session_id->internal.device;
tfp->session->session_id.internal.fw_session_id = fw_session_id;
/* Initialize Session and Device, which is private */
session = (struct tf_session *)tfp->session->core_data;
session->ver.major = 0;
session->ver.minor = 0;
session->ver.update = 0;
session_id = &parms->open_cfg->session_id;
session->session_id.internal.domain = session_id->internal.domain;
session->session_id.internal.bus = session_id->internal.bus;
session->session_id.internal.device = session_id->internal.device;