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 B6526A00C5; Tue, 21 Jun 2022 12:34:14 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DE5AD42823; Tue, 21 Jun 2022 12:34:03 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2137.outbound.protection.outlook.com [40.107.237.137]) by mails.dpdk.org (Postfix) with ESMTP id 1A20441132 for ; Tue, 21 Jun 2022 12:34:02 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oREBgwtNI9Vyn8eN9oPO3JEvE/ylHj+ehFVUWTF5Sga5NppcVleeo4bqdXl0ygN/iRoarjoHM2+mRTmdnSbryfwnw+JwInro+2URLcLkLqtLf8qpX2288sWo51E38a9zTPRwVvCRGdoah+GyNx4oxGd3oWjj/1ehcsKJ5V5+yov5c7rGswPyyt9WH8qutWeVPqg0OzEhhzvofF0XGzGzd0wt7yLQEQYI+T9Od2cFllQpD6aDV2obA+zJJhOlYdw2JieL9T0gWJbLKI+V7NQblI3tFUJ/nQJJv2BDIqYmmvBG6UWwLAxuF60szbNjICUACvVG5xmyRlH7u1yair/Vzg== 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=g2zkan+E1JAi3YdpmYl5SAhlMyyMCxYmR0dZLDgDovkgujoFC1Lb2dFHoDAsCw08XJ5orZnm5pE8YwaZ8G/I63E8vsCjcEmoEM/rrK1myP6NyjCh/+T+8+0SM0NQeZUxw1IyNj1+Mvb1NCiDaof8Qs3F5nGGz5fiT3JR5y4VeYPTbP5eBhETpEHendxe61DRw9Ifg9qIr0E/7UJqWHJbR5DL5aCOjrDyMPqgDFjb2RbYnsK4/H63rGIuHDJbHddm4oIfXpzpYeMN2/5Y/TtOcn50MWxHDdTLTWFvv2SWCUgtxVlra4u39vQ04M94IHpwCKpyegYdJaZMJRuMKQ/7kQ== 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=qiCMs7RMCvmEuzyAEmjg3Sip669KarAy6t41lC2js6nNLbx4SuYX+x/Z/46AqZYPeDCGcUjdgm9LrUi0/F9jJzXyv8KTu59zFtvKX7ScC9gvYhN/zF5f+Q2j9Fj1C0GqdBKtlEtx1iPvbHgyRk0h7pwULagYlgddZQapf+GwK+8= 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 MN2PR13MB3086.namprd13.prod.outlook.com (2603:10b6:208:135::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.15; Tue, 21 Jun 2022 10:34:00 +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 10:34:00 +0000 From: Chaoyong He To: dev@dpdk.org Cc: niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v2 03/12] net/nfp: move app specific init logic to own function Date: Tue, 21 Jun 2022 18:32:59 +0800 Message-Id: <1655807588-7320-4-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1655807588-7320-1-git-send-email-chaoyong.he@corigine.com> References: <1655807588-7320-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: OS0PR01CA0018.jpnprd01.prod.outlook.com (2603:1096:604:24::23) 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: 07eaa3a4-512e-457e-4473-08da53718e04 X-MS-TrafficTypeDiagnostic: MN2PR13MB3086: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: TSfFg+FK3uwwGs+YqhWvorlakChism0xLMXardWj+gzeQanxSKauMQL7qKSCIQUeE5LLulkTsv92LP69SfQKEHXSEUqJUMN1dr3sSBTpaCWGOgniKXADblipxsiz3FSJpPKXm8//YC45Mf0jFFBjn+6NxCSHKOiI9OLdOGnCRB77k4u4cfkYj3rdX5zN5cglRM8BkQccTCtYtUq/r+48P08G4d6eLlv3M912bm2T96kvi8Y1AlHqwEmf8ul0OuUaQ/TRwgO/4V7ZMmsryyFN3o7t3nANyEC+J3q2xhyryHLVjzavvhp4JwUIfwkmtsna/QG807OhIN7AJ7+0HWOQQt/iQwvDwJOp8JeIS2qAvvICNNXPPRjIrx+rZptSWNbV0wHf5H+K3KSq9Pv73CHHFVIQ3VU63E4S5pOX+Cg4gPeKojKMayXP7T/sbBBl0aRBIQub+2E+fb5AApEm8MZuUpYQgpl7StNoXQQm1kNN+7/nYy1sulJ+WwLBNMWhueKVVe/k7maf8Wt7H4gCFBk7buRxJ31vK5tZAKtp8py8abr3CyBd5zMmODLAheuYW29rA1ZF4K2fsStTu/4td7QGvQ+Py2XJXudwuZBEEYg4/0RGuMQ0crzTIYm7x7xYjnHeImZw4jRYmJbvhRAu6q53FUOKYLRobNs+wj0+6zUy5jmZr/ZU7EXaNzPtcnZ73+6wgfedm8j/cwb23OfVMVaRcVohJWi7MW3Rl0ttvb2/24OCsIfzJSKLKJnQqlyEpvOW 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)(376002)(396003)(136003)(366004)(39830400003)(346002)(83380400001)(107886003)(186003)(41300700001)(2616005)(38100700002)(38350700002)(66476007)(4326008)(86362001)(5660300002)(8936002)(44832011)(6506007)(2906002)(52116002)(26005)(6512007)(6916009)(316002)(8676002)(66556008)(66946007)(6486002)(478600001)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?WHF6SWliZXE5Ymc2N2phMWkvQkxvQUZGQVJOTDd6SkpZOWovMktycWVleGVF?= =?utf-8?B?Z2VYb0ZIYUZjR2w4SDBoaEUyMjRKNHBuMHZLajJKRlpOWEs5ckpTS1JJOWxO?= =?utf-8?B?TWNnd0pGVm15S3hlb0FZUmJBMTR1dVBKNldlZkI4K0hjVW9LKzBlbUMwaUJx?= =?utf-8?B?NVdYdlptR0o3VDQ3MG5QZ2doZ0J5Y0FpZWpTUzdNbjQzdjcvMS9Md2hhK2hu?= =?utf-8?B?V1BkbVRiMmhWZ1lxQUR5OExGNkhuLzk5NEFPM0phdWFlaEVYQTROK242Q2ZU?= =?utf-8?B?UWF4NVNOV2YzK29RaEltY294cTVlMkg0YXhFc0s5Y2R2Y0N5WWYxNXRNK2Jz?=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V3LzJQOStJOE9KNFQyVXVCQVhH?= =?utf-8?B?ZFZIZzVzTFBjSDU4T3UwMWh1YjZBRm5nS3Y1ZStyb05sL0toclYwWjdaVTl2?= =?utf-8?B?SFRhVVQxR0RqbzZaNU9QaDBTeStLNElLeW1iaTlTVmlhNGtMSmZoV003R29Q?= =?utf-8?B?Zk11ckRqWU1CMnJEU201UnNOc3gxSkxtaXJoeEpYK2c0eWk5YjFsckpqbVAv?= =?utf-8?Q?m1gqggbrHWwhV5qw=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 07eaa3a4-512e-457e-4473-08da53718e04 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2022 10:34:00.7586 (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: mEyn0IZEkP8n3pNgWhLNMrQ0yhEyKqO+zmLwLy76RcAnRPMrW2CTtKeN7u063kFHqttPeY4eTKGVGjmwAKpDa7fDP2i4p2uBExN0UT70xHc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR13MB3086 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