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 1A3CAA0543; Tue, 21 Jun 2022 10:09:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EB5F342B81; Tue, 21 Jun 2022 10:09:20 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2119.outbound.protection.outlook.com [40.107.93.119]) by mails.dpdk.org (Postfix) with ESMTP id 9FD0542905 for ; Tue, 21 Jun 2022 10:09:17 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kiEpQo+4IhjCpe3Xprq00e3WSohXV/r760y8kmaLsdHBSq28LZvVgzqTxEHWAUjfnHsy/fxGZE3fOciOKljbNvLc1fXfFj1v27vfn12032Yg6H6b449AsXWSmabhDkmrWjUuesbBy0nG358v3mdoR0CvVMzbZHTbPeuBXKFaGRnu5gCQFehobyi7QiKiZztzghP2U04rLE/9lzCLNpETjGD6g2tSmnwsiLEUXhtsKgtoZCMrZl8SkgrEcGChNNZPR5mp1qPBJtnJQyeSoaBSyx8LN7jkl9kcgsoryOh31QEUqE2qblo6ZXMx2Nb18tf/F2UPJFccVhtSeCOpFQopug== 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=chF83Qe2pBV1Dy+19CXMz3CDqAErGTaf2ljOSzLjmX4=; b=Oskx552HwzGyjfJ/UuDmPQ8O38+DMenUnKs/rdG2e4zMNsEHtkhMCh5vmuQSclXItvjWFSbe27N9NXIELudPYyOC2n82DgwalB09MC66iRimOoYdXYxIdIGRIa+TJMaWmLKNOFwcEKflH+ijSpZ8M9HxjrabMo8VErCgtATLgcmWPNRMthP1eSqwkC4pU7JJJYnq6biupNkN8K1xu8SZEwUcQCbDZVMgR1nUC6FQoMl5aIlEWD7IeRfxBkg1ffb5cgELLNdZtRx7+YvjFT7tqdwIueciyzp+wZCWtO+mkSZZNjMYp3/HDj7Umsfp8g4jfk3TCovWwYe87t/+Mi0uFw== 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=chF83Qe2pBV1Dy+19CXMz3CDqAErGTaf2ljOSzLjmX4=; b=dtNuhC7F6jE456OwG86BcTsv8+QtsB89rI+zG4gF9E+lAM8oiPpmidmNIX/OJBe35CRWSZllsji6UT7rFmmrZuQpfJfIXoiqWWzVQAvGGLLI7i0z7qrc0cMQA25AorcaGZrHDHTsEc7nWdFvnjbuOK7WX57ssLATmZbhLN6b4F4= 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 DM6PR13MB2730.namprd13.prod.outlook.com (2603:10b6:5:13e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.13; Tue, 21 Jun 2022 08:09:16 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::5d9e:9ce5:51d1:2021]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::5d9e:9ce5:51d1:2021%7]) with mapi id 15.20.5373.015; Tue, 21 Jun 2022 08:09:16 +0000 From: Chaoyong He To: dev@dpdk.org Cc: niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH 03/12] net/nfp: move app specific init logic to own function Date: Tue, 21 Jun 2022 16:08:30 +0800 Message-Id: <1655798919-38659-4-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1655798919-38659-1-git-send-email-chaoyong.he@corigine.com> References: <1655798919-38659-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: OS0P286CA0009.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:9c::14) 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: 15875549-c6e0-4bb4-b702-08da535d55c1 X-MS-TrafficTypeDiagnostic: DM6PR13MB2730: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: /S6AfRm2vwzc1zVry+oCtn4pDja5Fj2E8t2/oJ4wOc4NFJ3cnGZrms5aUR5chT0SFXg0Z2HvroQzzz9wnFEo74n92jiLeytW1nqqceKpOmZd+yh3F5wxakifEPNivu6Xo+/yr66WtDAgQRVXrMexj5uR8yS1UO4PqGKwP8Paf2LGutaEeiePLXUev+rr3ihUQOTOmTtUb0fgDnID5BvSeGHKDpGBQqNWq/ql5S6EgBdHW02bQxG/Gw9LT9kwYKG3bTUjalFpZ0aPjnmyev61WG0JTiQP8thHDOIjKdAHQnLhQpMufV87G5fefGyoZTAY/zIXYeNyPigEvwmYplH3bvLKjC3os4Hhd8ZGeWAWi49WefnW8JWKEQQvyZ6dLPP58nNIl4yM4ZBRfbmEwU3PE6IkpTWhkx3LgvMI1JhkDzRxH/elDSQdP+wDx1wTzPytisvPxUycQZermj+5VSbqTzJ0OZ9CX1A4X/XlzUopVRhq5GonhGU3QaExIxq7zAU+riiOTC1dwFfP3xByD2+D2F1BTBymuR7M0BgGrYjmsyozVbpYucLjm7tyTghriDHkpjf/6dUFLwPcnFFqEQV8vwvL4bGQY4ydFrNNSTobNPY/a4MMZ3st8M5U1nXCmaXSMYuUG0TNzeEQsoYSzCC3glqQqVjwag9DuVZ8w5f4voaBvRVVgb1Pb6xHxD8zXKn3233ZvS+mcM54yliVAAIGhw== 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)(39830400003)(376002)(366004)(136003)(346002)(396003)(38100700002)(2616005)(38350700002)(86362001)(83380400001)(66946007)(66476007)(41300700001)(186003)(8936002)(8676002)(66556008)(5660300002)(107886003)(44832011)(2906002)(316002)(4326008)(6506007)(26005)(6512007)(6916009)(478600001)(52116002)(6666004)(36756003)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?TTJyUW5IRTU4VnRKYjNuZ2t3cjMvamdOU1QxS3FudmlMamtkZGVTa09NQzBj?= =?utf-8?B?NElwaEdFLzRyV1kxdnFYc1diQjlqZTR1TU9kM3orSW5GcG11RmNtQ3lIbXR6?= =?utf-8?B?eHo5M0dNb2psVDA3Ulhrd0Urc1pGNVdwK0szVkRkUTN3UmFlUkszTTFQa2c1?= =?utf-8?B?N25NTGhnMXZOR0tGeHB2TzRZYmF3dGw3YWZIdTYrejczWi9mbTVrcTRTMmc1?= =?utf-8?B?aVpZdmQ0bmVPU2tqcDk1V0kvajAzMk0wYXowcXhWZTArYlRHZEh1T3ovMng3?= =?utf-8?B?S3JadzJyV000b2IwUjNGTGtQZEdrVy84SXp6UEthTE5xalFHYi9PTUhQUEFU?= =?utf-8?B?bk5yMTU0U3EvVHVzNTBySWJxRjFjV2llcWN0ZCtueHNMcE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yYjJ5R0ROdS80LzVEdGVoRzNnSGZmTWhuVDU3ZjFhOFRaK2czT0NW?= =?utf-8?B?OFQySlc5NVl4YUlCU1lRcDVzQ1A1aFA4Tk53c0lEMnZKWjVuMDJxemE4SDNV?= =?utf-8?B?V050dHVsdXZXNUE4bldFZWUxWGNBNGZPNTVOZUhueEw5V3J0V1YyZnEwRUlL?= =?utf-8?Q?5fM33kiZ7uTDvikI=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 15875549-c6e0-4bb4-b702-08da535d55c1 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2022 08:09:16.4356 (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: JqiYeGSfUAoz1bK8so8sP0lP4GYAlYt7J7vqv74dJcZYdpWlaO1wRjXz5v+jRbGj1vpPTJsdakvx9Ih/3T9y7fmrT5n5KgZkn6TaL9gfnFs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR13MB2730 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 | 91 +++++++++++++++++++++++++++++--------------- 1 file changed, 61 insertions(+), 30 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 2c5607c..cf2106c 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -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