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 2EB3CA0032; Fri, 24 Jun 2022 04:55:20 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0CC1E4282D; Fri, 24 Jun 2022 04:55:07 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2094.outbound.protection.outlook.com [40.107.237.94]) by mails.dpdk.org (Postfix) with ESMTP id C9A8C42802 for ; Fri, 24 Jun 2022 04:55:03 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oQsbj0II+ytPlb/Bb2arfNlZAufBeJ4Z+pwYn44swl7DUjwMnP7xyP8WIQzK5nryqxOnMC07ZbALPWPDx5ao7jpA8vOINO+OUjj7pjotFysiKg3TZklY0THgf03CGOoRP3TfVzrnamt2CHClHeak3JR2io7CORRrwEm5/B1NjOxt4BHTdoXlnfjZfx8ux/QFy8Pn22wsr1aKUelkDp675TY1oRsapSC4pFCDn7963haWS/l3JGrmeJkEzAEh59MJMo/E2WxiXsAi6UDDuG9fR+l8E0aaU+mwktoSrT5hwYJONfDIT0RYqyrWVLbP8SUUAlOgdPOjTOyXXq+BGf7EOQ== 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=OzIPY65Qurr1vpZcNUuVc2QNs4BpRID01zN2FzcvPwRZ/QvDGlg+OH07suySZnaZd1svWtkR8tbyYJ6PQir2hss51u76JtbXPkGW9TJL5tLcWJRl3LltpDFK/idUKsvIIB+wk6IVO4i5WMZ4JscqHiW/ed81ikRXQzBUwl4QzhubxSzDeLBSJpR4ybW1GDYdtvGXtYsJ5g3dlDuXb5+aPhJHQ7boSmVWP4DeZqie0T0RANtptHLXyZOiMkxJ2iD41BTifYedQNqgrcKJ5X8Ga4SXztFJtH21TGaFrIKQ3YPEmRH/HttwI/YzTxuHTydjs2aY6gbaUhEweeDrOY6KkA== 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=Sr9pKgFUbS/SMMRvFE4agil/Swdaqc6EhVH0/MDsSV/cC8pRzD/mJRS5oQl5hH2mreOYtKVMEi1TIdWGayzzF0pthYej0D0633ofBMm4NQerZFXx9CsuYCN6aHD+BOcK6TnNbdA267wsJFOKYVhzyiXqNC6dAWJEdBDWYB6Aa3Q= 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 MN2PR13MB2752.namprd13.prod.outlook.com (2603:10b6:208:f2::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.15; Fri, 24 Jun 2022 02:55:01 +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; Fri, 24 Jun 2022 02:55:01 +0000 From: Chaoyong He To: dev@dpdk.org Cc: niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v3 03/12] net/nfp: move app specific init logic to own function Date: Fri, 24 Jun 2022 10:53:52 +0800 Message-Id: <1656039241-20955-4-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1656039241-20955-1-git-send-email-chaoyong.he@corigine.com> References: <1656039241-20955-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR02CA0030.apcprd02.prod.outlook.com (2603:1096:4:195::17) 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: 8ae632c3-1f72-49af-463a-08da558ceed4 X-MS-TrafficTypeDiagnostic: MN2PR13MB2752:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k1s5V6xhQ3juXtjIrUXjfNkB6OYD/tj8YmcAlsAigAQmkIlQiD8wIXzAIHri2f3VVm/Uc7PtdlyDRdbRqLNokNPZVQW3bUm6GpKJXNuuwzfkvF81Psi5Dh0lEbfNASuYLdam7RvabMYNh0ElwyfpUa4ZtScmeAt3OZC+brFWTH2zq80UDoFOaEeR8ZlWFVq8ueD09zFs52BTZI6ceIpgo+zCHuZhEHl5wlc1c0BtC4z0hPHID9ONlx+ZYGDzHvgkwj9eq43mi95/UO3EZGzLUIYf56VW43SPBis5MpjzJK4fGjAH9rA4r3WyDMP7AFB/nENTNxdDkU4T0V+S/mDWAlUoBHyhYZEB+F/bewKZdaXaja8d543xNI2TnA/BGuqrjh35G8uNHp0kVTkPrewzDRfBlpnC8Ivt87zIGGS62VMgiGFbsysoKG3B0Jakjq0A6zvxk/HspCxVN/SnJ+JTywoVwSg5o/XGUPXnBF41SowjZjHNu4GMxzxmb+xnkMMErnEvYkjXqncbgehKivrsScEJDy1vujMuU0kqrunIkaCnJdIUTdy9+gow7nzwjIV8sT/mMIL9sm1G943VcFpANmLH25vh3qfHx2CN8/cDbmyLmQm8VTC9XTGzjKYUTIX6lUPyoUdvNO7kzkK4IzliuszTlsCcysm33CQOv8nfgZNIhw5JDCqvULhoYUGjaYPuZsZMirpEUYDyNJ4LSJIO5R0zN3HEIiOhUXX9CEk/yqRpmdXvZHYYFkM7iH8DPk1AwyWmAL6/zUjOqus6YWoXauzy/UYEnjHTakc/Fxy5NyFMgaKrh/prQadhOpNWg2O0+/I5HQApU0pTImiP1a7nhg== 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)(66556008)(2906002)(66946007)(26005)(83380400001)(6916009)(66476007)(6486002)(2616005)(8676002)(41300700001)(38100700002)(4326008)(6506007)(6512007)(44832011)(86362001)(478600001)(36756003)(186003)(52116002)(316002)(6666004)(38350700002)(8936002)(107886003)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?eHlaQ3ljckV0bkpZWVpvYUowcGJ0TmlmYVZVSG1JekNwOWF2OFlhbFdJZWJS?= =?utf-8?B?dnYyVHl4a0tKVE51SXIzWmZqbjBFMEQ3OVFJS0MydE5wdVByN0g1Vjd6SG5n?= =?utf-8?B?N28wc0FJSzd4SWEyeU9mb25yeXNOVEVDVDYxT0tDRXJrZUZmcmhLdTN2VXFO?= =?utf-8?B?UDArbXVJZFVVNFppSUJ1ZTg0VVZWaitMYldTL1p0SHFSWU0yVjdUbEdUeGhN?= =?utf-8?B?MHl4YkhSR29TdHI4eHJ0WW94bG1pb1hEWmNLajVhNzcwcFBKY0E5YURmdEE0?= =?utf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PNExGZDdrRndWZC9h?= =?utf-8?B?TmNGSDdlekp0R2IrYjVvSTZpUSthZWVMaVRXOG53RXdZdWVsVkZGdVRiRXJj?= =?utf-8?B?VFE9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8ae632c3-1f72-49af-463a-08da558ceed4 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2022 02:55:01.8580 (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: Vq/h+rWedMMbddhClf5z21fMfRnus+0l34S3TZaSSFZk39b1mIeWZ+5rGJP0J3IExzgcbbCUHBnMst+/3N8wTK5fcm3p/fjpx0oeZMhA54Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR13MB2752 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