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 2B2A945B37; Mon, 14 Oct 2024 14:02:34 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5B8A140A82; Mon, 14 Oct 2024 14:01:42 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by mails.dpdk.org (Postfix) with ESMTP id BD65F40676 for ; Mon, 14 Oct 2024 14:01:32 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 9B5EE200910; Mon, 14 Oct 2024 14:01:32 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 5ACF1201D05; Mon, 14 Oct 2024 14:01:32 +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 C0231183DC02; Mon, 14 Oct 2024 20:01:31 +0800 (+08) From: vanshika.shukla@nxp.com To: dev@dpdk.org, Hemant Agrawal , Sachin Saxena Cc: Brick Yang , Rohit Raj Subject: [v3 10/43] net/dpaa2: update DPNI link status method Date: Mon, 14 Oct 2024 17:30:53 +0530 Message-Id: <20241014120126.170790-11-vanshika.shukla@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241014120126.170790-1-vanshika.shukla@nxp.com> References: <20240918075056.1838654-2-vanshika.shukla@nxp.com> <20241014120126.170790-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 b120e2c815..0adebc0bf1 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -2087,7 +2087,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(); @@ -2099,14 +2099,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) @@ -2115,7 +2115,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; @@ -2127,7 +2127,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; @@ -2142,7 +2142,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(); @@ -2155,23 +2154,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