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 44423A00C4; Fri, 5 Aug 2022 08:33:30 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 57F1842C35; Fri, 5 Aug 2022 08:33:10 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2108.outbound.protection.outlook.com [40.107.220.108]) by mails.dpdk.org (Postfix) with ESMTP id 2326F42C14 for ; Fri, 5 Aug 2022 08:33:08 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hLzH5xuSqt0n7lRbPvDIYIfvvy3GiCqnqwUVefnQuO5v539VKoi1OvqcLQgPHBH4xTwlb4rbDphxQUgpCE8L8yE9KawpvbRKKpipVi+ga2HvMPAqHt4oSVXSw+/1a8D/pfocl8lun7FGfkhUhLcotDFKgKlVa7s06PAzltHD6sglcCohUHlnoc8kOqFXBRPEhSEMNtrGDPafKSLH535XPg6GFSs5He+W0p86hY7NFlbHZcto2zrfuC2lXuN2MjGYc7cKYrhHrmgNQzmV0647PCCGZFRCjzRQ0REM5MmT2PqpFmRwIDrSf1ow3yaLKYxzi5IjyAh/Ck/IRZwY4PGZyA== 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=xm+osS83/vIi4Loqb7jrKJm55KK86k6ftxN5ZQDoP7M=; b=Z3XqAr23B+dC2qPSrRIjFGxtQb6BMpPDEouUYC4ylnjJxBOtFDnCO+WPY4SCtLF0WV32eBzN0DFYcxXYYsoRqzHnhyr4fHexS5GKqLrp9hLAbi3gXb6I527NH1rHdVPvamoIbboQKtXCK2cc8XvfwK7pgNP7fFGMC3fVTo6cyDt8hRFQG4vK5XNMxZr7/qjBe1e44JDmbGV6/Xu1xUyV1djM1NBTwhPWcpPtC2NxAs63I6VJX9m0+3KlXLdzReAyos8NqTy96HhJn2G2TWak6Lya0HODlMCs6GYOpE16MNNFbTOFZb44ho8aKUcbhpyJ/gzywpiRZY5ZUvZKtqlPGQ== 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=xm+osS83/vIi4Loqb7jrKJm55KK86k6ftxN5ZQDoP7M=; b=v5XW0Qe02ZPx1ZV3MbEnHt3zWduwlAJEIL87p1UNC1c2JyDBJuM9vxcAaS+rgi8gSe2bHZM5M2Q15LDqsxVIvQpS6Nd1YNNOnOh6gfBDmHKcvvVR4DZfg79dSrE4vjz+5/b/ESdkyKpVZV5YS0B1REWBC0zaWqEp1wcI385rzrQ= 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 MW5PR13MB5854.namprd13.prod.outlook.com (2603:10b6:303:1c0::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Fri, 5 Aug 2022 06:33:06 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::402d:6abc:83a8:2431]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::402d:6abc:83a8:2431%5]) with mapi id 15.20.5504.014; Fri, 5 Aug 2022 06:33:06 +0000 From: Chaoyong He To: dev@dpdk.org Cc: niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v5 03/12] net/nfp: move app specific init logic to own function Date: Fri, 5 Aug 2022 14:32:26 +0800 Message-Id: <1659681155-16525-4-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1659681155-16525-1-git-send-email-chaoyong.he@corigine.com> References: <1659681155-16525-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SG2PR04CA0157.apcprd04.prod.outlook.com (2603:1096:4::19) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1e2720b0-1e63-4ba5-d316-08da76ac5b2e X-MS-TrafficTypeDiagnostic: MW5PR13MB5854:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b72xf5gaasnuZDga5gqLCI0Q5nPMwDU3r0o8yA9csjDT8VeeQa/tNWCzeLgsRPjdpoItUBdcWZQlOQRAg4EOxi9+gAAtz+UdiLWPMwQ0hAVO8hSmoXf4FzOhQK0OtlGEGgSfe12ztOJ0mOT2A5IqzB35JU0lQZzGP7uorRMdQZNtCueQAJEm1b7QkrJ1UUEO3z83hPYLopt6dT/Ys6ENhDtndhbohJSErz1UVWqOS3+q3sT4nfs8WgnSviJ9w6thl3/D/cLo1P1xMXmyZdcq+TnnsxtDHCm8Tf4pHC5ztBF3mKnkIpDJJEuFTFpgfttT9sQP8wFNtdRdtk4mFlMdkgj5MHUhsUy1kBkH0Ume0cbpQiaO2kIGMsYnpa6Zf+9tHezMKrpxrh97sSUpyp0SDl4lL7p645VgvXs3jElx3d29tR9vxdtbb4ht3n6zTaW2lhoj0p20cJuL8NWRejEaAPsWbxUrFPCanrnYcqeq7k8x9ucdPCBqV73qvtRMvxQ/2oztD7Wh/s5WKQ9Yl8QSvJB9fll9KlUfBdWSQ1eFC1KNA/81LPK7MX4YIHhNuHonKgNoMwkGxVLipFIKhxEFg3rAsDfuO4rnCDASECpkoODg9Vu+I2P8E2ss+vTlxUoNqYeW4BLix0fXwMnfKYzIwtB2NBEylN5IycoekG6bb4qeR8BLXBj2HH2He2r4SXzGmzLq0QVgB3jI26avpGjbrx2CZ4e0KYZRGYkaSQvZmuglyAhHi5imMCsw/ZuqFCUoTg5YTXGtxo4qkrfLODpkltIbkuMur/7Cu0Vr8pzvBZw= 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:(13230016)(4636009)(366004)(136003)(346002)(39840400004)(396003)(376002)(4326008)(6512007)(6506007)(52116002)(6486002)(36756003)(26005)(41300700001)(6666004)(6916009)(186003)(316002)(66556008)(86362001)(66476007)(44832011)(8936002)(8676002)(2906002)(5660300002)(478600001)(2616005)(83380400001)(107886003)(66946007)(38100700002)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?SHdURXY3Um5SOGlqa2ZaM2RnNUFBQkhUTXp1d2Nqc1lvNlBvaTYvZUdpU20z?= =?utf-8?B?Z1pJSnB5M2pqd0N6byt1SlE4WTJCc1k2dXpvOWltRkdPeXh1NkFDS0FlMXFS?= =?utf-8?B?NG9BNStHaXU5eXNLTXpxaTkxOXptQmRTL0l6WHdyV2pEWE0yMkxQcGlxWjBy?= =?utf-8?B?YmptVUNkZVNWUUtDZmVtejZQY0tIa2tlV2sySE95N0VRSVlCbXJEVXJ0ZnF0?= =?utf-8?B?REtiYnRKd0g4QnpnRFZIcjNGUnZYTzBwSjYydTN4a1NyVW9BbXdrR3pDU2dk?= =?utf-8?B?UWtPbWlDa3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-8?B?Y25PYllSSGlFbks1RTh2dGJ1WE9lY3E4L2xmc0ZDMVdZYk5pVFg0VUh3Wk5V?= =?utf-8?B?Ymc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e2720b0-1e63-4ba5-d316-08da76ac5b2e X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2022 06:33:06.5093 (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: IMnuUJJsB46aleJJCIWpxYwPThHaC3h4YJrxyiAypsHQ+nROt1dJBqVkifDn288/Biq9Ocrk7O6dj38/7ppjJtXni7C8DTvTe1gBepgPvRE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR13MB5854 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 The NFP card can load different firmware applications. This commit move the init logic of corenic app of the secondary process into its own function. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- drivers/net/nfp/nfp_ethdev.c | 93 +++++++++++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 31 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 2c5607c..90dd01e 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -936,7 +936,7 @@ break; default: PMD_INIT_LOG(ERR, "nfp_net: no device ID matching"); - err = -ENODEV; + ret = -ENODEV; goto pf_cleanup; } @@ -991,6 +991,50 @@ return ret; } +static int +nfp_secondary_init_app_nic(struct rte_pci_device *pci_dev, + struct nfp_rtsym_table *sym_tbl, + struct nfp_cpp *cpp) +{ + int i; + int err = 0; + int ret = 0; + int total_vnics; + struct nfp_net_hw *hw; + + /* Read the number of vNIC's created for the PF */ + total_vnics = nfp_rtsym_read_le(sym_tbl, "nfd_cfg_pf0_num_ports", &err); + if (err || total_vnics <= 0 || total_vnics > 8) { + PMD_INIT_LOG(ERR, "nfd_cfg_pf0_num_ports symbol with wrong value"); + return -ENODEV; + } + + for (i = 0; i < total_vnics; i++) { + struct rte_eth_dev *eth_dev; + char port_name[RTE_ETH_NAME_MAX_LEN]; + snprintf(port_name, sizeof(port_name), "%s_port%d", + pci_dev->device.name, i); + + PMD_DRV_LOG(DEBUG, "Secondary attaching to port %s", port_name); + eth_dev = rte_eth_dev_attach_secondary(port_name); + if (eth_dev == NULL) { + RTE_LOG(ERR, EAL, + "secondary process attach failed, ethdev doesn't exist"); + ret = -ENODEV; + break; + } + + eth_dev->process_private = cpp; + hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + if (nfp_net_ethdev_ops_mount(hw, eth_dev)) + return -EINVAL; + + rte_eth_dev_probing_finish(eth_dev); + } + + return ret; +} + /* * When attaching to the NFP4000/6000 PF on a secondary process there * is no need to initialise the PF again. Only minimal work is required @@ -999,12 +1043,10 @@ static int nfp_pf_secondary_init(struct rte_pci_device *pci_dev) { - int i; int err = 0; int ret = 0; - int total_ports; + enum nfp_app_id app_id; struct nfp_cpp *cpp; - struct nfp_net_hw *hw; struct nfp_rtsym_table *sym_tbl; if (pci_dev == NULL) @@ -1038,37 +1080,26 @@ return -EIO; } - total_ports = nfp_rtsym_read_le(sym_tbl, "nfd_cfg_pf0_num_ports", &err); - if (err || total_ports <= 0 || total_ports > 8) { - PMD_INIT_LOG(ERR, "nfd_cfg_pf0_num_ports symbol with wrong value"); - ret = -ENODEV; + /* Read the app ID of the firmware loaded */ + app_id = nfp_rtsym_read_le(sym_tbl, "_pf0_net_app_id", &err); + if (err) { + PMD_INIT_LOG(ERR, "Couldn't read app_id from fw"); goto sym_tbl_cleanup; } - for (i = 0; i < total_ports; i++) { - struct rte_eth_dev *eth_dev; - char port_name[RTE_ETH_NAME_MAX_LEN]; - - snprintf(port_name, sizeof(port_name), "%s_port%d", - pci_dev->device.name, i); - - PMD_DRV_LOG(DEBUG, "Secondary attaching to port %s", port_name); - eth_dev = rte_eth_dev_attach_secondary(port_name); - if (eth_dev == NULL) { - RTE_LOG(ERR, EAL, - "secondary process attach failed, ethdev doesn't exist"); - ret = -ENODEV; - break; + switch (app_id) { + case NFP_APP_CORE_NIC: + PMD_INIT_LOG(INFO, "Initializing coreNIC"); + ret = nfp_secondary_init_app_nic(pci_dev, sym_tbl, cpp); + if (ret) { + PMD_INIT_LOG(ERR, "Could not initialize coreNIC!"); + goto sym_tbl_cleanup; } - - 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; - - rte_eth_dev_probing_finish(eth_dev); + break; + default: + PMD_INIT_LOG(ERR, "Unsupported Firmware loaded"); + ret = -EINVAL; + goto sym_tbl_cleanup; } if (ret) -- 1.8.3.1