From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 987B7A04A2; Fri, 22 May 2020 19:26:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BD7A21D9F4; Fri, 22 May 2020 19:26:21 +0200 (CEST) Received: from relay.smtp.broadcom.com (relay.smtp.broadcom.com [192.19.232.149]) by dpdk.org (Postfix) with ESMTP id 7B5661D9F3 for ; Fri, 22 May 2020 19:26:20 +0200 (CEST) Received: from dhcp-10-123-153-22.dhcp.broadcom.net (bgccx-dev-host-lnx2.bec.broadcom.net [10.123.153.22]) by relay.smtp.broadcom.com (Postfix) with ESMTP id 643611BFEDA; Fri, 22 May 2020 10:26:17 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com 643611BFEDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1590168378; bh=1XjBMCd7TZqkSUBfJBp5MQwGoEVBF6+Udb/7xh5N3H4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s66jcr3P/pFSqsY1ra/++Jhv3C4vM0xpJp9gg/gbzoTMquEiSKombQ3sOxFMcM1Ej bYoZNw9ojYZtA/SiGgTO2lpmrOam4Ntnd+kGnmy7NQYDaGSI2DZvvYBPb0eJGRCKP2 M7jTs3uGV5w9OUp916Qe235Zaqm2CGNZAqNVUg8c= From: Kalesh A P To: dev@dpdk.org Cc: ferruh.yigit@intel.com, ajit.khaparde@broadcom.com Date: Fri, 22 May 2020 23:12:08 +0530 Message-Id: <20200522174209.19402-2-kalesh-anakkur.purayil@broadcom.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20200522174209.19402-1-kalesh-anakkur.purayil@broadcom.com> References: <20200522173254.18643-2-kalesh-anakkur.purayil@broadcom.com> <20200522174209.19402-1-kalesh-anakkur.purayil@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] =?utf-8?q?_=5BPATCH_v2_1/2=5D_net/bnxt=3A_fix_the_chec?= =?utf-8?q?k_for_validating=C2=A0link_speed?= X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Kalesh AP 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") Cc: stable@dpdk.org Signed-off-by: Kalesh AP Reviewed-by: Somnath Kotur Reviewed-by: Ajit Kumar Khaparde --- 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 446764c..2c3aef6 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -780,4 +780,5 @@ void bnxt_cancel_fc_thread(struct bnxt *bp); void bnxt_flow_cnt_alarm_cb(void *arg); int bnxt_flow_stats_req(struct bnxt *bp); int bnxt_flow_stats_cnt(struct bnxt *bp); +uint32_t bnxt_get_speed_capabilities(struct bnxt *bp); #endif diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index ae495da..e635781 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -778,7 +778,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 c1798b5..945bc90 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -2788,13 +2788,18 @@ static uint16_t bnxt_parse_eth_link_speed(uint32_t conf_link_speed) ETH_LINK_SPEED_40G | ETH_LINK_SPEED_50G | \ ETH_LINK_SPEED_100G | ETH_LINK_SPEED_200G) -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; @@ -2804,14 +2809,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); @@ -2957,8 +2962,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