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 0451BA00C3 for ; Fri, 15 May 2020 20:46:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D1E351DB41; Fri, 15 May 2020 20:46:00 +0200 (CEST) Received: from rnd-relay.smtp.broadcom.com (rnd-relay.smtp.broadcom.com [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id 0EB241DAC0; Fri, 15 May 2020 20:45:52 +0200 (CEST) Received: from mail-irv-17.broadcom.com (mail-irv-17.lvn.broadcom.net [10.75.242.48]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id 7301391BEC; Fri, 15 May 2020 11:44:44 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com 7301391BEC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1589568284; bh=6PLKxsk2TUtkRv/7Jklqn4ck+RxhpHbGlhcZemwd/so=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d1nVfx2Je7RkAIoWywY1t3SSEHDsdZdE8e851UyEyKeQgFF/QLCmgAEvxMJ2Zv/TJ 18+o5kSNn5rPnuaDzJxoOtgxJCRWN9NkIi2XWeqWYyA4krDhJEj9w3OYKxwUE2Ehtz LQ60SALVGR7TkdbH//Oxbah7nmXShwBTMvwgjVCY= Received: from localhost.localdomain (unknown [10.230.185.215]) by mail-irv-17.broadcom.com (Postfix) with ESMTP id 84B9C14008D; Fri, 15 May 2020 11:45:50 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: ferruh.yigit@intel.com, stable@dpdk.org, Kalesh AP , Somnath Kotur Date: Fri, 15 May 2020 11:45:38 -0700 Message-Id: <20200515184542.89318-6-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200515184542.89318-1-ajit.khaparde@broadcom.com> References: <20200515184542.89318-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH v1 5/9] net/bnxt: fix to alloc link info struct X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Dynamically alloc link info structure. Fixes: 1d0704f4d793 ("net/bnxt: add device configure operation") Cc: stable@dpdk.org Signed-off-by: Ajit Khaparde Signed-off-by: Kalesh AP Reviewed-by: Somnath Kotur --- drivers/net/bnxt/bnxt.h | 2 +- drivers/net/bnxt/bnxt_ethdev.c | 65 ++++++++++++++++++++++------------ drivers/net/bnxt/bnxt_hwrm.c | 28 +++++++-------- 3 files changed, 58 insertions(+), 37 deletions(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index b71435495..b66f6ba25 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -648,7 +648,7 @@ struct bnxt { /* default HWRM request timeout value */ uint32_t hwrm_cmd_timeout; - struct bnxt_link_info link_info; + struct bnxt_link_info *link_info; struct bnxt_cos_queue_info *rx_cos_queue; struct bnxt_cos_queue_info *tx_cos_queue; uint8_t tx_cosq_id[BNXT_COS_QUEUE_COUNT]; diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 90fb7f635..7367c14d4 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -191,6 +191,11 @@ static uint16_t bnxt_rss_hash_tbl_size(const struct bnxt *bp) return bnxt_rss_ctxts(bp) * BNXT_RSS_ENTRIES_PER_CTX_THOR; } +static void bnxt_free_link_info(struct bnxt *bp) +{ + rte_free(bp->link_info); +} + static void bnxt_free_leds_info(struct bnxt *bp) { rte_free(bp->leds); @@ -233,6 +238,16 @@ static void bnxt_free_mem(struct bnxt *bp, bool reconfig) bp->grp_info = NULL; } +static int bnxt_alloc_link_info(struct bnxt *bp) +{ + bp->link_info = + rte_zmalloc("bnxt_link_info", sizeof(struct bnxt_link_info), 0); + if (bp->link_info == NULL) + return -ENOMEM; + + return 0; +} + static int bnxt_alloc_leds_info(struct bnxt *bp) { bp->leds = rte_zmalloc("bnxt_leds", @@ -709,7 +724,7 @@ static int bnxt_init_chip(struct bnxt *bp) goto err_free; } - if (!bp->link_info.link_up) { + if (!bp->link_info->link_up) { rc = bnxt_set_hwrm_link_config(bp, true); if (rc) { PMD_DRV_LOG(ERR, @@ -751,7 +766,7 @@ static int bnxt_shutdown_nic(struct bnxt *bp) static uint32_t bnxt_get_speed_capabilities(struct bnxt *bp) { - uint32_t link_speed = bp->link_info.support_speeds; + uint32_t link_speed = bp->link_info->support_speeds; uint32_t speed_capa = 0; if (link_speed & HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100MB) @@ -777,7 +792,8 @@ static uint32_t bnxt_get_speed_capabilities(struct bnxt *bp) if (link_speed & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_200GB) speed_capa |= ETH_LINK_SPEED_200G; - if (bp->link_info.auto_mode == HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_MODE_NONE) + if (bp->link_info->auto_mode == + HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_MODE_NONE) speed_capa |= ETH_LINK_SPEED_FIXED; else speed_capa |= ETH_LINK_SPEED_AUTONEG; @@ -1210,7 +1226,7 @@ static int bnxt_dev_set_link_up_op(struct rte_eth_dev *eth_dev) struct bnxt *bp = eth_dev->data->dev_private; int rc = 0; - if (!bp->link_info.link_up) + if (!bp->link_info->link_up) rc = bnxt_set_hwrm_link_config(bp, true); if (!rc) eth_dev->data->dev_link.link_status = 1; @@ -1225,7 +1241,7 @@ static int bnxt_dev_set_link_down_op(struct rte_eth_dev *eth_dev) eth_dev->data->dev_link.link_status = 0; bnxt_set_hwrm_link_config(bp, false); - bp->link_info.link_up = 0; + bp->link_info->link_up = 0; return 0; } @@ -1302,6 +1318,7 @@ static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev) bnxt_free_leds_info(bp); bnxt_free_cos_queues(bp); + bnxt_free_link_info(bp); eth_dev->dev_ops = NULL; eth_dev->rx_pkt_burst = NULL; @@ -1867,9 +1884,9 @@ static int bnxt_flow_ctrl_get_op(struct rte_eth_dev *dev, return rc; memset(fc_conf, 0, sizeof(*fc_conf)); - if (bp->link_info.auto_pause) + if (bp->link_info->auto_pause) fc_conf->autoneg = 1; - switch (bp->link_info.pause) { + switch (bp->link_info->pause) { case 0: fc_conf->mode = RTE_FC_NONE; break; @@ -1904,40 +1921,40 @@ static int bnxt_flow_ctrl_set_op(struct rte_eth_dev *dev, switch (fc_conf->mode) { case RTE_FC_NONE: - bp->link_info.auto_pause = 0; - bp->link_info.force_pause = 0; + bp->link_info->auto_pause = 0; + bp->link_info->force_pause = 0; break; case RTE_FC_RX_PAUSE: if (fc_conf->autoneg) { - bp->link_info.auto_pause = + bp->link_info->auto_pause = HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_RX; - bp->link_info.force_pause = 0; + bp->link_info->force_pause = 0; } else { - bp->link_info.auto_pause = 0; - bp->link_info.force_pause = + bp->link_info->auto_pause = 0; + bp->link_info->force_pause = HWRM_PORT_PHY_CFG_INPUT_FORCE_PAUSE_RX; } break; case RTE_FC_TX_PAUSE: if (fc_conf->autoneg) { - bp->link_info.auto_pause = + bp->link_info->auto_pause = HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_TX; - bp->link_info.force_pause = 0; + bp->link_info->force_pause = 0; } else { - bp->link_info.auto_pause = 0; - bp->link_info.force_pause = + bp->link_info->auto_pause = 0; + bp->link_info->force_pause = HWRM_PORT_PHY_CFG_INPUT_FORCE_PAUSE_TX; } break; case RTE_FC_FULL: if (fc_conf->autoneg) { - bp->link_info.auto_pause = + bp->link_info->auto_pause = HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_TX | HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_RX; - bp->link_info.force_pause = 0; + bp->link_info->force_pause = 0; } else { - bp->link_info.auto_pause = 0; - bp->link_info.force_pause = + bp->link_info->auto_pause = 0; + bp->link_info->force_pause = HWRM_PORT_PHY_CFG_INPUT_FORCE_PAUSE_TX | HWRM_PORT_PHY_CFG_INPUT_FORCE_PAUSE_RX; } @@ -4229,7 +4246,7 @@ static void bnxt_write_fw_reset_reg(struct bnxt *bp, uint32_t index) static void bnxt_dev_cleanup(struct bnxt *bp) { bnxt_set_hwrm_link_config(bp, false); - bp->link_info.link_up = 0; + bp->link_info->link_up = 0; if (bp->eth_dev->data->dev_started) bnxt_dev_stop_op(bp->eth_dev); @@ -5440,6 +5457,10 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev) return rc; } + rc = bnxt_alloc_link_info(bp); + if (rc) + goto error_free; + rc = bnxt_alloc_hwrm_resources(bp); if (rc) { PMD_DRV_LOG(ERR, diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 4022fafd1..2e93a847f 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -1223,7 +1223,7 @@ static int bnxt_hwrm_port_phy_cfg(struct bnxt *bp, struct bnxt_link_info *conf) if (conf->link_up) { /* Setting Fixed Speed. But AutoNeg is ON, So disable it */ - if (bp->link_info.auto_mode && conf->link_speed) { + if (bp->link_info->auto_mode && conf->link_speed) { req.auto_mode = HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_NONE; PMD_DRV_LOG(DEBUG, "Disabling AutoNeg\n"); } @@ -2821,8 +2821,8 @@ bnxt_parse_eth_link_speed_mask(struct bnxt *bp, uint32_t link_speed) uint16_t ret = 0; if (link_speed == ETH_LINK_SPEED_AUTONEG) { - if (bp->link_info.support_speeds) - return bp->link_info.support_speeds; + if (bp->link_info->support_speeds) + return bp->link_info->support_speeds; link_speed = BNXT_SUPPORTED_SPEEDS; } @@ -2919,7 +2919,7 @@ static uint16_t bnxt_parse_hw_link_duplex(uint16_t hw_link_duplex) int bnxt_get_hwrm_link_config(struct bnxt *bp, struct rte_eth_link *link) { int rc = 0; - struct bnxt_link_info *link_info = &bp->link_info; + struct bnxt_link_info *link_info = bp->link_info; rc = bnxt_hwrm_port_phy_qcfg(bp, link_info); if (rc) { @@ -2981,19 +2981,19 @@ int bnxt_set_hwrm_link_config(struct bnxt *bp, bool link_up) */ if (autoneg == 1 && !(!BNXT_CHIP_THOR(bp) && - (bp->link_info.auto_link_speed || - bp->link_info.force_link_speed))) { + (bp->link_info->auto_link_speed || + bp->link_info->force_link_speed))) { link_req.phy_flags |= HWRM_PORT_PHY_CFG_INPUT_FLAGS_RESTART_AUTONEG; link_req.auto_link_speed_mask = bnxt_parse_eth_link_speed_mask(bp, dev_conf->link_speeds); } else { - if (bp->link_info.phy_type == + if (bp->link_info->phy_type == HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASET || - bp->link_info.phy_type == + bp->link_info->phy_type == HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASETE || - bp->link_info.media_type == + bp->link_info->media_type == HWRM_PORT_PHY_QCFG_OUTPUT_MEDIA_TYPE_TP) { PMD_DRV_LOG(ERR, "10GBase-T devices must autoneg\n"); return -EINVAL; @@ -3003,14 +3003,14 @@ int bnxt_set_hwrm_link_config(struct bnxt *bp, bool link_up) /* If user wants a particular speed try that first. */ if (speed) link_req.link_speed = speed; - else if (bp->link_info.force_link_speed) - link_req.link_speed = bp->link_info.force_link_speed; + else if (bp->link_info->force_link_speed) + link_req.link_speed = bp->link_info->force_link_speed; else - link_req.link_speed = bp->link_info.auto_link_speed; + link_req.link_speed = bp->link_info->auto_link_speed; } link_req.duplex = bnxt_parse_eth_link_duplex(dev_conf->link_speeds); - link_req.auto_pause = bp->link_info.auto_pause; - link_req.force_pause = bp->link_info.force_pause; + link_req.auto_pause = bp->link_info->auto_pause; + link_req.force_pause = bp->link_info->force_pause; port_phy_cfg: rc = bnxt_hwrm_port_phy_cfg(bp, &link_req); -- 2.21.1 (Apple Git-122.3)