Skip to contentSkip to conversation

bnxt patch series

PATCH Superseded Ajit Khaparde 4 participants 54 messages Jul 12, 2019 – Jul 17, 2019 Network drivers

lore
Share & tools
lore
#0 lore raw

cover bnxt patch series

Patchset fixing various bugs in bnxt PMD based on recent patch submission.
https://patchwork.dpdk.org/patch/56311/

Ajit Khaparde (3):
net/bnxt: fix for doorbell register offset for Tx ring. net/bnxt: save the number of EM flow count net/bnxt: fix a compilation warning

Jay Ding (1):
net/bnxt: fix to avoid sending invalid VNIC id to firmware

Kalesh AP (5):
net/bnxt: fix extended port counter statistics net/bnxt: fix possible segfault in case of probe failure net/bnxt: do not fail VF probe when the MAC address is zero net/bnxt: fix to enable disable interrupts correctly in start stop net/bnxt: fix to check for invalid VNIC in cleanup path

Lance Richardson (4):
net/bnxt: fix Tx hang after port stop/start net/bnxt: reset Rx allocation state on port restart net/bnxt: nq doorbell cleanups
net/bnxt: avoid null pointer dereference

Qingmin Liu (1):
net/bnxt: fix rxq count if ntuple filtering is disabled

Rahul Gupta (1):
net/bnxt: correctly set L4 checksum error for tunnel and non-tunnel
packets

 drivers/net/bnxt/bnxt.h        |   3 +
 drivers/net/bnxt/bnxt_ethdev.c | 307 +++++++++++++++++++--------------
 drivers/net/bnxt/bnxt_hwrm.c   |  56 +++++-
 drivers/net/bnxt/bnxt_hwrm.h   |   1 +
 drivers/net/bnxt/bnxt_irq.c    |   5 +-
 drivers/net/bnxt/bnxt_ring.c   |  11 +-
 drivers/net/bnxt/bnxt_ring.h   |  23 ++-
 drivers/net/bnxt/bnxt_rxr.c    |  43 +++--
 drivers/net/bnxt/bnxt_rxr.h    | 120 ++++++++++---
 drivers/net/bnxt/bnxt_util.c   |  11 ++
 drivers/net/bnxt/bnxt_util.h   |   1 +
 drivers/net/bnxt/bnxt_vnic.c   |   3 +
 12 files changed, 409 insertions(+), 175 deletions(-)
Signature · 1 line
2.20.1 (Apple Git-117)
#1 lore raw

PATCH 1/15 net/bnxt: fix extended port counter statistics

From: Kalesh AP <[email protected]>

1. refactor stats allocation code to new routine
2. check for extended statistics support depends on "hwrm_spec_code" which is set in bnxt_hwrm_ver_get called later. Hence we were never querying extended port stats as flags field was not updated. Fixed this by moving the stats allocation after the call to bnxt_hwrm_ver_get.
3. we were incorrectly passing the host address used for port statistics to PORT_QSTATS_EXT command. Fixed this by passing the correct extended stats address.

Fixes f55e12f33416 ("net/bnxt: support extended port counters")
---
 drivers/net/bnxt/bnxt.h        |   1 +
 drivers/net/bnxt/bnxt_ethdev.c | 226 +++++++++++++++++----------------
 drivers/net/bnxt/bnxt_hwrm.c   |   7 +-
 3 files changed, 125 insertions(+), 109 deletions(-)
drivers/net/bnxt/bnxt.h +1 -0
index 942da7ff0..45e7359b2 100644
@@ -350,6 +350,7 @@ struct bnxt {
 #define BNXT_FLAG_TRUSTED_VF_EN	(1 << 11)
 #define BNXT_FLAG_DFLT_VNIC_SET	(1 << 12)
 #define BNXT_FLAG_THOR_CHIP	(1 << 13)
+#define BNXT_FLAG_EXT_STATS_SUPPORTED	(1 << 29)
 #define BNXT_FLAG_NEW_RM	(1 << 30)
 #define BNXT_FLAG_INIT_DONE	(1U << 31)
 #define BNXT_PF(bp)		(!((bp)->flags & BNXT_FLAG_VF))
drivers/net/bnxt/bnxt_ethdev.c +119 -107

251 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.c +5 -2
index 8f0d33dca..f691922bd 100644
@@ -611,6 +611,9 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
 		}
 	}
 
+	if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_STATS_SUPPORTED)
+		bp->flags |= BNXT_FLAG_EXT_STATS_SUPPORTED;
+
 	HWRM_UNLOCK();
 
 	return rc;
@@ -4495,13 +4498,13 @@ int bnxt_hwrm_ext_port_qstats(struct bnxt *bp)
 	req.port_id = rte_cpu_to_le_16(pf->port_id);
 	if (bp->flags & BNXT_FLAG_EXT_TX_PORT_STATS) {
 		req.tx_stat_host_addr =
-			rte_cpu_to_le_64(bp->hw_tx_port_stats_map);
+			rte_cpu_to_le_64(bp->hw_tx_port_stats_ext_map);
 		req.tx_stat_size =
 			rte_cpu_to_le_16(sizeof(struct tx_port_stats_ext));
 	}
 	if (bp->flags & BNXT_FLAG_EXT_RX_PORT_STATS) {
 		req.rx_stat_host_addr =
-			rte_cpu_to_le_64(bp->hw_rx_port_stats_map);
+			rte_cpu_to_le_64(bp->hw_rx_port_stats_ext_map);
 		req.rx_stat_size =
 			rte_cpu_to_le_16(sizeof(struct rx_port_stats_ext));
 	}
Signature · 1 line
2.20.1 (Apple Git-117)
#2 lore raw

Re: [dpdk-dev] [PATCH 01/15] net/bnxt: fix extended port counter statistics

drivers/net/bnxt/bnxt_ethdev.c int bnxt_alloc_ctx_mem(struct bnxt *bp) · line 3656

Quoted 4 lines · On Fri, 12 Jul 2019 11:36:08 +0530 Ajit Khaparde <[email protected]>…
drivers/net/bnxt/bnxt_ethdev.c +4 -0
+	snprintf(mz_name, RTE_MEMZONE_NAMESIZE,
+		 "bnxt_%04x:%02x:%02x:%02x-%s", pci_dev->addr.domain,
+		 pci_dev->addr.bus, pci_dev->addr.devid,
+		 pci_dev->addr.function, "rx_port_stats");

You could use the PCI_PRI_FMT definition from rte_pci.h here.

#3 lore raw

PATCH 2/15 net/bnxt: fix possible segfault in case of probe failure

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

Fixed couple of possible segfaults due to NULL pointer dereference in case of probe failure.

Fixes c09f57b49c13 ("net/bnxt: add start/stop/link update operations")
---
 drivers/net/bnxt/bnxt_irq.c  | 3 +++
 drivers/net/bnxt/bnxt_vnic.c | 3 +++
 2 files changed, 6 insertions(+)
