From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0057.outbound.protection.outlook.com [104.47.38.57]) by dpdk.org (Postfix) with ESMTP id 6C37B6CBC for ; Mon, 24 Oct 2016 14:00:03 +0200 (CEST) Received: from BN6PR03CA0048.namprd03.prod.outlook.com (10.175.124.34) by BY2PR0301MB1622.namprd03.prod.outlook.com (10.163.28.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.16; Mon, 24 Oct 2016 12:00:01 +0000 Received: from BY2FFO11FD005.protection.gbl (2a01:111:f400:7c0c::134) by BN6PR03CA0048.outlook.office365.com (2603:10b6:404:10c::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.639.5 via Frontend Transport; Mon, 24 Oct 2016 12:00:02 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com;nxp.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD005.mail.protection.outlook.com (10.1.14.126) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.669.7 via Frontend Transport; Mon, 24 Oct 2016 12:00:01 +0000 Received: from Tophie.ap.freescale.net ([10.232.14.87]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u9OBwEMe008267; Mon, 24 Oct 2016 04:59:58 -0700 From: Shreyansh Jain To: CC: , , , Shreyansh Jain , Hemant Agrawal Date: Mon, 24 Oct 2016 17:29:39 +0530 Message-ID: <1477310380-17944-21-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477310380-17944-1-git-send-email-shreyansh.jain@nxp.com> References: <1476539108-13170-1-git-send-email-shreyansh.jain@nxp.com> <1477310380-17944-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131217840019202507; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(50986999)(76176999)(626004)(97736004)(2906002)(2351001)(229853001)(47776003)(19580395003)(19580405001)(5660300001)(48376002)(81166006)(7846002)(50226002)(305945005)(104016004)(4326007)(8666005)(189998001)(5003940100001)(8936002)(356003)(81156014)(92566002)(8676002)(5890100001)(87936001)(2950100002)(68736007)(6666003)(106466001)(50466002)(105606002)(77096005)(36756003)(85426001)(586003)(86362001)(6916009)(110136003)(33646002)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0301MB1622; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD005; 1:z7sALQ7UXAOB9YkB2QdrBUvQuupA13hHRe0jfDjWlFPx2lsJAt7+YFUZ9BHNihMlqJLGbdhHWBiCUS/amduI6K2N8o+DS4n+C3u178lNk1hzWioAzewnNSkGDnykyMcyh3Xe/6rjSm+OAN2teSkefuQz8+fwb3tzLrsI/NsFlO1+f9NIwW9OteUYQ9iN98OGEPzdGPTKNhYwmijKSZi2lQMIbw9JCvQkz90kh24JGgPX7JuJJMULTi54NwfpqqaTGqU2ZgeSlpMwcbvdaU3IawK8sqR0y2VAhkT+KRnvEjv6ap43/YVDDVkthbkSp1a49CHTtfZZVT1+xe8Znz/6l2eJupFPJAKrV3HBujZJGqak8tkSfO3+6GMKTQzdorYbhr6+9F7KWVmAtYpgg7eKH8vxpBS6bDKr0M/IhssZiM/17aqRFgNX+Y2YXQR1Xe/qI/kpq2V2UAdeW/kIhMsTTz16zbYK0aVaiA69RXZXvqd2sFfl+SD6NGCbLHn+7ultmr7XJfx1grgLAxpwCkYmjnE3NXh5q8BK69nHRnlLW0bQA3uu9xvAcwGkfOEGFfYIhVg6ePApsNr0pfCEdeh4EarHR3TwXk/nZ/w6/4fc1F46/3oeYlDgeJXRiRilf7eEjWYUfmJnwInTLNe5N4LPk4Y8Xxs4rEQ8a6T127ZeS/eufkwRB9Z/oqd91BmyS+3yJe8I4fmevsP4Qyeh3/6Wz3mU8aAETX0NF47NiCdRlEc= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: e328b77a-861c-4380-806c-08d3fc0548fe X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB1622; 2:BQDG3QGaqQemWMErPlCD73yGiJY4xBKi4UiFD1IdcsjFggfR9vmv7aiycTNADLoHaRxjTudzGXhOmv9el6zTgCg6RV43g5qsgTI3Agfs9Kf9KUkgtuTw0+dmmC7GTKdpk2uMzxvmdWnZSUzlrFXjbZOU9kZlbRIUG5/7p3U7CXbvZjb0Kmp8vpK9ujPROiowJi5QgDvGlIwYqE3NeF6bGA==; 3:uzkihc5/g8ww8eruZpmsUb9fSxeYcGA4ncSwX8gApsjVFWKJZ2GQ7SuoTGqFC8JV3YviMLe0JOaOiQvFFS5o1TNEJBUXJQmvhbh8WS0erBfaxOx/3H15bifOm6OcD5KfWkr9VpOiS34WdSevxQP8jH0MZKZ02/Ow7gKL43LgyKLdGlMRWmDnz7TFJQJIlMcEkq/B89tBTMuhugtp61Oj0TG4fT9OIEG5Pvfr0ZEHVD/BpVY9atVWXkbv1yW36aeC X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0301MB1622; X-Microsoft-Exchange-Diagnostics: 1; BY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sLZ2kvfy65fQ+Pc3HPnk3HJFQ6x1fTCaQcSaUw4J+/ITP2cQB4T69lyCtjU6amlA==; 4:ekPZdOhrMfvoof0XEuZGMK5oaouOYfQT4VWCSu7Jin56GiRwXesi96+1HL6JVaMCP/dELFC1h5GKCqbeH22Wn2PNLSMFQetc5TpKptPHlPJTl/s1ko/sMXG78/TtuECX75vsDIvnObRYurMOrzio1hkj88iJHzktr3CbbZ9qqtYAAP0Q64wYmgIhjo2z5H/G+k8aXs6bLGiQfmmk4YPGCpuBxqzqoxFXN7bwnfGKLY9GYFz5ISsKOhgChztBtVzf9RAS1WxAWCdwatroD1E/7C0wtIRZ0tzd1Vvk5TiwvxqxOTnNcug4mG9ejJomy49knr/XDpsfw9laRrO3AH7NAnvhgKb4/kIj48kWdrNr1LzipN+3hZNXcRRwJOAk1hQwDawRwQNhAHGoNK3xX5wCGOxyNrkcetDS3V5iJzJvMBFHs35bppF60RX+81ya63lVa6AwwuEgIVZD+uN91Jt+VxUX8dJRlqZ6ke5c7BynLGWlbOsXpC8lVoaFvnCiv9oxCqwtr4OFIgZNi4i9uDbnfOPQRRlxAqlUAHwUJ3DT5pKSmABhmq20EgNEmEh/6Rnh X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(13023025)(13018025)(13024025)(13015025)(13017025)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:BY2PR0301MB1622; BCL:0; PCL:0; RULEID:(400006); SRVR:BY2PR0301MB1622; X-Forefront-PRVS: 0105DAA385 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR0301MB1622; 23:BncWYa6hUBRYoXTzNA4IXsDVMwoTwBg5nrkmmCI?= =?us-ascii?Q?4PGnkEGnWCS6jbDtD7nGWXJgT2IJzqXTXqgXVG9VgfG4R3P6dHTHHf8N6LNu?= =?us-ascii?Q?yzP355TmzA4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ascii?Q?zOpSGx9M4C8WvzwlUM/Dd4Ff8HeFTyZ1c1JxfeNbkarWMHlhDL1vuGApdCHs?= =?us-ascii?Q?b3C1Nuo1jrQo9vEv6HI55sr2ad5vTSmSUs9usfcDgo2Th675+XiNkLVn4XkL?= =?us-ascii?Q?bw3v2NLWpjD/99DQAhiOkCWSpGULL6Hej2lAiQdGohXMqOgSCMiwlOv0Aqsq?= =?us-ascii?Q?frSQkm8VfC4mgp/LLN02Hly/DTudOpFCJZf9x?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB1622; 6:kq7ejrZlrp04f4tsd6T0AAaEM0P/Hrwc76n9pZgS1mHf8el64UThu9Y8th+QROloFzM/+R4Cvd2HeB6Xa7OEi0rG928onWxodL4cMaAmOVbXsL9J+qGveKjQixAjv3IAx98yfS4AvDC+pbQhmnCTrPHzLbQKaDYpuyi7C/TWBP27heeu3i+1dnMB/DS9g/9VzwMSP1PwSKg5HN4kx9E0Ls4SZRwIJ9iWRyuUklvDSw4TmjG1TggwnxupGwvEAxLE0h05+Yu05A6BnmlX7WUwEGS/c/C+UA2cQerAWlVCW6dLXcGmDPeBAJwtS3VEjgrW; 5:xOVm9/Qk2j0d4NHhn1wmCQP1zHC2UAW+LP4wfyduI7XfGbx20VmJGu1gpnJhv8YUKr+4E8PPc/aXgHDPU3OkLlF/J1qn9wePAki1jTAN3qFCtTDCkSpVNaNNZqdTwENVfWkVYZs36bKkb6iEB20UvbmYq1+84YNdda9Z5TtdNV28TTpkL+1YKW6JZddnHoeS; 24:fEFftz1oVU+zFusRj8tjP+yvQlBuwnN8lDwJWlwg7j+/DECXQhIsqfGJd+p8l5kSxgUnPv53B7XVAKrhjfBgTFkW/WoUWtD3iALvQDA3V8Y= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB1622; 7:+JDZOilMyPbyUP1tLCB52ky0TzllJsj/y4/ZDswP/2VhwQDtW2ouKquh2+42Na5SCi49seE58UioqT95OXfCfyyXDKVnUNW/QO9tqz9Uk/fKNQMLad7D9v1lhg0ozxiPgEK8apqPim61JbKcHdqnw2X5TTJ4Ihu42wm3nqE5yC2Egr/uIufhvN+dG8ipVJt3UybNuHiB6838vNFw9E8qd2DjpuF0NEnnWHdYPsgxZRgojTkRGsp0bBvv1sC4zIX7MPO7gqO+5QeRxqRb5Bf8jnCp9xDug3hwCPuBRl5LkaBXs56fKMeR6LStClPMi4TUTnHiSSwln00zQ8B4DYd2YGzuawTWTJq2a6Itq1ECO2g= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2016 12:00:01.7174 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0301MB1622 Subject: [dpdk-dev] [PATCH v5 20/21] ether: introduce ethernet dev probe remove X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Oct 2016 12:00:04 -0000 From: Jan Viktorin Signed-off-by: Jan Viktorin Signed-off-by: Shreyansh Jain Signed-off-by: Hemant Agrawal --- lib/librte_ether/rte_ethdev.c | 148 +++++++++++++++++++++++++++++++++++++++++- lib/librte_ether/rte_ethdev.h | 31 +++++++++ 2 files changed, 177 insertions(+), 2 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index ba9ae1e..78b3fb8 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -325,6 +325,101 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev) } int +rte_eth_dev_soc_probe(struct rte_soc_driver *soc_drv, + struct rte_soc_device *soc_dev) +{ + struct eth_driver *eth_drv; + struct rte_eth_dev *eth_dev; + char ethdev_name[RTE_ETH_NAME_MAX_LEN]; + + int diag; + + eth_drv = container_of(soc_drv, struct eth_driver, soc_drv); + + rte_eal_soc_device_name(&soc_dev->addr, ethdev_name, + sizeof(ethdev_name)); + + eth_dev = rte_eth_dev_allocate(ethdev_name); + if (eth_dev == NULL) + return -ENOMEM; + + if (rte_eal_process_type() == RTE_PROC_PRIMARY) { + eth_dev->data->dev_private = rte_zmalloc( + "ethdev private structure", + eth_drv->dev_private_size, + RTE_CACHE_LINE_SIZE); + if (eth_dev->data->dev_private == NULL) + rte_panic("Cannot allocate memzone for private port " + "data\n"); + } + eth_dev->soc_dev = soc_dev; + eth_dev->driver = eth_drv; + eth_dev->data->rx_mbuf_alloc_failed = 0; + + /* init user callbacks */ + TAILQ_INIT(&(eth_dev->link_intr_cbs)); + + /* + * Set the default MTU. + */ + eth_dev->data->mtu = ETHER_MTU; + + /* Invoke PMD device initialization function */ + diag = (*eth_drv->eth_dev_init)(eth_dev); + if (diag == 0) + return 0; + + RTE_PMD_DEBUG_TRACE("driver %s: eth_dev_init(%s) failed\n", + soc_drv->driver.name, + soc_dev->addr.name); + if (rte_eal_process_type() == RTE_PROC_PRIMARY) + rte_free(eth_dev->data->dev_private); + rte_eth_dev_release_port(eth_dev); + return diag; +} + +int +rte_eth_dev_soc_remove(struct rte_soc_device *soc_dev) +{ + const struct eth_driver *eth_drv; + struct rte_eth_dev *eth_dev; + char ethdev_name[RTE_ETH_NAME_MAX_LEN]; + int ret; + + if (soc_dev == NULL) + return -EINVAL; + + rte_eal_soc_device_name(&soc_dev->addr, ethdev_name, + sizeof(ethdev_name)); + + eth_dev = rte_eth_dev_allocated(ethdev_name); + if (eth_dev == NULL) + return -ENODEV; + + eth_drv = container_of(soc_dev->driver, struct eth_driver, soc_drv); + + /* Invoke PMD device uninit function */ + if (*eth_drv->eth_dev_uninit) { + ret = (*eth_drv->eth_dev_uninit)(eth_dev); + if (ret) + return ret; + } + + /* free ether device */ + rte_eth_dev_release_port(eth_dev); + + if (rte_eal_process_type() == RTE_PROC_PRIMARY) + rte_free(eth_dev->data->dev_private); + + eth_dev->soc_dev = NULL; + eth_dev->driver = NULL; + eth_dev->data = NULL; + + return 0; +} + + +int rte_eth_dev_is_valid_port(uint8_t port_id) { if (port_id >= RTE_MAX_ETHPORTS || @@ -1557,6 +1652,7 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info) RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get); (*dev->dev_ops->dev_infos_get)(dev, dev_info); dev_info->pci_dev = dev->pci_dev; + dev_info->soc_dev = dev->soc_dev; dev_info->driver_name = dev->data->drv_name; dev_info->nb_rx_queues = dev->data->nb_rx_queues; dev_info->nb_tx_queues = dev->data->nb_tx_queues; @@ -2534,8 +2630,15 @@ _rte_eth_dev_callback_process(struct rte_eth_dev *dev, static inline struct rte_intr_handle *eth_dev_get_intr_handle(struct rte_eth_dev *dev) { - if (dev->pci_dev) + if (dev->pci_dev) { + RTE_ASSERT(dev->soc_dev == NULL); return &dev->pci_dev->intr_handle; + } + + if (dev->soc_dev) { + RTE_ASSERT(dev->pci_dev == NULL); + return &dev->soc_dev->intr_handle; + } RTE_ASSERT(0); return NULL; @@ -2572,6 +2675,23 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data) return 0; } +static inline +const char *eth_dev_get_driver_name(const struct rte_eth_dev *dev) +{ + if (dev->pci_dev) { + RTE_ASSERT(dev->soc_dev == NULL); + return dev->driver->pci_drv.driver.name; + } + + if (dev->soc_dev) { + RTE_ASSERT(dev->pci_dev == NULL); + return dev->driver->soc_drv.driver.name; + } + + RTE_ASSERT(0); + return NULL; +} + const struct rte_memzone * rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, uint16_t queue_id, size_t size, unsigned align, @@ -2579,9 +2699,11 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, { char z_name[RTE_MEMZONE_NAMESIZE]; const struct rte_memzone *mz; + const char *drv_name; + drv_name = eth_dev_get_driver_name(dev); snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d", - dev->driver->pci_drv.driver.name, ring_name, + drv_name, ring_name, dev->data->port_id, queue_id); mz = rte_memzone_lookup(z_name); @@ -3228,6 +3350,28 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_de eth_dev->data->drv_name = pci_dev->driver->driver.name; } +void +rte_eth_copy_soc_info(struct rte_eth_dev *eth_dev, + struct rte_soc_device *soc_dev) +{ + if ((eth_dev == NULL) || (soc_dev == NULL)) { + RTE_PMD_DEBUG_TRACE("NULL pointer eth_dev=%p soc_dev=%p\n", + eth_dev, soc_dev); + return; + } + + RTE_ASSERT(eth_dev->soc_dev != NULL); + + eth_dev->data->dev_flags = 0; + if (soc_dev->driver->drv_flags & RTE_SOC_DRV_INTR_LSC) + eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC; + if (soc_dev->driver->drv_flags & RTE_SOC_DRV_DETACHABLE) + eth_dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE; + + eth_dev->data->numa_node = soc_dev->device.numa_node; + eth_dev->data->drv_name = soc_dev->driver->driver.name; +} + int rte_eth_dev_l2_tunnel_eth_type_conf(uint8_t port_id, struct rte_eth_l2_tunnel_conf *l2_tunnel) diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index f893fe0..ff7958f 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -180,6 +180,7 @@ extern "C" { #include #include #include +#include #include #include #include "rte_ether.h" @@ -877,6 +878,7 @@ struct rte_eth_conf { */ struct rte_eth_dev_info { struct rte_pci_device *pci_dev; /**< Device PCI information. */ + struct rte_soc_device *soc_dev; /**< Device SoC information. */ const char *driver_name; /**< Device Driver name. */ unsigned int if_index; /**< Index to bound host interface, or 0 if none. Use if_indextoname() to translate into an interface name. */ @@ -1626,6 +1628,7 @@ struct rte_eth_dev { const struct eth_driver *driver;/**< Driver for this device */ const struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */ struct rte_pci_device *pci_dev; /**< PCI info. supplied by probing */ + struct rte_soc_device *soc_dev; /**< SoC info. supplied by probing */ /** User application callbacks for NIC interrupts */ struct rte_eth_dev_cb_list link_intr_cbs; /** @@ -1860,6 +1863,7 @@ typedef int (*eth_dev_uninit_t)(struct rte_eth_dev *eth_dev); */ struct eth_driver { struct rte_pci_driver pci_drv; /**< The PMD is also a PCI driver. */ + struct rte_soc_driver soc_drv; /**< The PMD is also a SoC driver. */ eth_dev_init_t eth_dev_init; /**< Device init function. */ eth_dev_uninit_t eth_dev_uninit; /**< Device uninit function. */ unsigned int dev_private_size; /**< Size of device private data. */ @@ -4262,6 +4266,20 @@ void rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_dev); /** + * Copy SoC device info to the Ethernet device data. + * + * @param eth_dev + * The *eth_dev* pointer is the address of the *rte_eth_dev* structure. + * @param soc_dev + * The *soc_dev* pointer is the address of the *rte_soc_device* structure. + * + * @return + * - 0 on success, negative on error + */ +void rte_eth_copy_soc_info(struct rte_eth_dev *eth_dev, + struct rte_soc_device *soc_dev); + +/** * Create memzone for HW rings. * malloc can't be used as the physical address is needed. * If the memzone is already created, then this function returns a ptr @@ -4376,6 +4394,19 @@ int rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv, */ int rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev); +/** + * Wrapper for use by SoC drivers as a .devinit function to attach to a ethdev + * interface. + */ +int rte_eth_dev_soc_probe(struct rte_soc_driver *soc_drv, + struct rte_soc_device *soc_dev); + +/** + * Wrapper for use by SoC drivers as a .devuninit function to detach a ethdev + * interface. + */ +int rte_eth_dev_soc_remove(struct rte_soc_device *soc_dev); + #ifdef __cplusplus } #endif -- 2.7.4