patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Kalesh A P <kalesh-anakkur.purayil@broadcom.com>
To: stable@dpdk.org
Cc: ajit.khaparde@broadcom.com, bluca@debian.org
Subject: [dpdk-stable] [PATCH 19.11 2/2] net/bnxt: fix setting link speed
Date: Wed, 12 Aug 2020 09:22:35 +0530	[thread overview]
Message-ID: <20200812035235.32516-2-kalesh-anakkur.purayil@broadcom.com> (raw)
In-Reply-To: <20200812035235.32516-1-kalesh-anakkur.purayil@broadcom.com>

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

[ upstream commit 0466d286cdedc98ab561fcb23fb125e6d9329678 ]

bnxt PMD uses the macro BNXT_SUPPORTED_SPEEDS to validate
the user requested speed. But this has all the speed values
supported by the PMD and is not chip specific.

The check against this macro returns success when the user
tries set the speed to 100G on a port even if the chip does
not support 100G speed.

Fixed it to use bnxt_get_speed_capabilities() to check the
supported speeds by the chip.

Fixes: 1d0704f4d793 ("net/bnxt: add device configure operation")

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.h        |  1 +
 drivers/net/bnxt/bnxt_ethdev.c |  2 +-
 drivers/net/bnxt/bnxt_hwrm.c   | 14 +++++++++-----
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 46cf418..d9fe943 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -680,6 +680,7 @@ void bnxt_schedule_fw_health_check(struct bnxt *bp);
 
 bool is_bnxt_supported(struct rte_eth_dev *dev);
 bool bnxt_stratus_device(struct bnxt *bp);
+uint32_t bnxt_get_speed_capabilities(struct bnxt *bp);
 extern const struct rte_flow_ops bnxt_flow_ops;
 #define bnxt_acquire_flow_lock(bp) \
 	pthread_mutex_lock(&(bp)->flow_lock)
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 90e1a33..8e65839 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -490,7 +490,7 @@ static int bnxt_shutdown_nic(struct bnxt *bp)
  * Device configuration and status function
  */
 
-static uint32_t bnxt_get_speed_capabilities(struct bnxt *bp)
+uint32_t bnxt_get_speed_capabilities(struct bnxt *bp)
 {
 	uint32_t link_speed = bp->link_info.support_speeds;
 	uint32_t speed_capa = 0;
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index fed1aa3..0e73f08 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -2684,13 +2684,18 @@ static uint16_t bnxt_parse_eth_link_speed(uint32_t conf_link_speed)
 		ETH_LINK_SPEED_10G | ETH_LINK_SPEED_20G | ETH_LINK_SPEED_25G | \
 		ETH_LINK_SPEED_40G | ETH_LINK_SPEED_50G | ETH_LINK_SPEED_100G)
 
-static int bnxt_valid_link_speed(uint32_t link_speed, uint16_t port_id)
+static int bnxt_validate_link_speed(struct bnxt *bp)
 {
+	uint32_t link_speed = bp->eth_dev->data->dev_conf.link_speeds;
+	uint16_t port_id = bp->eth_dev->data->port_id;
+	uint32_t link_speed_capa;
 	uint32_t one_speed;
 
 	if (link_speed == ETH_LINK_SPEED_AUTONEG)
 		return 0;
 
+	link_speed_capa = bnxt_get_speed_capabilities(bp);
+
 	if (link_speed & ETH_LINK_SPEED_FIXED) {
 		one_speed = link_speed & ~ETH_LINK_SPEED_FIXED;
 
@@ -2700,14 +2705,14 @@ static int bnxt_valid_link_speed(uint32_t link_speed, uint16_t port_id)
 				link_speed, port_id);
 			return -EINVAL;
 		}
-		if ((one_speed & BNXT_SUPPORTED_SPEEDS) != one_speed) {
+		if ((one_speed & link_speed_capa) != one_speed) {
 			PMD_DRV_LOG(ERR,
 				"Unsupported advertised speed (%u) for port %u\n",
 				link_speed, port_id);
 			return -EINVAL;
 		}
 	} else {
-		if (!(link_speed & BNXT_SUPPORTED_SPEEDS)) {
+		if (!(link_speed & link_speed_capa)) {
 			PMD_DRV_LOG(ERR,
 				"Unsupported advertised speeds (%u) for port %u\n",
 				link_speed, port_id);
@@ -2848,8 +2853,7 @@ int bnxt_set_hwrm_link_config(struct bnxt *bp, bool link_up)
 	if (!BNXT_SINGLE_PF(bp) || BNXT_VF(bp))
 		return 0;
 
-	rc = bnxt_valid_link_speed(dev_conf->link_speeds,
-			bp->eth_dev->data->port_id);
+	rc = bnxt_validate_link_speed(bp);
 	if (rc)
 		goto error;
 
-- 
2.10.1


  reply	other threads:[~2020-08-12  3:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-12  3:52 [dpdk-stable] [PATCH 19.11 1/2] net/bnxt: support speed capabilities query Kalesh A P
2020-08-12  3:52 ` Kalesh A P [this message]
2020-08-12  8:38 ` Luca Boccassi
2020-08-13  4:29   ` Ajit Khaparde
2020-08-13  8:47     ` Luca Boccassi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200812035235.32516-2-kalesh-anakkur.purayil@broadcom.com \
    --to=kalesh-anakkur.purayil@broadcom.com \
    --cc=ajit.khaparde@broadcom.com \
    --cc=bluca@debian.org \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).