patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH 19.11 0/9] backports for 19.11.9
@ 2021-05-20 10:16 Kalesh A P
  2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 1/9] net/bnxt: fix build failures after merging patches Kalesh A P
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Kalesh A P @ 2021-05-20 10:16 UTC (permalink / raw)
  To: stable

From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

This set has those bnxt PMD patches which were not applying
cleanly on 19.11 tree. It also has one patch which fixes the build
failures seen with latest tree after applying the remaining bnxt patches.

Kalesh AP (9):
  net/bnxt: fix build failures after merging patches
  net/bnxt: drop unused attribute
  net/bnxt: fix double free in port start failure
  net/bnxt: fix firmware fatal error handling
  net/bnxt: fix memory allocation for command response
  net/bnxt: fix timesync when PTP is not supported
  net/bnxt: fix VF info allocation
  net/bnxt: fix PTP support for Thor
  net/bnxt: fix xstats get

 drivers/net/bnxt/bnxt.h        |   6 ++
 drivers/net/bnxt/bnxt_ethdev.c | 174 ++++++++++++++++++++++++++++++++++-------
 drivers/net/bnxt/bnxt_hwrm.c   | 122 ++++++++++++++---------------
 drivers/net/bnxt/bnxt_hwrm.h   |   2 +-
 drivers/net/bnxt/bnxt_rxr.c    |  17 ++--
 drivers/net/bnxt/bnxt_stats.c  |  18 ++---
 drivers/net/bnxt/bnxt_stats.h  |   2 +-
 drivers/net/bnxt/bnxt_util.h   |   2 +
 8 files changed, 235 insertions(+), 108 deletions(-)

-- 
2.10.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-stable] [PATCH 19.11 1/9] net/bnxt: fix build failures after merging patches
  2021-05-20 10:16 [dpdk-stable] [PATCH 19.11 0/9] backports for 19.11.9 Kalesh A P
@ 2021-05-20 10:16 ` Kalesh A P
  2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 2/9] net/bnxt: drop unused attribute Kalesh A P
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Kalesh A P @ 2021-05-20 10:16 UTC (permalink / raw)
  To: stable

From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

There is a build failure after merging patches to 19.11.9.
Though the patches applies cleanly to 19.11 LTS repo,
observed build failure because some macros are changed in
upstream tree.

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
---
 drivers/net/bnxt/bnxt_ethdev.c | 7 +++----
 drivers/net/bnxt/bnxt_hwrm.c   | 2 +-
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 524764e..26cc3dc 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -2417,14 +2417,13 @@ bnxt_rx_queue_count_op(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 
 		switch (cmpl_type) {
 		case CMPL_BASE_TYPE_RX_L2:
-		case CMPL_BASE_TYPE_RX_L2_V2:
 			agg_cnt = BNXT_RX_L2_AGG_BUFS(rxcmp);
 			raw_cons = raw_cons + CMP_LEN(cmpl_type) + agg_cnt;
 			desc++;
 			break;
 
 		case CMPL_BASE_TYPE_RX_TPA_END:
-			if (BNXT_CHIP_P5(rxq->bp)) {
+			if (BNXT_CHIP_THOR(rxq->bp)) {
 				struct rx_tpa_v2_end_cmpl_hi *p5_tpa_end;
 
 				p5_tpa_end = (void *)rxcmp;
@@ -3474,12 +3473,12 @@ static int bnxt_get_tx_ts(struct bnxt *bp, uint64_t *ts)
 static int bnxt_clr_rx_ts(struct bnxt *bp, uint64_t *last_ts)
 {
 	struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
-	struct bnxt_pf_info *pf = bp->pf;
+	struct bnxt_pf_info *pf = &bp->pf;
 	uint16_t port_id;
 	int i = 0;
 	uint32_t fifo;
 
-	if (!ptp || (bp->flags & BNXT_FLAG_CHIP_P5))
+	if (!ptp || BNXT_CHIP_THOR(bp))
 		return -EINVAL;
 
 	port_id = pf->port_id;
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 0d240b1..12f8107 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -5108,7 +5108,7 @@ int bnxt_hwrm_poll_ver_get(struct bnxt *bp)
 	bp->max_req_len = HWRM_MAX_REQ_LEN;
 	bp->hwrm_cmd_timeout = SHORT_HWRM_CMD_TIMEOUT;
 
-	HWRM_PREP(&req, HWRM_VER_GET, BNXT_USE_CHIMP_MB);
+	HWRM_PREP(req, VER_GET, BNXT_USE_CHIMP_MB);
 	req.hwrm_intf_maj = HWRM_VERSION_MAJOR;
 	req.hwrm_intf_min = HWRM_VERSION_MINOR;
 	req.hwrm_intf_upd = HWRM_VERSION_UPDATE;
-- 
2.10.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-stable] [PATCH 19.11 2/9] net/bnxt: drop unused attribute
  2021-05-20 10:16 [dpdk-stable] [PATCH 19.11 0/9] backports for 19.11.9 Kalesh A P
  2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 1/9] net/bnxt: fix build failures after merging patches Kalesh A P
@ 2021-05-20 10:16 ` Kalesh A P
  2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 3/9] net/bnxt: fix double free in port start failure Kalesh A P
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Kalesh A P @ 2021-05-20 10:16 UTC (permalink / raw)
  To: stable

From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

[ upstream commit 4f28d9a1a62cd3b5083e38117eb255431ad520ae ]

Remove "__rte_unused" instances that are wrongly marked.

