Skip to contentSkip to conversation

bnxt patchset

PATCH Superseded Ajit Khaparde 3 participants 11 messages Apr 20, 2018 Network drivers

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover bnxt patchset

Please apply.

Ajit Khaparde (3):
net/bnxt: cache address of doorbell to subsequent access net/bnxt: fix set_rx_mask from using invalid vnic id net/bnxt: fix mbuf data_off initialization

 drivers/net/bnxt/bnxt.h        |  1 +
 drivers/net/bnxt/bnxt_cpr.c    |  2 +-
 drivers/net/bnxt/bnxt_ethdev.c | 19 ++++++++++++++-----
 drivers/net/bnxt/bnxt_hwrm.c   |  3 +++
 drivers/net/bnxt/bnxt_ring.c   | 17 +++++------------
 drivers/net/bnxt/bnxt_rxr.c    |  2 ++
 6 files changed, 26 insertions(+), 18 deletions(-)
Signature · 1 line
2.15.1 (Apple Git-101)
#1 lore raw

PATCH v2 1/3 net/bnxt: cache address of doorbell to subsequent access

While creating TX, Rx, CQ rings use cached DB address instead of getting it from the PCI memory resource.

---
 drivers/net/bnxt/bnxt.h        |  1 +
 drivers/net/bnxt/bnxt_cpr.c    |  2 +-
 drivers/net/bnxt/bnxt_ethdev.c | 12 ++++++++++++
 drivers/net/bnxt/bnxt_ring.c   | 17 +++++------------
 4 files changed, 19 insertions(+), 13 deletions(-)
drivers/net/bnxt/bnxt.h +1 -0
index bdca2622f..97b0e0853 100644
@@ -208,6 +208,7 @@ struct bnxt {
 	struct rte_eth_dev		*eth_dev;
 	struct rte_eth_rss_conf		rss_conf;
 	struct rte_pci_device		*pdev;
+	void				*doorbell_base;
 
 	uint32_t		flags;
 #define BNXT_FLAG_REGISTERED	(1 << 0)
drivers/net/bnxt/bnxt_cpr.c +1 -1
index 5ac197ea7..8dde8cc0f 100644
@@ -144,7 +144,7 @@ int bnxt_alloc_def_cp_ring(struct bnxt *bp)
 				  HWRM_NA_SIGNATURE);
 	if (rc)
 		goto err_out;
-	cpr->cp_doorbell = bp->pdev->mem_resource[2].addr;
+	cpr->cp_doorbell = (char *)bp->doorbell_base;
 	B_CP_DIS_DB(cpr, cpr->cp_raw_cons);
 	if (BNXT_PF(bp))
 		rc = bnxt_hwrm_func_cfg_def_cp(bp);
drivers/net/bnxt/bnxt_ethdev.c +12 -0
index 7632c326b..a133114a3 100644
@@ -3095,11 +3095,23 @@ static int bnxt_init_board(struct rte_eth_dev *eth_dev)
 		rc = -ENOMEM;
 		goto init_err_release;
 	}
+
+	if (!pci_dev->mem_resource[2].addr) {
+		PMD_DRV_LOG(ERR,
+			    "Cannot find PCI device BAR 2 address, aborting\n");
+		rc = -ENODEV;
+		goto init_err_release;
+	} else {
+		bp->doorbell_base = (void *)pci_dev->mem_resource[2].addr;
+	}
+
 	return 0;
 
 init_err_release:
 	if (bp->bar0)
 		bp->bar0 = NULL;
+	if (bp->doorbell_base)
+		bp->doorbell_base = NULL;
 
 init_err_disable:
 
drivers/net/bnxt/bnxt_ring.c +5 -12
index 478eab4f3..8e822e11f 100644
@@ -261,7 +261,6 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
  */
 int bnxt_alloc_hwrm_rings(struct bnxt *bp)
 {
-	struct rte_pci_device *pci_dev = bp->pdev;
 	unsigned int i;
 	int rc = 0;
 
@@ -283,8 +282,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
 					HWRM_NA_SIGNATURE);
 		if (rc)
 			goto err_out;
