From patchwork Thu Oct 27 15:17:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shreyansh Jain X-Patchwork-Id: 16835 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id C2F752E41; Thu, 27 Oct 2016 17:18:25 +0200 (CEST) Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0075.outbound.protection.outlook.com [104.47.34.75]) by dpdk.org (Postfix) with ESMTP id 2D93EBC20 for ; Thu, 27 Oct 2016 17:18:17 +0200 (CEST) Received: from CY1PR03CA0035.namprd03.prod.outlook.com (10.174.128.45) by SN1PR0301MB1629.namprd03.prod.outlook.com (10.162.130.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.679.12; Thu, 27 Oct 2016 15:18:15 +0000 Received: from BL2FFO11FD028.protection.gbl (2a01:111:f400:7c09::106) by CY1PR03CA0035.outlook.office365.com (2603:10b6:600::45) 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; Thu, 27 Oct 2016 15:18:15 +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 BL2FFO11FD028.mail.protection.outlook.com (10.173.161.107) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.679.5 via Frontend Transport; Thu, 27 Oct 2016 15:18:14 +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 u9RFGIfo027183; Thu, 27 Oct 2016 08:18:12 -0700 From: Shreyansh Jain To: Date: Thu, 27 Oct 2016 20:47:46 +0530 Message-ID: <1477581467-12588-21-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477581467-12588-1-git-send-email-shreyansh.jain@nxp.com> References: <1477310380-17944-1-git-send-email-shreyansh.jain@nxp.com> <1477581467-12588-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131220550950970101; (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)(50466002)(19580405001)(48376002)(87936001)(19580395003)(2906002)(47776003)(106466001)(8676002)(2950100002)(6916009)(92566002)(85426001)(77096005)(2351001)(105606002)(229853001)(5890100001)(626004)(5660300001)(36756003)(6666003)(110136003)(33646002)(68736007)(11100500001)(81156014)(97736004)(86362001)(104016004)(305945005)(356003)(8936002)(81166006)(8666005)(4326007)(50226002)(7846002)(76176999)(189998001)(586003)(5003940100001)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR0301MB1629; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD028; 1:s7jwXoL/uuqFe3FmTcKgdL3yVrmTuPQ+n0hAQ6u28QMEvrs2ZrT6i2qMcS5aQdI1DXVfJO7ju+UOE2jzDYB/XV7JKd+LoESVeUDg+5dPRJXaNMX380uJFFBou7Ec4jhWK7nQlgF2QYZ2Y26uVSNXoMcH2DRfKqdcbdNnlSNmzorC9IMNC78EkojRoTEbBHamluOd5H6oegprCJuggSXPlVrAKBbFD1qhNk0pBO5AoGyzK1mvgftu1gCbttZG+sOuSaIh5xiqguQ+IN9v1HpNvhP3uU4SI9JnHkQFBhMsHIxSgY+WzYx7zP5T2VXp+VtyOZSmlqRM3ZosQBZ/n2LZoo3OBCxPGYBhHFKBQhTSLAN1aoQ8LKnqbE2jYPPRUDPPIDCYNgdjKQrMXwsHA65AcOYiT8j76Cn2XEjuAdwAauiVnrkmCamqMfeLy8BVwVc5bxXmXJa7QlhQJW0dSx9C8DLbZNO+RZKFMldqjoqX68+ezcuEOpQsDPRgE9HZGtlJs26Ul8kZX1P9lkyr00RYx6yqeetcdsWKvvTQl1xc3wmCHODZbxofXocPQwd5yrfo+lPYDWtwelIlZk+aSc11RKepQIFk92KVSBfjnutZe730VVB9GsFy/cMNBJUQyko26m4V/M/2yB+MMWkttrQrdXYFzpm/GkxEJz5wkJlzg1LukFjws9DqraSs9Dv175i7gK9P3JF+2JQMfQD8n/MtZZ30eoE9aleFe2qxM+vSllI= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 51263ee9-f5d9-4561-768c-08d3fe7c790b X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB1629; 2:xcsKPFwn38WNMuvjSegh5tEm42Ks1IZGQud0uqw5yrndU2JkZ2Q/18EkmKpLS+tYrAJL9HRuR38XxpJQdI49+OIOIIYBi2c3Vndaa8hj37JlDq/3UGtXtgW/TQE4sUzJn3qLBWtJmuS1pxuXtrUec2jR93IQ6Gpidtp7/2m1WGWLed+BLdHd+TE1tDvXDZKXz/FsWPtSP5lxjQk6RX96ug==; 3:eHcC/9aF+GELULUs9IY11oBTu3Tc8ry1sUUIIPL3HGuBgx9r9bG6RPvHFhXZqmzHh8gTbJXQxMHMACb60XtHmCO5wJFGXjtkfpb2FSqNav7mX44Wy/YIT230ABqaNNMddtrHrkNnnp5NB143aEPjoMME7JTF38fEmZm3O1Wxl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NHBx4kzshzhYU1VsqC4EZkHnzPFj8ZQ1Me7vrJi8u5xpeFu/lYt9ITLVg+7lFcKL79DyR0VWxWcZHX+FBfDzCYeYo0u0GLtWSg7IKo61a8uEWXuA2yHKtaLHBAivqoRiAFhAWgvrIXfj7pXWXFj9EFZwvcZ3tmfbPSe72snVUSzUuyJinsWB/N+VWpJtWQ3cbBn18ccMgfzYFjyfxjL52VaqyqLXtBclHWJGjX4ZNAi2ltakdpucWZ7XLu2UX/hX67SNGaAYoYIn0qRAJaoVGNzXYS05tpzNmTXtNF7BzJnQovCu39l117fFu98luZcK/Kf9HsJN6OZvxpghgrD5oejKSes2Ccl3HV52x6pzcQTR7Pq7+xcrWERwlNJXcE3g+vE0lwoOOfrAp0EZ4PYE2y9YGrcHuszJTIgOE3kCviiIKsxK0taBLohfkOgsTLHpuk10HDBSFXl6/EUEk 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)(13024025)(13015025)(13017025)(13018025)(8121501046)(5005006)(3002001)(10201501046)(6055026); SRVR:SN1PR0301MB1629; BCL:0; PCL:0; RULEID:(400006); SRVR:SN1PR0301MB1629; X-Forefront-PRVS: 0108A997B2 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR0301MB1629; 23:CaIu/8NVpfURLQGBa7xlyNGztkjUXroG1V8BJNM?= =?us-ascii?Q?aVPS23yE0gfA/Sx14/1m9mSQ72bBYFFus7GwneYOuO0b0T5zT6BSW9yYfZhW?= =?us-ascii?Q?P1asE3pSHEblBtwl91FKv8V2CeAHA+aHaZmA1PQka0V3f8x2wWb+QhShX1Vt?= =?us-ascii?Q?cfz2gdaOwlnrXJh9WA0ZBu5cb3ad1j+hsNY998E+AJufb6Hbd36I3mSLt6ui?= =?us-ascii?Q?tXkr75czKtje7NFhbbrZ1RcRDo6r7DVt7y8Df7SAPUwSOg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LOa//OxjThIqXG2ZRcBlqrxXxsYTGsQmC9axFoMjC?= =?us-ascii?Q?OMz1K4yA3wniJind0zPlE/EsEmsV+dJbyDBHvuW0pD0QS0vY13KwSEi3XqWr?= =?us-ascii?Q?sUQUyptHaWGvOKkJVSfw=3D?= X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB1629; 6:TKoImNR6uFti/tv2WByPYHS8YUVl3EfnB/6MHQVAUC/rdm4OYzL3SGzCYA+FWrBhYrntAl1ieMR4YYJ8aeVe60vt7k1GvsAxsEiV4LdNoIpaNa7Osn6B2KAfiixh7vw51G80IoPVuOqeNJgrgM2/4s1xlOCYM0BlenNKg0K+DmnV5o9rAIGilry1GSoSieeR164Xqgdg+uh2BhL4h2MmN3ptlS6k8falsESG+QhN/gkDx1X4BQtipkN+13qu0IMcmH7TXD9W5XmKWmITud+Tt2stzsKwfSIQbfHtLJfEihB4C3JLciqAReA0D6lWradv; 5:PZC/77LRgjzTJidCOFcKbTRZ3yzZV8Ped8qam/eCygRuppFq6b0jsIm+u8Gz+wXacpoXqbhOqKrf6562qBDzNotb6j6OJzWG64g6QyQsTGCRaRP1ldpf7nIr74+LRk8Vfye4Tbx6MYjlCBHcWa/N5ys5hcsTVvQy2joJXHi8N8TMklXH/WcRAw58CzvIOoIN; 24:al9Y8foYJd4Q82G4h7U69/0eqYj9gbrY+f+MJzjKse0ZP1SB05ygg659dAOEHa7sE6uVjylEM3Ugk7XRCsrrDWWXIDpjXJS1Vj69TOmKUkw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB1629; 7:cClzt4BIdz12hfMYvrWYz60wRWsB8jM0OzGxZ6cgmmVtwbyKwTpj99DLicBQZMbse6x2A4Pxc5HpxJanZ/CjYNX0fFPq14yWLPGAEOey34rJTzakRTJBspiR0RITOle3lHz/hc/6d7Qi/S9wRsyRzUq3vMrypdqR/y50xhepgYKkf+IQr4QwZATBdr6ABBxz3CKjqcT+v6KXIe8BIMmsCzHFfVWjUOL+yK72zpMie7zyAp3Kuh8h5U9Q++mPMrKutE4nAWFxjXujuCJQKY4+0cViH2rlW1ta0urvtxtur2y395XAXreBhXiuu832vK+f5cPiWa/yn5NJtxLnp4oe22wCAEEZ28K8Xxv8/Dk8pVA= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2016 15:18:14.7850 (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: SN1PR0301MB1629 Cc: Shreyansh Jain , thomas.monjalon@6wind.com, viktorin@rehivetech.com Subject: [dpdk-dev] [PATCH v6 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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