Fixes: 1bf01f5135f8 ("net/bnxt: prevent device access when device is in reset")

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_stats.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/bnxt/bnxt_stats.h b/drivers/net/bnxt/bnxt_stats.h
index 7e11efe..591c55c 100644
--- a/drivers/net/bnxt/bnxt_stats.h
+++ b/drivers/net/bnxt/bnxt_stats.h
@@ -12,7 +12,7 @@ void bnxt_free_stats(struct bnxt *bp);
 int bnxt_stats_get_op(struct rte_eth_dev *eth_dev,
 			   struct rte_eth_stats *bnxt_stats);
 int bnxt_stats_reset_op(struct rte_eth_dev *eth_dev);
-int bnxt_dev_xstats_get_names_op(__rte_unused struct rte_eth_dev *eth_dev,
+int bnxt_dev_xstats_get_names_op(struct rte_eth_dev *eth_dev,
 	struct rte_eth_xstat_name *xstats_names,
 	__rte_unused unsigned int limit);
 int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev,
-- 
2.10.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-stable] [PATCH 19.11 3/9] net/bnxt: fix double free in port start failure
  2021-05-20 10:16 [dpdk-stable] [PATCH 19.11 0/9] backports for 19.11.9 Kalesh A P
  2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 1/9] net/bnxt: fix build failures after merging patches Kalesh A P
  2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 2/9] net/bnxt: drop unused attribute Kalesh A P
@ 2021-05-20 10:16 ` Kalesh A P
  2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 4/9] net/bnxt: fix firmware fatal error handling Kalesh A P
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Kalesh A P @ 2021-05-20 10:16 UTC (permalink / raw)
  To: stable

From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

[ upstream commit 39a03b401e4a72a118bae60c5834be2b6913098e ]

During port start when bnxt_start_nic() fails, it tries to free
"intr_handle->intr_vec" but the variable is not set to NULL after that.
If port start fails, driver invokes bnxt_dev_stop() which will lead
to a double free of "intr_handle->intr_vec".

Fix it by removing the call to free "intr_handle->intr_vec" in the
bnxt_start_nic() failure path as it is anyway doing in bnxt_dev_stop().

Fixes: 9d276b439aaf ("net/bnxt: fix error handling in device start")

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_ethdev.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 26cc3dc..bcdf1fc 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -442,7 +442,7 @@ static int bnxt_init_chip(struct bnxt *bp)
 			PMD_DRV_LOG(ERR, "Failed to allocate %d rx_queues"
 				" intr_vec", bp->eth_dev->data->nb_rx_queues);
 			rc = -ENOMEM;
-			goto err_disable;
+			goto err_out;
 		}
 		PMD_DRV_LOG(DEBUG, "intr_handle->intr_vec = %p "
 			"intr_handle->nb_efd = %d intr_handle->max_intr = %d\n",
@@ -462,13 +462,13 @@ static int bnxt_init_chip(struct bnxt *bp)
 #ifndef RTE_EXEC_ENV_FREEBSD
 	/* In FreeBSD OS, nic_uio driver does not support interrupts */
 	if (rc)
-		goto err_free;
+		goto err_out;
 #endif
 
 	rc = bnxt_get_hwrm_link_config(bp, &new);
 	if (rc) {
 		PMD_DRV_LOG(ERR, "HWRM Get link config failure rc: %x\n", rc);
-		goto err_free;
+		goto err_out;
 	}
 
 	if (!bp->link_info.link_up) {
@@ -476,17 +476,13 @@ static int bnxt_init_chip(struct bnxt *bp)
 		if (rc) {
 			PMD_DRV_LOG(ERR,
 				"HWRM link config failure rc: %x\n", rc);
-			goto err_free;
+			goto err_out;
 		}
 	}
 	bnxt_print_link_info(bp->eth_dev);
 
 	return 0;
 
-err_free:
-	rte_free(intr_handle->intr_vec);
-err_disable:
-	rte_intr_efd_disable(intr_handle);
 err_out:
 	/* Some of the error status returned by FW may not be from errno.h */
 	if (rc > 0)
-- 
2.10.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-stable] [PATCH 19.11 4/9] net/bnxt: fix firmware fatal error handling
  2021-05-20 10:16 [dpdk-stable] [PATCH 19.11 0/9] backports for 19.11.9 Kalesh A P
                   ` (2 preceding siblings ...)
  2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 3/9] net/bnxt: fix double free in port start failure Kalesh A P