-		cpr->cp_doorbell = (char *)pci_dev->mem_resource[2].addr +
-		    idx * 0x80;
+		cpr->cp_doorbell = (char *)bp->doorbell_base + idx * 0x80;
 		bp->grp_info[i].cp_fw_ring_id = cp_ring->fw_ring_id;
 		B_CP_DIS_DB(cpr, cpr->cp_raw_cons);
 
@@ -296,8 +294,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
 		if (rc)
 			goto err_out;
 		rxr->rx_prod = 0;
-		rxr->rx_doorbell = (char *)pci_dev->mem_resource[2].addr +
-		    idx * 0x80;
+		rxr->rx_doorbell = (char *)bp->doorbell_base + idx * 0x80;
 		bp->grp_info[i].rx_fw_ring_id = ring->fw_ring_id;
 		B_RX_DB(rxr->rx_doorbell, rxr->rx_prod);
 
@@ -316,9 +313,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
 			goto err_out;
 		PMD_DRV_LOG(DEBUG, "Alloc AGG Done!\n");
 		rxr->ag_prod = 0;
-		rxr->ag_doorbell =
-		    (char *)pci_dev->mem_resource[2].addr +
-		    map_idx * 0x80;
+		rxr->ag_doorbell = (char *)bp->doorbell_base + map_idx * 0x80;
 		bp->grp_info[i].ag_fw_ring_id = ring->fw_ring_id;
 		B_RX_DB(rxr->ag_doorbell, rxr->ag_prod);
 
@@ -350,8 +345,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
 		if (rc)
 			goto err_out;
 
-		cpr->cp_doorbell = (char *)pci_dev->mem_resource[2].addr +
-		    idx * 0x80;
+		cpr->cp_doorbell = (char *)bp->doorbell_base + idx * 0x80;
 		B_CP_DIS_DB(cpr, cpr->cp_raw_cons);
 
 		/* Tx ring */
@@ -362,8 +356,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
 		if (rc)
 			goto err_out;
 
-		txr->tx_doorbell = (char *)pci_dev->mem_resource[2].addr +
-		    idx * 0x80;
+		txr->tx_doorbell = (char *)bp->doorbell_base + idx * 0x80;
 		txq->index = idx;
 	}
 
Signature · 1 line
2.15.1 (Apple Git-101)
#2 lore raw

PATCH v2 2/3 net/bnxt: fix set_rx_mask from using invalid vnic id

In reply to Ajit Khaparde

In some cases bnxt_hwrm_cfa_l2_set_rx_mask is being called before VNICs are allocated. The FW returns an error in such cases. Move bnxt_init_nic to bnxt_dev_init such that the ids are initialized to an invalid id.
Prevent sending the command to the FW only with a valid vnic id.

Fixes 244bc98b0da7 ("net/bnxt: set L2 Rx mask")

--
v1->v2: update commit message and commit log

---
 drivers/net/bnxt/bnxt_ethdev.c | 7 ++-----
 drivers/net/bnxt/bnxt_hwrm.c   | 3 +++
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +2 -5
index a133114a3..348129dad 100644
@@ -395,10 +395,6 @@ static int bnxt_init_nic(struct bnxt *bp)
 	bnxt_init_vnics(bp);
 	bnxt_init_filters(bp);
 
-	rc = bnxt_init_chip(bp);
-	if (rc)
-		return rc;
-
 	return 0;
 }
 
@@ -594,7 +590,7 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
 	}
 	bp->dev_stopped = 0;
 
-	rc = bnxt_init_nic(bp);
+	rc = bnxt_init_chip(bp);
 	if (rc)
 		goto error;
 
@@ -3398,6 +3394,7 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
 		goto error_free_int;
 
 	bnxt_enable_int(bp);
+	bnxt_init_nic(bp);
 
 	return 0;
 
drivers/net/bnxt/bnxt_hwrm.c +3 -0
index 11204bf42..bc8773509 100644
@@ -221,6 +221,9 @@ int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt *bp,
 	struct hwrm_cfa_l2_set_rx_mask_output *resp = bp->hwrm_cmd_resp_addr;
 	uint32_t mask = 0;
 
+	if (vnic->fw_vnic_id == INVALID_HW_RING_ID)
+		return rc;
+
 	HWRM_PREP(req, CFA_L2_SET_RX_MASK);
 	req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
 
Signature · 1 line
2.15.1 (Apple Git-101)
#3 lore raw

PATCH v2 3/3 net/bnxt: fix mbuf data_off initialization

