From: Denis Pryazhennikov <denis.pryazhenni...@arknetworks.am> API allows to delete entry from any supported HW table.
Signed-off-by: Denis Pryazhennikov <denis.pryazhenni...@arknetworks.am> Reviewed-by: Ivan Malov <ivan.ma...@arknetworks.am> Reviewed-by: Andy Moreton <amore...@xilinx.com> --- drivers/common/sfc_efx/base/efx.h | 11 ++++ drivers/common/sfc_efx/base/efx_table.c | 77 +++++++++++++++++++++++++ drivers/common/sfc_efx/version.map | 1 + 3 files changed, 89 insertions(+) diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h index 90d86c70dd..49f807823e 100644 --- a/drivers/common/sfc_efx/base/efx.h +++ b/drivers/common/sfc_efx/base/efx.h @@ -5168,6 +5168,17 @@ efx_table_entry_insert( __in_bcount(data_size) uint8_t *entry_datap, __in unsigned int data_size); +LIBEFX_API +extern __checkReturn efx_rc_t +efx_table_entry_delete( + __in efx_nic_t *enp, + __in efx_table_id_t table_id, + __in uint16_t mask_id, + __in uint16_t key_width, + __in uint16_t mask_width, + __in_bcount(data_size) uint8_t *entry_datap, + __in unsigned int data_size); + #ifdef __cplusplus } #endif diff --git a/drivers/common/sfc_efx/base/efx_table.c b/drivers/common/sfc_efx/base/efx_table.c index 6ebb92e83b..13a12a116e 100644 --- a/drivers/common/sfc_efx/base/efx_table.c +++ b/drivers/common/sfc_efx/base/efx_table.c @@ -419,6 +419,83 @@ efx_table_entry_insert( fail4: EFSYS_PROBE(fail4); +fail3: + EFSYS_PROBE(fail3); +fail2: + EFSYS_PROBE(fail2); +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + return (rc); +} + + __checkReturn efx_rc_t +efx_table_entry_delete( + __in efx_nic_t *enp, + __in efx_table_id_t table_id, + __in uint16_t mask_id, + __in uint16_t key_width, + __in uint16_t mask_width, + __in_bcount(data_size) uint8_t *entry_datap, + __in unsigned int data_size) +{ + const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp); + unsigned int n_dwords; + efx_mcdi_req_t req; + efx_rc_t rc; + EFX_MCDI_DECLARE_BUF(payload, + MC_CMD_TABLE_DELETE_IN_LENMAX_MCDI2, + MC_CMD_TABLE_DELETE_OUT_LEN); + + /* + * Ensure MCDI number of 32bit units matches EFX maximum possible + * data in bytes. + */ + EFX_STATIC_ASSERT((MC_CMD_TABLE_DELETE_IN_LENMAX * sizeof(uint32_t)) == + EFX_TABLE_ENTRY_LENGTH_MAX); + + if (encp->enc_table_api_supported == B_FALSE) { + rc = ENOTSUP; + goto fail1; + } + + if ((data_size % sizeof(uint32_t)) != 0) { + rc = EINVAL; + goto fail2; + } + + if ((data_size == 0) || (data_size > EFX_TABLE_ENTRY_LENGTH_MAX)) { + rc = EINVAL; + goto fail3; + } + + n_dwords = data_size / sizeof(uint32_t); + + req.emr_cmd = MC_CMD_TABLE_DELETE; + req.emr_in_buf = payload; + req.emr_in_length = MC_CMD_TABLE_DELETE_IN_LEN(n_dwords); + req.emr_out_buf = payload; + req.emr_out_length = MC_CMD_TABLE_DELETE_OUT_LEN; + + MCDI_IN_SET_DWORD(req, TABLE_DELETE_IN_TABLE_ID, (uint32_t)table_id); + MCDI_IN_SET_WORD(req, TABLE_DELETE_IN_MASK_ID, mask_id); + MCDI_IN_SET_WORD(req, TABLE_DELETE_IN_KEY_WIDTH, key_width); + MCDI_IN_SET_WORD(req, TABLE_DELETE_IN_MASK_WIDTH, mask_width); + + + memcpy(MCDI_IN2(req, uint8_t, TABLE_DELETE_IN_DATA), entry_datap, data_size); + + efx_mcdi_execute(enp, &req); + + if (req.emr_rc != 0) { + rc = req.emr_rc; + goto fail4; + } + + return (0); + +fail4: + EFSYS_PROBE(fail4); + fail3: EFSYS_PROBE(fail3); fail2: diff --git a/drivers/common/sfc_efx/version.map b/drivers/common/sfc_efx/version.map index 2be519e0e1..d083a54a03 100644 --- a/drivers/common/sfc_efx/version.map +++ b/drivers/common/sfc_efx/version.map @@ -233,6 +233,7 @@ INTERNAL { efx_sram_buf_tbl_set; efx_table_describe; + efx_table_entry_delete; efx_table_entry_insert; efx_table_is_supported; efx_table_list; -- 2.30.2