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 9DFF4A0547; Fri, 12 Aug 2022 11:22:58 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B3D0242C19; Fri, 12 Aug 2022 11:22:43 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2106.outbound.protection.outlook.com [40.107.223.106]) by mails.dpdk.org (Postfix) with ESMTP id 88DAA42B96 for ; Fri, 12 Aug 2022 11:22:42 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KsqKNCL4DO/nh9IPFS/IRoFqPfH8JEwSlGF9ET6O3Shgw2Db6EdkIbYTXKIYpCEpp/Wr3SFG8rsCF3fuxrASPABfMP1XPgDqnoUK5oik+BYsTLMEYIu/EB/aac17AD8QIGcjLkZ97DMXPHfjsASCeFbEq24RiR7eyienE2+tQ3QUjxguBAmpn3ddhWlxNUxMScSLtn77d5K4vFLBM7QBMBybFnYIg7r14NSwl5grXgX7QJU+lK5v/lAS+uID23hcrYFoFXHHP9/cmuU4mj9JsiRvCi7Tj+pkGq9DC8XTXFjro+HhUw6LSPjHYiOuprB1+FKYorabnq9DzodbeR6JsA== 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=YjZDMzT7Tih/xM8NDPibSuz2KMZW/uIdapVVvg58AkM=; b=JtwXykcBbndyp4w7tWrnGMoSwg9skGNp1KSTr8YFtasqls+tCW9xT5NBvbvrLtt9UahwtlszSEok6pXwBaAV6AsQzRvH8b4nAOhtFynrXM3yvEl9jE0Yl16uopUdIpm4F63UAdzefsY7amvFlNegHV6h4aKaDXWPv83PxrO/BxmFtos0dS04h/cue6lysc1wfaRa/QG7TSsv8Vwlr/pHe1wpW6aDBB0zIhILpunIJTwHtyNrpNSZyPIZHsjFJyjSsiqI1o1fnupaMjodNoNxyeyAhTQgLh2AVyzXLr+/Zi5Z2n59weVImtYfdiQ1umplSO0EWPFDYgQ+lvZeJRWBnw== 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=YjZDMzT7Tih/xM8NDPibSuz2KMZW/uIdapVVvg58AkM=; b=DSglYzZ6R/ejr5hf87zYNt5kKwyFuCEJD+bOnxqeJe8AOx57qbxqMebEd1qX4L/bfWJtNd3p/pTGrufzfW0clN6w68KHHFlE8mBWceRUyjcZwCxXYhQfqxo1c/35QHXmdMFdfJgpkmoVTxceB9DRA/Jvv5GSCPZ6TIgBP8MBvE4= 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 PH0PR13MB5284.namprd13.prod.outlook.com (2603:10b6:510:f5::12) 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 09:22:41 +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 09:22:41 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v6 03/12] net/nfp: move app specific init logic to own function Date: Fri, 12 Aug 2022 17:22:04 +0800 Message-Id: <1660296133-35266-4-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1660296133-35266-1-git-send-email-chaoyong.he@corigine.com> References: <1660296133-35266-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR01CA0046.apcprd01.prod.exchangelabs.com (2603:1096:4:193::18) 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: 25c4b004-7575-457c-a172-08da7c4434a8 X-MS-TrafficTypeDiagnostic: PH0PR13MB5284:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Wc5/Bi0jVB+MC1SqcoXIewSAGQPPVYA78cYsxr+upl8C2V2bl1+/6fQRpFLN3JY5VKlChoxOR3X1xPqnlR2iDBZ91wDS/welRsJggXiohsd8N7rVk56X4emCsC56LTK+6fkHDEKpe3zol0ardtIkCleNNUxYhnverO1c2moU6e5vk/piPoKLThujJDHLDoMMkuLMtYTioG+34B8lsmK4FNga8Ri2+S/9PyyWnGi5eZlgza9IcY8b4fG8RYot3gl4qoYucNX66sMLHyVKpylYDaLvj+aWg5Pdq9J2OGihNOqLOqJzQkWv27e2grUgn0CNDnhgRAqHtPfK1tDyikOryjW1KBAactiBois4ZvWlZ789XzP0s3/VBSu6J00eXfnWPtHnSK1ngzwD/fk3pVDcuyZLA5hA9oUJEia2+CN6HM293CEZPDP7qBGRb0h1W8o+T0RzBFno1vI7Vz/rzr5VG28/VqGXjvq21okVWuxtpXXd3AUpSG34ev2hP5Nm3kdD1jL/baz6QqmPaexET3P7l1pTsYXuu5K4by2B+GsxYwkWbhjd8f9C1b3PdDjQlZoXKQ87mdZ+awRGRPJJW6v2FKxktNbmKZlWnMELD1FXXA8938rGcVaLgv9g+SCO/EFK/zd2eb9BvQVyzNbH837ziMJcpsHDp/ESwAcfuHACd4tEozn8rNA4/zRI6gxC/LcTKWc02yWTNf/ty32kJKXf3Yzpv5Thsr+81zI89jx9esfSUQkd8cLDD3RZzb8ApXu0YtywTAdhwtmwPofZz/dWfqr/BfLGM3bN+iWcABjADnIt4hDYf6FdyPxK4BbG2QvvhIfCbOBzgfNU0TW/oGR0ZuuEwrbLgHe8avTW17nymE4= 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)(346002)(376002)(39850400004)(136003)(396003)(366004)(86362001)(36756003)(6666004)(41300700001)(44832011)(38100700002)(38350700002)(83380400001)(186003)(6506007)(6916009)(26005)(107886003)(6512007)(2616005)(5660300002)(8936002)(478600001)(52116002)(2906002)(6486002)(8676002)(316002)(66476007)(4326008)(66946007)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?V2lkZXB3ZU9wQ1lGWldYSWlCVkprY0Q1NXdoSWdaQUlaNVYySG9ZVy9nRXdD?= =?utf-8?B?RUE0akpIZkIwVWh3YTYrMENTblc3dHdwcTRyc2hjaWcxSi81WWhvVG5aMlFx?= =?utf-8?B?cGZTenF2cXczT0x1TFhHQ3Jzay9zS2NsbHhRS3JWRmtEeDIyYzNlektjdzM3?= =?utf-8?B?NWNzQlNGZkVJR3c4aHZuYUZnMFZEdnNsNmFFMFY0WHcybXZ5SlA5RTZteVg0?= =?utf-8?B?dWYwTXNGL3BpR3lCZ3NoU09UQm1FNVhET24yakQrMGUyWCtUdk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E0R1RoNGFvUTF2MHFXZjFreVpmaVhrWHJWcEI0VGNVMDFG?= =?utf-8?B?WmQwem92alk5ZFdvUURuY3pGNURjaW8xRng3aGxId2VaQi85d0hLdWtYNVl6?= =?utf-8?B?QUE9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 25c4b004-7575-457c-a172-08da7c4434a8 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2022 09:22:41.1621 (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: HLdqnfK7MAQBP6dvhisTVz1AFl6rjMbzhXVWN2ZkGL80zHoobVo0Kk/3jfO9cdxoUCHaQyraKLaj8qXBn8/PBHTXejFay0v+JLDfRboRZC4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5284 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 3e4dc8d..ec4f408 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -991,6 +991,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 @@ -999,12 +1042,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) @@ -1038,37 +1079,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