drivers/net/bnxt/bnxt_irq.c +3 -0
index 0bb3eb4fa..61f7498a5 100644
@@ -52,6 +52,9 @@ void bnxt_free_int(struct bnxt *bp)
 {
 	struct bnxt_irq *irq;
 
+	if (bp->irq_tbl == NULL)
+		return;
+
 	irq = bp->irq_tbl;
 	if (irq) {
 		if (irq->requested) {
drivers/net/bnxt/bnxt_vnic.c +3 -0
index 262cfc18d..20e5bf2d1 100644
@@ -89,6 +89,9 @@ void bnxt_free_vnic_attributes(struct bnxt *bp)
 	struct bnxt_vnic_info *vnic;
 	unsigned int i;
 
+	if (bp->vnic_info == NULL)
+		return;
+
 	for (i = 0; i < bp->max_vnics; i++) {
 		vnic = &bp->vnic_info[i];
 		if (vnic->rss_table) {
Signature · 1 line
2.20.1 (Apple Git-117)
#4 lore raw

PATCH 3/15 net/bnxt: do not fail VF probe when the MAC address is zero

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

VF driver should not fail probe if the host PF driver has not assigned any MAC address for the VF. It should generate a random MAC address and configure the MAC and then continue probing the device.

Fixes be160484a48d ("net/bnxt: check if MAC address is all zeros")
---
 drivers/net/bnxt/bnxt_ethdev.c | 62 +++++++++++++++++++++++-----------
 drivers/net/bnxt/bnxt_hwrm.c   | 25 ++++++++++++++
 drivers/net/bnxt/bnxt_hwrm.h   |  1 +
 drivers/net/bnxt/bnxt_util.c   | 11 ++++++
 drivers/net/bnxt/bnxt_util.h   |  1 +
 5 files changed, 80 insertions(+), 20 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +42 -20
index 1ce6e81e5..523a8f1c5 100644
@@ -3753,6 +3753,46 @@ static int bnxt_alloc_stats_mem(struct bnxt *bp)
 	return 0;
 }
 
+static int bnxt_setup_mac_addr(struct rte_eth_dev *eth_dev)
+{
+	struct bnxt *bp = eth_dev->data->dev_private;
+	int rc = 0;
+
+	eth_dev->data->mac_addrs = rte_zmalloc("bnxt_mac_addr_tbl",
+					       RTE_ETHER_ADDR_LEN *
+					       bp->max_l2_ctx,
+					       0);
+	if (eth_dev->data->mac_addrs == NULL) {
+		PMD_DRV_LOG(ERR, "Failed to alloc MAC addr tbl\n");
+		return -ENOMEM;
+	}
+
+	if (bnxt_check_zero_bytes(bp->dflt_mac_addr, RTE_ETHER_ADDR_LEN)) {
+		if (BNXT_PF(bp))
+			return -EINVAL;
+
+		/* Generate a random MAC address, if none was assigned by PF */
+		PMD_DRV_LOG(INFO, "VF MAC address not assigned by Host PF\n");
+		bnxt_eth_hw_addr_random(bp->mac_addr);
+		PMD_DRV_LOG(INFO,
+			    "Assign random MAC:%02X:%02X:%02X:%02X:%02X:%02X\n",
+			    bp->mac_addr[0], bp->mac_addr[1], bp->mac_addr[2],
+			    bp->mac_addr[3], bp->mac_addr[4], bp->mac_addr[5]);
+
+		rc = bnxt_hwrm_set_mac(bp);
+		if (!rc)
+			memcpy(&bp->eth_dev->data->mac_addrs[0], bp->mac_addr,
+			       RTE_ETHER_ADDR_LEN);
+		return rc;
+	}
+
+	/* Copy the permanent MAC from the FUNC_QCAPS response */
+	memcpy(bp->mac_addr, bp->dflt_mac_addr, RTE_ETHER_ADDR_LEN);
+	memcpy(&eth_dev->data->mac_addrs[0], bp->mac_addr, RTE_ETHER_ADDR_LEN);
+
+	return rc;
+}
+
 #define ALLOW_FUNC(x)	\
 	{ \
 		uint32_t arg = (x); \
@@ -3840,28 +3880,10 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
 		rc = -EBUSY;
 		goto error_free;
 	}
-	eth_dev->data->mac_addrs = rte_zmalloc("bnxt_mac_addr_tbl",
-					RTE_ETHER_ADDR_LEN * bp->max_l2_ctx, 0);
-	if (eth_dev->data->mac_addrs == NULL) {
-		PMD_DRV_LOG(ERR,
-			"Failed to alloc %u bytes needed to store MAC addr tbl",
-			RTE_ETHER_ADDR_LEN * bp->max_l2_ctx);
-		rc = -ENOMEM;
-		goto error_free;
-	}
 
-	if (bnxt_check_zero_bytes(bp->dflt_mac_addr, RTE_ETHER_ADDR_LEN)) {
-		PMD_DRV_LOG(ERR,
-			    "Invalid MAC addr %02X:%02X:%02X:%02X:%02X:%02X\n",
-			    bp->dflt_mac_addr[0], bp->dflt_mac_addr[1],
-			    bp->dflt_mac_addr[2], bp->dflt_mac_addr[3],
-			    bp->dflt_mac_addr[4], bp->dflt_mac_addr[5]);
-		rc = -EINVAL;
+	rc = bnxt_setup_mac_addr(eth_dev);
+	if (rc)
 		goto error_free;
-	}
-	/* Copy the permanent MAC from the qcap response address now. */
-	memcpy(bp->mac_addr, bp->dflt_mac_addr, sizeof(bp->mac_addr));
-	memcpy(&eth_dev->data->mac_addrs[0], bp->mac_addr, RTE_ETHER_ADDR_LEN);
 
 	/* THOR does not support ring groups.
 	 * But we will use the array to save RSS context IDs.
drivers/net/bnxt/bnxt_hwrm.c +25 -0
index f691922bd..a9356c6b8 100644
@@ -4607,3 +4607,28 @@ int bnxt_hwrm_tunnel_redirect_info(struct bnxt *bp, uint8_t tun_type,
 
 	return rc;
 }
+
+int bnxt_hwrm_set_mac(struct bnxt *bp)
+{
+	struct hwrm_func_vf_cfg_output *resp = bp->hwrm_cmd_resp_addr;
+	struct hwrm_func_vf_cfg_input req = {0};
+	int rc = 0;
+
+	if (!BNXT_VF(bp))
+		return 0;
+
+	HWRM_PREP(req, FUNC_VF_CFG, BNXT_USE_CHIMP_MB);
+
+	req.enables =
+		rte_cpu_to_le_32(HWRM_FUNC_VF_CFG_INPUT_ENABLES_DFLT_MAC_ADDR);
+	memcpy(req.dflt_mac_addr, bp->mac_addr, RTE_ETHER_ADDR_LEN);
+
+	rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
+
+	HWRM_CHECK_RESULT();
+
+	memcpy(bp->dflt_mac_addr, bp->mac_addr, RTE_ETHER_ADDR_LEN);
+	HWRM_UNLOCK();
+
+	return rc;
+}
drivers/net/bnxt/bnxt_hwrm.h +1 -0
index e35462cb4..37aaa1a9e 100644
@@ -196,4 +196,5 @@ int bnxt_hwrm_tunnel_redirect_free(struct bnxt *bp, uint8_t type);
 int bnxt_hwrm_tunnel_redirect_query(struct bnxt *bp, uint32_t *type);
 int bnxt_hwrm_tunnel_redirect_info(struct bnxt *bp, uint8_t tun_type,
 				   uint16_t *dst_fid);
+int bnxt_hwrm_set_mac(struct bnxt *bp);
 #endif
drivers/net/bnxt/bnxt_util.c +11 -0
index 7d3342719..dda40af28 100644
@@ -4,6 +4,7 @@
  */
 
 #include <inttypes.h>
+#include <rte_ether.h>
 
 #include "bnxt_util.h"
 
@@ -16,3 +17,13 @@ int bnxt_check_zero_bytes(const uint8_t *bytes, int len)
 			return 0;
 	return 1;
 }
+
+void bnxt_eth_hw_addr_random(uint8_t *mac_addr)
+{
+	rte_eth_random_addr(mac_addr);
+
+	/* Set Organizationally Unique Identifier (OUI) prefix */
+	mac_addr[0] = 0x00;
+	mac_addr[1] = 0x0a;
+	mac_addr[2] = 0xf7;
+}
drivers/net/bnxt/bnxt_util.h +1 -0
index 2378833cc..9f1868a78 100644
@@ -7,5 +7,6 @@
 #define _BNXT_UTIL_H_
 
 int bnxt_check_zero_bytes(const uint8_t *bytes, int len);
+void bnxt_eth_hw_addr_random(uint8_t *mac_addr);
 
 #endif /* _BNXT_UTIL_H_ */
Signature · 1 line
2.20.1 (Apple Git-117)
#5 lore raw

PATCH 4/15 net/bnxt: fix Tx hang after port stop/start

In reply to Ajit Khaparde

From: Lance Richardson <[email protected]>

Initialize the state of the the completion valid indicator when a completion ring is freed, otherwise completions may not be processed when a new ring is allocated.

Fixes 5735eb241947 ("net/bnxt: support Tx batching")
---
 drivers/net/bnxt/bnxt_hwrm.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/bnxt/bnxt_hwrm.c +1 -0
index a9356c6b8..b6f9ec0a0 100644
@@ -2089,6 +2089,7 @@ static void bnxt_free_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
 	memset(cpr->cp_desc_ring, 0, cpr->cp_ring_struct->ring_size *
 			sizeof(*cpr->cp_desc_ring));
 	cpr->cp_raw_cons = 0;
+	cpr->valid = 0;
 }
 
 void bnxt_free_hwrm_rx_ring(struct bnxt *bp, int queue_index)
Signature · 1 line
2.20.1 (Apple Git-117)
#6 lore raw

PATCH 5/15 net/bnxt: reset Rx allocation state on port restart

In reply to Ajit Khaparde

From: Lance Richardson <[email protected]>

Move call site of bnxt_rxq_vec_setup() to ensure that rxq->rxrearm_nb and rxq->rxrearm_start are reinitialized correctly when a port is restarted.

Fixes af3ed597e305 ("net/bnxt: initial vector-mode driver")
---
 drivers/net/bnxt/bnxt_ring.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/bnxt/bnxt_ring.c +3 -0
index 16327dbe9..13478fa02 100644
@@ -613,6 +613,9 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
 		bnxt_db_write(&rxr->rx_db, rxr->rx_prod);
 		bnxt_db_write(&rxr->ag_db, rxr->ag_prod);
 		rxq->index = i;
+#ifdef RTE_LIBRTE_BNXT_INC_VECTOR
+		bnxt_rxq_vec_setup(rxq);
+#endif
 	}
 
 	for (i = 0; i < bp->tx_cp_nr_rings; i++) {
Signature · 1 line
2.20.1 (Apple Git-117)
#7 lore raw

Re: [dpdk-dev] [PATCH 05/15] net/bnxt: reset Rx allocation state on port restart

Quoted 20 lines · Ajit Khaparde

From: Lance Richardson <[email protected]>

Move call site of bnxt_rxq_vec_setup() to ensure that rxq->rxrearm_nb and rxq->rxrearm_start are reinitialized correctly when a port is restarted.

Fixes af3ed597e305 ("net/bnxt: initial vector-mode driver")
---
 drivers/net/bnxt/bnxt_ring.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/bnxt/bnxt_ring.c +0 -0
index 16327dbe9..13478fa02 100644

drivers/net/bnxt/bnxt_ring.c int bnxt_alloc_hwrm_rings(struct bnxt *bp) · line 616

Quoted 4 lines
drivers/net/bnxt/bnxt_ring.c +1 -0
@@ -613,6 +613,9 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
                bnxt_db_write(&rxr->rx_db, rxr->rx_prod);
                bnxt_db_write(&rxr->ag_db, rxr->ag_prod);
                rxq->index = i;
+#ifdef RTE_LIBRTE_BNXT_INC_VECTOR

This #ifdef should be removed, the macro is never defined in upstream.

Quoted 8 lines
drivers/net/bnxt/bnxt_ring.c +2 -1
+               bnxt_rxq_vec_setup(rxq);
+#endif
        }
 
        for (i = 0; i < bp->tx_cp_nr_rings; i++) {
--

2.20.1 (Apple Git-117)

#8 lore raw

Re: [dpdk-dev] [PATCH 05/15] net/bnxt: reset Rx allocation state on port restart

Quoted 18 lines · Lance Richardson
Quoted 15 lines · Ajit Khaparde

From: Lance Richardson <[email protected]>

Move call site of bnxt_rxq_vec_setup() to ensure that rxq->rxrearm_nb and rxq->rxrearm_start are reinitialized correctly when a port is restarted.

Fixes af3ed597e305 ("net/bnxt: initial vector-mode driver")
---
 drivers/net/bnxt/bnxt_ring.c | 3 +++
 1 file changed, 3 insertions(+)
Quoted 11 lines

drivers/net/bnxt/bnxt_ring.c int bnxt_alloc_hwrm_rings(struct bnxt *bp) · line 616

Quoted 9 lines
drivers/net/bnxt/bnxt_ring.c +1 -0
index 16327dbe9..13478fa02 100644
@@ -613,6 +613,9 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
                bnxt_db_write(&rxr->rx_db, rxr->rx_prod);
                bnxt_db_write(&rxr->ag_db, rxr->ag_prod);
                rxq->index = i;
+#ifdef RTE_LIBRTE_BNXT_INC_VECTOR

This #ifdef should be removed, the macro is never defined in upstream.

Correction, it needs to be changed to "#ifdef RTE_ARCH_X86".

Lance

Quoted 9 lines
Quoted 9 lines
drivers/net/bnxt/bnxt_ring.c +2 -1
+               bnxt_rxq_vec_setup(rxq);
+#endif
        }
 
        for (i = 0; i < bp->tx_cp_nr_rings; i++) {
--

2.20.1 (Apple Git-117)

#9 lore raw

PATCH 6/15 net/bnxt: correctly set L4 checksum error for tunnel and non-tunnel packets

In reply to Ajit Khaparde

From: Rahul Gupta <[email protected]>

Update ol_flags correctly for checksum errors in case of tunnel and non-tunnel packet.

Fixes 65ee636872eb ("net/bnxt: fix Rx checksum flags)
---
 drivers/net/bnxt/bnxt_rxr.c |  43 ++++++++++---
 drivers/net/bnxt/bnxt_rxr.h | 120 ++++++++++++++++++++++++++++++------
 2 files changed, 133 insertions(+), 30 deletions(-)
drivers/net/bnxt/bnxt_rxr.c +33 -10
index 44303f3b0..54a2cf5fd 100644
@@ -362,6 +362,7 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
 	int rc = 0;
 	uint8_t agg_buf = 0;
 	uint16_t cmp_type;
+	uint32_t flags2_f = 0;
 
 	rxcmp = (struct rx_pkt_cmpl *)
 	    &cpr->cp_desc_ring[cp_cons];
@@ -440,19 +441,41 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
 		mbuf->ol_flags |= PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED;
 	}
 
-	if (likely(RX_CMP_IP_CS_OK(rxcmp1)))
-		mbuf->ol_flags |= PKT_RX_IP_CKSUM_GOOD;
-	else if (likely(RX_CMP_IP_CS_UNKNOWN(rxcmp1)))
-		mbuf->ol_flags |= PKT_RX_IP_CKSUM_UNKNOWN;
-	else
+	flags2_f = flags2_0xf(rxcmp1);
+	/* IP Checksum */
+	if (unlikely(((IS_IP_NONTUNNEL_PKT(flags2_f)) &&
+		      (RX_CMP_IP_CS_ERROR(rxcmp1))) ||
+		     (IS_IP_TUNNEL_PKT(flags2_f) &&
+		      (RX_CMP_IP_OUTER_CS_ERROR(rxcmp1))))) {
 		mbuf->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+	} else if (unlikely(RX_CMP_IP_CS_UNKNOWN(rxcmp1))) {
+		mbuf->ol_flags |= PKT_RX_IP_CKSUM_UNKNOWN;
+	} else {
+		mbuf->ol_flags |= PKT_RX_IP_CKSUM_GOOD;
+	}
 
-	if (likely(RX_CMP_L4_CS_OK(rxcmp1)))
-		mbuf->ol_flags |= PKT_RX_L4_CKSUM_GOOD;
-	else if (likely(RX_CMP_L4_CS_UNKNOWN(rxcmp1)))
+	/* L4 Checksum */
+	if (likely(IS_L4_NONTUNNEL_PKT(flags2_f))) {
+		if (unlikely(RX_CMP_L4_INNER_CS_ERR2(rxcmp1)))
+			mbuf->ol_flags |= PKT_RX_L4_CKSUM_BAD;
+		else
+			mbuf->ol_flags |= PKT_RX_L4_CKSUM_GOOD;
+	} else if (IS_L4_TUNNEL_PKT(flags2_f)) {
+		if (unlikely(RX_CMP_L4_INNER_CS_ERR2(rxcmp1)))
+			mbuf->ol_flags |= PKT_RX_L4_CKSUM_BAD;
+		else
+			mbuf->ol_flags |= PKT_RX_L4_CKSUM_GOOD;
+		if (unlikely(RX_CMP_L4_OUTER_CS_ERR2(rxcmp1))) {
+			mbuf->ol_flags |= PKT_RX_OUTER_L4_CKSUM_BAD;
+		} else if (unlikely(IS_L4_TUNNEL_PKT_ONLY_INNER_L4_CS
+				    (flags2_f))) {
+			mbuf->ol_flags |= PKT_RX_OUTER_L4_CKSUM_UNKNOWN;
+		} else {
+			mbuf->ol_flags |= PKT_RX_OUTER_L4_CKSUM_GOOD;
+		}
+	} else if (unlikely(RX_CMP_L4_CS_UNKNOWN(rxcmp1))) {
 		mbuf->ol_flags |= PKT_RX_L4_CKSUM_UNKNOWN;
-	else
-		mbuf->ol_flags |= PKT_RX_L4_CKSUM_BAD;
+	}
 
 	mbuf->packet_type = bnxt_parse_pkt_type(rxcmp, rxcmp1);
 
drivers/net/bnxt/bnxt_rxr.h +100 -20

136 lines not on this page · raw message

Signature · 1 line
2.20.1 (Apple Git-117)
#10 lore raw

PATCH 7/15 net/bnxt: fix for doorbell register offset for Tx ring.

In reply to Ajit Khaparde

For Tx-ring # 104 and higher, the doorbell register was incorrectly configured due to which FW was not able to receive the notification of packet to transmit. With this fix, user can run traffic upto 256 rings.

Fixes 6eb3cc2294fd ("net/bnxt: add initial Tx code")
---
 drivers/net/bnxt/bnxt_ring.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/bnxt/bnxt_ring.c +2 -2
index 13478fa02..f4f57862d 100644
@@ -639,12 +639,12 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
 		ring_type = HWRM_RING_ALLOC_INPUT_RING_TYPE_TX;
 		rc = bnxt_hwrm_ring_alloc(bp, ring,
 					  ring_type,
-					  idx, cpr->hw_stats_ctx_id,
+					  i, cpr->hw_stats_ctx_id,
 					  cp_ring->fw_ring_id);
 		if (rc)
 			goto err_out;
 
-		bnxt_set_db(bp, &txr->tx_db, ring_type, idx, ring->fw_ring_id);
+		bnxt_set_db(bp, &txr->tx_db, ring_type, i, ring->fw_ring_id);
 		txq->index = idx;
 		bnxt_hwrm_set_ring_coal(bp, &coal, cp_ring->fw_ring_id);
 	}
Signature · 1 line
2.20.1 (Apple Git-117)
#11 lore raw

PATCH 8/15 net/bnxt: save the number of EM flow count

In reply to Ajit Khaparde

Save the number of EM flow count returned by the FW in HWRM_FUNC_QCFG and use it to calculate the overall pool of L2 contexts supported by FW.

Fixes 6d8109bcb398 ("net/bnxt: check VF resources if resource manager is enabled")
---
 drivers/net/bnxt/bnxt.h      |  1 +
 drivers/net/bnxt/bnxt_hwrm.c | 11 +++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)
drivers/net/bnxt/bnxt.h +1 -0
index 45e7359b2..cd809b385 100644
@@ -429,6 +429,7 @@ struct bnxt {
 	uint16_t		max_rx_rings;
 	uint16_t		max_nq_rings;
 	uint16_t		max_l2_ctx;
+	uint16_t		max_rx_em_flows;
 	uint16_t		max_vnics;
 	uint16_t		max_stat_ctx;
 	uint16_t		first_vf_id;
drivers/net/bnxt/bnxt_hwrm.c +9 -2
index b6f9ec0a0..84cda5e6c 100644
@@ -589,8 +589,10 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
 	bp->max_cp_rings = rte_le_to_cpu_16(resp->max_cmpl_rings);
 	bp->max_tx_rings = rte_le_to_cpu_16(resp->max_tx_rings);
 	bp->max_rx_rings = rte_le_to_cpu_16(resp->max_rx_rings);
-	bp->max_l2_ctx = rte_le_to_cpu_16(resp->max_l2_ctxs);
 	bp->first_vf_id = rte_le_to_cpu_16(resp->first_vf_id);
+	bp->max_rx_em_flows = rte_le_to_cpu_16(resp->max_rx_em_flows);
+	bp->max_l2_ctx =
+		rte_le_to_cpu_16(resp->max_l2_ctxs) + bp->max_rx_em_flows;
 	/* TODO: For now, do not support VMDq/RFS on VFs. */
 	if (BNXT_PF(bp)) {
 		if (bp->pf.max_vfs)
@@ -796,7 +798,12 @@ int bnxt_hwrm_func_resc_qcaps(struct bnxt *bp)
 		bp->max_tx_rings = rte_le_to_cpu_16(resp->max_tx_rings);
 		bp->max_rx_rings = rte_le_to_cpu_16(resp->max_rx_rings);
 		bp->max_ring_grps = rte_le_to_cpu_32(resp->max_hw_ring_grps);
-		bp->max_l2_ctx = rte_le_to_cpu_16(resp->max_l2_ctxs);
+		/* func_resource_qcaps does not return max_rx_em_flows.
+		 * So use the value provided by func_qcaps.
+		 */
+		bp->max_l2_ctx =
+			rte_le_to_cpu_16(resp->max_l2_ctxs) +
+			bp->max_rx_em_flows;
 		bp->max_vnics = rte_le_to_cpu_16(resp->max_vnics);
 		bp->max_stat_ctx = rte_le_to_cpu_16(resp->max_stat_ctx);
 	}
Signature · 1 line
2.20.1 (Apple Git-117)
#12 lore raw

PATCH 9/15 net/bnxt: nq doorbell cleanups

In reply to Ajit Khaparde

From: Lance Richardson <[email protected]>

Simplify nq doorbell handling code by removing redundant db parameter and consolidating NQ doorbell macro into the inline function that uses it.

Add "enable interrupt" variant of nq write. This will be used in a subsequent commit.

When initializing nq doorbell, don't assume that only the "disable interrupt" form will be used.

Fixes f8168ca0e690 ("net/bnxt: support thor controller")
---
 drivers/net/bnxt/bnxt.h      |  1 +
 drivers/net/bnxt/bnxt_ring.c |  2 +-
 drivers/net/bnxt/bnxt_ring.h | 23 ++++++++++++++++++-----
 3 files changed, 20 insertions(+), 6 deletions(-)
drivers/net/bnxt/bnxt.h +1 -0
index cd809b385..3ccf784e5 100644
@@ -246,6 +246,7 @@ struct bnxt_coal {
 #define DBR_TYPE_SRQ				(0x2ULL << 60)
 #define DBR_TYPE_CQ				(0x4ULL << 60)
 #define DBR_TYPE_NQ				(0xaULL << 60)
+#define DBR_TYPE_NQ_ARM				(0xbULL << 60)
 
 #define BNXT_RSS_TBL_SIZE_THOR		512
 #define BNXT_RSS_ENTRIES_PER_CTX_THOR	64
drivers/net/bnxt/bnxt_ring.c +1 -1
index f4f57862d..9e6074ae3 100644
@@ -341,7 +341,7 @@ static void bnxt_set_db(struct bnxt *bp,
 			db->db_key64 = DBR_PATH_L2 | DBR_TYPE_CQ;
 			break;
 		case HWRM_RING_ALLOC_INPUT_RING_TYPE_NQ:
-			db->db_key64 = DBR_PATH_L2 | DBR_TYPE_NQ;
+			db->db_key64 = DBR_PATH_L2;
 			break;
 		}
 		db->db_key64 |= (uint64_t)fid << DBR_XID_SFT;
drivers/net/bnxt/bnxt_ring.h +18 -5
index af2c5762f..e5cef3a1d 100644
@@ -84,15 +84,28 @@ static inline void bnxt_db_write(struct bnxt_db_info *db, uint32_t idx)
 		rte_write32(db->db_key32 | idx, db->doorbell);
 }
 
+/* Ring an NQ doorbell and disable interrupts for the ring. */
 static inline void bnxt_db_nq(struct bnxt_cp_ring_info *cpr)
 {
-	struct bnxt_db_info *db = &cpr->cp_db;
+	if (unlikely(!cpr->cp_db.db_64))
+		return;
+
+	rte_smp_wmb();
+	rte_write64(cpr->cp_db.db_key64 | DBR_TYPE_NQ |
+		    RING_CMP(cpr->cp_ring_struct, cpr->cp_raw_cons),
+		    cpr->cp_db.doorbell);
+}
+
+/* Ring an NQ doorbell and enable interrupts for the ring. */
+static inline void bnxt_db_nq_arm(struct bnxt_cp_ring_info *cpr)
+{
+	if (unlikely(!cpr->cp_db.db_64))
+		return;
 
 	rte_smp_wmb();
-	if (likely(db->db_64))
-		rte_write64(db->db_key64 | DBR_TYPE_NQ |
-			    RING_CMP(cpr->cp_ring_struct, cpr->cp_raw_cons),
-			    db->doorbell);
+	rte_write64(cpr->cp_db.db_key64 | DBR_TYPE_NQ_ARM |
+		    RING_CMP(cpr->cp_ring_struct, cpr->cp_raw_cons),
+		    cpr->cp_db.doorbell);
 }
 
 static inline void bnxt_db_cq(struct bnxt_cp_ring_info *cpr)
Signature · 1 line
2.20.1 (Apple Git-117)
#13 lore raw

PATCH 10/15 net/bnxt: avoid null pointer dereference

In reply to Ajit Khaparde

From: Lance Richardson <[email protected]>

Avoid null pointer dereference when allocating an insolated completion ring by basing nq ring allocation on whether an nq ring was requested instead of whether the device supports nq rings.

Fixes f8168ca0e690 ("net/bnxt: support thor controller")
---
 drivers/net/bnxt/bnxt_ring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bnxt/bnxt_ring.c +1 -1
index 9e6074ae3..98853ea7a 100644
@@ -280,7 +280,7 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
 	}
 	cp_ring_info->hw_stats_ctx_id = HWRM_NA_SIGNATURE;
 
