bnxt atchset
cover bnxt atchset
Please apply these patches.
Ajit Khaparde (10):
net/bnxt: check return values in bnxt_dev_init net/bnxt: fix double increment of idx during Tx ring alloc net/bnxt: parse checksum offload flags
net/bnxt: fix grp_info usage
net/bnxt: return proper error code
net/bnxt: add check for multi host PF per port. net/bnxt: check if initialization is done before accessing stats net/bnxt: fix check for ether_type
net/bnxt: check on-chip resources
Somnath Kotur (3):
net/bnxt: fix duplicate filter pattern creation error net/bnxt: remove unnecessary addition of a temporary filter net/bnxt: fix bug with duplicate pattern for 5tuple filter bnxt/bnxt: free the aggregration ring while freeing all the HWRM rings
drivers/net/bnxt/bnxt.h | 7 ++- drivers/net/bnxt/bnxt_cpr.c | 1 - drivers/net/bnxt/bnxt_ethdev.c | 97 +++++++++++++++++++++++++++++++++--------- drivers/net/bnxt/bnxt_filter.c | 49 ++++++++++++++++++--- drivers/net/bnxt/bnxt_hwrm.c | 32 ++++++++------ drivers/net/bnxt/bnxt_ring.c | 7 ++- drivers/net/bnxt/bnxt_ring.h | 2 +- drivers/net/bnxt/bnxt_rxq.c | 7 +++ drivers/net/bnxt/bnxt_stats.c | 13 +++++- drivers/net/bnxt/bnxt_txq.c | 7 +++ drivers/net/bnxt/bnxt_txr.c | 15 ++++--- 11 files changed, 182 insertions(+), 55 deletions(-)
Signature · 1 line
2.14.3 (Apple Git-98)
PATCH 1/13 net/bnxt: check return values in bnxt_dev_init
We are not checking for return values of functions like bnxt_hwrm_queue_qportcfg and bnxt_hwrm_func_qcfg in bnxt_dev_init thereby preventing a cleanup in case of a HWRM command failure. This patch fixes that.
--- drivers/net/bnxt/bnxt_ethdev.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +10 -2
@@ -3172,9 +3172,17 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev) rc =bnxt_hwrm_ver_get (bp);if (rc) goto error_free; -bnxt_hwrm_queue_qportcfg (bp); + rc =bnxt_hwrm_queue_qportcfg (bp); +if (rc) { +RTE_LOG (ERR ,PMD ,"hwrm queue qportcfg failed\n" ); + goto error_free; + } -bnxt_hwrm_func_qcfg (bp); + rc =bnxt_hwrm_func_qcfg (bp); +if (rc) { +RTE_LOG (ERR ,PMD ,"hwrm func qcfg failed\n" ); + goto error_free; + }/* Get the MAX capabilities for this function */ rc =bnxt_hwrm_func_qcaps (bp);
Signature · 1 line
2.14.3 (Apple Git-98)
Re: [PATCH 01/13] net/bnxt: check return values in bnxt_dev_init
drivers/net/bnxt/bnxt_ethdev.c bnxt_dev_init(struct rte_eth_dev *eth_dev) · line 3179
Quoted 5 lines · On Mon, 8 Jan 2018 12:24:25 -0800 Ajit Khaparde <[email protected]>…
drivers/net/bnxt/bnxt_ethdev.c +5
-0+ rc =bnxt_hwrm_queue_qportcfg (bp); +if (rc) { +RTE_LOG (ERR ,PMD ,"hwrm queue qportcfg failed\n" ); + goto error_free; + }
I noticed that this driver is still using RTE_LOG directly. The current desired behaviour is for each driver to define its own dynamic log type (see i40e for an example).
PATCH 2/13 net/bnxt: fix double increment of idx during Tx ring alloc
In reply to Ajit KhapardeWe are incrementing idx twice while allocating Tx rings. Since this is passed to the firmware, it may cause unexpected behavior.
--- drivers/net/bnxt/bnxt_ring.c | 3 --- 1 file changed, 3 deletions(-)
drivers/net/bnxt/bnxt_ring.c +0 -3
@@ -362,9 +362,6 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)struct bnxt_ring *ring = txr->tx_ring_struct;unsigned int idx = i +1 + bp->rx_cp_nr_rings; -/* Account for AGG Rings. AGG ring cnt = Rx Cmpl ring cnt */ - idx += bp->rx_cp_nr_rings; -/* Tx cmpl */ rc = bnxt_hwrm_ring_alloc(bp, cp_ring, HWRM_RING_ALLOC_INPUT_RING_TYPE_L2_CMPL,
Signature · 1 line
2.14.3 (Apple Git-98)
PATCH 3/13 net/bnxt: parse checksum offload flags
In reply to Ajit KhapardeParse the Tx checksum offload flags and set the proper bits in the Tx descriptor.
--- drivers/net/bnxt/bnxt_txr.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/net/bnxt/bnxt_txr.c +10 -5
@@ -217,23 +217,28 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt, tx_pkt->outer_l3_len; txbd1->mss = tx_pkt->tso_segsz; - }else if (tx_pkt->ol_flags &PKT_TX_OIP_IIP_TCP_UDP_CKSUM ) { + }else if ((tx_pkt->ol_flags &PKT_TX_OIP_IIP_TCP_UDP_CKSUM ) == +PKT_TX_OIP_IIP_TCP_UDP_CKSUM ) {/* Outer IP, Inner IP, Inner TCP/UDP CSO */ txbd1->lflags |=TX_BD_FLG_TIP_IP_TCP_UDP_CHKSUM ; txbd1->mss =0 ; - }else if (tx_pkt->ol_flags &PKT_TX_IIP_TCP_UDP_CKSUM ) { + }else if ((tx_pkt->ol_flags &PKT_TX_IIP_TCP_UDP_CKSUM ) == +PKT_TX_IIP_TCP_UDP_CKSUM ) {/* (Inner) IP, (Inner) TCP/UDP CSO */ txbd1->lflags |=TX_BD_FLG_IP_TCP_UDP_CHKSUM ; txbd1->mss =0 ; - }else if (tx_pkt->ol_flags &PKT_TX_OIP_TCP_UDP_CKSUM ) { + }else if ((tx_pkt->ol_flags &PKT_TX_OIP_TCP_UDP_CKSUM ) == +PKT_TX_OIP_TCP_UDP_CKSUM ) {/* Outer IP, (Inner) TCP/UDP CSO */ txbd1->lflags |=TX_BD_FLG_TIP_TCP_UDP_CHKSUM ; txbd1->mss =0 ; - }else if (tx_pkt->ol_flags &PKT_TX_OIP_IIP_CKSUM ) { + }else if ((tx_pkt->ol_flags &PKT_TX_OIP_IIP_CKSUM ) == +PKT_TX_OIP_IIP_CKSUM ) {/* Outer IP, Inner IP CSO */ txbd1->lflags |=TX_BD_FLG_TIP_IP_CHKSUM ; txbd1->mss =0 ; - }else if (tx_pkt->ol_flags &PKT_TX_TCP_UDP_CKSUM ) { + }else if ((tx_pkt->ol_flags &PKT_TX_TCP_UDP_CKSUM ) == +PKT_TX_TCP_UDP_CKSUM ) {/* TCP/UDP CSO */ txbd1->lflags |=TX_BD_LONG_LFLAGS_TCP_UDP_CHKSUM ; txbd1->mss =0 ;
Signature · 1 line
2.14.3 (Apple Git-98)
PATCH 4/13 net/bnxt: fix grp_info usage
In reply to Ajit KhapardeRing groups is a Rx only attribute. Make sure there are sufficient ring groups available. Return an error if they are not available.
--- drivers/net/bnxt/bnxt_cpr.c | 1 - drivers/net/bnxt/bnxt_ethdev.c | 15 +++++++++++++-- drivers/net/bnxt/bnxt_hwrm.c | 14 ++++---------- drivers/net/bnxt/bnxt_ring.c | 4 +++- drivers/net/bnxt/bnxt_ring.h | 2 +- 5 files changed, 21 insertions(+), 15 deletions(-)
drivers/net/bnxt/bnxt_cpr.c +0 -1
@@ -165,7 +165,6 @@ int bnxt_alloc_def_cp_ring(struct bnxt *bp) goto err_out; cpr->cp_doorbell = bp->pdev->mem_resource[2 ].addr;B_CP_DIS_DB (cpr, cpr->cp_raw_cons); - bp->grp_info[0 ].cp_fw_ring_id = cp_ring->fw_ring_id;if (BNXT_PF (bp)) rc =bnxt_hwrm_func_cfg_def_cp (bp);else
drivers/net/bnxt/bnxt_ethdev.c +13 -2
@@ -393,7 +393,10 @@ static int bnxt_init_nic(struct bnxt *bp) {int rc; -bnxt_init_ring_grps (bp); + rc =bnxt_init_ring_grps (bp); +if (rc) +return rc; +bnxt_init_vnics (bp);bnxt_init_filters (bp);
@@ -3207,11 +3210,19 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)/* Copy the permanent MAC from the qcap response address now. */ memcpy (bp->mac_addr, bp->dflt_mac_addr,sizeof (bp->mac_addr));memcpy (ð_dev->data->mac_addrs[0 ], bp->mac_addr,ETHER_ADDR_LEN ); + +if (bp->max_ring_grps < bp->rx_cp_nr_rings) { +/* 1 ring is for default completion ring */ +RTE_LOG (ERR ,PMD ,"Insufficient resource: Ring Group\n" ); + rc = -ENOSPC ; + goto error_free; + } + bp->grp_info =rte_zmalloc ("bnxt_grp_info" ,sizeof (*bp->grp_info) * bp->max_ring_grps,0 );if (!bp->grp_info) {RTE_LOG (ERR ,PMD , -"Failed to alloc %zu bytes needed to store group info table\n" , +"Failed to alloc %zu bytes to store group info table\n" ,sizeof (*bp->grp_info) * bp->max_ring_grps); rc = -ENOMEM ; goto error_free;
drivers/net/bnxt/bnxt_hwrm.c +4 -10
@@ -1138,7 +1138,6 @@ int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, cpr->hw_stats_ctx_id =rte_le_to_cpu_16 (resp->stat_ctx_id);HWRM_UNLOCK (); - bp->grp_info[idx].fw_stats_ctx = cpr->hw_stats_ctx_id;return rc; }
@@ -1661,19 +1660,15 @@ int bnxt_free_all_hwrm_stat_ctxs(struct bnxt *bp)for (i =0 ; i < bp->rx_cp_nr_rings + bp->tx_cp_nr_rings; i++) { -if (i >= bp->rx_cp_nr_rings) +if (i >= bp->rx_cp_nr_rings) { cpr = bp->tx_queues[i - bp->rx_cp_nr_rings]->cp_ring; -else + }else { cpr = bp->rx_queues[i]->cp_ring; + bp->grp_info[i].fw_stats_ctx =-1 ; + }if (cpr->hw_stats_ctx_id !=HWRM_NA_SIGNATURE ) { rc =bnxt_hwrm_stat_ctx_free (bp, cpr, i); cpr->hw_stats_ctx_id =HWRM_NA_SIGNATURE ; -/* -* TODO. Need a better way to reset grp_info.stats_ctx -* for Rx rings only. stats_ctx is not saved for Tx -* in grp_info. -*/ - bp->grp_info[i].fw_stats_ctx = cpr->hw_stats_ctx_id;if (rc)return rc; }
@@ -1733,7 +1728,6 @@ static void bnxt_free_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,bnxt_hwrm_ring_free (bp, cp_ring,HWRM_RING_FREE_INPUT_RING_TYPE_L2_CMPL ); cp_ring->fw_ring_id =INVALID_HW_RING_ID ; - bp->grp_info[idx].cp_fw_ring_id =INVALID_HW_RING_ID ;memset (cpr->cp_desc_ring,0 , cpr->cp_ring_struct->ring_size *sizeof (*cpr->cp_desc_ring)); cpr->cp_raw_cons =0 ;
drivers/net/bnxt/bnxt_ring.c +3 -1
@@ -63,13 +63,15 @@ void bnxt_free_ring(struct bnxt_ring *ring)* Ring groups */ -void bnxt_init_ring_grps (struct bnxt *bp) +int bnxt_init_ring_grps (struct bnxt *bp) {unsigned int i;for (i =0 ; i < bp->max_ring_grps; i++)memset (&bp->grp_info[i], (uint8_t )HWRM_NA_SIGNATURE ,sizeof (struct bnxt_ring_grp_info )); + +return 0 ; }/*
drivers/net/bnxt/bnxt_ring.h +1 -1
@@ -94,7 +94,7 @@ struct bnxt_tx_ring_info;struct bnxt_rx_ring_info ;struct bnxt_cp_ring_info ;void bnxt_free_ring (struct bnxt_ring *ring); -void bnxt_init_ring_grps (struct bnxt *bp); +int bnxt_init_ring_grps (struct bnxt *bp); int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx, struct bnxt_tx_ring_info *tx_ring_info, struct bnxt_rx_ring_info *rx_ring_info,
Signature · 1 line
2.14.3 (Apple Git-98)
PATCH 5/13 net/bnxt: return proper error code
In reply to Ajit KhapardeIf the FW fails bnxt_hwrm_func_reset() with an error status, instead of returning -1, return a more standard value of -EIO. Similarly sometimes the status returned by certain FW commands may not be generic. Return a more standard value of -EIO in that case as well.
--- drivers/net/bnxt/bnxt_ethdev.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/bnxt/bnxt_ethdev.c +5 -1
@@ -378,6 +378,10 @@ static int bnxt_init_chip(struct bnxt *bp) err_out:bnxt_free_all_hwrm_resources (bp); +/* Some of the error status returned by FW may not be from errno.h */ +if (rc >0 ) + rc = -EIO ; +return rc; }
@@ -3268,7 +3272,7 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev) rc =bnxt_hwrm_func_reset (bp);if (rc) {RTE_LOG (ERR ,PMD ,"hwrm chip reset failure rc: %x\n" , rc); - rc =-1 ; + rc = -EIO ; goto error_free; }
Signature · 1 line
2.14.3 (Apple Git-98)
PATCH 6/13 net/bnxt: add check for multi host PF per port.
In reply to Ajit KhapardeCertain SKUs of NIC can support features like NPAR, Multi Host PFs per port. We need to check for such features in order to restrict certain HWRM commands from being sent to the FW.
For the single PF per port model, allow commands like hwrm_port_phy_cfg from the PF driver. In NPAR and MH environments with multiple PFs per port, we should not allow HWRM commands like hwrm_port_phy_cfg to be sent to the FW.
This patch takes care of that.
--- drivers/net/bnxt/bnxt.h | 6 ++++-- drivers/net/bnxt/bnxt_ethdev.c | 4 ++-- drivers/net/bnxt/bnxt_hwrm.c | 6 +++++- drivers/net/bnxt/bnxt_stats.c | 4 ++-- 4 files changed, 13 insertions(+), 7 deletions(-)
drivers/net/bnxt/bnxt.h +4 -2
@@ -244,10 +244,12 @@ struct bnxt {#define BNXT_FLAG_SHORT_CMD (1 << 4)#define BNXT_FLAG_UPDATE_HASH (1 << 5)#define BNXT_FLAG_PTP_SUPPORTED (1 << 6) +#define BNXT_FLAG_MULTI_HOST (1 << 7)#define BNXT_PF (bp) (!((bp)->flags & BNXT_FLAG_VF))#define BNXT_VF (bp) ((bp)->flags & BNXT_FLAG_VF) -#define BNXT_NPAR_ENABLED (bp) ((bp)->port_partition_type) -#define BNXT_NPAR_PF (bp) (BNXT_PF(bp) && BNXT_NPAR_ENABLED(bp)) +#define BNXT_NPAR (bp) ((bp)->port_partition_type) +#define BNXT_MH (bp) ((bp)->flags & BNXT_FLAG_MULTI_HOST) +#define BNXT_SINGLE_PF (bp) (BNXT_PF(bp) && !BNXT_NPAR(bp) && !BNXT_MH(bp))unsigned int rx_nr_rings;unsigned int rx_cp_nr_rings;
drivers/net/bnxt/bnxt_ethdev.c +2 -2
@@ -1039,7 +1039,7 @@ static int bnxt_flow_ctrl_set_op(struct rte_eth_dev *dev, {struct bnxt *bp = (struct bnxt *)dev->data->dev_private; -if (BNXT_NPAR_PF (bp) ||BNXT_VF (bp)) { +if (!BNXT_SINGLE_PF (bp) ||BNXT_VF (bp)) {RTE_LOG (ERR ,PMD ,"Flow Control Settings cannot be modified\n" );return -ENOTSUP ; }
@@ -1570,7 +1570,7 @@ bnxt_vlan_pvid_set_op(struct rte_eth_dev *dev, uint16_t pvid, int on)uint16_t vlan = bp->vlan;int rc; -if (BNXT_NPAR_PF (bp) ||BNXT_VF (bp)) { +if (!BNXT_SINGLE_PF (bp) ||BNXT_VF (bp)) {RTE_LOG (ERR ,PMD ,"PVID cannot be modified for this function\n" );return -ENOTSUP ;
drivers/net/bnxt/bnxt_hwrm.c +5 -1
@@ -2193,7 +2193,7 @@ int bnxt_set_hwrm_link_config(struct bnxt *bp, bool link_up)struct bnxt_link_info link_req;uint16_t speed, autoneg; -if (BNXT_NPAR_PF (bp) ||BNXT_VF (bp)) +if (!BNXT_SINGLE_PF (bp) ||BNXT_VF (bp))return 0 ; rc = bnxt_valid_link_speed(dev_conf->link_speeds,
@@ -2249,6 +2249,7 @@ int bnxt_hwrm_func_qcfg(struct bnxt *bp) {struct hwrm_func_qcfg_input req = {0 };struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr; +uint16_t flags;int rc =0 ;HWRM_PREP (req,FUNC_QCFG );
@@ -2260,6 +2261,9 @@ int bnxt_hwrm_func_qcfg(struct bnxt *bp)/* Hard Coded.. 0xfff VLAN ID mask */ bp->vlan =rte_le_to_cpu_16 (resp->vlan) &0xfff ; + flags =rte_le_to_cpu_16 (resp->flags); +if (BNXT_PF (bp) && (flags &HWRM_FUNC_QCFG_OUTPUT_FLAGS_MULTI_HOST )) + bp->flags |=BNXT_FLAG_MULTI_HOST ;switch (resp->port_partition_type) {case HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR1_0 :
drivers/net/bnxt/bnxt_stats.c +2 -2
@@ -358,12 +358,12 @@ void bnxt_dev_xstats_reset_op(struct rte_eth_dev *eth_dev) {struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; -if (bp->flags &BNXT_FLAG_PORT_STATS && !BNXT_NPAR_PF (bp)) +if (bp->flags &BNXT_FLAG_PORT_STATS &&BNXT_SINGLE_PF (bp))bnxt_hwrm_port_clr_stats (bp);if (BNXT_VF (bp))RTE_LOG (ERR ,PMD ,"Operation not supported on a VF device\n" ); -if (BNXT_NPAR_PF (bp)) +if (!BNXT_SINGLE_PF (bp))RTE_LOG (ERR ,PMD ,"Operation not supported on a MF device\n" );if (!(bp->flags &BNXT_FLAG_PORT_STATS ))RTE_LOG (ERR ,PMD ,"Operation not supported\n" );
Signature · 1 line
2.14.3 (Apple Git-98)
PATCH 7/13 net/bnxt: check if initialization is done before accessing stats
In reply to Ajit KhapardeMaintain state of PMD initialization and check it before checking stats. In certain cases, we might end up accessing stats before the required HWRM commands are processed by FW.
--- drivers/net/bnxt/bnxt.h | 1 + drivers/net/bnxt/bnxt_ethdev.c | 2 ++ drivers/net/bnxt/bnxt_stats.c | 9 +++++++++ 3 files changed, 12 insertions(+)
drivers/net/bnxt/bnxt.h +1 -0
@@ -245,6 +245,7 @@ struct bnxt {#define BNXT_FLAG_UPDATE_HASH (1 << 5)#define BNXT_FLAG_PTP_SUPPORTED (1 << 6)#define BNXT_FLAG_MULTI_HOST (1 << 7) +#define BNXT_FLAG_INIT_DONE (1 << 31)#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)
drivers/net/bnxt/bnxt_ethdev.c +2 -0
@@ -590,6 +590,7 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)if (rc) goto error; + bp->flags |=BNXT_FLAG_INIT_DONE ;return 0 ; error:
@@ -635,6 +636,7 @@ static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev) }bnxt_set_hwrm_link_config (bp, false);bnxt_hwrm_port_clr_stats (bp); + bp->flags &= ~BNXT_FLAG_INIT_DONE ;bnxt_shutdown_nic (bp); bp->dev_stopped =1 ; }
drivers/net/bnxt/bnxt_stats.c +9 -0
@@ -236,6 +236,10 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev,struct bnxt *bp = eth_dev->data->dev_private;memset (bnxt_stats,0 ,sizeof (*bnxt_stats)); +if (!(bp->flags &BNXT_FLAG_INIT_DONE )) { +RTE_LOG (ERR ,PMD ,"Device Initialization not complete!\n" ); +return 0 ; + }for (i =0 ; i < bp->rx_cp_nr_rings; i++) {struct bnxt_rx_queue *rxq = bp->rx_queues[i];
@@ -267,6 +271,11 @@ void bnxt_stats_reset_op(struct rte_eth_dev *eth_dev) {struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; +if (!(bp->flags &BNXT_FLAG_INIT_DONE )) { +RTE_LOG (ERR ,PMD ,"Device Initialization not complete!\n" ); +return ; + } +bnxt_clear_all_hwrm_stat_ctxs (bp);rte_atomic64_clear (&bp->rx_mbuf_alloc_fail); }
Signature · 1 line
2.14.3 (Apple Git-98)
PATCH 8/13 net/bnxt: fix check for ether_type
In reply to Ajit KhapardeAs per documentation, While supporting ethertype_filters matching ether_types 0x0800 (IPv4) and 0x86DD (IPv6) is invalid. But we were wrongly doing that. This patch fixes it.
--- drivers/net/bnxt/bnxt_ethdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +3 -3
@@ -1732,9 +1732,9 @@ bnxt_match_and_validate_ether_filter(struct bnxt *bp,int match =0 ; *ret =0 ; -if (efilter->ether_type != ETHER_TYPE_IPv4 && - efilter->ether_type != ETHER_TYPE_IPv6) { -RTE_LOG (ERR ,PMD ,"unsupported ether_type(0x%04x) in" +if (efilter->ether_type == ETHER_TYPE_IPv4 || + efilter->ether_type == ETHER_TYPE_IPv6) { +RTE_LOG (ERR ,PMD ,"invalid ether_type(0x%04x) in" " ethertype filter." , efilter->ether_type); *ret = -EINVAL ; goto exit;
Signature · 1 line
2.14.3 (Apple Git-98)
PATCH 9/13 net/bnxt: remove unnecessary addition of a temporary filter
In reply to Ajit Khapardefilter1 which is used to just get the l2 filter FW id and not used later was unecessarily being inserted into a list and was not being freed after it's use was done.
Fix it by not doing the list insertion and releasing it back to the free filter pool.
--- drivers/net/bnxt/bnxt_filter.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/bnxt/bnxt_filter.c +5 -2
@@ -806,7 +806,6 @@ bnxt_get_l2_filter(struct bnxt *bp, struct bnxt_filter_info *nf,bnxt_free_filter (bp, filter1);return NULL ; } -STAILQ_INSERT_TAIL (&vnic->filter, filter1, next);return filter1; }
@@ -957,7 +956,11 @@ bnxt_validate_and_parse_flow(struct rte_eth_dev *dev, goto ret; } -//done: +if (filter1) { +bnxt_free_filter (bp, filter1); + filter1->fw_l2_filter_id =-1 ; + } + act =nxt_non_void_action (++act);if (act->type !=RTE_FLOW_ACTION_TYPE_END ) { rte_flow_error_set(error, EINVAL,
Signature · 1 line
2.14.3 (Apple Git-98)
PATCH 10/13 net/bnxt: fix duplicate filter pattern creation error
In reply to Ajit KhapardeFrom: Somnath Kotur <[email protected]>
If the attribute/pattern for a flow is the same, with only the 'action' i.e the destination queue index changing, allow it by cleaning up the older ntuple filter and updating the existing flow with the new filter rule having the new destination queue ID. Also, clear the L2 filter during flow_destroy after destroying the ntuple filter, otherwise the flow record is not completely purged from the HW.
--- drivers/net/bnxt/bnxt_filter.c | 42 +++++++++++++++++++++++++++++++++++++----- drivers/net/bnxt/bnxt_hwrm.c | 1 - 2 files changed, 37 insertions(+), 6 deletions(-)
drivers/net/bnxt/bnxt_filter.c +37 -5
@@ -1045,8 +1045,23 @@ bnxt_match_filter(struct bnxt *bp, struct bnxt_filter_info *nf) !memcmp (mf->dst_ipaddr, nf->dst_ipaddr,sizeof (nf->dst_ipaddr)) && !memcmp (mf->dst_ipaddr_mask, nf->dst_ipaddr_mask, - sizeof(nf->dst_ipaddr_mask))) - return -EEXIST; + sizeof(nf->dst_ipaddr_mask))) { + if (mf->dst_id == nf->dst_id) + return -EEXIST; +/* Same Flow, Different queue +* Clear the old ntuple filter +*/ +if (nf->filter_type ==HWRM_CFA_EM_FILTER ) +bnxt_hwrm_clear_em_filter (bp, mf); +if (nf->filter_type ==HWRM_CFA_NTUPLE_FILTER ) +bnxt_hwrm_clear_ntuple_filter (bp, mf); +/* Free the old filter, update flow +* with new filter +*/ +bnxt_free_filter (bp, mf); + flow->filter = nf; +return -EXDEV ; + } } }return 0 ;
@@ -1062,6 +1077,7 @@ bnxt_flow_create(struct rte_eth_dev *dev,struct bnxt *bp = (struct bnxt *)dev->data->dev_private;struct bnxt_filter_info *filter;struct bnxt_vnic_info *vnic =NULL ; +bool update_flow = false;struct rte_flow *flow;unsigned int i;int ret =0 ;
@@ -1092,9 +1108,17 @@ bnxt_flow_create(struct rte_eth_dev *dev, goto free_filter; ret =bnxt_match_filter (bp, filter); -if (ret !=0 ) { +if (ret == -EEXIST ) {RTE_LOG (DEBUG ,PMD ,"Flow already exists.\n" ); +/* Clear the filter that was created as part of +* validate_and_parse_flow() above +*/ +bnxt_hwrm_clear_l2_filter (bp, filter); goto free_filter; + }else if (ret == -EXDEV ) { +RTE_LOG (DEBUG ,PMD ,"Flow with same pattern exists" ); +RTE_LOG (DEBUG ,PMD ,"Updating with different destination\n" ); + update_flow = true; }if (filter->filter_type ==HWRM_CFA_EM_FILTER ) {
@@ -1117,22 +1141,29 @@ bnxt_flow_create(struct rte_eth_dev *dev,if (!ret) { flow->filter = filter; flow->vnic = vnic; +if (update_flow) { + ret = -EXDEV ; + goto free_flow; + }RTE_LOG (ERR ,PMD ,"Successfully created flow.\n" );STAILQ_INSERT_TAIL (&vnic->flow_list, flow, next);return flow; } free_filter: - filter->fw_l2_filter_id =-1 ;bnxt_free_filter (bp, filter); free_flow:if (ret == -EEXIST )rte_flow_error_set (error, ret,RTE_FLOW_ERROR_TYPE_HANDLE ,NULL ,"Matching Flow exists." ); +else if (ret == -EXDEV ) +rte_flow_error_set (error, ret, +RTE_FLOW_ERROR_TYPE_HANDLE ,NULL , +"Flow with pattern exists, updating destination queue" );else rte_flow_error_set (error, -ret,RTE_FLOW_ERROR_TYPE_HANDLE ,NULL , -"Failed to create flow." ); +"Failed to create flow." );rte_free (flow); flow =NULL ;return flow;
@@ -1156,6 +1187,7 @@ bnxt_flow_destroy(struct rte_eth_dev *dev,if (filter->filter_type ==HWRM_CFA_NTUPLE_FILTER ) ret =bnxt_hwrm_clear_ntuple_filter (bp, filter); +bnxt_hwrm_clear_l2_filter (bp, filter);if (!ret) {STAILQ_REMOVE (&vnic->flow_list, flow, rte_flow, next);rte_free (flow);
drivers/net/bnxt/bnxt_hwrm.c +0 -1
@@ -3665,7 +3665,6 @@ int bnxt_hwrm_clear_ntuple_filter(struct bnxt *bp,HWRM_UNLOCK (); filter->fw_ntuple_filter_id =-1 ; - filter->fw_l2_filter_id =-1 ;return 0 ; }
Signature · 1 line
2.14.3 (Apple Git-98)
PATCH 11/13 net/bnxt: fix bug with duplicate pattern for 5tuple filter
In reply to Ajit KhapardeFrom: Somnath Kotur <[email protected]>
When user re-issues same 5 tuple filter pattern cmd with different destination queue, it would flag it as an existing match. However, when deletion on this filter was attempted, it would crash as the 'vnic' from which the filter was being removed from would be different. Fix by updating the filter in the scenario where there is a pattern match and only the destination queue varies.
--- drivers/net/bnxt/bnxt_ethdev.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +23 -9
@@ -1962,7 +1962,8 @@ parse_ntuple_filter(struct bnxt *bp,static struct bnxt_filter_info *bnxt_match_ntuple_filter (struct bnxt *bp, -struct bnxt_filter_info *bfilter) +struct bnxt_filter_info *bfilter, +struct bnxt_vnic_info **mvnic) {struct bnxt_filter_info *mfilter =NULL ;int i;
@@ -1981,8 +1982,11 @@ bnxt_match_ntuple_filter(struct bnxt *bp, bfilter->dst_port == mfilter->dst_port && bfilter->dst_port_mask == mfilter->dst_port_mask && bfilter->flags == mfilter->flags && - bfilter->enables == mfilter->enables) + bfilter->enables == mfilter->enables) { + if (mvnic) + *mvnic = vnic;return mfilter; + } } }return NULL ;
@@ -1994,7 +1998,7 @@ bnxt_cfg_ntuple_filter(struct bnxt *bp, enum rte_filter_op filter_op) {struct bnxt_filter_info *bfilter, *mfilter, *filter1; -struct bnxt_vnic_info *vnic, *vnic0; +struct bnxt_vnic_info *vnic, *vnic0, *mvnic;int ret;if (nfilter->flags !=RTE_5TUPLE_FLAGS ) {
@@ -2032,12 +2036,22 @@ bnxt_cfg_ntuple_filter(struct bnxt *bp, bfilter->ethertype =0x800 ; bfilter->enables |=NTUPLE_FLTR_ALLOC_INPUT_EN_ETHERTYPE ; - mfilter =bnxt_match_ntuple_filter (bp, bfilter); + mfilter =bnxt_match_ntuple_filter (bp, bfilter, &mvnic); -if (mfilter !=NULL && filter_op ==RTE_ETH_FILTER_ADD ) { -RTE_LOG (ERR ,PMD ,"filter exists." ); +if (mfilter !=NULL && filter_op ==RTE_ETH_FILTER_ADD && + bfilter->dst_id == mfilter->dst_id) { +RTE_LOG (ERR ,PMD ,"filter exists.\n" ); ret = -EEXIST ; goto free_filter; + }else if (mfilter !=NULL && filter_op ==RTE_ETH_FILTER_ADD && + bfilter->dst_id != mfilter->dst_id) { + mfilter->dst_id = vnic->fw_vnic_id; + ret =bnxt_hwrm_set_ntuple_filter (bp, mfilter->dst_id, mfilter); +STAILQ_REMOVE (&mvnic->filter, mfilter, bnxt_filter_info, next); +STAILQ_INSERT_TAIL (&vnic->filter, mfilter, next); +RTE_LOG (ERR ,PMD ,"filter with matching pattern exists.\n" ); +RTE_LOG (ERR ,PMD ," Updated it to the new destination queue\n" ); + goto free_filter; }if (mfilter ==NULL && filter_op ==RTE_ETH_FILTER_DELETE ) {RTE_LOG (ERR ,PMD ,"filter doesn't exist." );
@@ -2059,11 +2073,11 @@ bnxt_cfg_ntuple_filter(struct bnxt *bp, } ret =bnxt_hwrm_clear_ntuple_filter (bp, mfilter); -STAILQ_REMOVE (&vnic->filter, mfilter, bnxt_filter_info, - next); +STAILQ_REMOVE (&vnic->filter, mfilter, bnxt_filter_info, next);bnxt_free_filter (bp, mfilter); - bfilter->fw_l2_filter_id =-1 ; + mfilter->fw_l2_filter_id =-1 ;bnxt_free_filter (bp, bfilter); + bfilter->fw_l2_filter_id =-1 ; }return 0 ;
Signature · 1 line
2.14.3 (Apple Git-98)
PATCH 12/13 bnxt/bnxt: free the aggregration ring while freeing all the HWRM rings
In reply to Ajit KhapardeFrom: Somnath Kotur <[email protected]>
bnxt_free_all_hwrm_rings() was freeing all the Rx Rings including zero-ing out the memory for the Aggregration rings, but was not issuing the FW cmd to destroy the AGG ring(s) from HW. This would manifest in problems when port stop/port start would be issued as there would be a HW ring leak everytime port stop was issued.
--- drivers/net/bnxt/bnxt_hwrm.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/bnxt/bnxt_hwrm.c +9 -2
@@ -1783,10 +1783,17 @@ int bnxt_free_all_hwrm_rings(struct bnxt *bp) rxr->rx_ring_struct->ring_size * sizeof(*rxr->rx_buf_ring)); rxr->rx_prod =0 ; + } + ring = rxr->ag_ring_struct; +if (ring->fw_ring_id !=INVALID_HW_RING_ID ) { +bnxt_hwrm_ring_free (bp, ring, +HWRM_RING_FREE_INPUT_RING_TYPE_RX ); + ring->fw_ring_id =INVALID_HW_RING_ID ;memset (rxr->ag_buf_ring,0 , - rxr->ag_ring_struct->ring_size * -sizeof (*rxr->ag_buf_ring)); + rxr->ag_ring_struct->ring_size * +sizeof (*rxr->ag_buf_ring)); rxr->ag_prod =0 ; + bp->grp_info[i].ag_fw_ring_id =INVALID_HW_RING_ID ; }if (cpr->cp_ring_struct->fw_ring_id !=INVALID_HW_RING_ID ) {bnxt_free_cp_ring (bp, cpr, idx);
Signature · 1 line
2.14.3 (Apple Git-98)
PATCH 13/13 net/bnxt: check on-chip resources
In reply to Ajit KhapardeCheck for availability of on-chip resources - like Queue count, number stat context, number of ring groups before inheriting and initializing as per application requirements.
Also check before creating a Tx or Rx queue make sure there are enough resources to complete the request.
--- drivers/net/bnxt/bnxt_ethdev.c | 20 ++++++++++++++++++++ drivers/net/bnxt/bnxt_rxq.c | 7 +++++++ drivers/net/bnxt/bnxt_txq.c | 7 +++++++ 3 files changed, 34 insertions(+)
drivers/net/bnxt/bnxt_ethdev.c +20 -0
@@ -530,6 +530,26 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev) bp->tx_queues = (void *)eth_dev->data->tx_queues;/* Inherit new configurations */ +if (eth_dev->data->nb_rx_queues > bp->rx_nr_rings || + eth_dev->data->nb_tx_queues > bp->tx_nr_rings || + eth_dev->data->nb_rx_queues + eth_dev->data->nb_tx_queues +1 > + bp->max_cp_rings || + eth_dev->data->nb_rx_queues + eth_dev->data->nb_tx_queues > + bp->max_stat_ctx || + (uint32_t )(eth_dev->data->nb_rx_queues +1 ) > bp->max_ring_grps) { +RTE_LOG (ERR ,PMD , +"Insufficient resources to support requested config\n" ); +RTE_LOG (ERR ,PMD , +"Num Queues Requested: Tx %d, Rx %d\n" , + eth_dev->data->nb_tx_queues, + eth_dev->data->nb_rx_queues); +RTE_LOG (ERR ,PMD , +"Res available: TxQ %d, RxQ %d, CQ %d Stat %d, Grp %d\n" , + bp->tx_nr_rings, bp->rx_nr_rings, bp->max_cp_rings, + bp->max_stat_ctx, bp->max_ring_grps); +return -ENOSPC ; + } + bp->rx_nr_rings = eth_dev->data->nb_rx_queues; bp->tx_nr_rings = eth_dev->data->nb_tx_queues; bp->rx_cp_nr_rings = bp->rx_nr_rings;
drivers/net/bnxt/bnxt_rxq.c +7 -0
@@ -311,6 +311,13 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,struct bnxt_rx_queue *rxq;int rc =0 ; +if (queue_idx >= bp->max_rx_rings) { +RTE_LOG (ERR ,PMD , +"Cannot create Rx ring %d. Only %d rings available\n" , + queue_idx, bp->max_rx_rings); +return -ENOSPC ; + } +if (!nb_desc || nb_desc >MAX_RX_DESC_CNT ) {RTE_LOG (ERR ,PMD ,"nb_desc %d is invalid\n" , nb_desc); rc = -EINVAL ;
drivers/net/bnxt/bnxt_txq.c +7 -0
@@ -108,6 +108,13 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev,struct bnxt_tx_queue *txq;int rc =0 ; +if (queue_idx >= bp->max_tx_rings) { +RTE_LOG (ERR ,PMD , +"Cannot create Tx ring %d. Only %d rings available\n" , + queue_idx, bp->max_tx_rings); +return -ENOSPC ; + } +if (!nb_desc || nb_desc >MAX_TX_DESC_CNT ) {RTE_LOG (ERR ,PMD ,"nb_desc %d is invalid" , nb_desc); rc = -EINVAL ;
Signature · 1 line
2.14.3 (Apple Git-98)
Quoted 13 lines · Ajit Khaparde
Please apply these patches.
Ajit Khaparde (10):
net/bnxt: check return values inbnxt_dev_initnet/bnxt: fix double increment of idx during Tx ring alloc net/bnxt: parse checksum offload flags
net/bnxt: fixgrp_infousage
net/bnxt: return proper error code
net/bnxt: add check for multi host PF per port. net/bnxt: check if initialization is done before accessing stats net/bnxt: fix check forether_type
net/bnxt: check on-chip resources
Quoted 5 lines
Somnath Kotur (3):
net/bnxt: fix duplicate filter pattern creation error net/bnxt: remove unnecessary addition of a temporary filter net/bnxt: fix bug with duplicate pattern for 5tuple filter bnxt/bnxt: free the aggregration ring while freeing all the HWRM rings
Series applied to dpdk-next-net/master, thanks.
Fixes lines are missing for some patches [1], can you please provide them, I can update commits when received.
[1]
$ ./devtools/check-git-log.sh -13
Missing 'Fixes' tag:
net/bnxt: fix group info usage
net/bnxt: fix duplicate filter pattern creation error
net/bnxt: fix bug with duplicate pattern for 5tuple filter