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 B85CEA0543; Fri, 12 Aug 2022 12:23:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C765142C19; Fri, 12 Aug 2022 12:22:52 +0200 (CEST) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2097.outbound.protection.outlook.com [40.107.100.97]) by mails.dpdk.org (Postfix) with ESMTP id AB55242C0F for ; Fri, 12 Aug 2022 12:22:51 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YSywhVjUKQPROxuknA3yAyl9Zc6D6TMruaHihPqwg9iOuhKhZYKFa8w6ZmPlglfJndCZZZj8aZWqA+/jNonb9A0MRg6k//VhhOuLFeFe9NGIOUWLqMgs1Vy6ovi3hLV/JLRx+XCenw3THLC1rnAZ/asiU+ykPbXJFiLlDugBjX+yb1FGDvDg9oOEWWNLY++8FyFVe6Io/677DP8E/QgUMtn0S25sIejPrbTYPadzzXoPdOUkfzjlUB6qAqmq7ZXZIY5E9hTJIQDanG129gK56xy4iGwch884bbZ1efEVg/EXVpxgVX/h13Zhvf4ZddKPfjw9Nde7en+lC30F3C4H/w== 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=rWkx/IN8sJbLl/WbuVLACv6rdxnqLgVTLyn2TtXCaIo=; b=JNYI0gdfejidgvcfFEtTVm3g3CmctZ3nVqvM4Uplp0yGJybFjKTztWs8FzsxMMMYiUFWwzrqGMMM5iLHElSG153kY78UjVvRT+UljVr6LOpTS/LorOP5PfBQ6BBJJSjPVwgbUZeEnKUYewy5vJ2y81OXnlvn9l5C3ta6xNvClSsSbN8Jg2h2PBGcAv8qwguNj195Iz32pALmyCrBRAcitE1tc53sXZm5k0u4mfZCEGM/364gotsvJJ4Is2QlAsTSPTQYcuBIsHueEDhNFVtAZGo1JSfGM86tHrW98vFhc9jZX4u0/PBZ/OTjw1DKfxF+8LV7lWtBWwGOD+Q3mohDkA== 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=rWkx/IN8sJbLl/WbuVLACv6rdxnqLgVTLyn2TtXCaIo=; b=k1VpBae0ojeWnWCwuG24LZ9ur1A71KwNIgv/fsnKVPbUtjcPpgfK9XGlkDuLAzUGbgNlJREbwMBmqwQa7237ENyVEYc1YrDJhLDW75gdPILMA7PofnJG2JsQMZxg1rw76/0UV9etzxdJp+zH+NFyDdbVGgmKRvWjy+iLcuFKpcw= 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 MN2PR13MB2624.namprd13.prod.outlook.com (2603:10b6:208:ed::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.9; Fri, 12 Aug 2022 10:22:50 +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.5525.009; Fri, 12 Aug 2022 10:22:50 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v7 03/12] net/nfp: move app specific init logic to own function Date: Fri, 12 Aug 2022 18:22:21 +0800 Message-Id: <1660299750-10668-4-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1660299750-10668-1-git-send-email-chaoyong.he@corigine.com> References: <1660299750-10668-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: BYAPR01CA0019.prod.exchangelabs.com (2603:10b6:a02:80::32) 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: b90df940-2893-4736-d679-08da7c4c9be1 X-MS-TrafficTypeDiagnostic: MN2PR13MB2624:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pppWkR26Pb6OPjqEm7WAqSx5aL7gOECzxFHLV3xF43WMj4vujJ/BKJ1ONE+PEZX1hB5lxqrUSuvAfwcS93YPm5wo3bHlRN3ccREy2+KVQPRMGLEClhMfCS9fuLy9QsD9jYk1EiCc7S8+68VK7s/GH05wF7wYHA9BRdmXOyHElc3R+zMW+b72/r+13AJWlaLq+3hfRhhQmy6UAuopMdt2D4s5WXjAgUzExoY93GHhHutW6bFho9BgNP7TqE0tgRdvppAPy+6UErwP0NAJu/3Q3xiWX2qxUy7kQxfEv74FrobaPCHBYHyINZWqLnukKJpdL35nF62D/REjTEy4gf8yKpP8fhwOlvtbILkDJTCUqM1p18uF6ewxOSx6oTEnMPBtXlUj9JEUQiSiLOCQZNn8ZCFW40CIl8EI12i3T8jIV+ZwxYP07o8sMGZhrO901sw5ev68QdgZ+ZebkS5Vz8BWfmlUuz7etCXFlTBwMmvSLENfqnnUjjsv9XTmSPHcgTPKcBdRPNoCB8+KjypdYfFhhk1tlO3IqlxGVpfYRufY2pMjKUWTYMQucI8hOsIDrq7gJ43KCp1Y5ARXXNVX/86o3WVguu7Uln7/T1Gs/q4Ftq948lMxcL8PM0uMSZBWwJDp+4d9p/l7UglqaEWNZQuHJyt1DVYlKRGfLBVRalAc5XxS9fZQVhk4+99XPdhlfQ+ME3dA0a4Zp+LH+NksPS0wJd80m8yyLt6vabQPio3zKu9LDdJK3ECcgHD59PqLE04BaUfBuOJn5iRA1bOAGPhAjV9+HfJxW3m1nITMsnQiAu7xCW6lX4oQsZMkF53eT1B0 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)(396003)(346002)(39840400004)(376002)(136003)(52116002)(41300700001)(6916009)(316002)(26005)(478600001)(6486002)(6512007)(186003)(6666004)(36756003)(83380400001)(5660300002)(2616005)(107886003)(6506007)(66476007)(8676002)(4326008)(66556008)(66946007)(44832011)(86362001)(2906002)(8936002)(38100700002)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?VGxKV1NhRWZQMk1TVElRaXFqbkkySXlMMi9PckRXaDM5elZpRjU1eG9tZThB?= =?utf-8?B?QlVBZFNlWVlEYmtpYndMMXZZK0Z4Y1F2ZEJsMmljUzFWQm5oQ2FaVlZuaWx0?= =?utf-8?B?cStrYW1vMDdrQjltRmJScWdTQTBDaTUzNXRwQmdiL04vZ2owS091d2RNcENu?= =?utf-8?B?Z2JpaE1jc2pjejBiWmJvVTR3SVcrOUNJc2xoa2ZUMTJMenBHdTM5bXh4aVcw?= =?utf-8?B?WEh4eDRleEZLcWgzTVU1NmMzR1lTZWhlNkV4UWdtdTBaRVo4allEMDVZbi9Q?= =?utf-8?B?L2RWTUFwclZIczRrN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zAySi9wVUk4dTNudjR2ZVdL?= =?utf-8?B?MHRxQ3R2bElKRWt3Y2t6MDlEQktZVnlaUFp2L2N2aHlxd0hhMlJkME1nS0NW?= =?utf-8?B?MXc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: b90df940-2893-4736-d679-08da7c4c9be1 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2022 10:22:50.3161 (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: mXqB+1DGq5LEzcqel2aT0ES6Mv44Wy1SNE0TE4ujlCQzXPPyArB/9ERc+vghNqYF+lxVRGkAvYtg83yV0xJVnAudh6aG8vk5JKkaYXFCOB4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR13MB2624 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 088140a..a6a7e7e 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -992,6 +992,49 @@ 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 != 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 @@ -1000,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; struct nfp_cpp *cpp; - struct nfp_net_hw *hw; + enum nfp_app_id app_id; struct nfp_rtsym_table *sym_tbl; if (pci_dev == NULL) @@ -1039,37 +1080,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_id = nfp_rtsym_read_le(sym_tbl, "_pf0_net_app_id", &err); + if (err != 0) { + 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 != 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; } if (ret != 0) -- 1.8.3.1