In reply to Ajit Khaparde

Initialize mbuf->data_off to RTE_PKTMBUF_HEADROOM after allocation. Without this, it might be possible that the DMA address provided to the HW may not be in sync to what is indicated to the application in bnxt_rx_pkt.

Fixes 2eb53b134aae ("net/bnxt: add initial Rx code")

--
v1->v2: update commit message and commit log

---
 drivers/net/bnxt/bnxt_rxr.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/bnxt/bnxt_rxr.c +2 -0
index 4bc320430..7b956ac78 100644
@@ -46,6 +46,7 @@ static inline int bnxt_alloc_rx_data(struct bnxt_rx_queue *rxq,
 	}
 
 	rx_buf->mbuf = mbuf;
+	mbuf->data_off = RTE_PKTMBUF_HEADROOM;
 
 	rxbd->addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf));
 
@@ -73,6 +74,7 @@ static inline int bnxt_alloc_ag_data(struct bnxt_rx_queue *rxq,
 
 
 	rx_buf->mbuf = mbuf;
+	mbuf->data_off = RTE_PKTMBUF_HEADROOM;
 
 	rxbd->addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf));
 
Signature · 1 line
2.15.1 (Apple Git-101)
#4 lore raw
In reply to Ajit Khaparde
Quoted 6 lines · Ajit Khaparde

Please apply.

Ajit Khaparde (3):
net/bnxt: cache address of doorbell to subsequent access net/bnxt: fix set_rx_mask from using invalid vnic id net/bnxt: fix mbuf data_off initialization

Hi Ajit,

Still getting warnings with check-git-log.sh [1], can you please check?

$ ./devtools/check-git-log.sh -3
Wrong headline format:
        net/bnxt: fix set_rx_mask from using invalid vnic id
        net/bnxt: fix mbuf data_off initialization
#5 lore raw

20/04/2018 12:20, Ferruh Yigit:

Quoted 8 lines · Ajit Khaparde
Quoted 6 lines

Please apply.

Ajit Khaparde (3):
net/bnxt: cache address of doorbell to subsequent access net/bnxt: fix set_rx_mask from using invalid vnic id net/bnxt: fix mbuf data_off initialization

Quoted 8 lines

Hi Ajit,

Still getting warnings with check-git-log.sh [1], can you please check?

$ ./devtools/check-git-log.sh -3
Wrong headline format:
        net/bnxt: fix set_rx_mask from using invalid vnic id
        net/bnxt: fix mbuf data_off initialization

It's better to use real english words or well know abbreviations for patch titles. Example:
net/bnxt: avoid invalid vNIC in L2 Rx mask
net/bnxt: fix mbuf data offset initialization

#6 lore raw

v3 cover bnxt patchset

Apologize for the multiple iterations.
Please apply.

Ajit Khaparde (3):
net/bnxt: cache address of doorbell to subsequent access net/bnxt: avoid invalid vnic id in set L2 Rx mask net/bnxt: fix mbuf data offset initialization

 drivers/net/bnxt/bnxt.h        |  1 +
 drivers/net/bnxt/bnxt_cpr.c    |  2 +-
 drivers/net/bnxt/bnxt_ethdev.c | 19 ++++++++++++++-----
 drivers/net/bnxt/bnxt_hwrm.c   |  3 +++
 drivers/net/bnxt/bnxt_ring.c   | 17 +++++------------
 drivers/net/bnxt/bnxt_rxr.c    |  2 ++
 6 files changed, 26 insertions(+), 18 deletions(-)
Signature · 1 line
2.15.1 (Apple Git-101)
#7 lore raw

PATCH v3 1/3 net/bnxt: cache address of doorbell to subsequent access

While creating TX, Rx, CQ rings use cached DB address instead of getting it from the PCI memory resource.

---
 drivers/net/bnxt/bnxt.h        |  1 +
 drivers/net/bnxt/bnxt_cpr.c    |  2 +-
 drivers/net/bnxt/bnxt_ethdev.c | 12 ++++++++++++
 drivers/net/bnxt/bnxt_ring.c   | 17 +++++------------
 4 files changed, 19 insertions(+), 13 deletions(-)
