patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH v2 02/12] net/bnxt: remove unused macro
       [not found] ` <20210310212637.72205-1-ajit.khaparde@broadcom.com>
@ 2021-03-10 21:26   ` Ajit Khaparde
  2021-03-10 21:26   ` [dpdk-stable] [PATCH v2 03/12] net/bnxt: fix VNIC configuration Ajit Khaparde
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: Ajit Khaparde @ 2021-03-10 21:26 UTC (permalink / raw)
  To: ferruh.yigit
  Cc: ajit.khaparde, dev, kalesh-anakkur.purayil, stable, Somnath Kotur

[-- Attachment #1: Type: text/plain, Size: 931 bytes --]

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

remove HWRM_SEQ_ID_INVALID macro.

Fixes: 804e746c7b73 ("net/bnxt: add hardware resource manager init code")
Cc: stable@dpdk.org

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_hwrm.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h
index a9d9fcb294..449cb911e5 100644
--- a/drivers/net/bnxt/bnxt_hwrm.h
+++ b/drivers/net/bnxt/bnxt_hwrm.h
@@ -14,7 +14,6 @@ struct bnxt_filter_info;
 struct bnxt_cp_ring_info;
 struct hwrm_func_qstats_output;
 
-#define HWRM_SEQ_ID_INVALID -1U
 /* Convert Bit field location to value */
 #define ASYNC_CMPL_EVENT_ID_LINK_STATUS_CHANGE	\
 	(1 << HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE)
-- 
2.21.1 (Apple Git-122.3)


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

* [dpdk-stable] [PATCH v2 03/12] net/bnxt: fix VNIC configuration
       [not found] ` <20210310212637.72205-1-ajit.khaparde@broadcom.com>
  2021-03-10 21:26   ` [dpdk-stable] [PATCH v2 02/12] net/bnxt: remove unused macro Ajit Khaparde
@ 2021-03-10 21:26   ` Ajit Khaparde
  2021-03-10 21:26   ` [dpdk-stable] [PATCH v2 05/12] net/bnxt: fix queues per VNIC Ajit Khaparde
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: Ajit Khaparde @ 2021-03-10 21:26 UTC (permalink / raw)
  To: ferruh.yigit; +Cc: ajit.khaparde, dev, kalesh-anakkur.purayil, stable

[-- Attachment #1: Type: text/plain, Size: 2248 bytes --]

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

PMD should not set any flags to receive RoCE traffic while
configuring the vnic. Since the PMD does not support RoCE
some of the flags and code is unused. Clean it up.

Fixes: b7778e8a1c00 ("net/bnxt: refactor to properly allocate resources for PF/VF")
Cc: stable@dpdk.org

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_hwrm.c | 10 ----------
 drivers/net/bnxt/bnxt_vnic.h |  2 --
 2 files changed, 12 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index cb8baa8776..5366fe72ca 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -2013,12 +2013,6 @@ int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic)
 	if (vnic->bd_stall)
 		req.flags |=
 		    rte_cpu_to_le_32(HWRM_VNIC_CFG_INPUT_FLAGS_BD_STALL_MODE);
-	if (vnic->roce_dual)
-		req.flags |= rte_cpu_to_le_32(
-			HWRM_VNIC_QCFG_OUTPUT_FLAGS_ROCE_DUAL_VNIC_MODE);
-	if (vnic->roce_only)
-		req.flags |= rte_cpu_to_le_32(
-			HWRM_VNIC_QCFG_OUTPUT_FLAGS_ROCE_ONLY_VNIC_MODE);
 	if (vnic->rss_dflt_cr)
 		req.flags |= rte_cpu_to_le_32(
 			HWRM_VNIC_QCFG_OUTPUT_FLAGS_RSS_DFLT_CR_MODE);
@@ -2066,10 +2060,6 @@ int bnxt_hwrm_vnic_qcfg(struct bnxt *bp, struct bnxt_vnic_info *vnic,
 			HWRM_VNIC_QCFG_OUTPUT_FLAGS_VLAN_STRIP_MODE;
 	vnic->bd_stall = rte_le_to_cpu_32(resp->flags) &
 			HWRM_VNIC_QCFG_OUTPUT_FLAGS_BD_STALL_MODE;
-	vnic->roce_dual = rte_le_to_cpu_32(resp->flags) &
-			HWRM_VNIC_QCFG_OUTPUT_FLAGS_ROCE_DUAL_VNIC_MODE;
-	vnic->roce_only = rte_le_to_cpu_32(resp->flags) &
-			HWRM_VNIC_QCFG_OUTPUT_FLAGS_ROCE_ONLY_VNIC_MODE;
 	vnic->rss_dflt_cr = rte_le_to_cpu_32(resp->flags) &
 			HWRM_VNIC_QCFG_OUTPUT_FLAGS_RSS_DFLT_CR_MODE;
 
diff --git a/drivers/net/bnxt/bnxt_vnic.h b/drivers/net/bnxt/bnxt_vnic.h
index 917b909284..00a664c8b8 100644
--- a/drivers/net/bnxt/bnxt_vnic.h
+++ b/drivers/net/bnxt/bnxt_vnic.h
@@ -52,8 +52,6 @@ struct bnxt_vnic_info {
 	bool		vlan_strip;
 	bool		func_default;
 	bool		bd_stall;
-	bool		roce_dual;
-	bool		roce_only;
 	bool		rss_dflt_cr;
 
 	STAILQ_HEAD(, bnxt_filter_info)	filter;
-- 
2.21.1 (Apple Git-122.3)


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

* [dpdk-stable] [PATCH v2 05/12] net/bnxt: fix queues per VNIC
       [not found] ` <20210310212637.72205-1-ajit.khaparde@broadcom.com>
  2021-03-10 21:26   ` [dpdk-stable] [PATCH v2 02/12] net/bnxt: remove unused macro Ajit Khaparde
  2021-03-10 21:26   ` [dpdk-stable] [PATCH v2 03/12] net/bnxt: fix VNIC configuration Ajit Khaparde
