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 184D9A0093; Fri, 17 Jun 2022 11:36:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4E97A415D7; Fri, 17 Jun 2022 11:35:33 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2114.outbound.protection.outlook.com [40.107.94.114]) by mails.dpdk.org (Postfix) with ESMTP id C4AD242B6E for ; Fri, 17 Jun 2022 11:35:28 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PYsjrP8nOKk5oMn/Nv+jbQM7laKr1X1kgJoLn5K/FkErjNSecdcnPiFt4mfQY+pGM6csgdzrH3cm+8Kt94psFoyzDj+HnsMnHU0Uh/gnixVSnE6qHWnX+6MXyF9kxY3plCtGGrkRBDJLFuv55+6pNUmoRxqcYzGWUI9f/W/v2mVr6KzbfooCVjXEP4fApC2KwKB5clSfPlHjgH6s2YCrqCR8+CCLRzNbvVClhg1sERpuURDlx9dHm9Yqb8EhPCWSim+L3Hbm5wd0o1Zi/cYD8eK6kQdhOEcwqM8oN0HC1axGjFVOVGEsvMnTmvCTpeLUyPB5zn6FojeVMXAESrjrzg== 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=L3T+F9lLbwKb/edutfQI/I6V5Tc0434kyN5Bx9zMMS0=; b=kpc84k+WUixkkJzBYkqvTX/UIzPWCpQq2MM49CjzTSclC4SjbZCU3hTuL12DCH2ZZxc526QXXa6A04EDTVcAICPKlXo+vPBtbuuXWTrIdxIag98BgYWBKUnrMMIW/FfwUVrYt984VqCV3qYtLwDShL0p+/vNMeMqDBMi+dMx0L+0bTXbVOA7RawBzhaTBhXgN/03DRCjbIz7HbmtcHFf/9ljKXMU6WpnFHPrBusz/tpttMm74vjt0mS0tCEe5JEB6hN0JnDBuxmdVn668Pwi9mqLnx2WJAILFAVbfaUZwReVYcXxZpsiKbGv7I1i01VG/5Ltx2Psk70zUS44wlEuIw== 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=L3T+F9lLbwKb/edutfQI/I6V5Tc0434kyN5Bx9zMMS0=; b=bl/agmW/GFHiaNR3NfQEJuCX9F/bt7GPnlPq2+vRPDGHLpFKZS2y/tutRRi6vGGZqjhmoma+PIR0iEfYzfy/c3u9DeW8qAfVPVlgQPLYiYz8zA47Ehmv3gCM11vIlNCRlIC79XWjURp7zK+zr4Y6QPQqWpd8KtOzdYxolYMqqS0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from DM6PR13MB3004.namprd13.prod.outlook.com (2603:10b6:5:191::21) by CO3PR13MB5671.namprd13.prod.outlook.com (2603:10b6:303:17a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.9; Fri, 17 Jun 2022 09:35:27 +0000 Received: from DM6PR13MB3004.namprd13.prod.outlook.com ([fe80::ac31:a36a:cc15:cd35]) by DM6PR13MB3004.namprd13.prod.outlook.com ([fe80::ac31:a36a:cc15:cd35%7]) with mapi id 15.20.5373.009; Fri, 17 Jun 2022 09:35:27 +0000 From: Jin Liu To: dev@dpdk.org Cc: niklas.soderlund@corigine.com, Jin Liu , Diana Wang , Peng Zhang , Chaoyong He Subject: [PATCH v3 07/13] net/nfp: support firmware with NFDk Date: Fri, 17 Jun 2022 11:34:38 +0200 Message-Id: <20220617093444.2004000-8-jin.liu@corigine.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220617093444.2004000-1-jin.liu@corigine.com> References: <20220616023939.1798769-1-jin.liu@corigine.com> <20220617093444.2004000-1-jin.liu@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO4P123CA0192.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a4::17) To DM6PR13MB3004.namprd13.prod.outlook.com (2603:10b6:5:191::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5f15f435-8164-44bf-79cd-08da5044b5f5 X-MS-TrafficTypeDiagnostic: CO3PR13MB5671:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YBnpyn3NA6FL/imVCQf8WryMG40i7d2QFZ6qHwfyN78m4XabaAEpTejIW1Jvr8bFD66TIbaOSmYlgfkQGTgEWEaFrlsYGt/F10GZOLMEejpLTOVWBuVdjyAGePLke3wH9Pwqgvs+1NX/cMhmV2/YyCTfySJh4pxiC7Cx0BlLnWMF1AGyJCDdRlWFylKouZdM9cgCYH1bRoxMDFA8dV2ZkT9D/ubq9rBXfHD7290BJFy90FXa3GurNxkT7NxukJ+UajLlMQWr+2plusTIqxqRepg2V50C/uHJcucUfmCe771Fnaej788mfN7Olbol9WnGDVVH0oHrRxarKJ04sToUu+mV9g3GJGBJgNmnWUgt4Zvk83xNe323dCt2WhviKcoGcHHhsOSxc8vGE/RYuzadBEceZl7enJt0/qtqpf8hdjSAWeGmvDcFUBKnwszYbMAHyd3ZUJ21UvlEGAk0aCQpaQrxM7AALmMSpZTeQ8/eEvreugF9P2ErL85+xwFSzbxOtG7eG6QW9hWfO/6TPO7Q9vsWJ6VGWH10uPp9vPzjHCPcq1p8v/e6WMm4XMyT6YWHV9WS7H4FSaOczE+uqnZzLSRRAei7h6dGYUpQbbL/uqJijmnWrYl/thE4y+DciljcdBts2rW8sw717E4QM10gA2vULv3kdfmUDf6LVBazR+hE2bBn+3JlOD0JtdvOBGyJfafayUWahbVRroAM1HKy7lQe7WNwldqJzys6WEpucWa7ueS1iseAxQnbrWCPcoPFi9SdRN5xMoYBMgUMd3nwpx8kvjpyb68e3qG71DRHfg0y4VfXxv6T4Gb9Recj/bmw8IyFswRMY1IYWzFOpJNlQg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR13MB3004.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(346002)(136003)(366004)(396003)(39840400004)(66476007)(66556008)(26005)(8676002)(6666004)(107886003)(66946007)(6506007)(6916009)(44832011)(2906002)(316002)(4326008)(38350700002)(186003)(508600001)(54906003)(5660300002)(966005)(6486002)(6512007)(1076003)(8936002)(2616005)(36756003)(52116002)(83380400001)(86362001)(38100700002)(41300700001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?SnlGUm5rL0t5Y0pDOFcxSHlIbmh4bUs4SE5VU2hHMktLbG1lM0lhVWxQczVx?= =?utf-8?B?eTBleC84NnFURWhDaTEvNW1jUWJhakhTVHdVSFMyeHdXL0JnU1RQZjR4RHJF?= =?utf-8?B?RWxrWktISlFrZ2NNZHV4UFFweUFib3lWb01vZGtNUU4rWWg4eFZ0ZkVYSmF2?= =?utf-8?B?VjkwR0prWndtck8zUDNBcm1LdDBtaHQzVHFhQnRTQjgzNFFnSXJ2SU5UK1Z6?= =?utf-8?B?N2RObzNpNVVWM1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hYUXlUTTlVMlFR?= =?utf-8?B?TXhGZHJYb21UM2lJYnlTcnZuYkFaWDI4dWpCdGxicGQvUm80SUI4bFl4ZlBp?= =?utf-8?B?czNvNXpTVlo3ejNFdDVjUDZjcUk3NzlrcHlnQ3NteklLRWc4cHVIR2pSQlpl?= =?utf-8?B?YjR4QURYY3Y5TlRSSC81d2hDbW9WbnZ6emFtZEhXWU1ZanVwVWxNK3ZRNzBy?= =?utf-8?B?dmdGWlUwTXZNM3BIVmM0ODh5UE1jTDVsSEM0ZFAwQTdlOHlzdzFLekFWTTFx?= =?utf-8?B?cW40UzJYQlNyNTYwdEo2cWdhYmg5K1lQMDhIM0d5cG95OWxyd1huVUtmTHZj?= =?utf-8?Q?nWyzZyqtU8UZVduw=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5f15f435-8164-44bf-79cd-08da5044b5f5 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB3004.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2022 09:35:26.9608 (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: hUhn6FSmdHF4fTTGKDR4lARXcFHtsGHDyjyTV38yMB7lM7nsGjvLsdfNZqpuf/ONsff1ZR6QrFQj2WLn9wTRxQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO3PR13MB5671 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 Modify nfp driver logic, add firmware version (NFD3 or NFDK) judgment, will according to the firmware version, mount different driver functions. Signed-off-by: Jin Liu Signed-off-by: Diana Wang Signed-off-by: Peng Zhang Signed-off-by: Chaoyong He Signed-off-by: Niklas Söderlund --- doc/guides/nics/nfp.rst | 7 ++-- doc/guides/rel_notes/release_22_07.rst | 1 + drivers/net/nfp/nfp_ctrl.h | 2 + drivers/net/nfp/nfp_ethdev.c | 49 +++++++++++++++++++----- drivers/net/nfp/nfp_ethdev_vf.c | 53 +++++++++++++++++++------- 5 files changed, 85 insertions(+), 27 deletions(-) diff --git a/doc/guides/nics/nfp.rst b/doc/guides/nics/nfp.rst index dcefac3ef6..55539accc2 100644 --- a/doc/guides/nics/nfp.rst +++ b/doc/guides/nics/nfp.rst @@ -100,9 +100,10 @@ more than one SmartNIC, same type of SmartNIC or different ones, and to upload a different firmware to each SmartNIC. .. Note:: - Currently the NFP PMD supports using the PF with Agilio Basic Firmware. See - https://help.netronome.com/support/solutions for more information on the - various firmwares supported by the Netronome Agilio CX smartNIC. + Currently the NFP PMD supports using the PF with Agilio Firmware with NFD3 + and Agilio Firmware with NFDk. See https://help.netronome.com/support/solutions + for more information on the various firmwares supported by the Netronome + Agilio CX smartNIC. PF multiport support -------------------- diff --git a/doc/guides/rel_notes/release_22_07.rst b/doc/guides/rel_notes/release_22_07.rst index d5d8c735b1..64308e6c1a 100644 --- a/doc/guides/rel_notes/release_22_07.rst +++ b/doc/guides/rel_notes/release_22_07.rst @@ -111,6 +111,7 @@ New Features * **Updated Netronome nfp driver.** * Added support for NFP3800 NIC. + * Added support for firmware with NFDk. * **Updated VMware vmxnet3 networking driver.** diff --git a/drivers/net/nfp/nfp_ctrl.h b/drivers/net/nfp/nfp_ctrl.h index 4dd62ef194..e73715e2aa 100644 --- a/drivers/net/nfp/nfp_ctrl.h +++ b/drivers/net/nfp/nfp_ctrl.h @@ -135,6 +135,8 @@ * - define more STS bits */ #define NFP_NET_CFG_VERSION 0x0030 +#define NFP_NET_CFG_VERSION_DP_NFD3 0 +#define NFP_NET_CFG_VERSION_DP_NFDK 1 #define NFP_NET_CFG_VERSION_RESERVED_MASK (0xff << 24) #define NFP_NET_CFG_VERSION_CLASS_MASK (0xff << 16) #define NFP_NET_CFG_VERSION_CLASS(x) (((x) & 0xff) << 16) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index cb84dc3188..1bbba9187e 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -358,6 +358,32 @@ static const struct eth_dev_ops nfp_net_nfd3_eth_dev_ops = { .rx_queue_intr_disable = nfp_rx_queue_intr_disable, }; +static inline int +nfp_net_ethdev_ops_mount(struct nfp_net_hw *hw, struct rte_eth_dev *eth_dev) +{ + switch (NFD_CFG_CLASS_VER_of(hw->ver)) { + case NFP_NET_CFG_VERSION_DP_NFD3: + break; + case NFP_NET_CFG_VERSION_DP_NFDK: + if (NFD_CFG_MAJOR_VERSION_of(hw->ver) < 5) { + PMD_DRV_LOG(ERR, "NFDK must use ABI 5 or newer, found: %d", + NFD_CFG_MAJOR_VERSION_of(hw->ver)); + return -EINVAL; + } + break; + default: + PMD_DRV_LOG(ERR, "The version of firmware is not correct."); + return -EINVAL; + } + + eth_dev->dev_ops = &nfp_net_nfd3_eth_dev_ops; + eth_dev->rx_queue_count = nfp_net_rx_queue_count; + eth_dev->rx_pkt_burst = &nfp_net_recv_pkts; + eth_dev->tx_pkt_burst = &nfp_net_nfd3_xmit_pkts; + + return 0; +} + static int nfp_net_init(struct rte_eth_dev *eth_dev) { @@ -402,11 +428,6 @@ nfp_net_init(struct rte_eth_dev *eth_dev) PMD_INIT_LOG(DEBUG, "Working with physical port number: %d, " "NFP internal port number: %d", port, hw->nfp_idx); - eth_dev->dev_ops = &nfp_net_nfd3_eth_dev_ops; - eth_dev->rx_queue_count = nfp_net_rx_queue_count; - eth_dev->rx_pkt_burst = &nfp_net_recv_pkts; - eth_dev->tx_pkt_burst = &nfp_net_nfd3_xmit_pkts; - /* For secondary processes, the primary has done all the work */ if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; @@ -441,6 +462,11 @@ nfp_net_init(struct rte_eth_dev *eth_dev) PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar); + hw->ver = nn_cfg_readl(hw, NFP_NET_CFG_VERSION); + + if (nfp_net_ethdev_ops_mount(hw, eth_dev)) + return -EINVAL; + hw->max_rx_queues = nn_cfg_readl(hw, NFP_NET_CFG_MAX_RXRINGS); hw->max_tx_queues = nn_cfg_readl(hw, NFP_NET_CFG_MAX_TXRINGS); @@ -473,7 +499,6 @@ nfp_net_init(struct rte_eth_dev *eth_dev) nfp_net_cfg_queue_setup(hw); /* Get some of the read-only fields from the config BAR */ - hw->ver = nn_cfg_readl(hw, NFP_NET_CFG_VERSION); hw->cap = nn_cfg_readl(hw, NFP_NET_CFG_CAP); hw->max_mtu = nn_cfg_readl(hw, NFP_NET_CFG_MAX_MTU); hw->mtu = RTE_ETHER_MTU; @@ -939,6 +964,7 @@ nfp_pf_secondary_init(struct rte_pci_device *pci_dev) int err; int total_ports; struct nfp_cpp *cpp; + struct nfp_net_hw *hw; struct nfp_rtsym_table *sym_tbl; if (pci_dev == NULL) @@ -988,11 +1014,14 @@ nfp_pf_secondary_init(struct rte_pci_device *pci_dev) "secondary process attach failed, ethdev doesn't exist"); return -ENODEV; } + + hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + + if (nfp_net_ethdev_ops_mount(hw, eth_dev)) + return -EINVAL; + eth_dev->process_private = cpp; - eth_dev->dev_ops = &nfp_net_nfd3_eth_dev_ops; - eth_dev->rx_queue_count = nfp_net_rx_queue_count; - eth_dev->rx_pkt_burst = &nfp_net_recv_pkts; - eth_dev->tx_pkt_burst = &nfp_net_nfd3_xmit_pkts; + rte_eth_dev_probing_finish(eth_dev); } diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c index c46ee0f913..0b4660aba6 100644 --- a/drivers/net/nfp/nfp_ethdev_vf.c +++ b/drivers/net/nfp/nfp_ethdev_vf.c @@ -265,6 +265,32 @@ static const struct eth_dev_ops nfp_netvf_nfd3_eth_dev_ops = { .rx_queue_intr_disable = nfp_rx_queue_intr_disable, }; +static inline int +nfp_netvf_ethdev_ops_mount(struct nfp_net_hw *hw, struct rte_eth_dev *eth_dev) +{ + switch (NFD_CFG_CLASS_VER_of(hw->ver)) { + case NFP_NET_CFG_VERSION_DP_NFD3: + break; + case NFP_NET_CFG_VERSION_DP_NFDK: + if (NFD_CFG_MAJOR_VERSION_of(hw->ver) < 5) { + PMD_DRV_LOG(ERR, "NFDK must use ABI 5 or newer, found: %d", + NFD_CFG_MAJOR_VERSION_of(hw->ver)); + return -EINVAL; + } + break; + default: + PMD_DRV_LOG(ERR, "The version of firmware is not correct."); + return -EINVAL; + } + + eth_dev->dev_ops = &nfp_netvf_nfd3_eth_dev_ops; + eth_dev->rx_queue_count = nfp_net_rx_queue_count; + eth_dev->rx_pkt_burst = &nfp_net_recv_pkts; + eth_dev->tx_pkt_burst = &nfp_net_nfd3_xmit_pkts; + + return 0; +} + static int nfp_netvf_init(struct rte_eth_dev *eth_dev) { @@ -292,10 +318,19 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev) hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); - eth_dev->dev_ops = &nfp_netvf_nfd3_eth_dev_ops; - eth_dev->rx_queue_count = nfp_net_rx_queue_count; - eth_dev->rx_pkt_burst = &nfp_net_recv_pkts; - eth_dev->tx_pkt_burst = &nfp_net_nfd3_xmit_pkts; + hw->ctrl_bar = (uint8_t *)pci_dev->mem_resource[0].addr; + if (hw->ctrl_bar == NULL) { + PMD_DRV_LOG(ERR, + "hw->ctrl_bar is NULL. BAR0 not configured"); + return -ENODEV; + } + + PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar); + + hw->ver = nn_cfg_readl(hw, NFP_NET_CFG_VERSION); + + if (nfp_netvf_ethdev_ops_mount(hw, eth_dev)) + return -EINVAL; /* For secondary processes, the primary has done all the work */ if (rte_eal_process_type() != RTE_PROC_PRIMARY) @@ -313,15 +348,6 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev) pci_dev->addr.domain, pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function); - hw->ctrl_bar = (uint8_t *)pci_dev->mem_resource[0].addr; - if (hw->ctrl_bar == NULL) { - PMD_DRV_LOG(ERR, - "hw->ctrl_bar is NULL. BAR0 not configured"); - return -ENODEV; - } - - PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar); - hw->max_rx_queues = nn_cfg_readl(hw, NFP_NET_CFG_MAX_RXRINGS); hw->max_tx_queues = nn_cfg_readl(hw, NFP_NET_CFG_MAX_TXRINGS); @@ -354,7 +380,6 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev) nfp_net_cfg_queue_setup(hw); /* Get some of the read-only fields from the config BAR */ - hw->ver = nn_cfg_readl(hw, NFP_NET_CFG_VERSION); hw->cap = nn_cfg_readl(hw, NFP_NET_CFG_CAP); hw->max_mtu = nn_cfg_readl(hw, NFP_NET_CFG_MAX_MTU); hw->mtu = RTE_ETHER_MTU; -- 2.27.0