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 E2FFFA00C5; Thu, 15 Sep 2022 12:45:13 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 01D3D4282F; Thu, 15 Sep 2022 12:44:59 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2109.outbound.protection.outlook.com [40.107.101.109]) by mails.dpdk.org (Postfix) with ESMTP id 2F53A4280D for ; Thu, 15 Sep 2022 12:44:58 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tm+d1t+boBq8LGIBn+fLcVSCY7TWMQpDc2l4Zbya1lLmibBHlYj1FHcWso6gxiU8noVm8OMPl1P495K5U7i0QkCDsjEcBW+/FbrBoMcbpsMjAzxhLT8pEdWVlNiWTL+NAw24BRxUxsXNQ7DSYJaRxnA4RUBec7/1dYtjWWetqWCIs9AzZabcPD3ahKyXpkS3I2XSFiEekVHP5wU9Zc/qSOs4EnHgrDsMy0dhiue882rziSa3oeMHeBA2IOFuFynMAFoudkAs2Rm1JfF8JZNUIvEa4O9+huAPQcUKiVx1wrflugWiySTNZA7fZ1Wt3FPDVyoByW7Ll+NYJgya0q+03g== 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=BdKMo4WIoS0z8M0mAkfqqFBPZt+O2goaKkiPOuz7AHU=; b=TSoLr/wS+a9pNG3iSTe8t/RhBXGkJf/6KqInGR5Do1/eop98ZSvwbZuBBEZ6DDxlrgoidV5K+XwDh8ZO3E7rXW1JMxCXun6dLIwAEnHZZFCILYIKNvK+oMkHi+EnKsVq++G0J0eEeBg8dPoQ05xVuubManzFVqdxdNv5O259E19YyBBwTn8oyJoh/Zm26v7IeKOX/fhQ4nk7gs9Heeeasm7ERIdUR/rIbccYmUuktDOisokq5tGmBdh73vBouKu2PLIX9/VbiUKy+6z4dA3d0vkDMAMR/yqsdPVl/0UqI8F+rM4rTGGeBsF/92rV9LRtj2bzekyrch7k4UQHnaJIGA== 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=BdKMo4WIoS0z8M0mAkfqqFBPZt+O2goaKkiPOuz7AHU=; b=FmyxFWrijFiQ1Ouebb9gG7ZOnpCigq1WyKiVNhXDozSRiu4eC81/uG2vQ6ewTXBfOag37bapx7yfld87H/05ENrRZk6bQy4ERinNoUzsvLr6cdn98ttEW9GEgw5YHVU1mMWNkytC7eh+fB5OMPZbrsLOlBMYm/3Fpp/JgyjDTa4= 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 SA0PR13MB4158.namprd13.prod.outlook.com (2603:10b6:806:9b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.5; Thu, 15 Sep 2022 10:44:56 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::819:38c:6513:bf15]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::819:38c:6513:bf15%4]) with mapi id 15.20.5632.012; Thu, 15 Sep 2022 10:44:56 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v9 03/12] net/nfp: move app specific init logic to own function Date: Thu, 15 Sep 2022 18:44:20 +0800 Message-Id: <1663238669-12244-4-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1663238669-12244-1-git-send-email-chaoyong.he@corigine.com> References: <1663238669-12244-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: BYAPR11CA0071.namprd11.prod.outlook.com (2603:10b6:a03:80::48) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|SA0PR13MB4158:EE_ X-MS-Office365-Filtering-Correlation-Id: 663b00b2-fd8c-4658-d823-08da97075480 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vcSxbe2yBfVTdwL6mDWQxnVyUCCzspd2AsVTeVGKIMsx3m/CYCESOOkLDxzvr9KX14fYwEeTI1LbYDsRX+Vbjg5IIbVTY293PhPyI7M0zEdmUgCoilUz4uETLREnJHkw3oCXFJDch91IxLHx7g594ccoteLHZ3gevYfVTXCBCGC6Wrg6/0KweneCydBzb1jSvGgSyPCR6E1swg49JIfv8FZX0lTSw/U728QCNusTmih3QscibJJlasw1clF3asvijeph1Ewf6a29pXpX64u9ii/3Y10SfZoYAPDIrj0TyENueqkD2gLQVMfce64dEcwpveaDZh5WJxAnPiN7Ih/vCMJ5kHHU591EuYIeR/9wTsk9pXzyN3gTjHlMdpcoXFYVQ1tctcwjQYo/RUgCqxAeHZFhK9PZT9jMuU3eCv1v7wWqgIRYNl9VQm5tpS9M2sRq1tfr/pOaF7zeGfTUpd+czvll/x+flObMedeSot2BaO6Of1i3k7uzEmAnSRekgyYQrduZPXrzvlauahygTjz/2rP3QfKveIYXRu9NKNATHnvvX+gW5wz+XdGiViCTn4hCYd8jGcsHKHXpjcw9MbQ4qBSyKVDv2BOlkoSMkoB7nAxU/RzTgnJBTbjaCOL3F+6WXtPF2nDD7Ef7Y3f01stlW+QqDAh9sLHTvZKnzpmJFMhut7E8wWwqukjoMbX4wwjobBZPL9vXsl591e1Qf3dnvQ0vOTWcmkdvtE7oH+6Qmf1OEJYSEaySVjS5Pz4gVd/kwLMuHI0g+cNq8SZR91dbwQ== 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)(396003)(346002)(366004)(376002)(39840400004)(136003)(451199015)(2616005)(38350700002)(38100700002)(186003)(86362001)(83380400001)(107886003)(8676002)(66946007)(66476007)(4326008)(66556008)(44832011)(8936002)(41300700001)(2906002)(5660300002)(6506007)(478600001)(6666004)(316002)(6512007)(26005)(6486002)(52116002)(6916009)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Z2R4dXNXcGdOWi9YNjlteUtmRzhTQWdxc2dwZWp3bTQ2YlFzNzgxZXlKOElI?= =?utf-8?B?M3Vaa1VzVmppUndZbjFRNDlyUUNtOC9FcGRCMzRtQURUUkJCalo0ZGx1OEh4?= =?utf-8?B?b043UXI4SFg4Y0ZHUENJaVBwbmFSYjRUT3hNZHhoU3EwOGFrN21hN3ZOcXdn?= =?utf-8?B?dVdHRmk3VmQvQ0xGc0IrUE5Pb1kwczZPYS9sc0JyaEE1aStiVldrR3E2WTdt?= =?utf-8?B?czBXMFJlOXkwczRCK1NibFl0VnV1WDNyZytKOXVKc1NyZEdhdk14Y2hsTlFZ?= =?utf-8?B?ZjZBM0xEWGlLc292NUZyTmlwbD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zd0bUhoQ1ViQnYyUHl2TGhmWTNKR2I0aGJHdjMwRWltZGZm?= =?utf-8?B?VXc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR13MB4158 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 | 90 +++++++++++++++++++++++++++++--------------- 1 file changed, 60 insertions(+), 30 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 5c96f0b..0d09a69 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -994,6 +994,49 @@ return ret; } +static int +nfp_secondary_init_app_fw_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 != 0 || 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_INIT_LOG(DEBUG, "Secondary attaching to port %s", port_name); + eth_dev = rte_eth_dev_attach_secondary(port_name); + if (eth_dev == NULL) { + PMD_INIT_LOG(ERR, "Secondary process attach to port %s failed", port_name); + 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 @@ -1002,12 +1045,10 @@ static int nfp_pf_secondary_init(struct rte_pci_device *pci_dev) { - int i; int err = 0; int ret = 0; - int total_ports; struct nfp_cpp *cpp; - struct nfp_net_hw *hw; + enum nfp_app_fw_id app_fw_id; struct nfp_rtsym_table *sym_tbl; if (pci_dev == NULL) @@ -1041,37 +1082,26 @@ return -EIO; } - total_ports = nfp_rtsym_read_le(sym_tbl, "nfd_cfg_pf0_num_ports", &err); - if (err != 0 || 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_fw_id = nfp_rtsym_read_le(sym_tbl, "_pf0_net_app_id", &err); + if (err != 0) { + PMD_INIT_LOG(ERR, "Couldn't read app_fw_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_fw_id) { + case NFP_APP_FW_CORE_NIC: + PMD_INIT_LOG(INFO, "Initializing coreNIC"); + ret = nfp_secondary_init_app_fw_nic(pci_dev, sym_tbl, cpp); + if (ret != 0) { + 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; } /* Register the CPP bridge service for the secondary too */ -- 1.8.3.1