@ 2021-05-20 10:16 ` Kalesh A P
  2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 5/9] net/bnxt: fix memory allocation for command response Kalesh A P
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Kalesh A P @ 2021-05-20 10:16 UTC (permalink / raw)
  To: stable

From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

[upstream commit 94131e4ab74728da994d5179052bb30c3c76910c ]

During some fatal firmware error conditions, the PCI config space
register 0x2e which normally contains the subsystem ID will become
0xffff. This register will revert back to the normal value after
the chip has completed core reset. If we detect this condition,
we can poll this config register immediately for the value to revert.
Because we use config read cycles to poll this register, there is no
possibility of Master Abort if we happen to read it during core reset.
This speeds up recovery significantly as we don't have to wait for the
conservative min_time before polling to see if the firmware has come
out of reset. As soon as this register changes value we can proceed
to re-initialize the device.

Fixes: df6cd7c1f73a ("net/bnxt: handle reset notify async event from FW")

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_ethdev.c | 55 ++++++++++++++++++++++++++++++++++++++++--
 drivers/net/bnxt/bnxt_util.h   |  2 ++
 2 files changed, 55 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index bcdf1fc..32c4eed 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -4009,6 +4009,32 @@ static void bnxt_dev_cleanup(struct bnxt *bp)
 	bnxt_uninit_resources(bp, true);
 }
 
+static int
+bnxt_check_fw_reset_done(struct bnxt *bp)
+{
+	int timeout = bp->fw_reset_max_msecs;
+	uint16_t val = 0;
+	int rc;
+
+	do {
+		rc = rte_pci_read_config(bp->pdev, &val, sizeof(val), PCI_SUBSYSTEM_ID_OFFSET);
+		if (rc < 0) {
+			PMD_DRV_LOG(ERR, "Failed to read PCI offset 0x%x", PCI_SUBSYSTEM_ID_OFFSET);
+			return rc;
+		}
+		if (val != 0xffff)
+			break;
+		rte_delay_ms(1);
+	} while (timeout--);
+
+	if (val == 0xffff) {
+		PMD_DRV_LOG(ERR, "Firmware reset aborted, PCI config space invalid\n");
+		return -1;
+	}
+
+	return 0;
+}
+
 static int bnxt_restore_vlan_filters(struct bnxt *bp)
 {
 	struct rte_eth_dev *dev = bp->eth_dev;
@@ -4123,6 +4149,12 @@ static void bnxt_dev_recover(void *arg)
 	struct bnxt *bp = arg;
 	int rc = 0;
 
+	if (!bp->fw_reset_min_msecs) {
+		rc = bnxt_check_fw_reset_done(bp);
+		if (rc)
+			goto err;
+	}
+
 	/* Clear Error flag so that device re-init should happen */
 	bp->flags &= ~BNXT_FLAG_FATAL_ERROR;
 
@@ -4162,14 +4194,33 @@ static void bnxt_dev_recover(void *arg)
 void bnxt_dev_reset_and_resume(void *arg)
 {
 	struct bnxt *bp = arg;
+	uint32_t us = US_PER_MS * bp->fw_reset_min_msecs;
+	uint16_t val = 0;
 	int rc;
 
 	bnxt_dev_cleanup(bp);
 
 	bnxt_wait_for_device_shutdown(bp);
 
-	rc = rte_eal_alarm_set(US_PER_MS * bp->fw_reset_min_msecs,
-			       bnxt_dev_recover, (void *)bp);
+	/* During some fatal firmware error conditions, the PCI config space
+	 * register 0x2e which normally contains the subsystem ID will become
+	 * 0xffff. This register will revert back to the normal value after
+	 * the chip has completed core reset. If we detect this condition,
+	 * we can poll this config register immediately for the value to revert.
+	 */
+	if (bp->flags & BNXT_FLAG_FATAL_ERROR) {
+		rc = rte_pci_read_config(bp->pdev, &val, sizeof(val), PCI_SUBSYSTEM_ID_OFFSET);
+		if (rc < 0) {
+			PMD_DRV_LOG(ERR, "Failed to read PCI offset 0x%x", PCI_SUBSYSTEM_ID_OFFSET);
+			return;
+		}
+		if (val == 0xffff) {
+			bp->fw_reset_min_msecs = 0;
+			us = 1;
+		}
+	}
+
+	rc = rte_eal_alarm_set(us, bnxt_dev_recover, (void *)bp);
 	if (rc)
 		PMD_DRV_LOG(ERR, "Error setting recovery alarm");
 }
diff --git a/drivers/net/bnxt/bnxt_util.h b/drivers/net/bnxt/bnxt_util.h
index a15b3a1..68665196 100644
--- a/drivers/net/bnxt/bnxt_util.h
+++ b/drivers/net/bnxt/bnxt_util.h
@@ -10,6 +10,8 @@
 #define BIT(n)	(1UL << (n))
 #endif /* BIT */
 
+#define PCI_SUBSYSTEM_ID_OFFSET	0x2e
+
 int bnxt_check_zero_bytes(const uint8_t *bytes, int len);
 void bnxt_eth_hw_addr_random(uint8_t *mac_addr);
 
-- 
2.10.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-stable] [PATCH 19.11 5/9] net/bnxt: fix memory allocation for command response
  2021-05-20 10:16 [dpdk-stable] [PATCH 19.11 0/9] backports for 19.11.9 Kalesh A P
                   ` (3 preceding siblings ...)
  2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 4/9] net/bnxt: fix firmware fatal error handling Kalesh A P
