From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0049.outbound.protection.outlook.com [104.47.33.49]) by dpdk.org (Postfix) with ESMTP id 02A7A8DA4 for ; Sat, 15 Oct 2016 15:45:04 +0200 (CEST) Received: from CY1PR03CA0010.namprd03.prod.outlook.com (10.174.128.20) by BY2PR03MB331.namprd03.prod.outlook.com (10.141.139.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.587.9; Sat, 15 Oct 2016 13:45:01 +0000 Received: from BN1AFFO11OLC001.protection.gbl (2a01:111:f400:7c10::185) by CY1PR03CA0010.outlook.office365.com (2603:10b6:600::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.12 via Frontend Transport; Sat, 15 Oct 2016 13:45:01 +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 BN1AFFO11OLC001.mail.protection.outlook.com (10.58.53.72) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.669.7 via Frontend Transport; Sat, 15 Oct 2016 13:45:00 +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 u9FDhhgW021870; Sat, 15 Oct 2016 06:44:57 -0700 From: Shreyansh Jain To: CC: , , , Shreyansh Jain , Hemant Agrawal Date: Sat, 15 Oct 2016 19:15:07 +0530 Message-ID: <1476539108-13170-17-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1476539108-13170-1-git-send-email-shreyansh.jain@nxp.com> References: <1473410639-10367-1-git-send-email-shreyansh.jain@nxp.com> <1476539108-13170-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131210127003417913; (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)(189002)(199003)(11100500001)(19580395003)(229853001)(6666003)(8676002)(104016004)(97736004)(48376002)(19580405001)(50466002)(81166006)(5003940100001)(626004)(5890100001)(8936002)(76176999)(5660300001)(68736007)(87936001)(85426001)(77096005)(50986999)(50226002)(36756003)(8666005)(86362001)(356003)(586003)(7846002)(110136003)(81156014)(2950100002)(33646002)(305945005)(105606002)(106466001)(47776003)(92566002)(6916009)(2906002)(2351001)(4326007)(189998001)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR03MB331; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11OLC001; 1:kdU/AVTx/y858OM6EgU3JSiPSOJTv85dqYjhuCVASvjlYxFkNnNbUtj89cPoOdYruTP/S6o0IHnPD02pPBgCMYZuumf0e8JalGAk3AvvxAnAjQWWrRwfhPo2ePxy/PhAt3mTi8DvGjwvT5T2WwNzpXDPgs3T9wM1CURrCE/l+DLxW3rtdBA2jU9cEgbe3TLPOySjV1En0dVrG1bjy8lMJqk7gtRjsg/oGrm2Ed/J/X8vtv5WfnWp5s7MxKbT6Www997j2llvg31jCHnCItQtUJ9w19iTiCDdwrBfILBWFMQBFEmmPA0ODHEkPIUB5BcQQs48XfuEZV6MqgRILOAt5ZITe/MDTaFL6Nz7I0xPRJtFauXD14YIgJm6q+y1A/irkXG9DROgvCOeConKzfWoE0Bm8L6V1bUTn1NIa0OZ6PHOVLZuizPVwr2Uji+pTAV9G0WEC0E+s/2/hOyH8gsAU5vGr79PcAFhvThB3PyWb+6LtSUeae9TiRgsKE9H7UBP2HphLIHdsQLmX1M7p/Azug3oLDgYu22KBvVSf4XdZ/cu2oY2PSuptYToOD3Tz5t7vksvzLt+sYrvyx/y5UpAS8YcMdouaVcgHvB0W7Jv5V7rUhGe6v5eLeb35WofokzkiTWYCE+XHciUFBxRLeZxM6jZeij9k51tR6bsi2oiUpuuxlGUdN4bWNmfeiZNbBaMDeO4EDsmJFZBh1D5RnjkfOBW31NtLG+hGxepfdPK9Zs= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 0108e967-c4a4-4d37-9bdc-08d3f501756d X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB331; 2:Zbmjqx9/VUDIpWs+T6r9GOmUvonvGR89yc0F02fxyvbMKDhYgX8j0F4udELL1QRm+R8iC82cGX6rMF5H4skiuc7o6NBg4Xw6XajEXfkfjwOV84Idjng4sdxSBHOPIfhyp2bA82r9762x9BXXL6bfnFrNWPKp2iA2CRYtD0BI/wFkrRVcJsYI3xuEoLWcVcQL; 3:SoZ21OwdTz0jE/N1/7SFbBHfEWVFFvNSXg7kBAuyPCkwipe1CGn5LWOL5mlEfoAm3aWBo6ca8HUuTcZYGYGQok4zfjNBwItJu1yzsqg+g9l9HMeqH33koqX+089gTNhRxLBvpVOXk3XcGEsywsmz7hj59LDt+vtrlytq4Q7pdUWaIxikFQFbIU3mc2XhPtfZs3kZ09iO//N8osCLkVG/Fw4gyonyUAZ1BWpqJuwxnNc= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB331; X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB331; 25:b68GGI+kFbQLCScqz7RyFxy251KhS7D4Vv8fr98p78g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=; 4:JBiZ+4ELj4oGYZmdSPB1EgOW1MFDdcaRoOWGHDLTQLHNPmNfASaio69lyHnB9sl6KuXlz8AcWxkaBXu/Fo++wms6QUvXFIpg7I0Gt5wBIFXU2xIMrpCTQYK9hPEQKfomw64KN9y9NbL/zz+b1uA8S12fdvAymRFEnIALid5QQqSB1h2IWuIPu9IJmBz3vVM3BB97QS3i66/+2XmlLOk0aMYlRft7c1/cWnpr0Ymk30xma+qzLNmDubZTLaeDMuRnzTz22PlZRnAWBVgvDjgn7JgHx7ARfbkkmhcVOHWtutEGF8sjI5msD7XCdiD65pOhloupkoAk8w6G9oP37wC5qTqvKfLlHF1WDDaT3jUmhEQ219sl2bFmVDc85ZegGYdLrO8cPiGHVkYAO6Hr2NXrPimuHjHuNqJBOzbp4mhfC5gRDkaU3+SS6ZlRVdo6YlAf2YxxOfAbaoy8pJ36dGL100CUPHLBGer520JTmWyocDEZvYAXQ5sr9b+43+T9DE9gqmMSilHNVGnGK1TwHiJO6zfO6ShiN16koGshQRBZSmo= 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)(5005006)(13017025)(13015025)(8121501046)(13018025)(13024025)(3002001)(10201501046)(6055026); SRVR:BY2PR03MB331; BCL:0; PCL:0; RULEID:(400006); SRVR:BY2PR03MB331; X-Forefront-PRVS: 00963989E5 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR03MB331; 23:a/IvmCf/p/khpfEB6206WCEZ/bRyoF0GIlNXdSCbXs?= =?us-ascii?Q?t0KAuw4E07sCfrf2l7CJ5A870NCFmjYooDfP4N5YwhGNDn+Z+lpCifUW6w7N?= =?us-ascii?Q?J3XXNCaWKLkIf+hf7I0WAXAhfjDrUMdvpmQWiXyCr8HcIFubmU356Z/3Jvrs?= =?us-ascii?Q?7/646qqOifqkGccRmmzdlDSxGylfKUmXPygQ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3WP/zWf0tJtLRbmd9MyQjVx2VX4fqEm8WrqYZe8dNyMO35Ihrw2KbfNszqYuLdZ/qSuJgjYiHunixg36BUnBXvsUIBFJcsW7AWyGJA9pk1VH8FkX0kbjM9goyJgIkQ== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2016 13:45:00.1545 (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: BY2PR03MB331 Subject: [dpdk-dev] [PATCH v4 16/17] 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: Sat, 15 Oct 2016 13:45:06 -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