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 D184443EAA; Fri, 19 Apr 2024 07:25:19 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1AD3A4067E; Fri, 19 Apr 2024 07:24:45 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2101.outbound.protection.outlook.com [40.107.244.101]) by mails.dpdk.org (Postfix) with ESMTP id 35F22406B8 for ; Fri, 19 Apr 2024 07:24:39 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WpwSwNXQPei8ZDer3nnsFwmmFX7RYfnJBYir8v+Ko8a2MFJgzZaxSqygzi3MsX6RGQYQUFREx1GAJQZ3RWBdUSYwfw5/4rSs1v+lct9sR3M6rSX7KNe58ZUsART18FcmDMGyq8urVKpQIDFC2XukN3xf6+qFv0dqJismbvmH7hUEK/7rDtOOqRsQb5n4PVOPO9EFsy4NbyN+Aav1HKYhW14zsZN+yN3xQIoHBEdCrebLkcHoD0wIX5x+iYR8IVwK+dLVJ4h+G6GQVR6V9/N6VpsCQjL+XbILBb7ES1/P6HH5cJEHlO3W6p/BUXENFmaFbpWFQR7z5rgZZEbesPUWEA== 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=rCi8m/zoxaAvim3gUm+/XR3DC/mZmc359W4FsSl8Q5Y=; b=IwThOumowVfvAGCKz2i2OLJO7NcuWmK2nWagjaGmQKN9upzD8vLvcpaWNtV+7H9heZ4QSKkU2G7IHhsLnDK2HhM9SuxxSTcLHabqnASgWB9wXpORkJvuqwgvEsNIIcqzFgRjNev3D4tVk+UmMKLv4Dcljjw1JPeaqWRUmLBnAEXB8cA8KyYQu5Kz/CegufTOWGsjoiNIMqd3BHQzhsczCWZiKalb3rZjTVfOQZD7i8RvOQ3ki8F0QxJjEw7M+qfurCOoLqHsNAWOwHYDbEbAr2qN+ksaDRZWQ+mREE2GW3zAPVe3SjE/i/IJ+I3MLexc3QJi/xUiouFuoo/DG8n7pA== 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=rCi8m/zoxaAvim3gUm+/XR3DC/mZmc359W4FsSl8Q5Y=; b=UNnHhx98bY54cI1OkQqWWA3IvxFjbSz+jfLmGcs2mQ0/lWsV/+S3kx0xM2E0nHVIR2mD1UHccUOqZVSF0QnOSlaJwEP29g3jpI+VfYKhXlUIZjUYYIh6e6+rPKD8+VxX/mzYvbu9vV44g5zUENDe3UyfRANvUVx9dbm4jF1cwXA= 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 MW3PR13MB3961.namprd13.prod.outlook.com (2603:10b6:303:2c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.42; Fri, 19 Apr 2024 05:24:37 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ec12:7411:559a:850e]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ec12:7411:559a:850e%5]) with mapi id 15.20.7472.042; Fri, 19 Apr 2024 05:24:37 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He , Long Wu , Peng Zhang Subject: [PATCH v2 8/8] net/nfp: unify port create and destroy interface Date: Fri, 19 Apr 2024 13:23:49 +0800 Message-Id: <20240419052349.1294696-9-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240419052349.1294696-1-chaoyong.he@corigine.com> References: <20240419031226.1191069-1-chaoyong.he@corigine.com> <20240419052349.1294696-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR03CA0087.apcprd03.prod.outlook.com (2603:1096:4:7c::15) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|MW3PR13MB3961:EE_ X-MS-Office365-Filtering-Correlation-Id: 17a25d86-db1e-486b-ae1a-08dc6031009c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?RirRFPOCUU0fbPvJK8araBgl4+K6MgOkOHPSYaYbycTXFHWaPCdCCpRf5pn5?= =?us-ascii?Q?T0+6tUiMeu2wKifu4+vDuqmkMKRCuHtSFzLax7KSI0f2noUMcV0LF2lAKk+v?= =?us-ascii?Q?R2oACBrncI1pVaslfZjxlExP8T+NG4l8IEx29pqvgMI09aYZzOG7ZrgZMT5z?= =?us-ascii?Q?wrC0LJqjaJ1awN+XI5qwmGwRv5AGJzIDIRmrIalTV5ocO3A0F6qzNLYiF6U0?= =?us-ascii?Q?JObv3hApjugvjz/dsQ0E2zKGd2jRz128ZZ95nZiL59Ir2O0A8el2kbXW8Zru?= =?us-ascii?Q?kaRgjkTQATr+jF8YmPx+ZBwLu69F8dkygnDUnIIXZl9lK6PHqh0iAieeSQ7s?= =?us-ascii?Q?/GaVnJogTmaiL81lYz+wvQ7TKSBOX8h9vJTyjfrd1ThA0aWvGr76VR809BVs?= =?us-ascii?Q?g8L2/qbmi6Mkvd6f/0Rq7Rs1zWSqvjLRCPneB3+bfz+P3AQPPbjQZzXkk33e?= =?us-ascii?Q?j1HqMJmy23iKwQAC7nUI0R8mjI+Wng+q3X7IOLGjiA8nPrc+vm0XcejJClsS?= =?us-ascii?Q?c3cOMIOS7Ob9O3w6nJOcbc6a88dB5oWKXsoRc7WyLfHW5AmiffMLz6lOFhVo?= =?us-ascii?Q?fyQ7BvTYocoIfCf/NDsgj3PDues756hVQkf9+KZ9v871rDAxNuc5Q6QZPSdf?= =?us-ascii?Q?q4+UA7AuFO7k5bEc22ZEHWm4R69UWnr4PAIDt1Zsj0eM9SYnxg107CEZC1X8?= =?us-ascii?Q?9223e58lPY5jH90meQcHAOU1jaazNcMUakyZwHPnCiDYfKUKtTAEN3aClJiW?= =?us-ascii?Q?Voxbe0jQcLnNJqvlAYSivm4LS/a7jfjSGkJtwWc0r2NIefgxGXvrBBleOwGx?= =?us-ascii?Q?5CENtmSAyYxodUPGB31EBRTaaWq3xN9urmzaYy/przFv959birESYDFdwcvW?= =?us-ascii?Q?auBG+7ZCWDtUqzX6CQ0taICcwBjZcb0jO9EVVYdz70kHhXha2qvy6kXSufLU?= =?us-ascii?Q?T3Omw2bepg4apS2iWIQzmunhPaBhWbvPXt6bqQTNAMowb0zstXW4njHaFA/Q?= =?us-ascii?Q?x+IUMXRpgFDhOeINPOew50owjS3UCjl204mFBGuiJOebGDiW8YHNHHEp2nqX?= =?us-ascii?Q?7ofPPjkKLUJqlSSvpLxvpf2+fiyqP6Goonw571qCY9wOZVTqYiPSOpd4rHCU?= =?us-ascii?Q?anQt43Pl9o3uL6U/Ol5J6Vov3tsLS0v/kRiX74u26CuUhp2atgaO/u4Wxg65?= =?us-ascii?Q?3yU9/RTWJc4niqH/pS6r+/faVZBUpu93V6zk4hH9eBcFi40om8WXw90refAa?= =?us-ascii?Q?ClFTKw6GjnNXiFvPfXTpBKjeJwCfbcQeCyWr6e8GsbGOVvvCG+JJuEGPYe5C?= =?us-ascii?Q?VDlgqeBTOWaw7qQUswUQYhoh3fT/v0y6MHPq6eDMSedTsg=3D=3D?= 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:(13230031)(52116005)(1800799015)(366007)(376005)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?lpIffk0KYBf9Z0iWxUWd67dIy57EnndygzaQ40AJtJYo3N4+MgX0mwLim7N1?= =?us-ascii?Q?DcD5BArGbgsaVFp/Sic54FXKDwXgE9K6mamEF4lMZy1zZj2DtsSRZhmP0qp1?= =?us-ascii?Q?dC+uVM/i2jTnPCKNChbWs6Hm7RWlyi0YqCXZBS6OQxWQE//TrPMTp75zTP/m?= =?us-ascii?Q?N3HXLdz1hyZJxJD1ywn3KCToO0qIL8PGCO39XWLo284AeDBPPLi5usO1EnzP?= =?us-ascii?Q?tL2L31YQ79f4tERGJ4gO86zWYCZZ4wVFIhViQFkomYWLFHcjc6CCs9owZPcm?= =?us-ascii?Q?gkcaZHqqzGuJXu/cwzWJUGFbzoliW3/0prPqczcBLrBt31g0Zta7UN54Dl/u?= =?us-ascii?Q?/XK8A3MhfvyPgPIZGbL4HLXatZu0MageZBOwWkW8MTTqCtH8Sx+vz45ZnO5g?= =?us-ascii?Q?sgRRgaBqznZZQ/60IMXrZzgw5T5XuOo4MhtBzAA1LFWP+GKjjvjxHHGZxkb3?= =?us-ascii?Q?J8y5onhRCOnYk2PwfCRz1OEVYG79yiwqOzDrHRJbTsZMMQUOa37nvhfa8/P0?= =?us-ascii?Q?/poCzT3fAGT+0tQi+EwIaZkYzzXNoRnQmFzcZXBIQ5quzFM1Gezkvmid/dAf?= =?us-ascii?Q?+6HG2u5SZWUqs/v6kLRIDOIupYeQ67daElHlJA0DHCJh8XJypAz7tow843js?= =?us-ascii?Q?cQznd7bog99kw7iGHRvxP9EtlLxUJX0RL3af3oZgLPa6eDjFHZX8OcnwbXry?= =?us-ascii?Q?rnIdfLsEPq3xLJlWSGK03uQXXFoL4JfcPh01iOXbihYH7D86jcgyPVyjeZFG?= =?us-ascii?Q?jm9H3fWcgzs/6hDoe1AkDTDYTFaZL/d/oCV1yxpiexMhRTAVurqhP0Wd8uzP?= =?us-ascii?Q?n5fbeGCHsNVL8ox0MHflPDYexNBWzIpUm6w21SqtshRJAvB9js8ke8Pj0FVl?= =?us-ascii?Q?UfrKwB6mduGa/jZcTYTncnWjPrO0wSb6OJV1EdWPsZJHT14OoQvONW7CrLuS?= =?us-ascii?Q?XYWMZAVB+HScQCaA6zPMi8Qn6Le0GeKuXsF1/lD4smZ2Z04jCDqFe83cyM/X?= =?us-ascii?Q?voq0lqbHEoZNnD69syVmCZhzum5dy+7bcBi0rCh/cmmm2UEgb+EZsu8BTA1t?= =?us-ascii?Q?NMNgY/+e+NCSFUJBo6qkKQfSqDHOMYH9ixQ8pYne0K9zBvdCrjwAXlkjb8vL?= =?us-ascii?Q?hSm/PPk0qD66MkCJmvkAy+24aERkO3hoQ3Hv+y48fljTKij2i+oGs4nBXFFK?= =?us-ascii?Q?K+T8K1kfOdTzA6mgs2BXmJhq2v43UiYk+2ZjoBqd2l7yUlAjzpa3ufcnHw/k?= =?us-ascii?Q?OvH2g3rJWvCmKcrX9G518rgHJafnXKPX646t1RD31CHqrZF9/ugt2NwfzO9E?= =?us-ascii?Q?8dzpFdVLE6/QHtH2ASMN0hj7azFT7QZtkOJYCoSOFXe1n/sYdS98R9L2vXd6?= =?us-ascii?Q?ib/om/4G5xAo9Tp/vnnGKIYUznpbUn7vHnLvpQjEQCxR6ItyxO7Net75s6cd?= =?us-ascii?Q?rszKjpH2INh7OKn5CVqMi6bZnKM/O2924KMnrT2HwUXDetU0KVb7Ti6ArkUm?= =?us-ascii?Q?RLSVBov+3O5GL5iHm71Tvzi9F5n5fxn4sUNkS5DJS/tEaKa1w+3M+Bl0Gwj5?= =?us-ascii?Q?1FLj0/axvf9wmSxZB8I9XYtjjIqw7OjCQLDFZEgmfkbv9+flG0OgnCMxj0Ei?= =?us-ascii?Q?Aw=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 17a25d86-db1e-486b-ae1a-08dc6031009c X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2024 05:24:37.2831 (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: kMHenpOPv3lYZXFxJB010iPrpQHEclSmWe0XC5+u5of85U3Egz+ZrUfh/p/xOj5TYk+U4BoOza74hEbmivrxs49IuUUhVcORShbBwFd1L80= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR13MB3961 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 interface 'rte_eth_dev_create()' and 'rte_eth_dev_destroy()' are available for both primary and secondary process. Signed-off-by: Chaoyong He Signed-off-by: Long Wu Reviewed-by: Peng Zhang --- drivers/net/nfp/flower/nfp_flower.c | 31 +++-- .../net/nfp/flower/nfp_flower_representor.c | 18 +-- drivers/net/nfp/nfp_ethdev.c | 112 +++++++++--------- 3 files changed, 80 insertions(+), 81 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index 76e5d674f1..0edebd574a 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -798,25 +798,36 @@ nfp_uninit_app_fw_flower(struct nfp_net_hw_priv *hw_priv) rte_free(app_fw_flower); } +static int +nfp_secondary_flower_init(struct rte_eth_dev *eth_dev, + void *para) +{ + eth_dev->process_private = para; + eth_dev->dev_ops = &nfp_flower_pf_vnic_ops; + eth_dev->rx_pkt_burst = nfp_net_recv_pkts; + eth_dev->tx_pkt_burst = nfp_flower_pf_xmit_pkts; + + return 0; +} + int nfp_secondary_init_app_fw_flower(struct nfp_net_hw_priv *hw_priv) { - struct rte_eth_dev *eth_dev; - const char *port_name = "pf_vnic_eth_dev"; + int ret; + const char *pci_name; + char port_name[RTE_ETH_NAME_MAX_LEN]; + + pci_name = strchr(hw_priv->pf_dev->pci_dev->name, ':') + 1; + snprintf(port_name, RTE_ETH_NAME_MAX_LEN, "%s_repr_pf", pci_name); PMD_INIT_LOG(DEBUG, "Secondary attaching to port %s", port_name); - eth_dev = rte_eth_dev_attach_secondary(port_name); - if (eth_dev == NULL) { + ret = rte_eth_dev_create(&hw_priv->pf_dev->pci_dev->device, port_name, 0, NULL, + NULL, nfp_secondary_flower_init, hw_priv); + if (ret != 0) { PMD_INIT_LOG(ERR, "Secondary process attach to port %s failed", port_name); return -ENODEV; } - eth_dev->process_private = hw_priv; - eth_dev->dev_ops = &nfp_flower_pf_vnic_ops; - eth_dev->rx_pkt_burst = nfp_net_recv_pkts; - eth_dev->tx_pkt_burst = nfp_flower_pf_xmit_pkts; - rte_eth_dev_probing_finish(eth_dev); - return 0; } diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c index 60f02ad919..f9001ab1f0 100644 --- a/drivers/net/nfp/flower/nfp_flower_representor.c +++ b/drivers/net/nfp/flower/nfp_flower_representor.c @@ -683,10 +683,8 @@ nfp_flower_repr_free_all(struct nfp_app_fw_flower *app_fw_flower) repr = app_fw_flower->vf_reprs[i]; if (repr != NULL) { eth_dev = rte_eth_dev_get_by_name(repr->name); - if (eth_dev != NULL) { - nfp_flower_repr_free(eth_dev, NFP_REPR_TYPE_VF); - app_fw_flower->vf_reprs[i] = NULL; - } + if (eth_dev != NULL) + rte_eth_dev_destroy(eth_dev, nfp_flower_repr_uninit); } } @@ -694,20 +692,16 @@ nfp_flower_repr_free_all(struct nfp_app_fw_flower *app_fw_flower) repr = app_fw_flower->phy_reprs[i]; if (repr != NULL) { eth_dev = rte_eth_dev_get_by_name(repr->name); - if (eth_dev != NULL) { - nfp_flower_repr_free(eth_dev, NFP_REPR_TYPE_PHYS_PORT); - app_fw_flower->phy_reprs[i] = NULL; - } + if (eth_dev != NULL) + rte_eth_dev_destroy(eth_dev, nfp_flower_repr_uninit); } } repr = app_fw_flower->pf_repr; if (repr != NULL) { eth_dev = rte_eth_dev_get_by_name(repr->name); - if (eth_dev != NULL) { - nfp_flower_repr_free(eth_dev, NFP_REPR_TYPE_PF); - app_fw_flower->pf_repr = NULL; - } + if (eth_dev != NULL) + rte_eth_dev_destroy(eth_dev, nfp_flower_pf_repr_uninit); } } diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index d450c9472e..cdc946faff 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -34,6 +34,16 @@ #define NFP_PF_DRIVER_NAME net_nfp_pf #define NFP_PF_FORCE_RELOAD_FW "force_reload_fw" +struct nfp_net_init { + /** Sequential physical port number, only valid for CoreNIC firmware */ + uint8_t idx; + + /** Internal port number as seen from NFP */ + uint8_t nfp_idx; + + struct nfp_net_hw_priv *hw_priv; +}; + static int nfp_devarg_handle_int(const char *key, const char *value, @@ -559,7 +569,7 @@ nfp_net_keepalive_stop(struct nfp_multi_pf *multi_pf) rte_eal_alarm_cancel(nfp_net_beat_timer, (void *)multi_pf); } -static void +static int nfp_net_uninit(struct rte_eth_dev *eth_dev) { struct nfp_net_hw *net_hw; @@ -577,6 +587,8 @@ nfp_net_uninit(struct rte_eth_dev *eth_dev) nfp_ipsec_uninit(eth_dev); if (net_hw->mac_stats_area != NULL) nfp_cpp_area_release_free(net_hw->mac_stats_area); + + return 0; } static void @@ -875,7 +887,8 @@ nfp_net_ethdev_ops_mount(struct nfp_net_hw *hw, } static int -nfp_net_init(struct rte_eth_dev *eth_dev) +nfp_net_init(struct rte_eth_dev *eth_dev, + void *para) { int err; uint16_t port; @@ -884,6 +897,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev) struct nfp_hw *hw; struct nfp_net_hw *net_hw; struct nfp_pf_dev *pf_dev; + struct nfp_net_init *hw_init; struct rte_pci_device *pci_dev; struct nfp_net_hw_priv *hw_priv; struct nfp_app_fw_nic *app_fw_nic; @@ -891,6 +905,11 @@ nfp_net_init(struct rte_eth_dev *eth_dev) pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); net_hw = eth_dev->data->dev_private; + hw_init = para; + net_hw->idx = hw_init->idx; + net_hw->nfp_idx = hw_init->nfp_idx; + eth_dev->process_private = hw_init->hw_priv; + /* Use backpointer here to the PF of this eth_dev */ hw_priv = eth_dev->process_private; pf_dev = hw_priv->pf_dev; @@ -898,7 +917,10 @@ nfp_net_init(struct rte_eth_dev *eth_dev) /* Use backpointer to the CoreNIC app struct */ app_fw_nic = NFP_PRIV_TO_APP_FW_NIC(pf_dev->app_fw_priv); - port = ((struct nfp_net_hw *)eth_dev->data->dev_private)->idx; + /* Add this device to the PF's array of physical ports */ + app_fw_nic->ports[net_hw->idx] = net_hw; + + port = net_hw->idx; if (port > 7) { PMD_DRV_LOG(ERR, "Port value is wrong"); return -ENODEV; @@ -1475,15 +1497,15 @@ nfp_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv) uint8_t id; int ret = 0; uint32_t total_vnics; - struct nfp_net_hw *hw; - unsigned int numa_node; - struct rte_eth_dev *eth_dev; struct nfp_app_fw_nic *app_fw_nic; struct nfp_eth_table *nfp_eth_table; char bar_name[RTE_ETH_NAME_MAX_LEN]; char port_name[RTE_ETH_NAME_MAX_LEN]; char vnic_name[RTE_ETH_NAME_MAX_LEN]; struct nfp_pf_dev *pf_dev = hw_priv->pf_dev; + struct nfp_net_init hw_init = { + .hw_priv = hw_priv, + }; nfp_eth_table = pf_dev->nfp_eth_table; PMD_INIT_LOG(INFO, "Total physical ports: %d", nfp_eth_table->count); @@ -1543,7 +1565,6 @@ nfp_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv) PMD_INIT_LOG(DEBUG, "ctrl bar: %p", pf_dev->ctrl_bar); /* Loop through all physical ports on PF */ - numa_node = rte_socket_id(); for (i = 0; i < app_fw_nic->total_phyports; i++) { if (pf_dev->multi_pf.enabled) snprintf(port_name, sizeof(port_name), "%s", @@ -1552,46 +1573,14 @@ nfp_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv) snprintf(port_name, sizeof(port_name), "%s_port%u", pf_dev->pci_dev->device.name, i); - /* Allocate a eth_dev for this phyport */ - eth_dev = rte_eth_dev_allocate(port_name); - if (eth_dev == NULL) { - ret = -ENODEV; - goto port_cleanup; - } - - /* Allocate memory for this phyport */ - eth_dev->data->dev_private = rte_zmalloc_socket(port_name, - sizeof(struct nfp_net_hw), - RTE_CACHE_LINE_SIZE, numa_node); - if (eth_dev->data->dev_private == NULL) { - ret = -ENOMEM; - rte_eth_dev_release_port(eth_dev); - goto port_cleanup; - } - - hw = eth_dev->data->dev_private; id = nfp_function_id_get(pf_dev, i); - - /* Add this device to the PF's array of physical ports */ - app_fw_nic->ports[id] = hw; - - hw->idx = id; - hw->nfp_idx = nfp_eth_table->ports[id].index; - - eth_dev->device = &pf_dev->pci_dev->device; - eth_dev->process_private = hw_priv; - - /* - * Ctrl/tx/rx BAR mappings and remaining init happens in - * @nfp_net_init() - */ - ret = nfp_net_init(eth_dev); - if (ret != 0) { - ret = -ENODEV; + hw_init.idx = id; + hw_init.nfp_idx = nfp_eth_table->ports[id].index; + ret = rte_eth_dev_create(&pf_dev->pci_dev->device, port_name, + sizeof(struct nfp_net_hw), NULL, NULL, + nfp_net_init, &hw_init); + if (ret != 0) goto port_cleanup; - } - - rte_eth_dev_probing_finish(eth_dev); } /* End loop, all ports on this PF */ @@ -1608,10 +1597,8 @@ nfp_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv) snprintf(port_name, sizeof(port_name), "%s_port%u", pf_dev->pci_dev->device.name, i); eth_dev = rte_eth_dev_get_by_name(port_name); - if (eth_dev != NULL) { - nfp_net_uninit(eth_dev); - rte_eth_dev_release_port(eth_dev); - } + if (eth_dev != NULL) + rte_eth_dev_destroy(eth_dev, nfp_net_uninit); } nfp_cpp_area_release_free(pf_dev->ctrl_area); app_cleanup: @@ -2012,6 +1999,20 @@ nfp_pf_init(struct rte_pci_device *pci_dev) return ret; } +static int +nfp_secondary_net_init(struct rte_eth_dev *eth_dev, + void *para) +{ + struct nfp_net_hw *net_hw; + + net_hw = eth_dev->data->dev_private; + nfp_net_ethdev_ops_mount(net_hw, eth_dev); + + eth_dev->process_private = para; + + return 0; +} + static int nfp_secondary_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv) { @@ -2020,7 +2021,6 @@ nfp_secondary_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv) int ret = 0; uint8_t function_id; uint32_t total_vnics; - struct nfp_net_hw *hw; char pf_name[RTE_ETH_NAME_MAX_LEN]; struct nfp_pf_dev *pf_dev = hw_priv->pf_dev; @@ -2034,7 +2034,6 @@ nfp_secondary_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv) } for (i = 0; i < total_vnics; i++) { - struct rte_eth_dev *eth_dev; char port_name[RTE_ETH_NAME_MAX_LEN]; if (nfp_check_multi_pf_from_fw(total_vnics)) @@ -2045,18 +2044,13 @@ nfp_secondary_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv) pf_dev->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) { + ret = rte_eth_dev_create(&pf_dev->pci_dev->device, port_name, 0, + NULL, NULL, nfp_secondary_net_init, hw_priv); + if (ret != 0) { PMD_INIT_LOG(ERR, "Secondary process attach to port %s failed", port_name); ret = -ENODEV; break; } - - eth_dev->process_private = hw_priv; - hw = eth_dev->data->dev_private; - nfp_net_ethdev_ops_mount(hw, eth_dev); - - rte_eth_dev_probing_finish(eth_dev); } return ret; -- 2.39.1