@ 2021-05-20 10:16 ` Kalesh A P
  2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 6/9] net/bnxt: fix timesync when PTP is not supported Kalesh A P
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Kalesh A P @ 2021-05-20 10:16 UTC (permalink / raw)
  To: stable

From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

[ upstream commit 4f1d8fdc3f4234857c1e78af564fcfd92f602f70 ]

Driver re-allocates memory for the command response buffer
when the installed firmware version is newer (and has a larger
max response length) than the version of HWRM that was used to
build the PMD.

This change helps to avoid the re-allocation by allocating the
memory for the command response buffer with PAGE_SIZE.

Fixes: b7778e8a1c00 ("net/bnxt: refactor to properly allocate resources for PF/VF")

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Lance Richardson <lance.richardson@broadcom.com>
---
 drivers/net/bnxt/bnxt_ethdev.c |  2 +-
 drivers/net/bnxt/bnxt_hwrm.c   | 27 ++++-----------------------
 2 files changed, 5 insertions(+), 24 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 32c4eed..ed02cf0 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -5026,7 +5026,7 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
 	rc = bnxt_alloc_hwrm_resources(bp);
 	if (rc) {
 		PMD_DRV_LOG(ERR,
-			    "Failed to allocate hwrm resource rc: %x\n", rc);
+			    "Failed to allocate response buffer rc: %x\n", rc);
 		goto error_free;
 	}
 	rc = bnxt_init_resources(bp, false);
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 12f8107..4e3dfff 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -1053,28 +1053,8 @@ int bnxt_hwrm_ver_get(struct bnxt *bp, uint32_t timeout)
 	max_resp_len = rte_le_to_cpu_16(resp->max_resp_len);
 	dev_caps_cfg = rte_le_to_cpu_32(resp->dev_caps_cfg);
 
-	if (bp->max_resp_len != max_resp_len) {
-		sprintf(type, "bnxt_hwrm_%04x:%02x:%02x:%02x",
-			bp->pdev->addr.domain, bp->pdev->addr.bus,
-			bp->pdev->addr.devid, bp->pdev->addr.function);
-
-		rte_free(bp->hwrm_cmd_resp_addr);
-
-		bp->hwrm_cmd_resp_addr = rte_malloc(type, max_resp_len, 0);
-		if (bp->hwrm_cmd_resp_addr == NULL) {
-			rc = -ENOMEM;
-			goto error;
-		}
-		bp->hwrm_cmd_resp_dma_addr =
-			rte_malloc_virt2iova(bp->hwrm_cmd_resp_addr);
-		if (bp->hwrm_cmd_resp_dma_addr == RTE_BAD_IOVA) {
-			PMD_DRV_LOG(ERR,
-			"Unable to map response buffer to physical memory.\n");
-			rc = -ENOMEM;
-			goto error;
-		}
-		bp->max_resp_len = max_resp_len;
-	}
+	RTE_VERIFY(max_resp_len <= bp->max_resp_len);
+	bp->max_resp_len = max_resp_len;
 
 	if ((dev_caps_cfg &
 		HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_SUPPORTED) &&
@@ -2484,7 +2464,7 @@ int bnxt_alloc_hwrm_resources(struct bnxt *bp)
 
 	sprintf(type, "bnxt_hwrm_%04x:%02x:%02x:%02x", pdev->addr.domain,
 		pdev->addr.bus, pdev->addr.devid, pdev->addr.function);
-	bp->max_resp_len = HWRM_MAX_RESP_LEN;
+	bp->max_resp_len = BNXT_PAGE_SIZE;
 	bp->hwrm_cmd_resp_addr = rte_malloc(type, bp->max_resp_len, 0);
 	if (bp->hwrm_cmd_resp_addr == NULL)
 		return -ENOMEM;
@@ -5106,6 +5086,7 @@ int bnxt_hwrm_poll_ver_get(struct bnxt *bp)
 	int rc = 0;
 
 	bp->max_req_len = HWRM_MAX_REQ_LEN;
+	bp->max_resp_len = BNXT_PAGE_SIZE;
 	bp->hwrm_cmd_timeout = SHORT_HWRM_CMD_TIMEOUT;
 
 	HWRM_PREP(req, VER_GET, BNXT_USE_CHIMP_MB);
-- 
2.10.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-stable] [PATCH 19.11 6/9] net/bnxt: fix timesync when PTP is not supported
  2021-05-20 10:16 [dpdk-stable] [PATCH 19.11 0/9] backports for 19.11.9 Kalesh A P
                   ` (4 preceding siblings ...)
  2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 5/9] net/bnxt: fix memory allocation for command response Kalesh A P
@ 2021-05-20 10:16 ` Kalesh A P
  2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 7/9] net/bnxt: fix VF info allocation Kalesh A P
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Kalesh A P @ 2021-05-20 10:16 UTC (permalink / raw)
  To: stable

From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

[ upstream commit ab15dd5a1c4d563e80b10e42e39c4d2f010fa389 ]

Fixed to return error when PTP support is not supported on the port.
Also, removed an unnecessary check inside bnxt_get_rx_ts().

Fixes: b11cceb83a34 ("net/bnxt: support timesync")

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
---
 drivers/net/bnxt/bnxt_ethdev.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index ed02cf0..08f56a3 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -3505,9 +3505,6 @@ static int bnxt_get_rx_ts(struct bnxt *bp, uint64_t *ts)
 	uint16_t port_id;
 	uint32_t fifo;
 
-	if (!ptp)
-		return -ENODEV;
-
 	fifo = rte_le_to_cpu_32(rte_read32((uint8_t *)bp->bar0 +
 				ptp->rx_mapped_regs[BNXT_PTP_RX_FIFO]));
 	if (!(fifo & BNXT_PTP_RX_FIFO_PENDING))
@@ -3538,7 +3535,7 @@ bnxt_timesync_write_time(struct rte_eth_dev *dev, const struct timespec *ts)
 	struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
 
 	if (!ptp)
-		return 0;
+		return -ENOTSUP;
 
 	ns = rte_timespec_to_ns(ts);
 	/* Set the timecounters to a new value. */
@@ -3558,7 +3555,7 @@ bnxt_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts)
 	int rc = 0;
 
 	if (!ptp)
-		return 0;
+		return -ENOTSUP;
 
 	if (BNXT_CHIP_THOR(bp))
 		rc = bnxt_hwrm_port_ts_query(bp, BNXT_PTP_FLAGS_CURRENT_TIME,
@@ -3580,7 +3577,7 @@ bnxt_timesync_enable(struct rte_eth_dev *dev)
 	int rc;
 
 	if (!ptp)
-		return 0;
+		return -ENOTSUP;
 
 	ptp->rx_filter = 1;
 	ptp->tx_tstamp_en = 1;
@@ -3619,7 +3616,7 @@ bnxt_timesync_disable(struct rte_eth_dev *dev)
 	struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
 
 	if (!ptp)
-		return 0;
+		return -ENOTSUP;
 
 	ptp->rx_filter = 0;
 	ptp->tx_tstamp_en = 0;
@@ -3644,7 +3641,7 @@ bnxt_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
 	uint64_t ns;
 
 	if (!ptp)
-		return 0;
+		return -ENOTSUP;
 
 	if (BNXT_CHIP_THOR(bp))
 		rx_tstamp_cycles = ptp->rx_timestamp;
@@ -3667,7 +3664,7 @@ bnxt_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
 	int rc = 0;
 
 	if (!ptp)
-		return 0;
+		return -ENOTSUP;
 
 	if (BNXT_CHIP_THOR(bp))
 		rc = bnxt_hwrm_port_ts_query(bp, BNXT_PTP_FLAGS_PATH_TX,
@@ -3688,7 +3685,7 @@ bnxt_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta)
 	struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
 
 	if (!ptp)
-		return 0;
+		return -ENOTSUP;
 
 	ptp->tc.nsec += delta;
 	ptp->tx_tstamp_tc.nsec += delta;
-- 
2.10.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-stable] [PATCH 19.11 7/9] net/bnxt: fix VF info allocation
  2021-05-20 10:16 [dpdk-stable] [PATCH 19.11 0/9] backports for 19.11.9 Kalesh A P
                   ` (5 preceding siblings ...)
  2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 6/9] net/bnxt: fix timesync when PTP is not supported Kalesh A P
