bnxt patchset to improve rte flow support
v2 cover bnxt patchset to improve rte flow support
Among other changes, this patchset adds support to:
- create filters with RSS action.
- create source MAC filters.
- use user provided priority to place rule appropriately in HW.
This patch has been rebased to dpdk-next-net commit 8587a8b9eddefa39e4ceac7e9385efcc5e73307c
Please apply.
Ajit Khaparde (13):
net/bnxt: return standard error codes for HWRM command net/bnxt: refactor code to allow dynamic creation of VNIC net/bnxt: allow flow creation when RSS is enabled net/bnxt: add support to create SMAC and inner DMAC filters net/bnxt: add support for RSS action
net/bnxt: parse priority attribute for flow creation net/bnxt: delete and flush L2 filters cleanly net/bnxt: cleanup vnic after flow validate net/bnxt: allow only unicast MAC address filter creation net/bnxt: check device is started before flow creation net/bnxt: handle cleanup if flow creation fails net/bnxt: drop untagged frames when specified net/bnxt: handle flow flush handling
Kalesh AP (2):
net/bnxt: fix an issue in setting default MAC address net/bnxt: fix multicast filter programming
Rahul Gupta (1):
net/bnxt: properly handle ring cleanup in case of error
Somnath Kotur (1):
net/bnxt: check for invalid VNIC ID in vnic tpa cfg
Venkat Duvvuru (3):
net/bnxt: validate RSS hash key length net/bnxt: synchronize between flow related functions net/bnxt: fix VLAN filtering code path
drivers/net/bnxt/bnxt.h | 12 + drivers/net/bnxt/bnxt_ethdev.c | 254 ++++++--- drivers/net/bnxt/bnxt_filter.c | 18 +- drivers/net/bnxt/bnxt_filter.h | 18 + drivers/net/bnxt/bnxt_flow.c | 904 ++++++++++++++++++++++++++++----- drivers/net/bnxt/bnxt_hwrm.c | 190 +++++-- drivers/net/bnxt/bnxt_hwrm.h | 7 +- drivers/net/bnxt/bnxt_ring.c | 37 ++ drivers/net/bnxt/bnxt_rxq.c | 29 +- drivers/net/bnxt/bnxt_vnic.c | 38 +- drivers/net/bnxt/bnxt_vnic.h | 6 + 11 files changed, 1240 insertions(+), 273 deletions(-)
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH v2 1/20 net/bnxt: return standard error codes for HWRM command
If the FW returns an error for an HWRM request, it does not necessarily return standard error codes. Convert these HWRM errors to standard errno.
--- drivers/net/bnxt/bnxt_hwrm.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/net/bnxt/bnxt_hwrm.c +14 -2
@@ -219,8 +219,14 @@ static int bnxt_hwrm_send_message(struct bnxt *bp, void *msg,rte_spinlock_unlock (&bp->hwrm_lock); \if (rc ==HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED ) \ rc = -EACCES ; \ -else if (rc >0 ) \ +else if (rc ==HWRM_ERR_CODE_RESOURCE_ALLOC_ERROR ) \ + rc = -ENOSPC ; \ +else if (rc ==HWRM_ERR_CODE_INVALID_PARAMS ) \ rc = -EINVAL ; \ +else if (rc ==HWRM_ERR_CODE_CMD_NOT_SUPPORTED ) \ + rc = -ENOTSUP ; \ +else if (rc >0 ) \ + rc = -EIO ; \return rc; \ } \if (resp->error_code) { \
@@ -241,8 +247,14 @@ static int bnxt_hwrm_send_message(struct bnxt *bp, void *msg,rte_spinlock_unlock (&bp->hwrm_lock); \if (rc ==HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED ) \ rc = -EACCES ; \ -else if (rc >0 ) \ +else if (rc ==HWRM_ERR_CODE_RESOURCE_ALLOC_ERROR ) \ + rc = -ENOSPC ; \ +else if (rc ==HWRM_ERR_CODE_INVALID_PARAMS ) \ rc = -EINVAL ; \ +else if (rc ==HWRM_ERR_CODE_CMD_NOT_SUPPORTED ) \ + rc = -ENOTSUP ; \ +else if (rc >0 ) \ + rc = -EIO ; \return rc; \ } \ }while (0 )
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH v2 2/20 net/bnxt: refactor code to allow dynamic creation of VNIC
In reply to Ajit KhapardeRefactor code to allow dynamic creation of VNIC for RSS or Queue Action during flow create.
--- drivers/net/bnxt/bnxt.h | 1 + drivers/net/bnxt/bnxt_ethdev.c | 54 ++++++++++------------------------ drivers/net/bnxt/bnxt_flow.c | 12 ++++++++ drivers/net/bnxt/bnxt_hwrm.c | 1 + drivers/net/bnxt/bnxt_rxq.c | 27 +++++++---------- drivers/net/bnxt/bnxt_vnic.c | 36 +++++++++++++++++++++++ drivers/net/bnxt/bnxt_vnic.h | 3 ++ 7 files changed, 78 insertions(+), 56 deletions(-)
drivers/net/bnxt/bnxt.h +1 -0
@@ -454,6 +454,7 @@ struct bnxt {unsigned int rx_nr_rings;unsigned int rx_cp_nr_rings; +unsigned int rx_num_qs_per_vnic;struct bnxt_rx_queue **rx_queues;const void *rx_mem_zone;struct rx_port_stats *hw_rx_port_stats;
drivers/net/bnxt/bnxt_ethdev.c +15 -39
82 lines not on this page · raw message
drivers/net/bnxt/bnxt_flow.c +12 -0
@@ -1071,6 +1071,13 @@ bnxt_flow_create(struct rte_eth_dev *dev,int ret =0 ;uint32_t tun_type; +if (BNXT_VF (bp) && !BNXT_VF_IS_TRUSTED (bp)) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_HANDLE ,NULL , +"Failed to create flow, Not a Trusted VF!" ); +return NULL ; + } + flow =rte_zmalloc ("bnxt_flow" ,sizeof (struct rte_flow ),0 );if (!flow) { rte_flow_error_set(error, ENOMEM,
@@ -1249,6 +1256,11 @@ bnxt_flow_destroy(struct rte_eth_dev *dev,struct bnxt_vnic_info *vnic = flow->vnic;int ret =0 ; +if (!filter) { + ret = -EINVAL ; + goto done; + } +if (filter->filter_type ==HWRM_CFA_TUNNEL_REDIRECT_FILTER && filter->enables == filter->tunnel_type) { ret = bnxt_handle_tunnel_redirect_destroy(bp,
drivers/net/bnxt/bnxt_hwrm.c +1 -0
@@ -2327,6 +2327,7 @@ int bnxt_clear_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic)else rc =bnxt_hwrm_clear_l2_filter (bp, filter);STAILQ_REMOVE (&vnic->filter, filter, bnxt_filter_info, next); +bnxt_free_filter (bp, filter);//if (rc) //break; }
drivers/net/bnxt/bnxt_rxq.c +10 -17
@@ -100,6 +100,7 @@ int bnxt_mq_rx_configure(struct bnxt *bp) } } nb_q_per_grp = bp->rx_cp_nr_rings / pools; + bp->rx_num_qs_per_vnic = nb_q_per_grp;PMD_DRV_LOG (DEBUG ,"pools = %u nb_q_per_grp = %u\n" , pools, nb_q_per_grp); start_grp_id =0 ;
@@ -158,29 +159,16 @@ int bnxt_mq_rx_configure(struct bnxt *bp) out:if (dev_conf->rxmode.mq_mode Ð_MQ_RX_RSS_FLAG ) {struct rte_eth_rss_conf *rss = &dev_conf->rx_adv_conf.rss_conf; -uint16_t hash_type =0 ;if (bp->flags &BNXT_FLAG_UPDATE_HASH ) { rss = &bp->rss_conf; bp->flags &= ~BNXT_FLAG_UPDATE_HASH ; } -if (rss->rss_hf Ð_RSS_IPV4 ) - hash_type |=HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4 ; -if (rss->rss_hf Ð_RSS_NONFRAG_IPV4_TCP ) - hash_type |=HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV4 ; -if (rss->rss_hf Ð_RSS_NONFRAG_IPV4_UDP ) - hash_type |=HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV4 ; -if (rss->rss_hf Ð_RSS_IPV6 ) - hash_type |=HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV6 ; -if (rss->rss_hf Ð_RSS_NONFRAG_IPV6_TCP ) - hash_type |=HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV6 ; -if (rss->rss_hf Ð_RSS_NONFRAG_IPV6_UDP ) - hash_type |=HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV6 ; -for (i =0 ; i < bp->nr_vnics; i++) { vnic = &bp->vnic_info[i]; - vnic->hash_type = hash_type; + vnic->hash_type = +bnxt_rte_to_hwrm_hash_types (rss->rss_hf);/* * Use the supplied key if the key length is
@@ -469,7 +457,9 @@ int bnxt_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id) vnic, bp->grp_info[rx_queue_id].fw_grp_id); } - rc =bnxt_vnic_rss_configure (bp, vnic); +PMD_DRV_LOG (DEBUG ,"Rx Queue Count %d\n" , vnic->rx_queue_cnt); +if (vnic->rx_queue_cnt >1 ) + rc =bnxt_vnic_rss_configure (bp, vnic); }if (rc ==0 )
@@ -522,7 +512,10 @@ int bnxt_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id) vnic = rxq->vnic;if (BNXT_HAS_RING_GRPS (bp)) vnic->fw_grp_ids[rx_queue_id] =INVALID_HW_RING_ID ; - rc =bnxt_vnic_rss_configure (bp, vnic); + +PMD_DRV_LOG (DEBUG ,"Rx Queue Count %d\n" , vnic->rx_queue_cnt); +if (vnic->rx_queue_cnt >1 ) + rc =bnxt_vnic_rss_configure (bp, vnic); }if (rc ==0 )
drivers/net/bnxt/bnxt_vnic.c +36 -0
@@ -222,3 +222,39 @@ int bnxt_alloc_vnic_mem(struct bnxt *bp) bp->vnic_info = vnic_mem;return 0 ; } + +int bnxt_vnic_grp_alloc (struct bnxt *bp,struct bnxt_vnic_info *vnic) +{ +uint32_t size =sizeof (*vnic->fw_grp_ids) * bp->max_ring_grps; + + vnic->fw_grp_ids =rte_zmalloc ("vnic_fw_grp_ids" , size,0 ); +if (!vnic->fw_grp_ids) { +PMD_DRV_LOG (ERR , +"Failed to alloc %d bytes for group ids\n" , + size); +return -ENOMEM ; + } +memset (vnic->fw_grp_ids,-1 , size); + +return 0 ; +} + +uint16_t bnxt_rte_to_hwrm_hash_types (uint64_t rte_type) +{ +uint16_t hwrm_type =0 ; + +if (rte_type Ð_RSS_IPV4 ) + hwrm_type |=HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4 ; +if (rte_type Ð_RSS_NONFRAG_IPV4_TCP ) + hwrm_type |=HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV4 ; +if (rte_type Ð_RSS_NONFRAG_IPV4_UDP ) + hwrm_type |=HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV4 ; +if (rte_type Ð_RSS_IPV6 ) + hwrm_type |=HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV6 ; +if (rte_type Ð_RSS_NONFRAG_IPV6_TCP ) + hwrm_type |=HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV6 ; +if (rte_type Ð_RSS_NONFRAG_IPV6_UDP ) + hwrm_type |=HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV6 ; + +return hwrm_type; +}
drivers/net/bnxt/bnxt_vnic.h +3 -0
@@ -42,6 +42,7 @@ struct bnxt_vnic_info {uint16_t cos_rule;uint16_t lb_rule; +uint16_t rx_queue_cnt;bool vlan_strip;bool func_default;bool bd_stall;
@@ -63,4 +64,6 @@ void bnxt_free_vnic_attributes(struct bnxt *bp);int bnxt_alloc_vnic_attributes (struct bnxt *bp);void bnxt_free_vnic_mem (struct bnxt *bp);int bnxt_alloc_vnic_mem (struct bnxt *bp); +int bnxt_vnic_grp_alloc (struct bnxt *bp,struct bnxt_vnic_info *vnic); +uint16_t bnxt_rte_to_hwrm_hash_types (uint64_t rte_type);#endif
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH v2 3/20 net/bnxt: allow flow creation when RSS is enabled
In reply to Ajit KhapardeCurrently flow creation is allowed with queue action only when RSS is disabled. Remove this restriction. Flows can be created when RSS is enabled.
--- drivers/net/bnxt/bnxt.h | 1 + drivers/net/bnxt/bnxt_ethdev.c | 2 +- drivers/net/bnxt/bnxt_flow.c | 177 +++++++++++++++++++++++++++------ drivers/net/bnxt/bnxt_vnic.h | 2 + 4 files changed, 149 insertions(+), 33 deletions(-)
drivers/net/bnxt/bnxt.h +1 -0
@@ -554,6 +554,7 @@ struct bnxt {int bnxt_link_update_op (struct rte_eth_dev *eth_dev,int wait_to_complete);int bnxt_rcv_msg_from_vf (struct bnxt *bp,uint16_t vf_id,void *msg);int is_bnxt_in_error (struct bnxt *bp); +uint16_t bnxt_rss_ctxts (const struct bnxt *bp);int bnxt_map_fw_health_status_regs (struct bnxt *bp);uint32_t bnxt_read_fw_status_reg (struct bnxt *bp,uint32_t index);
drivers/net/bnxt/bnxt_ethdev.c +1 -1
@@ -189,7 +189,7 @@ int is_bnxt_in_error(struct bnxt *bp)* High level utility functions */ -static uint16_t bnxt_rss_ctxts (const struct bnxt *bp) +uint16_t bnxt_rss_ctxts (const struct bnxt *bp) {if (!BNXT_CHIP_THOR (bp))return 1 ;
drivers/net/bnxt/bnxt_flow.c +145 -32
270 lines not on this page · raw message
drivers/net/bnxt/bnxt_vnic.h +2 -0
@@ -9,6 +9,8 @@#include <sys/queue.h> #include <stdbool.h> +#define INVALID_VNIC_ID ((uint16_t)-1) +struct bnxt_vnic_info {STAILQ_ENTRY (bnxt_vnic_info) next;uint8_t ff_pool_idx;
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH v2 4/20 net/bnxt: add support to create SMAC and inner DMAC filters
In reply to Ajit KhapardeWe are currently creating only outer DMAC filters. Create SMAC and inner DMAC filters using HWRM_CFA_L2_FILTER_ALLOC. For this the HWRM_CFA_L2_FILTER_ALLOC has already been updated.
--- drivers/net/bnxt/bnxt.h | 4 ++ drivers/net/bnxt/bnxt_ethdev.c | 9 ++- drivers/net/bnxt/bnxt_filter.h | 8 +++ drivers/net/bnxt/bnxt_flow.c | 118 +++++++++++++++++++++++++-------- drivers/net/bnxt/bnxt_hwrm.c | 44 +++++++++++- drivers/net/bnxt/bnxt_hwrm.h | 4 ++ drivers/net/bnxt/bnxt_rxq.c | 2 + 7 files changed, 160 insertions(+), 29 deletions(-)
drivers/net/bnxt/bnxt.h +4 -0
@@ -439,6 +439,7 @@ struct bnxt {#define BNXT_FLAG_NEW_RM BIT(23)#define BNXT_FLAG_INIT_DONE BIT(24)#define BNXT_FLAG_FW_CAP_ONE_STEP_TX_TS BIT(25) +#define BNXT_FLAG_ADV_FLOW_MGMT BIT(26)#define BNXT_PF (bp) (!((bp)->flags & BNXT_FLAG_VF))#define BNXT_VF (bp) ((bp)->flags & BNXT_FLAG_VF)#define BNXT_NPAR (bp) ((bp)->port_partition_type)
@@ -452,6 +453,9 @@ struct bnxt {#define BNXT_HAS_NQ (bp) BNXT_CHIP_THOR(bp)#define BNXT_HAS_RING_GRPS (bp) (!BNXT_CHIP_THOR(bp)) +uint32_t flow_flags; +#define BNXT_FLOW_FLAG_L2_HDR_SRC_FILTER_EN BIT(0) +unsigned int rx_nr_rings;unsigned int rx_cp_nr_rings;unsigned int rx_num_qs_per_vnic;
drivers/net/bnxt/bnxt_ethdev.c +8 -1
@@ -1039,6 +1039,7 @@ static int bnxt_mac_addr_add_op(struct rte_eth_dev *eth_dev, filter->mac_index = index;memcpy (filter->l2_addr, mac_addr,RTE_ETHER_ADDR_LEN ); + filter->flags |=HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_OUTERMOST ; rc =bnxt_hwrm_set_l2_filter (bp, vnic->fw_vnic_id, filter);if (!rc) {
@@ -1739,6 +1740,7 @@ static int bnxt_add_vlan_filter(struct bnxt *bp, uint16_t vlan_id) filter->l2_ivlan = vlan_id; filter->l2_ivlan_mask =0x0FFF ; filter->enables |= en; + filter->flags |=HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_OUTERMOST ; rc =bnxt_hwrm_set_l2_filter (bp, vnic->fw_vnic_id, filter);if (rc) {/* Free the newly allocated filter as we were
@@ -1904,7 +1906,8 @@ bnxt_set_default_mac_addr_op(struct rte_eth_dev *dev,memcpy (filter->l2_addr, bp->mac_addr,RTE_ETHER_ADDR_LEN );memset (filter->l2_addr_mask,0xff ,RTE_ETHER_ADDR_LEN ); - filter->flags |=HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_RX ; + filter->flags |=HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_RX | +HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_OUTERMOST ; filter->enables |=HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR |HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR_MASK ;
@@ -4433,6 +4436,10 @@ static int bnxt_init_fw(struct bnxt *bp)if (rc)return -EIO ; + rc =bnxt_hwrm_cfa_adv_flow_mgmt_qcaps (bp); +if (rc) +return rc; + rc =bnxt_hwrm_queue_qportcfg (bp);if (rc)return rc;
drivers/net/bnxt/bnxt_filter.h +8 -0
@@ -9,6 +9,13 @@#include <rte_ether.h> struct bnxt ; + +#define BNXT_FLOW_L2_VALID_FLAG BIT(0) +#define BNXT_FLOW_L2_SRC_VALID_FLAG BIT(1) +#define BNXT_FLOW_L2_INNER_SRC_VALID_FLAG BIT(2) +#define BNXT_FLOW_L2_DST_VALID_FLAG BIT(3) +#define BNXT_FLOW_L2_INNER_DST_VALID_FLAG BIT(4) +struct bnxt_filter_info {STAILQ_ENTRY (bnxt_filter_info) next;uint64_t fw_l2_filter_id;
@@ -28,6 +35,7 @@ struct bnxt_filter_info {uint32_t enables;uint8_t l2_addr[RTE_ETHER_ADDR_LEN ];uint8_t l2_addr_mask[RTE_ETHER_ADDR_LEN ]; +uint32_t valid_flags;uint16_t l2_ovlan;uint16_t l2_ovlan_mask;uint16_t l2_ivlan;
drivers/net/bnxt/bnxt_flow.c +92 -26
220 lines not on this page · raw message
drivers/net/bnxt/bnxt_hwrm.c +42 -2
65 lines not on this page · raw message
drivers/net/bnxt/bnxt_hwrm.h +4 -0
@@ -38,6 +38,9 @@ struct bnxt_cp_ring_info;#define HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESV_STRATEGY_MINIMAL_STATIC \ HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESERVATION_STRATEGY_MINIMAL_STATIC +#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_L2_HDR_SRC_FILTER_EN \ +HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_L2_HEADER_SOURCE_FIELDS_SUPPORTED +#define HWRM_SPEC_CODE_1_8_4 0x10804#define HWRM_SPEC_CODE_1_9_0 0x10900#define HWRM_SPEC_CODE_1_9_2 0x10902
@@ -210,4 +213,5 @@ int bnxt_hwrm_error_recovery_qcfg(struct bnxt *bp);int bnxt_hwrm_fw_reset (struct bnxt *bp);int bnxt_hwrm_port_ts_query (struct bnxt *bp,uint8_t path,uint64_t *timestamp); +int bnxt_hwrm_cfa_adv_flow_mgmt_qcaps (struct bnxt *bp);#endif
drivers/net/bnxt/bnxt_rxq.c +2 -0
@@ -64,6 +64,7 @@ int bnxt_mq_rx_configure(struct bnxt *bp) rc = -ENOMEM ; goto err_out; } + filter->flags |=HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_OUTERMOST ;STAILQ_INSERT_TAIL (&vnic->filter, filter, next); goto out; }
@@ -145,6 +146,7 @@ int bnxt_mq_rx_configure(struct bnxt *bp) rc = -ENOMEM ; goto err_out; } + filter->flags |=HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_OUTERMOST ;/* * TODO: Configure & associate CFA rule for * each VNIC for each VMDq with MACVLAN, MACVLAN+TC
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH v2 5/20 net/bnxt: add support for RSS action
In reply to Ajit KhapardeAdd support for RSS action during flow creation.
group id should not be 0 when RSS action is specified. Driver will return an error for such a flow.
If a group id is used to create a filter with “n” RSS queues, it cannot be used to create a filter with a different number of RSS queues till all the flows using that combination are deleted.
While creating a flow if a group id groups a certain Rx queue ids for RSS, the same group id shall not create a flow with a different group of Rx queue ids till all the flows belonging to the group ids are deleted.
While creating a flow if a group id groups a certain Rx queue ids for RSS, the same queue ids shall not be used with a different group id till all flows created with that group id are deleted.
--- drivers/net/bnxt/bnxt_filter.h | 2 + drivers/net/bnxt/bnxt_flow.c | 377 ++++++++++++++++++++++++++++----- drivers/net/bnxt/bnxt_hwrm.c | 13 ++ drivers/net/bnxt/bnxt_vnic.c | 2 +- drivers/net/bnxt/bnxt_vnic.h | 1 + 5 files changed, 337 insertions(+), 58 deletions(-)
drivers/net/bnxt/bnxt_filter.h +2 -0
@@ -19,6 +19,7 @@ struct bnxt;struct bnxt_filter_info {STAILQ_ENTRY (bnxt_filter_info) next;uint64_t fw_l2_filter_id; +struct bnxt_filter_info *matching_l2_fltr_ptr;uint64_t fw_em_filter_id;uint64_t fw_ntuple_filter_id;#define INVALID_MAC_INDEX ((uint16_t)-1)
@@ -33,6 +34,7 @@ struct bnxt_filter_info {/* Filter Characteristics */ uint32_t flags;uint32_t enables; +uint32_t l2_ref_cnt;uint8_t l2_addr[RTE_ETHER_ADDR_LEN ];uint8_t l2_addr_mask[RTE_ETHER_ADDR_LEN ];uint32_t valid_flags;
drivers/net/bnxt/bnxt_flow.c +320 -57
512 lines not on this page · raw message
drivers/net/bnxt/bnxt_hwrm.c +13 -0
@@ -373,12 +373,25 @@ int bnxt_hwrm_clear_l2_filter(struct bnxt *bp, struct bnxt_filter_info *filter) {int rc =0 ; +struct bnxt_filter_info *l2_filter = filter;struct hwrm_cfa_l2_filter_free_input req = {.req_type =0 };struct hwrm_cfa_l2_filter_free_output *resp = bp->hwrm_cmd_resp_addr;if (filter->fw_l2_filter_id ==UINT64_MAX )return 0 ; +if (filter->matching_l2_fltr_ptr) + l2_filter = filter->matching_l2_fltr_ptr; + +PMD_DRV_LOG (DEBUG ,"filter: %p l2_filter: %p ref_cnt: %d\n" , + filter, l2_filter, l2_filter->l2_ref_cnt); + +if (l2_filter->l2_ref_cnt >0 ) + l2_filter->l2_ref_cnt--; + +if (l2_filter->l2_ref_cnt >0 ) +return 0 ; +HWRM_PREP (req,CFA_L2_FILTER_FREE ,BNXT_USE_CHIMP_MB ); req.l2_filter_id =rte_cpu_to_le_64 (filter->fw_l2_filter_id);
drivers/net/bnxt/bnxt_vnic.c +1 -1
@@ -16,7 +16,7 @@* VNIC Functions */ -static void prandom_bytes (void *dest_ptr,size_t len) +void prandom_bytes (void *dest_ptr,size_t len) {char *dest = (char *)dest_ptr;uint64_t rb;
drivers/net/bnxt/bnxt_vnic.h +1 -0
@@ -67,5 +67,6 @@ int bnxt_alloc_vnic_attributes(struct bnxt *bp);void bnxt_free_vnic_mem (struct bnxt *bp);int bnxt_alloc_vnic_mem (struct bnxt *bp);int bnxt_vnic_grp_alloc (struct bnxt *bp,struct bnxt_vnic_info *vnic); +void prandom_bytes (void *dest_ptr,size_t len);uint16_t bnxt_rte_to_hwrm_hash_types (uint64_t rte_type);#endif
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH v2 6/20 net/bnxt: parse priority attribute for flow creation
In reply to Ajit KhapardeParse priority attribute during flow creation. This information will be used to give a hint to the FW to place the flow rule accordingly in the CFA tables.
--- drivers/net/bnxt/bnxt_filter.h | 1 + drivers/net/bnxt/bnxt_flow.c | 25 +++++++++++-------------- 2 files changed, 12 insertions(+), 14 deletions(-)
drivers/net/bnxt/bnxt_filter.h +1 -0
@@ -68,6 +68,7 @@ struct bnxt_filter_info {uint16_t ip_protocol;uint16_t ip_addr_type;uint16_t ethertype; +uint32_t priority; };struct bnxt_filter_info *bnxt_alloc_filter (struct bnxt *bp);
drivers/net/bnxt/bnxt_flow.c +11 -14
@@ -227,6 +227,9 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, valid_flags |= inner ?BNXT_FLOW_L2_INNER_DST_VALID_FLAG :BNXT_FLOW_L2_DST_VALID_FLAG ; + filter->priority = attr->priority; +PMD_DRV_LOG (DEBUG , +"Creating a priority flow\n" ); }if (rte_is_broadcast_ether_addr (ð_mask->src)) {
@@ -712,15 +715,6 @@ bnxt_flow_parse_attr(const struct rte_flow_attr *attr,return -rte_errno; } -/* Not supported */ -if (attr->priority) { -rte_flow_error_set (error, -EINVAL , -RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY , - attr, -"No support for priority." ); -return -rte_errno; - }return 0 ; }
@@ -802,13 +796,16 @@ bnxt_create_l2_filter(struct bnxt *bp, struct bnxt_filter_info *nf,memcpy (filter1->l2_addr, nf->dst_macaddr,RTE_ETHER_ADDR_LEN ); } -if (nf->valid_flags &BNXT_FLOW_L2_DST_VALID_FLAG || - nf->valid_flags &BNXT_FLOW_L2_INNER_DST_VALID_FLAG ) { +if (nf->priority && + (nf->valid_flags &BNXT_FLOW_L2_DST_VALID_FLAG || + nf->valid_flags &BNXT_FLOW_L2_INNER_DST_VALID_FLAG )) {/* Tell the FW where to place the filter in the table. */ - filter1->pri_hint = +if (nf->priority >65535 ) { + filter1->pri_hint =HWRM_CFA_L2_FILTER_ALLOC_INPUT_PRI_HINT_BELOW_FILTER ; -/* This will place the filter in TCAM */ - filter1->l2_filter_id_hint = (uint64_t )-1 ; +/* This will place the filter in TCAM */ + filter1->l2_filter_id_hint = (uint64_t )-1 ; + } } filter1->enables = HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR |
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH v2 7/20 net/bnxt: delete and flush L2 filters cleanly
In reply to Ajit KhapardeOnce the last filter associated with a VNIC is deleted when using RSS action or the Queue action free the VNIC. Also free the RSS context if the VNIC is using it.
--- drivers/net/bnxt/bnxt_filter.c | 18 +++++------- drivers/net/bnxt/bnxt_flow.c | 41 ++++++++++++++++++++++++++-- drivers/net/bnxt/bnxt_hwrm.c | 50 ++++++++++++++++++++-------------- 3 files changed, 75 insertions(+), 34 deletions(-)
drivers/net/bnxt/bnxt_filter.c +7 -11
@@ -117,6 +117,13 @@ void bnxt_free_filter_mem(struct bnxt *bp) max_filters = bp->max_l2_ctx;for (i =0 ; i < max_filters; i++) { filter = &bp->filter_info[i]; +if (filter->fw_ntuple_filter_id != ((uint64_t )-1 ) && + filter->filter_type ==HWRM_CFA_NTUPLE_FILTER ) { +/* Call HWRM to try to free filter again */ + rc =bnxt_hwrm_clear_ntuple_filter (bp, filter); + } + filter->fw_ntuple_filter_id =UINT64_MAX ; +if (filter->fw_l2_filter_id != ((uint64_t )-1 ) && filter->filter_type ==HWRM_CFA_L2_FILTER ) {PMD_DRV_LOG (DEBUG ,"L2 filter is not free\n" );
@@ -129,17 +136,6 @@ void bnxt_free_filter_mem(struct bnxt *bp) } filter->fw_l2_filter_id =UINT64_MAX ; -if (filter->fw_ntuple_filter_id != ((uint64_t )-1 ) && - filter->filter_type ==HWRM_CFA_NTUPLE_FILTER ) { -PMD_DRV_LOG (ERR ,"NTUPLE filter is not free\n" ); -/* Call HWRM to try to free filter again */ - rc =bnxt_hwrm_clear_ntuple_filter (bp, filter); -if (rc) -PMD_DRV_LOG (ERR , -"Cannot free NTUPLE filter: %d\n" , - rc); - } - filter->fw_ntuple_filter_id =UINT64_MAX ; }STAILQ_INIT (&bp->free_filter_list);
drivers/net/bnxt/bnxt_flow.c +39 -2
75 lines not on this page · raw message
drivers/net/bnxt/bnxt_hwrm.c +29 -21
72 lines not on this page · raw message
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH v2 8/20 net/bnxt: cleanup vnic after flow validate
In reply to Ajit KhapardeWhen an application issues flow validate, we free the temporary filter that is created. But the vnic is not freed up. This can potentially interfere with subsequent flow creation. So free the vnic.
--- drivers/net/bnxt/bnxt_flow.c | 76 +++++++++++++++++++++--------------- drivers/net/bnxt/bnxt_hwrm.c | 41 ++++++++++++------- drivers/net/bnxt/bnxt_hwrm.h | 3 +- 3 files changed, 73 insertions(+), 47 deletions(-)
drivers/net/bnxt/bnxt_flow.c +45 -31
@@ -1355,6 +1355,25 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,return rc; } +static +struct bnxt_vnic_info *find_matching_vnic (struct bnxt *bp, +struct bnxt_filter_info *filter) +{ +struct bnxt_vnic_info *vnic =NULL ; +unsigned int i; + +for (i =0 ; i < bp->max_vnics; i++) { + vnic = &bp->vnic_info[i]; +if (vnic->fw_vnic_id !=INVALID_VNIC_ID && + filter->dst_id == vnic->fw_vnic_id) { +PMD_DRV_LOG (DEBUG ,"Found matching VNIC Id %d\n" , + vnic->ff_pool_idx); +return vnic; + } + } +return NULL ; +} + static int bnxt_flow_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
@@ -1363,6 +1382,7 @@ bnxt_flow_validate(struct rte_eth_dev *dev, struct rte_flow_error *error) {struct bnxt *bp = dev->data->dev_private; +struct bnxt_vnic_info *vnic =NULL ;struct bnxt_filter_info *filter;int ret =0 ;
@@ -1378,6 +1398,26 @@ bnxt_flow_validate(struct rte_eth_dev *dev, ret =bnxt_validate_and_parse_flow (dev, pattern, actions, attr, error, filter); + + vnic =find_matching_vnic (bp, filter); +if (vnic) { +if (STAILQ_EMPTY (&vnic->filter)) { +rte_free (vnic->fw_grp_ids); +bnxt_hwrm_vnic_ctx_free (bp, vnic); +bnxt_hwrm_vnic_free (bp, vnic); + vnic->rx_queue_cnt =0 ; + bp->nr_vnics--; +PMD_DRV_LOG (DEBUG ,"Free VNIC\n" ); + } + } + +if (filter->filter_type ==HWRM_CFA_EM_FILTER ) +bnxt_hwrm_clear_em_filter (bp, filter); +else if (filter->filter_type ==HWRM_CFA_NTUPLE_FILTER ) +bnxt_hwrm_clear_ntuple_filter (bp, filter); +else +bnxt_hwrm_clear_l2_filter (bp, filter); +/* No need to hold on to this filter if we are just validating flow */ filter->fw_l2_filter_id =UINT64_MAX ;bnxt_free_filter (bp, filter);
@@ -1414,7 +1454,7 @@ bnxt_match_filter(struct bnxt *bp, struct bnxt_filter_info *nf)struct rte_flow *flow;int i; -for (i = bp->max_vnics; i >=0 ; i--) { +for (i = bp->max_vnics -1 ; i >=0 ; i--) {struct bnxt_vnic_info *vnic = &bp->vnic_info[i];if (vnic->fw_vnic_id ==INVALID_VNIC_ID )
@@ -1484,7 +1524,6 @@ bnxt_flow_create(struct rte_eth_dev *dev,struct bnxt_filter_info *filter;bool update_flow = false;struct rte_flow *flow; -unsigned int i;int ret =0 ;uint32_t tun_type;
@@ -1585,15 +1624,7 @@ bnxt_flow_create(struct rte_eth_dev *dev, ret =bnxt_hwrm_set_ntuple_filter (bp, filter->dst_id, filter); } -for (i =0 ; i < bp->max_vnics; i++) { - vnic = &bp->vnic_info[i]; -if (vnic->fw_vnic_id !=INVALID_VNIC_ID && - filter->dst_id == vnic->fw_vnic_id) { -PMD_DRV_LOG (ERR ,"Found matching VNIC Id %d\n" , - vnic->ff_pool_idx); -break ; - } - } + vnic =find_matching_vnic (bp, filter); done:if (!ret || update_flow) { flow->filter = filter;
@@ -1734,26 +1765,9 @@ bnxt_flow_destroy(struct rte_eth_dev *dev,*/ if (vnic &&STAILQ_EMPTY (&vnic->flow_list)) {rte_free (vnic->fw_grp_ids); -if (vnic->rx_queue_cnt >1 ) { -if (BNXT_CHIP_THOR (bp)) { -int j; - -for (j =0 ; j < vnic->num_lb_ctxts; - j++) { -bnxt_hwrm_vnic_ctx_free (bp, - vnic, - vnic->fw_grp_ids[j]); - vnic->fw_grp_ids[j] = -INVALID_HW_RING_ID ; - } - vnic->num_lb_ctxts =0 ; - }else { -bnxt_hwrm_vnic_ctx_free (bp, - vnic, - vnic->rss_rule); - vnic->rss_rule =INVALID_HW_RING_ID ; - } - } +if (vnic->rx_queue_cnt >1 ) +bnxt_hwrm_vnic_ctx_free (bp, vnic); +bnxt_hwrm_vnic_free (bp, vnic); vnic->rx_queue_cnt =0 ; bp->nr_vnics--;
drivers/net/bnxt/bnxt_hwrm.c +27 -14
65 lines not on this page · raw message
drivers/net/bnxt/bnxt_hwrm.h +1 -2
@@ -112,8 +112,7 @@ int bnxt_hwrm_vnic_qcfg(struct bnxt *bp, struct bnxt_vnic_info *vnic, int16_t fw_vf_id);int bnxt_hwrm_vnic_ctx_alloc (struct bnxt *bp,struct bnxt_vnic_info *vnic,uint16_t ctx_idx); -int bnxt_hwrm_vnic_ctx_free (struct bnxt *bp,struct bnxt_vnic_info *vnic, -uint16_t ctx_idx); +int bnxt_hwrm_vnic_ctx_free (struct bnxt *bp,struct bnxt_vnic_info *vnic);int bnxt_hwrm_vnic_free (struct bnxt *bp,struct bnxt_vnic_info *vnic);int bnxt_hwrm_vnic_rss_cfg (struct bnxt *bp,struct bnxt_vnic_info *vnic);
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH v2 9/20 net/bnxt: fix an issue in setting default MAC address
In reply to Ajit KhapardeFrom: Kalesh AP <[email protected]>
Driver was incorrectly programming the MAC with the already configured one instead of the newly requested MAC by user.
Also, fix to restore the old mac address back to the default vnic filter if the mac update operation fails.
--- drivers/net/bnxt/bnxt_ethdev.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +5 -2
@@ -1904,7 +1904,7 @@ bnxt_set_default_mac_addr_op(struct rte_eth_dev *dev,if (filter->mac_index !=0 )continue ; -memcpy (filter->l2_addr, bp->mac_addr,RTE_ETHER_ADDR_LEN ); +memcpy (filter->l2_addr, addr,RTE_ETHER_ADDR_LEN );memset (filter->l2_addr_mask,0xff ,RTE_ETHER_ADDR_LEN ); filter->flags |=HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_RX |HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_OUTERMOST ;
@@ -1913,8 +1913,11 @@ bnxt_set_default_mac_addr_op(struct rte_eth_dev *dev,HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR_MASK ; rc =bnxt_hwrm_set_l2_filter (bp, vnic->fw_vnic_id, filter); -if (rc) +if (rc) { +memcpy (filter->l2_addr, bp->mac_addr, +RTE_ETHER_ADDR_LEN );return rc; + }memcpy (bp->mac_addr, addr,RTE_ETHER_ADDR_LEN );PMD_DRV_LOG (DEBUG ,"Set MAC addr\n" );
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH v2 10/20 net/bnxt: allow only unicast MAC address filter creation
In reply to Ajit KhapardeCheck if the application is trying to create filters using broadcast and multicast MAC address and reject it.
--- drivers/net/bnxt/bnxt_flow.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/net/bnxt/bnxt_flow.c +16 -0
@@ -219,6 +219,14 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, }if (rte_is_broadcast_ether_addr (ð_mask->dst)) { +if (!rte_is_unicast_ether_addr (ð_spec->dst)) { +rte_flow_error_set (error, +EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item, +"DMAC is invalid" ); +return -rte_errno; + }rte_memcpy (filter->dst_macaddr, ð_spec->dst,RTE_ETHER_ADDR_LEN ); en |= use_ntuple ?
@@ -233,6 +241,14 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp, }if (rte_is_broadcast_ether_addr (ð_mask->src)) { +if (!rte_is_unicast_ether_addr (ð_spec->src)) { +rte_flow_error_set (error, +EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item, +"SMAC is invalid" ); +return -rte_errno; + }rte_memcpy (filter->src_macaddr, ð_spec->src,RTE_ETHER_ADDR_LEN ); en |= use_ntuple ?
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH v2 11/20 net/bnxt: properly handle ring cleanup in case of error
In reply to Ajit KhapardeFrom: Rahul Gupta <[email protected]>
Initialize all rings to INVALID_HW_RING_ID.
This can be used to determine the rings to free if allocation fails.
--- drivers/net/bnxt/bnxt_ring.c | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
drivers/net/bnxt/bnxt_ring.c +37 -0
@@ -583,6 +583,42 @@ int bnxt_alloc_hwrm_rx_ring(struct bnxt *bp, int queue_index)return rc; } +/* Initialise all rings to -1, its used to free rings later if allocation +* of few rings fails. +*/ +static void bnxt_init_all_rings (struct bnxt *bp) +{ +unsigned int i =0 ; +struct bnxt_rx_queue *rxq; +struct bnxt_ring *cp_ring; +struct bnxt_ring *ring; +struct bnxt_rx_ring_info *rxr; +struct bnxt_tx_queue *txq; + +for (i =0 ; i < bp->rx_cp_nr_rings; i++) { + rxq = bp->rx_queues[i]; +/* Rx-compl */ + cp_ring = rxq->cp_ring->cp_ring_struct; + cp_ring->fw_ring_id =INVALID_HW_RING_ID ; +/* Rx-Reg */ + rxr = rxq->rx_ring; + ring = rxr->rx_ring_struct; + ring->fw_ring_id =INVALID_HW_RING_ID ; +/* Rx-AGG */ + ring = rxr->ag_ring_struct; + ring->fw_ring_id =INVALID_HW_RING_ID ; + } +for (i =0 ; i < bp->tx_cp_nr_rings; i++) { + txq = bp->tx_queues[i]; +/* Tx cmpl */ + cp_ring = txq->cp_ring->cp_ring_struct; + cp_ring->fw_ring_id =INVALID_HW_RING_ID ; +/*Tx Ring */ + ring = txq->tx_ring->tx_ring_struct; + ring->fw_ring_id =INVALID_HW_RING_ID ; + } +} +/* ring_grp usage: * [0] = default completion ring * [1 -> +rx_cp_nr_rings] = rx_cp, rx rings
@@ -596,6 +632,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)int rc =0 ;bnxt_init_dflt_coal (&coal); +bnxt_init_all_rings (bp);for (i =0 ; i < bp->rx_cp_nr_rings; i++) {struct bnxt_rx_queue *rxq = bp->rx_queues[i];
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH v2 12/20 net/bnxt: check device is started before flow creation
In reply to Ajit KhapardeCheck device is started before flow creation.
Since the vnic data structures aren't created until device start, the driver dereferences NULL vnic if flow creation is attempted before device is started,
--- drivers/net/bnxt/bnxt_flow.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/net/bnxt/bnxt_flow.c +9 -0
@@ -1550,6 +1550,15 @@ bnxt_flow_create(struct rte_eth_dev *dev,return NULL ; } +if (!dev->data->dev_started) { +rte_flow_error_set (error, +EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , +NULL , +"Device must be started" ); +return NULL ; + } + flow =rte_zmalloc ("bnxt_flow" ,sizeof (struct rte_flow ),0 );if (!flow) { rte_flow_error_set(error, ENOMEM,
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH v2 13/20 net/bnxt: check for invalid VNIC ID in vnic tpa cfg
In reply to Ajit KhapardeFrom: Somnath Kotur <[email protected]>
If driver init/probe fails as part of cleanup/rollback, we may end up invoking this HWRM cmd even on an invalid vNIC which will unecessarily log an error message as the cmd will fail.
Check for invalid ID before issuing the HWRM cmd
--- drivers/net/bnxt/bnxt_hwrm.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/bnxt/bnxt_hwrm.c +5 -0
@@ -1965,6 +1965,11 @@ int bnxt_hwrm_vnic_tpa_cfg(struct bnxt *bp,if (BNXT_CHIP_THOR (bp))return 0 ; +if (vnic->fw_vnic_id ==INVALID_HW_RING_ID ) { +PMD_DRV_LOG (DEBUG ,"Invalid vNIC ID\n" ); +return 0 ; + } +HWRM_PREP (req,VNIC_TPA_CFG ,BNXT_USE_CHIMP_MB );if (enable) {
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH v2 14/20 net/bnxt: validate RSS hash key length
In reply to Ajit KhapardeFrom: Venkat Duvvuru <[email protected]>
In bnxt_rss_hash_update_op, driver is proceeding with bnxt_hwrm_vnic_rss_cfg even though RSS hashkey length is invalid.
This patch fixes the problem by returning -EINVAL when RSS hashkey length is invalid.
--- drivers/net/bnxt/bnxt_ethdev.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +12 -6
@@ -1373,14 +1373,20 @@ static int bnxt_rss_hash_update_op(struct rte_eth_dev *eth_dev, vnic->hash_type =bnxt_rte_to_hwrm_hash_types (rss_conf->rss_hf);/* -* Use the supplied key if the key length is -* acceptable and the rss_key is not NULL +* If hashkey is not specified, use the previously configured +* hashkey */ -if (rss_conf->rss_key && rss_conf->rss_key_len <=HW_HASH_KEY_SIZE ) -memcpy (vnic->rss_hash_key, - rss_conf->rss_key, - rss_conf->rss_key_len); +if (!rss_conf->rss_key) + goto rss_config; +if (rss_conf->rss_key_len !=HW_HASH_KEY_SIZE ) { +PMD_DRV_LOG (ERR , +"Invalid hashkey length, should be 16 bytes\n" ); +return -EINVAL ; + } +memcpy (vnic->rss_hash_key, rss_conf->rss_key, rss_conf->rss_key_len); + +rss_config:bnxt_hwrm_vnic_rss_cfg (bp, vnic);return 0 ; }
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH v2 15/20 net/bnxt: handle cleanup if flow creation fails
In reply to Ajit KhapardeIf flow creation fails because of an HWRM command failure or or some other reason, reset the vnic and rxq info set earlier.
--- drivers/net/bnxt/bnxt_flow.c | 66 +++++++++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 5 deletions(-)
drivers/net/bnxt/bnxt_flow.c +61 -5
@@ -177,6 +177,14 @@ bnxt_validate_and_parse_flow_type(struct bnxt *bp,return -rte_errno; } +if (!item->spec || !item->mask) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ITEM , + item, +"spec/mask is NULL" ); +return -rte_errno; + } +switch (item->type) {case RTE_FLOW_ITEM_TYPE_ANY : inner =
@@ -971,11 +979,11 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,bnxt_flow_non_void_action (actions);struct bnxt *bp = dev->data->dev_private;struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf; +struct bnxt_vnic_info *vnic =NULL , *vnic0 =NULL ;const struct rte_flow_action_queue *act_q;const struct rte_flow_action_vf *act_vf;struct bnxt_filter_info *filter1 =NULL ;const struct rte_flow_action_rss *rss; -struct bnxt_vnic_info *vnic, *vnic0;struct bnxt_rx_queue *rxq =NULL ;int dflt_vnic, vnic_id;unsigned int rss_idx;
@@ -1077,8 +1085,15 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,PMD_DRV_LOG (DEBUG ,"VNIC found\n" ); rc =bnxt_vnic_prep (bp, vnic); -if (rc) +if (rc) { +rte_flow_error_set (error, +EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act, +"VNIC prep fail" ); + rc = -rte_errno; goto ret; + } PMD_DRV_LOG(DEBUG, "vnic[%d] = %p vnic->fw_grp_ids = %p\n",
@@ -1091,7 +1106,12 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, filter->dst_id = vnic->fw_vnic_id; filter1 =bnxt_get_l2_filter (bp, filter, vnic);if (filter1 ==NULL ) { - rc = -ENOSPC ; +rte_flow_error_set (error, +ENOSPC , +RTE_FLOW_ERROR_TYPE_ACTION , + act, +"Filter not available" ); + rc = -rte_errno; goto ret; }
@@ -1119,7 +1139,12 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, vnic0 = &bp->vnic_info[0 ]; filter1 =bnxt_get_l2_filter (bp, filter, vnic0);if (filter1 ==NULL ) { - rc = -ENOSPC ; +rte_flow_error_set (error, +ENOSPC , +RTE_FLOW_ERROR_TYPE_ACTION , + act, +"New filter not available" ); + rc = -rte_errno; goto ret; }
@@ -1182,6 +1207,11 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, vnic0 = &bp->vnic_info[0 ]; filter1 =bnxt_get_l2_filter (bp, filter, vnic0);if (filter1 ==NULL ) { +rte_flow_error_set (error, +ENOSPC , +RTE_FLOW_ERROR_TYPE_ACTION , + act, +"New filter not available" ); rc = -ENOSPC ; goto ret; }
@@ -1278,8 +1308,15 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, vnic->func_default =0 ;//This is not a default VNIC. rc =bnxt_vnic_prep (bp, vnic); -if (rc) +if (rc) { +rte_flow_error_set (error, +EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + act, +"VNIC prep fail" ); + rc = -rte_errno; goto ret; + } PMD_DRV_LOG(DEBUG, "vnic[%d] = %p vnic->fw_grp_ids = %p\n",
@@ -1334,6 +1371,11 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, filter->dst_id = vnic->fw_vnic_id; filter1 =bnxt_get_l2_filter (bp, filter, vnic);if (filter1 ==NULL ) { +rte_flow_error_set (error, +ENOSPC , +RTE_FLOW_ERROR_TYPE_ACTION , + act, +"New filter not available" ); rc = -ENOSPC ; goto ret; }
@@ -1367,7 +1409,18 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, rc = -rte_errno; goto ret; } + +return rc; ret: + +//TODO: Cleanup according to ACTION TYPE. +if (rte_errno) { +if (vnic &&STAILQ_EMPTY (&vnic->filter)) + vnic->rx_queue_cnt =0 ; + +if (rxq && !vnic->rx_queue_cnt) + rxq->vnic = &bp->vnic_info[0 ]; + }return rc; }
@@ -1414,6 +1467,8 @@ bnxt_flow_validate(struct rte_eth_dev *dev, ret =bnxt_validate_and_parse_flow (dev, pattern, actions, attr, error, filter); +if (ret) + goto exit; vnic =find_matching_vnic (bp, filter);if (vnic) {
@@ -1434,6 +1489,7 @@ bnxt_flow_validate(struct rte_eth_dev *dev,else bnxt_hwrm_clear_l2_filter (bp, filter); +exit:/* No need to hold on to this filter if we are just validating flow */ filter->fw_l2_filter_id =UINT64_MAX ;bnxt_free_filter (bp, filter);
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH v2 16/20 net/bnxt: synchronize between flow related functions
In reply to Ajit KhapardeFrom: Venkat Duvvuru <[email protected]>
Currently, there are four flow related functions, namely bnxt_flow_create, bnxt_flow_destroy, bnxt_flow_validate, bnxt_flow_flush. All these functions are not multi-thread safe.
This patch fixes it by synchronizing these functions with a lock.
--- drivers/net/bnxt/bnxt.h | 6 +++++ drivers/net/bnxt/bnxt_ethdev.c | 23 ++++++++++++++++ drivers/net/bnxt/bnxt_flow.c | 49 +++++++++++++++++++++++++++------- 3 files changed, 69 insertions(+), 9 deletions(-)
drivers/net/bnxt/bnxt.h +6 -0
@@ -456,6 +456,7 @@ struct bnxt {uint32_t flow_flags;#define BNXT_FLOW_FLAG_L2_HDR_SRC_FILTER_EN BIT(0) +pthread_mutex_t flow_lock;unsigned int rx_nr_rings;unsigned int rx_cp_nr_rings;unsigned int rx_num_qs_per_vnic;
@@ -567,6 +568,11 @@ void bnxt_schedule_fw_health_check(struct bnxt *bp);bool is_bnxt_supported (struct rte_eth_dev *dev);bool bnxt_stratus_device (struct bnxt *bp);extern const struct rte_flow_ops bnxt_flow_ops; +#define bnxt_acquire_flow_lock (bp) \ + pthread_mutex_lock(&(bp)->flow_lock) + +#define bnxt_release_flow_lock (bp) \ + pthread_mutex_unlock(&(bp)->flow_lock)extern int bnxt_logtype_driver; #define PMD_DRV_LOG_RAW(level, fmt, args...) \
drivers/net/bnxt/bnxt_ethdev.c +23 -0
@@ -4476,6 +4476,17 @@ static int bnxt_init_fw(struct bnxt *bp)return 0 ; } +static int +bnxt_init_locks (struct bnxt *bp) +{ +int err; + + err =pthread_mutex_init (&bp->flow_lock,NULL ); +if (err) +PMD_DRV_LOG (ERR ,"Unable to initialize flow_lock\n" ); +return err; +} +static int bnxt_init_resources (struct bnxt *bp,bool reconfig_dev) {int rc;
@@ -4533,6 +4544,10 @@ static int bnxt_init_resources(struct bnxt *bp, bool reconfig_dev)if (rc)return rc; + rc =bnxt_init_locks (bp); +if (rc) +return rc; +return 0 ; }
@@ -4613,6 +4628,12 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)return rc; } +static void +bnxt_uninit_locks (struct bnxt *bp) +{ +pthread_mutex_destroy (&bp->flow_lock); +} +static int bnxt_uninit_resources (struct bnxt *bp,bool reconfig_dev) {
@@ -4674,6 +4695,8 @@ bnxt_dev_uninit(struct rte_eth_dev *eth_dev) eth_dev->rx_pkt_burst =NULL ; eth_dev->tx_pkt_burst =NULL ; +bnxt_uninit_locks (bp); +return rc; }
drivers/net/bnxt/bnxt_flow.c +40 -9
134 lines not on this page · raw message
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH v2 17/20 net/bnxt: drop untagged frames when specified
In reply to Ajit KhapardeWhen a drop action for L2 filters is specified, support it.
--- drivers/net/bnxt/bnxt_filter.h | 6 ++++ drivers/net/bnxt/bnxt_flow.c | 61 ++++++++++++++++++++++++++++++---- 2 files changed, 61 insertions(+), 6 deletions(-)
drivers/net/bnxt/bnxt_filter.h +6 -0
@@ -15,6 +15,8 @@ struct bnxt;#define BNXT_FLOW_L2_INNER_SRC_VALID_FLAG BIT(2)#define BNXT_FLOW_L2_DST_VALID_FLAG BIT(3)#define BNXT_FLOW_L2_INNER_DST_VALID_FLAG BIT(4) +#define BNXT_FLOW_L2_DROP_FLAG BIT(5) +#define BNXT_FLOW_PARSE_INNER_FLAG BIT(6)struct bnxt_filter_info {STAILQ_ENTRY (bnxt_filter_info) next;
@@ -148,4 +150,8 @@ struct bnxt_filter_info *bnxt_get_l2_filter(struct bnxt *bp, HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_MIRROR_VNIC_ID#define NTUPLE_FLTR_ALLOC_INPUT_EN_MIRROR_VNIC_ID \ HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_MIRROR_VNIC_ID +#define L2_FILTER_ALLOC_INPUT_EN_T_NUM_VLANS \ + HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_T_NUM_VLANS +#define L2_FILTER_ALLOC_INPUT_EN_NUM_VLANS \ + HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_NUM_VLANS#endif
drivers/net/bnxt/bnxt_flow.c +55 -6
109 lines not on this page · raw message
Signature · 1 line
2.20.1 (Apple Git-117)
Re: [dpdk-dev] [PATCH v2 17/20] net/bnxt: drop untagged frames when specified
Quoted 6 lines · Ajit Khaparde
When a drop action for L2 filters is specified, support it.
Signed-off-by Ajit Khaparde <[email protected]>Reviewed-by Rahul Gupta <[email protected]>Reviewed-by Somnath Kotur <[email protected]>Reviewed-by Kalesh Anakkur Purayil <[email protected]>
<...>
Quoted 17 lines
drivers/net/bnxt/bnxt_flow.c +7
-0@@ -1121,19 +1152,27 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,break ;case RTE_FLOW_ACTION_TYPE_DROP : vnic0 = &bp->vnic_info[0 ]; + filter->dst_id = vnic0->fw_vnic_id; + filter->valid_flags |=BNXT_FLOW_L2_DROP_FLAG ; filter1 =bnxt_get_l2_filter (bp, filter, vnic0);if (filter1 ==NULL ) { +rte_flow_error_set (error, +ENOSPC , +RTE_FLOW_ERROR_TYPE_ACTION , + act, +"Filter not available" ); rc = -ENOSPC ; goto ret; }
drivers/net/bnxt/bnxt_flow.c bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, · line 1175
Quoted 10 lines
drivers/net/bnxt/bnxt_flow.c +3
-2- filter->fw_l2_filter_id = filter1->fw_l2_filter_id;if (filter->filter_type ==HWRM_CFA_EM_FILTER ) filter->flags =HWRM_CFA_EM_FLOW_ALLOC_INPUT_FLAGS_DROP ; -else +else if (filter->filter_type ==HWRM_CFA_NTUPLE_FILTER ) filter->flags =HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_FLAGS_DROP ; + +bnxt_update_filter_flags_en (filter, filter1);
This function gets three parameter [1], you are breaking the build here and fixing it later in the patches, I will fix this while merging. But please test patch by patch build next time.
[1]bnxt_update_filter_flags_en(filter, filter1, use_ntuple);
PATCH v2 18/20 net/bnxt: fix VLAN filtering code path
In reply to Ajit KhapardeFrom: Venkat Duvvuru <[email protected]>
Currently, when hw-vlan-filter is enabled on testpmd, driver is receiving all vlan packets. Instead, it should only receive untagged packets and vlan packets for which the VLAN filter is programmed. This is because, the default rule to match on MAC is not getting deleted, when hw-vlan-filter is ON.
This patch fixes the problem, by deleting the default MAC rule and programming a new rule to receive only untagged packets, when hw-vlan-filter is enabled & another rule for each vlan, as and when that vlan is configured on that port.
--- drivers/net/bnxt/bnxt_ethdev.c | 153 ++++++++++++++++++++++++++------- drivers/net/bnxt/bnxt_filter.h | 1 + drivers/net/bnxt/bnxt_hwrm.c | 9 +- 3 files changed, 128 insertions(+), 35 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +121 -32
@@ -1001,6 +1001,53 @@ static void bnxt_mac_addr_remove_op(struct rte_eth_dev *eth_dev, } } +static int bnxt_add_mac_filter (struct bnxt *bp,struct bnxt_vnic_info *vnic, +struct rte_ether_addr *mac_addr,uint32_t index) +{ +struct bnxt_filter_info *filter; +int rc =0 ; + + filter =STAILQ_FIRST (&vnic->filter); +/* During bnxt_mac_addr_add_op, default MAC is +* already programmed, so skip it. But, when +* hw-vlan-filter is turned OFF from ON, default +* MAC filter should be restored +*/ +if (filter->dflt) +return 0 ; + + filter =bnxt_alloc_filter (bp); +if (!filter) { +PMD_DRV_LOG (ERR ,"L2 filter alloc failed\n" ); +return -ENODEV ; + } + + filter->mac_index = index; +/* bnxt_alloc_filter copies default MAC to filter->l2_addr. So, +* if the MAC that's been programmed now is a different one, then, +* copy that addr to filter->l2_addr +*/ +if (mac_addr) +memcpy (filter->l2_addr, mac_addr,RTE_ETHER_ADDR_LEN ); + filter->flags |=HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_OUTERMOST ; + + rc =bnxt_hwrm_set_l2_filter (bp, vnic->fw_vnic_id, filter); +if (!rc) { +if (filter->mac_index ==0 ) { + filter->dflt = true; +STAILQ_INSERT_HEAD (&vnic->filter, filter, next); + }else { +STAILQ_INSERT_TAIL (&vnic->filter, filter, next); + } + }else { + filter->mac_index =INVALID_MAC_INDEX ; +memset (&filter->l2_addr,0 ,RTE_ETHER_ADDR_LEN ); +bnxt_free_filter (bp, filter); + } + +return rc; +} +static int bnxt_mac_addr_add_op (struct rte_eth_dev *eth_dev,struct rte_ether_addr *mac_addr,uint32_t index,uint32_t pool)
@@ -1031,24 +1078,8 @@ static int bnxt_mac_addr_add_op(struct rte_eth_dev *eth_dev,return 0 ; } } - filter =bnxt_alloc_filter (bp); -if (!filter) { -PMD_DRV_LOG (ERR ,"L2 filter alloc failed\n" ); -return -ENODEV ; - } - filter->mac_index = index; -memcpy (filter->l2_addr, mac_addr,RTE_ETHER_ADDR_LEN ); - filter->flags |=HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_OUTERMOST ; - - rc =bnxt_hwrm_set_l2_filter (bp, vnic->fw_vnic_id, filter); -if (!rc) { -STAILQ_INSERT_TAIL (&vnic->filter, filter, next); - }else { - filter->mac_index =INVALID_MAC_INDEX ; -memset (&filter->l2_addr,0 ,RTE_ETHER_ADDR_LEN ); -bnxt_free_filter (bp, filter); - } + rc =bnxt_add_mac_filter (bp, vnic, mac_addr, index);return rc; }
@@ -1683,9 +1714,10 @@ static int bnxt_del_vlan_filter(struct bnxt *bp, uint16_t vlan_id) filter =STAILQ_FIRST (&vnic->filter);while (filter) {/* Search for this matching MAC+VLAN filter */ -if (filter->enables & chk && filter->l2_ivlan == vlan_id && - !memcmp (filter->l2_addr, - bp->mac_addr, +if ((filter->enables & chk) && + (filter->l2_ivlan == vlan_id && + filter->l2_ivlan_mask !=0 ) && + !memcmp (filter->l2_addr, bp->mac_addr,RTE_ETHER_ADDR_LEN )) {/* Delete the filter */ rc =bnxt_hwrm_clear_l2_filter (bp, filter);
@@ -1726,8 +1758,11 @@ static int bnxt_add_vlan_filter(struct bnxt *bp, uint16_t vlan_id) filter =STAILQ_FIRST (&vnic->filter);/* Check if the VLAN has already been added */ while (filter) { -if (filter->enables & chk && filter->l2_ivlan == vlan_id && - !memcmp (filter->l2_addr, bp->mac_addr,RTE_ETHER_ADDR_LEN )) +if ((filter->enables & chk) && + (filter->l2_ivlan == vlan_id && + filter->l2_ivlan_mask ==0x0FFF ) && + !memcmp (filter->l2_addr, bp->mac_addr, +RTE_ETHER_ADDR_LEN ))return -EEXIST ; filter =STAILQ_NEXT (filter, next);
@@ -1743,10 +1778,17 @@ static int bnxt_add_vlan_filter(struct bnxt *bp, uint16_t vlan_id)return -ENOMEM ; }/* MAC + VLAN ID filter */ +/* If l2_ivlan == 0 and l2_ivlan_mask != 0, only +* untagged packets are received +* +* If l2_ivlan != 0 and l2_ivlan_mask != 0, untagged +* packets and only the programmed vlan's packets are received +*/ filter->l2_ivlan = vlan_id; filter->l2_ivlan_mask =0x0FFF ; filter->enables |= en; filter->flags |=HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_OUTERMOST ; + rc =bnxt_hwrm_set_l2_filter (bp, vnic->fw_vnic_id, filter);if (rc) {/* Free the newly allocated filter as we were
@@ -1755,10 +1797,16 @@ static int bnxt_add_vlan_filter(struct bnxt *bp, uint16_t vlan_id) filter->fw_l2_filter_id =UINT64_MAX ;STAILQ_INSERT_TAIL (&bp->free_filter_list, filter, next);return rc; + }else { +/* Add this new filter to the list */ +if (vlan_id ==0 ) { + filter->dflt = true; +STAILQ_INSERT_HEAD (&vnic->filter, filter, next); + }else { +STAILQ_INSERT_TAIL (&vnic->filter, filter, next); + } } -/* Add this new filter to the list */ -STAILQ_INSERT_TAIL (&vnic->filter, filter, next);PMD_DRV_LOG (INFO ,"Added Vlan filter for %d\n" , vlan_id);return rc;
@@ -1781,11 +1829,39 @@ static int bnxt_vlan_filter_set_op(struct rte_eth_dev *eth_dev,return bnxt_del_vlan_filter (bp, vlan_id); } +static int bnxt_del_dflt_mac_filter (struct bnxt *bp, +struct bnxt_vnic_info *vnic) +{ +struct bnxt_filter_info *filter; +int rc; + + filter =STAILQ_FIRST (&vnic->filter); +while (filter) { +if (filter->dflt && + !memcmp (filter->l2_addr, bp->mac_addr, +RTE_ETHER_ADDR_LEN )) { + rc =bnxt_hwrm_clear_l2_filter (bp, filter); +if (rc) +return rc; + filter->dflt = false; +STAILQ_REMOVE (&vnic->filter, filter, + bnxt_filter_info, next); +STAILQ_INSERT_TAIL (&bp->free_filter_list, + filter, next); + filter->fw_l2_filter_id =-1 ; +break ; + } + filter =STAILQ_NEXT (filter, next); + } +return 0 ; +} +static int bnxt_vlan_offload_set_op (struct rte_eth_dev *dev,int mask) {struct bnxt *bp = dev->data->dev_private;uint64_t rx_offloads = dev->data->dev_conf.rxmode.offloads; +struct bnxt_vnic_info *vnic;unsigned int i;int rc;
@@ -1793,15 +1869,28 @@ bnxt_vlan_offload_set_op(struct rte_eth_dev *dev, int mask)if (rc)return rc; -if (mask Ð_VLAN_FILTER_MASK ) { -if (!(rx_offloads &DEV_RX_OFFLOAD_VLAN_FILTER )) { -/* Remove any VLAN filters programmed */ -for (i =0 ; i <4095 ; i++) -bnxt_del_vlan_filter (bp, i); - } -PMD_DRV_LOG (DEBUG ,"VLAN Filtering: %d\n" , - !!(rx_offloads &DEV_RX_OFFLOAD_VLAN_FILTER )); + vnic =BNXT_GET_DEFAULT_VNIC (bp); +if (!(rx_offloads &DEV_RX_OFFLOAD_VLAN_FILTER )) { +/* Remove any VLAN filters programmed */ +for (i =0 ; i <4095 ; i++) +bnxt_del_vlan_filter (bp, i); + + rc =bnxt_add_mac_filter (bp, vnic,NULL ,0 ); +if (rc) +return rc; + }else { +/* Default filter will allow packets that match the +* dest mac. So, it has to be deleted, otherwise, we +* will endup receiving vlan packets for which the +* filter is not programmed, when hw-vlan-filter +* configuration is ON +*/ +bnxt_del_dflt_mac_filter (bp, vnic); +/* This filter will allow only untagged packets */ +bnxt_add_vlan_filter (bp,0 ); } +PMD_DRV_LOG (DEBUG ,"VLAN Filtering: %d\n" , + !!(rx_offloads &DEV_RX_OFFLOAD_VLAN_FILTER ));if (mask Ð_VLAN_STRIP_MASK ) {/* Enable or disable VLAN stripping */
drivers/net/bnxt/bnxt_filter.h +1 -0
@@ -71,6 +71,7 @@ struct bnxt_filter_info {uint16_t ip_addr_type;uint16_t ethertype;uint32_t priority; +uint8_t dflt; };struct bnxt_filter_info *bnxt_alloc_filter (struct bnxt *bp);
drivers/net/bnxt/bnxt_hwrm.c +6 -3
@@ -2415,15 +2415,18 @@ int bnxt_set_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic)int rc =0 ; STAILQ_FOREACH(filter, &vnic->filter, next) { -if (filter->filter_type ==HWRM_CFA_EM_FILTER ) +if (filter->filter_type ==HWRM_CFA_EM_FILTER ) { rc =bnxt_hwrm_set_em_filter (bp, filter->dst_id, filter); -else if (filter->filter_type ==HWRM_CFA_NTUPLE_FILTER ) + }else if (filter->filter_type ==HWRM_CFA_NTUPLE_FILTER ) { rc =bnxt_hwrm_set_ntuple_filter (bp, filter->dst_id, filter); -else + }else { rc =bnxt_hwrm_set_l2_filter (bp, vnic->fw_vnic_id, filter); +if (!rc) + filter->dflt =1 ; + }if (rc)break ; }
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH v2 19/20 net/bnxt: fix multicast filter programming
In reply to Ajit KhapardeFrom: Kalesh AP <[email protected]>
Fixed multicast filter programming and allmulti programming. Fixed to skip programming multicast macs if the user requests allmulti mode.
Also removed a comment in bnxt_hwrm_cfa_l2_set_rx_mask() which is no longer valid now.
--- drivers/net/bnxt/bnxt_ethdev.c | 4 ++++ drivers/net/bnxt/bnxt_hwrm.c | 11 ++++------- 2 files changed, 8 insertions(+), 7 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +4 -0
@@ -2053,6 +2053,10 @@ bnxt_dev_set_mc_addr_list_op(struct rte_eth_dev *eth_dev, } vnic->mc_addr_cnt = i; +if (vnic->mc_addr_cnt) + vnic->flags |=BNXT_VNIC_INFO_MCAST ; +else + vnic->flags &= ~BNXT_VNIC_INFO_MCAST ; allmulti:return bnxt_hwrm_cfa_l2_set_rx_mask (bp, vnic,0 ,NULL );
drivers/net/bnxt/bnxt_hwrm.c +4 -7
@@ -295,20 +295,17 @@ int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt *bp,HWRM_PREP (req,CFA_L2_SET_RX_MASK ,BNXT_USE_CHIMP_MB ); req.vnic_id =rte_cpu_to_le_16 (vnic->fw_vnic_id); -/* FIXME add multicast flag, when multicast adding options is supported -* by ethtool. -*/ if (vnic->flags &BNXT_VNIC_INFO_BCAST ) mask |=HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_BCAST ;if (vnic->flags &BNXT_VNIC_INFO_UNTAGGED ) mask |=HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_VLAN_NONVLAN ; +if (vnic->flags &BNXT_VNIC_INFO_PROMISC ) mask |=HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_PROMISCUOUS ; -if (vnic->flags &BNXT_VNIC_INFO_ALLMULTI ) + +if (vnic->flags &BNXT_VNIC_INFO_ALLMULTI ) { mask |=HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ALL_MCAST ; -if (vnic->flags &BNXT_VNIC_INFO_MCAST ) - mask |=HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_MCAST ; -if (vnic->mc_addr_cnt) { + }else if (vnic->flags &BNXT_VNIC_INFO_MCAST ) { mask |=HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_MCAST ; req.num_mc_entries =rte_cpu_to_le_32 (vnic->mc_addr_cnt); req.mc_tbl_addr =rte_cpu_to_le_64 (vnic->mc_list_dma_addr);
Signature · 1 line
2.20.1 (Apple Git-117)
PATCH v2 20/20 net/bnxt: handle flow flush handling
In reply to Ajit KhapardeWe are not freeing all the flows when a flow_flush is called. Iterate through all the flows belonging to all the VNICs in use and free the filters.
--- drivers/net/bnxt/bnxt_flow.c | 63 ++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 31 deletions(-)
drivers/net/bnxt/bnxt_flow.c +32 -31
@@ -1161,7 +1161,7 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,RTE_FLOW_ERROR_TYPE_ACTION , act, "Filter not available"); - rc = -ENOSPC ; + rc = -rte_errno; goto ret; }
@@ -1172,7 +1172,7 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, filter->flags =HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_FLAGS_DROP ; -bnxt_update_filter_flags_en (filter, filter1); +bnxt_update_filter_flags_en (filter, filter1, use_ntuple);break ;case RTE_FLOW_ACTION_TYPE_COUNT : vnic0 = &bp->vnic_info[0 ];
@@ -1251,7 +1251,7 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,RTE_FLOW_ERROR_TYPE_ACTION , act, "New filter not available"); - rc = -ENOSPC ; + rc = -rte_errno; goto ret; }
@@ -1415,7 +1415,7 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,RTE_FLOW_ERROR_TYPE_ACTION , act, "New filter not available"); - rc = -ENOSPC ; + rc = -rte_errno; goto ret; }
@@ -1520,7 +1520,6 @@ bnxt_flow_validate(struct rte_eth_dev *dev,bnxt_hwrm_vnic_ctx_free (bp, vnic);bnxt_hwrm_vnic_free (bp, vnic); vnic->rx_queue_cnt =0 ; - bp->nr_vnics--;PMD_DRV_LOG (DEBUG ,"Free VNIC\n" ); } }
@@ -1753,36 +1752,20 @@ bnxt_flow_create(struct rte_eth_dev *dev, vnic =find_matching_vnic (bp, filter); done:if (!ret || update_flow) { - flow->filter = filter; - flow->vnic = vnic; -/* VNIC is set only in case of queue or RSS action */ -if (vnic) { -/* -* RxQ0 is not used for flow filters. -*/ - -if (update_flow) { - ret = -EXDEV ; - goto free_flow; - } -STAILQ_INSERT_TAIL (&vnic->filter, filter, next); - } -PMD_DRV_LOG (ERR ,"Successfully created flow.\n" ); -STAILQ_INSERT_TAIL (&vnic->flow_list, flow, next); -bnxt_release_flow_lock (bp); -return flow; - } -if (!ret) { flow->filter = filter; flow->vnic = vnic;if (update_flow) { ret = -EXDEV ; goto free_flow; } + +STAILQ_INSERT_TAIL (&vnic->filter, filter, next);PMD_DRV_LOG (ERR ,"Successfully created flow.\n" );STAILQ_INSERT_TAIL (&vnic->flow_list, flow, next); +bnxt_release_flow_lock (bp);return flow; } + free_filter:bnxt_free_filter (bp, filter); free_flow:
@@ -1925,7 +1908,6 @@ bnxt_flow_destroy(struct rte_eth_dev *dev,bnxt_hwrm_vnic_free (bp, vnic); vnic->rx_queue_cnt =0 ; - bp->nr_vnics--; } }else { rte_flow_error_set(error, -ret,
@@ -1941,6 +1923,7 @@ static int bnxt_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error) { struct bnxt *bp = dev->data->dev_private; +struct bnxt_filter_info *filter =NULL ;struct bnxt_vnic_info *vnic;struct rte_flow *flow;unsigned int i;
@@ -1949,11 +1932,12 @@ bnxt_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)bnxt_acquire_flow_lock (bp);for (i =0 ; i < bp->max_vnics; i++) { vnic = &bp->vnic_info[i]; -if (vnic->fw_vnic_id ==INVALID_VNIC_ID ) +if (vnic && vnic->fw_vnic_id ==INVALID_VNIC_ID )continue ; - STAILQ_FOREACH(flow, &vnic->flow_list, next) { -struct bnxt_filter_info *filter = flow->filter; +while (!STAILQ_EMPTY (&vnic->flow_list)) { + flow =STAILQ_FIRST (&vnic->flow_list); + filter = flow->filter; if (filter->filter_type == HWRM_CFA_TUNNEL_REDIRECT_FILTER &&
@@ -1974,7 +1958,7 @@ bnxt_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error) ret =bnxt_hwrm_clear_em_filter (bp, filter);if (filter->filter_type ==HWRM_CFA_NTUPLE_FILTER ) ret =bnxt_hwrm_clear_ntuple_filter (bp, filter); -else if (!i) +else if (i) ret =bnxt_hwrm_clear_l2_filter (bp, filter);if (ret) {
@@ -1988,10 +1972,27 @@ bnxt_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)return -rte_errno; } done: -bnxt_free_filter (bp, filter);STAILQ_REMOVE (&vnic->flow_list, flow, rte_flow, next); + +STAILQ_REMOVE (&vnic->filter, + filter, + bnxt_filter_info, + next); +bnxt_free_filter (bp, filter); +rte_free (flow); + +/* If this was the last flow associated with this vnic, +* switch the queue back to RSS pool. +*/ +if (STAILQ_EMPTY (&vnic->flow_list)) { +rte_free (vnic->fw_grp_ids); +if (vnic->rx_queue_cnt >1 ) +bnxt_hwrm_vnic_ctx_free (bp, vnic); +bnxt_hwrm_vnic_free (bp, vnic); + vnic->rx_queue_cnt =0 ; + } } }
Signature · 1 line
2.20.1 (Apple Git-117)
Re: [dpdk-dev] [PATCH v2 20/20] net/bnxt: handle flow flush handling
Quoted 3 lines · Ajit Khaparde
We are not freeing all the flows when a
flow_flushis called. Iterate through all the flows belonging to all the VNICs in use and free the filters.
For the patch title "handle flow flush handling", I think here 'handle' means fixing the "flow flush handling", I am updating that way. Can you please send the fixes tag for it, I can update later in the next-net?
Same question for other patches in this patchset that start with "handle xxx", is that handle means fix something? If so can you please send commit log updates for them too?
Thanks.
Quoted 5 lines
Reviewed-by Rahul Gupta <[email protected]>Reviewed-by Venkat Duvvuru <[email protected]>Reviewed-by Kalesh Anakkur Purayil <[email protected]>Signed-off-by Ajit Khaparde <[email protected]>
Quoted 33 lines · Ajit Khaparde
Among other changes, this patchset adds support to:
- create filters with RSS action.
- create source MAC filters.
- use user provided priority to place rule appropriately in HW.This patch has been rebased to dpdk-next-net commit
8587a8b9eddefa39e4ceac7e9385efcc5e73307cPlease apply.
Ajit Khaparde (13):
net/bnxt: return standard error codes for HWRM command net/bnxt: refactor code to allow dynamic creation of VNIC net/bnxt: allow flow creation when RSS is enabled net/bnxt: add support to create SMAC and inner DMAC filters net/bnxt: add support for RSS action
net/bnxt: parse priority attribute for flow creation net/bnxt: delete and flush L2 filters cleanly net/bnxt: cleanup vnic after flow validate net/bnxt: allow only unicast MAC address filter creation net/bnxt: check device is started before flow creation net/bnxt: handle cleanup if flow creation fails net/bnxt: drop untagged frames when specified net/bnxt: handle flow flush handlingKalesh AP (2):
net/bnxt: fix an issue in setting default MAC address net/bnxt: fix multicast filter programmingRahul Gupta (1):
net/bnxt: properly handle ring cleanup in case of error
Quoted 7 lines
Somnath Kotur (1):
net/bnxt: check for invalid VNIC ID in vnic tpa cfgVenkat Duvvuru (3):
net/bnxt: validate RSS hash key length net/bnxt: synchronize between flow related functions net/bnxt: fix VLAN filtering code path
32-bit build error [1] fixed while merging, please confirm the fix in the repo.
[1]
In file included from .../drivers/net/bnxt/bnxt_flow.c:14:.../drivers/net/bnxt/bnxt_flow.c: In function ‘bnxt_update_filter_flags_en’:.../drivers/net/bnxt/bnxt.h:579:50: error: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 6 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
579 | rte_log(RTE_LOG_ ## level, bnxt_logtype_driver, "%s(): " fmt, \
| ^~~~~~~~.../drivers/net/bnxt/bnxt.h:583:2: note: in expansion of macro ‘PMD_DRV_LOG_RAW’
583 | PMD_DRV_LOG_RAW(level, fmt, ## args)
| ^~~~~~~~~~~~~~~
.../drivers/net/bnxt/bnxt_flow.c:997:2: note: in expansion of macro ‘PMD_DRV_LOG’
997 | PMD_DRV_LOG(DEBUG, "l2_filter: %p fw_l2_filter_id %lx l2_ref_cnt %d\n",
| ^~~~~~~~~~~
.../drivers/net/bnxt/bnxt_flow.c:997:54: note: format string is defined here
997 | PMD_DRV_LOG(DEBUG, "l2_filter: %p fw_l2_filter_id %lx l2_ref_cnt %d\n",
| ~~^
| |
| long unsigned int
| %llxQuoted 33 lines · Ajit Khaparde
Among other changes, this patchset adds support to:
- create filters with RSS action.
- create source MAC filters.
- use user provided priority to place rule appropriately in HW.This patch has been rebased to dpdk-next-net commit
8587a8b9eddefa39e4ceac7e9385efcc5e73307cPlease apply.
Ajit Khaparde (13):
net/bnxt: return standard error codes for HWRM command net/bnxt: refactor code to allow dynamic creation of VNIC net/bnxt: allow flow creation when RSS is enabled net/bnxt: add support to create SMAC and inner DMAC filters net/bnxt: add support for RSS action
net/bnxt: parse priority attribute for flow creation net/bnxt: delete and flush L2 filters cleanly net/bnxt: cleanup vnic after flow validate net/bnxt: allow only unicast MAC address filter creation net/bnxt: check device is started before flow creation net/bnxt: handle cleanup if flow creation fails net/bnxt: drop untagged frames when specified net/bnxt: handle flow flush handlingKalesh AP (2):
net/bnxt: fix an issue in setting default MAC address net/bnxt: fix multicast filter programmingRahul Gupta (1):
net/bnxt: properly handle ring cleanup in case of error
Quoted 7 lines
Somnath Kotur (1):
net/bnxt: check for invalid VNIC ID in vnic tpa cfgVenkat Duvvuru (3):
net/bnxt: validate RSS hash key length net/bnxt: synchronize between flow related functions net/bnxt: fix VLAN filtering code path
Series applied to dpdk-next-net/master, thanks.