drivers/net/bnxt/bnxt.h +1 -0
index bdca2622f..97b0e0853 100644
@@ -208,6 +208,7 @@ struct bnxt {
 	struct rte_eth_dev		*eth_dev;
 	struct rte_eth_rss_conf		rss_conf;
 	struct rte_pci_device		*pdev;
+	void				*doorbell_base;
 
 	uint32_t		flags;
 #define BNXT_FLAG_REGISTERED	(1 << 0)
drivers/net/bnxt/bnxt_cpr.c +1 -1
index 5ac197ea7..8dde8cc0f 100644
@@ -144,7 +144,7 @@ int bnxt_alloc_def_cp_ring(struct bnxt *bp)
 				  HWRM_NA_SIGNATURE);
 	if (rc)
 		goto err_out;
-	cpr->cp_doorbell = bp->pdev->mem_resource[2].addr;
+	cpr->cp_doorbell = (char *)bp->doorbell_base;
 	B_CP_DIS_DB(cpr, cpr->cp_raw_cons);
 	if (BNXT_PF(bp))
 		rc = bnxt_hwrm_func_cfg_def_cp(bp);
drivers/net/bnxt/bnxt_ethdev.c +12 -0
index 7632c326b..a133114a3 100644
@@ -3095,11 +3095,23 @@ static int bnxt_init_board(struct rte_eth_dev *eth_dev)
 		rc = -ENOMEM;
 		goto init_err_release;
 	}
+
+	if (!pci_dev->mem_resource[2].addr) {
+		PMD_DRV_LOG(ERR,
+			    "Cannot find PCI device BAR 2 address, aborting\n");
+		rc = -ENODEV;
+		goto init_err_release;
+	} else {
+		bp->doorbell_base = (void *)pci_dev->mem_resource[2].addr;
+	}
+
 	return 0;
 
 init_err_release:
 	if (bp->bar0)
 		bp->bar0 = NULL;
+	if (bp->doorbell_base)
+		bp->doorbell_base = NULL;
 
 init_err_disable:
 
drivers/net/bnxt/bnxt_ring.c +5 -12
index 478eab4f3..8e822e11f 100644
@@ -261,7 +261,6 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
  */
 int bnxt_alloc_hwrm_rings(struct bnxt *bp)
 {
-	struct rte_pci_device *pci_dev = bp->pdev;
 	unsigned int i;
 	int rc = 0;
 
@@ -283,8 +282,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
 					HWRM_NA_SIGNATURE);
 		if (rc)
 			goto err_out;
-		cpr->cp_doorbell = (char *)pci_dev->mem_resource[2].addr +
-		    idx * 0x80;
+		cpr->cp_doorbell = (char *)bp->doorbell_base + idx * 0x80;
 		bp->grp_info[i].cp_fw_ring_id = cp_ring->fw_ring_id;
 		B_CP_DIS_DB(cpr, cpr->cp_raw_cons);
 
@@ -296,8 +294,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
 		if (rc)
 			goto err_out;
 		rxr->rx_prod = 0;
-		rxr->rx_doorbell = (char *)pci_dev->mem_resource[2].addr +
-		    idx * 0x80;
+		rxr->rx_doorbell = (char *)bp->doorbell_base + idx * 0x80;
 		bp->grp_info[i].rx_fw_ring_id = ring->fw_ring_id;
 		B_RX_DB(rxr->rx_doorbell, rxr->rx_prod);
 
@@ -316,9 +313,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
 			goto err_out;
 		PMD_DRV_LOG(DEBUG, "Alloc AGG Done!\n");
 		rxr->ag_prod = 0;
-		rxr->ag_doorbell =
-		    (char *)pci_dev->mem_resource[2].addr +
-		    map_idx * 0x80;
+		rxr->ag_doorbell = (char *)bp->doorbell_base + map_idx * 0x80;
 		bp->grp_info[i].ag_fw_ring_id = ring->fw_ring_id;
 		B_RX_DB(rxr->ag_doorbell, rxr->ag_prod);
 
@@ -350,8 +345,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
 		if (rc)
 			goto err_out;
 
-		cpr->cp_doorbell = (char *)pci_dev->mem_resource[2].addr +
-		    idx * 0x80;
+		cpr->cp_doorbell = (char *)bp->doorbell_base + idx * 0x80;
 		B_CP_DIS_DB(cpr, cpr->cp_raw_cons);
 
 		/* Tx ring */