-	if (BNXT_HAS_NQ(bp)) {
+	if (nq_ring_info) {
 		struct bnxt_ring *nq_ring = nq_ring_info->cp_ring_struct;
 
 		nq_ring->bd = (char *)mz->addr + nq_ring_start;
Signature · 1 line
2.20.1 (Apple Git-117)
#14 lore raw

PATCH 11/15 net/bnxt: fix to enable disable interrupts correctly in start stop

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

1. disable interrupts in dev_stop_op()
2. enable interrupts in dev_start_op()
3. Clean queue intr-vector mapping in dev_stop_op() and thus fix a possible memory leak.

Fixes c09f57b49c13 ("net/bnxt: add start/stop/link update operations")
---
 drivers/net/bnxt/bnxt_ethdev.c | 17 ++++++++++++++++-
 drivers/net/bnxt/bnxt_irq.c    |  2 --
 2 files changed, 16 insertions(+), 3 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +16 -1
index 523a8f1c5..ff0edeef4 100644
@@ -779,6 +779,7 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
 
 	eth_dev->rx_pkt_burst = bnxt_receive_function(eth_dev);
 	eth_dev->tx_pkt_burst = bnxt_transmit_function(eth_dev);
+	bnxt_enable_int(bp);
 	bp->flags |= BNXT_FLAG_INIT_DONE;
 	return 0;
 
@@ -818,6 +819,13 @@ static int bnxt_dev_set_link_down_op(struct rte_eth_dev *eth_dev)
 static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
 {
 	struct bnxt *bp = eth_dev->data->dev_private;
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
+
+	bnxt_disable_int(bp);
+
+	/* disable uio/vfio intr/eventfd mapping */
+	rte_intr_disable(intr_handle);
 
 	bp->flags &= ~BNXT_FLAG_INIT_DONE;
 	if (bp->eth_dev->data->dev_started) {
@@ -825,6 +833,14 @@ static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
 		eth_dev->data->dev_link.link_status = 0;
 	}
 	bnxt_set_hwrm_link_config(bp, false);
+
+	/* Clean queue intr-vector mapping */
+	rte_intr_efd_disable(intr_handle);
+	if (intr_handle->intr_vec != NULL) {
+		rte_free(intr_handle->intr_vec);
+		intr_handle->intr_vec = NULL;
+	}
+
 	bnxt_hwrm_port_clr_stats(bp);
 	bnxt_free_tx_mbufs(bp);
 	bnxt_free_rx_mbufs(bp);
@@ -3991,7 +4007,6 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
 	if (rc)
 		goto error_free_int;
 
-	bnxt_enable_int(bp);
 	bnxt_init_nic(bp);
 
 	return 0;
drivers/net/bnxt/bnxt_irq.c +0 -2
index 61f7498a5..6c4dce401 100644
@@ -58,7 +58,6 @@ void bnxt_free_int(struct bnxt *bp)
 	irq = bp->irq_tbl;
 	if (irq) {
 		if (irq->requested) {
-			rte_intr_disable(&bp->pdev->intr_handle);
 			rte_intr_callback_unregister(&bp->pdev->intr_handle,
 						     irq->handler,
 						     (void *)bp->eth_dev);
@@ -123,7 +122,6 @@ int bnxt_request_int(struct bnxt *bp)
 
 	rte_intr_callback_register(&bp->pdev->intr_handle, irq->handler,
 				   (void *)bp->eth_dev);
-	rte_intr_enable(&bp->pdev->intr_handle);
 
 	irq->requested = 1;
 	return rc;
Signature · 1 line
2.20.1 (Apple Git-117)
#15 lore raw

PATCH 12/15 net/bnxt: fix to check for invalid VNIC in cleanup path

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

The cleanup/rollback operation post rte_eth_dev_start failure might end up invoking an HWRM cmd even on an invalid vNIC resulting in error messages being logged needlessly.
Fix to check for the same before issuing the HWRM cmd.

Fixes c09f57b49c13 ("net/bnxt: add start/stop/link update operations")
---
 drivers/net/bnxt/bnxt_hwrm.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/bnxt/bnxt_hwrm.c +5 -0
index 84cda5e6c..1a0265f8a 100644
@@ -2325,6 +2325,11 @@ void bnxt_free_all_hwrm_resources(struct bnxt *bp)
 	for (i = bp->nr_vnics - 1; i >= 0; i--) {
 		struct bnxt_vnic_info *vnic = &bp->vnic_info[i];
 
+		if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
+			PMD_DRV_LOG(DEBUG, "Invalid vNIC ID\n");
+			return;
+		}
+
 		bnxt_clear_hwrm_vnic_flows(bp, vnic);
 
 		bnxt_clear_hwrm_vnic_filters(bp, vnic);
Signature · 1 line
2.20.1 (Apple Git-117)
#16 lore raw

PATCH 13/15 net/bnxt: fix a compilation warning

In reply to Ajit Khaparde

Compiler complains of an uninitialized variable.
Initializing it to avoid the issue.

Fixes db678d5c2b54 ("net/bnxt: add HWRM VNIC configure")
---
 drivers/net/bnxt/bnxt_hwrm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bnxt/bnxt_hwrm.c +1 -1
index 1a0265f8a..a4e0c2e0c 100644
@@ -1523,8 +1523,8 @@ int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic)
 	int rc = 0;
 	struct hwrm_vnic_cfg_input req = {.req_type = 0 };
 	struct hwrm_vnic_cfg_output *resp = bp->hwrm_cmd_resp_addr;
+	struct bnxt_plcmodes_cfg pmodes = { 0 };
 	uint32_t ctx_enable_flag = 0;
-	struct bnxt_plcmodes_cfg pmodes;
 	uint32_t enables = 0;
 
 	if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
Signature · 1 line
2.20.1 (Apple Git-117)
#17 lore raw

Re: [dpdk-dev] [PATCH 13/15] net/bnxt: fix a compilation warning

No worries. I will get to it.

From mobile device

Quoted 30 lines · Ajit Khaparde

Compiler complains of an uninitialized variable. Initializing it to avoid the issue.

Fixes db678d5c2b54 ("net/bnxt: add HWRM VNIC configure")

---
drivers/net/bnxt/bnxt_hwrm.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bnxt/bnxt_hwrm.c +1 -2
index 1a0265f8a..a4e0c2e0c 100644
@@ -1523,8 +1523,8 @@ int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic)
   int rc = 0;
   struct hwrm_vnic_cfg_input req = {.req_type = 0 };
   struct hwrm_vnic_cfg_output *resp = bp->hwrm_cmd_resp_addr;
+    struct bnxt_plcmodes_cfg pmodes = { 0 };
   uint32_t ctx_enable_flag = 0;
-    struct bnxt_plcmodes_cfg pmodes;
   uint32_t enables = 0;
 
   if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
--

2.20.1 (Apple Git-117)

#18 lore raw

PATCH 14/15 net/bnxt: fix rxq count if ntuple filtering is disabled

In reply to Ajit Khaparde

From: Qingmin Liu <[email protected]>

If ntuple filtering is disabled, FW will return max_vnics=1. Due to this only single Rxq is created.
Change to max_rx_rings = RTE_MIN(bp->max_rx_rings, bp->max_stat_ctx) to fix it.

Fixes 6d8109bcb398 ("net/bnxt: check VF resources if resource manager is enabled")
---
 drivers/net/bnxt/bnxt_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bnxt/bnxt_ethdev.c +1 -1
index ff0edeef4..2e02d30aa 100644
@@ -493,7 +493,7 @@ static void bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
 	/* PF/VF specifics */
 	if (BNXT_PF(bp))
 		dev_info->max_vfs = bp->pdev->max_vfs;
-	max_rx_rings = RTE_MIN(bp->max_vnics, bp->max_stat_ctx);
+	max_rx_rings = RTE_MIN(bp->max_rx_rings, bp->max_stat_ctx);
 	/* For the sake of symmetry, max_rx_queues = max_tx_queues */
 	dev_info->max_rx_queues = max_rx_rings;
 	dev_info->max_tx_queues = max_rx_rings;
Signature · 1 line
2.20.1 (Apple Git-117)
#19 lore raw

PATCH 15/15 net/bnxt: fix to avoid sending invalid VNIC id to firmware

In reply to Ajit Khaparde

From: Jay Ding <[email protected]>

Add checking for vinc id before sending message to chimp in bnxt_hwrm_vnic_plcmode_cfg().

Fixes db678d5c2b54 ("net/bnxt: add HWRM VNIC configure")
---
 drivers/net/bnxt/bnxt_hwrm.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/bnxt/bnxt_hwrm.c +5 -0
index a4e0c2e0c..313459aaf 100644
@@ -1497,6 +1497,11 @@ static int bnxt_hwrm_vnic_plcmodes_cfg(struct bnxt *bp,
 	struct hwrm_vnic_plcmodes_cfg_input req = {.req_type = 0 };
 	struct hwrm_vnic_plcmodes_cfg_output *resp = bp->hwrm_cmd_resp_addr;
 
+	if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
+		PMD_DRV_LOG(DEBUG, "VNIC ID %x\n", vnic->fw_vnic_id);
+		return rc;
+	}
+
 	HWRM_PREP(req, VNIC_PLCMODES_CFG, BNXT_USE_CHIMP_MB);
 
 	req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
Signature · 1 line
2.20.1 (Apple Git-117)
#20 lore raw

v2 cover bnxt patch series

In reply to Ajit Khaparde

Patchset fixing various bugs in bnxt PMD based on recent patch submission.
https://patchwork.dpdk.org/patch/56311/
Please apply.

Note this patchset supersedes the previous patch series:
https://patchwork.dpdk.org/project/dpdk/list/?series=5464

Ajit Khaparde (3):
net/bnxt: fix for doorbell register offset for Tx ring. net/bnxt: save the number of EM flow count net/bnxt: fix a compilation warning

Jay Ding (1):
net/bnxt: fix to avoid sending invalid VNIC id to firmware

Kalesh AP (5):
net/bnxt: fix extended port counter statistics net/bnxt: fix possible segfault in case of probe failure net/bnxt: do not fail VF probe when the MAC address is zero net/bnxt: fix to enable disable interrupts correctly in start stop net/bnxt: fix to check for invalid VNIC in cleanup path

Lance Richardson (4):
net/bnxt: fix Tx hang after port stop/start net/bnxt: reset Rx allocation state on port restart net/bnxt: nq doorbell cleanups
net/bnxt: avoid null pointer dereference

Qingmin Liu (1):
net/bnxt: fix rxq count if ntuple filtering is disabled

Rahul Gupta (1):
net/bnxt: correctly set L4 checksum error for tunnel and non-tunnel
packets

 drivers/net/bnxt/bnxt.h        |   3 +
 drivers/net/bnxt/bnxt_ethdev.c | 307 +++++++++++++++++++--------------
 drivers/net/bnxt/bnxt_hwrm.c   |  56 +++++-
 drivers/net/bnxt/bnxt_hwrm.h   |   1 +
 drivers/net/bnxt/bnxt_irq.c    |   5 +-
 drivers/net/bnxt/bnxt_ring.c   |  11 +-
 drivers/net/bnxt/bnxt_ring.h   |  23 ++-
 drivers/net/bnxt/bnxt_rxq.c    |   4 -
 drivers/net/bnxt/bnxt_rxr.c    |  43 +++--
 drivers/net/bnxt/bnxt_rxr.h    | 120 ++++++++++---
 drivers/net/bnxt/bnxt_util.c   |  11 ++
 drivers/net/bnxt/bnxt_util.h   |   1 +
 drivers/net/bnxt/bnxt_vnic.c   |   3 +
 13 files changed, 409 insertions(+), 179 deletions(-)
Signature · 1 line
2.20.1 (Apple Git-117)
#21 lore raw

PATCH v2 1/15 net/bnxt: fix extended port counter statistics

From: Kalesh AP <[email protected]>

1. refactor stats allocation code to new routine
2. check for extended statistics support depends on "hwrm_spec_code" which is set in bnxt_hwrm_ver_get called later. Hence we were never querying extended port stats as flags field was not updated. Fixed this by moving the stats allocation after the call to bnxt_hwrm_ver_get.
3. we were incorrectly passing the host address used for port statistics to PORT_QSTATS_EXT command. Fixed this by passing the correct extended stats address.

Fixes f55e12f33416 ("net/bnxt: support extended port counters")

--
v1->v2: Use PCI_PRI_FMT to format PCI address.

---
 drivers/net/bnxt/bnxt.h        |   1 +
 drivers/net/bnxt/bnxt_ethdev.c | 226 +++++++++++++++++----------------
 drivers/net/bnxt/bnxt_hwrm.c   |   7 +-
 3 files changed, 125 insertions(+), 109 deletions(-)
drivers/net/bnxt/bnxt.h +1 -0
index 942da7ff0..45e7359b2 100644
@@ -350,6 +350,7 @@ struct bnxt {
 #define BNXT_FLAG_TRUSTED_VF_EN	(1 << 11)
 #define BNXT_FLAG_DFLT_VNIC_SET	(1 << 12)
 #define BNXT_FLAG_THOR_CHIP	(1 << 13)
+#define BNXT_FLAG_EXT_STATS_SUPPORTED	(1 << 29)
 #define BNXT_FLAG_NEW_RM	(1 << 30)
 #define BNXT_FLAG_INIT_DONE	(1U << 31)
 #define BNXT_PF(bp)		(!((bp)->flags & BNXT_FLAG_VF))
drivers/net/bnxt/bnxt_ethdev.c +119 -107

251 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.c +5 -2
index 8f0d33dca..f691922bd 100644
@@ -611,6 +611,9 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
 		}
 	}
 
+	if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_STATS_SUPPORTED)
+		bp->flags |= BNXT_FLAG_EXT_STATS_SUPPORTED;
+
 	HWRM_UNLOCK();
 
 	return rc;
@@ -4495,13 +4498,13 @@ int bnxt_hwrm_ext_port_qstats(struct bnxt *bp)
 	req.port_id = rte_cpu_to_le_16(pf->port_id);
 	if (bp->flags & BNXT_FLAG_EXT_TX_PORT_STATS) {
 		req.tx_stat_host_addr =
-			rte_cpu_to_le_64(bp->hw_tx_port_stats_map);
+			rte_cpu_to_le_64(bp->hw_tx_port_stats_ext_map);
 		req.tx_stat_size =
 			rte_cpu_to_le_16(sizeof(struct tx_port_stats_ext));
 	}
 	if (bp->flags & BNXT_FLAG_EXT_RX_PORT_STATS) {
 		req.rx_stat_host_addr =
-			rte_cpu_to_le_64(bp->hw_rx_port_stats_map);
+			rte_cpu_to_le_64(bp->hw_rx_port_stats_ext_map);
 		req.rx_stat_size =
 			rte_cpu_to_le_16(sizeof(struct rx_port_stats_ext));
 	}
Signature · 1 line
2.20.1 (Apple Git-117)
#22 lore raw

PATCH v2 2/15 net/bnxt: fix possible segfault in case of probe failure

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

Fixed couple of possible segfaults due to NULL pointer dereference in case of probe failure.

Fixes c09f57b49c13 ("net/bnxt: add start/stop/link update operations")
---
 drivers/net/bnxt/bnxt_irq.c  | 3 +++
 drivers/net/bnxt/bnxt_vnic.c | 3 +++
 2 files changed, 6 insertions(+)
drivers/net/bnxt/bnxt_irq.c +3 -0
index 0bb3eb4fa..61f7498a5 100644
@@ -52,6 +52,9 @@ void bnxt_free_int(struct bnxt *bp)
 {
 	struct bnxt_irq *irq;
 
+	if (bp->irq_tbl == NULL)
+		return;
+
 	irq = bp->irq_tbl;
 	if (irq) {
 		if (irq->requested) {
drivers/net/bnxt/bnxt_vnic.c +3 -0
index 262cfc18d..20e5bf2d1 100644
@@ -89,6 +89,9 @@ void bnxt_free_vnic_attributes(struct bnxt *bp)
 	struct bnxt_vnic_info *vnic;
 	unsigned int i;
 
+	if (bp->vnic_info == NULL)
+		return;
+
 	for (i = 0; i < bp->max_vnics; i++) {
 		vnic = &bp->vnic_info[i];
 		if (vnic->rss_table) {
Signature · 1 line
2.20.1 (Apple Git-117)
#23 lore raw

PATCH v2 3/15 net/bnxt: do not fail VF probe when the MAC address is zero

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

VF driver should not fail probe if the host PF driver has not assigned any MAC address for the VF. It should generate a random MAC address and configure the MAC and then continue probing the device.

Fixes be160484a48d ("net/bnxt: check if MAC address is all zeros")
---
 drivers/net/bnxt/bnxt_ethdev.c | 62 +++++++++++++++++++++++-----------
 drivers/net/bnxt/bnxt_hwrm.c   | 25 ++++++++++++++
 drivers/net/bnxt/bnxt_hwrm.h   |  1 +
 drivers/net/bnxt/bnxt_util.c   | 11 ++++++
 drivers/net/bnxt/bnxt_util.h   |  1 +
 5 files changed, 80 insertions(+), 20 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +42 -20
index cb50572a6..40a57bb23 100644
@@ -3753,6 +3753,46 @@ static int bnxt_alloc_stats_mem(struct bnxt *bp)
 	return 0;
 }
 
+static int bnxt_setup_mac_addr(struct rte_eth_dev *eth_dev)
+{
+	struct bnxt *bp = eth_dev->data->dev_private;
+	int rc = 0;
+
+	eth_dev->data->mac_addrs = rte_zmalloc("bnxt_mac_addr_tbl",
+					       RTE_ETHER_ADDR_LEN *
+					       bp->max_l2_ctx,
+					       0);
+	if (eth_dev->data->mac_addrs == NULL) {
+		PMD_DRV_LOG(ERR, "Failed to alloc MAC addr tbl\n");
+		return -ENOMEM;
+	}
+
+	if (bnxt_check_zero_bytes(bp->dflt_mac_addr, RTE_ETHER_ADDR_LEN)) {
+		if (BNXT_PF(bp))
+			return -EINVAL;
+
+		/* Generate a random MAC address, if none was assigned by PF */
+		PMD_DRV_LOG(INFO, "VF MAC address not assigned by Host PF\n");
+		bnxt_eth_hw_addr_random(bp->mac_addr);
+		PMD_DRV_LOG(INFO,
+			    "Assign random MAC:%02X:%02X:%02X:%02X:%02X:%02X\n",
+			    bp->mac_addr[0], bp->mac_addr[1], bp->mac_addr[2],
+			    bp->mac_addr[3], bp->mac_addr[4], bp->mac_addr[5]);
+
+		rc = bnxt_hwrm_set_mac(bp);
+		if (!rc)
+			memcpy(&bp->eth_dev->data->mac_addrs[0], bp->mac_addr,
+			       RTE_ETHER_ADDR_LEN);
+		return rc;
+	}
+
+	/* Copy the permanent MAC from the FUNC_QCAPS response */
+	memcpy(bp->mac_addr, bp->dflt_mac_addr, RTE_ETHER_ADDR_LEN);
+	memcpy(&eth_dev->data->mac_addrs[0], bp->mac_addr, RTE_ETHER_ADDR_LEN);
+
+	return rc;
+}
+
 #define ALLOW_FUNC(x)	\
 	{ \
 		uint32_t arg = (x); \
@@ -3840,28 +3880,10 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
 		rc = -EBUSY;
 		goto error_free;
 	}
-	eth_dev->data->mac_addrs = rte_zmalloc("bnxt_mac_addr_tbl",
-					RTE_ETHER_ADDR_LEN * bp->max_l2_ctx, 0);
-	if (eth_dev->data->mac_addrs == NULL) {
-		PMD_DRV_LOG(ERR,
-			"Failed to alloc %u bytes needed to store MAC addr tbl",
-			RTE_ETHER_ADDR_LEN * bp->max_l2_ctx);
-		rc = -ENOMEM;
-		goto error_free;
-	}
 
-	if (bnxt_check_zero_bytes(bp->dflt_mac_addr, RTE_ETHER_ADDR_LEN)) {
-		PMD_DRV_LOG(ERR,
-			    "Invalid MAC addr %02X:%02X:%02X:%02X:%02X:%02X\n",
-			    bp->dflt_mac_addr[0], bp->dflt_mac_addr[1],
-			    bp->dflt_mac_addr[2], bp->dflt_mac_addr[3],
-			    bp->dflt_mac_addr[4], bp->dflt_mac_addr[5]);
-		rc = -EINVAL;
+	rc = bnxt_setup_mac_addr(eth_dev);
+	if (rc)
 		goto error_free;
-	}
-	/* Copy the permanent MAC from the qcap response address now. */
-	memcpy(bp->mac_addr, bp->dflt_mac_addr, sizeof(bp->mac_addr));
-	memcpy(&eth_dev->data->mac_addrs[0], bp->mac_addr, RTE_ETHER_ADDR_LEN);
 
 	/* THOR does not support ring groups.
 	 * But we will use the array to save RSS context IDs.
drivers/net/bnxt/bnxt_hwrm.c +25 -0
index f691922bd..a9356c6b8 100644
@@ -4607,3 +4607,28 @@ int bnxt_hwrm_tunnel_redirect_info(struct bnxt *bp, uint8_t tun_type,
 
 	return rc;
 }
+
+int bnxt_hwrm_set_mac(struct bnxt *bp)
+{
+	struct hwrm_func_vf_cfg_output *resp = bp->hwrm_cmd_resp_addr;
+	struct hwrm_func_vf_cfg_input req = {0};
+	int rc = 0;
+
+	if (!BNXT_VF(bp))
+		return 0;
+
+	HWRM_PREP(req, FUNC_VF_CFG, BNXT_USE_CHIMP_MB);
+
+	req.enables =
+		rte_cpu_to_le_32(HWRM_FUNC_VF_CFG_INPUT_ENABLES_DFLT_MAC_ADDR);
+	memcpy(req.dflt_mac_addr, bp->mac_addr, RTE_ETHER_ADDR_LEN);
+
+	rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
+
+	HWRM_CHECK_RESULT();
+
+	memcpy(bp->dflt_mac_addr, bp->mac_addr, RTE_ETHER_ADDR_LEN);
+	HWRM_UNLOCK();
+
+	return rc;
+}
drivers/net/bnxt/bnxt_hwrm.h +1 -0
index e35462cb4..37aaa1a9e 100644
@@ -196,4 +196,5 @@ int bnxt_hwrm_tunnel_redirect_free(struct bnxt *bp, uint8_t type);
 int bnxt_hwrm_tunnel_redirect_query(struct bnxt *bp, uint32_t *type);
 int bnxt_hwrm_tunnel_redirect_info(struct bnxt *bp, uint8_t tun_type,
 				   uint16_t *dst_fid);
+int bnxt_hwrm_set_mac(struct bnxt *bp);
 #endif
drivers/net/bnxt/bnxt_util.c +11 -0
index 7d3342719..dda40af28 100644
@@ -4,6 +4,7 @@
  */
 
 #include <inttypes.h>
+#include <rte_ether.h>
 
 #include "bnxt_util.h"
 
@@ -16,3 +17,13 @@ int bnxt_check_zero_bytes(const uint8_t *bytes, int len)
 			return 0;
 	return 1;
 }
+
+void bnxt_eth_hw_addr_random(uint8_t *mac_addr)
+{
+	rte_eth_random_addr(mac_addr);
+
+	/* Set Organizationally Unique Identifier (OUI) prefix */
+	mac_addr[0] = 0x00;
+	mac_addr[1] = 0x0a;
+	mac_addr[2] = 0xf7;
+}
drivers/net/bnxt/bnxt_util.h +1 -0
index 2378833cc..9f1868a78 100644
@@ -7,5 +7,6 @@
 #define _BNXT_UTIL_H_
 
 int bnxt_check_zero_bytes(const uint8_t *bytes, int len);
+void bnxt_eth_hw_addr_random(uint8_t *mac_addr);
 
 #endif /* _BNXT_UTIL_H_ */
Signature · 1 line
2.20.1 (Apple Git-117)
#24 lore raw

PATCH v2 4/15 net/bnxt: fix Tx hang after port stop/start

In reply to Ajit Khaparde

From: Lance Richardson <[email protected]>

Initialize the state of the the completion valid indicator when a completion ring is freed, otherwise completions may not be processed when a new ring is allocated.

Fixes 5735eb241947 ("net/bnxt: support Tx batching")
---
 drivers/net/bnxt/bnxt_hwrm.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/bnxt/bnxt_hwrm.c +1 -0
index a9356c6b8..b6f9ec0a0 100644
@@ -2089,6 +2089,7 @@ static void bnxt_free_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
 	memset(cpr->cp_desc_ring, 0, cpr->cp_ring_struct->ring_size *
 			sizeof(*cpr->cp_desc_ring));
 	cpr->cp_raw_cons = 0;
+	cpr->valid = 0;
 }
 
 void bnxt_free_hwrm_rx_ring(struct bnxt *bp, int queue_index)
Signature · 1 line
2.20.1 (Apple Git-117)
#25 lore raw

PATCH v2 5/15 net/bnxt: reset Rx allocation state on port restart

In reply to Ajit Khaparde

From: Lance Richardson <[email protected]>

Move call site of bnxt_rxq_vec_setup() to ensure that rxq->rxrearm_nb and rxq->rxrearm_start are reinitialized correctly when a port is restarted.

Fixes af3ed597e305 ("net/bnxt: initial vector-mode driver")

--
v1->v2: Move bnxt_rxq_vec_setup under RTE_ARCH_X86.

---
 drivers/net/bnxt/bnxt_ring.c | 3 +++
 drivers/net/bnxt/bnxt_rxq.c  | 4 ----
 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/net/bnxt/bnxt_ring.c +3 -0
index 16327dbe9..7453d4b56 100644
@@ -613,6 +613,9 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
 		bnxt_db_write(&rxr->rx_db, rxr->rx_prod);
 		bnxt_db_write(&rxr->ag_db, rxr->ag_prod);
 		rxq->index = i;
+#ifdef RTE_ARCH_X86
+		bnxt_rxq_vec_setup(rxq);
+#endif
 	}
 
 	for (i = 0; i < bp->tx_cp_nr_rings; i++) {
drivers/net/bnxt/bnxt_rxq.c +0 -4
index 6919acbb4..c94cac5a9 100644
@@ -356,10 +356,6 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
 	eth_dev->data->rx_queue_state[queue_idx] = queue_state;
 	rte_spinlock_init(&rxq->lock);
 
-#ifdef RTE_ARCH_X86
-	bnxt_rxq_vec_setup(rxq);
-#endif
-
 out:
 	return rc;
 }
Signature · 1 line
2.20.1 (Apple Git-117)
#26 lore raw

PATCH v2 6/15 net/bnxt: correctly set L4 checksum error for tunnel and non-tunnel packets

In reply to Ajit Khaparde

From: Rahul Gupta <[email protected]>

Update ol_flags correctly for checksum errors in case of tunnel and non-tunnel packet.

Fixes 65ee636872eb ("net/bnxt: fix Rx checksum flags)
---
 drivers/net/bnxt/bnxt_rxr.c |  43 ++++++++++---
 drivers/net/bnxt/bnxt_rxr.h | 120 ++++++++++++++++++++++++++++++------
 2 files changed, 133 insertions(+), 30 deletions(-)
drivers/net/bnxt/bnxt_rxr.c +33 -10
index 44303f3b0..54a2cf5fd 100644
@@ -362,6 +362,7 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
 	int rc = 0;
 	uint8_t agg_buf = 0;
 	uint16_t cmp_type;
+	uint32_t flags2_f = 0;
 
 	rxcmp = (struct rx_pkt_cmpl *)
 	    &cpr->cp_desc_ring[cp_cons];
@@ -440,19 +441,41 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
 		mbuf->ol_flags |= PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED;
 	}
 
-	if (likely(RX_CMP_IP_CS_OK(rxcmp1)))
-		mbuf->ol_flags |= PKT_RX_IP_CKSUM_GOOD;
-	else if (likely(RX_CMP_IP_CS_UNKNOWN(rxcmp1)))
-		mbuf->ol_flags |= PKT_RX_IP_CKSUM_UNKNOWN;
-	else
+	flags2_f = flags2_0xf(rxcmp1);
+	/* IP Checksum */
+	if (unlikely(((IS_IP_NONTUNNEL_PKT(flags2_f)) &&
+		      (RX_CMP_IP_CS_ERROR(rxcmp1))) ||
+		     (IS_IP_TUNNEL_PKT(flags2_f) &&
+		      (RX_CMP_IP_OUTER_CS_ERROR(rxcmp1))))) {
 		mbuf->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+	} else if (unlikely(RX_CMP_IP_CS_UNKNOWN(rxcmp1))) {
+		mbuf->ol_flags |= PKT_RX_IP_CKSUM_UNKNOWN;
+	} else {
+		mbuf->ol_flags |= PKT_RX_IP_CKSUM_GOOD;
+	}
 
-	if (likely(RX_CMP_L4_CS_OK(rxcmp1)))
-		mbuf->ol_flags |= PKT_RX_L4_CKSUM_GOOD;
-	else if (likely(RX_CMP_L4_CS_UNKNOWN(rxcmp1)))
+	/* L4 Checksum */
+	if (likely(IS_L4_NONTUNNEL_PKT(flags2_f))) {
+		if (unlikely(RX_CMP_L4_INNER_CS_ERR2(rxcmp1)))
+			mbuf->ol_flags |= PKT_RX_L4_CKSUM_BAD;
+		else
+			mbuf->ol_flags |= PKT_RX_L4_CKSUM_GOOD;
+	} else if (IS_L4_TUNNEL_PKT(flags2_f)) {
+		if (unlikely(RX_CMP_L4_INNER_CS_ERR2(rxcmp1)))
+			mbuf->ol_flags |= PKT_RX_L4_CKSUM_BAD;
+		else
+			mbuf->ol_flags |= PKT_RX_L4_CKSUM_GOOD;
+		if (unlikely(RX_CMP_L4_OUTER_CS_ERR2(rxcmp1))) {
+			mbuf->ol_flags |= PKT_RX_OUTER_L4_CKSUM_BAD;
+		} else if (unlikely(IS_L4_TUNNEL_PKT_ONLY_INNER_L4_CS
+				    (flags2_f))) {
+			mbuf->ol_flags |= PKT_RX_OUTER_L4_CKSUM_UNKNOWN;
+		} else {
+			mbuf->ol_flags |= PKT_RX_OUTER_L4_CKSUM_GOOD;
+		}
+	} else if (unlikely(RX_CMP_L4_CS_UNKNOWN(rxcmp1))) {
 		mbuf->ol_flags |= PKT_RX_L4_CKSUM_UNKNOWN;
-	else
-		mbuf->ol_flags |= PKT_RX_L4_CKSUM_BAD;
+	}
 
 	mbuf->packet_type = bnxt_parse_pkt_type(rxcmp, rxcmp1);
 
drivers/net/bnxt/bnxt_rxr.h +100 -20

136 lines not on this page · raw message

Signature · 1 line
2.20.1 (Apple Git-117)
#27 lore raw

PATCH v2 7/15 net/bnxt: fix for doorbell register offset for Tx ring.

In reply to Ajit Khaparde

For Tx-ring # 104 and higher, the doorbell register was incorrectly configured due to which FW was not able to receive the notification of packet to transmit. With this fix, user can run traffic upto 256 rings.

Fixes 6eb3cc2294fd ("net/bnxt: add initial Tx code")
---
 drivers/net/bnxt/bnxt_ring.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/bnxt/bnxt_ring.c +2 -2
index 7453d4b56..9b19459b6 100644
@@ -639,12 +639,12 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
 		ring_type = HWRM_RING_ALLOC_INPUT_RING_TYPE_TX;
 		rc = bnxt_hwrm_ring_alloc(bp, ring,
 					  ring_type,
-					  idx, cpr->hw_stats_ctx_id,
+					  i, cpr->hw_stats_ctx_id,
 					  cp_ring->fw_ring_id);
 		if (rc)
 			goto err_out;
 
-		bnxt_set_db(bp, &txr->tx_db, ring_type, idx, ring->fw_ring_id);
+		bnxt_set_db(bp, &txr->tx_db, ring_type, i, ring->fw_ring_id);
 		txq->index = idx;
 		bnxt_hwrm_set_ring_coal(bp, &coal, cp_ring->fw_ring_id);
 	}
Signature · 1 line
2.20.1 (Apple Git-117)
#28 lore raw

PATCH v2 8/15 net/bnxt: save the number of EM flow count

In reply to Ajit Khaparde

Save the number of EM flow count returned by the FW in HWRM_FUNC_QCFG and use it to calculate the overall pool of L2 contexts supported by FW.

Fixes 6d8109bcb398 ("net/bnxt: check VF resources if resource manager is enabled")
---
 drivers/net/bnxt/bnxt.h      |  1 +
 drivers/net/bnxt/bnxt_hwrm.c | 11 +++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)
