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 5C24643EA9; Fri, 19 Apr 2024 05:13:58 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D63F940A80; Fri, 19 Apr 2024 05:13:09 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2127.outbound.protection.outlook.com [40.107.237.127]) by mails.dpdk.org (Postfix) with ESMTP id EDA2340A6C for ; Fri, 19 Apr 2024 05:13:07 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bsjZq92NyOKzULC/x69N2b8Hx9ZKPbNB7m9bB0SjivBcr9yg4IdnJ02cfWevoUZUjx5PzGvt99hWquoKiCPUiAHyiQ4sS6H7vaVrLaoZb1/Be9QKJfC62ndpULqUGw4PAvEaBGkrAOHT5NPZxj1D4HPVW8H/SmltgpJzA4sICS1Xa7Ef0ktf3eJ5JNRl0En0Uudn5CfKt8maj7I00IUDmZaYB130u8WrrB3o9mXycN4Bs0yBpEqtQaBMRHI+88ujRpmjuDkrkEZvQtcida6jbch5gtZy7XP8/5VrGcixbhb05UkInNaMkSDkZ1uMm0m9r9O9eJ1sHH4JQgsZ0Sdn4w== 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=ntj1HwsKnkBah8aco6gQDkahRf7A4kAQlfnaFMUkhdQ=; b=n5GBcdeXmGoeUz/Q4XHrGtcLq47PTYo+PrBngI3pucOxPRWhrohCCW82BuNCces39LQncb4UZSi/5yevc2FMwmyQEEH/mgz9emcY+xeb45aSK6VJf7pxU5WxLf2dZUr0Ix4U/HHxqgYEwhup9uOwQ6TFF16DIHh5RGecL0yReMmHNWVB1X1c+HDs27h3TWsdjZaTsNa7phv96iDqUxKN2LsiJDev5bn7McMJ0g2g7i7aLVi82jbZJzw8sd1ICX5lRb/aZvqNO2XGRQ5wIXxhTbVEbHqMU7/+dv+6sdmRybWhiGfxVV6spux2RTQPvQ87AY2M3dgilT7k+duIaU/ARA== 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=ntj1HwsKnkBah8aco6gQDkahRf7A4kAQlfnaFMUkhdQ=; b=lWJoFtkODo6ZW5Jxmsmt41I21w1odKGGVZNdcFiiy/zKWPgtP5JRIByT4k5DFC9ISEG/dysKMeW+TghE5lTUgnGo3xiRMMexF1S9UHQtKLm13R7EoKBzG1KXleJgByFQiOfDg0flN5DdttDHVPJGksglFROlgwAhR9f8kILYhWk= 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 BY1PR13MB6310.namprd13.prod.outlook.com (2603:10b6:a03:52e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.38; Fri, 19 Apr 2024 03:13:06 +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 03:13:06 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He , Long Wu , Peng Zhang Subject: [PATCH 8/8] net/nfp: unify port create and destroy interface Date: Fri, 19 Apr 2024 11:12:26 +0800 Message-Id: <20240419031226.1191069-9-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240419031226.1191069-1-chaoyong.he@corigine.com> References: <20240419031226.1191069-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI2PR01CA0044.apcprd01.prod.exchangelabs.com (2603:1096:4:193::8) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|BY1PR13MB6310:EE_ X-MS-Office365-Filtering-Correlation-Id: 92598a2a-b9f2-4cf0-160c-08dc601ea219 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?hmkhjR/2Ln/BhxKdgmA3E95DgH5rQQiAa21n7Pq79foofr6XS7tVdHULGzQV?= =?us-ascii?Q?S8llFQ1/Lwts+I4DCu5nb0vdgEdNslBRuaxVc/15ZDWbQmGzmj87fKo0YfSA?= =?us-ascii?Q?ZLSsT1w+EdFNHaYk4ETGLUQfZRtaSLV3WErsk0T7Et9E2LNRl6tn61NjeV3f?= =?us-ascii?Q?ddrc+rEabsGyxtQkyMeBNwlQYK320SIUbw/nKQrvbuEuVaRwt+d7BtV7YXH+?= =?us-ascii?Q?llFrbjE1hd64FrIq5wggInU44q+Ic1Qo8GWeo6Y081Ok3qf1crgtFV9SA9ea?= =?us-ascii?Q?ZOyxMloxzOU41Vm+Hg85QjIxvn9UJA2Ozho/EBrWIyHJOqYSl0Ch6nClL3Jq?= =?us-ascii?Q?YhfDJiB4aJx1jmshoz2ciNPkGjz3Vv6M4DpiVtCToTxAT/1tq8mbikKg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d3Zn9VTTj+w4o0A1FZpRZeVy7FZZnZ8F?= =?us-ascii?Q?yTZSHHBgb6tD7EcEJub9k8dGUFIZuFHx4AJzIA0S9I1PdQ=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)(366007)(52116005)(376005)(1800799015)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?C4wc3uQbLa0MJ1chmuSa9te+mIAOcYduATX/+hoDbS+gM1Y2dmvnUIKM4w2l?= =?us-ascii?Q?afN+AAunne0fnk/a0welo9nWqlGVJVzDfT/5tFl9HaL5QDmKhC5tTeGNkuu2?= =?us-ascii?Q?mfFi7gauLd3CnPpFLT8j+9Nj39sRfHlREpNBIC8snnBXSiEgqJHYoCx14OEr?= =?us-ascii?Q?LO0lt07EG3yitf+4rsf+zHJ4tEHdpYQGVT5bqZiWhqd6J0y9cDhDOVlwrOCu?= =?us-ascii?Q?MSbmQI3tUhVYH/0JUyugcRqSDemVKSb920Xv52jRaI/BSw1VDAcnBa4ZP38R?= =?us-ascii?Q?WolMf9QcKzuMalFHQcETHXgQRBfwCFf+p5V2iKjD31lqBEsUJxCRD+PfrcJ/?= =?us-ascii?Q?yqpCzdJElJsWEbUNEmVRWNI0xn2BTF4Rh9b7TMYBLXekYyWbxH4PZv4Q5m8O?= =?us-ascii?Q?qs3AG6oXvcfZMiV97tb0g6m9E2zqgmKFQy7j52ii9CF6QepPDl2L1//VcvIc?= =?us-ascii?Q?kIjHuFEoZYgq3+AiKY/E61Zf8yNFWXvQvJv6wMi2Sam4i68HrdfABaz2GgNV?= =?us-ascii?Q?Do5gSY99kzhOoK6pvl+wPzLR6pJUoeImDy/xVGJDHKziaJS77wiwSHSHZirg?= =?us-ascii?Q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/MOb5uShx8Se1bcp6Eta0JKN1mAC0J?= =?us-ascii?Q?sIYm4YLZ6VUV5LtIiR0Juz5YpcHIWK8QV3HQ97rUojJTwa2K/lvJrN84FQrA?= =?us-ascii?Q?WIkqjp4e8/UoKJIphw3PL7yFzgS5sezR9gyvtSHKakicAhSd0YrL561mG4EL?= =?us-ascii?Q?EA=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 92598a2a-b9f2-4cf0-160c-08dc601ea219 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2024 03:13:06.7563 (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: Urdw9Jv5+CxIV2AmLAxu4SAwXVO8GpoR1Ds66KsKwOeQqocdczE4RpDreaDL1EhiNpmkyhd7jYFRHf9SZjj8Us8duw/GUYWOFTMXyK4VeVs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR13MB6310 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 fba8410c58..13fcadd71d 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