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 D3372A0093; Fri, 9 Dec 2022 03:44:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B9DB240E03; Fri, 9 Dec 2022 03:44:20 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2103.outbound.protection.outlook.com [40.107.220.103]) by mails.dpdk.org (Postfix) with ESMTP id 0FFC6400D6 for ; Fri, 9 Dec 2022 03:44:19 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nD5ojZh55LKQbNYQ1f2D3ygc9aZcSltz+pGyPasQOKqF7jG5Rr8iBrB5IzFiM8tG3gMDI7dhU+8bEqaGPKzcs8pzr98sVcxnGyqpM/n4iHzeDP+wldYT3ZIlaAzg7C6M50qUZpy+9Bhe4b+QxBuZG/Z73iKjEGXqcXVdFj6IqpP4hcSSgOIUXPAqPIra5Kat331OX1rL6Itapjx8jXMgIjexHZthDbfcw41IjNSTwZHhyPzmEl1xI49xmg4J/TscB6dB5BUpEaRJ/fvBpW8UbXt/qKiAQQcwQdgqIxmsvb0s1R/4Y4oBrbiWCqj+UFLh24pr0YecYqFZe3F6OOFoeg== 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=zIRTWyRqoSBlZGERsTHHdKweW0Vg/i3GWMwFvgJFO+Q=; b=GukSabf9pV/muDBGMDd5DEsvGF3zcFhKKHa9RdCAe5nBBY//SipMqkk+v/pSx90nUfKhETmsAA3lQI8pTx751oUYyC3g1I9vZRT1E9hNA2M+iro+rxWSmHWB9w0dL2gQ2pCDOJwShdGNdtfwOggD4etK+jl77bYcMTbBPXVlgRtsWRehdtNL31EyRygnR1jWX9UbGTMjh7bvfHVBdNpdk/fa/3ba0P4ppu6y94yefErA63ot91WSAa83rVbWGBAcLAy/tWzyPWuADihRR/1vaCOS/f4/AZ5cmdw5F0XLhCnfK+/VS8pntMtdqwFH11iDJSjQyqiLtavb9Acx1G6CPA== 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=zIRTWyRqoSBlZGERsTHHdKweW0Vg/i3GWMwFvgJFO+Q=; b=PYknuwRaL8uNYg9rELYJnv5TWcEyzVE1SacnJpzHm9QkqGCTOfGa2b525raGMNjZZPwhxuhukJ0lxQ0dTe91LuNKAIojh+yNMq/ojJqg/jwXAB1Ly4QFaT4SLygOH9/x91d/x985pG84UHkiz3BYiK2IF4LAuKgdQuzhAEKiTaM= 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 BLAPR13MB4642.namprd13.prod.outlook.com (2603:10b6:208:30d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.16; Fri, 9 Dec 2022 02:44:15 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::5122:8c31:51f3:4ee7]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::5122:8c31:51f3:4ee7%5]) with mapi id 15.20.5880.016; Fri, 9 Dec 2022 02:44:15 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Long Wu , Chaoyong He Subject: [PATCH] net/nfp: add support reading linkspeed from port table Date: Fri, 9 Dec 2022 10:43:59 +0800 Message-Id: <20221209024359.15245-1-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.29.3 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO6P265CA0028.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2ff::12) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|BLAPR13MB4642:EE_ X-MS-Office365-Filtering-Correlation-Id: 35362d40-4324-45c7-0207-08dad98f429d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KJhEr3qApZAOUvp5htDf6xnp3yTq1ZRFvlA5mBURgDO2aRluNW40QMUNp1CeNP4LiSxp7O3SO5acvs6UTOGYQb1UI8FfIcTKKbFTBHup5rVwqSg7kY9AelPE2WJX8Wzpz1Z/Kq6RJGQkePfA6s8LzBZPuJ7stbkCBwQv0UyDiy7IKdrNBoxwAwhN8CYOdrDWPuTPKxiBQ50hUjXlKNzciL2TSTJ2o47ZGCFJpUU51L3VfOnxf/kGZ4rQzdjyp18eOI9K+j2QMuUQ7gTOmw0FbEIG4phFjmY1KJktIP5Hy+4BbE0+FDVfWLAOQxBwnE9J4Wgju2cVSpabV4MKaGBqis0dtX/cHYUwAWFo9hlntFdkqs8sYqjF6T3LJEwssgHRHapzJU4WE1IZv3KMkcZToiIY8kpl/JzT/m9t1eZrcWzZkBit4UsZpwUN80FQFH4CxDT1Lq4Dr8dKPuNIRIurFeMWXQlS50k1YK3UL2rcgg3GVPxR5mvy1QqcUvg87crEt47Ou9hXL6ecVrEZEf43thXk1TzgYS5ZvojS9z88jDmMKUtadSvMqkC8qSMKRbJ2JKdLvLh5tFjw8srRXpbMBkHn3PCYFZ9BnwPJC8O36bImBupvWcE2bFAS80XHOd2o8Fz+YPBxfMU4xhrdl6oF0khElHaj8HzQvbxyhHSZmNuw4xgj8vqqN7A2wxRvPIn64ltJLhQlhyGLPK7eMQgnog== 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:(13230022)(4636009)(346002)(366004)(396003)(136003)(39830400003)(376002)(451199015)(86362001)(83380400001)(1076003)(2616005)(2906002)(44832011)(36756003)(8936002)(5660300002)(38350700002)(38100700002)(41300700001)(316002)(66556008)(8676002)(66946007)(4326008)(66476007)(107886003)(6666004)(54906003)(6916009)(66574015)(52116002)(6506007)(478600001)(6486002)(26005)(6512007)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?bngrSnMyR3RUNnZkVURJMU5IL3VCWmhYMVJEaGk3OTg5WXZ6MldwQlArdTlJ?= =?utf-8?B?N3o3bG0vWGhsUzU0QWJMOWhkVEdjMzQ2VEpuNU10Q05HLzg1Y0dnQVIzaEh2?= =?utf-8?B?TlJXY1RuMGNIbTlNZ1J3SktHZGpRaFgvQ3VjTi9LNFExRzI3ZTQ0c2lyTWxy?= =?utf-8?B?bXNzSlhMWUJ3NFJiVEd3ZWpyWVdyK0c5TXJFd05jV3dwQnRaVXZWQnNBQWRO?= =?utf-8?B?WTh0SDZzUFgvVEJEKzNiTHN5cmpGdkhjZmh2NUpKU1doMUFwbm0wUGRIbk5R?= =?utf-8?B?OENZN2dGbEtETGFKcm4wS2ppK0duc25KV0RYUXZscytSTzVFUFNibk1xWUNn?= =?utf-8?B?ZTRwNWFBRFdTZ3doZkEzN29tcWdaWWFXem1jQ25oMy9UME84TzM2a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igine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35362d40-4324-45c7-0207-08dad98f429d X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2022 02:44:15.1544 (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: PeeLzymJa1Rq0B0Su00Kp4j11vTYEmC3ACcFm982iKsPOVQ4GdliJXzn7N8OHCpCo2fB4gO6B9zfbGecbISEgzDQDsmcwAImH0+s97rL1FA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR13MB4642 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: Long Wu The NFP PMD driver retrieves the linkspeed by reading the NFP_NET_CFG_STS_LINK register. This register is not set by all versions of the firmware. Add a second preferred method to read the linkspeed from the port table instead, while keeping the old lookup method as a fallback in case that is not supported. Signed-off-by: Long Wu Reviewed-by: Chaoyong He Reviewed-by: Niklas Söderlund --- drivers/net/nfp/nfp_common.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c index 71711bfa22..71f649e606 100644 --- a/drivers/net/nfp/nfp_common.c +++ b/drivers/net/nfp/nfp_common.c @@ -492,7 +492,9 @@ nfp_net_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) { struct nfp_net_hw *hw; struct rte_eth_link link; + struct nfp_eth_table *nfp_eth_table; uint32_t nn_link_status; + uint32_t i; int ret; static const uint32_t ls_to_ethtool[] = { @@ -519,13 +521,28 @@ nfp_net_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX; - nn_link_status = (nn_link_status >> NFP_NET_CFG_STS_LINK_RATE_SHIFT) & - NFP_NET_CFG_STS_LINK_RATE_MASK; + if (hw->pf_dev != NULL) { + nfp_eth_table = hw->pf_dev->nfp_eth_table; + if (nfp_eth_table != NULL) { + link.link_speed = nfp_eth_table->ports[hw->idx].speed; + for (i = 0; i < RTE_DIM(ls_to_ethtool); i++) { + if (ls_to_ethtool[i] == link.link_speed) + break; + } + if (i == RTE_DIM(ls_to_ethtool)) + link.link_speed = RTE_ETH_SPEED_NUM_NONE; + } else { + link.link_speed = RTE_ETH_SPEED_NUM_NONE; + } + } else { + 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(ls_to_ethtool)) - link.link_speed = RTE_ETH_SPEED_NUM_NONE; - else - link.link_speed = ls_to_ethtool[nn_link_status]; + if (nn_link_status >= RTE_DIM(ls_to_ethtool)) + link.link_speed = RTE_ETH_SPEED_NUM_NONE; + else + link.link_speed = ls_to_ethtool[nn_link_status]; + } ret = rte_eth_linkstatus_set(dev, &link); if (ret == 0) { -- 2.29.3