drivers/net/bnxt/bnxt.h +1 -0
index 45e7359b2..cd809b385 100644
@@ -429,6 +429,7 @@ struct bnxt {
 	uint16_t		max_rx_rings;
 	uint16_t		max_nq_rings;
 	uint16_t		max_l2_ctx;
+	uint16_t		max_rx_em_flows;
 	uint16_t		max_vnics;
 	uint16_t		max_stat_ctx;
 	uint16_t		first_vf_id;
drivers/net/bnxt/bnxt_hwrm.c +9 -2
index b6f9ec0a0..84cda5e6c 100644
@@ -589,8 +589,10 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
 	bp->max_cp_rings = rte_le_to_cpu_16(resp->max_cmpl_rings);
 	bp->max_tx_rings = rte_le_to_cpu_16(resp->max_tx_rings);
 	bp->max_rx_rings = rte_le_to_cpu_16(resp->max_rx_rings);
-	bp->max_l2_ctx = rte_le_to_cpu_16(resp->max_l2_ctxs);
 	bp->first_vf_id = rte_le_to_cpu_16(resp->first_vf_id);
+	bp->max_rx_em_flows = rte_le_to_cpu_16(resp->max_rx_em_flows);
+	bp->max_l2_ctx =
+		rte_le_to_cpu_16(resp->max_l2_ctxs) + bp->max_rx_em_flows;
 	/* TODO: For now, do not support VMDq/RFS on VFs. */
 	if (BNXT_PF(bp)) {
 		if (bp->pf.max_vfs)
@@ -796,7 +798,12 @@ int bnxt_hwrm_func_resc_qcaps(struct bnxt *bp)
 		bp->max_tx_rings = rte_le_to_cpu_16(resp->max_tx_rings);
 		bp->max_rx_rings = rte_le_to_cpu_16(resp->max_rx_rings);
 		bp->max_ring_grps = rte_le_to_cpu_32(resp->max_hw_ring_grps);
-		bp->max_l2_ctx = rte_le_to_cpu_16(resp->max_l2_ctxs);
+		/* func_resource_qcaps does not return max_rx_em_flows.
+		 * So use the value provided by func_qcaps.
+		 */
+		bp->max_l2_ctx =
+			rte_le_to_cpu_16(resp->max_l2_ctxs) +
+			bp->max_rx_em_flows;
 		bp->max_vnics = rte_le_to_cpu_16(resp->max_vnics);
 		bp->max_stat_ctx = rte_le_to_cpu_16(resp->max_stat_ctx);
 	}
Signature · 1 line
2.20.1 (Apple Git-117)
#29 lore raw

PATCH v2 9/15 net/bnxt: nq doorbell cleanups

In reply to Ajit Khaparde

From: Lance Richardson <[email protected]>

Simplify nq doorbell handling code by removing redundant db parameter and consolidating NQ doorbell macro into the inline function that uses it.

Add "enable interrupt" variant of nq write. This will be used in a subsequent commit.

When initializing nq doorbell, don't assume that only the "disable interrupt" form will be used.

Fixes f8168ca0e690 ("net/bnxt: support thor controller")
---
 drivers/net/bnxt/bnxt.h      |  1 +
 drivers/net/bnxt/bnxt_ring.c |  2 +-
 drivers/net/bnxt/bnxt_ring.h | 23 ++++++++++++++++++-----
 3 files changed, 20 insertions(+), 6 deletions(-)
drivers/net/bnxt/bnxt.h +1 -0
index cd809b385..3ccf784e5 100644
@@ -246,6 +246,7 @@ struct bnxt_coal {
 #define DBR_TYPE_SRQ				(0x2ULL << 60)
 #define DBR_TYPE_CQ				(0x4ULL << 60)
 #define DBR_TYPE_NQ				(0xaULL << 60)
+#define DBR_TYPE_NQ_ARM				(0xbULL << 60)
 
 #define BNXT_RSS_TBL_SIZE_THOR		512
 #define BNXT_RSS_ENTRIES_PER_CTX_THOR	64
drivers/net/bnxt/bnxt_ring.c +1 -1
index 9b19459b6..faf861cc1 100644
@@ -341,7 +341,7 @@ static void bnxt_set_db(struct bnxt *bp,
 			db->db_key64 = DBR_PATH_L2 | DBR_TYPE_CQ;
 			break;
 		case HWRM_RING_ALLOC_INPUT_RING_TYPE_NQ:
-			db->db_key64 = DBR_PATH_L2 | DBR_TYPE_NQ;
+			db->db_key64 = DBR_PATH_L2;
 			break;
 		}
 		db->db_key64 |= (uint64_t)fid << DBR_XID_SFT;
drivers/net/bnxt/bnxt_ring.h +18 -5
index af2c5762f..e5cef3a1d 100644
@@ -84,15 +84,28 @@ static inline void bnxt_db_write(struct bnxt_db_info *db, uint32_t idx)
 		rte_write32(db->db_key32 | idx, db->doorbell);
 }
 
+/* Ring an NQ doorbell and disable interrupts for the ring. */
 static inline void bnxt_db_nq(struct bnxt_cp_ring_info *cpr)
 {
-	struct bnxt_db_info *db = &cpr->cp_db;
+	if (unlikely(!cpr->cp_db.db_64))
+		return;
+
+	rte_smp_wmb();
+	rte_write64(cpr->cp_db.db_key64 | DBR_TYPE_NQ |
+		    RING_CMP(cpr->cp_ring_struct, cpr->cp_raw_cons),
+		    cpr->cp_db.doorbell);
+}
+
+/* Ring an NQ doorbell and enable interrupts for the ring. */
+static inline void bnxt_db_nq_arm(struct bnxt_cp_ring_info *cpr)
+{
+	if (unlikely(!cpr->cp_db.db_64))
+		return;
 
 	rte_smp_wmb();
-	if (likely(db->db_64))
-		rte_write64(db->db_key64 | DBR_TYPE_NQ |
-			    RING_CMP(cpr->cp_ring_struct, cpr->cp_raw_cons),
-			    db->doorbell);
+	rte_write64(cpr->cp_db.db_key64 | DBR_TYPE_NQ_ARM |
+		    RING_CMP(cpr->cp_ring_struct, cpr->cp_raw_cons),
+		    cpr->cp_db.doorbell);
 }
 
 static inline void bnxt_db_cq(struct bnxt_cp_ring_info *cpr)
Signature · 1 line
2.20.1 (Apple Git-117)
#30 lore raw

PATCH v2 10/15 net/bnxt: avoid null pointer dereference

In reply to Ajit Khaparde

From: Lance Richardson <[email protected]>

Avoid null pointer dereference when allocating an insolated completion ring by basing nq ring allocation on whether an nq ring was requested instead of whether the device supports nq rings.

Fixes f8168ca0e690 ("net/bnxt: support thor controller")
---
 drivers/net/bnxt/bnxt_ring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bnxt/bnxt_ring.c +1 -1
index faf861cc1..ada748c05 100644
@@ -280,7 +280,7 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
 	}
 	cp_ring_info->hw_stats_ctx_id = HWRM_NA_SIGNATURE;
 
