From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 180E045977; Fri, 13 Sep 2024 08:01:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4761D42E97; Fri, 13 Sep 2024 08:00:18 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by mails.dpdk.org (Postfix) with ESMTP id 4F74642E57 for ; Fri, 13 Sep 2024 08:00:07 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 297171A1D89; Fri, 13 Sep 2024 08:00:07 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id B94341A1DA4; Fri, 13 Sep 2024 08:00:06 +0200 (CEST) Received: from lsv03379.swis.in-blr01.nxp.com (lsv03379.swis.in-blr01.nxp.com [92.120.147.188]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id A9A47183DC0F; Fri, 13 Sep 2024 14:00:04 +0800 (+08) From: vanshika.shukla@nxp.com To: dev@dpdk.org, Hemant Agrawal , Sachin Saxena Cc: Brick Yang , Rohit Raj Subject: [v1 10/43] net/dpaa2: update DPNI link status method Date: Fri, 13 Sep 2024 11:29:26 +0530 Message-Id: <20240913055959.3246917-11-vanshika.shukla@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240913055959.3246917-1-vanshika.shukla@nxp.com> References: <20240913055959.3246917-1-vanshika.shukla@nxp.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV using ClamSMTP X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Brick Yang If SFP module is not connected to the port and flow control is configured using flow control API, link will show DOWN even after connecting the SFP module and fiber cable. This issue cannot be reproduced if only SFP module is connected and fiber cable is disconnected before configuring flow control even though link is down in this case too. This patch improves it by getting configuration values from dpni_get_link_cfg API instead of dpni_get_link_state API, which provides us static configuration data. Signed-off-by: Brick Yang Signed-off-by: Rohit Raj --- drivers/net/dpaa2/dpaa2_ethdev.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index 9172097abf..2fb9b8ea95 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -2084,7 +2084,7 @@ dpaa2_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) int ret = -EINVAL; struct dpaa2_dev_priv *priv; struct fsl_mc_io *dpni; - struct dpni_link_state state = {0}; + struct dpni_link_cfg cfg = {0}; PMD_INIT_FUNC_TRACE(); @@ -2096,14 +2096,14 @@ dpaa2_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) return ret; } - ret = dpni_get_link_state(dpni, CMD_PRI_LOW, priv->token, &state); + ret = dpni_get_link_cfg(dpni, CMD_PRI_LOW, priv->token, &cfg); if (ret) { - DPAA2_PMD_ERR("error: dpni_get_link_state %d", ret); + DPAA2_PMD_ERR("error: dpni_get_link_cfg %d", ret); return ret; } memset(fc_conf, 0, sizeof(struct rte_eth_fc_conf)); - if (state.options & DPNI_LINK_OPT_PAUSE) { + if (cfg.options & DPNI_LINK_OPT_PAUSE) { /* DPNI_LINK_OPT_PAUSE set * if ASYM_PAUSE not set, * RX Side flow control (handle received Pause frame) @@ -2112,7 +2112,7 @@ dpaa2_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) * RX Side flow control (handle received Pause frame) * No TX side flow control (send Pause frame disabled) */ - if (!(state.options & DPNI_LINK_OPT_ASYM_PAUSE)) + if (!(cfg.options & DPNI_LINK_OPT_ASYM_PAUSE)) fc_conf->mode = RTE_ETH_FC_FULL; else fc_conf->mode = RTE_ETH_FC_RX_PAUSE; @@ -2124,7 +2124,7 @@ dpaa2_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) * if ASYM_PAUSE not set, * Flow control disabled */ - if (state.options & DPNI_LINK_OPT_ASYM_PAUSE) + if (cfg.options & DPNI_LINK_OPT_ASYM_PAUSE) fc_conf->mode = RTE_ETH_FC_TX_PAUSE; else fc_conf->mode = RTE_ETH_FC_NONE; @@ -2139,7 +2139,6 @@ dpaa2_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) int ret = -EINVAL; struct dpaa2_dev_priv *priv; struct fsl_mc_io *dpni; - struct dpni_link_state state = {0}; struct dpni_link_cfg cfg = {0}; PMD_INIT_FUNC_TRACE(); @@ -2152,23 +2151,19 @@ dpaa2_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) return ret; } - /* It is necessary to obtain the current state before setting fc_conf + /* It is necessary to obtain the current cfg before setting fc_conf * as MC would return error in case rate, autoneg or duplex values are * different. */ - ret = dpni_get_link_state(dpni, CMD_PRI_LOW, priv->token, &state); + ret = dpni_get_link_cfg(dpni, CMD_PRI_LOW, priv->token, &cfg); if (ret) { - DPAA2_PMD_ERR("Unable to get link state (err=%d)", ret); + DPAA2_PMD_ERR("Unable to get link cfg (err=%d)", ret); return -1; } /* Disable link before setting configuration */ dpaa2_dev_set_link_down(dev); - /* Based on fc_conf, update cfg */ - cfg.rate = state.rate; - cfg.options = state.options; - /* update cfg with fc_conf */ switch (fc_conf->mode) { case RTE_ETH_FC_FULL: -- 2.25.1