@ 2021-03-10 21:26   ` Ajit Khaparde
  2021-03-10 21:26   ` [dpdk-stable] [PATCH v2 10/12] net/bnxt: fix firmware fatal error handling Ajit Khaparde
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: Ajit Khaparde @ 2021-03-10 21:26 UTC (permalink / raw)
  To: ferruh.yigit
  Cc: ajit.khaparde, dev, kalesh-anakkur.purayil, Venkat Duvvuru,
	stable, Somnath Kotur

[-- Attachment #1: Type: text/plain, Size: 1670 bytes --]

From: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>

Update queues per VNIC in single queue mode.
bp->rx_num_qs_per_vnic is not initialized in the single queue mode.
As a result of this when an interface is reconfigured to single
queue mode from an existing multiqueue mode, bp->rx_num_qs_per_vnic
is not updated to the value of 1. Hence, the driver will try to
access more than one queue resulting in a crash.

This patch fixes it by initializing bp->rx_num_qs_per_vnic in the
single queue mode as well.

Fixes: 36024b2e7fe5 ("net/bnxt: allow dynamic creation of VNIC")
Cc: stable@dpdk.org

Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_rxq.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c
index f46b10c1c5..53a9b52a46 100644
--- a/drivers/net/bnxt/bnxt_rxq.c
+++ b/drivers/net/bnxt/bnxt_rxq.c
@@ -106,7 +106,6 @@ int bnxt_mq_rx_configure(struct bnxt *bp)
 
 	pools = RTE_MIN(pools, bp->rx_cp_nr_rings);
 	nb_q_per_grp = bp->rx_cp_nr_rings / pools;
-	bp->rx_num_qs_per_vnic = nb_q_per_grp;
 	PMD_DRV_LOG(DEBUG, "pools = %u nb_q_per_grp = %u\n",
 		    pools, nb_q_per_grp);
 	start_grp_id = 0;
@@ -165,6 +164,8 @@ int bnxt_mq_rx_configure(struct bnxt *bp)
 	}
 
 out:
+	bp->rx_num_qs_per_vnic = nb_q_per_grp;
+
 	if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG) {
 		struct rte_eth_rss_conf *rss = &dev_conf->rx_adv_conf.rss_conf;
 
-- 
2.21.1 (Apple Git-122.3)


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

* [dpdk-stable] [PATCH v2 10/12] net/bnxt: fix firmware fatal error handling
       [not found] ` <20210310212637.72205-1-ajit.khaparde@broadcom.com>
                     ` (2 preceding siblings ...)
  2021-03-10 21:26   ` [dpdk-stable] [PATCH v2 05/12] net/bnxt: fix queues per VNIC Ajit Khaparde
@ 2021-03-10 21:26   ` Ajit Khaparde
  2021-03-10 21:26   ` [dpdk-stable] [PATCH v2 11/12] net/bnxt: fix FW readiness check during recovery Ajit Khaparde
  2021-03-10 21:26   ` [dpdk-stable] [PATCH v2 12/12] net/bnxt: fix PTP support for Thor Ajit Khaparde
  5 siblings, 0 replies; 6+ messages in thread
From: Ajit Khaparde @ 2021-03-10 21:26 UTC (permalink / raw)
  To: ferruh.yigit
  Cc: ajit.khaparde, dev, kalesh-anakkur.purayil, stable, Somnath Kotur

[-- Attachment #1: Type: text/plain, Size: 4104 bytes --]

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

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")
Cc: stable@dpdk.org

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 | 56 ++++++++++++++++++++++++++++++++--
 drivers/net/bnxt/bnxt_util.h   |  2 ++
 2 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 9e0ec46403..67ff800da5 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -3743,6 +3743,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;
@@ -3840,6 +3866,13 @@ static void bnxt_dev_recover(void *arg)
 	int rc = 0;
 
 	pthread_mutex_lock(&bp->err_recovery_lock);
+
+	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;
 
@@ -3891,14 +3924,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 8de55e1038..64e97eed15 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.21.1 (Apple Git-122.3)


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

* [dpdk-stable] [PATCH v2 11/12] net/bnxt: fix FW readiness check during recovery
       [not found] ` <20210310212637.72205-1-ajit.khaparde@broadcom.com>
                     ` (3 preceding siblings ...)
  2021-03-10 21:26   ` [dpdk-stable] [PATCH v2 10/12] net/bnxt: fix firmware fatal error handling Ajit Khaparde
@ 2021-03-10 21:26   ` Ajit Khaparde
  2021-03-10 21:26   ` [dpdk-stable] [PATCH v2 12/12] net/bnxt: fix PTP support for Thor Ajit Khaparde
  5 siblings, 0 replies; 6+ messages in thread
From: Ajit Khaparde @ 2021-03-10 21:26 UTC (permalink / raw)
  To: ferruh.yigit
  Cc: ajit.khaparde, dev, kalesh-anakkur.purayil, stable, Somnath Kotur

[-- Attachment #1: Type: text/plain, Size: 3759 bytes --]

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

Moved fw readiness check to a new routine bnxt_check_fw_ready().

During error recovery, driver needs to wait for fw readiness.
For that, it uses bnxt_hwrm_ver_get() function now and that
function does parsing of the VER_GET response as well.

Added a new lightweight function bnxt_hwrm_poll_ver_get() for polling
the firmware readiness which issues VER_GET and checks for success
without processing the command response.

Fixes: df6cd7c1f73a ("net/bnxt: handle reset notify async event from FW")
Cc: stable@dpdk.org

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 | 33 +++++++++++++++++++++------------
 drivers/net/bnxt/bnxt_hwrm.c   | 22 ++++++++++++++++++++++
 drivers/net/bnxt/bnxt_hwrm.h   |  1 +
 3 files changed, 44 insertions(+), 12 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 67ff800da5..af146451a5 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -3859,10 +3859,28 @@ static int bnxt_restore_filters(struct bnxt *bp)
 	return ret;
 }
 
+static int bnxt_check_fw_ready(struct bnxt *bp)
+{
+	int timeout = bp->fw_reset_max_msecs;
+	int rc = 0;
+
+	do {
+		rc = bnxt_hwrm_poll_ver_get(bp);
+		if (rc == 0)
+			break;
+		rte_delay_ms(BNXT_FW_READY_WAIT_INTERVAL);
+		timeout -= BNXT_FW_READY_WAIT_INTERVAL;
+	} while (rc && timeout > 0);
+
+	if (rc)
+		PMD_DRV_LOG(ERR, "FW is not Ready after reset\n");
+
+	return rc;
+}
+
 static void bnxt_dev_recover(void *arg)
 {
 	struct bnxt *bp = arg;
-	int timeout = bp->fw_reset_max_msecs;
 	int rc = 0;
 
 	pthread_mutex_lock(&bp->err_recovery_lock);
@@ -3876,18 +3894,9 @@ static void bnxt_dev_recover(void *arg)
 	/* Clear Error flag so that device re-init should happen */
 	bp->flags &= ~BNXT_FLAG_FATAL_ERROR;
 
-	do {
-		rc = bnxt_hwrm_ver_get(bp, SHORT_HWRM_CMD_TIMEOUT);
-		if (rc == 0)
-			break;
-		rte_delay_ms(BNXT_FW_READY_WAIT_INTERVAL);
-		timeout -= BNXT_FW_READY_WAIT_INTERVAL;
-	} while (rc && timeout);
-
-	if (rc) {
-		PMD_DRV_LOG(ERR, "FW is not Ready after reset\n");
+	rc = bnxt_check_fw_ready(bp);
+	if (rc)
 		goto err;
-	}
 
 	rc = bnxt_init_resources(bp, true);
 	if (rc) {
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 9142119954..0b5318e238 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -5913,3 +5913,25 @@ int bnxt_hwrm_fw_echo_reply(struct bnxt *bp, uint32_t echo_req_data1,
 
 	return rc;
 }
+
+int bnxt_hwrm_poll_ver_get(struct bnxt *bp)
+{
+	struct hwrm_ver_get_input req = {.req_type = 0 };
+	struct hwrm_ver_get_output *resp = bp->hwrm_cmd_resp_addr;
+	int rc = 0;
+
+	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);
+	req.hwrm_intf_maj = HWRM_VERSION_MAJOR;
+	req.hwrm_intf_min = HWRM_VERSION_MINOR;
+	req.hwrm_intf_upd = HWRM_VERSION_UPDATE;
+
+	rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
+
+	HWRM_CHECK_RESULT_SILENT();
+	HWRM_UNLOCK();
+
+	return rc;
+}
diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h
index c47c2498e9..785e321bfd 100644
--- a/drivers/net/bnxt/bnxt_hwrm.h
+++ b/drivers/net/bnxt/bnxt_hwrm.h
@@ -304,4 +304,5 @@ int bnxt_hwrm_cfa_pair_free(struct bnxt *bp, struct bnxt_representor *rep);
 int bnxt_hwrm_cfa_adv_flow_mgmt_qcaps(struct bnxt *bp);
 int bnxt_hwrm_fw_echo_reply(struct bnxt *bp, uint32_t echo_req_data1,
 			    uint32_t echo_req_data2);
+int bnxt_hwrm_poll_ver_get(struct bnxt *bp);
 #endif
-- 
2.21.1 (Apple Git-122.3)


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

* [dpdk-stable] [PATCH v2 12/12] net/bnxt: fix PTP support for Thor
       [not found] ` <20210310212637.72205-1-ajit.khaparde@broadcom.com>
                     ` (4 preceding siblings ...)
  2021-03-10 21:26   ` [dpdk-stable] [PATCH v2 11/12] net/bnxt: fix FW readiness check during recovery Ajit Khaparde
@ 2021-03-10 21:26   ` Ajit Khaparde
  5 siblings, 0 replies; 6+ messages in thread
From: Ajit Khaparde @ 2021-03-10 21:26 UTC (permalink / raw)
  To: ferruh.yigit
  Cc: ajit.khaparde, dev, kalesh-anakkur.purayil, stable, Lance Richardson

[-- Attachment #1: Type: text/plain, Size: 6401 bytes --]

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

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")
Cc: stable@dpdk.org

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        |  8 ++++
 drivers/net/bnxt/bnxt_ethdev.c | 79 +++++++++++++++++++++++++++++++++-
 drivers/net/bnxt/bnxt_rxr.c    | 17 +++++---
 3 files changed, 97 insertions(+), 7 deletions(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index bf3459e830..de1b4af919 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -309,6 +309,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
@@ -358,6 +359,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 {
@@ -671,6 +673,12 @@ struct bnxt {
 #define BNXT_TRUFLOW_EN(bp)	((bp)->flags & BNXT_FLAG_TRUFLOW_EN)
 #define BNXT_GFID_ENABLED(bp)	((bp)->flags & BNXT_FLAG_GFID_ENABLE)
 
+	uint32_t			flags2;
+#define BNXT_FLAGS2_PTP_TIMESYNC_ENABLED	BIT(0)
+#define BNXT_FLAGS2_PTP_ALARM_SCHEDULED		BIT(1)
+#define BNXT_P5_PTP_TIMESYNC_ENABLED(bp)	\
+	((bp)->flags2 & BNXT_FLAGS2_PTP_TIMESYNC_ENABLED)
+
 	uint16_t		chip_num;
 #define CHIP_NUM_58818		0xd818
 #define BNXT_CHIP_SR2(bp)	((bp)->chip_num == CHIP_NUM_58818)
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index af146451a5..c55a2d8197 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1300,6 +1300,73 @@ static void bnxt_free_switch_domain(struct bnxt *bp)
 	}
 }
 
+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->flags2 &= ~BNXT_FLAGS2_PTP_ALARM_SCHEDULED;
+	}
+}
+
+static int bnxt_schedule_ptp_alarm(struct bnxt *bp)
+{
+	struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
+	int rc;
+
+	if (bp->flags2 & BNXT_FLAGS2_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->flags2 & BNXT_FLAGS2_PTP_ALARM_SCHEDULED) {
+		rte_eal_alarm_cancel(bnxt_ptp_get_current_time, (void *)bp);
+		bp->flags2 &= ~BNXT_FLAGS2_PTP_ALARM_SCHEDULED;
+	}
+}
+
+static void bnxt_ptp_stop(struct bnxt *bp)
+{
+	bnxt_cancel_ptp_alarm(bp);
+	bp->flags2 &= ~BNXT_FLAGS2_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->flags2 |= BNXT_FLAGS2_PTP_TIMESYNC_ENABLED;
+		bp->flags2 |= BNXT_FLAGS2_PTP_ALARM_SCHEDULED;
+	}
+
+	return rc;
+}
+
 static int bnxt_dev_stop(struct rte_eth_dev *eth_dev)
 {
 	struct bnxt *bp = eth_dev->data->dev_private;
@@ -1330,6 +1397,9 @@ static int bnxt_dev_stop(struct rte_eth_dev *eth_dev)
 
 	bnxt_cancel_fw_health_check(bp);
 
+	if (BNXT_P5_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);
@@ -1449,6 +1519,9 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
 
 	bnxt_schedule_fw_health_check(bp);
 
+	if (BNXT_P5_PTP_TIMESYNC_ENABLED(bp))
+		bnxt_schedule_ptp_alarm(bp);
+
 	return 0;
 
 error:
@@ -3351,8 +3424,10 @@ bnxt_timesync_enable(struct rte_eth_dev *dev)
 
 	if (!BNXT_CHIP_P5(bp))
 		bnxt_map_ptp_regs(bp);
+	else
+		rc = bnxt_ptp_start(bp);
 
-	return 0;
+	return rc;
 }
 
 static int
@@ -3372,6 +3447,8 @@ bnxt_timesync_disable(struct rte_eth_dev *dev)
 
 	if (!BNXT_CHIP_P5(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 498811a732..30d22b7aba 100644
--- a/drivers/net/bnxt/bnxt_rxr.c
+++ b/drivers/net/bnxt/bnxt_rxr.c
@@ -603,9 +603,11 @@ bnxt_set_ol_flags(struct bnxt_rx_ring_info *rxr, struct rx_pkt_cmpl *rxcmp,
 static void
 bnxt_get_rx_ts_p5(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_P5(bp))
+	if (!BNXT_CHIP_P5(bp) || !ptp)
 		return;
 
 	/* On Thor, Rx timestamps are provided directly in the
@@ -616,10 +618,13 @@ bnxt_get_rx_ts_p5(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.21.1 (Apple Git-122.3)


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

end of thread, other threads:[~2021-03-10 21:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <d3d41dec-035d-7dd5-ec5b-cd9f6f3536cb@intel.com>
     [not found] ` <20210310212637.72205-1-ajit.khaparde@broadcom.com>
2021-03-10 21:26   ` [dpdk-stable] [PATCH v2 02/12] net/bnxt: remove unused macro Ajit Khaparde
2021-03-10 21:26   ` [dpdk-stable] [PATCH v2 03/12] net/bnxt: fix VNIC configuration Ajit Khaparde
2021-03-10 21:26   ` [dpdk-stable] [PATCH v2 05/12] net/bnxt: fix queues per VNIC Ajit Khaparde
2021-03-10 21:26   ` [dpdk-stable] [PATCH v2 10/12] net/bnxt: fix firmware fatal error handling Ajit Khaparde
2021-03-10 21:26   ` [dpdk-stable] [PATCH v2 11/12] net/bnxt: fix FW readiness check during recovery Ajit Khaparde
2021-03-10 21:26   ` [dpdk-stable] [PATCH v2 12/12] net/bnxt: fix PTP support for Thor Ajit Khaparde

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