-	if (BNXT_HAS_NQ(bp)) {
+	if (nq_ring_info) {
 		struct bnxt_ring *nq_ring = nq_ring_info->cp_ring_struct;
 
 		nq_ring->bd = (char *)mz->addr + nq_ring_start;
Signature · 1 line
2.20.1 (Apple Git-117)
#31 lore raw

PATCH v2 11/15 net/bnxt: fix to enable disable interrupts correctly in start stop

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

1. disable interrupts in dev_stop_op()
2. enable interrupts in dev_start_op()
3. Clean queue intr-vector mapping in dev_stop_op() and thus fix a possible memory leak.

Fixes c09f57b49c13 ("net/bnxt: add start/stop/link update operations")
---
 drivers/net/bnxt/bnxt_ethdev.c | 17 ++++++++++++++++-
 drivers/net/bnxt/bnxt_irq.c    |  2 --
 2 files changed, 16 insertions(+), 3 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +16 -1
index 40a57bb23..292b7c3d1 100644
@@ -779,6 +779,7 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
 
 	eth_dev->rx_pkt_burst = bnxt_receive_function(eth_dev);
 	eth_dev->tx_pkt_burst = bnxt_transmit_function(eth_dev);
+	bnxt_enable_int(bp);
 	bp->flags |= BNXT_FLAG_INIT_DONE;
 	return 0;
 
@@ -818,6 +819,13 @@ static int bnxt_dev_set_link_down_op(struct rte_eth_dev *eth_dev)
 static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
 {
 	struct bnxt *bp = eth_dev->data->dev_private;
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
+
+	bnxt_disable_int(bp);
+
+	/* disable uio/vfio intr/eventfd mapping */
+	rte_intr_disable(intr_handle);
 
 	bp->flags &= ~BNXT_FLAG_INIT_DONE;
 	if (bp->eth_dev->data->dev_started) {
@@ -825,6 +833,14 @@ static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
 		eth_dev->data->dev_link.link_status = 0;
 	}
 	bnxt_set_hwrm_link_config(bp, false);
+
+	/* Clean queue intr-vector mapping */
+	rte_intr_efd_disable(intr_handle);
+	if (intr_handle->intr_vec != NULL) {
+		rte_free(intr_handle->intr_vec);
+		intr_handle->intr_vec = NULL;
+	}
+
 	bnxt_hwrm_port_clr_stats(bp);
 	bnxt_free_tx_mbufs(bp);
 	bnxt_free_rx_mbufs(bp);
@@ -3991,7 +4007,6 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
 	if (rc)
 		goto error_free_int;
 
-	bnxt_enable_int(bp);
 	bnxt_init_nic(bp);
 
 	return 0;
drivers/net/bnxt/bnxt_irq.c +0 -2
index 61f7498a5..6c4dce401 100644
@@ -58,7 +58,6 @@ void bnxt_free_int(struct bnxt *bp)
 	irq = bp->irq_tbl;
 	if (irq) {
 		if (irq->requested) {
-			rte_intr_disable(&bp->pdev->intr_handle);
 			rte_intr_callback_unregister(&bp->pdev->intr_handle,
 						     irq->handler,
 						     (void *)bp->eth_dev);
@@ -123,7 +122,6 @@ int bnxt_request_int(struct bnxt *bp)
 
 	rte_intr_callback_register(&bp->pdev->intr_handle, irq->handler,
 				   (void *)bp->eth_dev);
-	rte_intr_enable(&bp->pdev->intr_handle);
 
 	irq->requested = 1;
 	return rc;
Signature · 1 line
2.20.1 (Apple Git-117)
#32 lore raw

PATCH v2 12/15 net/bnxt: fix to check for invalid VNIC in cleanup path

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

The cleanup/rollback operation post rte_eth_dev_start failure might end up invoking an HWRM cmd even on an invalid vNIC resulting in error messages being logged needlessly.
Fix to check for the same before issuing the HWRM cmd.

Fixes c09f57b49c13 ("net/bnxt: add start/stop/link update operations")
---
 drivers/net/bnxt/bnxt_hwrm.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/bnxt/bnxt_hwrm.c +5 -0
index 84cda5e6c..1a0265f8a 100644
@@ -2325,6 +2325,11 @@ void bnxt_free_all_hwrm_resources(struct bnxt *bp)
 	for (i = bp->nr_vnics - 1; i >= 0; i--) {
 		struct bnxt_vnic_info *vnic = &bp->vnic_info[i];
 
+		if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
+			PMD_DRV_LOG(DEBUG, "Invalid vNIC ID\n");
+			return;
+		}
+
 		bnxt_clear_hwrm_vnic_flows(bp, vnic);
 
 		bnxt_clear_hwrm_vnic_filters(bp, vnic);
Signature · 1 line
2.20.1 (Apple Git-117)
#33 lore raw

PATCH v2 13/15 net/bnxt: fix a compilation warning

In reply to Ajit Khaparde

Compiler complains of an uninitialized variable.
Initializing it to avoid the issue.

Fixes db678d5c2b54 ("net/bnxt: add HWRM VNIC configure")
---
 drivers/net/bnxt/bnxt_hwrm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bnxt/bnxt_hwrm.c +1 -1
index 1a0265f8a..a4e0c2e0c 100644
@@ -1523,8 +1523,8 @@ int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic)
 	int rc = 0;
 	struct hwrm_vnic_cfg_input req = {.req_type = 0 };
 	struct hwrm_vnic_cfg_output *resp = bp->hwrm_cmd_resp_addr;
+	struct bnxt_plcmodes_cfg pmodes = { 0 };
 	uint32_t ctx_enable_flag = 0;
-	struct bnxt_plcmodes_cfg pmodes;
 	uint32_t enables = 0;
 
 	if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
Signature · 1 line
2.20.1 (Apple Git-117)
#34 lore raw

PATCH v2 14/15 net/bnxt: fix rxq count if ntuple filtering is disabled

In reply to Ajit Khaparde

From: Qingmin Liu <[email protected]>

If ntuple filtering is disabled, FW will return max_vnics=1. Due to this only single Rxq is created.
Change to max_rx_rings = RTE_MIN(bp->max_rx_rings, bp->max_stat_ctx) to fix it.

Fixes 6d8109bcb398 ("net/bnxt: check VF resources if resource manager is enabled")
---
 drivers/net/bnxt/bnxt_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bnxt/bnxt_ethdev.c +1 -1
index 292b7c3d1..0b3999d12 100644
@@ -493,7 +493,7 @@ static void bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
 	/* PF/VF specifics */
 	if (BNXT_PF(bp))
 		dev_info->max_vfs = bp->pdev->max_vfs;
-	max_rx_rings = RTE_MIN(bp->max_vnics, bp->max_stat_ctx);
+	max_rx_rings = RTE_MIN(bp->max_rx_rings, bp->max_stat_ctx);
 	/* For the sake of symmetry, max_rx_queues = max_tx_queues */
 	dev_info->max_rx_queues = max_rx_rings;
 	dev_info->max_tx_queues = max_rx_rings;
Signature · 1 line
2.20.1 (Apple Git-117)
#35 lore raw

PATCH v2 15/15 net/bnxt: fix to avoid sending invalid VNIC id to firmware

In reply to Ajit Khaparde

From: Jay Ding <[email protected]>

Add checking for vinc id before sending message to chimp in bnxt_hwrm_vnic_plcmode_cfg().

Fixes db678d5c2b54 ("net/bnxt: add HWRM VNIC configure")
---
 drivers/net/bnxt/bnxt_hwrm.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/bnxt/bnxt_hwrm.c +5 -0
index a4e0c2e0c..313459aaf 100644
@@ -1497,6 +1497,11 @@ static int bnxt_hwrm_vnic_plcmodes_cfg(struct bnxt *bp,
 	struct hwrm_vnic_plcmodes_cfg_input req = {.req_type = 0 };
 	struct hwrm_vnic_plcmodes_cfg_output *resp = bp->hwrm_cmd_resp_addr;
 
+	if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
+		PMD_DRV_LOG(DEBUG, "VNIC ID %x\n", vnic->fw_vnic_id);
+		return rc;
+	}
+
 	HWRM_PREP(req, VNIC_PLCMODES_CFG, BNXT_USE_CHIMP_MB);
 
 	req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
Signature · 1 line
2.20.1 (Apple Git-117)
#36 lore raw
In reply to Ajit Khaparde
Quoted 28 lines · Ajit Khaparde

Patchset fixing various bugs in bnxt PMD based on recent patch submission.
https://patchwork.dpdk.org/patch/56311/
Please apply.

Note this patchset supersedes the previous patch series:
https://patchwork.dpdk.org/project/dpdk/list/?series=5464

Ajit Khaparde (3):
net/bnxt: fix for doorbell register offset for Tx ring. net/bnxt: save the number of EM flow count net/bnxt: fix a compilation warning

Jay Ding (1):
net/bnxt: fix to avoid sending invalid VNIC id to firmware

Kalesh AP (5):
net/bnxt: fix extended port counter statistics net/bnxt: fix possible segfault in case of probe failure net/bnxt: do not fail VF probe when the MAC address is zero net/bnxt: fix to enable disable interrupts correctly in start stop net/bnxt: fix to check for invalid VNIC in cleanup path

Lance Richardson (4):
net/bnxt: fix Tx hang after port stop/start net/bnxt: reset Rx allocation state on port restart net/bnxt: nq doorbell cleanups
net/bnxt: avoid null pointer dereference

Quoted 6 lines

Qingmin Liu (1):
net/bnxt: fix rxq count if ntuple filtering is disabled

Rahul Gupta (1):
net/bnxt: correctly set L4 checksum error for tunnel and non-tunnel
packets

Can you please check 'check-git-log.sh' warnings:

./devtools/check-git-log.sh -15
Wrong headline format:
net/bnxt: fix for doorbell register offset for Tx ring.
Headline too long:
net/bnxt: correctly set L4 checksum error for tunnel and non-tunnel packets net/bnxt: fix to enable disable interrupts correctly in start stop
Wrong tag:

        Fixes: 65ee636872eb ("net/bnxt: fix Rx checksum flags)

Wrong 'Fixes' reference:

Fixes af3ed597e305 ("net/bnxt: initial vector-mode driver")
Fixes 65ee636872eb ("net/bnxt: fix Rx checksum flags)

Is it candidate for Cc: [email protected] backport?
net/bnxt: fix extended port counter statistics
net/bnxt: fix possible segfault in case of probe failure net/bnxt: do not fail VF probe when the MAC address is zero net/bnxt: fix Tx hang after port stop/start
net/bnxt: correctly set L4 checksum error for tunnel and non-tunnel packets net/bnxt: fix for doorbell register offset for Tx ring. net/bnxt: save the number of EM flow count
net/bnxt: fix to enable disable interrupts correctly in start stop net/bnxt: fix to check for invalid VNIC in cleanup path net/bnxt: fix a compilation warning
net/bnxt: fix rxq count if ntuple filtering is disabled net/bnxt: fix to avoid sending invalid VNIC id to firmware

#37 lore raw

v3 cover bnxt patch series

Patchset fixing various bugs in bnxt PMD based on recent commit:
1e101412320061a4a1cd47db4227b4f8a163e9f6

Ajit Khaparde (3):
net/bnxt: fix for doorbell register offset for Tx ring net/bnxt: save the number of EM flow count net/bnxt: fix a compilation warning

Jay Ding (1):
net/bnxt: fix to avoid sending invalid VNIC id to firmware

Kalesh AP (5):
net/bnxt: fix extended port counter statistics net/bnxt: fix possible segfault in case of probe failure net/bnxt: do not fail VF probe when the MAC address is zero net/bnxt: fix to enable disable interrupts correctly net/bnxt: fix to check for invalid VNIC in cleanup path

Lance Richardson (4):
net/bnxt: fix Tx hang after port stop/start net/bnxt: reset Rx allocation state on port restart net/bnxt: nq doorbell cleanups
net/bnxt: avoid null pointer dereference

Qingmin Liu (1):
net/bnxt: fix rxq count if ntuple filtering is disabled

Rahul Gupta (1):
net/bnxt: fix L4 checksum error indication in Rx path

 drivers/net/bnxt/bnxt.h        |   3 +
 drivers/net/bnxt/bnxt_ethdev.c | 307 +++++++++++++++++++--------------
 drivers/net/bnxt/bnxt_hwrm.c   |  56 +++++-
 drivers/net/bnxt/bnxt_hwrm.h   |   1 +
 drivers/net/bnxt/bnxt_irq.c    |   5 +-
 drivers/net/bnxt/bnxt_ring.c   |  11 +-
 drivers/net/bnxt/bnxt_ring.h   |  23 ++-
 drivers/net/bnxt/bnxt_rxq.c    |   4 -
 drivers/net/bnxt/bnxt_rxr.c    |  43 +++--
 drivers/net/bnxt/bnxt_rxr.h    | 120 ++++++++++---
 drivers/net/bnxt/bnxt_util.c   |  11 ++
 drivers/net/bnxt/bnxt_util.h   |   1 +
 drivers/net/bnxt/bnxt_vnic.c   |   3 +
 13 files changed, 409 insertions(+), 179 deletions(-)
Signature · 1 line
2.20.1 (Apple Git-117)
#38 lore raw

PATCH v3 1/15 net/bnxt: fix extended port counter statistics

From: Kalesh AP <[email protected]>

1. refactor stats allocation code to new routine
2. check for extended statistics support depends on "hwrm_spec_code" which is set in bnxt_hwrm_ver_get called later. Hence we were never querying extended port stats as flags field was not updated. Fixed this by moving the stats allocation after the call to bnxt_hwrm_ver_get.
3. we were incorrectly passing the host address used for port statistics to PORT_QSTATS_EXT command. Fixed this by passing the correct extended stats address.

Fixes f55e12f33416 ("net/bnxt: support extended port counters")

--
v1->v2: Use PCI_PRI_FMT to format PCI address.

---
 drivers/net/bnxt/bnxt.h        |   1 +
 drivers/net/bnxt/bnxt_ethdev.c | 226 +++++++++++++++++----------------
 drivers/net/bnxt/bnxt_hwrm.c   |   7 +-
 3 files changed, 125 insertions(+), 109 deletions(-)
drivers/net/bnxt/bnxt.h +1 -0
index 942da7ff0..45e7359b2 100644
@@ -350,6 +350,7 @@ struct bnxt {
 #define BNXT_FLAG_TRUSTED_VF_EN	(1 << 11)
 #define BNXT_FLAG_DFLT_VNIC_SET	(1 << 12)
 #define BNXT_FLAG_THOR_CHIP	(1 << 13)
+#define BNXT_FLAG_EXT_STATS_SUPPORTED	(1 << 29)
 #define BNXT_FLAG_NEW_RM	(1 << 30)
 #define BNXT_FLAG_INIT_DONE	(1U << 31)
 #define BNXT_PF(bp)		(!((bp)->flags & BNXT_FLAG_VF))
drivers/net/bnxt/bnxt_ethdev.c +119 -107

251 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.c +5 -2
index 8f0d33dca..f691922bd 100644
@@ -611,6 +611,9 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
 		}
 	}
 
+	if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_STATS_SUPPORTED)
+		bp->flags |= BNXT_FLAG_EXT_STATS_SUPPORTED;
+
 	HWRM_UNLOCK();
 
 	return rc;
@@ -4495,13 +4498,13 @@ int bnxt_hwrm_ext_port_qstats(struct bnxt *bp)
 	req.port_id = rte_cpu_to_le_16(pf->port_id);
 	if (bp->flags & BNXT_FLAG_EXT_TX_PORT_STATS) {
 		req.tx_stat_host_addr =
-			rte_cpu_to_le_64(bp->hw_tx_port_stats_map);
+			rte_cpu_to_le_64(bp->hw_tx_port_stats_ext_map);
 		req.tx_stat_size =
 			rte_cpu_to_le_16(sizeof(struct tx_port_stats_ext));
 	}
 	if (bp->flags & BNXT_FLAG_EXT_RX_PORT_STATS) {
 		req.rx_stat_host_addr =
-			rte_cpu_to_le_64(bp->hw_rx_port_stats_map);
+			rte_cpu_to_le_64(bp->hw_rx_port_stats_ext_map);
 		req.rx_stat_size =
 			rte_cpu_to_le_16(sizeof(struct rx_port_stats_ext));
 	}
Signature · 1 line
2.20.1 (Apple Git-117)
#39 lore raw

PATCH v3 2/15 net/bnxt: fix possible segfault in case of probe failure

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

Fixed couple of possible segfaults due to NULL pointer dereference in case of probe failure.

Fixes c09f57b49c13 ("net/bnxt: add start/stop/link update operations")
---
 drivers/net/bnxt/bnxt_irq.c  | 3 +++
 drivers/net/bnxt/bnxt_vnic.c | 3 +++
 2 files changed, 6 insertions(+)
drivers/net/bnxt/bnxt_irq.c +3 -0
index 0bb3eb4fa..61f7498a5 100644
@@ -52,6 +52,9 @@ void bnxt_free_int(struct bnxt *bp)
 {
 	struct bnxt_irq *irq;
 
+	if (bp->irq_tbl == NULL)
+		return;
+
 	irq = bp->irq_tbl;
 	if (irq) {
 		if (irq->requested) {
drivers/net/bnxt/bnxt_vnic.c +3 -0
index 262cfc18d..20e5bf2d1 100644
@@ -89,6 +89,9 @@ void bnxt_free_vnic_attributes(struct bnxt *bp)
 	struct bnxt_vnic_info *vnic;
 	unsigned int i;
 
+	if (bp->vnic_info == NULL)
+		return;
+
 	for (i = 0; i < bp->max_vnics; i++) {
 		vnic = &bp->vnic_info[i];
 		if (vnic->rss_table) {
Signature · 1 line
2.20.1 (Apple Git-117)
#40 lore raw

PATCH v3 3/15 net/bnxt: do not fail VF probe when the MAC address is zero

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

VF driver should not fail probe if the host PF driver has not assigned any MAC address for the VF. It should generate a random MAC address and configure the MAC and then continue probing the device.

Fixes be160484a48d ("net/bnxt: check if MAC address is all zeros")
---
 drivers/net/bnxt/bnxt_ethdev.c | 62 +++++++++++++++++++++++-----------
 drivers/net/bnxt/bnxt_hwrm.c   | 25 ++++++++++++++
 drivers/net/bnxt/bnxt_hwrm.h   |  1 +
 drivers/net/bnxt/bnxt_util.c   | 11 ++++++
 drivers/net/bnxt/bnxt_util.h   |  1 +
 5 files changed, 80 insertions(+), 20 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +42 -20
index da0486c62..e44df1881 100644
@@ -3753,6 +3753,46 @@ static int bnxt_alloc_stats_mem(struct bnxt *bp)
 	return 0;
 }
 
+static int bnxt_setup_mac_addr(struct rte_eth_dev *eth_dev)
+{
+	struct bnxt *bp = eth_dev->data->dev_private;
+	int rc = 0;
+
+	eth_dev->data->mac_addrs = rte_zmalloc("bnxt_mac_addr_tbl",
+					       RTE_ETHER_ADDR_LEN *
+					       bp->max_l2_ctx,
+					       0);
+	if (eth_dev->data->mac_addrs == NULL) {
+		PMD_DRV_LOG(ERR, "Failed to alloc MAC addr tbl\n");
+		return -ENOMEM;
+	}
+
+	if (bnxt_check_zero_bytes(bp->dflt_mac_addr, RTE_ETHER_ADDR_LEN)) {
+		if (BNXT_PF(bp))
+			return -EINVAL;
+
+		/* Generate a random MAC address, if none was assigned by PF */
+		PMD_DRV_LOG(INFO, "VF MAC address not assigned by Host PF\n");
+		bnxt_eth_hw_addr_random(bp->mac_addr);
+		PMD_DRV_LOG(INFO,
+			    "Assign random MAC:%02X:%02X:%02X:%02X:%02X:%02X\n",
+			    bp->mac_addr[0], bp->mac_addr[1], bp->mac_addr[2],
+			    bp->mac_addr[3], bp->mac_addr[4], bp->mac_addr[5]);
+
+		rc = bnxt_hwrm_set_mac(bp);
+		if (!rc)
+			memcpy(&bp->eth_dev->data->mac_addrs[0], bp->mac_addr,
+			       RTE_ETHER_ADDR_LEN);
+		return rc;
+	}
+
+	/* Copy the permanent MAC from the FUNC_QCAPS response */
+	memcpy(bp->mac_addr, bp->dflt_mac_addr, RTE_ETHER_ADDR_LEN);
+	memcpy(&eth_dev->data->mac_addrs[0], bp->mac_addr, RTE_ETHER_ADDR_LEN);
+
+	return rc;
+}
+
 #define ALLOW_FUNC(x)	\
 	{ \
 		uint32_t arg = (x); \
@@ -3840,28 +3880,10 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
 		rc = -EBUSY;
 		goto error_free;
 	}
-	eth_dev->data->mac_addrs = rte_zmalloc("bnxt_mac_addr_tbl",
-					RTE_ETHER_ADDR_LEN * bp->max_l2_ctx, 0);
-	if (eth_dev->data->mac_addrs == NULL) {
-		PMD_DRV_LOG(ERR,
-			"Failed to alloc %u bytes needed to store MAC addr tbl",
-			RTE_ETHER_ADDR_LEN * bp->max_l2_ctx);
-		rc = -ENOMEM;
-		goto error_free;
-	}
 
-	if (bnxt_check_zero_bytes(bp->dflt_mac_addr, RTE_ETHER_ADDR_LEN)) {
-		PMD_DRV_LOG(ERR,
-			    "Invalid MAC addr %02X:%02X:%02X:%02X:%02X:%02X\n",
-			    bp->dflt_mac_addr[0], bp->dflt_mac_addr[1],
-			    bp->dflt_mac_addr[2], bp->dflt_mac_addr[3],
-			    bp->dflt_mac_addr[4], bp->dflt_mac_addr[5]);
-		rc = -EINVAL;
+	rc = bnxt_setup_mac_addr(eth_dev);
+	if (rc)
 		goto error_free;
-	}
-	/* Copy the permanent MAC from the qcap response address now. */
-	memcpy(bp->mac_addr, bp->dflt_mac_addr, sizeof(bp->mac_addr));
-	memcpy(&eth_dev->data->mac_addrs[0], bp->mac_addr, RTE_ETHER_ADDR_LEN);
 
 	/* THOR does not support ring groups.
 	 * But we will use the array to save RSS context IDs.
drivers/net/bnxt/bnxt_hwrm.c +25 -0
index f691922bd..a9356c6b8 100644
@@ -4607,3 +4607,28 @@ int bnxt_hwrm_tunnel_redirect_info(struct bnxt *bp, uint8_t tun_type,
 
 	return rc;
 }
+
+int bnxt_hwrm_set_mac(struct bnxt *bp)
+{
+	struct hwrm_func_vf_cfg_output *resp = bp->hwrm_cmd_resp_addr;
+	struct hwrm_func_vf_cfg_input req = {0};
+	int rc = 0;
+
+	if (!BNXT_VF(bp))
+		return 0;
+
+	HWRM_PREP(req, FUNC_VF_CFG, BNXT_USE_CHIMP_MB);
+
+	req.enables =
+		rte_cpu_to_le_32(HWRM_FUNC_VF_CFG_INPUT_ENABLES_DFLT_MAC_ADDR);
+	memcpy(req.dflt_mac_addr, bp->mac_addr, RTE_ETHER_ADDR_LEN);
+
+	rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
+
+	HWRM_CHECK_RESULT();
+
+	memcpy(bp->dflt_mac_addr, bp->mac_addr, RTE_ETHER_ADDR_LEN);
+	HWRM_UNLOCK();
+
+	return rc;
+}
drivers/net/bnxt/bnxt_hwrm.h +1 -0
index e35462cb4..37aaa1a9e 100644
@@ -196,4 +196,5 @@ int bnxt_hwrm_tunnel_redirect_free(struct bnxt *bp, uint8_t type);
 int bnxt_hwrm_tunnel_redirect_query(struct bnxt *bp, uint32_t *type);
 int bnxt_hwrm_tunnel_redirect_info(struct bnxt *bp, uint8_t tun_type,
 				   uint16_t *dst_fid);
+int bnxt_hwrm_set_mac(struct bnxt *bp);
 #endif
drivers/net/bnxt/bnxt_util.c +11 -0
index 7d3342719..dda40af28 100644
@@ -4,6 +4,7 @@
  */
 
 #include <inttypes.h>
+#include <rte_ether.h>
 
 #include "bnxt_util.h"
 
@@ -16,3 +17,13 @@ int bnxt_check_zero_bytes(const uint8_t *bytes, int len)
 			return 0;
 	return 1;
 }
+
+void bnxt_eth_hw_addr_random(uint8_t *mac_addr)
+{
+	rte_eth_random_addr(mac_addr);
+
+	/* Set Organizationally Unique Identifier (OUI) prefix */
+	mac_addr[0] = 0x00;
+	mac_addr[1] = 0x0a;
+	mac_addr[2] = 0xf7;
+}
drivers/net/bnxt/bnxt_util.h +1 -0
index 2378833cc..9f1868a78 100644
@@ -7,5 +7,6 @@
 #define _BNXT_UTIL_H_
 
 int bnxt_check_zero_bytes(const uint8_t *bytes, int len);
+void bnxt_eth_hw_addr_random(uint8_t *mac_addr);
 
 #endif /* _BNXT_UTIL_H_ */
Signature · 1 line
2.20.1 (Apple Git-117)
#41 lore raw

PATCH v3 4/15 net/bnxt: fix Tx hang after port stop/start

In reply to Ajit Khaparde

From: Lance Richardson <[email protected]>

Initialize the state of the the completion valid indicator when a completion ring is freed, otherwise completions may not be processed when a new ring is allocated.

Fixes 5735eb241947 ("net/bnxt: support Tx batching")
---
 drivers/net/bnxt/bnxt_hwrm.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/bnxt/bnxt_hwrm.c +1 -0
index a9356c6b8..b6f9ec0a0 100644
@@ -2089,6 +2089,7 @@ static void bnxt_free_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
 	memset(cpr->cp_desc_ring, 0, cpr->cp_ring_struct->ring_size *
 			sizeof(*cpr->cp_desc_ring));
 	cpr->cp_raw_cons = 0;
+	cpr->valid = 0;
 }
 
 void bnxt_free_hwrm_rx_ring(struct bnxt *bp, int queue_index)
Signature · 1 line
2.20.1 (Apple Git-117)
#42 lore raw

PATCH v3 5/15 net/bnxt: reset Rx allocation state on port restart

In reply to Ajit Khaparde

From: Lance Richardson <[email protected]>

Move call site of bnxt_rxq_vec_setup() to ensure that rxq->rxrearm_nb and rxq->rxrearm_start are reinitialized correctly when a port is restarted.

Fixes bc4a000f2f53 ("net/bnxt: implement SSE vector mode")

--
v1->v2: Move bnxt_rxq_vec_setup under RTE_ARCH_X86.

---
 drivers/net/bnxt/bnxt_ring.c | 3 +++
 drivers/net/bnxt/bnxt_rxq.c  | 4 ----
 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/net/bnxt/bnxt_ring.c +3 -0
index 16327dbe9..7453d4b56 100644
@@ -613,6 +613,9 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
 		bnxt_db_write(&rxr->rx_db, rxr->rx_prod);
 		bnxt_db_write(&rxr->ag_db, rxr->ag_prod);
 		rxq->index = i;
+#ifdef RTE_ARCH_X86
+		bnxt_rxq_vec_setup(rxq);
+#endif
 	}
 
 	for (i = 0; i < bp->tx_cp_nr_rings; i++) {
drivers/net/bnxt/bnxt_rxq.c +0 -4
index 6919acbb4..c94cac5a9 100644
@@ -356,10 +356,6 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
 	eth_dev->data->rx_queue_state[queue_idx] = queue_state;
 	rte_spinlock_init(&rxq->lock);
 
-#ifdef RTE_ARCH_X86
-	bnxt_rxq_vec_setup(rxq);
-#endif
-
 out:
 	return rc;
 }
Signature · 1 line
2.20.1 (Apple Git-117)
#43 lore raw

PATCH v3 6/15 net/bnxt: fix L4 checksum error indication in Rx path

In reply to Ajit Khaparde

From: Rahul Gupta <[email protected]>

Update ol_flags correctly for checksum errors in case of tunnel and non-tunnel packet.

Fixes 65ee636872eb ("net/bnxt: fix Rx checksum flags")

--
v1->v3: Fix check-git-log output.

---
 drivers/net/bnxt/bnxt_rxr.c |  43 ++++++++++---
 drivers/net/bnxt/bnxt_rxr.h | 120 ++++++++++++++++++++++++++++++------
 2 files changed, 133 insertions(+), 30 deletions(-)
drivers/net/bnxt/bnxt_rxr.c +33 -10
index 44303f3b0..54a2cf5fd 100644
@@ -362,6 +362,7 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
 	int rc = 0;
 	uint8_t agg_buf = 0;
 	uint16_t cmp_type;
+	uint32_t flags2_f = 0;
 
 	rxcmp = (struct rx_pkt_cmpl *)
 	    &cpr->cp_desc_ring[cp_cons];
@@ -440,19 +441,41 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
 		mbuf->ol_flags |= PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED;
 	}
 
-	if (likely(RX_CMP_IP_CS_OK(rxcmp1)))
-		mbuf->ol_flags |= PKT_RX_IP_CKSUM_GOOD;
-	else if (likely(RX_CMP_IP_CS_UNKNOWN(rxcmp1)))
-		mbuf->ol_flags |= PKT_RX_IP_CKSUM_UNKNOWN;
-	else
+	flags2_f = flags2_0xf(rxcmp1);
+	/* IP Checksum */
+	if (unlikely(((IS_IP_NONTUNNEL_PKT(flags2_f)) &&
+		      (RX_CMP_IP_CS_ERROR(rxcmp1))) ||
+		     (IS_IP_TUNNEL_PKT(flags2_f) &&
+		      (RX_CMP_IP_OUTER_CS_ERROR(rxcmp1))))) {
 		mbuf->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+	} else if (unlikely(RX_CMP_IP_CS_UNKNOWN(rxcmp1))) {
+		mbuf->ol_flags |= PKT_RX_IP_CKSUM_UNKNOWN;
+	} else {
+		mbuf->ol_flags |= PKT_RX_IP_CKSUM_GOOD;
+	}
 
-	if (likely(RX_CMP_L4_CS_OK(rxcmp1)))
-		mbuf->ol_flags |= PKT_RX_L4_CKSUM_GOOD;
-	else if (likely(RX_CMP_L4_CS_UNKNOWN(rxcmp1)))
+	/* L4 Checksum */
+	if (likely(IS_L4_NONTUNNEL_PKT(flags2_f))) {
+		if (unlikely(RX_CMP_L4_INNER_CS_ERR2(rxcmp1)))
+			mbuf->ol_flags |= PKT_RX_L4_CKSUM_BAD;
+		else
+			mbuf->ol_flags |= PKT_RX_L4_CKSUM_GOOD;
+	} else if (IS_L4_TUNNEL_PKT(flags2_f)) {
+		if (unlikely(RX_CMP_L4_INNER_CS_ERR2(rxcmp1)))
+			mbuf->ol_flags |= PKT_RX_L4_CKSUM_BAD;
+		else
+			mbuf->ol_flags |= PKT_RX_L4_CKSUM_GOOD;
+		if (unlikely(RX_CMP_L4_OUTER_CS_ERR2(rxcmp1))) {
+			mbuf->ol_flags |= PKT_RX_OUTER_L4_CKSUM_BAD;
+		} else if (unlikely(IS_L4_TUNNEL_PKT_ONLY_INNER_L4_CS
+				    (flags2_f))) {
+			mbuf->ol_flags |= PKT_RX_OUTER_L4_CKSUM_UNKNOWN;
+		} else {
+			mbuf->ol_flags |= PKT_RX_OUTER_L4_CKSUM_GOOD;
+		}
+	} else if (unlikely(RX_CMP_L4_CS_UNKNOWN(rxcmp1))) {
 		mbuf->ol_flags |= PKT_RX_L4_CKSUM_UNKNOWN;
-	else
-		mbuf->ol_flags |= PKT_RX_L4_CKSUM_BAD;
+	}
 
 	mbuf->packet_type = bnxt_parse_pkt_type(rxcmp, rxcmp1);
 
drivers/net/bnxt/bnxt_rxr.h +100 -20

136 lines not on this page · raw message

Signature · 1 line
2.20.1 (Apple Git-117)
#44 lore raw

PATCH v3 7/15 net/bnxt: fix for doorbell register offset for Tx ring

In reply to Ajit Khaparde

For Tx-ring # 104 and higher, the doorbell register was incorrectly configured due to which FW was not able to receive the notification of packet to transmit. With this fix, user can run traffic upto 256 rings.

Fixes 6eb3cc2294fd ("net/bnxt: add initial Tx code")

--
v1->v3: Fix output of check-git-log.

---
 drivers/net/bnxt/bnxt_ring.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/bnxt/bnxt_ring.c +2 -2
index 7453d4b56..9b19459b6 100644
@@ -639,12 +639,12 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
 		ring_type = HWRM_RING_ALLOC_INPUT_RING_TYPE_TX;
 		rc = bnxt_hwrm_ring_alloc(bp, ring,
 					  ring_type,
-					  idx, cpr->hw_stats_ctx_id,
+					  i, cpr->hw_stats_ctx_id,
 					  cp_ring->fw_ring_id);
 		if (rc)
 			goto err_out;
 
-		bnxt_set_db(bp, &txr->tx_db, ring_type, idx, ring->fw_ring_id);
+		bnxt_set_db(bp, &txr->tx_db, ring_type, i, ring->fw_ring_id);
 		txq->index = idx;
 		bnxt_hwrm_set_ring_coal(bp, &coal, cp_ring->fw_ring_id);
 	}
Signature · 1 line
2.20.1 (Apple Git-117)
#45 lore raw

PATCH v3 8/15 net/bnxt: save the number of EM flow count

In reply to Ajit Khaparde

Save the number of EM flow count returned by the FW in HWRM_FUNC_QCFG and use it to calculate the overall pool of L2 contexts supported by FW.

Fixes 6d8109bcb398 ("net/bnxt: check VF resources if resource manager is enabled")
---
 drivers/net/bnxt/bnxt.h      |  1 +
 drivers/net/bnxt/bnxt_hwrm.c | 11 +++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)
drivers/net/bnxt/bnxt.h +1 -0
index 45e7359b2..cd809b385 100644
@@ -429,6 +429,7 @@ struct bnxt {
 	uint16_t		max_rx_rings;
 	uint16_t		max_nq_rings;
 	uint16_t		max_l2_ctx;
+	uint16_t		max_rx_em_flows;
 	uint16_t		max_vnics;
 	uint16_t		max_stat_ctx;
 	uint16_t		first_vf_id;
drivers/net/bnxt/bnxt_hwrm.c +9 -2
index b6f9ec0a0..84cda5e6c 100644
@@ -589,8 +589,10 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
 	bp->max_cp_rings = rte_le_to_cpu_16(resp->max_cmpl_rings);
 	bp->max_tx_rings = rte_le_to_cpu_16(resp->max_tx_rings);
 	bp->max_rx_rings = rte_le_to_cpu_16(resp->max_rx_rings);
-	bp->max_l2_ctx = rte_le_to_cpu_16(resp->max_l2_ctxs);
 	bp->first_vf_id = rte_le_to_cpu_16(resp->first_vf_id);
+	bp->max_rx_em_flows = rte_le_to_cpu_16(resp->max_rx_em_flows);
+	bp->max_l2_ctx =
+		rte_le_to_cpu_16(resp->max_l2_ctxs) + bp->max_rx_em_flows;
 	/* TODO: For now, do not support VMDq/RFS on VFs. */
 	if (BNXT_PF(bp)) {
 		if (bp->pf.max_vfs)
@@ -796,7 +798,12 @@ int bnxt_hwrm_func_resc_qcaps(struct bnxt *bp)
 		bp->max_tx_rings = rte_le_to_cpu_16(resp->max_tx_rings);
 		bp->max_rx_rings = rte_le_to_cpu_16(resp->max_rx_rings);
 		bp->max_ring_grps = rte_le_to_cpu_32(resp->max_hw_ring_grps);
-		bp->max_l2_ctx = rte_le_to_cpu_16(resp->max_l2_ctxs);
+		/* func_resource_qcaps does not return max_rx_em_flows.
+		 * So use the value provided by func_qcaps.
+		 */
+		bp->max_l2_ctx =
+			rte_le_to_cpu_16(resp->max_l2_ctxs) +
+			bp->max_rx_em_flows;
 		bp->max_vnics = rte_le_to_cpu_16(resp->max_vnics);
 		bp->max_stat_ctx = rte_le_to_cpu_16(resp->max_stat_ctx);
 	}
Signature · 1 line
2.20.1 (Apple Git-117)
#46 lore raw

PATCH v3 9/15 net/bnxt: nq doorbell cleanups

In reply to Ajit Khaparde

From: Lance Richardson <[email protected]>

Simplify nq doorbell handling code by removing redundant db parameter and consolidating NQ doorbell macro into the inline function that uses it.

Add "enable interrupt" variant of nq write. This will be used in a subsequent commit.

When initializing nq doorbell, don't assume that only the "disable interrupt" form will be used.

Fixes f8168ca0e690 ("net/bnxt: support thor controller")
---
 drivers/net/bnxt/bnxt.h      |  1 +
 drivers/net/bnxt/bnxt_ring.c |  2 +-
 drivers/net/bnxt/bnxt_ring.h | 23 ++++++++++++++++++-----
 3 files changed, 20 insertions(+), 6 deletions(-)
drivers/net/bnxt/bnxt.h +1 -0
index cd809b385..3ccf784e5 100644
@@ -246,6 +246,7 @@ struct bnxt_coal {
 #define DBR_TYPE_SRQ				(0x2ULL << 60)
 #define DBR_TYPE_CQ				(0x4ULL << 60)
 #define DBR_TYPE_NQ				(0xaULL << 60)
+#define DBR_TYPE_NQ_ARM				(0xbULL << 60)
 
 #define BNXT_RSS_TBL_SIZE_THOR		512
 #define BNXT_RSS_ENTRIES_PER_CTX_THOR	64
drivers/net/bnxt/bnxt_ring.c +1 -1
index 9b19459b6..faf861cc1 100644
@@ -341,7 +341,7 @@ static void bnxt_set_db(struct bnxt *bp,
 			db->db_key64 = DBR_PATH_L2 | DBR_TYPE_CQ;
 			break;
 		case HWRM_RING_ALLOC_INPUT_RING_TYPE_NQ:
-			db->db_key64 = DBR_PATH_L2 | DBR_TYPE_NQ;
+			db->db_key64 = DBR_PATH_L2;
 			break;
 		}
 		db->db_key64 |= (uint64_t)fid << DBR_XID_SFT;
drivers/net/bnxt/bnxt_ring.h +18 -5
index af2c5762f..e5cef3a1d 100644
@@ -84,15 +84,28 @@ static inline void bnxt_db_write(struct bnxt_db_info *db, uint32_t idx)
 		rte_write32(db->db_key32 | idx, db->doorbell);
 }
 
+/* Ring an NQ doorbell and disable interrupts for the ring. */
 static inline void bnxt_db_nq(struct bnxt_cp_ring_info *cpr)
 {
-	struct bnxt_db_info *db = &cpr->cp_db;
+	if (unlikely(!cpr->cp_db.db_64))
+		return;
+
+	rte_smp_wmb();
+	rte_write64(cpr->cp_db.db_key64 | DBR_TYPE_NQ |
+		    RING_CMP(cpr->cp_ring_struct, cpr->cp_raw_cons),
+		    cpr->cp_db.doorbell);
+}
+
+/* Ring an NQ doorbell and enable interrupts for the ring. */
+static inline void bnxt_db_nq_arm(struct bnxt_cp_ring_info *cpr)
+{
+	if (unlikely(!cpr->cp_db.db_64))
+		return;
 
 	rte_smp_wmb();
-	if (likely(db->db_64))
-		rte_write64(db->db_key64 | DBR_TYPE_NQ |
-			    RING_CMP(cpr->cp_ring_struct, cpr->cp_raw_cons),
-			    db->doorbell);
+	rte_write64(cpr->cp_db.db_key64 | DBR_TYPE_NQ_ARM |
+		    RING_CMP(cpr->cp_ring_struct, cpr->cp_raw_cons),
+		    cpr->cp_db.doorbell);
 }
 
 static inline void bnxt_db_cq(struct bnxt_cp_ring_info *cpr)
Signature · 1 line
2.20.1 (Apple Git-117)
#47 lore raw

PATCH v3 10/15 net/bnxt: avoid null pointer dereference

In reply to Ajit Khaparde

From: Lance Richardson <[email protected]>

Avoid null pointer dereference when allocating an insolated completion ring by basing nq ring allocation on whether an nq ring was requested instead of whether the device supports nq rings.

Fixes f8168ca0e690 ("net/bnxt: support thor controller")
---
 drivers/net/bnxt/bnxt_ring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bnxt/bnxt_ring.c +1 -1
index faf861cc1..ada748c05 100644
@@ -280,7 +280,7 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
 	}
 	cp_ring_info->hw_stats_ctx_id = HWRM_NA_SIGNATURE;
 
-	if (BNXT_HAS_NQ(bp)) {
+	if (nq_ring_info) {
 		struct bnxt_ring *nq_ring = nq_ring_info->cp_ring_struct;
 
 		nq_ring->bd = (char *)mz->addr + nq_ring_start;
Signature · 1 line
2.20.1 (Apple Git-117)
#48 lore raw

PATCH v3 11/15 net/bnxt: fix to enable disable interrupts correctly

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

1. disable interrupts in dev_stop_op()
2. enable interrupts in dev_start_op()
3. Clean queue intr-vector mapping in dev_stop_op() and thus fix a possible memory leak.

Fixes c09f57b49c13 ("net/bnxt: add start/stop/link update operations")

--
v1->v3: Fix errors reported by check-git-log script.

---
 drivers/net/bnxt/bnxt_ethdev.c | 17 ++++++++++++++++-
 drivers/net/bnxt/bnxt_irq.c    |  2 --
 2 files changed, 16 insertions(+), 3 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +16 -1
index e44df1881..538bed1a5 100644
@@ -779,6 +779,7 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
 
 	eth_dev->rx_pkt_burst = bnxt_receive_function(eth_dev);
 	eth_dev->tx_pkt_burst = bnxt_transmit_function(eth_dev);
+	bnxt_enable_int(bp);
 	bp->flags |= BNXT_FLAG_INIT_DONE;
 	return 0;
 
@@ -818,6 +819,13 @@ static int bnxt_dev_set_link_down_op(struct rte_eth_dev *eth_dev)
 static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
 {
 	struct bnxt *bp = eth_dev->data->dev_private;
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
+
+	bnxt_disable_int(bp);
+
+	/* disable uio/vfio intr/eventfd mapping */
+	rte_intr_disable(intr_handle);
 
 	bp->flags &= ~BNXT_FLAG_INIT_DONE;
 	if (bp->eth_dev->data->dev_started) {
@@ -825,6 +833,14 @@ static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
 		eth_dev->data->dev_link.link_status = 0;
 	}
 	bnxt_set_hwrm_link_config(bp, false);
+
+	/* Clean queue intr-vector mapping */
+	rte_intr_efd_disable(intr_handle);
+	if (intr_handle->intr_vec != NULL) {
+		rte_free(intr_handle->intr_vec);
+		intr_handle->intr_vec = NULL;
+	}
+
 	bnxt_hwrm_port_clr_stats(bp);
 	bnxt_free_tx_mbufs(bp);
 	bnxt_free_rx_mbufs(bp);
@@ -3991,7 +4007,6 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
 	if (rc)
 		goto error_free_int;
 
-	bnxt_enable_int(bp);
 	bnxt_init_nic(bp);
 
 	return 0;
drivers/net/bnxt/bnxt_irq.c +0 -2
index 61f7498a5..6c4dce401 100644
@@ -58,7 +58,6 @@ void bnxt_free_int(struct bnxt *bp)
 	irq = bp->irq_tbl;
 	if (irq) {
 		if (irq->requested) {
-			rte_intr_disable(&bp->pdev->intr_handle);
 			rte_intr_callback_unregister(&bp->pdev->intr_handle,
 						     irq->handler,
 						     (void *)bp->eth_dev);
@@ -123,7 +122,6 @@ int bnxt_request_int(struct bnxt *bp)
 
 	rte_intr_callback_register(&bp->pdev->intr_handle, irq->handler,
 				   (void *)bp->eth_dev);
-	rte_intr_enable(&bp->pdev->intr_handle);
 
 	irq->requested = 1;
 	return rc;
Signature · 1 line
2.20.1 (Apple Git-117)
#49 lore raw

PATCH v3 12/15 net/bnxt: fix to check for invalid VNIC in cleanup path

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

The cleanup/rollback operation post rte_eth_dev_start failure might end up invoking an HWRM cmd even on an invalid vNIC resulting in error messages being logged needlessly.
Fix to check for the same before issuing the HWRM cmd.

Fixes c09f57b49c13 ("net/bnxt: add start/stop/link update operations")
---
 drivers/net/bnxt/bnxt_hwrm.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/bnxt/bnxt_hwrm.c +5 -0
index 84cda5e6c..1a0265f8a 100644
@@ -2325,6 +2325,11 @@ void bnxt_free_all_hwrm_resources(struct bnxt *bp)
 	for (i = bp->nr_vnics - 1; i >= 0; i--) {
 		struct bnxt_vnic_info *vnic = &bp->vnic_info[i];
 
+		if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
+			PMD_DRV_LOG(DEBUG, "Invalid vNIC ID\n");
+			return;
+		}
+
 		bnxt_clear_hwrm_vnic_flows(bp, vnic);
 
 		bnxt_clear_hwrm_vnic_filters(bp, vnic);
Signature · 1 line
2.20.1 (Apple Git-117)
#50 lore raw

PATCH v3 13/15 net/bnxt: fix a compilation warning

In reply to Ajit Khaparde

Compiler complains of an uninitialized variable.
Initializing it to avoid the issue.

Fixes db678d5c2b54 ("net/bnxt: add HWRM VNIC configure")
---
 drivers/net/bnxt/bnxt_hwrm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bnxt/bnxt_hwrm.c +1 -1
index 1a0265f8a..a4e0c2e0c 100644
@@ -1523,8 +1523,8 @@ int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic)
 	int rc = 0;
 	struct hwrm_vnic_cfg_input req = {.req_type = 0 };
 	struct hwrm_vnic_cfg_output *resp = bp->hwrm_cmd_resp_addr;
+	struct bnxt_plcmodes_cfg pmodes = { 0 };
 	uint32_t ctx_enable_flag = 0;
-	struct bnxt_plcmodes_cfg pmodes;
 	uint32_t enables = 0;
 
 	if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
Signature · 1 line
2.20.1 (Apple Git-117)
#51 lore raw

PATCH v3 14/15 net/bnxt: fix rxq count if ntuple filtering is disabled

In reply to Ajit Khaparde

From: Qingmin Liu <[email protected]>

If ntuple filtering is disabled, FW will return max_vnics=1. Due to this only single Rxq is created.
Change to max_rx_rings = RTE_MIN(bp->max_rx_rings, bp->max_stat_ctx) to fix it.

Fixes 6d8109bcb398 ("net/bnxt: check VF resources if resource manager is enabled")
---
 drivers/net/bnxt/bnxt_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bnxt/bnxt_ethdev.c +1 -1
index 538bed1a5..cd87d0dbc 100644
@@ -493,7 +493,7 @@ static void bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
 	/* PF/VF specifics */
 	if (BNXT_PF(bp))
 		dev_info->max_vfs = bp->pdev->max_vfs;
-	max_rx_rings = RTE_MIN(bp->max_vnics, bp->max_stat_ctx);
+	max_rx_rings = RTE_MIN(bp->max_rx_rings, bp->max_stat_ctx);
 	/* For the sake of symmetry, max_rx_queues = max_tx_queues */
 	dev_info->max_rx_queues = max_rx_rings;
 	dev_info->max_tx_queues = max_rx_rings;
Signature · 1 line
2.20.1 (Apple Git-117)
#52 lore raw

PATCH v3 15/15 net/bnxt: fix to avoid sending invalid VNIC id to firmware

In reply to Ajit Khaparde

From: Jay Ding <[email protected]>

Add checking for vinc id before sending message to chimp in bnxt_hwrm_vnic_plcmode_cfg().

Fixes db678d5c2b54 ("net/bnxt: add HWRM VNIC configure")
---
 drivers/net/bnxt/bnxt_hwrm.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/bnxt/bnxt_hwrm.c +5 -0
index a4e0c2e0c..313459aaf 100644
@@ -1497,6 +1497,11 @@ static int bnxt_hwrm_vnic_plcmodes_cfg(struct bnxt *bp,
 	struct hwrm_vnic_plcmodes_cfg_input req = {.req_type = 0 };
 	struct hwrm_vnic_plcmodes_cfg_output *resp = bp->hwrm_cmd_resp_addr;
 
+	if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
+		PMD_DRV_LOG(DEBUG, "VNIC ID %x\n", vnic->fw_vnic_id);
+		return rc;
+	}
+
 	HWRM_PREP(req, VNIC_PLCMODES_CFG, BNXT_USE_CHIMP_MB);
 
 	req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
Signature · 1 line
2.20.1 (Apple Git-117)
#53 lore raw
In reply to Ajit Khaparde
Quoted 24 lines · Ajit Khaparde

Patchset fixing various bugs in bnxt PMD based on recent commit:
1e101412320061a4a1cd47db4227b4f8a163e9f6

Ajit Khaparde (3):
net/bnxt: fix for doorbell register offset for Tx ring net/bnxt: save the number of EM flow count net/bnxt: fix a compilation warning

Jay Ding (1):
net/bnxt: fix to avoid sending invalid VNIC id to firmware

Kalesh AP (5):
net/bnxt: fix extended port counter statistics net/bnxt: fix possible segfault in case of probe failure net/bnxt: do not fail VF probe when the MAC address is zero net/bnxt: fix to enable disable interrupts correctly net/bnxt: fix to check for invalid VNIC in cleanup path

Lance Richardson (4):
net/bnxt: fix Tx hang after port stop/start net/bnxt: reset Rx allocation state on port restart net/bnxt: nq doorbell cleanups
net/bnxt: avoid null pointer dereference

Quoted 5 lines

Qingmin Liu (1):
net/bnxt: fix rxq count if ntuple filtering is disabled

Rahul Gupta (1):
net/bnxt: fix L4 checksum error indication in Rx path

Series applied to dpdk-next-net/master, thanks.