@ 2021-05-20 10:16 ` Kalesh A P
  2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 8/9] net/bnxt: fix PTP support for Thor Kalesh A P
  2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 9/9] net/bnxt: fix xstats get Kalesh A P
  8 siblings, 0 replies; 10+ messages in thread
From: Kalesh A P @ 2021-05-20 10:16 UTC (permalink / raw)
  To: stable

From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

[ upstream commit 01406837bf49950fa3a3fdd9d62eb7e0819383e4 ]

1. Renamed bnxt_hwrm_alloc_vf_info()/bnxt_hwrm_free_vf_info to
   bnxt_alloc_vf_info()/bnxt_free_vf_info as it does not
   issue any HWRM command to fw.
2. Fix missing unlock when memory allocation fails.

Fixes: b7778e8a1c00 ("net/bnxt: refactor to properly allocate resources for PF/VF")

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_ethdev.c |  2 +-
 drivers/net/bnxt/bnxt_hwrm.c   | 93 +++++++++++++++++++++++++-----------------
 drivers/net/bnxt/bnxt_hwrm.h   |  2 +-
 3 files changed, 57 insertions(+), 40 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 08f56a3..a49ec72 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -5105,7 +5105,7 @@ bnxt_dev_uninit(struct rte_eth_dev *eth_dev)
 
 	if (eth_dev->data->dev_started)
 		bnxt_dev_close_op(eth_dev);
-	bnxt_hwrm_free_vf_info(bp);
+	bnxt_free_vf_info(bp);
 	eth_dev->dev_ops = NULL;
 	eth_dev->rx_pkt_burst = NULL;
 	eth_dev->tx_pkt_burst = NULL;
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 4e3dfff..d1f6d23 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -589,10 +589,13 @@ static int bnxt_hwrm_ptp_qcfg(struct bnxt *bp)
 	return 0;
 }
 
-void bnxt_hwrm_free_vf_info(struct bnxt *bp)
+void bnxt_free_vf_info(struct bnxt *bp)
 {
 	uint16_t i;
 
+	if (bp->pf.vf_info == NULL)
+		return;
+
 	for (i = 0; i < bp->pf.max_vfs; i++) {
 		rte_free(bp->pf.vf_info[i].vlan_table);
 		bp->pf.vf_info[i].vlan_table = NULL;
@@ -603,6 +606,50 @@ void bnxt_hwrm_free_vf_info(struct bnxt *bp)
 	bp->pf.vf_info = NULL;
 }
 
+static int bnxt_alloc_vf_info(struct bnxt *bp, uint16_t max_vfs)
+{
+	struct bnxt_child_vf_info *vf_info = bp->pf.vf_info;
+	int i;
+
+	if (vf_info)
+		bnxt_free_vf_info(bp);
+
+	vf_info = rte_zmalloc("bnxt_vf_info", sizeof(*vf_info) * max_vfs, 0);
+	if (vf_info == NULL) {
+		PMD_DRV_LOG(ERR, "Failed to alloc vf info\n");
+		return -ENOMEM;
+	}
+
+	bp->pf.max_vfs = max_vfs;
+	for (i = 0; i < max_vfs; i++) {
+		vf_info[i].fid = bp->pf.first_vf_id + i;
+		vf_info[i].vlan_table = rte_zmalloc("VF VLAN table",
+						    getpagesize(), getpagesize());
+		if (vf_info[i].vlan_table == NULL) {
+			PMD_DRV_LOG(ERR, "Failed to alloc VLAN table for VF %d\n", i);
+			goto err;
+		}
+		rte_mem_lock_page(vf_info[i].vlan_table);
+
+		vf_info[i].vlan_as_table = rte_zmalloc("VF VLAN AS table",
+						       getpagesize(), getpagesize());
+		if (vf_info[i].vlan_as_table == NULL) {
+			PMD_DRV_LOG(ERR, "Failed to alloc VLAN AS table for VF %d\n", i);
+			goto err;
+		}
+		rte_mem_lock_page(vf_info[i].vlan_as_table);
+
+		STAILQ_INIT(&vf_info[i].filter);
+	}
+
+	bp->pf.vf_info = vf_info;
+
+	return 0;
+err:
+	bnxt_free_vf_info(bp);
+	return -ENOMEM;
+}
+
 static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
 {
 	int rc = 0;
@@ -610,7 +657,6 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
 	struct hwrm_func_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
 	uint16_t new_max_vfs;
 	uint32_t flags;
-	int i;
 
 	HWRM_PREP(req, FUNC_QCAPS, BNXT_USE_CHIMP_MB);
 
@@ -628,42 +674,9 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
 		bp->pf.total_vfs = rte_le_to_cpu_16(resp->max_vfs);
 		new_max_vfs = bp->pdev->max_vfs;
 		if (new_max_vfs != bp->pf.max_vfs) {
-			if (bp->pf.vf_info)
-				bnxt_hwrm_free_vf_info(bp);
-			bp->pf.vf_info = rte_zmalloc("bnxt_vf_info",
-			    sizeof(bp->pf.vf_info[0]) * new_max_vfs, 0);
-			if (bp->pf.vf_info == NULL) {
-				PMD_DRV_LOG(ERR, "Alloc vf info fail\n");
-				HWRM_UNLOCK();
-				return -ENOMEM;
-			}
-			bp->pf.max_vfs = new_max_vfs;
-			for (i = 0; i < new_max_vfs; i++) {
-				bp->pf.vf_info[i].fid = bp->pf.first_vf_id + i;
-				bp->pf.vf_info[i].vlan_table =
-					rte_zmalloc("VF VLAN table",
-						    getpagesize(),
-						    getpagesize());
-				if (bp->pf.vf_info[i].vlan_table == NULL)
-					PMD_DRV_LOG(ERR,
-					"Fail to alloc VLAN table for VF %d\n",
-					i);
-				else
-					rte_mem_lock_page(
-						bp->pf.vf_info[i].vlan_table);
-				bp->pf.vf_info[i].vlan_as_table =
-					rte_zmalloc("VF VLAN AS table",
-						    getpagesize(),
-						    getpagesize());
-				if (bp->pf.vf_info[i].vlan_as_table == NULL)
-					PMD_DRV_LOG(ERR,
-					"Alloc VLAN AS table for VF %d fail\n",
-					i);
-				else
-					rte_mem_lock_page(
-					       bp->pf.vf_info[i].vlan_as_table);
-				STAILQ_INIT(&bp->pf.vf_info[i].filter);
-			}
+			rc = bnxt_alloc_vf_info(bp, new_max_vfs);
+			if (rc)
+				goto unlock;
 		}
 	}
 
@@ -717,6 +730,7 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
 	if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_HOT_RESET_CAPABLE)
 		bp->fw_cap |= BNXT_FW_CAP_HOT_RESET;
 
+unlock:
 	HWRM_UNLOCK();
 
 	return rc;
@@ -727,6 +741,9 @@ int bnxt_hwrm_func_qcaps(struct bnxt *bp)
 	int rc;
 
 	rc = __bnxt_hwrm_func_qcaps(bp);
+	if (rc == -ENOMEM)
+		return rc;
+
 	if (!rc && bp->hwrm_spec_code >= HWRM_SPEC_CODE_1_8_3) {
 		rc = bnxt_alloc_ctx_mem(bp);
 		if (rc)
diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h
index ccc1bf9..7b2432f 100644
--- a/drivers/net/bnxt/bnxt_hwrm.h
+++ b/drivers/net/bnxt/bnxt_hwrm.h
@@ -88,7 +88,7 @@ int bnxt_hwrm_func_buf_rgtr(struct bnxt *bp);
 int bnxt_hwrm_func_buf_unrgtr(struct bnxt *bp);
 int bnxt_hwrm_func_driver_register(struct bnxt *bp);
 int bnxt_hwrm_func_qcaps(struct bnxt *bp);
-void bnxt_hwrm_free_vf_info(struct bnxt *bp);
+void bnxt_free_vf_info(struct bnxt *bp);
 int bnxt_hwrm_func_reset(struct bnxt *bp);
 int bnxt_hwrm_func_driver_unregister(struct bnxt *bp, uint32_t flags);
 int bnxt_hwrm_func_qstats(struct bnxt *bp, uint16_t fid,
-- 
2.10.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-stable] [PATCH 19.11 8/9] net/bnxt: fix PTP support for Thor
  2021-05-20 10:16 [dpdk-stable] [PATCH 19.11 0/9] backports for 19.11.9 Kalesh A P
                   ` (6 preceding siblings ...)
  2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 7/9] net/bnxt: fix VF info allocation Kalesh A P
