Skip to contentSkip to conversation

bnxt patchset

PATCH In review Ajit Khaparde 2 participants 6 messages Apr 19, 2018 – Apr 20, 2018 Network drivers

lore
Share & tools
lore
#0 lore raw

cover bnxt patchset

Please apply.

Ajit Khaparde (3):
net/bnxt: cache address of doorbell to subsequent access net/bnxt: check vnic_id before issuing set_rx_mask net/bnxt: initialize mbuf data_off

 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 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 2/3 net/bnxt: check vnic_id before issuing set_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. Prevent sending the command the FW by checking for a valid vnic id.

Fixes 244bc98b0da7 ("net/bnxt: set L2 Rx mask")
---
 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

Re: [dpdk-stable] [PATCH 2/3] net/bnxt: check vnic_id before issuing set_rx_mask

Quoted 3 lines · 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. Prevent sending the command the FW by checking for a valid vnic id

Hi Ajit,

Commit title doesn't explain "why" but explains what has been done. It is easier to see "what" part from code but not easy to see "why" without explanation. Here commit log explain the reason and scope, only title doesn't reflect it. Title can be something like "fix firmware error" ...

Please check patches with "check-git-log.sh", it will already complain about title, script complains about "_" to force explaining "why" instead of using variable/function names.

Previous set you have sent has same problem, they are already in next-net but if you have bandwidth can you please check them too? If you can send revised commit log/title I can update them. "check-git-log.sh" will help to find failing ones.

<...>

drivers/net/bnxt/bnxt_ethdev.c static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev) · line 593

Quoted 6 lines
drivers/net/bnxt/bnxt_ethdev.c +1 -1
@@ -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);

Is this bnxt_init_nic()/bnxt_init_chip() changes related to what has been described in commit log? If so can you explain in commit log why there are related?

#4 lore raw

Re: [dpdk-stable] [PATCH 2/3] net/bnxt: check vnic_id before issuing set_rx_mask

Quoted 7 lines · Ferruh Yigit
Quoted 3 lines · 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. Prevent sending the command the FW by checking for a valid vnic id

Hi Ajit,

Quoted 8 lines

Commit title doesn't explain "why" but explains what has been done. It is easier
to see "what" part from code but not easy to see "why" without explanation. Here
commit log explain the reason and scope, only title doesn't reflect it. Title
can be something like "fix firmware error" ...

Yes, Sure. I missed it. ​I was concentrating on keeping the title short.​

Quoted 6 lines

Please check patches with "check-git-log.sh", it will already complain about
title, script complains about "_" to force explaining "why" instead of using
variable/function names.

Quoted 8 lines

Previous set you have sent has same problem, they are already in next-net but if
you have bandwidth can you please check them too? If you can send revised commit
log/title
​​
I can update them. "check-git-log.sh" will help to find failing ones.

​Will do. Thanks
​

Quoted 15 lines

<...>

Review static int bnxt_dev_start_op(struct rte_eth_dev

Quoted 1 line
(quoted diff) +0 -0
@@ -594,7 +590,7 @@ static int bnxt_dev_start_op(struct rte_eth_dev

*eth_dev)

drivers/net/bnxt/bnxt_ethdev.c static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev) · line 593

Quoted 5 lines
drivers/net/bnxt/bnxt_ethdev.c +1 -1
      }
      bp->dev_stopped = 0;
 
-     rc = bnxt_init_nic(bp);
+     rc = bnxt_init_chip(bp);

Is this bnxt_init_nic()/bnxt_init_chip() changes related to what has been described in commit log? If so can you explain in commit log why there are related?

#5 lore raw

PATCH 3/3 net/bnxt: initialize mbuf data_off

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")
---
 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)