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 8ED0342C6A; Fri, 9 Jun 2023 08:29:08 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1CF1D40EDB; Fri, 9 Jun 2023 08:29:08 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2136.outbound.protection.outlook.com [40.107.92.136]) by mails.dpdk.org (Postfix) with ESMTP id B6A7D40A84; Fri, 9 Jun 2023 08:29:06 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cjf2PNrgdaphrNStB8uShz5JGTa9Y0nvCOE/aYt8NZ4NjltYY65La0gl1tf14kITAaY0F6cgiGEvUulxQQ8HWLkvJTWcwfiyFSwmJVQZOy2SUPo7OX2CkdlPil6GDKNr7LZLnUre+5I85552EA3KEFu7RnC00XsLiJ6RVvmhzcWZeYBmlVMV5j6xk+XkTMuJNDXvy64fMzEU4dZlsM/srv6z7W5mrJMhtoxSpuGAdr5dO+/OeqAJ8D7N1UKHdRkSV6wCR68Am8lpzQ+UYymNQEZPylKLAIkDPO0raNV8QMpYCyKGtjHLXU08Qmg1GsA/JIsJLYZPkbGCjbVDIiPaMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=X/Q5PYPok+vQU+OQld80PGaVCDvLYmri1Nrl6rmerdw=; b=iz08l50+OG3pyNkCBWepA/wGDB21ur9jpYwzTpMCy9Ej8I9hm02J6Jfd08afT6TbAsxfP9rftoQqBOZ7YxwrY2asr+D0UPEhIP3Y1lNQmnMJ4+Eb3byCxm8gDFl96rWinUQMIa6cxfdVu0rX1O31KgfqnJU62b5IFrBCWhJFvHFMPZKK6kYnrJFbQcoqTw2sBncbomRfqCB5NLIIdgp6fmhTmZmRfluLwA70ABhAFrdfVsK9tpttuV2dzRzvie2r/Tpqph1/jadAP8tVjuXzlWAxJMDaePQgt+pAYyqijU0cjkzgZdOldv9LqlItHjh3ZL9N8u2d+NVVFBuwGRfpPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=X/Q5PYPok+vQU+OQld80PGaVCDvLYmri1Nrl6rmerdw=; b=CGixR7ZwSUF8S4dESk6rkUoJnxKuCKWlgFd6KzG/EHAu13PQNh4YjpQjGC3/kgkBJAxleBQHjUL/6DM6OsYzfEM0dC9JI0v0ahfbj3EFvEUJqGtxJnO09dv6zHKQH91U+p4fu51d7pM0jS2q9RzdMF07fCdiESE5vF/NBqI2d+0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by MW4PR13MB5532.namprd13.prod.outlook.com (2603:10b6:303:183::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Fri, 9 Jun 2023 06:29:04 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::d2cb:a650:e1ce:2174]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::d2cb:a650:e1ce:2174%3]) with mapi id 15.20.6455.030; Fri, 9 Jun 2023 06:29:04 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, James Hershaw , stable@dpdk.org, Chaoyong He , Long Wu Subject: [PATCH] net/nfp: fix incorrect link status after LSC event Date: Fri, 9 Jun 2023 14:28:46 +0800 Message-Id: <20230609062846.1334539-1-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: BYAPR08CA0048.namprd08.prod.outlook.com (2603:10b6:a03:117::25) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|MW4PR13MB5532:EE_ X-MS-Office365-Filtering-Correlation-Id: 19bfd925-31a4-46a2-e2b3-08db68b2d24a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E7xOPjdzkFTfUp5Hho0PYqD4iePbnREBqDrW3hGZ4gC3/N+gEqnJjT+uCEyv8q13txppvo8+HX0LPfavH4lpXuQGNqD1ui0Iq0BZrsRImZUBlEG9AS5pFhNCae4YvqQMAgHGRJ8mYTJNFXkYuprEZEZtPfSFrN8n0KacCkTY+/ejZmgVHMOP9DNRpxVVKYHP68xNQJSDK5joOLUj/cfANPgeAntkotDTsfsMG4GmFyhu8qYzhjSdltgctQZJ46IuYgVZisg45ZIBn/QhxNWrZC7ol8Q8kD+YRqibQuJR519+nlRC5dpUA6VUOjfHCG1ksWB4w+AfSErR7GdnTdl9NTHfp6BifXclVdbhBH99kP1mbJUEoqBhy9O3exRP+XSurJ6NjjWIER3FhxT9c/T6ZmA7DuzcYhLKiWnVKNN8K4uKkl7Dg6f6dscXZRZG/39fNJErI1hFzeHOEq9FnBhtST7EhShjtIXdBn20fPHiT2vnam+Hw5Ftl+to8XwxWfam9qqNVMip7h4OSS5gh6FbJMv+901cjOg/bYwbTSjrvddVEMaqlbxZ3G7jkp9rOe4mlG3wET8QSz8X6ZRI7qHX0UO5yTYf/DkCzanwNrTsqyKBATPgGH8mg866sU3hnj3q X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(366004)(396003)(376002)(346002)(136003)(39840400004)(451199021)(66476007)(450100002)(66946007)(6916009)(4326008)(478600001)(316002)(8936002)(2906002)(41300700001)(8676002)(5660300002)(54906003)(44832011)(66556008)(6666004)(6486002)(52116002)(6512007)(26005)(1076003)(107886003)(6506007)(2616005)(66574015)(38100700002)(186003)(36756003)(83380400001)(86362001)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?eFJ5QjlMbmVaM01ZUTMxditYM3ptdjVSaDlDSm83VVJCdExZcEgrVTZjT2JS?= =?utf-8?B?VllkY0JWZWhuOW5xVm9zSmMxclVpR0JGOXhzR2FIZEJ2Qm1PUDRZVld2aU5h?= =?utf-8?B?ak1yK0s5U2NsK04wVStCK0hYNGpQRmpqWDR0S0wzamt5ZjhFVlZPTUVFNGpD?= =?utf-8?B?L0hNOUJYV1BWeWJwaTVLNGRabjhLN0pvTDBEc1Rqa2RNZDUwcVhGTk9rbnlI?= =?utf-8?B?YVVLMENRNmh5SDQ2Qzh4Qk94UVNBYVk2dXNsakVpQzRjeGxJVzJyWFFGZWs0?= =?utf-8?B?SGNyak1sdVVMTmR2bHJ3bnEwOVRITXhqNWI0OWw0andRVHA0WTd6TFB4Rktr?= =?utf-8?B?cWVnRDZkQXhwZDhyY3ZGQlBVM3RjemtSalk2Z0ZyVG1FNVRidlN1OG5Zd1NC?= =?utf-8?B?TEtra1NMT1BoTUt4bVc5a0Q1eHRNUUZZQTJYbjNVQnRqR1Z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X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2023 06:29:04.7963 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: W9QOwn4NZ3HkwKmGPEL12kUys2X0DP74NducGkWprah3/1PKScH/QrzM/sFAsdn6NWxQJxHgreLN6vfoKSajhbiBLewzpIIstiZbx+DiFBQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR13MB5532 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: James Hershaw Incorrect port speed shown after a link state and interrupt of type RTE_ETH_EVENT_INTR_LSC occurs. This is because the interrupt handler for this type of event in the nfp PMD does not reconfigure the netdev. Fixed by moving the call to the nfp_net_notify_port_speed() function to within the nfp_net_link_update() function, which is called by the interrupt handler. Fixes: 36a9abd4b679 ("net/nfp: write link speed to control BAR") Cc: stable@dpdk.org Signed-off-by: James Hershaw Reviewed-by: Chaoyong He Reviewed-by: Long Wu Reviewed-by: Niklas Söderlund --- drivers/net/nfp/nfp_common.c | 72 +++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 29 deletions(-) diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c index 08f9529ead..18f974d0e4 100644 --- a/drivers/net/nfp/nfp_common.c +++ b/drivers/net/nfp/nfp_common.c @@ -187,31 +187,23 @@ nfp_net_link_speed_rte2nfp(uint16_t speed) } static void -nfp_net_notify_port_speed(struct rte_eth_dev *dev) +nfp_net_notify_port_speed(struct nfp_net_hw *hw, struct rte_eth_link *link) { - struct nfp_net_hw *hw; - struct nfp_eth_table *eth_table; - uint32_t nn_link_status; - - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - eth_table = hw->pf_dev->nfp_eth_table; - /** * Read the link status from NFP_NET_CFG_STS. If the link is down * then write the link speed NFP_NET_CFG_STS_LINK_RATE_UNKNOWN to * NFP_NET_CFG_STS_NSP_LINK_RATE. */ - nn_link_status = nn_cfg_readw(hw, NFP_NET_CFG_STS); - if ((nn_link_status & NFP_NET_CFG_STS_LINK) == 0) { + if (link->link_status == RTE_ETH_LINK_DOWN) { nn_cfg_writew(hw, NFP_NET_CFG_STS_NSP_LINK_RATE, NFP_NET_CFG_STS_LINK_RATE_UNKNOWN); return; } /** - * Link is up so read the link speed from the eth_table and write to + * Link is up so write the link speed from the eth_table to * NFP_NET_CFG_STS_NSP_LINK_RATE. */ nn_cfg_writew(hw, NFP_NET_CFG_STS_NSP_LINK_RATE, - nfp_net_link_speed_rte2nfp(eth_table->ports[hw->idx].speed)); + nfp_net_link_speed_rte2nfp(link->link_speed)); } /* The length of firmware version string */ @@ -281,9 +273,6 @@ nfp_net_reconfig(struct nfp_net_hw *hw, uint32_t ctrl, uint32_t update) { int ret; - if (hw->pf_dev != NULL && hw->pf_dev->app_fw_id == NFP_APP_FW_CORE_NIC) - nfp_net_notify_port_speed(hw->eth_dev); - rte_spinlock_lock(&hw->reconfig_lock); nn_cfg_writel(hw, NFP_NET_CFG_CTRL, ctrl); @@ -738,10 +727,13 @@ nfp_net_promisc_disable(struct rte_eth_dev *dev) int nfp_net_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) { + int ret; + uint32_t i; + uint32_t nn_link_status; struct nfp_net_hw *hw; struct rte_eth_link link; - uint16_t nn_link_status; - int ret; + struct nfp_eth_table *nfp_eth_table; + PMD_DRV_LOG(DEBUG, "Link update"); @@ -756,18 +748,31 @@ nfp_net_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) link.link_status = RTE_ETH_LINK_UP; link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX; - - /** - * Shift and mask nn_link_status so that it is effectively the value - * at offset NFP_NET_CFG_STS_NSP_LINK_RATE. - */ - nn_link_status = (nn_link_status >> NFP_NET_CFG_STS_LINK_RATE_SHIFT) & - NFP_NET_CFG_STS_LINK_RATE_MASK; - - if (nn_link_status >= RTE_DIM(nfp_net_link_speed_nfp2rte)) - link.link_speed = RTE_ETH_SPEED_NUM_NONE; - else - link.link_speed = nfp_net_link_speed_nfp2rte[nn_link_status]; + link.link_speed = RTE_ETH_SPEED_NUM_NONE; + + if (link.link_status == RTE_ETH_LINK_UP) { + if (hw->pf_dev != NULL) { + nfp_eth_table = hw->pf_dev->nfp_eth_table; + if (nfp_eth_table != NULL) { + uint32_t speed = nfp_eth_table->ports[hw->idx].speed; + for (i = 0; i < RTE_DIM(nfp_net_link_speed_nfp2rte); i++) { + if (nfp_net_link_speed_nfp2rte[i] == speed) { + link.link_speed = speed; + break; + } + } + } + } else { + /** + * Shift and mask nn_link_status so that it is effectively the value + * at offset NFP_NET_CFG_STS_NSP_LINK_RATE. + */ + nn_link_status = (nn_link_status >> NFP_NET_CFG_STS_LINK_RATE_SHIFT) & + NFP_NET_CFG_STS_LINK_RATE_MASK; + if (nn_link_status < RTE_DIM(nfp_net_link_speed_nfp2rte)) + link.link_speed = nfp_net_link_speed_nfp2rte[nn_link_status]; + } + } ret = rte_eth_linkstatus_set(dev, &link); if (ret == 0) { @@ -776,6 +781,15 @@ nfp_net_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) else PMD_DRV_LOG(INFO, "NIC Link is Down"); } + + /** + * Notify the port to update the speed value in the CTRL BAR from NSP. + * Not applicable for VFs as the associated PF is still attached to the + * kernel driver. + */ + if (hw->pf_dev != NULL) + nfp_net_notify_port_speed(hw, &link); + return ret; } -- 2.39.1