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 6F1E4A0548; Thu, 8 Sep 2022 10:45:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 530CB4282F; Thu, 8 Sep 2022 10:45:35 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2121.outbound.protection.outlook.com [40.107.237.121]) by mails.dpdk.org (Postfix) with ESMTP id 89D8742829 for ; Thu, 8 Sep 2022 10:45:33 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jJHwP/NolEBxD1RuMe2+/m8y5SaNFis3it36D8JJ9xAECM1ClA/uPtVugjYrKMxm1SQrtHfueGi2YE9I00m1SrxSHjfFNLWP6s2IACkWnl2nWRjJyjUJXdRf8gaW/vH48dmyiesRPmWV8NDgnGkrdrTwS9IKiRHDFjZeTXZJ7hWR6l7+ByUCiwgSg7wHsCBd+zBM3srwN5zxsA/1LZHfZJp3AVM8g+/NAj7oc3bZoVM6VVs7qwLB63fcoLYNbVV1dfckXohZVloy6uGF2hKGRcFuDyEKq0TQzTboI6Ql9zsE9QrHbXmETv6RLpQPAFb6BelRFCXmOedHkZi064Hnxw== 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=JG5xtXeyb63Jsz3Anq89hgeTM42RXjngsiBgaep2x9s=; b=eJ/JtRpd32nmGs1RRQ+VjzhbBiahEboWhqWYQ6vB9sO+Zm9xLMSolxTENvs7UJyGGjZPne9A0TiLzzYEO/sKfVKAk0P8OU0YucsILqQ9ifMQxCrw/CFNGAQo7jP60WDygSdkljgMV1K3TNtMlG9yTeXGxOVDOWBwvDpwqK7/4zYUCwnS6FLmL01ECQDShXWDdyhPsZau2DzJKdJhtRq3pTzA5tbQ/3hKY1hiEsDKOANs/H+1DRFHj6xM0H3nkTYJAsLR2VY4wzfSAVW9unLjJNfCwnmPYGgKkZ5y87p8A/hfIaS2Cv9TmZnCdgdlzQo2GMqwDgic/WXYnXnRAqf/bQ== 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=JG5xtXeyb63Jsz3Anq89hgeTM42RXjngsiBgaep2x9s=; b=YY8KnxO8qvlj4GI80KA9Yh+xozKFx0s6hJRFNzL240DALXS/eKi7kECRAAqyWqCpDjRjEU/7IXoE3LQAiwpDBGPhZLiET+RceSNXo7+5TM3hIPaSZF1otZzNo+cnSCuxBIgZuK5hZbOuNQDB2G4H2mW7tU61ng0aLZEYG0B79ak= 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 MW4PR13MB5940.namprd13.prod.outlook.com (2603:10b6:303:1b8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.3; Thu, 8 Sep 2022 08:45:31 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::402d:6abc:83a8:2431]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::402d:6abc:83a8:2431%6]) with mapi id 15.20.5612.009; Thu, 8 Sep 2022 08:45:31 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v8 03/12] net/nfp: move app specific init logic to own function Date: Thu, 8 Sep 2022 16:44:53 +0800 Message-Id: <1662626702-17254-4-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1662626702-17254-1-git-send-email-chaoyong.he@corigine.com> References: <1662626702-17254-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR01CA0023.apcprd01.prod.exchangelabs.com (2603:1096:4:192::17) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|MW4PR13MB5940:EE_ X-MS-Office365-Filtering-Correlation-Id: dd83ad48-8fc9-4be7-97ae-08da91767d03 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3i0RhhFzdLIwvU5kSUexdJnVPC4aeIwcm1rDLmSXqjfhxE2sPv3GY5AV4py03tMe766V/qtTtic2R11MtOReVlEUCY30QFRxJf91U6BrHaYSvXLTJ9w3U9gzeOv68uEP1sqGQbeBOFOLkxxBYHdxtuMsjXBkFELP5tqgj924K9tImlYK8aCX8uNSK9TaQxD4ylzCWwEg2grKE5x7WxAkXNlm47r3fo+D/9MJsyz+Ia8XUeg8dXhoNNpyEVrC+5zMjyHOjdchf6WD5ouenWPS7Jczz/FQ+8sncSkZC/Eeq6wBnJw7JU/Tvq7F+WXUvGMrWohRXyOagdKp3gZH2a38VI9aZSmvXtIReDjG+72+20D8aWCYuIUp3kn5Qh1GJ1Vej3CiHd35BAXjRJsu4qEHuB7z6YrChzmrl5zAcDDUZ0ypI2j9RF/h2JMkasvsdlnxIEJ7G2ogGdCSRBC+pNgyGpU/Oda4KVxdHjwe25hXRktjORdQvlc4GAwiYBLpzr8iqh8YBLIOB0E5fLD4xaFX6UsrqgjNidVIv2s39T8CWVVFT+LjU/ikHKJH88WIrTO8CLYILC3tzejAxEI9TxZYOEg5lyCpPsSD9WLHwGRLkiDJCYDg5MsfhC0Rs1gYOdG5H8WUFcfvScyHlkOgMcAbs+MyJ+hG2DBGEa+9okmFZ6ssAFdAk95zxxJNE6ymWtl21Kxen5m3TculYYR5nFnoUDHkIsQWln8mtv8qKiOhQVtiEtlN77DrTLGIC1IOO+2/lpsRhjQ089SueiVSamjFfQ== 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)(396003)(366004)(39840400004)(346002)(376002)(136003)(107886003)(44832011)(2616005)(41300700001)(6916009)(38350700002)(83380400001)(26005)(6512007)(186003)(36756003)(38100700002)(4326008)(2906002)(6506007)(316002)(66946007)(478600001)(86362001)(5660300002)(66476007)(52116002)(6486002)(6666004)(8936002)(8676002)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?cHYwaGthOVBVcWVmdytnNGNmNU9tMGJvd0lnVHF3Q2FIeXA1OC9LVDVZcjhS?= =?utf-8?B?cHBadWpRM0RxMW9sanNReVV6VGowbXVtZEsydXhhOXFNdjlybUVaNjFoM3V6?= =?utf-8?B?Z2Z2TVl1Kzg2QTdIeFF5MUZFeWJTbi84K044TVdRaWJjUzY2QUE3ckZXSCt1?= =?utf-8?B?Z1JwVFhBeFZxUDAyak9zYWo3SDhsN2E2T0x5ZGg3OGpIS0lXQWlFNitPeUs0?= =?utf-8?B?U21scERIbWYyYmhrM0RObzB6RjM0STFUVzFrNkljbS9MSTlHTkNNb0VWUW45?= =?utf-8?B?K0tWQ2V6Y0V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FF0R1Q0?= =?utf-8?B?WmZmT0lLeFJtVEoxbE44citkL01XWmpQaHMxaEc0QnkrM1dGZld1ejZzc1lx?= =?utf-8?B?anc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR13MB5940 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 955b214..19b26cb 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -994,6 +994,49 @@ return ret; } +static int +nfp_secondary_init_app_fw_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 @@ -1002,12 +1045,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_fw_id app_fw_id; struct nfp_rtsym_table *sym_tbl; if (pci_dev == NULL) @@ -1041,37 +1082,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_fw_id = nfp_rtsym_read_le(sym_tbl, "_pf0_net_app_id", &err); + if (err != 0) { + PMD_INIT_LOG(ERR, "Couldn't read app_fw_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_fw_id) { + case NFP_APP_FW_CORE_NIC: + PMD_INIT_LOG(INFO, "Initializing coreNIC"); + ret = nfp_secondary_init_app_fw_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