From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0077.outbound.protection.outlook.com [104.47.41.77]) by dpdk.org (Postfix) with ESMTP id 49B75BB82 for ; Fri, 28 Oct 2016 14:31:20 +0200 (CEST) Received: from BN3PR0301CA0041.namprd03.prod.outlook.com (10.160.180.179) by BLUPR0301MB1617.namprd03.prod.outlook.com (10.162.214.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.679.12; Fri, 28 Oct 2016 12:31:19 +0000 Received: from BY2FFO11FD052.protection.gbl (2a01:111:f400:7c0c::199) by BN3PR0301CA0041.outlook.office365.com (2a01:111:e400:4000::51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.679.12 via Frontend Transport; Fri, 28 Oct 2016 12:31:19 +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 BY2FFO11FD052.mail.protection.outlook.com (10.1.15.189) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.679.5 via Frontend Transport; Fri, 28 Oct 2016 12:31:18 +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 u9SCPEMW019399; Fri, 28 Oct 2016 05:31:15 -0700 From: Shreyansh Jain To: Date: Fri, 28 Oct 2016 17:56:37 +0530 Message-ID: <1477657598-826-21-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477657598-826-1-git-send-email-shreyansh.jain@nxp.com> References: <1477581467-12588-1-git-send-email-shreyansh.jain@nxp.com> <1477657598-826-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131221314788088588; (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)(1110001)(1109001)(339900001)(199003)(189002)(6916009)(47776003)(5660300001)(68736007)(110136003)(2950100002)(11100500001)(2906002)(5003940100001)(6666003)(92566002)(4326007)(97736004)(87936001)(626004)(189998001)(85426001)(356003)(586003)(76176999)(50986999)(305945005)(8936002)(36756003)(8666005)(7846002)(50226002)(81166006)(8676002)(104016004)(33646002)(77096005)(81156014)(5890100001)(229853001)(2351001)(50466002)(48376002)(19580405001)(19580395003)(106466001)(105606002)(86362001)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0301MB1617; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD052; 1:7N9TWQVz2hnDQdYv+Wt1lvu8arPXtOf50dBPnTvNx58KzC0JoKRbTztlBMCoIKaqYs1tGOEVpCZRyEF5tJRWPLN9iB05yUQKxrxbaPeXcsM4I8RjZXD0UfmrHoXR+vSZo26AJUH2sNv8QXKLNFeVkLC7fcQXEbnjX0MAoRXSHsXd6OEISgvKwNb82AmGFF3BcCGr1VEqC6+CrNcbhSqVH/eAVAZl5W1JpttXYJAp3oVVT1YlmpiMCnDZFu5WGOmHWLf9Rh5RnTakmyEPtv5YVhF/C4R8A97vMOqeVkhtjguR5cXh2GHCLzg6rvvQpLui8SLh3lPh+Yx68wm3GexxytcsX5hSN+spLbk9qdDldqvuwBPbfP1OSNolvc4F5NHzysNTnZf3f+JTsDxKxsOcWfq6UT/yxpnw+lQG8d7yBEffCeaRX5eY+yel+87pS3X4tDQ/WIlAsvPhKJMnXC8H61EvymVo+H80GKyZkyWpYmfq3GLuaAoaEGoClmWEy06QJroKea/qLCzoF1eo+gaXDwkKlC/5if5Ha4Y3FW8CO+SIJ9F+t/OUjPvTSBuAw17bS1aqjzp9Z3QSKSxbsJJd0yfipV6Kvn8kquKa6VFlUtc0tJvkJJ19bewej7VORIfrvTL8w+JqowUt0io/4ien8jsOY6JkstHN4peSZ17ha7mkarDzUL4hbtLPQSftT4JmnkFQQvObwWjODtdptF0J2sYxIeMfDI2+Mwja2PBuPwA= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: e55741ad-a736-498d-f9ad-08d3ff2e515b X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB1617; 2:5veld7dYzl2GQk/RNrrhWjIN+KjS2YeIh9iRyvuj+C8GbYB1P2b1m+MI09uVER6JjB5H336+mG7xaXi3/lf2FSR3/Wp+ApLYhKyaPpkGnYx4ZrM6cDnd4DZWKnA6LL/VzoC1/IVfhncqJ1vuk0su39EJwAjC+L9vNi5BcyAMRmE+EELbj7Lqs4MF9jnYZ0alvvrh3nYIbpiqWeMw5XCuBA==; 3:bJmrfE1Ih9GHfSfUdk/gLwvdKflfr9uP/TqqU18Q7OD2N2IqpAyvrLaA4ei0LJkOFqkwXHVdsEKgjzNOyq3Z2372k1irccz7X0YHb+VDSqJ1bdtGm222Utm9o60XRqb1EPfqmhgSzAWGogrSA73PbIPEbMZ1tu+cT4RNpNygz/vkLM7HaFA+exFAn0FjorE7Plb6sBgIPDQURLcUa8oVk4igJD7lD/AuARtTERzjccgbwV9DN/yMnnMh7liFNjI5 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0301MB1617; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB1617; 25:vPSx8H3jItM7ALB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479YHm7fl03caP66e/0EvtaJDyOnCNedtoWIBhxavVlQZHwYPZw==; 4:5HrjRS7u/Uf6HFgW0yjrpjs5eWPyQz9ofzF6BascUsCJYN+TkIZGPqdtxZQSzoMqa6/ClvJPuSX6vMqc+KlyN7qmjbqqqQ1sOaq4jGEll8zHKwJSPZCLhsFfW20nHvdtWgJpDZYwesqa2pkYgPvBrABZ+tvE4izTlX+KmnC4i72oo/TNFG8BVxDTWtZWsMpg4KAQ6DJx5pf++oHBdtM8lWedjfWFIZg578ba5zU0YM6ZbwuQ4MWLDzjxoIOi4Kf5Sb/FocCMfzZL/cd/iIbZ60vQtnQgNIqKdCpvLb0zoZsf6NiSdHqf/RWi+2OQY9NkE71N1bd6/XlHbWZ5sL9DeUr/XznZJV3Mw0H/4gYTjRV5oRa7SxK/EN/wNDWDt0CxFGREzNMU6WUqtEedCXDe2KHmfNQhHyO+TQjzpLExPQVnkyXyEjjJUvTOpgxTB7SP/hNqMrfI0czju8wgU1jSDDX0WcNw7YBXxiueaamCIEuatXzcoFxgtUG/Rj23SCh/6o4lvreNrxl7dH8tMZMJjhTFbRjRiucPVPUiw5JLqri5vlHumip03PW2RgmIulIw 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)(13017025)(13018025)(13024025)(13023025)(13015025)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:BLUPR0301MB1617; BCL:0; PCL:0; RULEID:(400006); SRVR:BLUPR0301MB1617; X-Forefront-PRVS: 0109D382B0 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0301MB1617; 23:5AFa9e1D15j7bFTjTB/5Iv4rHPZPJHsujbGHb6G?= =?us-ascii?Q?0RbMSP/GjsgPHUm5ctHPGMFvZbvab0cKCAvuDkJ8XUvkiWYk/fWImyB5vuwg?= =?us-ascii?Q?rO+v9Za3whBF5QcfGyW6e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?= =?us-ascii?Q?3IujyEYvndXdeioKmxziQu00HqSyBb7aQeKJGaooL8aB0Fpm7c7mGm4dJAhl?= =?us-ascii?Q?u084lIalzzkDuCMTLep+3Vri/xbjxxbz+PQh5WT+UDFQyT3oFDJ3/kcFurqE?= =?us-ascii?Q?rLy8aaZ9yohFaDrR1KXQEkdQ42hR1TY6sZA8KTHbK4ko2ASocM/oBHUynAuN?= =?us-ascii?Q?zuUCrel+0MrsuyLcFBXkP7NLZamH0LSs5xP7U3v0RCOkvUX4zRUcV216DFk7?= =?us-ascii?Q?XvLG5ssKFZIi23IE+kns=3D?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB1617; 6:7+vQyFB5NcfI6dNAR2FOgKhDZQHJcERa8Bmp8fLlTLSYa0dXNpecE1sfrm5OYwow0iUv3nRh0mXpohFdBL2aCkqVOu++JQLiBTmEzvdRBG/m9J5bTHYt2orvBjgCCo4xeujHGgjkzaWaBPApYcSOfXP1vOkjfm+HTNQfIp1AnvG8PK4tDzqpBwy3NMvNHowLKYz2rKcVmru2KqGV9q4SIXtyyll8IyCSGSxILB62C15CfNCgakuA7i6GZCSi8e5eqb8S9Vax3qMxmWIFVFVw5T+KRMiVBHuZ9bXEE5RiNx5gz41OnQ/0gfiBCjHx8axh; 5:GMm+YGTTmPptcxxbbJEi/MADPWKDvht1rY+clm4V/tQSForIazJvHQM4L8cXYbe3dOW+KU3WI1QtB0l8ik7J+7IkmvOTQQIodgPemd5phNmhgALpb0gumt3BfqewLP3QUxMMVMC5E5XrukuuA4luruYnz0A5lQclXuu3BMXuegWKSeX5TdL8udfRe8nFH3jQ; 24:lohr7SW+KAsm4B12Ot1LP7jUwRNbaS+7cjAtYLILb3/8jt/eoAkJXPvIRih/G0YBEDKuaWqE+DlnCwUjumPZL+nhxbXDSQoPhldsOBFn5lI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB1617; 7:NNCpRBSQmDHKLVLdtZHzMHKeerNQAd3GSkVwfL+7pRP3AU36Lu/vVuMcSIzeTEDtRyAwyndYh5y9+wBCFJHuWhoU6SuIOE44qkX0dRL8QhaLJeT3EJVr0VZ2gvQMqH4ZjBCPsUgrBZgkwTDG3o+Rllyew2Utpl2vWbgBD0m8Tr48NPsJmFKN1vqXj4V9wd5m7z3JOE+aVKmSU25XtDarWpAGd+xRq0tffUazlXOH3e2UlLDb2DDkgI8cMr/oCTfNK4EuBCg4HJ18YEj/7fjeD1YJt3vmO9NvbcMbDZTVbZJwuNcVuK8wdPNVGWnM3RWrmC7PYSeuUaekTrSrdCBMl0UekUExjRGfQkKZt5OqmqA= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2016 12:31:18.6060 (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: BLUPR0301MB1617 Cc: Shreyansh Jain , thomas.monjalon@6wind.com, viktorin@rehivetech.com Subject: [dpdk-dev] [PATCH v7 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: Fri, 28 Oct 2016 12:31:21 -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 4c61246..972e916 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; @@ -2535,8 +2631,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; @@ -2573,6 +2676,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, @@ -2580,9 +2700,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); @@ -3229,6 +3351,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