@ 2021-05-20 10:16 ` Kalesh A P
  2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 9/9] net/bnxt: fix xstats get Kalesh A P
  8 siblings, 0 replies; 10+ messages in thread
From: Kalesh A P @ 2021-05-20 10:16 UTC (permalink / raw)
  To: stable

From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

[ upstream commit 53f98141ee9d3a3406fe1281bbc993efd0c06575 ]

On Thor, Rx timestamp is present in the Rx completion record.
Only 32 bits of the timestamp is present in the completion.
The driver needs to periodically poll the current 48 bit
free running timer using the HWRM_PORT_TS_QUERY command.
It can combine the upper 16 bits from the HWRM response
with the lower 32 bits in the Rx completion to produce
the 48 bit timestamp for the Rx packet.

This patch adds an alarm thread to periodically poll the current 48 bit
free running timer using the HWRM_PORT_TS_QUERY command.
This avoids issuing the hwrm command from the Rx handler.
This patch also handles the timer roll over condition.

Fixes: 6cbd89f9f3d8 ("net/bnxt: support PTP for Thor")

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Lance Richardson <lance.richardson@broadcom.com>
Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt.h        |  6 ++++
 drivers/net/bnxt/bnxt_ethdev.c | 79 +++++++++++++++++++++++++++++++++++++++++-
 drivers/net/bnxt/bnxt_rxr.c    | 17 +++++----
 3 files changed, 95 insertions(+), 7 deletions(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index d5818e6..f68cbda 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -275,6 +275,7 @@ struct rte_flow {
 #define BNXT_PTP_FLAGS_PATH_TX		0x0
 #define BNXT_PTP_FLAGS_PATH_RX		0x1
 #define BNXT_PTP_FLAGS_CURRENT_TIME	0x2
+#define BNXT_PTP_CURRENT_TIME_MASK	0xFFFF00000000ULL
 
 struct bnxt_ptp_cfg {
 #define BNXT_GRCPF_REG_WINDOW_BASE_OUT  0x400
@@ -324,6 +325,7 @@ struct bnxt_ptp_cfg {
 
 	/* On Thor, the Rx timestamp is present in the Rx completion record */
 	uint64_t			rx_timestamp;
+	uint64_t			current_time;
 };
 
 struct bnxt_coal {
@@ -522,6 +524,8 @@ struct bnxt {
 #define BNXT_FLAG_ADV_FLOW_MGMT			BIT(23)
 #define BNXT_FLAG_NPAR_PF                      BIT(24)
 #define BNXT_FLAG_DFLT_MAC_SET			BIT(26)
+#define BNXT_FLAGS_PTP_TIMESYNC_ENABLED		BIT(27)
+#define BNXT_FLAGS_PTP_ALARM_SCHEDULED		BIT(28)
 #define BNXT_PF(bp)		(!((bp)->flags & BNXT_FLAG_VF))
 #define BNXT_VF(bp)		((bp)->flags & BNXT_FLAG_VF)
 #define BNXT_NPAR(bp)		((bp)->flags & BNXT_FLAG_NPAR_PF)
@@ -535,6 +539,8 @@ struct bnxt {
 #define BNXT_HAS_NQ(bp)		BNXT_CHIP_THOR(bp)
 #define BNXT_HAS_RING_GRPS(bp)	(!BNXT_CHIP_THOR(bp))
 #define BNXT_HAS_DFLT_MAC_SET(bp)      ((bp)->flags & BNXT_FLAG_DFLT_MAC_SET)
+#define BNXT_THOR_PTP_TIMESYNC_ENABLED(bp)	\
+	((bp)->flags & BNXT_FLAGS_PTP_TIMESYNC_ENABLED)
 
 	uint32_t		fw_cap;
 #define BNXT_FW_CAP_HOT_RESET		BIT(0)
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index a49ec72..1660782 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -942,6 +942,73 @@ static int bnxt_dev_set_link_down_op(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static void bnxt_ptp_get_current_time(void *arg)
+{
+	struct bnxt *bp = arg;
+	struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
+	int rc;
+
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return;
+
+	if (!ptp)
+		return;
+
+	bnxt_hwrm_port_ts_query(bp, BNXT_PTP_FLAGS_CURRENT_TIME,
+				&ptp->current_time);
+
+	rc = rte_eal_alarm_set(US_PER_S, bnxt_ptp_get_current_time, (void *)bp);
+	if (rc != 0) {
+		PMD_DRV_LOG(ERR, "Failed to re-schedule PTP alarm\n");
+		bp->flags &= ~BNXT_FLAGS_PTP_ALARM_SCHEDULED;
+	}
+}
+
+static int bnxt_schedule_ptp_alarm(struct bnxt *bp)
+{
+	struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
+	int rc;
+
+	if (bp->flags & BNXT_FLAGS_PTP_ALARM_SCHEDULED)
+		return 0;
+
+	bnxt_hwrm_port_ts_query(bp, BNXT_PTP_FLAGS_CURRENT_TIME,
+				&ptp->current_time);
+
+	rc = rte_eal_alarm_set(US_PER_S, bnxt_ptp_get_current_time, (void *)bp);
+	return rc;
+}
+
+static void bnxt_cancel_ptp_alarm(struct bnxt *bp)
+{
+	if (bp->flags & BNXT_FLAGS_PTP_ALARM_SCHEDULED) {
+		rte_eal_alarm_cancel(bnxt_ptp_get_current_time, (void *)bp);
+		bp->flags &= ~BNXT_FLAGS_PTP_ALARM_SCHEDULED;
+	}
+}
+
+static void bnxt_ptp_stop(struct bnxt *bp)
+{
+	bnxt_cancel_ptp_alarm(bp);
+	bp->flags &= ~BNXT_FLAGS_PTP_TIMESYNC_ENABLED;
+}
+
+static int bnxt_ptp_start(struct bnxt *bp)
+{
+	int rc;
+
+	rc = bnxt_schedule_ptp_alarm(bp);
+	if (rc != 0) {
+		PMD_DRV_LOG(ERR, "Failed to schedule PTP alarm\n");
+	} else {
+		bp->flags |= BNXT_FLAGS_PTP_TIMESYNC_ENABLED;
+		bp->flags |= BNXT_FLAGS_PTP_ALARM_SCHEDULED;
+	}
+
+	return rc;
+}
+
 /* Unload the driver, release resources */
 static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
 {
@@ -962,6 +1029,9 @@ static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
 
 	bnxt_cancel_fw_health_check(bp);
 
+	if (BNXT_THOR_PTP_TIMESYNC_ENABLED(bp))
+		bnxt_cancel_ptp_alarm(bp);
+
 	/* Do not bring link down during reset recovery */
 	if (!is_bnxt_in_error(bp)) {
 		bnxt_dev_set_link_down_op(eth_dev);
@@ -1432,6 +1502,9 @@ static int bnxt_reta_query_op(struct rte_eth_dev *eth_dev,
 		}
 	}
 
+	if (BNXT_THOR_PTP_TIMESYNC_ENABLED(bp))
+		bnxt_schedule_ptp_alarm(bp);
+
 	return 0;
 }
 
@@ -3605,8 +3678,10 @@ bnxt_timesync_enable(struct rte_eth_dev *dev)
 
 	if (!BNXT_CHIP_THOR(bp))
 		bnxt_map_ptp_regs(bp);
+	else
+		rc = bnxt_ptp_start(bp);
 
-	return 0;
+	return rc;
 }
 
 static int
@@ -3626,6 +3701,8 @@ bnxt_timesync_disable(struct rte_eth_dev *dev)
 
 	if (!BNXT_CHIP_THOR(bp))
 		bnxt_unmap_ptp_regs(bp);
+	else
+		bnxt_ptp_stop(bp);
 
 	return 0;
 }
diff --git a/drivers/net/bnxt/bnxt_rxr.c b/drivers/net/bnxt/bnxt_rxr.c
index dcdde44..8abd391 100644
--- a/drivers/net/bnxt/bnxt_rxr.c
+++ b/drivers/net/bnxt/bnxt_rxr.c
@@ -380,9 +380,11 @@ bnxt_parse_pkt_type(struct rx_pkt_cmpl *rxcmp, struct rx_pkt_cmpl_hi *rxcmp1)
 static void
 bnxt_get_rx_ts_thor(struct bnxt *bp, uint32_t rx_ts_cmpl)
 {
-	uint64_t systime_cycles = 0;
+	struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
+	uint64_t last_hwrm_time;
+	uint64_t pkt_time = 0;
 
-	if (!BNXT_CHIP_THOR(bp))
+	if (!BNXT_CHIP_THOR(bp) || !ptp)
 		return;
 
 	/* On Thor, Rx timestamps are provided directly in the
@@ -393,10 +395,13 @@ bnxt_get_rx_ts_thor(struct bnxt *bp, uint32_t rx_ts_cmpl)
 	 * from the HWRM response with the lower 32 bits in the
 	 * Rx completion to produce the 48 bit timestamp for the Rx packet
 	 */
-	bnxt_hwrm_port_ts_query(bp, BNXT_PTP_FLAGS_CURRENT_TIME,
-				&systime_cycles);
-	bp->ptp_cfg->rx_timestamp = (systime_cycles & 0xFFFF00000000);
-	bp->ptp_cfg->rx_timestamp |= rx_ts_cmpl;
+	last_hwrm_time = ptp->current_time;
+	pkt_time = (last_hwrm_time & BNXT_PTP_CURRENT_TIME_MASK) | rx_ts_cmpl;
+	if (rx_ts_cmpl < (uint32_t)last_hwrm_time) {
+		/* timer has rolled over */
+		pkt_time += (1ULL << 32);
+	}
+	ptp->rx_timestamp = pkt_time;
 }
 #endif
 
-- 
2.10.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-stable] [PATCH 19.11 9/9] net/bnxt: fix xstats get
  2021-05-20 10:16 [dpdk-stable] [PATCH 19.11 0/9] backports for 19.11.9 Kalesh A P
                   ` (7 preceding siblings ...)
  2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 8/9] net/bnxt: fix PTP support for Thor Kalesh A P