@@ -362,8 +356,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
 		if (rc)
 			goto err_out;
 
-		txr->tx_doorbell = (char *)pci_dev->mem_resource[2].addr +
-		    idx * 0x80;
+		txr->tx_doorbell = (char *)bp->doorbell_base + idx * 0x80;
 		txq->index = idx;
 	}
 
Signature · 1 line
2.15.1 (Apple Git-101)
#8 lore raw

PATCH v3 2/3 net/bnxt: avoid invalid vnic id in set L2 Rx mask

In reply to Ajit Khaparde

In some cases bnxt_hwrm_cfa_l2_set_rx_mask is being called before VNICs are allocated. The FW returns an error in such cases. Move bnxt_init_nic to bnxt_dev_init such that the ids are initialized to an invalid id.
Prevent sending the command to the FW only with a valid vnic id.

Fixes 244bc98b0da7 ("net/bnxt: set L2 Rx mask")

--
v1->v2: update commit message and commit log
v2->v3: fix commit log as suggested

---
 drivers/net/bnxt/bnxt_ethdev.c | 7 ++-----
 drivers/net/bnxt/bnxt_hwrm.c   | 3 +++
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +2 -5
index a133114a3..348129dad 100644
@@ -395,10 +395,6 @@ static int bnxt_init_nic(struct bnxt *bp)
 	bnxt_init_vnics(bp);
 	bnxt_init_filters(bp);
 
-	rc = bnxt_init_chip(bp);
-	if (rc)
-		return rc;
-
 	return 0;
 }
 
@@ -594,7 +590,7 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
 	}
 	bp->dev_stopped = 0;
 
-	rc = bnxt_init_nic(bp);
+	rc = bnxt_init_chip(bp);
 	if (rc)
 		goto error;
 
@@ -3398,6 +3394,7 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
 		goto error_free_int;
 
 	bnxt_enable_int(bp);
+	bnxt_init_nic(bp);
 
 	return 0;
 
drivers/net/bnxt/bnxt_hwrm.c +3 -0
index 11204bf42..bc8773509 100644
@@ -221,6 +221,9 @@ int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt *bp,
 	struct hwrm_cfa_l2_set_rx_mask_output *resp = bp->hwrm_cmd_resp_addr;
 	uint32_t mask = 0;
 
+	if (vnic->fw_vnic_id == INVALID_HW_RING_ID)
+		return rc;
+
 	HWRM_PREP(req, CFA_L2_SET_RX_MASK);
 	req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
 
Signature · 1 line
2.15.1 (Apple Git-101)
#9 lore raw

PATCH v3 3/3 net/bnxt: fix mbuf data offset initialization

In reply to Ajit Khaparde

Initialize mbuf->data_off to RTE_PKTMBUF_HEADROOM after allocation. Without this, it might be possible that the DMA address provided to the HW may not be in sync to what is indicated to the application in bnxt_rx_pkt.

Fixes 2eb53b134aae ("net/bnxt: add initial Rx code")

--
v1->v2: update commit message and commit log
v2->v3: fix commit log as suggested

---
 drivers/net/bnxt/bnxt_rxr.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/bnxt/bnxt_rxr.c +2 -0
index 4bc320430..7b956ac78 100644
@@ -46,6 +46,7 @@ static inline int bnxt_alloc_rx_data(struct bnxt_rx_queue *rxq,
 	}
 
 	rx_buf->mbuf = mbuf;
+	mbuf->data_off = RTE_PKTMBUF_HEADROOM;
 
 	rxbd->addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf));
 
@@ -73,6 +74,7 @@ static inline int bnxt_alloc_ag_data(struct bnxt_rx_queue *rxq,
 
 
 	rx_buf->mbuf = mbuf;
+	mbuf->data_off = RTE_PKTMBUF_HEADROOM;
 
 	rxbd->addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf));
 
Signature · 1 line
2.15.1 (Apple Git-101)
#10 lore raw
In reply to Ajit Khaparde
Quoted 7 lines · Ajit Khaparde

Apologize for the multiple iterations.
Please apply.

Ajit Khaparde (3):
net/bnxt: cache address of doorbell to subsequent access net/bnxt: avoid invalid vnic id in set L2 Rx mask net/bnxt: fix mbuf data offset initialization

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