@ 2021-05-20 10:16 ` Kalesh A P
  8 siblings, 0 replies; 10+ messages in thread
From: Kalesh A P @ 2021-05-20 10:16 UTC (permalink / raw)
  To: stable

From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

[ upstream commit eac4fc71cdaa6b68dbd0e4129e5751c712501693 ]

Fix to return count in xstats get op in all cases.
Driver was returning 0 if the 'xstats' parameter being passed to
xstats_get_op was NULL. This won't work on some applications that
rely on a valid count being passed even in this case so that it can
allocate memory accordingly followed by a reissue of the xstats_get_op
to get the actual stats populated by the driver.

Fixes: 063e59ddd28e ("net/bnxt: fix crash in xstats get")

Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Lance Richardson <lance.richardson@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_stats.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_stats.c b/drivers/net/bnxt/bnxt_stats.c
index 84011fc..692b096 100644
--- a/drivers/net/bnxt/bnxt_stats.c
+++ b/drivers/net/bnxt/bnxt_stats.c
@@ -465,10 +465,13 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev,
 	if (rc)
 		return rc;
 
-	if (xstats == NULL)
-		return 0;
+	stat_count = RTE_DIM(bnxt_rx_stats_strings) +
+		RTE_DIM(bnxt_tx_stats_strings) + 1/* For tx_drop_pkts */ +
+		RTE_DIM(bnxt_rx_ext_stats_strings) +
+		RTE_DIM(bnxt_tx_ext_stats_strings);
 
-	memset(xstats, 0, sizeof(*xstats));
+	if (n < stat_count || xstats == NULL)
+		return stat_count;
 
 	bnxt_hwrm_port_qstats(bp);
 	bnxt_hwrm_func_qstats_tx_drop(bp, 0xffff, &tx_drop_pkts);
@@ -480,14 +483,7 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev,
 					(bp->fw_tx_port_stats_ext_size /
 					 stat_size));
 
-	count = RTE_DIM(bnxt_rx_stats_strings) +
-		RTE_DIM(bnxt_tx_stats_strings) + 1/* For tx_drop_pkts */ +
-		RTE_DIM(bnxt_rx_ext_stats_strings) +
-		RTE_DIM(bnxt_tx_ext_stats_strings);
-	stat_count = count;
-
-	if (n < count)
-		return count;
+	memset(xstats, 0, sizeof(*xstats));
 
 	count = 0;
 	for (i = 0; i < RTE_DIM(bnxt_rx_stats_strings); i++) {
-- 
2.10.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-05-20  9:55 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-20 10:16 [dpdk-stable] [PATCH 19.11 0/9] backports for 19.11.9 Kalesh A P
2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 1/9] net/bnxt: fix build failures after merging patches Kalesh A P
2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 2/9] net/bnxt: drop unused attribute Kalesh A P
2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 3/9] net/bnxt: fix double free in port start failure Kalesh A P
2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 4/9] net/bnxt: fix firmware fatal error handling Kalesh A P
2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 5/9] net/bnxt: fix memory allocation for command response Kalesh A P
2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 6/9] net/bnxt: fix timesync when PTP is not supported Kalesh A P
2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 7/9] net/bnxt: fix VF info allocation Kalesh A P
2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 8/9] net/bnxt: fix PTP support for Thor Kalesh A P
2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 9/9] net/bnxt: fix xstats get Kalesh A P

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ https://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git