[PATCH 00/38] Remove struct eth_driver
STALE3425d
104 messages,
11 authors,
2017-05-10 · page 1 of 2 · open the first message on its own page
This series is removing the PCI specific struct eth_driver from rte_ether. The
PCI drivers are changed to use the newly introduced header-only helpers
instead. Although the virtual drivers did not make use of the ethdev's driver
field they are converted to use the VDEV specific allocation helpers. The
motivation for this change is to properly embed a reference to the generic
rte_device in the ethdev.
The series is based on:
* http://dpdk.org/dev/patchwork/patch/20416/
* http://dpdk.org/dev/patchwork/patch/20417/
* my "Rework vdev probing to use rte_bus infrastructure" series
* http://dpdk.org/dev/patchwork/patch/21058/
If requested I can push a tree with all dependent patches.
Jan Blunck (38):
eal: add name field to generic device
eal: parse "driver" device argument before probing drivers
net/nfp: use library function for DMA zone reserve
net/vmxnet3: use library function for DMA zone reserve
ether: add allocation helper for virtual drivers
net/tap: use ethdev allocation helper for virtual devices
net/vhost: use ethdev allocation helper for virtual devices
net/virtio: use ethdev allocation helper for virtual devices
net/af_packet: use ethdev allocation helper for virtual devices
app/test: don't short-circuit null device creation
net/null: internalize eth_dev_null_create()
net/null: use ethdev allocation helper for virtual devices
net/bonding: make bonding API call through EAL on create/free
net/bonding: use ethdev allocation helper for virtual devices
ethdev: add PCI driver helpers
net/virtio: Don't use eth_driver
net/bnx2x: Don't use eth_driver
net/bnxt: Don't use eth_driver
net/cxgbe: Don't use eth_driver
net/em: Don't use eth_driver
net/igb: Don't use eth_driver
net/ena: Don't use eth_driver
net/enic: Don't use eth_driver
net/fm10k: Don't use eth_driver
net/i40e: Don't use eth_driver
net/i40evf: Don't use eth_driver
net/ixgbe: Don't use eth_driver
net/mlx: Don't reference eth_driver
net/nfp: Don't use eth_driver
net/qede: Don't use eth_driver
net/sfc: Don't use eth_driver
net/szedata2: Don't use eth_driver
net/thunderx: Don't use eth_driver
net/vmxnet3: Don't use eth_driver
ethdev: remove unused ethdev PCI probe/remove
ethdev: remove unused ethdev driver
ethdev: remove PCI specific helper from generic ethdev header
ethdev: don't include PCI header
drivers/net/af_packet/rte_eth_af_packet.c | 42 +++----
drivers/net/bnx2x/bnx2x_ethdev.c | 64 ++++++----
drivers/net/bnxt/bnxt_ethdev.c | 36 ++++--
drivers/net/bonding/rte_eth_bond_api.c | 171 ++++----------------------
drivers/net/bonding/rte_eth_bond_args.c | 2 +-
drivers/net/bonding/rte_eth_bond_pmd.c | 160 +++++++++++++++++++++++--
drivers/net/cxgbe/cxgbe_ethdev.c | 29 +++--
drivers/net/cxgbe/cxgbe_main.c | 2 +-
drivers/net/cxgbe/sge.c | 6 +-
drivers/net/e1000/em_ethdev.c | 30 +++--
drivers/net/e1000/igb_ethdev.c | 60 ++++++----
drivers/net/ena/ena_ethdev.c | 29 +++--
drivers/net/enic/enic_ethdev.c | 29 +++--
drivers/net/fm10k/fm10k_ethdev.c | 30 +++--
drivers/net/i40e/i40e_ethdev.c | 36 +++---
drivers/net/i40e/i40e_ethdev_vf.c | 31 +++--
drivers/net/i40e/i40e_fdir.c | 2 +-
drivers/net/ixgbe/ixgbe_ethdev.c | 66 +++++++----
drivers/net/mlx4/mlx4.c | 17 ++-
drivers/net/mlx5/mlx5.c | 19 ++-
drivers/net/nfp/nfp_net.c | 59 ++++-----
drivers/net/null/Makefile | 7 +-
drivers/net/null/rte_eth_null.c | 55 +++------
drivers/net/null/rte_eth_null.h | 40 -------
drivers/net/null/rte_pmd_null_version.map | 7 --
drivers/net/qede/qede_ethdev.c | 60 ++++++----
drivers/net/qede/qede_ethdev.h | 1 +
drivers/net/ring/rte_eth_ring.c | 1 -
drivers/net/sfc/sfc_ethdev.c | 34 ++++--
drivers/net/szedata2/rte_eth_szedata2.c | 29 +++--
drivers/net/tap/rte_eth_tap.c | 37 ++----
drivers/net/thunderx/nicvf_ethdev.c | 29 +++--
drivers/net/vhost/rte_eth_vhost.c | 54 ++++-----
drivers/net/virtio/virtio_ethdev.c | 34 ++++--
drivers/net/virtio/virtio_user_ethdev.c | 20 +---
drivers/net/vmxnet3/vmxnet3_ethdev.c | 30 +++--
drivers/net/vmxnet3/vmxnet3_rxtx.c | 30 +----
lib/librte_eal/bsdapp/eal/eal_pci.c | 3 +
lib/librte_eal/common/eal_common_dev.c | 3 +
lib/librte_eal/common/eal_common_vdev.c | 50 +++++++-
lib/librte_eal/common/include/rte_dev.h | 1 +
lib/librte_eal/common/include/rte_pci.h | 1 +
lib/librte_eal/linuxapp/eal/eal_pci.c | 3 +
lib/librte_ether/Makefile | 2 +
lib/librte_ether/rte_ethdev.c | 117 ------------------
lib/librte_ether/rte_ethdev.h | 105 +---------------
lib/librte_ether/rte_ethdev_pci.h | 191 ++++++++++++++++++++++++++++++
lib/librte_ether/rte_ethdev_vdev.h | 84 +++++++++++++
lib/librte_ether/rte_ether_version.map | 4 -
test/test/test_link_bonding_rssconf.c | 4 +-
50 files changed, 1065 insertions(+), 891 deletions(-)
delete mode 100644 drivers/net/null/rte_eth_null.h
create mode 100644 lib/librte_ether/rte_ethdev_pci.h
create mode 100644 lib/librte_ether/rte_ethdev_vdev.h
--
2.7.4
This adds a name field to the generic struct rte_device. The EAL is
checking for the name being populated when registering a device but
doesn't enforce global unique names as this is left to the bus
implementations.
Signed-off-by: Jan Blunck <redacted>
---
lib/librte_eal/bsdapp/eal/eal_pci.c | 3 +++
lib/librte_eal/common/eal_common_dev.c | 3 +++
lib/librte_eal/common/eal_common_vdev.c | 2 ++
lib/librte_eal/common/include/rte_dev.h | 1 +
lib/librte_eal/common/include/rte_pci.h | 1 +
lib/librte_eal/linuxapp/eal/eal_pci.c | 3 +++
6 files changed, 13 insertions(+)
diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 3a5c315..58cdb54 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c @@ -280,6 +280,9 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
/* FreeBSD has no NUMA support (yet) */
dev -> device . numa_node = 0 ;
+ rte_eal_pci_device_name ( & dev -> addr , dev -> name , sizeof ( dev -> name ));
+ dev -> device . name = dev -> name ;
+
/* FreeBSD has only one pass through driver */
dev -> kdrv = RTE_KDRV_NIC_UIO ;
diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
index 4bde430..12a2286 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c @@ -68,6 +68,9 @@ rte_eal_driver_unregister(struct rte_driver *driver)
void rte_eal_device_insert ( struct rte_device * dev )
{
+ RTE_VERIFY ( dev -> name );
+ RTE_VERIFY ( dev -> name [ 0 ] != '\0' );
+
TAILQ_INSERT_TAIL ( & dev_device_list , dev , next );
}
diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index 22fe2ca..c922297 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c @@ -180,6 +180,7 @@ rte_eal_vdev_init(const char *name, const char *args)
dev -> device . devargs = devargs ;
dev -> device . numa_node = SOCKET_ID_ANY ;
+ dev -> device . name = devargs -> virt . drv_name ;
ret = vdev_probe_all_drivers ( dev );
if ( ret ) { @@ -271,6 +272,7 @@ vdev_scan(void)
dev -> device . devargs = devargs ;
dev -> device . numa_node = SOCKET_ID_ANY ;
+ dev -> device . name = devargs -> virt . drv_name ;
rte_eal_device_insert ( & dev -> device );
TAILQ_INSERT_TAIL ( & vdev_device_list , dev , next ); diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h
index 4251099..67c2b0c 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h @@ -122,6 +122,7 @@ struct rte_driver;
*/
struct rte_device {
TAILQ_ENTRY ( rte_device ) next ; /**< Next device */
+ const char * name ; /**< Device name */
const struct rte_driver * driver ; /**< Associated driver */
int numa_node ; /**< NUMA node connection */
struct rte_devargs * devargs ; /**< Device user arguments */ diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index 8557e47..a036fe9 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h @@ -158,6 +158,7 @@ struct rte_pci_device {
struct rte_pci_driver * driver ; /**< Associated driver */
uint16_t max_vfs ; /**< sriov enable if not zero */
enum rte_kernel_driver kdrv ; /**< Kernel driver passthrough */
+ char name [ PCI_PRI_STR_SIZE + 1 ]; /**< PCI location (ASCII) */
};
/** diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c
index e2fc219..8b131f8 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -316,6 +316,9 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)
dev -> device . numa_node = tmp ;
}
+ rte_eal_pci_device_name ( addr , dev -> name , sizeof ( dev -> name ));
+ dev -> device . name = dev -> name ;
+
/* parse resources */
snprintf ( filename , sizeof ( filename ), "%s/resource" , dirname );
if ( pci_parse_sysfs_resource ( filename , dev ) < 0 ) { --
2.7.4
In some cases the virtual device name should be totally different than
the driver being used for the device. Therefore lets parse the devargs for
the "driver" argument before probing drivers in vdev_probe_all_drivers().
Signed-off-by: Jan Blunck <redacted>
---
lib/librte_eal/common/eal_common_vdev.c | 48 +++++++++++++++++++++++++++++----
1 file changed, 43 insertions(+), 5 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index c922297..4b5c0eb 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c @@ -72,12 +72,48 @@ rte_eal_vdrv_unregister(struct rte_vdev_driver *driver)
TAILQ_REMOVE ( & vdev_driver_list , driver , next );
}
+ /*
+ * Parse "driver" devargs without adding a dependency on rte_kvargs . h
+ */
+ static char * parse_driver_arg ( const char * args )
+ {
+ char * str , * c ;
+
+ if ( ! args || args [ 0 ] == '\0' )
+ return NULL ;
+
+ c = str = strdup ( args );
+
+ do {
+ if ( strncmp ( c , "driver=" , 7 ) == 0 ) {
+ c += 7 ;
+ break ;
+ }
+
+ c = strchr ( c , ',' );
+ if ( c )
+ c ++ ;
+ } while ( c );
+
+ if ( ! c )
+ free ( str );
+
+ return c ;
+ }
+
static int
vdev_probe_all_drivers ( struct rte_vdev_device * dev )
{
- const char * name = rte_vdev_device_name ( dev );
+ const char * name ;
+ char * drv_name ;
struct rte_vdev_driver * driver ;
- int ret ;
+ int ret = 1 ;
+
+ drv_name = parse_driver_arg ( rte_vdev_device_args ( dev ));
+ name = drv_name ? drv_name : rte_vdev_device_name ( dev );
+
+ RTE_LOG ( DEBUG , EAL , "Search driver %s to probe device %s \n " , name ,
+ rte_vdev_device_name ( dev ));
TAILQ_FOREACH ( driver , & vdev_driver_list , next ) {
/* @@ -92,7 +128,7 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev)
ret = driver -> probe ( dev );
if ( ret )
dev -> device . driver = NULL ;
- return ret ;
+ goto out ;
}
}
@@ -105,11 +141,13 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev)
ret = driver -> probe ( dev );
if ( ret )
dev -> device . driver = NULL ;
- return ret ;
+ break ;
}
}
- return 1 ;
+ out :
+ free ( drv_name );
+ return ret ;
}
static struct rte_vdev_device * --
2.7.4
This driver can use the library function rte_eth_dma_zone_reserve()
instead of duplicating the code.
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/nfp/nfp_net.c | 30 ++++++------------------------
1 file changed, 6 insertions(+), 24 deletions(-)
diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index d79f262..b9dfe80 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c @@ -205,26 +205,6 @@ nn_cfg_writeq(struct nfp_net_hw *hw, int off, uint64_t val)
nn_writeq ( rte_cpu_to_le_64 ( val ), hw -> ctrl_bar + off );
}
- /* Creating memzone for hardware rings. */
- static const struct rte_memzone *
- ring_dma_zone_reserve ( struct rte_eth_dev * dev , const char * ring_name ,
- uint16_t queue_id , uint32_t ring_size , int socket_id )
- {
- char z_name [ RTE_MEMZONE_NAMESIZE ];
- const struct rte_memzone * mz ;
-
- snprintf ( z_name , sizeof ( z_name ), "%s_%s_%d_%d" ,
- dev -> driver -> pci_drv . driver . name ,
- ring_name , dev -> data -> port_id , queue_id );
-
- mz = rte_memzone_lookup ( z_name );
- if ( mz )
- return mz ;
-
- return rte_memzone_reserve_aligned ( z_name , ring_size , socket_id , 0 ,
- NFP_MEMZONE_ALIGN );
- }
-
/*
* Atomically reads link status information from global structure rte_eth_dev .
* @@ -1461,9 +1441,10 @@ nfp_net_rx_queue_setup(struct rte_eth_dev *dev,
* handle the maximum ring size is allocated in order to allow for
* resizing in later calls to the queue setup function .
*/
- tz = ring_dma_zone_reserve ( dev , "rx_ring" , queue_idx ,
+ tz = rte_eth_dma_zone_reserve ( dev , "rx_ring" , queue_idx ,
sizeof ( struct nfp_net_rx_desc ) *
- NFP_NET_MAX_RX_DESC , socket_id );
+ NFP_NET_MAX_RX_DESC , NFP_MEMZONE_ALIGN ,
+ socket_id );
if ( tz == NULL ) {
RTE_LOG ( ERR , PMD , "Error allocatig rx dma \n " ); @@ -1603,9 +1584,10 @@ nfp_net_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
* handle the maximum ring size is allocated in order to allow for
* resizing in later calls to the queue setup function .
*/
- tz = ring_dma_zone_reserve ( dev , "tx_ring" , queue_idx ,
+ tz = rte_eth_dma_zone_reserve ( dev , "tx_ring" , queue_idx ,
sizeof ( struct nfp_net_tx_desc ) *
- NFP_NET_MAX_TX_DESC , socket_id );
+ NFP_NET_MAX_TX_DESC , NFP_MEMZONE_ALIGN ,
+ socket_id );
if ( tz == NULL ) {
RTE_LOG ( ERR , PMD , "Error allocating tx dma \n " );
nfp_net_tx_queue_release ( txq ); --
2.7.4
This driver can use the library function rte_eth_dma_zone_reserve()
instead of duplicating the code.
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/vmxnet3/vmxnet3_rxtx.c | 30 ++++--------------------------
1 file changed, 4 insertions(+), 26 deletions(-)
diff --git a/drivers/net/vmxnet3/vmxnet3_rxtx.c b/drivers/net/vmxnet3/vmxnet3_rxtx.c
index b246884..5e1b68a 100644
--- a/drivers/net/vmxnet3/vmxnet3_rxtx.c
+++ b/drivers/net/vmxnet3/vmxnet3_rxtx.c @@ -872,30 +872,6 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
return nb_rx ;
}
- /*
- * Create memzone for device rings . malloc can ' t be used as the physical address is
- * needed . If the memzone is already created , then this function returns a ptr
- * to the old one .
- */
- static const struct rte_memzone *
- ring_dma_zone_reserve ( struct rte_eth_dev * dev , const char * ring_name ,
- uint16_t queue_id , uint32_t ring_size , int socket_id )
- {
- char z_name [ RTE_MEMZONE_NAMESIZE ];
- const struct rte_memzone * mz ;
-
- snprintf ( z_name , sizeof ( z_name ), "%s_%s_%d_%d" ,
- dev -> driver -> pci_drv . driver . name , ring_name ,
- dev -> data -> port_id , queue_id );
-
- mz = rte_memzone_lookup ( z_name );
- if ( mz )
- return mz ;
-
- return rte_memzone_reserve_aligned ( z_name , ring_size ,
- socket_id , 0 , VMXNET3_RING_BA_ALIGN );
- }
-
int
vmxnet3_dev_tx_queue_setup ( struct rte_eth_dev * dev ,
uint16_t queue_idx , @@ -963,7 +939,8 @@ vmxnet3_dev_tx_queue_setup(struct rte_eth_dev *dev,
size += sizeof ( struct Vmxnet3_TxCompDesc ) * comp_ring -> size ;
size += sizeof ( struct Vmxnet3_TxDataDesc ) * data_ring -> size ;
- mz = ring_dma_zone_reserve ( dev , "txdesc" , queue_idx , size , socket_id );
+ mz = rte_eth_dma_zone_reserve ( dev , "txdesc" , queue_idx , size ,
+ VMXNET3_RING_BA_ALIGN , socket_id );
if ( mz == NULL ) {
PMD_INIT_LOG ( ERR , "ERROR: Creating queue descriptors zone" );
return - ENOMEM ; @@ -1065,7 +1042,8 @@ vmxnet3_dev_rx_queue_setup(struct rte_eth_dev *dev,
size = sizeof ( struct Vmxnet3_RxDesc ) * ( ring0 -> size + ring1 -> size );
size += sizeof ( struct Vmxnet3_RxCompDesc ) * comp_ring -> size ;
- mz = ring_dma_zone_reserve ( dev , "rxdesc" , queue_idx , size , socket_id );
+ mz = rte_eth_dma_zone_reserve ( dev , "rxdesc" , queue_idx , size ,
+ VMXNET3_RING_BA_ALIGN , socket_id );
if ( mz == NULL ) {
PMD_INIT_LOG ( ERR , "ERROR: Creating queue descriptors zone" );
return - ENOMEM ; --
2.7.4
This helper should be used by ethdev drivers supporting virtual devices
to help allocating a new ethdev and properly filling the default fields.
Signed-off-by: Jan Blunck <redacted>
---
lib/librte_ether/Makefile | 1 +
lib/librte_ether/rte_ethdev_vdev.h | 85 ++++++++++++++++++++++++++++++++++++++
2 files changed, 86 insertions(+)
create mode 100644 lib/librte_ether/rte_ethdev_vdev.h
diff --git a/lib/librte_ether/Makefile b/lib/librte_ether/Makefile
index 1d095a9..31e6ba7 100644
--- a/lib/librte_ether/Makefile
+++ b/lib/librte_ether/Makefile @@ -50,6 +50,7 @@ SRCS-y += rte_flow.c
# Export include files
#
SYMLINK-y-include += rte_ethdev.h
+ SYMLINK-y-include += rte_ethdev_vdev.h
SYMLINK-y-include += rte_eth_ctrl.h
SYMLINK-y-include += rte_dev_info.h
SYMLINK-y-include += rte_flow.h diff --git a/lib/librte_ether/rte_ethdev_vdev.h b/lib/librte_ether/rte_ethdev_vdev.h
new file mode 100644
index 0000000..0b47535
--- /dev/null
+++ b/lib/librte_ether/rte_ethdev_vdev.h @@ -0,0 +1,85 @@
+ /*-
+ * BSD LICENSE
+ *
+ * Copyright ( c ) 2017 Brocade Communications Systems , Inc .
+ * Author : Jan Blunck < jblunck @ infradead . org >
+ *
+ * Redistribution and use in source and binary forms , with or without
+ * modification , are permitted provided that the following conditions
+ * are met :
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice , this list of conditions and the following disclaimer .
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice , this list of conditions and the following disclaimer in
+ * the documentation and / or other materials provided with the
+ * distribution .
+ * * Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission .
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT
+ * LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL ,
+ * SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT
+ * LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE ,
+ * DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT
+ * ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
+ */
+
+ #ifndef _RTE_ETHDEV_VDEV_H_
+ #define _RTE_ETHDEV_VDEV_H_
+
+ #include <rte_malloc.h>
+ #include <rte_vdev.h>
+ #include <rte_ethdev.h>
+
+ /**
+ * @ internal
+ * Allocates a new ethdev slot for an ethernet device and returns the pointer
+ * to that slot for the driver to use .
+ *
+ * @ param dev
+ * Pointer to virtual device
+ *
+ * @ param private_data_size
+ * Size of private data structure
+ *
+ * @ return
+ * A pointer to a rte_eth_dev or NULL if allocation failed .
+ */
+ static inline struct rte_eth_dev *
+ rte_eth_vdev_allocate ( struct rte_vdev_device * dev , size_t private_data_size )
+ {
+ struct rte_eth_dev * eth_dev ;
+ const char * name = rte_vdev_device_name ( dev );
+
+ eth_dev = rte_eth_dev_allocate ( name );
+ if ( ! eth_dev )
+ return NULL ;
+
+ if ( private_data_size ) {
+ eth_dev -> data -> dev_private = rte_zmalloc_socket ( name ,
+ private_data_size , RTE_CACHE_LINE_SIZE ,
+ dev -> device . numa_node );
+ if ( ! eth_dev -> data -> dev_private ) {
+ rte_eth_dev_release_port ( eth_dev );
+ return NULL ;
+ }
+ }
+
+ eth_dev -> device = & dev -> device ;
+ eth_dev -> driver = NULL ;
+ eth_dev -> intr_handle = NULL ;
+
+ eth_dev -> data -> kdrv = RTE_KDRV_NONE ;
+ eth_dev -> data -> numa_node = dev -> device . numa_node ;
+ eth_dev -> data -> drv_name = dev -> device . driver -> name ;
+ return eth_dev ;
+ }
+
+ #endif /* _RTE_ETHDEV_VDEV_H_ */ --
2.7.4
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/tap/rte_eth_tap.c | 37 +++++++++++--------------------------
1 file changed, 11 insertions(+), 26 deletions(-)
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 941150f..f6f025f 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c @@ -33,6 +33,7 @@
#include <rte_mbuf.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_vdev.h>
#include <rte_malloc.h>
#include <rte_vdev.h>
#include <rte_kvargs.h> @@ -641,12 +642,12 @@ static const struct eth_dev_ops ops = {
};
static int
- eth_dev_tap_create ( const char * name , char * tap_name )
+ eth_dev_tap_create ( struct rte_vdev_device * vdev , char * tap_name )
{
int numa_node = rte_socket_id ();
- struct rte_eth_dev * dev = NULL ;
- struct pmd_internals * pmd = NULL ;
- struct rte_eth_dev_data * data = NULL ;
+ struct rte_eth_dev * dev ;
+ struct pmd_internals * pmd ;
+ struct rte_eth_dev_data * data ;
int i ;
RTE_LOG ( DEBUG , PMD , " TAP device on numa %u \n " , rte_socket_id ()); @@ -657,30 +658,19 @@ eth_dev_tap_create(const char *name, char *tap_name)
goto error_exit ;
}
- pmd = rte_zmalloc_socket ( tap_name , sizeof ( * pmd ), 0 , numa_node );
- if ( ! pmd ) {
- RTE_LOG ( ERR , PMD , "TAP Unable to allocate internal struct \n " );
- goto error_exit ;
- }
-
- dev = rte_eth_dev_allocate ( tap_name );
+ dev = rte_eth_vdev_allocate ( vdev , sizeof ( * pmd ));
if ( ! dev ) {
RTE_LOG ( ERR , PMD , "TAP Unable to allocate device struct \n " );
goto error_exit ;
}
+ pmd = dev -> data -> dev_private ;
snprintf ( pmd -> name , sizeof ( pmd -> name ), "%s" , tap_name );
-
pmd -> nb_queues = RTE_PMD_TAP_MAX_QUEUES ;
/* Setup some default values */
- data -> dev_private = pmd ;
- data -> port_id = dev -> data -> port_id ;
+ rte_memcpy ( data , dev -> data , sizeof ( * data ));
data -> dev_flags = RTE_ETH_DEV_DETACHABLE ;
- data -> kdrv = RTE_KDRV_NONE ;
- data -> drv_name = pmd_tap_drv . driver . name ;
- data -> numa_node = numa_node ;
-
data -> dev_link = pmd_link ;
data -> mac_addrs = & pmd -> eth_addr ;
data -> nb_rx_queues = pmd -> nb_queues ; @@ -688,10 +678,8 @@ eth_dev_tap_create(const char *name, char *tap_name)
dev -> data = data ;
dev -> dev_ops = & ops ;
- dev -> driver = NULL ;
dev -> rx_pkt_burst = pmd_rx_burst ;
dev -> tx_pkt_burst = pmd_tx_burst ;
- snprintf ( dev -> data -> name , sizeof ( dev -> data -> name ), "%s" , name );
/* Presetup the fds to -1 as being not valid */
for ( i = 0 ; i < RTE_PMD_TAP_MAX_QUEUES ; i ++ ) { @@ -702,13 +690,10 @@ eth_dev_tap_create(const char *name, char *tap_name)
return 0 ;
error_exit :
- RTE_LOG ( DEBUG , PMD , "TAP Unable to initialize %s \n " , name );
+ RTE_LOG ( DEBUG , PMD , "TAP Unable to initialize %s \n " ,
+ rte_vdev_device_name ( vdev ));
rte_free ( data );
- rte_free ( pmd );
-
- rte_eth_dev_release_port ( dev );
-
return - EINVAL ;
}
@@ -785,7 +770,7 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)
RTE_LOG ( NOTICE , PMD , "Initializing pmd_tap for %s as %s \n " ,
name , tap_name );
- ret = eth_dev_tap_create ( name , tap_name );
+ ret = eth_dev_tap_create ( dev , tap_name );
leave :
if ( ret == -1 ) { --
2.7.4
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/vhost/rte_eth_vhost.c | 54 +++++++++++++++++++--------------------
1 file changed, 26 insertions(+), 28 deletions(-)
diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index d0d0474..e2dae6f 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c @@ -39,6 +39,7 @@
#include <rte_mbuf.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_vdev.h>
#include <rte_malloc.h>
#include <rte_memcpy.h>
#include <rte_vdev.h> @@ -1012,9 +1013,10 @@ static const struct eth_dev_ops ops = {
static struct rte_vdev_driver pmd_vhost_drv ;
static int
- eth_dev_vhost_create ( const char * name , char * iface_name , int16_t queues ,
- const unsigned numa_node , uint64_t flags )
+ eth_dev_vhost_create ( struct rte_vdev_device * dev , char * iface_name ,
+ int16_t queues , const unsigned int numa_node , uint64_t flags )
{
+ const char * name = rte_vdev_device_name ( dev );
struct rte_eth_dev_data * data = NULL ;
struct pmd_internal * internal = NULL ;
struct rte_eth_dev * eth_dev = NULL ; @@ -1025,23 +1027,19 @@ eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues,
RTE_LOG ( INFO , PMD , "Creating VHOST-USER backend on numa socket %u \n " ,
numa_node );
- /* now do all data allocation - for eth_dev structure, dummy pci driver
- * and internal ( private ) data
+ /* now do all data allocation - for eth_dev structure and internal
+ * ( private ) data
*/
data = rte_zmalloc_socket ( name , sizeof ( * data ), 0 , numa_node );
if ( data == NULL )
goto error ;
- internal = rte_zmalloc_socket ( name , sizeof ( * internal ), 0 , numa_node );
- if ( internal == NULL )
- goto error ;
-
list = rte_zmalloc_socket ( name , sizeof ( * list ), 0 , numa_node );
if ( list == NULL )
goto error ;
/* reserve an ethdev entry */
- eth_dev = rte_eth_dev_allocate ( name );
+ eth_dev = rte_eth_vdev_allocate ( dev , sizeof ( * internal ));
if ( eth_dev == NULL )
goto error ;
@@ -1058,10 +1056,10 @@ eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues,
/* now put it all together
* - store queue data in internal ,
- * - store numa_node info in ethdev data
* - point eth_dev_data to internals
* - and point eth_dev structure to new eth_dev_data structure
*/
+ internal = eth_dev -> data -> dev_private ;
internal -> dev_name = strdup ( name );
if ( internal -> dev_name == NULL )
goto error ; @@ -1077,26 +1075,21 @@ eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues,
rte_spinlock_init ( & vring_state -> lock );
vring_states [ eth_dev -> data -> port_id ] = vring_state ;
- data -> dev_private = internal ;
- data -> port_id = eth_dev -> data -> port_id ;
- memmove ( data -> name , eth_dev -> data -> name , sizeof ( data -> name ));
+ /* We'll replace the 'data' originally allocated by eth_dev. So the
+ * vhost PMD resources won ' t be shared between multi processes .
+ */
+ rte_memcpy ( data , eth_dev -> data , sizeof ( * data ));
+ eth_dev -> data = data ;
+
data -> nb_rx_queues = queues ;
data -> nb_tx_queues = queues ;
internal -> max_queues = queues ;
data -> dev_link = pmd_link ;
data -> mac_addrs = eth_addr ;
-
- /* We'll replace the 'data' originally allocated by eth_dev. So the
- * vhost PMD resources won ' t be shared between multi processes .
- */
- eth_dev -> data = data ;
- eth_dev -> dev_ops = & ops ;
- eth_dev -> driver = NULL ;
data -> dev_flags =
RTE_ETH_DEV_DETACHABLE | RTE_ETH_DEV_INTR_LSC ;
- data -> kdrv = RTE_KDRV_NONE ;
- data -> drv_name = pmd_vhost_drv . driver . name ;
- data -> numa_node = numa_node ;
+
+ eth_dev -> dev_ops = & ops ;
/* finally assign rx and tx ops */
eth_dev -> rx_pkt_burst = eth_vhost_rx ; @@ -1114,8 +1107,10 @@ eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues,
return data -> port_id ;
error :
- if ( internal )
+ if ( internal ) {
+ free ( internal -> iface_name );
free ( internal -> dev_name );
+ }
rte_free ( vring_state );
rte_free ( eth_addr );
if ( eth_dev ) @@ -1158,7 +1153,6 @@ open_int(const char *key __rte_unused, const char *value, void *extra_args)
static int
rte_pmd_vhost_probe ( struct rte_vdev_device * dev )
{
- const char * name ;
struct rte_kvargs * kvlist = NULL ;
int ret = 0 ;
char * iface_name ; @@ -1167,8 +1161,8 @@ rte_pmd_vhost_probe(struct rte_vdev_device *dev)
int client_mode = 0 ;
int dequeue_zero_copy = 0 ;
- name = rte_vdev_device_name ( dev );
- RTE_LOG ( INFO , PMD , "Initializing pmd_vhost for %s \n " , name );
+ RTE_LOG ( INFO , PMD , "Initializing pmd_vhost for %s \n " ,
+ rte_vdev_device_name ( dev ));
kvlist = rte_kvargs_parse ( rte_vdev_device_args ( dev ), valid_arguments );
if ( kvlist == NULL ) @@ -1213,7 +1207,11 @@ rte_pmd_vhost_probe(struct rte_vdev_device *dev)
flags |= RTE_VHOST_USER_DEQUEUE_ZERO_COPY ;
}
- eth_dev_vhost_create ( name , iface_name , queues , rte_socket_id (), flags );
+ if ( dev -> device . numa_node == SOCKET_ID_ANY )
+ dev -> device . numa_node = rte_socket_id ();
+
+ eth_dev_vhost_create ( dev , iface_name , queues , dev -> device . numa_node ,
+ flags );
out_free :
rte_kvargs_free ( kvlist ); --
2.7.4
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/virtio/virtio_user_ethdev.c | 20 +++++---------------
1 file changed, 5 insertions(+), 15 deletions(-)
diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index 42ad8a2..15e3a93 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -37,6 +37,7 @@
#include <rte_malloc.h>
#include <rte_kvargs.h>
+ #include <rte_ethdev_vdev.h>
#include <rte_vdev.h>
#include "virtio_ethdev.h" @@ -277,27 +278,21 @@ get_integer_arg(const char *key __rte_unused,
static struct rte_vdev_driver virtio_user_driver ;
static struct rte_eth_dev *
- virtio_user_eth_dev_alloc ( const char * name )
+ virtio_user_eth_dev_alloc ( struct rte_vdev_device * vdev )
{
struct rte_eth_dev * eth_dev ;
struct rte_eth_dev_data * data ;
struct virtio_hw * hw ;
struct virtio_user_dev * dev ;
- eth_dev = rte_eth_dev_allocate ( name );
+ eth_dev = rte_eth_vdev_allocate ( vdev , sizeof ( * hw ));
if ( ! eth_dev ) {
PMD_INIT_LOG ( ERR , "cannot alloc rte_eth_dev" );
return NULL ;
}
data = eth_dev -> data ;
-
- hw = rte_zmalloc ( NULL , sizeof ( * hw ), 0 );
- if ( ! hw ) {
- PMD_INIT_LOG ( ERR , "malloc virtio_hw failed" );
- rte_eth_dev_release_port ( eth_dev );
- return NULL ;
- }
+ hw = eth_dev -> data -> dev_private ;
dev = rte_zmalloc ( NULL , sizeof ( * dev ), 0 );
if ( ! dev ) { @@ -313,12 +308,7 @@ virtio_user_eth_dev_alloc(const char *name)
hw -> modern = 0 ;
hw -> use_simple_rxtx = 0 ;
hw -> virtio_user_dev = dev ;
- data -> dev_private = hw ;
- data -> drv_name = virtio_user_driver . driver . name ;
- data -> numa_node = SOCKET_ID_ANY ;
- data -> kdrv = RTE_KDRV_NONE ;
data -> dev_flags = RTE_ETH_DEV_DETACHABLE ;
- eth_dev -> driver = NULL ;
return eth_dev ;
}
@@ -412,7 +402,7 @@ virtio_user_pmd_probe(struct rte_vdev_device *dev)
goto end ;
}
- eth_dev = virtio_user_eth_dev_alloc ( rte_vdev_device_name ( dev ));
+ eth_dev = virtio_user_eth_dev_alloc ( dev );
if ( ! eth_dev ) {
PMD_INIT_LOG ( ERR , "virtio_user fails to alloc device" );
goto end ; --
2.7.4
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/af_packet/rte_eth_af_packet.c | 42 ++++++++++++++-----------------
1 file changed, 19 insertions(+), 23 deletions(-)
diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 77536e8..6f6ba0c 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -38,6 +38,7 @@
#include <rte_mbuf.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_vdev.h>
#include <rte_malloc.h>
#include <rte_kvargs.h>
#include <rte_vdev.h> @@ -539,18 +540,19 @@ open_packet_iface(const char *key __rte_unused,
static struct rte_vdev_driver pmd_af_packet_drv ;
static int
- rte_pmd_init_internals ( const char * name ,
+ rte_pmd_init_internals ( struct rte_vdev_device * dev ,
const int sockfd ,
const unsigned nb_queues ,
unsigned int blocksize ,
unsigned int blockcnt ,
unsigned int framesize ,
unsigned int framecnt ,
- const unsigned numa_node ,
struct pmd_internals ** internals ,
struct rte_eth_dev ** eth_dev ,
struct rte_kvargs * kvlist )
{
+ const char * name = rte_vdev_device_name ( dev );
+ const unsigned int numa_node = dev -> device . numa_node ;
struct rte_eth_dev_data * data = NULL ;
struct rte_kvargs_pair * pair = NULL ;
struct ifreq ifr ; @@ -768,7 +770,7 @@ rte_pmd_init_internals(const char *name,
}
/* reserve an ethdev entry */
- * eth_dev = rte_eth_dev_allocate ( name );
+ * eth_dev = rte_eth_vdev_allocate ( dev , 0 );
if ( * eth_dev == NULL )
goto error ;
@@ -782,22 +784,16 @@ rte_pmd_init_internals(const char *name,
( * internals ) -> nb_queues = nb_queues ;
+ rte_memcpy ( data , ( * eth_dev ) -> data , sizeof ( * data ));
data -> dev_private = * internals ;
- data -> port_id = ( * eth_dev ) -> data -> port_id ;
data -> nb_rx_queues = ( uint16_t ) nb_queues ;
data -> nb_tx_queues = ( uint16_t ) nb_queues ;
data -> dev_link = pmd_link ;
data -> mac_addrs = & ( * internals ) -> eth_addr ;
- strncpy ( data -> name ,
- ( * eth_dev ) -> data -> name , strlen (( * eth_dev ) -> data -> name ));
( * eth_dev ) -> data = data ;
( * eth_dev ) -> dev_ops = & ops ;
- ( * eth_dev ) -> driver = NULL ;
( * eth_dev ) -> data -> dev_flags = RTE_ETH_DEV_DETACHABLE ;
- ( * eth_dev ) -> data -> drv_name = pmd_af_packet_drv . driver . name ;
- ( * eth_dev ) -> data -> kdrv = RTE_KDRV_NONE ;
- ( * eth_dev ) -> data -> numa_node = numa_node ;
return 0 ;
@@ -822,11 +818,11 @@ rte_pmd_init_internals(const char *name,
}
static int
- rte_eth_from_packet ( const char * name ,
+ rte_eth_from_packet ( struct rte_vdev_device * dev ,
int const * sockfd ,
- const unsigned numa_node ,
struct rte_kvargs * kvlist )
{
+ const char * name = rte_vdev_device_name ( dev );
struct pmd_internals * internals = NULL ;
struct rte_eth_dev * eth_dev = NULL ;
struct rte_kvargs_pair * pair = NULL ; @@ -909,11 +905,11 @@ rte_eth_from_packet(const char *name,
RTE_LOG ( INFO , PMD , "%s: \t frame size %d \n " , name , framesize );
RTE_LOG ( INFO , PMD , "%s: \t frame count %d \n " , name , framecount );
- if ( rte_pmd_init_internals ( name , * sockfd , qpairs ,
- blocksize , blockcount ,
- framesize , framecount ,
- numa_node , & internals , & eth_dev ,
- kvlist ) < 0 )
+ if ( rte_pmd_init_internals ( dev , * sockfd , qpairs ,
+ blocksize , blockcount ,
+ framesize , framecount ,
+ & internals , & eth_dev ,
+ kvlist ) < 0 )
return -1 ;
eth_dev -> rx_pkt_burst = eth_af_packet_rx ; @@ -925,15 +921,12 @@ rte_eth_from_packet(const char *name,
static int
rte_pmd_af_packet_probe ( struct rte_vdev_device * dev )
{
- const char * name = rte_vdev_device_name ( dev );
- unsigned numa_node ;
int ret = 0 ;
struct rte_kvargs * kvlist ;
int sockfd = -1 ;
- RTE_LOG ( INFO , PMD , "Initializing pmd_af_packet for %s \n " , name );
-
- numa_node = rte_socket_id ();
+ RTE_LOG ( INFO , PMD , "Initializing pmd_af_packet for %s \n " ,
+ rte_vdev_device_name ( dev ));
kvlist = rte_kvargs_parse ( rte_vdev_device_args ( dev ), valid_arguments );
if ( kvlist == NULL ) { @@ -953,7 +946,10 @@ rte_pmd_af_packet_probe(struct rte_vdev_device *dev)
goto exit ;
}
- ret = rte_eth_from_packet ( name , & sockfd , numa_node , kvlist );
+ if ( dev -> device . numa_node == SOCKET_ID_ANY )
+ dev -> device . numa_node = rte_socket_id ();
+
+ ret = rte_eth_from_packet ( dev , & sockfd , kvlist );
close ( sockfd ); /* no longer needed */
exit : --
2.7.4
A virtual device should get initialized through the rte_eal_vdev_init()
function to properly initialize the driver.
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/null/rte_eth_null.c | 1 +
test/test/test_link_bonding_rssconf.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index f4242b0..b856073 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c @@ -50,6 +50,7 @@ static unsigned default_packet_copy;
static const char * valid_arguments [] = {
ETH_NULL_PACKET_SIZE_ARG ,
ETH_NULL_PACKET_COPY_ARG ,
+ "driver" ,
NULL
};
diff --git a/test/test/test_link_bonding_rssconf.c b/test/test/test_link_bonding_rssconf.c
index 34f1c16..1023f7f 100644
--- a/test/test/test_link_bonding_rssconf.c
+++ b/test/test/test_link_bonding_rssconf.c @@ -552,7 +552,8 @@ test_setup(void)
port_id = rte_eth_dev_count ();
snprintf ( name , sizeof ( name ), SLAVE_DEV_NAME_FMT , port_id );
- retval = eth_dev_null_create ( name , 0 , 64 , 0 );
+ retval = rte_eal_vdev_init ( name ,
+ "driver=net_null,size=64,copy=0" );
TEST_ASSERT_SUCCESS ( retval , "Failed to create null device '%s' \n " ,
name );
--
2.7.4
There is no need to export this API. Remaining users should use the
rte_eal_vdev_init() function instead.
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/null/Makefile | 7 +-----
drivers/net/null/rte_eth_null.c | 4 +---
drivers/net/null/rte_eth_null.h | 40 -------------------------------
drivers/net/null/rte_pmd_null_version.map | 7 ------
test/test/test_link_bonding_rssconf.c | 1 -
5 files changed, 2 insertions(+), 57 deletions(-)
delete mode 100644 drivers/net/null/rte_eth_null.h
diff --git a/drivers/net/null/Makefile b/drivers/net/null/Makefile
index 0c909c6..80abb52 100644
--- a/drivers/net/null/Makefile
+++ b/drivers/net/null/Makefile @@ -41,18 +41,13 @@ CFLAGS += $(WERROR_FLAGS)
EXPORT_MAP := rte_pmd_null_version.map
- LIBABIVER := 1
+ LIBABIVER := 2
#
# all source are stored in SRCS-y
#
SRCS-$(CONFIG_RTE_LIBRTE_PMD_NULL) += rte_eth_null.c
- #
- # Export include files
- #
- SYMLINK-y-include += rte_eth_null.h
-
# this lib depends upon:
DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_NULL) += lib/librte_eal
DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_NULL) += lib/librte_mbuf diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index b856073..14f35d7 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c @@ -39,8 +39,6 @@
#include <rte_kvargs.h>
#include <rte_spinlock.h>
- #include "rte_eth_null.h"
-
#define ETH_NULL_PACKET_SIZE_ARG "size"
#define ETH_NULL_PACKET_COPY_ARG "copy"
@@ -480,7 +478,7 @@ static const struct eth_dev_ops ops = {
static struct rte_vdev_driver pmd_null_drv ;
- int
+ static int
eth_dev_null_create ( const char * name ,
const unsigned numa_node ,
unsigned packet_size , diff --git a/drivers/net/null/rte_eth_null.h b/drivers/net/null/rte_eth_null.h
deleted file mode 100644
index abada8c..0000000
--- a/drivers/net/null/rte_eth_null.h
+++ /dev/null @@ -1,40 +0,0 @@
- /*-
- * BSD LICENSE
- *
- * Copyright(c) 2015 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
- #ifndef RTE_ETH_NULL_H_
- #define RTE_ETH_NULL_H_
-
- int eth_dev_null_create(const char *name, const unsigned numa_node,
- unsigned packet_size, unsigned packet_copy);
-
- #endif /* RTE_ETH_NULL_H_ */diff --git a/drivers/net/null/rte_pmd_null_version.map b/drivers/net/null/rte_pmd_null_version.map
index 84b1d0f..ef35398 100644
--- a/drivers/net/null/rte_pmd_null_version.map
+++ b/drivers/net/null/rte_pmd_null_version.map @@ -2,10 +2,3 @@ DPDK_2.0 {
local: *;
};
-
- DPDK_2.2 {
- global:
-
- eth_dev_null_create;
-
- } DPDK_2.0;diff --git a/test/test/test_link_bonding_rssconf.c b/test/test/test_link_bonding_rssconf.c
index 1023f7f..8bd69ad 100644
--- a/test/test/test_link_bonding_rssconf.c
+++ b/test/test/test_link_bonding_rssconf.c @@ -52,7 +52,6 @@
#include <rte_string_fns.h>
#include <rte_errno.h>
#include <rte_eth_bond.h>
- #include <rte_eth_null.h>
#include "test.h"
--
2.7.4
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/null/rte_eth_null.c | 50 ++++++++++++++---------------------------
1 file changed, 17 insertions(+), 33 deletions(-)
diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 14f35d7..226c2e4 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c @@ -33,6 +33,7 @@
#include <rte_mbuf.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_vdev.h>
#include <rte_malloc.h>
#include <rte_memcpy.h>
#include <rte_vdev.h> @@ -479,8 +480,7 @@ static const struct eth_dev_ops ops = {
static struct rte_vdev_driver pmd_null_drv ;
static int
- eth_dev_null_create ( const char * name ,
- const unsigned numa_node ,
+ eth_dev_null_create ( struct rte_vdev_device * dev ,
unsigned packet_size ,
unsigned packet_copy )
{ @@ -497,27 +497,25 @@ eth_dev_null_create(const char *name,
0xBE , 0xAC , 0x01 , 0xFA
};
- if ( name == NULL )
- return - EINVAL ;
+ if ( dev -> device . numa_node == SOCKET_ID_ANY )
+ dev -> device . numa_node = rte_socket_id ();
RTE_LOG ( INFO , PMD , "Creating null ethdev on numa socket %u \n " ,
- numa_node );
+ dev -> device . numa_node );
/* now do all data allocation - for eth_dev structure, dummy pci driver
* and internal ( private ) data
*/
- data = rte_zmalloc_socket ( name , sizeof ( * data ), 0 , numa_node );
- if ( data == NULL )
- goto error ;
-
- internals = rte_zmalloc_socket ( name , sizeof ( * internals ), 0 , numa_node );
- if ( internals == NULL )
- goto error ;
+ data = rte_zmalloc_socket ( rte_vdev_device_name ( dev ), sizeof ( * data ), 0 ,
+ dev -> device . numa_node );
+ if ( ! data )
+ return - ENOMEM ;
- /* reserve an ethdev entry */
- eth_dev = rte_eth_dev_allocate ( name );
- if ( eth_dev == NULL )
- goto error ;
+ eth_dev = rte_eth_vdev_allocate ( dev , sizeof ( * internals ));
+ if ( ! eth_dev ) {
+ rte_free ( data );
+ return - ENOMEM ;
+ }
/* now put it all together
* - store queue data in internals , @@ -528,6 +526,7 @@ eth_dev_null_create(const char *name,
/* NOTE: we'll replace the data element, of originally allocated eth_dev
* so the nulls are local per - process */
+ internals = eth_dev -> data -> dev_private ;
internals -> packet_size = packet_size ;
internals -> packet_copy = packet_copy ;
internals -> port_id = eth_dev -> data -> port_id ; @@ -537,22 +536,16 @@ eth_dev_null_create(const char *name,
rte_memcpy ( internals -> rss_key , default_rss_key , 40 );
- data -> dev_private = internals ;
- data -> port_id = eth_dev -> data -> port_id ;
+ rte_memcpy ( data , eth_dev -> data , sizeof ( * data ));
data -> nb_rx_queues = ( uint16_t ) nb_rx_queues ;
data -> nb_tx_queues = ( uint16_t ) nb_tx_queues ;
data -> dev_link = pmd_link ;
data -> mac_addrs = & eth_addr ;
- strncpy ( data -> name , eth_dev -> data -> name , strlen ( eth_dev -> data -> name ));
eth_dev -> data = data ;
eth_dev -> dev_ops = & ops ;
- eth_dev -> driver = NULL ;
data -> dev_flags = RTE_ETH_DEV_DETACHABLE ;
- data -> kdrv = RTE_KDRV_NONE ;
- data -> drv_name = pmd_null_drv . driver . name ;
- data -> numa_node = numa_node ;
/* finally assign rx and tx ops */
if ( packet_copy ) { @@ -564,12 +557,6 @@ eth_dev_null_create(const char *name,
}
return 0 ;
-
- error :
- rte_free ( data );
- rte_free ( internals );
-
- return -1 ;
}
static inline int @@ -610,7 +597,6 @@ static int
rte_pmd_null_probe ( struct rte_vdev_device * dev )
{
const char * name , * params ;
- unsigned numa_node ;
unsigned packet_size = default_packet_size ;
unsigned packet_copy = default_packet_copy ;
struct rte_kvargs * kvlist = NULL ; @@ -623,8 +609,6 @@ rte_pmd_null_probe(struct rte_vdev_device *dev)
params = rte_vdev_device_args ( dev );
RTE_LOG ( INFO , PMD , "Initializing pmd_null for %s \n " , name );
- numa_node = rte_socket_id ();
-
if ( params != NULL ) {
kvlist = rte_kvargs_parse ( params , valid_arguments );
if ( kvlist == NULL ) @@ -653,7 +637,7 @@ rte_pmd_null_probe(struct rte_vdev_device *dev)
"packet copy is %s \n " , packet_size ,
packet_copy ? "enabled" : "disabled" );
- ret = eth_dev_null_create ( name , numa_node , packet_size , packet_copy );
+ ret = eth_dev_null_create ( dev , packet_size , packet_copy );
free_kvlist :
if ( kvlist ) --
2.7.4
To properly embed the generic rte_device into the rte_eth_dev this reworks
the bonding API to call through rte_eal_vdev_init().
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/bonding/rte_eth_bond_api.c | 171 +++++--------------------------
drivers/net/bonding/rte_eth_bond_args.c | 2 +-
drivers/net/bonding/rte_eth_bond_pmd.c | 174 ++++++++++++++++++++++++++++++--
3 files changed, 194 insertions(+), 153 deletions(-)
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index f552d96..80c7091 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c @@ -38,13 +38,12 @@
#include <rte_ethdev.h>
#include <rte_tcp.h>
#include <rte_vdev.h>
+ #include <rte_kvargs.h>
#include "rte_eth_bond.h"
#include "rte_eth_bond_private.h"
#include "rte_eth_bond_8023ad_private.h"
- #define DEFAULT_POLLING_INTERVAL_10_MS (10)
-
int
check_for_bonded_ethdev ( const struct rte_eth_dev * eth_dev )
{ @@ -163,163 +162,45 @@ number_of_sockets(void)
int
rte_eth_bond_create ( const char * name , uint8_t mode , uint8_t socket_id )
{
- struct bond_dev_private * internals = NULL ;
- struct rte_eth_dev * eth_dev = NULL ;
- uint32_t vlan_filter_bmp_size ;
-
- /* now do all data allocation - for eth_dev structure, dummy pci driver
- * and internal ( private ) data
- */
+ struct bond_dev_private * internals ;
+ char devargs [ 52 ];
+ uint8_t port_id ;
+ int ret ;
if ( name == NULL ) {
RTE_BOND_LOG ( ERR , "Invalid name specified" );
- goto err ;
- }
-
- if ( socket_id >= number_of_sockets ()) {
- RTE_BOND_LOG ( ERR ,
- "Invalid socket id specified to create bonded device on." );
- goto err ;
+ return - EINVAL ;
}
- internals = rte_zmalloc_socket ( name , sizeof ( * internals ), 0 , socket_id );
- if ( internals == NULL ) {
- RTE_BOND_LOG ( ERR , "Unable to malloc internals on socket" );
- goto err ;
- }
+ ret = snprintf ( devargs , sizeof ( devargs ),
+ "driver=net_bonding,mode=%d,socket_id=%d" , mode , socket_id );
+ if ( ret < 0 || ret >= ( int ) sizeof ( devargs ))
+ return - ENOMEM ;
- /* reserve an ethdev entry */
- eth_dev = rte_eth_dev_allocate ( name );
- if ( eth_dev == NULL ) {
- RTE_BOND_LOG ( ERR , "Unable to allocate rte_eth_dev" );
- goto err ;
- }
+ ret = rte_eal_vdev_init ( name , devargs );
+ if ( ret )
+ return - ENOMEM ;
- eth_dev -> data -> dev_private = internals ;
- eth_dev -> data -> nb_rx_queues = ( uint16_t ) 1 ;
- eth_dev -> data -> nb_tx_queues = ( uint16_t ) 1 ;
-
- eth_dev -> data -> mac_addrs = rte_zmalloc_socket ( name , ETHER_ADDR_LEN , 0 ,
- socket_id );
- if ( eth_dev -> data -> mac_addrs == NULL ) {
- RTE_BOND_LOG ( ERR , "Unable to malloc mac_addrs" );
- goto err ;
- }
-
- eth_dev -> dev_ops = & default_dev_ops ;
- eth_dev -> data -> dev_flags = RTE_ETH_DEV_INTR_LSC |
- RTE_ETH_DEV_DETACHABLE ;
- eth_dev -> driver = NULL ;
- eth_dev -> data -> kdrv = RTE_KDRV_NONE ;
- eth_dev -> data -> drv_name = pmd_bond_drv . driver . name ;
- eth_dev -> data -> numa_node = socket_id ;
-
- rte_spinlock_init ( & internals -> lock );
-
- internals -> port_id = eth_dev -> data -> port_id ;
- internals -> mode = BONDING_MODE_INVALID ;
- internals -> current_primary_port = RTE_MAX_ETHPORTS + 1 ;
- internals -> balance_xmit_policy = BALANCE_XMIT_POLICY_LAYER2 ;
- internals -> xmit_hash = xmit_l2_hash ;
- internals -> user_defined_mac = 0 ;
- internals -> link_props_set = 0 ;
-
- internals -> link_status_polling_enabled = 0 ;
-
- internals -> link_status_polling_interval_ms = DEFAULT_POLLING_INTERVAL_10_MS ;
- internals -> link_down_delay_ms = 0 ;
- internals -> link_up_delay_ms = 0 ;
-
- internals -> slave_count = 0 ;
- internals -> active_slave_count = 0 ;
- internals -> rx_offload_capa = 0 ;
- internals -> tx_offload_capa = 0 ;
- internals -> candidate_max_rx_pktlen = 0 ;
- internals -> max_rx_pktlen = 0 ;
-
- /* Initially allow to choose any offload type */
- internals -> flow_type_rss_offloads = ETH_RSS_PROTO_MASK ;
-
- memset ( internals -> active_slaves , 0 , sizeof ( internals -> active_slaves ));
- memset ( internals -> slaves , 0 , sizeof ( internals -> slaves ));
-
- /* Set mode 4 default configuration */
- bond_mode_8023ad_setup ( eth_dev , NULL );
- if ( bond_ethdev_mode_set ( eth_dev , mode )) {
- RTE_BOND_LOG ( ERR , "Failed to set bonded device %d mode too %d" ,
- eth_dev -> data -> port_id , mode );
- goto err ;
- }
+ ret = rte_eth_dev_get_port_by_name ( name , & port_id );
+ RTE_ASSERT ( ! ret );
- vlan_filter_bmp_size =
- rte_bitmap_get_memory_footprint ( ETHER_MAX_VLAN_ID + 1 );
- internals -> vlan_filter_bmpmem = rte_malloc ( name , vlan_filter_bmp_size ,
- RTE_CACHE_LINE_SIZE );
- if ( internals -> vlan_filter_bmpmem == NULL ) {
- RTE_BOND_LOG ( ERR ,
- "Failed to allocate vlan bitmap for bonded device %u \n " ,
- eth_dev -> data -> port_id );
- goto err ;
- }
-
- internals -> vlan_filter_bmp = rte_bitmap_init ( ETHER_MAX_VLAN_ID + 1 ,
- internals -> vlan_filter_bmpmem , vlan_filter_bmp_size );
- if ( internals -> vlan_filter_bmp == NULL ) {
- RTE_BOND_LOG ( ERR ,
- "Failed to init vlan bitmap for bonded device %u \n " ,
- eth_dev -> data -> port_id );
- rte_free ( internals -> vlan_filter_bmpmem );
- goto err ;
- }
-
- return eth_dev -> data -> port_id ;
+ /*
+ * To make bond_ethdev_configure () happy we need to free the
+ * internals -> kvlist here .
+ *
+ * Also see comment in bond_ethdev_configure ().
+ */
+ internals = rte_eth_devices [ port_id ]. data -> dev_private ;
+ rte_kvargs_free ( internals -> kvlist );
+ internals -> kvlist = NULL ;
- err :
- rte_free ( internals );
- if ( eth_dev != NULL ) {
- rte_free ( eth_dev -> data -> mac_addrs );
- rte_eth_dev_release_port ( eth_dev );
- }
- return -1 ;
+ return port_id ;
}
int
rte_eth_bond_free ( const char * name )
{
- struct rte_eth_dev * eth_dev = NULL ;
- struct bond_dev_private * internals ;
-
- /* now free all data allocation - for eth_dev structure,
- * dummy pci driver and internal ( private ) data
- */
-
- /* find an ethdev entry */
- eth_dev = rte_eth_dev_allocated ( name );
- if ( eth_dev == NULL )
- return - ENODEV ;
-
- internals = eth_dev -> data -> dev_private ;
- if ( internals -> slave_count != 0 )
- return - EBUSY ;
-
- if ( eth_dev -> data -> dev_started == 1 ) {
- bond_ethdev_stop ( eth_dev );
- bond_ethdev_close ( eth_dev );
- }
-
- eth_dev -> dev_ops = NULL ;
- eth_dev -> rx_pkt_burst = NULL ;
- eth_dev -> tx_pkt_burst = NULL ;
-
- internals = eth_dev -> data -> dev_private ;
- rte_bitmap_free ( internals -> vlan_filter_bmp );
- rte_free ( internals -> vlan_filter_bmpmem );
- rte_free ( eth_dev -> data -> dev_private );
- rte_free ( eth_dev -> data -> mac_addrs );
-
- rte_eth_dev_release_port ( eth_dev );
-
- return 0 ;
+ return rte_eal_vdev_uninit ( name );
}
static int diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c
index 3dca273..e3bdad9 100644
--- a/drivers/net/bonding/rte_eth_bond_args.c
+++ b/drivers/net/bonding/rte_eth_bond_args.c @@ -47,7 +47,7 @@ const char *pmd_bond_init_valid_arguments[] = {
PMD_BOND_XMIT_POLICY_KVARG ,
PMD_BOND_SOCKET_ID_KVARG ,
PMD_BOND_MAC_ADDR_KVARG ,
-
+ "driver" ,
NULL
};
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 6c03920..c0d08a8 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -51,6 +51,7 @@
#include "rte_eth_bond_8023ad_private.h"
#define REORDER_PERIOD_MS 10
+ #define DEFAULT_POLLING_INTERVAL_10_MS (10)
#define HASH_L4_PORTS(h) ((h)->src_port ^ (h)->dst_port)
@@ -2230,6 +2231,132 @@ const struct eth_dev_ops default_dev_ops = {
};
static int
+ bond_alloc ( struct rte_vdev_device * dev , uint8_t mode )
+ {
+ const char * name = rte_vdev_device_name ( dev );
+ uint8_t socket_id = dev -> device . numa_node ;
+ struct bond_dev_private * internals = NULL ;
+ struct rte_eth_dev * eth_dev = NULL ;
+ uint32_t vlan_filter_bmp_size ;
+
+ /* now do all data allocation - for eth_dev structure, dummy pci driver
+ * and internal ( private ) data
+ */
+
+ if ( name == NULL ) {
+ RTE_BOND_LOG ( ERR , "Invalid name specified" );
+ goto err ;
+ }
+
+ if ( socket_id >= number_of_sockets ()) {
+ RTE_BOND_LOG ( ERR ,
+ "Invalid socket id specified to create bonded device on." );
+ goto err ;
+ }
+
+ internals = rte_zmalloc_socket ( name , sizeof ( * internals ), 0 , socket_id );
+ if ( internals == NULL ) {
+ RTE_BOND_LOG ( ERR , "Unable to malloc internals on socket" );
+ goto err ;
+ }
+
+ /* reserve an ethdev entry */
+ eth_dev = rte_eth_dev_allocate ( name );
+ if ( eth_dev == NULL ) {
+ RTE_BOND_LOG ( ERR , "Unable to allocate rte_eth_dev" );
+ goto err ;
+ }
+
+ eth_dev -> data -> dev_private = internals ;
+ eth_dev -> data -> nb_rx_queues = ( uint16_t ) 1 ;
+ eth_dev -> data -> nb_tx_queues = ( uint16_t ) 1 ;
+
+ eth_dev -> data -> mac_addrs = rte_zmalloc_socket ( name , ETHER_ADDR_LEN , 0 ,
+ socket_id );
+ if ( eth_dev -> data -> mac_addrs == NULL ) {
+ RTE_BOND_LOG ( ERR , "Unable to malloc mac_addrs" );
+ goto err ;
+ }
+
+ eth_dev -> dev_ops = & default_dev_ops ;
+ eth_dev -> data -> dev_flags = RTE_ETH_DEV_INTR_LSC |
+ RTE_ETH_DEV_DETACHABLE ;
+ eth_dev -> driver = NULL ;
+ eth_dev -> data -> kdrv = RTE_KDRV_NONE ;
+ eth_dev -> data -> drv_name = pmd_bond_drv . driver . name ;
+ eth_dev -> data -> numa_node = socket_id ;
+
+ rte_spinlock_init ( & internals -> lock );
+
+ internals -> port_id = eth_dev -> data -> port_id ;
+ internals -> mode = BONDING_MODE_INVALID ;
+ internals -> current_primary_port = RTE_MAX_ETHPORTS + 1 ;
+ internals -> balance_xmit_policy = BALANCE_XMIT_POLICY_LAYER2 ;
+ internals -> xmit_hash = xmit_l2_hash ;
+ internals -> user_defined_mac = 0 ;
+ internals -> link_props_set = 0 ;
+
+ internals -> link_status_polling_enabled = 0 ;
+
+ internals -> link_status_polling_interval_ms =
+ DEFAULT_POLLING_INTERVAL_10_MS ;
+ internals -> link_down_delay_ms = 0 ;
+ internals -> link_up_delay_ms = 0 ;
+
+ internals -> slave_count = 0 ;
+ internals -> active_slave_count = 0 ;
+ internals -> rx_offload_capa = 0 ;
+ internals -> tx_offload_capa = 0 ;
+ internals -> candidate_max_rx_pktlen = 0 ;
+ internals -> max_rx_pktlen = 0 ;
+
+ /* Initially allow to choose any offload type */
+ internals -> flow_type_rss_offloads = ETH_RSS_PROTO_MASK ;
+
+ memset ( internals -> active_slaves , 0 , sizeof ( internals -> active_slaves ));
+ memset ( internals -> slaves , 0 , sizeof ( internals -> slaves ));
+
+ /* Set mode 4 default configuration */
+ bond_mode_8023ad_setup ( eth_dev , NULL );
+ if ( bond_ethdev_mode_set ( eth_dev , mode )) {
+ RTE_BOND_LOG ( ERR , "Failed to set bonded device %d mode too %d" ,
+ eth_dev -> data -> port_id , mode );
+ goto err ;
+ }
+
+ vlan_filter_bmp_size =
+ rte_bitmap_get_memory_footprint ( ETHER_MAX_VLAN_ID + 1 );
+ internals -> vlan_filter_bmpmem = rte_malloc ( name , vlan_filter_bmp_size ,
+ RTE_CACHE_LINE_SIZE );
+ if ( internals -> vlan_filter_bmpmem == NULL ) {
+ RTE_BOND_LOG ( ERR ,
+ "Failed to allocate vlan bitmap for bonded device %u \n " ,
+ eth_dev -> data -> port_id );
+ goto err ;
+ }
+
+ internals -> vlan_filter_bmp = rte_bitmap_init ( ETHER_MAX_VLAN_ID + 1 ,
+ internals -> vlan_filter_bmpmem , vlan_filter_bmp_size );
+ if ( internals -> vlan_filter_bmp == NULL ) {
+ RTE_BOND_LOG ( ERR ,
+ "Failed to init vlan bitmap for bonded device %u \n " ,
+ eth_dev -> data -> port_id );
+ rte_free ( internals -> vlan_filter_bmpmem );
+ goto err ;
+ }
+
+ return eth_dev -> data -> port_id ;
+
+ err :
+ rte_free ( internals );
+ if ( eth_dev != NULL ) {
+ rte_free ( eth_dev -> data -> mac_addrs );
+ rte_eth_dev_release_port ( eth_dev );
+ }
+ return -1 ;
+ }
+
+ static int
bond_probe ( struct rte_vdev_device * dev )
{
const char * name ; @@ -2238,6 +2365,9 @@ bond_probe(struct rte_vdev_device *dev)
uint8_t bonding_mode , socket_id ;
int arg_count , port_id ;
+ if ( ! dev )
+ return - EINVAL ;
+
name = rte_vdev_device_name ( dev );
RTE_LOG ( INFO , EAL , "Initializing pmd_bond for %s \n " , name );
@@ -2279,8 +2409,10 @@ bond_probe(struct rte_vdev_device *dev)
socket_id = rte_socket_id ();
}
+ dev -> device . numa_node = socket_id ;
+
/* Create link bonding eth device */
- port_id = rte_eth_bond_create ( name , bonding_mode , socket_id );
+ port_id = bond_alloc ( dev , bonding_mode );
if ( port_id < 0 ) {
RTE_LOG ( ERR , EAL , "Failed to create socket %s in mode %u on "
"socket %u. \n " , name , bonding_mode , socket_id ); @@ -2302,8 +2434,9 @@ bond_probe(struct rte_vdev_device *dev)
static int
bond_remove ( struct rte_vdev_device * dev )
{
+ struct rte_eth_dev * eth_dev ;
+ struct bond_dev_private * internals ;
const char * name ;
- int ret ;
if ( ! dev )
return - EINVAL ; @@ -2311,12 +2444,39 @@ bond_remove(struct rte_vdev_device *dev)
name = rte_vdev_device_name ( dev );
RTE_LOG ( INFO , EAL , "Uninitializing pmd_bond for %s \n " , name );
- /* free link bonding eth device */
- ret = rte_eth_bond_free ( name );
- if ( ret < 0 )
- RTE_LOG ( ERR , EAL , "Failed to free %s \n " , name );
+ /* now free all data allocation - for eth_dev structure,
+ * dummy pci driver and internal ( private ) data
+ */
- return ret ;
+ /* find an ethdev entry */
+ eth_dev = rte_eth_dev_allocated ( name );
+ if ( eth_dev == NULL )
+ return - ENODEV ;
+
+ RTE_ASSERT ( eth_dev -> device == & dev -> device );
+
+ internals = eth_dev -> data -> dev_private ;
+ if ( internals -> slave_count != 0 )
+ return - EBUSY ;
+
+ if ( eth_dev -> data -> dev_started == 1 ) {
+ bond_ethdev_stop ( eth_dev );
+ bond_ethdev_close ( eth_dev );
+ }
+
+ eth_dev -> dev_ops = NULL ;
+ eth_dev -> rx_pkt_burst = NULL ;
+ eth_dev -> tx_pkt_burst = NULL ;
+
+ internals = eth_dev -> data -> dev_private ;
+ rte_bitmap_free ( internals -> vlan_filter_bmp );
+ rte_free ( internals -> vlan_filter_bmpmem );
+ rte_free ( eth_dev -> data -> dev_private );
+ rte_free ( eth_dev -> data -> mac_addrs );
+
+ rte_eth_dev_release_port ( eth_dev );
+
+ return 0 ;
}
/* this part will resolve the slave portids after all the other pdev and vdev --
2.7.4
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/bonding/rte_eth_bond_pmd.c | 20 +++-----------------
1 file changed, 3 insertions(+), 17 deletions(-)
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index c0d08a8..3c80ff5 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -36,6 +36,7 @@
#include <rte_mbuf.h>
#include <rte_malloc.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_vdev.h>
#include <rte_tcp.h>
#include <rte_udp.h>
#include <rte_ip.h> @@ -2243,31 +2244,20 @@ bond_alloc(struct rte_vdev_device *dev, uint8_t mode)
* and internal ( private ) data
*/
- if ( name == NULL ) {
- RTE_BOND_LOG ( ERR , "Invalid name specified" );
- goto err ;
- }
-
if ( socket_id >= number_of_sockets ()) {
RTE_BOND_LOG ( ERR ,
"Invalid socket id specified to create bonded device on." );
goto err ;
}
- internals = rte_zmalloc_socket ( name , sizeof ( * internals ), 0 , socket_id );
- if ( internals == NULL ) {
- RTE_BOND_LOG ( ERR , "Unable to malloc internals on socket" );
- goto err ;
- }
-
/* reserve an ethdev entry */
- eth_dev = rte_eth_dev_allocate ( name );
+ eth_dev = rte_eth_vdev_allocate ( dev , sizeof ( * internals ));
if ( eth_dev == NULL ) {
RTE_BOND_LOG ( ERR , "Unable to allocate rte_eth_dev" );
goto err ;
}
- eth_dev -> data -> dev_private = internals ;
+ internals = eth_dev -> data -> dev_private ;
eth_dev -> data -> nb_rx_queues = ( uint16_t ) 1 ;
eth_dev -> data -> nb_tx_queues = ( uint16_t ) 1 ;
@@ -2281,10 +2271,6 @@ bond_alloc(struct rte_vdev_device *dev, uint8_t mode)
eth_dev -> dev_ops = & default_dev_ops ;
eth_dev -> data -> dev_flags = RTE_ETH_DEV_INTR_LSC |
RTE_ETH_DEV_DETACHABLE ;
- eth_dev -> driver = NULL ;
- eth_dev -> data -> kdrv = RTE_KDRV_NONE ;
- eth_dev -> data -> drv_name = pmd_bond_drv . driver . name ;
- eth_dev -> data -> numa_node = socket_id ;
rte_spinlock_init ( & internals -> lock );
--
2.7.4
This adds the following helper intended to be used by rte_pci_driver
implementations working with ethdev:
- rte_eth_dev_pci_allocate
- rte_eth_dev_pci_release
- rte_eth_dev_pci_generic_probe
- rte_eth_dev_pci_generic_remove
Signed-off-by: Jan Blunck <redacted>
---
lib/librte_ether/Makefile | 1 +
lib/librte_ether/rte_ethdev_pci.h | 151 ++++++++++++++++++++++++++++++++++++++
2 files changed, 152 insertions(+)
create mode 100644 lib/librte_ether/rte_ethdev_pci.h
diff --git a/lib/librte_ether/Makefile b/lib/librte_ether/Makefile
index 31e6ba7..a6fff5e 100644
--- a/lib/librte_ether/Makefile
+++ b/lib/librte_ether/Makefile @@ -50,6 +50,7 @@ SRCS-y += rte_flow.c
# Export include files
#
SYMLINK-y-include += rte_ethdev.h
+ SYMLINK-y-include += rte_ethdev_pci.h
SYMLINK-y-include += rte_ethdev_vdev.h
SYMLINK-y-include += rte_eth_ctrl.h
SYMLINK-y-include += rte_dev_info.h diff --git a/lib/librte_ether/rte_ethdev_pci.h b/lib/librte_ether/rte_ethdev_pci.h
new file mode 100644
index 0000000..4b728db
--- /dev/null
+++ b/lib/librte_ether/rte_ethdev_pci.h @@ -0,0 +1,151 @@
+ /*-
+ * BSD LICENSE
+ *
+ * Copyright ( c ) 2017 Brocade Communications Systems , Inc .
+ * Author : Jan Blunck < jblunck @ infradead . org >
+ *
+ * Redistribution and use in source and binary forms , with or without
+ * modification , are permitted provided that the following conditions
+ * are met :
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice , this list of conditions and the following disclaimer .
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice , this list of conditions and the following disclaimer in
+ * the documentation and / or other materials provided with the
+ * distribution .
+ * * Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission .
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT
+ * LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL ,
+ * SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT
+ * LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE ,
+ * DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT
+ * ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
+ */
+
+ #ifndef _RTE_ETHDEV_PCI_H_
+ #define _RTE_ETHDEV_PCI_H_
+
+ #include <rte_malloc.h>
+ #include <rte_pci.h>
+ #include <rte_ethdev.h>
+
+ /**
+ * @ internal
+ * Allocates a new ethdev slot for an ethernet device and returns the pointer
+ * to that slot for the driver to use .
+ *
+ * @ param dev
+ * Pointer to the PCI device
+ *
+ * @ param private_data_size
+ * Size of private data structure
+ *
+ * @ return
+ * A pointer to a rte_eth_dev or NULL if allocation failed .
+ */
+ static inline struct rte_eth_dev *
+ rte_eth_dev_pci_allocate ( struct rte_pci_device * dev , size_t private_data_size )
+ {
+ struct rte_eth_dev * eth_dev ;
+ const char * name ;
+
+ if ( ! dev )
+ return NULL ;
+
+ name = dev -> device . name ;
+
+ if ( rte_eal_process_type () == RTE_PROC_PRIMARY ) {
+ eth_dev = rte_eth_dev_allocate ( name );
+ if ( ! eth_dev )
+ return NULL ;
+
+ if ( private_data_size ) {
+ eth_dev -> data -> dev_private = rte_zmalloc_socket ( name ,
+ private_data_size , RTE_CACHE_LINE_SIZE ,
+ dev -> device . numa_node );
+ if ( ! eth_dev -> data -> dev_private ) {
+ rte_eth_dev_release_port ( eth_dev );
+ return NULL ;
+ }
+ }
+ } else {
+ eth_dev = rte_eth_dev_attach_secondary ( name );
+ if ( ! eth_dev )
+ return NULL ;
+ }
+
+ eth_dev -> device = & dev -> device ;
+ eth_dev -> driver = NULL ;
+ eth_dev -> intr_handle = & dev -> intr_handle ;
+ rte_eth_copy_pci_info ( eth_dev , dev );
+ return eth_dev ;
+ }
+
+ static inline void
+ rte_eth_dev_pci_release ( struct rte_eth_dev * eth_dev )
+ {
+ /* 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 -> data -> dev_private = NULL ;
+
+ eth_dev -> device = NULL ;
+ eth_dev -> driver = NULL ;
+ eth_dev -> intr_handle = NULL ;
+ }
+
+ typedef int ( * eth_dev_pci_callback_t )( struct rte_eth_dev * eth_dev );
+
+ static inline int
+ rte_eth_dev_pci_generic_probe ( struct rte_pci_device * pci_dev ,
+ size_t private_data_size , eth_dev_pci_callback_t dev_init )
+ {
+ struct rte_eth_dev * eth_dev ;
+ int ret ;
+
+ eth_dev = rte_eth_dev_pci_allocate ( pci_dev , private_data_size );
+ if ( ! eth_dev )
+ return - ENOMEM ;
+
+ RTE_FUNC_PTR_OR_ERR_RET ( * dev_init , - EINVAL );
+ ret = dev_init ( eth_dev );
+ if ( ret )
+ rte_eth_dev_pci_release ( eth_dev );
+
+ return ret ;
+ }
+
+ static inline int
+ rte_eth_dev_pci_generic_remove ( struct rte_pci_device * pci_dev ,
+ eth_dev_pci_callback_t dev_uninit )
+ {
+ struct rte_eth_dev * eth_dev ;
+ int ret ;
+
+ eth_dev = rte_eth_dev_allocated ( pci_dev -> device . name );
+ if ( ! eth_dev )
+ return - ENODEV ;
+
+ if ( dev_uninit ) {
+ ret = dev_uninit ( eth_dev );
+ if ( ret )
+ return ret ;
+ }
+
+ rte_eth_dev_pci_release ( eth_dev );
+ return 0 ;
+ }
+
+ #endif /* _RTE_ETHDEV_PCI_H_ */ --
2.7.4
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/virtio/virtio_ethdev.c | 34 +++++++++++++++++++++-------------
1 file changed, 21 insertions(+), 13 deletions(-)
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 4dc03b9..a600ca5 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c @@ -38,6 +38,7 @@
#include <unistd.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_memcpy.h>
#include <rte_string_fns.h>
#include <rte_memzone.h> @@ -1572,19 +1573,26 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
return 0 ;
}
- static struct eth_driver rte_virtio_pmd = {
- . pci_drv = {
- . driver = {
- . name = "net_virtio" ,
- },
- . id_table = pci_id_virtio_map ,
- . drv_flags = 0 ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
+ static int eth_virtio_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev , sizeof ( struct virtio_hw ),
+ eth_virtio_dev_init );
+ }
+
+ static int eth_virtio_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , eth_virtio_dev_uninit );
+ }
+
+ static struct rte_pci_driver rte_virtio_pmd = {
+ . driver = {
+ . name = "net_virtio" ,
},
- . eth_dev_init = eth_virtio_dev_init ,
- . eth_dev_uninit = eth_virtio_dev_uninit ,
- . dev_private_size = sizeof ( struct virtio_hw ),
+ . id_table = pci_id_virtio_map ,
+ . drv_flags = 0 ,
+ . probe = eth_virtio_pci_probe ,
+ . remove = eth_virtio_pci_remove ,
};
RTE_INIT ( rte_virtio_pmd_init ); @@ -1596,7 +1604,7 @@ rte_virtio_pmd_init(void)
return ;
}
- rte_eal_pci_register ( & rte_virtio_pmd . pci_drv );
+ rte_eal_pci_register ( & rte_virtio_pmd );
}
/* --
2.7.4
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/bnx2x/bnx2x_ethdev.c | 64 +++++++++++++++++++++++++++-------------
1 file changed, 44 insertions(+), 20 deletions(-)
diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index a0b0dfa..e295951 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c @@ -12,6 +12,7 @@
#include "bnx2x_rxtx.h"
#include <rte_dev.h>
+ #include <rte_ethdev_pci.h>
/*
* The set of PCI devices this driver supports @@ -626,34 +627,57 @@ eth_bnx2xvf_dev_init(struct rte_eth_dev *eth_dev)
return bnx2x_common_dev_init ( eth_dev , 1 );
}
- static struct eth_driver rte_bnx2x_pmd = {
- . pci_drv = {
- . id_table = pci_id_bnx2x_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_bnx2x_dev_init ,
- . dev_private_size = sizeof ( struct bnx2x_softc ),
+ static struct rte_pci_driver rte_bnx2x_pmd ;
+ static struct rte_pci_driver rte_bnx2xvf_pmd ;
+
+ static int eth_bnx2x_pci_probe ( struct rte_pci_driver * pci_drv ,
+ struct rte_pci_device * pci_dev )
+ {
+ struct rte_eth_dev * eth_dev ;
+ int ret ;
+
+ eth_dev = rte_eth_dev_pci_allocate ( pci_dev , sizeof ( struct bnx2x_softc ));
+ if ( ! eth_dev )
+ return - ENOMEM ;
+
+ if ( pci_drv == & rte_bnx2x_pmd )
+ ret = eth_bnx2x_dev_init ( eth_dev );
+ else if ( pci_drv == & rte_bnx2xvf_pmd )
+ ret = eth_bnx2xvf_dev_init ( eth_dev );
+ else
+ ret = - EINVAL ;
+
+ if ( ret )
+ rte_eth_dev_pci_release ( eth_dev );
+
+ return ret ;
+ }
+
+ static int eth_bnx2x_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , NULL );
+ }
+
+ static struct rte_pci_driver rte_bnx2x_pmd = {
+ . id_table = pci_id_bnx2x_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
+ . probe = eth_bnx2x_pci_probe ,
+ . remove = eth_bnx2x_pci_remove ,
};
/*
* virtual function driver struct
*/
- static struct eth_driver rte_bnx2xvf_pmd = {
- . pci_drv = {
- . id_table = pci_id_bnx2xvf_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_bnx2xvf_dev_init ,
- . dev_private_size = sizeof ( struct bnx2x_softc ),
+ static struct rte_pci_driver rte_bnx2xvf_pmd = {
+ . id_table = pci_id_bnx2xvf_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING ,
+ . probe = eth_bnx2x_pci_probe ,
+ . remove = eth_bnx2x_pci_remove ,
};
- RTE_PMD_REGISTER_PCI ( net_bnx2x , rte_bnx2x_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_bnx2x , rte_bnx2x_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_bnx2x , pci_id_bnx2x_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_bnx2x , "* igb_uio | uio_pci_generic | vfio" );
- RTE_PMD_REGISTER_PCI ( net_bnx2xvf , rte_bnx2xvf_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_bnx2xvf , rte_bnx2xvf_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_bnx2xvf , pci_id_bnx2xvf_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_bnx2xvf , "* igb_uio | vfio" ); --
2.7.4
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/bnxt/bnxt_ethdev.c | 36 +++++++++++++++++++++++-------------
1 file changed, 23 insertions(+), 13 deletions(-)
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 6167443..5dc3ff0 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -36,6 +36,7 @@
#include <rte_dev.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_malloc.h>
#include <rte_cycles.h>
@@ -1075,6 +1076,8 @@ static int bnxt_init_board(struct rte_eth_dev *eth_dev)
return rc ;
}
+ static int bnxt_dev_uninit ( struct rte_eth_dev * eth_dev );
+
static int
bnxt_dev_init ( struct rte_eth_dev * eth_dev )
{ @@ -1167,7 +1170,7 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
return 0 ;
error_free :
- eth_dev -> driver -> eth_dev_uninit ( eth_dev );
+ bnxt_dev_uninit ( eth_dev );
error :
return rc ;
} @@ -1196,19 +1199,26 @@ bnxt_dev_uninit(struct rte_eth_dev *eth_dev) {
return rc ;
}
- static struct eth_driver bnxt_rte_pmd = {
- . pci_drv = {
- . id_table = bnxt_pci_id_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING |
- RTE_PCI_DRV_INTR_LSC ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove
- },
- . eth_dev_init = bnxt_dev_init ,
- . eth_dev_uninit = bnxt_dev_uninit ,
- . dev_private_size = sizeof ( struct bnxt ),
+ static int bnxt_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev , sizeof ( struct bnxt ),
+ bnxt_dev_init );
+ }
+
+ static int bnxt_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , bnxt_dev_uninit );
+ }
+
+ static struct rte_pci_driver bnxt_rte_pmd = {
+ . id_table = bnxt_pci_id_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING |
+ RTE_PCI_DRV_INTR_LSC ,
+ . probe = bnxt_pci_probe ,
+ . remove = bnxt_pci_remove ,
};
- RTE_PMD_REGISTER_PCI ( net_bnxt , bnxt_rte_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_bnxt , bnxt_rte_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_bnxt , bnxt_pci_id_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_bnxt , "* igb_uio | uio_pci_generic | vfio" ); --
2.7.4
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/cxgbe/cxgbe_ethdev.c | 29 +++++++++++++++++++----------
drivers/net/cxgbe/sge.c | 6 +++---
2 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 4d543a7..34fed84 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c @@ -57,6 +57,7 @@
#include <rte_alarm.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_atomic.h>
#include <rte_malloc.h>
#include <rte_random.h> @@ -1039,17 +1040,25 @@ static int eth_cxgbe_dev_init(struct rte_eth_dev *eth_dev)
return err ;
}
- static struct eth_driver rte_cxgbe_pmd = {
- . pci_drv = {
- . id_table = cxgb4_pci_tbl ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_cxgbe_dev_init ,
- . dev_private_size = sizeof ( struct port_info ),
+ static int eth_cxgbe_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct port_info ), eth_cxgbe_dev_init );
+ }
+
+ static int eth_cxgbe_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , NULL );
+ }
+
+ static struct rte_pci_driver rte_cxgbe_pmd = {
+ . id_table = cxgb4_pci_tbl ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
+ . probe = eth_cxgbe_pci_probe ,
+ . remove = eth_cxgbe_pci_remove ,
};
- RTE_PMD_REGISTER_PCI ( net_cxgbe , rte_cxgbe_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_cxgbe , rte_cxgbe_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_cxgbe , cxgb4_pci_tbl );
RTE_PMD_REGISTER_KMOD_DEP ( net_cxgbe , "* igb_uio | uio_pci_generic | vfio" ); diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
index 37b6090..2f9e12c 100644
--- a/drivers/net/cxgbe/sge.c
+++ b/drivers/net/cxgbe/sge.c @@ -1641,7 +1641,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
iq -> size = cxgbe_roundup ( iq -> size , 16 );
snprintf ( z_name , sizeof ( z_name ), "%s_%s_%d_%d" ,
- eth_dev -> driver -> pci_drv . driver . name ,
+ eth_dev -> data -> drv_name ,
fwevtq ? "fwq_ring" : "rx_ring" ,
eth_dev -> data -> port_id , queue_id );
snprintf ( z_name_sw , sizeof ( z_name_sw ), "%s_sw_ring" , z_name ); @@ -1694,7 +1694,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
fl -> size = cxgbe_roundup ( fl -> size , 8 );
snprintf ( z_name , sizeof ( z_name ), "%s_%s_%d_%d" ,
- eth_dev -> driver -> pci_drv . driver . name ,
+ eth_dev -> data -> drv_name ,
fwevtq ? "fwq_ring" : "fl_ring" ,
eth_dev -> data -> port_id , queue_id );
snprintf ( z_name_sw , sizeof ( z_name_sw ), "%s_sw_ring" , z_name ); @@ -1890,7 +1890,7 @@ int t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq,
nentries = txq -> q . size + s -> stat_len / sizeof ( struct tx_desc );
snprintf ( z_name , sizeof ( z_name ), "%s_%s_%d_%d" ,
- eth_dev -> driver -> pci_drv . driver . name , "tx_ring" ,
+ eth_dev -> data -> drv_name , "tx_ring" ,
eth_dev -> data -> port_id , queue_id );
snprintf ( z_name_sw , sizeof ( z_name_sw ), "%s_sw_ring" , z_name );
--
2.7.4
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/e1000/em_ethdev.c | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index 4066ef9..39a62a3 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c @@ -45,6 +45,7 @@
#include <rte_pci.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_memory.h>
#include <rte_memzone.h>
#include <rte_eal.h> @@ -416,16 +417,23 @@ eth_em_dev_uninit(struct rte_eth_dev *eth_dev)
return 0 ;
}
- static struct eth_driver rte_em_pmd = {
- . pci_drv = {
- . id_table = pci_id_em_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_em_dev_init ,
- . eth_dev_uninit = eth_em_dev_uninit ,
- . dev_private_size = sizeof ( struct e1000_adapter ),
+ static int eth_em_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct e1000_adapter ), eth_em_dev_init );
+ }
+
+ static int eth_em_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , eth_em_dev_uninit );
+ }
+
+ static struct rte_pci_driver rte_em_pmd = {
+ . id_table = pci_id_em_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
+ . probe = eth_em_pci_probe ,
+ . remove = eth_em_pci_remove ,
};
static int @@ -1847,6 +1855,6 @@ eth_em_set_mc_addr_list(struct rte_eth_dev *dev,
return 0 ;
}
- RTE_PMD_REGISTER_PCI ( net_e1000_em , rte_em_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_e1000_em , rte_em_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_e1000_em , pci_id_em_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_e1000_em , "* igb_uio | uio_pci_generic | vfio" ); --
2.7.4
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/e1000/igb_ethdev.c | 60 ++++++++++++++++++++++++++----------------
1 file changed, 38 insertions(+), 22 deletions(-)
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index a112b38..1a162cc 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c @@ -45,6 +45,7 @@
#include <rte_pci.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_memory.h>
#include <rte_memzone.h>
#include <rte_eal.h> @@ -1087,31 +1088,46 @@ eth_igbvf_dev_uninit(struct rte_eth_dev *eth_dev)
return 0 ;
}
- static struct eth_driver rte_igb_pmd = {
- . pci_drv = {
- . id_table = pci_id_igb_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_igb_dev_init ,
- . eth_dev_uninit = eth_igb_dev_uninit ,
- . dev_private_size = sizeof ( struct e1000_adapter ),
+ static int eth_igb_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct e1000_adapter ), eth_igb_dev_init );
+ }
+
+ static int eth_igb_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , eth_igb_dev_uninit );
+ }
+
+ static struct rte_pci_driver rte_igb_pmd = {
+ . id_table = pci_id_igb_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
+ . probe = eth_igb_pci_probe ,
+ . remove = eth_igb_pci_remove ,
};
+
+ static int eth_igbvf_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct e1000_adapter ), eth_igbvf_dev_init );
+ }
+
+ static int eth_igbvf_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , eth_igbvf_dev_uninit );
+ }
+
/*
* virtual function driver struct
*/
- static struct eth_driver rte_igbvf_pmd = {
- . pci_drv = {
- . id_table = pci_id_igbvf_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_igbvf_dev_init ,
- . eth_dev_uninit = eth_igbvf_dev_uninit ,
- . dev_private_size = sizeof ( struct e1000_adapter ),
+ static struct rte_pci_driver rte_igbvf_pmd = {
+ . id_table = pci_id_igbvf_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING ,
+ . probe = eth_igbvf_pci_probe ,
+ . remove = eth_igbvf_pci_remove ,
};
static void @@ -5309,9 +5325,9 @@ eth_igb_configure_msix_intr(struct rte_eth_dev *dev)
E1000_WRITE_FLUSH ( hw );
}
- RTE_PMD_REGISTER_PCI ( net_e1000_igb , rte_igb_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_e1000_igb , rte_igb_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_e1000_igb , pci_id_igb_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_e1000_igb , "* igb_uio | uio_pci_generic | vfio" );
- RTE_PMD_REGISTER_PCI ( net_e1000_igb_vf , rte_igbvf_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_e1000_igb_vf , rte_igbvf_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_e1000_igb_vf , pci_id_igbvf_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_e1000_igb_vf , "* igb_uio | vfio" ); --
2.7.4
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/ena/ena_ethdev.c | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index b5e6db6..41573ae 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c @@ -33,6 +33,7 @@
#include <rte_ether.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_tcp.h>
#include <rte_atomic.h>
#include <rte_dev.h> @@ -1776,17 +1777,25 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
return sent_idx ;
}
- static struct eth_driver rte_ena_pmd = {
- . pci_drv = {
- . id_table = pci_id_ena_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_ena_dev_init ,
- . dev_private_size = sizeof ( struct ena_adapter ),
+ static int eth_ena_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct ena_adapter ), eth_ena_dev_init );
+ }
+
+ static int eth_ena_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , NULL );
+ }
+
+ static struct rte_pci_driver rte_ena_pmd = {
+ . id_table = pci_id_ena_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING ,
+ . probe = eth_ena_pci_probe ,
+ . remove = eth_ena_pci_remove ,
};
- RTE_PMD_REGISTER_PCI ( net_ena , rte_ena_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_ena , rte_ena_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_ena , pci_id_ena_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_ena , "* igb_uio | uio_pci_generic | vfio" ); --
2.7.4
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/enic/enic_ethdev.c | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c
index bffa870..57f71c7 100644
--- a/drivers/net/enic/enic_ethdev.c
+++ b/drivers/net/enic/enic_ethdev.c @@ -38,6 +38,7 @@
#include <rte_dev.h>
#include <rte_pci.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_string_fns.h>
#include "vnic_intr.h" @@ -634,17 +635,25 @@ static int eth_enicpmd_dev_init(struct rte_eth_dev *eth_dev)
return enic_probe ( enic );
}
- static struct eth_driver rte_enic_pmd = {
- . pci_drv = {
- . id_table = pci_id_enic_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_enicpmd_dev_init ,
- . dev_private_size = sizeof ( struct enic ),
+ static int eth_enic_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev , sizeof ( struct enic ),
+ eth_enicpmd_dev_init );
+ }
+
+ static int eth_enic_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , NULL );
+ }
+
+ static struct rte_pci_driver rte_enic_pmd = {
+ . id_table = pci_id_enic_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
+ . probe = eth_enic_pci_probe ,
+ . remove = eth_enic_pci_remove ,
};
- RTE_PMD_REGISTER_PCI ( net_enic , rte_enic_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_enic , rte_enic_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_enic , pci_id_enic_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_enic , "* igb_uio | uio_pci_generic | vfio" ); --
2.7.4
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/fm10k/fm10k_ethdev.c | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index c4fe746..5bb0426 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -32,6 +32,7 @@
*/
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_malloc.h>
#include <rte_memzone.h>
#include <rte_string_fns.h> @@ -3067,6 +3068,18 @@ eth_fm10k_dev_uninit(struct rte_eth_dev *dev)
return 0 ;
}
+ static int eth_fm10k_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct fm10k_adapter ), eth_fm10k_dev_init );
+ }
+
+ static int eth_fm10k_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , eth_fm10k_dev_uninit );
+ }
+
/*
* The set of PCI devices this driver supports . This driver will enable both PF
* and SRIOV - VF devices . @@ -3078,18 +3091,13 @@ static const struct rte_pci_id pci_id_fm10k_map[] = {
{ . vendor_id = 0 , /* sentinel */ },
};
- static struct eth_driver rte_pmd_fm10k = {
- . pci_drv = {
- . id_table = pci_id_fm10k_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_fm10k_dev_init ,
- . eth_dev_uninit = eth_fm10k_dev_uninit ,
- . dev_private_size = sizeof ( struct fm10k_adapter ),
+ static struct rte_pci_driver rte_pmd_fm10k = {
+ . id_table = pci_id_fm10k_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
+ . probe = eth_fm10k_pci_probe ,
+ . remove = eth_fm10k_pci_remove ,
};
- RTE_PMD_REGISTER_PCI ( net_fm10k , rte_pmd_fm10k . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_fm10k , rte_pmd_fm10k );
RTE_PMD_REGISTER_PCI_TABLE ( net_fm10k , pci_id_fm10k_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_fm10k , "* igb_uio | uio_pci_generic | vfio" ); --
2.7.4
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/i40e/i40e_ethdev.c | 36 ++++++++++++++++++++++--------------
drivers/net/i40e/i40e_fdir.c | 2 +-
2 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 303027b..8d4e509 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c @@ -44,6 +44,7 @@
#include <rte_pci.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_memzone.h>
#include <rte_malloc.h>
#include <rte_memcpy.h> @@ -627,16 +628,23 @@ static const struct rte_i40e_xstats_name_off rte_i40e_txq_prio_strings[] = {
#define I40E_NB_TXQ_PRIO_XSTATS (sizeof(rte_i40e_txq_prio_strings) / \
sizeof ( rte_i40e_txq_prio_strings [ 0 ]))
- static struct eth_driver rte_i40e_pmd = {
- . pci_drv = {
- . id_table = pci_id_i40e_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_i40e_dev_init ,
- . eth_dev_uninit = eth_i40e_dev_uninit ,
- . dev_private_size = sizeof ( struct i40e_adapter ),
+ static int eth_i40e_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct i40e_adapter ), eth_i40e_dev_init );
+ }
+
+ static int eth_i40e_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , eth_i40e_dev_uninit );
+ }
+
+ static struct rte_pci_driver rte_i40e_pmd = {
+ . id_table = pci_id_i40e_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
+ . probe = eth_i40e_pci_probe ,
+ . remove = eth_i40e_pci_remove ,
};
static inline int @@ -667,7 +675,7 @@ rte_i40e_dev_atomic_write_link_status(struct rte_eth_dev *dev,
return 0 ;
}
- RTE_PMD_REGISTER_PCI ( net_i40e , rte_i40e_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_i40e , rte_i40e_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_i40e , pci_id_i40e_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_i40e , "* igb_uio | uio_pci_generic | vfio" );
@@ -10282,10 +10290,10 @@ i40e_filter_restore(struct i40e_pf *pf)
}
static bool
- is_device_supported ( struct rte_eth_dev * dev , struct eth_driver * drv )
+ is_device_supported ( struct rte_eth_dev * dev , struct rte_pci_driver * drv )
{
- if ( strcmp ( dev -> driver -> pci_drv . driver . name ,
- drv -> pci_drv . driver . name ))
+ if ( strcmp ( dev -> data -> drv_name ,
+ drv -> driver . name ))
return false ;
return true ; diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index 0700253..35751d8 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c @@ -257,7 +257,7 @@ i40e_fdir_setup(struct i40e_pf *pf)
/* reserve memory for the fdir programming packet */
snprintf ( z_name , sizeof ( z_name ), "%s_%s_%d" ,
- eth_dev -> driver -> pci_drv . driver . name ,
+ eth_dev -> data -> drv_name ,
I40E_FDIR_MZ_NAME ,
eth_dev -> data -> port_id );
mz = i40e_memzone_reserve ( z_name , I40E_FDIR_PKT_LEN , SOCKET_ID_ANY ); --
2.7.4
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/i40e/i40e_ethdev_vf.c | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 55fd344..2a10ad5 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -55,6 +55,7 @@
#include <rte_alarm.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_atomic.h>
#include <rte_malloc.h>
#include <rte_dev.h> @@ -1542,22 +1543,30 @@ i40evf_dev_uninit(struct rte_eth_dev *eth_dev)
return 0 ;
}
+
+ static int eth_i40evf_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct i40e_adapter ), i40evf_dev_init );
+ }
+
+ static int eth_i40evf_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , i40evf_dev_uninit );
+ }
+
/*
* virtual function driver struct
*/
- static struct eth_driver rte_i40evf_pmd = {
- . pci_drv = {
- . id_table = pci_id_i40evf_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = i40evf_dev_init ,
- . eth_dev_uninit = i40evf_dev_uninit ,
- . dev_private_size = sizeof ( struct i40e_adapter ),
+ static struct rte_pci_driver rte_i40evf_pmd = {
+ . id_table = pci_id_i40evf_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING ,
+ . probe = eth_i40evf_pci_probe ,
+ . remove = eth_i40evf_pci_remove ,
};
- RTE_PMD_REGISTER_PCI ( net_i40e_vf , rte_i40evf_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_i40e_vf , rte_i40evf_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_i40e_vf , pci_id_i40evf_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_i40e_vf , "* igb_uio | vfio" );
--
2.7.4
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/ixgbe/ixgbe_ethdev.c | 66 ++++++++++++++++++++++++----------------
1 file changed, 40 insertions(+), 26 deletions(-)
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 7169007..de5e3c2 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -56,6 +56,7 @@
#include <rte_alarm.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_atomic.h>
#include <rte_malloc.h>
#include <rte_random.h> @@ -254,7 +255,7 @@ static void ixgbe_set_default_mac_addr(struct rte_eth_dev *dev,
struct ether_addr * mac_addr );
static void ixgbe_dcb_init ( struct ixgbe_hw * hw , struct ixgbe_dcb_config * dcb_config );
static bool is_device_supported ( struct rte_eth_dev * dev ,
- struct eth_driver * drv );
+ struct rte_pci_driver * drv );
/* For Virtual Function support */
static int eth_ixgbevf_dev_init ( struct rte_eth_dev * eth_dev ); @@ -1767,31 +1768,45 @@ eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev)
return 0 ;
}
- static struct eth_driver rte_ixgbe_pmd = {
- . pci_drv = {
- . id_table = pci_id_ixgbe_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_ixgbe_dev_init ,
- . eth_dev_uninit = eth_ixgbe_dev_uninit ,
- . dev_private_size = sizeof ( struct ixgbe_adapter ),
+ static int eth_ixgbe_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct ixgbe_adapter ), eth_ixgbe_dev_init );
+ }
+
+ static int eth_ixgbe_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , eth_ixgbe_dev_uninit );
+ }
+
+ static struct rte_pci_driver rte_ixgbe_pmd = {
+ . id_table = pci_id_ixgbe_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
+ . probe = eth_ixgbe_pci_probe ,
+ . remove = eth_ixgbe_pci_remove ,
};
+ static int eth_ixgbevf_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct ixgbe_adapter ), eth_ixgbevf_dev_init );
+ }
+
+ static int eth_ixgbevf_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , eth_ixgbevf_dev_uninit );
+ }
+
/*
* virtual function driver struct
*/
- static struct eth_driver rte_ixgbevf_pmd = {
- . pci_drv = {
- . id_table = pci_id_ixgbevf_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_ixgbevf_dev_init ,
- . eth_dev_uninit = eth_ixgbevf_dev_uninit ,
- . dev_private_size = sizeof ( struct ixgbe_adapter ),
+ static struct rte_pci_driver rte_ixgbevf_pmd = {
+ . id_table = pci_id_ixgbevf_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING ,
+ . probe = eth_ixgbevf_pci_probe ,
+ . remove = eth_ixgbevf_pci_remove ,
};
static int @@ -4382,10 +4397,9 @@ ixgbe_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
}
static bool
- is_device_supported ( struct rte_eth_dev * dev , struct eth_driver * drv )
+ is_device_supported ( struct rte_eth_dev * dev , struct rte_pci_driver * drv )
{
- if ( strcmp ( dev -> driver -> pci_drv . driver . name ,
- drv -> pci_drv . driver . name ))
+ if ( strcmp ( dev -> data -> drv_name , drv -> driver . name ))
return false ;
return true ; @@ -8682,9 +8696,9 @@ ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev)
return 0 ;
}
- RTE_PMD_REGISTER_PCI ( net_ixgbe , rte_ixgbe_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_ixgbe , rte_ixgbe_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_ixgbe , pci_id_ixgbe_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_ixgbe , "* igb_uio | uio_pci_generic | vfio" );
- RTE_PMD_REGISTER_PCI ( net_ixgbe_vf , rte_ixgbevf_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_ixgbe_vf , rte_ixgbevf_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_ixgbe_vf , pci_id_ixgbevf_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_ixgbe_vf , "* igb_uio | vfio" ); --
2.7.4
The eth_driver concept is unused in the mlx drivers so don't reference it.
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/mlx4/mlx4.c | 17 +++++++----------
drivers/net/mlx5/mlx5.c | 19 ++++++++-----------
2 files changed, 15 insertions(+), 21 deletions(-)
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index 79efaaa..31ee7e4 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c @@ -5510,7 +5510,7 @@ priv_dev_interrupt_handler_install(struct priv *priv, struct rte_eth_dev *dev)
}
}
- static struct eth_driver mlx4_driver ;
+ static struct rte_pci_driver mlx4_driver ;
/**
* DPDK callback to register a PCI device . @@ -5889,16 +5889,13 @@ static const struct rte_pci_id mlx4_pci_id_map[] = {
}
};
- static struct eth_driver mlx4_driver = {
- . pci_drv = {
- . driver = {
- . name = MLX4_DRIVER_NAME
- },
- . id_table = mlx4_pci_id_map ,
- . probe = mlx4_pci_probe ,
- . drv_flags = RTE_PCI_DRV_INTR_LSC ,
+ static struct rte_pci_driver mlx4_driver = {
+ . driver = {
+ . name = MLX4_DRIVER_NAME
},
- . dev_private_size = sizeof ( struct priv )
+ . id_table = mlx4_pci_id_map ,
+ . probe = mlx4_pci_probe ,
+ . drv_flags = RTE_PCI_DRV_INTR_LSC ,
};
/** diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index d4bd469..74a45f6 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c @@ -343,7 +343,7 @@ mlx5_args(struct priv *priv, struct rte_devargs *devargs)
return 0 ;
}
- static struct eth_driver mlx5_driver ;
+ static struct rte_pci_driver mlx5_driver ;
/**
* DPDK callback to register a PCI device . @@ -373,7 +373,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
int i ;
( void ) pci_drv ;
- assert ( pci_drv == & mlx5_driver . pci_drv );
+ assert ( pci_drv == & mlx5_driver );
/* Get mlx5_dev[] index. */
idx = mlx5_dev_idx ( & pci_dev -> addr );
if ( idx == -1 ) { @@ -761,16 +761,13 @@ static const struct rte_pci_id mlx5_pci_id_map[] = {
}
};
- static struct eth_driver mlx5_driver = {
- . pci_drv = {
- . driver = {
- . name = MLX5_DRIVER_NAME
- },
- . id_table = mlx5_pci_id_map ,
- . probe = mlx5_pci_probe ,
- . drv_flags = RTE_PCI_DRV_INTR_LSC ,
+ static struct rte_pci_driver mlx5_driver = {
+ . driver = {
+ . name = MLX5_DRIVER_NAME
},
- . dev_private_size = sizeof ( struct priv )
+ . id_table = mlx5_pci_id_map ,
+ . probe = mlx5_pci_probe ,
+ . drv_flags = RTE_PCI_DRV_INTR_LSC ,
};
/** --
2.7.4
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/nfp/nfp_net.c | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index b9dfe80..4cc003e 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c @@ -46,6 +46,7 @@
#include <rte_log.h>
#include <rte_debug.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_dev.h>
#include <rte_ether.h>
#include <rte_malloc.h> @@ -2579,18 +2580,26 @@ static const struct rte_pci_id pci_id_nfp_net_map[] = {
},
};
- static struct eth_driver rte_nfp_net_pmd = {
- . pci_drv = {
- . id_table = pci_id_nfp_net_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = nfp_net_init ,
- . dev_private_size = sizeof ( struct nfp_net_adapter ),
+ static int eth_nfp_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct nfp_net_adapter ), nfp_net_init );
+ }
+
+ static int eth_nfp_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , NULL );
+ }
+
+ static struct rte_pci_driver rte_nfp_net_pmd = {
+ . id_table = pci_id_nfp_net_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
+ . probe = eth_nfp_pci_probe ,
+ . remove = eth_nfp_pci_remove ,
};
- RTE_PMD_REGISTER_PCI ( net_nfp , rte_nfp_net_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_nfp , rte_nfp_net_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_nfp , pci_id_nfp_net_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_nfp , "* igb_uio | uio_pci_generic | vfio" );
--
2.7.4
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/qede/qede_ethdev.c | 60 +++++++++++++++++++++++++-----------------
drivers/net/qede/qede_ethdev.h | 1 +
2 files changed, 37 insertions(+), 24 deletions(-)
diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index 0494dbd..8dfddf0 100644
--- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c @@ -2337,35 +2337,47 @@ static const struct rte_pci_id pci_id_qede_map[] = {
{. vendor_id = 0 ,}
};
- static struct eth_driver rte_qedevf_pmd = {
- . pci_drv = {
- . id_table = pci_id_qedevf_map ,
- . drv_flags =
- RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = qedevf_eth_dev_init ,
- . eth_dev_uninit = qedevf_eth_dev_uninit ,
- . dev_private_size = sizeof ( struct qede_dev ),
+ static int qedevf_eth_dev_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct qede_dev ), qedevf_eth_dev_init );
+ }
+
+ static int qedevf_eth_dev_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , qedevf_eth_dev_uninit );
+ }
+
+ static struct rte_pci_driver rte_qedevf_pmd = {
+ . id_table = pci_id_qedevf_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
+ . probe = qedevf_eth_dev_pci_probe ,
+ . remove = qedevf_eth_dev_pci_remove ,
};
- static struct eth_driver rte_qede_pmd = {
- . pci_drv = {
- . id_table = pci_id_qede_map ,
- . drv_flags =
- RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = qede_eth_dev_init ,
- . eth_dev_uninit = qede_eth_dev_uninit ,
- . dev_private_size = sizeof ( struct qede_dev ),
+ static int qede_eth_dev_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct qede_dev ), qede_eth_dev_init );
+ }
+
+ static int qede_eth_dev_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , qede_eth_dev_uninit );
+ }
+
+ static struct rte_pci_driver rte_qede_pmd = {
+ . id_table = pci_id_qede_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
+ . probe = qede_eth_dev_pci_probe ,
+ . remove = qede_eth_dev_pci_remove ,
};
- RTE_PMD_REGISTER_PCI ( net_qede , rte_qede_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_qede , rte_qede_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_qede , pci_id_qede_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_qede , "* igb_uio | uio_pci_generic | vfio" );
- RTE_PMD_REGISTER_PCI ( net_qede_vf , rte_qedevf_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_qede_vf , rte_qedevf_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_qede_vf , pci_id_qedevf_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_qede_vf , "* igb_uio | vfio" ); diff --git a/drivers/net/qede/qede_ethdev.h b/drivers/net/qede/qede_ethdev.h
index be54f31..0fde8ec 100644
--- a/drivers/net/qede/qede_ethdev.h
+++ b/drivers/net/qede/qede_ethdev.h @@ -14,6 +14,7 @@
#include <rte_ether.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_dev.h>
#include <rte_ip.h>
--
2.7.4
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/sfc/sfc_ethdev.c | 34 +++++++++++++++++++++-------------
1 file changed, 21 insertions(+), 13 deletions(-)
diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 71587fb..ef8970d 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c @@ -29,6 +29,7 @@
#include <rte_dev.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_pci.h>
#include "efx.h" @@ -1340,21 +1341,28 @@ static const struct rte_pci_id pci_id_sfc_efx_map[] = {
{ . vendor_id = 0 /* sentinel */ }
};
- static struct eth_driver sfc_efx_pmd = {
- . pci_drv = {
- . id_table = pci_id_sfc_efx_map ,
- . drv_flags =
- RTE_PCI_DRV_INTR_LSC |
- RTE_PCI_DRV_NEED_MAPPING ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = sfc_eth_dev_init ,
- . eth_dev_uninit = sfc_eth_dev_uninit ,
- . dev_private_size = sizeof ( struct sfc_adapter ),
+ static int sfc_eth_dev_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct sfc_adapter ), sfc_eth_dev_init );
+ }
+
+ static int sfc_eth_dev_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , sfc_eth_dev_uninit );
+ }
+
+ static struct rte_pci_driver sfc_efx_pmd = {
+ . id_table = pci_id_sfc_efx_map ,
+ . drv_flags =
+ RTE_PCI_DRV_INTR_LSC |
+ RTE_PCI_DRV_NEED_MAPPING ,
+ . probe = sfc_eth_dev_pci_probe ,
+ . remove = sfc_eth_dev_pci_remove ,
};
- RTE_PMD_REGISTER_PCI ( net_sfc_efx , sfc_efx_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_sfc_efx , sfc_efx_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_sfc_efx , pci_id_sfc_efx_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_sfc_efx , "* igb_uio | uio_pci_generic | vfio" );
RTE_PMD_REGISTER_PARAM_STRING ( net_sfc_efx , --
2.7.4
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/szedata2/rte_eth_szedata2.c | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c
index fe7a6b3..54212b7 100644
--- a/drivers/net/szedata2/rte_eth_szedata2.c
+++ b/drivers/net/szedata2/rte_eth_szedata2.c @@ -45,6 +45,7 @@
#include <rte_mbuf.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_malloc.h>
#include <rte_memcpy.h>
#include <rte_kvargs.h> @@ -1587,18 +1588,26 @@ static const struct rte_pci_id rte_szedata2_pci_id_table[] = {
}
};
- static struct eth_driver szedata2_eth_driver = {
- . pci_drv = {
- . id_table = rte_szedata2_pci_id_table ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = rte_szedata2_eth_dev_init ,
- . eth_dev_uninit = rte_szedata2_eth_dev_uninit ,
- . dev_private_size = sizeof ( struct pmd_internals ),
+ static int szedata2_eth_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct pmd_internals ), rte_szedata2_eth_dev_init );
+ }
+
+ static int szedata2_eth_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev ,
+ rte_szedata2_eth_dev_uninit );
+ }
+
+ static struct rte_pci_driver szedata2_eth_driver = {
+ . id_table = rte_szedata2_pci_id_table ,
+ . probe = szedata2_eth_pci_probe ,
+ . remove = szedata2_eth_pci_remove ,
};
- RTE_PMD_REGISTER_PCI ( RTE_SZEDATA2_DRIVER_NAME , szedata2_eth_driver . pci_drv );
+ RTE_PMD_REGISTER_PCI ( RTE_SZEDATA2_DRIVER_NAME , szedata2_eth_driver );
RTE_PMD_REGISTER_PCI_TABLE ( RTE_SZEDATA2_DRIVER_NAME , rte_szedata2_pci_id_table );
RTE_PMD_REGISTER_KMOD_DEP ( RTE_SZEDATA2_DRIVER_NAME ,
"* combo6core & combov3 & szedata2 & szedata2_cv3" ); --
2.7.4
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/thunderx/nicvf_ethdev.c | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c
index 1060319..fa17f10 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c @@ -54,6 +54,7 @@
#include <rte_eal.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_interrupts.h>
#include <rte_log.h>
#include <rte_memory.h> @@ -2111,17 +2112,25 @@ static const struct rte_pci_id pci_id_nicvf_map[] = {
},
};
- static struct eth_driver rte_nicvf_pmd = {
- . pci_drv = {
- . id_table = pci_id_nicvf_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = nicvf_eth_dev_init ,
- . dev_private_size = sizeof ( struct nicvf ),
+ static int nicvf_eth_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev , sizeof ( struct nicvf ),
+ nicvf_eth_dev_init );
+ }
+
+ static int nicvf_eth_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , NULL );
+ }
+
+ static struct rte_pci_driver rte_nicvf_pmd = {
+ . id_table = pci_id_nicvf_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
+ . probe = nicvf_eth_pci_probe ,
+ . remove = nicvf_eth_pci_remove ,
};
- RTE_PMD_REGISTER_PCI ( net_thunderx , rte_nicvf_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_thunderx , rte_nicvf_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_thunderx , pci_id_nicvf_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_thunderx , "* igb_uio | uio_pci_generic | vfio" ); --
2.7.4
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/vmxnet3/vmxnet3_ethdev.c | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c
index b7b5377..9e6fffa 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c @@ -56,6 +56,7 @@
#include <rte_alarm.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_atomic.h>
#include <rte_string_fns.h>
#include <rte_malloc.h> @@ -338,16 +339,23 @@ eth_vmxnet3_dev_uninit(struct rte_eth_dev *eth_dev)
return 0 ;
}
- static struct eth_driver rte_vmxnet3_pmd = {
- . pci_drv = {
- . id_table = pci_id_vmxnet3_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_vmxnet3_dev_init ,
- . eth_dev_uninit = eth_vmxnet3_dev_uninit ,
- . dev_private_size = sizeof ( struct vmxnet3_hw ),
+ static int eth_vmxnet3_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct vmxnet3_hw ), eth_vmxnet3_dev_init );
+ }
+
+ static int eth_vmxnet3_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , eth_vmxnet3_dev_uninit );
+ }
+
+ static struct rte_pci_driver rte_vmxnet3_pmd = {
+ . id_table = pci_id_vmxnet3_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING ,
+ . probe = eth_vmxnet3_pci_probe ,
+ . remove = eth_vmxnet3_pci_remove ,
};
static int @@ -970,6 +978,6 @@ vmxnet3_process_events(struct vmxnet3_hw *hw)
}
#endif
- RTE_PMD_REGISTER_PCI ( net_vmxnet3 , rte_vmxnet3_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_vmxnet3 , rte_vmxnet3_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_vmxnet3 , pci_id_vmxnet3_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_vmxnet3 , "* igb_uio | uio_pci_generic | vfio" ); --
2.7.4
This removes the now unused rte_eth_dev_pci_probe() and
rte_eth_dev_pci_remove() functions.
Signed-off-by: Jan Blunck <redacted>
---
lib/librte_ether/rte_ethdev.c | 97 ----------------------------------
lib/librte_ether/rte_ethdev.h | 15 ------
lib/librte_ether/rte_ethdev_pci.h | 10 ++++
lib/librte_ether/rte_ether_version.map | 3 --
4 files changed, 10 insertions(+), 115 deletions(-)
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 86ee5bb..4669f80 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c @@ -277,103 +277,6 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
}
int
- rte_eth_dev_pci_probe ( struct rte_pci_driver * pci_drv ,
- struct rte_pci_device * pci_dev )
- {
- struct eth_driver * eth_drv ;
- struct rte_eth_dev * eth_dev ;
- char ethdev_name [ RTE_ETH_NAME_MAX_LEN ];
-
- int diag ;
-
- eth_drv = ( struct eth_driver * ) pci_drv ;
-
- rte_eal_pci_device_name ( & pci_dev -> addr , ethdev_name ,
- sizeof ( ethdev_name ));
-
- if ( rte_eal_process_type () == RTE_PROC_PRIMARY ) {
- eth_dev = rte_eth_dev_allocate ( ethdev_name );
- if ( eth_dev == NULL )
- return - ENOMEM ;
-
- 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 " );
- } else {
- eth_dev = rte_eth_dev_attach_secondary ( ethdev_name );
- if ( eth_dev == NULL ) {
- /*
- * if we failed to attach a device , it means the
- * device is skipped in primary process , due to
- * some errors . If so , we return a positive value ,
- * to let EAL skip it for the secondary process
- * as well .
- */
- return 1 ;
- }
- }
- eth_dev -> device = & pci_dev -> device ;
- eth_dev -> intr_handle = & pci_dev -> intr_handle ;
- eth_dev -> driver = eth_drv ;
-
- /* 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(vendor_id=0x%x device_id=0x%x) failed \n " ,
- pci_drv -> driver . name ,
- ( unsigned ) pci_dev -> id . vendor_id ,
- ( unsigned ) pci_dev -> id . device_id );
- 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_pci_remove ( struct rte_pci_device * pci_dev )
- {
- const struct eth_driver * eth_drv ;
- struct rte_eth_dev * eth_dev ;
- char ethdev_name [ RTE_ETH_NAME_MAX_LEN ];
- int ret ;
-
- if ( pci_dev == NULL )
- return - EINVAL ;
-
- rte_eal_pci_device_name ( & pci_dev -> addr , ethdev_name ,
- sizeof ( ethdev_name ));
-
- eth_dev = rte_eth_dev_allocated ( ethdev_name );
- if ( eth_dev == NULL )
- return - ENODEV ;
-
- eth_drv = ( const struct eth_driver * ) pci_dev -> driver ;
-
- /* 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 -> device = 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 || diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 9d5848b..1bfb8e7 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h @@ -4419,21 +4419,6 @@ rte_eth_dev_get_port_by_name(const char *name, uint8_t *port_id);
int
rte_eth_dev_get_name_by_port ( uint8_t port_id , char * name );
- /**
- * @ internal
- * Wrapper for use by pci drivers as a . probe function to attach to a ethdev
- * interface .
- */
- int rte_eth_dev_pci_probe ( struct rte_pci_driver * pci_drv ,
- struct rte_pci_device * pci_dev );
-
- /**
- * @ internal
- * Wrapper for use by pci drivers as a . remove function to detach a ethdev
- * interface .
- */
- int rte_eth_dev_pci_remove ( struct rte_pci_device * pci_dev );
-
#ifdef __cplusplus
}
#endif diff --git a/lib/librte_ether/rte_ethdev_pci.h b/lib/librte_ether/rte_ethdev_pci.h
index 4b728db..fe62589 100644
--- a/lib/librte_ether/rte_ethdev_pci.h
+++ b/lib/librte_ether/rte_ethdev_pci.h @@ -108,6 +108,11 @@ rte_eth_dev_pci_release(struct rte_eth_dev *eth_dev)
typedef int ( * eth_dev_pci_callback_t )( struct rte_eth_dev * eth_dev );
+ /**
+ * @ internal
+ * Wrapper for use by pci drivers in a . probe function to attach to a ethdev
+ * interface .
+ */
static inline int
rte_eth_dev_pci_generic_probe ( struct rte_pci_device * pci_dev ,
size_t private_data_size , eth_dev_pci_callback_t dev_init ) @@ -127,6 +132,11 @@ rte_eth_dev_pci_generic_probe(struct rte_pci_device *pci_dev,
return ret ;
}
+ /**
+ * @ internal
+ * Wrapper for use by pci drivers in a . remove function to detach a ethdev
+ * interface .
+ */
static inline int
rte_eth_dev_pci_generic_remove ( struct rte_pci_device * pci_dev ,
eth_dev_pci_callback_t dev_uninit ) diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index d34c57a..e2b6d0e 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map @@ -137,9 +137,6 @@ DPDK_16.07 {
DPDK_16.11 {
global:
- rte_eth_dev_pci_probe;
- rte_eth_dev_pci_remove;
-
} DPDK_16.07;
DPDK_17.02 { --
2.7.4
This removes the now unused struct eth_driver.
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/cxgbe/cxgbe_main.c | 1 -
drivers/net/ring/rte_eth_ring.c | 1 -
lib/librte_ether/rte_ethdev.h | 73 --------------------------------------
lib/librte_ether/rte_ethdev_pci.h | 2 --
lib/librte_ether/rte_ethdev_vdev.h | 1 -
5 files changed, 78 deletions(-)
diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c
index 541fc40..f895b18 100644
--- a/drivers/net/cxgbe/cxgbe_main.c
+++ b/drivers/net/cxgbe/cxgbe_main.c @@ -1165,7 +1165,6 @@ int cxgbe_probe(struct adapter *adapter)
allocate_mac :
pi -> eth_dev -> device = & adapter -> pdev -> device ;
pi -> eth_dev -> data -> dev_private = pi ;
- pi -> eth_dev -> driver = adapter -> eth_dev -> driver ;
pi -> eth_dev -> dev_ops = adapter -> eth_dev -> dev_ops ;
pi -> eth_dev -> tx_pkt_burst = adapter -> eth_dev -> tx_pkt_burst ;
pi -> eth_dev -> rx_pkt_burst = adapter -> eth_dev -> rx_pkt_burst ; diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index 62606e7..d6fc97a 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c @@ -338,7 +338,6 @@ do_eth_dev_ring_create(const char *name,
data -> mac_addrs = & internals -> address ;
eth_dev -> data = data ;
- eth_dev -> driver = NULL ;
eth_dev -> dev_ops = & ops ;
data -> dev_flags = RTE_ETH_DEV_DETACHABLE ;
data -> kdrv = RTE_KDRV_NONE ; diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 1bfb8e7..87c33bb 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h @@ -1628,7 +1628,6 @@ struct rte_eth_dev {
eth_tx_burst_t tx_pkt_burst ; /**< Pointer to PMD transmit function. */
eth_tx_prep_t tx_pkt_prepare ; /**< Pointer to PMD transmit prepare function. */
struct rte_eth_dev_data * data ; /**< Pointer to device data */
- const struct eth_driver * driver ; /**< Driver for this device */
const struct eth_dev_ops * dev_ops ; /**< Functions exported by PMD */
struct rte_device * device ; /**< Backing device */
struct rte_intr_handle * intr_handle ; /**< Device interrupt handle */ @@ -1812,78 +1811,6 @@ int rte_eth_dev_attach(const char *devargs, uint8_t *port_id);
*/
int rte_eth_dev_detach ( uint8_t port_id , char * devname );
- struct eth_driver ;
- /**
- * @ internal
- * Initialization function of an Ethernet driver invoked for each matching
- * Ethernet PCI device detected during the PCI probing phase .
- *
- * @ param eth_dev
- * The * eth_dev * pointer is the address of the * rte_eth_dev * structure
- * associated with the matching device and which have been [ automatically ]
- * allocated in the * rte_eth_devices * array .
- * The * eth_dev * structure is supplied to the driver initialization function
- * with the following fields already initialized :
- *
- * - * pci_dev *: Holds the pointers to the * rte_pci_device * structure which
- * contains the generic PCI information of the matching device .
- *
- * - * driver *: Holds the pointer to the * eth_driver * structure .
- *
- * - * dev_private *: Holds a pointer to the device private data structure .
- *
- * - * mtu *: Contains the default Ethernet maximum frame length ( 1500 ).
- *
- * - * port_id *: Contains the port index of the device ( actually the index
- * of the * eth_dev * structure in the * rte_eth_devices * array ).
- *
- * @ return
- * - 0 : Success , the device is properly initialized by the driver .
- * In particular , the driver MUST have set up the * dev_ops * pointer
- * of the * eth_dev * structure .
- * - < 0 : Error code of the device initialization failure .
- */
- typedef int ( * eth_dev_init_t )( struct rte_eth_dev * eth_dev );
-
- /**
- * @ internal
- * Finalization function of an Ethernet driver invoked for each matching
- * Ethernet PCI device detected during the PCI closing phase .
- *
- * @ param eth_dev
- * The * eth_dev * pointer is the address of the * rte_eth_dev * structure
- * associated with the matching device and which have been [ automatically ]
- * allocated in the * rte_eth_devices * array .
- * @ return
- * - 0 : Success , the device is properly finalized by the driver .
- * In particular , the driver MUST free the * dev_ops * pointer
- * of the * eth_dev * structure .
- * - < 0 : Error code of the device initialization failure .
- */
- typedef int ( * eth_dev_uninit_t )( struct rte_eth_dev * eth_dev );
-
- /**
- * @ internal
- * The structure associated with a PMD Ethernet driver .
- *
- * Each Ethernet driver acts as a PCI driver and is represented by a generic
- * * eth_driver * structure that holds :
- *
- * - An * rte_pci_driver * structure ( which must be the first field ).
- *
- * - The * eth_dev_init * function invoked for each matching PCI device .
- *
- * - The * eth_dev_uninit * function invoked for each matching PCI device .
- *
- * - The size of the private data to allocate for each matching device .
- */
- struct eth_driver {
- struct rte_pci_driver pci_drv ; /**< The PMD is also a PCI 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. */
- };
-
/**
* Convert a numerical speed in Mbps to a bitmap flag that can be used in
* the bitmap link_speeds of the struct rte_eth_conf diff --git a/lib/librte_ether/rte_ethdev_pci.h b/lib/librte_ether/rte_ethdev_pci.h
index fe62589..f85d26f 100644
--- a/lib/librte_ether/rte_ethdev_pci.h
+++ b/lib/librte_ether/rte_ethdev_pci.h @@ -84,7 +84,6 @@ rte_eth_dev_pci_allocate(struct rte_pci_device *dev, size_t private_data_size)
}
eth_dev -> device = & dev -> device ;
- eth_dev -> driver = NULL ;
eth_dev -> intr_handle = & dev -> intr_handle ;
rte_eth_copy_pci_info ( eth_dev , dev );
return eth_dev ; @@ -102,7 +101,6 @@ rte_eth_dev_pci_release(struct rte_eth_dev *eth_dev)
eth_dev -> data -> dev_private = NULL ;
eth_dev -> device = NULL ;
- eth_dev -> driver = NULL ;
eth_dev -> intr_handle = NULL ;
}
diff --git a/lib/librte_ether/rte_ethdev_vdev.h b/lib/librte_ether/rte_ethdev_vdev.h
index 0b47535..fa2cb61 100644
--- a/lib/librte_ether/rte_ethdev_vdev.h
+++ b/lib/librte_ether/rte_ethdev_vdev.h @@ -73,7 +73,6 @@ rte_eth_vdev_allocate(struct rte_vdev_device *dev, size_t private_data_size)
}
eth_dev -> device = & dev -> device ;
- eth_dev -> driver = NULL ;
eth_dev -> intr_handle = NULL ;
eth_dev -> data -> kdrv = RTE_KDRV_NONE ; --
2.7.4
This moves the rte_eth_copy_pci_info() into the PCI specific ethdev
header. As a side effect this also removes it from the list of symbols
exported by the rte_ethdev library.
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/cxgbe/cxgbe_main.c | 1 +
lib/librte_ether/rte_ethdev.c | 20 --------------------
lib/librte_ether/rte_ethdev.h | 14 --------------
lib/librte_ether/rte_ethdev_pci.h | 32 ++++++++++++++++++++++++++++++++
lib/librte_ether/rte_ether_version.map | 1 -
5 files changed, 33 insertions(+), 35 deletions(-)
diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c
index f895b18..1f230cd 100644
--- a/drivers/net/cxgbe/cxgbe_main.c
+++ b/drivers/net/cxgbe/cxgbe_main.c @@ -57,6 +57,7 @@
#include <rte_alarm.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_atomic.h>
#include <rte_malloc.h>
#include <rte_random.h> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 4669f80..80c2769 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c @@ -3103,26 +3103,6 @@ rte_eth_dev_get_dcb_info(uint8_t port_id,
return ( * dev -> dev_ops -> get_dcb_info )( dev , dcb_info );
}
- void
- rte_eth_copy_pci_info ( struct rte_eth_dev * eth_dev , struct rte_pci_device * pci_dev )
- {
- if (( eth_dev == NULL ) || ( pci_dev == NULL )) {
- RTE_PMD_DEBUG_TRACE ( "NULL pointer eth_dev=%p pci_dev=%p \n " ,
- eth_dev , pci_dev );
- return ;
- }
-
- eth_dev -> intr_handle = & pci_dev -> intr_handle ;
-
- eth_dev -> data -> dev_flags = 0 ;
- if ( pci_dev -> driver -> drv_flags & RTE_PCI_DRV_INTR_LSC )
- eth_dev -> data -> dev_flags |= RTE_ETH_DEV_INTR_LSC ;
-
- eth_dev -> data -> kdrv = pci_dev -> kdrv ;
- eth_dev -> data -> numa_node = pci_dev -> device . numa_node ;
- eth_dev -> data -> drv_name = pci_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 87c33bb..7259cb8 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h @@ -4233,20 +4233,6 @@ int rte_eth_timesync_read_time(uint8_t port_id, struct timespec *time);
int rte_eth_timesync_write_time ( uint8_t port_id , const struct timespec * time );
/**
- * Copy pci device info to the Ethernet device data .
- *
- * @ param eth_dev
- * The * eth_dev * pointer is the address of the * rte_eth_dev * structure .
- * @ param pci_dev
- * The * pci_dev * pointer is the address of the * rte_pci_device * structure .
- *
- * @ return
- * - 0 on success , negative on error
- */
- void rte_eth_copy_pci_info ( struct rte_eth_dev * eth_dev ,
- struct rte_pci_device * pci_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 diff --git a/lib/librte_ether/rte_ethdev_pci.h b/lib/librte_ether/rte_ethdev_pci.h
index f85d26f..2953579 100644
--- a/lib/librte_ether/rte_ethdev_pci.h
+++ b/lib/librte_ether/rte_ethdev_pci.h @@ -39,6 +39,38 @@
#include <rte_ethdev.h>
/**
+ * Copy pci device info to the Ethernet device data .
+ *
+ * @ param eth_dev
+ * The * eth_dev * pointer is the address of the * rte_eth_dev * structure .
+ * @ param pci_dev
+ * The * pci_dev * pointer is the address of the * rte_pci_device * structure .
+ *
+ * @ return
+ * - 0 on success , negative on error
+ */
+ static inline void
+ rte_eth_copy_pci_info ( struct rte_eth_dev * eth_dev ,
+ struct rte_pci_device * pci_dev )
+ {
+ if (( eth_dev == NULL ) || ( pci_dev == NULL )) {
+ RTE_PMD_DEBUG_TRACE ( "NULL pointer eth_dev=%p pci_dev=%p \n " ,
+ eth_dev , pci_dev );
+ return ;
+ }
+
+ eth_dev -> intr_handle = & pci_dev -> intr_handle ;
+
+ eth_dev -> data -> dev_flags = 0 ;
+ if ( pci_dev -> driver -> drv_flags & RTE_PCI_DRV_INTR_LSC )
+ eth_dev -> data -> dev_flags |= RTE_ETH_DEV_INTR_LSC ;
+
+ eth_dev -> data -> kdrv = pci_dev -> kdrv ;
+ eth_dev -> data -> numa_node = pci_dev -> device . numa_node ;
+ eth_dev -> data -> drv_name = pci_dev -> driver -> driver . name ;
+ }
+
+ /**
* @ internal
* Allocates a new ethdev slot for an ethernet device and returns the pointer
* to that slot for the driver to use . diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index e2b6d0e..a025119 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map @@ -7,7 +7,6 @@ DPDK_2.2 {
rte_eth_allmulticast_disable;
rte_eth_allmulticast_enable;
rte_eth_allmulticast_get;
- rte_eth_copy_pci_info;
rte_eth_dev_allocate;
rte_eth_dev_allocated;
rte_eth_dev_attach; --
2.7.4
Since the PCI functionality has been moved to the PCI specific ethdev
header we don't need to include rte_pci.h from here anymore.
Signed-off-by: Jan Blunck <redacted>
---
lib/librte_ether/rte_ethdev.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 7259cb8..a646ac8 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h @@ -179,7 +179,6 @@ extern "C" {
#include <rte_log.h>
#include <rte_interrupts.h>
- #include <rte_pci.h>
#include <rte_dev.h>
#include <rte_devargs.h>
#include <rte_errno.h> @@ -901,6 +900,8 @@ struct rte_eth_conf {
#define DEV_TX_OFFLOAD_GENEVE_TNL_TSO 0x00001000 /**< Used for tunneling packet. */
#define DEV_TX_OFFLOAD_MACSEC_INSERT 0x00002000
+ struct rte_pci_device ;
+
/**
* Ethernet device information
*/ --
2.7.4
quoted hunk Signed-off-by: Jan Blunck <redacted>
---
drivers/net/bnx2x/bnx2x_ethdev.c | 64
+++++++++++++++++++++++++++-------------
1 file changed, 44 insertions(+), 20 deletions(-)
diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index a0b0dfa..e295951 100644 --- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c #include "bnx2x_rxtx.h"
#include <rte_dev.h>
+#include <rte_ethdev_pci.h>
/*
* The set of PCI devices this driver supports @@ -626,34 +627,57 @@ eth_bnx2xvf_dev_init(struct rte_eth_dev *eth_dev) return bnx2x_common_dev_init(eth_dev, 1);
}
-static struct eth_driver rte_bnx2x_pmd = {
- .pci_drv = {
- .id_table = pci_id_bnx2x_map,
- .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
- .probe = rte_eth_dev_pci_probe,
- .remove = rte_eth_dev_pci_remove,
- },
- .eth_dev_init = eth_bnx2x_dev_init,
- .dev_private_size = sizeof(struct bnx2x_softc),
+static struct rte_pci_driver rte_bnx2x_pmd;
+static struct rte_pci_driver rte_bnx2xvf_pmd;
+
+static int eth_bnx2x_pci_probe(struct rte_pci_driver *pci_drv,
+ struct rte_pci_device *pci_dev)
+{
+ struct rte_eth_dev *eth_dev;
+ int ret;
+
+ eth_dev = rte_eth_dev_pci_allocate(pci_dev, sizeof(struct bnx2x_softc));
+ if (!eth_dev)
+ return -ENOMEM;
+
+ if (pci_drv == &rte_bnx2x_pmd)
+ ret = eth_bnx2x_dev_init(eth_dev);
+ else if (pci_drv == &rte_bnx2xvf_pmd)
+ ret = eth_bnx2xvf_dev_init(eth_dev);
+ else
+ ret = -EINVAL;
+
+ if (ret)
+ rte_eth_dev_pci_release(eth_dev);
+
+ return ret;
+}
+
+static int eth_bnx2x_pci_remove(struct rte_pci_device *pci_dev)
+{
+ return rte_eth_dev_pci_generic_remove(pci_dev, NULL);
+}
+
+static struct rte_pci_driver rte_bnx2x_pmd = {
+ .id_table = pci_id_bnx2x_map,
+ .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+ .probe = eth_bnx2x_pci_probe,
+ .remove = eth_bnx2x_pci_remove,
};
/*
* virtual function driver struct
*/
-static struct eth_driver rte_bnx2xvf_pmd = {
- .pci_drv = {
- .id_table = pci_id_bnx2xvf_map,
- .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
- .probe = rte_eth_dev_pci_probe,
- .remove = rte_eth_dev_pci_remove,
- },
- .eth_dev_init = eth_bnx2xvf_dev_init,
- .dev_private_size = sizeof(struct bnx2x_softc),
+static struct rte_pci_driver rte_bnx2xvf_pmd = {
+ .id_table = pci_id_bnx2xvf_map,
+ .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+ .probe = eth_bnx2x_pci_probe,
+ .remove = eth_bnx2x_pci_remove,
};
-RTE_PMD_REGISTER_PCI(net_bnx2x, rte_bnx2x_pmd.pci_drv);
+RTE_PMD_REGISTER_PCI(net_bnx2x, rte_bnx2x_pmd);
RTE_PMD_REGISTER_PCI_TABLE(net_bnx2x, pci_id_bnx2x_map);
RTE_PMD_REGISTER_KMOD_DEP(net_bnx2x, "* igb_uio | uio_pci_generic |
vfio");
-RTE_PMD_REGISTER_PCI(net_bnx2xvf, rte_bnx2xvf_pmd.pci_drv);
+RTE_PMD_REGISTER_PCI(net_bnx2xvf, rte_bnx2xvf_pmd);
RTE_PMD_REGISTER_PCI_TABLE(net_bnx2xvf, pci_id_bnx2xvf_map);
RTE_PMD_REGISTER_KMOD_DEP(net_bnx2xvf, "* igb_uio | vfio");
--
2.7.4
Acked-by: Harish Patil <redacted>
quoted hunk Signed-off-by: Jan Blunck <redacted>
---
drivers/net/qede/qede_ethdev.c | 60
+++++++++++++++++++++++++-----------------
drivers/net/qede/qede_ethdev.h | 1 +
2 files changed, 37 insertions(+), 24 deletions(-)
diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index 0494dbd..8dfddf0 100644 --- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c @@ -2337,35 +2337,47 @@ static const struct rte_pci_id pci_id_qede_map[] = {
{.vendor_id = 0,}
};
-static struct eth_driver rte_qedevf_pmd = {
- .pci_drv = {
- .id_table = pci_id_qedevf_map,
- .drv_flags =
- RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
- .probe = rte_eth_dev_pci_probe,
- .remove = rte_eth_dev_pci_remove,
- },
- .eth_dev_init = qedevf_eth_dev_init,
- .eth_dev_uninit = qedevf_eth_dev_uninit,
- .dev_private_size = sizeof(struct qede_dev),
+static int qedevf_eth_dev_pci_probe(struct rte_pci_driver *pci_drv
__rte_unused,
+ struct rte_pci_device *pci_dev)
+{
+ return rte_eth_dev_pci_generic_probe(pci_dev,
+ sizeof(struct qede_dev), qedevf_eth_dev_init);
+}
+
+static int qedevf_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
+{
+ return rte_eth_dev_pci_generic_remove(pci_dev, qedevf_eth_dev_uninit);
+}
+
+static struct rte_pci_driver rte_qedevf_pmd = {
+ .id_table = pci_id_qedevf_map,
+ .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+ .probe = qedevf_eth_dev_pci_probe,
+ .remove = qedevf_eth_dev_pci_remove,
};
-static struct eth_driver rte_qede_pmd = {
- .pci_drv = {
- .id_table = pci_id_qede_map,
- .drv_flags =
- RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
- .probe = rte_eth_dev_pci_probe,
- .remove = rte_eth_dev_pci_remove,
- },
- .eth_dev_init = qede_eth_dev_init,
- .eth_dev_uninit = qede_eth_dev_uninit,
- .dev_private_size = sizeof(struct qede_dev),
+static int qede_eth_dev_pci_probe(struct rte_pci_driver *pci_drv
__rte_unused,
+ struct rte_pci_device *pci_dev)
+{
+ return rte_eth_dev_pci_generic_probe(pci_dev,
+ sizeof(struct qede_dev), qede_eth_dev_init);
+}
+
+static int qede_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
+{
+ return rte_eth_dev_pci_generic_remove(pci_dev, qede_eth_dev_uninit);
+}
+
+static struct rte_pci_driver rte_qede_pmd = {
+ .id_table = pci_id_qede_map,
+ .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+ .probe = qede_eth_dev_pci_probe,
+ .remove = qede_eth_dev_pci_remove,
};
-RTE_PMD_REGISTER_PCI(net_qede, rte_qede_pmd.pci_drv);
+RTE_PMD_REGISTER_PCI(net_qede, rte_qede_pmd);
RTE_PMD_REGISTER_PCI_TABLE(net_qede, pci_id_qede_map);
RTE_PMD_REGISTER_KMOD_DEP(net_qede, "* igb_uio | uio_pci_generic |
vfio");
-RTE_PMD_REGISTER_PCI(net_qede_vf, rte_qedevf_pmd.pci_drv);
+RTE_PMD_REGISTER_PCI(net_qede_vf, rte_qedevf_pmd);
RTE_PMD_REGISTER_PCI_TABLE(net_qede_vf, pci_id_qedevf_map);
RTE_PMD_REGISTER_KMOD_DEP(net_qede_vf, "* igb_uio | vfio"); diff --git a/drivers/net/qede/qede_ethdev.h b/drivers/net/qede/qede_ethdev.h
index be54f31..0fde8ec 100644 --- a/drivers/net/qede/qede_ethdev.h
+++ b/drivers/net/qede/qede_ethdev.h #include <rte_ether.h>
#include <rte_ethdev.h>
+#include <rte_ethdev_pci.h>
#include <rte_dev.h>
#include <rte_ip.h>
--
2.7.4
Acked-by: Harish Patil <redacted>
Hello Jan,
On Monday 06 March 2017 03:29 PM, Jan Blunck wrote: quoted hunk This driver can use the library function rte_eth_dma_zone_reserve()
instead of duplicating the code.
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/nfp/nfp_net.c | 30 ++++++------------------------
1 file changed, 6 insertions(+), 24 deletions(-)
diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index d79f262..b9dfe80 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c @@ -205,26 +205,6 @@ nn_cfg_writeq(struct nfp_net_hw *hw, int off, uint64_t val)
nn_writeq ( rte_cpu_to_le_64 ( val ), hw -> ctrl_bar + off );
}
- /* Creating memzone for hardware rings. */
- static const struct rte_memzone *
- ring_dma_zone_reserve ( struct rte_eth_dev * dev , const char * ring_name ,
- uint16_t queue_id , uint32_t ring_size , int socket_id )
- {
- char z_name [ RTE_MEMZONE_NAMESIZE ];
- const struct rte_memzone * mz ;
-
- snprintf ( z_name , sizeof ( z_name ), "%s_%s_%d_%d" ,
- dev -> driver -> pci_drv . driver . name ,
- ring_name , dev -> data -> port_id , queue_id );
-
- mz = rte_memzone_lookup ( z_name );
- if ( mz )
- return mz ;
-
- return rte_memzone_reserve_aligned ( z_name , ring_size , socket_id , 0 ,
- NFP_MEMZONE_ALIGN );
- }
-
/*
* Atomically reads link status information from global structure rte_eth_dev .
* @@ -1461,9 +1441,10 @@ nfp_net_rx_queue_setup(struct rte_eth_dev *dev,
* handle the maximum ring size is allocated in order to allow for
* resizing in later calls to the queue setup function .
*/
- tz = ring_dma_zone_reserve ( dev , "rx_ring" , queue_idx ,
+ tz = rte_eth_dma_zone_reserve ( dev , "rx_ring" , queue_idx ,
sizeof ( struct nfp_net_rx_desc ) *
- NFP_NET_MAX_RX_DESC , socket_id );
+ NFP_NET_MAX_RX_DESC , NFP_MEMZONE_ALIGN ,
+ socket_id );
if ( tz == NULL ) {
RTE_LOG ( ERR , PMD , "Error allocatig rx dma \n " ); @@ -1603,9 +1584,10 @@ nfp_net_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
* handle the maximum ring size is allocated in order to allow for
* resizing in later calls to the queue setup function .
*/
- tz = ring_dma_zone_reserve ( dev , "tx_ring" , queue_idx ,
+ tz = rte_eth_dma_zone_reserve ( dev , "tx_ring" , queue_idx ,
sizeof ( struct nfp_net_tx_desc ) *
- NFP_NET_MAX_TX_DESC , socket_id );
+ NFP_NET_MAX_TX_DESC , NFP_MEMZONE_ALIGN ,
+ socket_id );
if ( tz == NULL ) {
RTE_LOG ( ERR , PMD , "Error allocating tx dma \n " );
nfp_net_tx_queue_release ( txq );
This change is not part of the eth_driver removal process. Isn't it?
I would suggest this should be a separate series all together. This is
valid for Patch 0004 as well.
On Fri, Mar 10, 2017 at 8:03 AM, Shreyansh Jain [off-list ref] wrote: On Monday 06 March 2017 03:29 PM, Jan Blunck wrote: quoted
-/* Creating memzone for hardware rings. */
-static const struct rte_memzone *
-ring_dma_zone_reserve(struct rte_eth_dev *dev, const char *ring_name,
- uint16_t queue_id, uint32_t ring_size, int
socket_id)
-{
- char z_name[RTE_MEMZONE_NAMESIZE];
- const struct rte_memzone *mz;
-
- snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
- dev->driver->pci_drv.driver.name,
- ring_name, dev->data->port_id, queue_id);
-
- mz = rte_memzone_lookup(z_name);
- if (mz)
- return mz;
-
- return rte_memzone_reserve_aligned(z_name, ring_size, socket_id,
0,
- NFP_MEMZONE_ALIGN);
-}
-
This change is not part of the eth_driver removal process. Isn't it?
I would suggest this should be a separate series all together. This is
valid for Patch 0004 as well.
It is removing a dependency on eth_driver (see
dev->driver->pci_drv.driver.name). Therefore even if I separate it
this series would depend on it.
Thanks for reviewing,
Jan
On Mon, 6 Mar 2017 10:59:52 +0100
Jan Blunck [off-list ref] wrote:
This series is removing the PCI specific struct eth_driver from rte_ether. The
PCI drivers are changed to use the newly introduced header-only helpers
instead. Although the virtual drivers did not make use of the ethdev's driver
field they are converted to use the VDEV specific allocation helpers. The
motivation for this change is to properly embed a reference to the generic
rte_device in the ethdev.
The series is based on:
* http://dpdk.org/dev/patchwork/patch/20416/
* http://dpdk.org/dev/patchwork/patch/20417/
* my "Rework vdev probing to use rte_bus infrastructure" series
* http://dpdk.org/dev/patchwork/patch/21058/
If requested I can push a tree with all dependent patches.
Jan Blunck (38):
eal: add name field to generic device
eal: parse "driver" device argument before probing drivers
net/nfp: use library function for DMA zone reserve
net/vmxnet3: use library function for DMA zone reserve
ether: add allocation helper for virtual drivers
net/tap: use ethdev allocation helper for virtual devices
net/vhost: use ethdev allocation helper for virtual devices
net/virtio: use ethdev allocation helper for virtual devices
net/af_packet: use ethdev allocation helper for virtual devices
app/test: don't short-circuit null device creation
net/null: internalize eth_dev_null_create()
net/null: use ethdev allocation helper for virtual devices
net/bonding: make bonding API call through EAL on create/free
net/bonding: use ethdev allocation helper for virtual devices
ethdev: add PCI driver helpers
net/virtio: Don't use eth_driver
net/bnx2x: Don't use eth_driver
net/bnxt: Don't use eth_driver
net/cxgbe: Don't use eth_driver
net/em: Don't use eth_driver
net/igb: Don't use eth_driver
net/ena: Don't use eth_driver
net/enic: Don't use eth_driver
net/fm10k: Don't use eth_driver
net/i40e: Don't use eth_driver
net/i40evf: Don't use eth_driver
net/ixgbe: Don't use eth_driver
net/mlx: Don't reference eth_driver
net/nfp: Don't use eth_driver
net/qede: Don't use eth_driver
net/sfc: Don't use eth_driver
net/szedata2: Don't use eth_driver
net/thunderx: Don't use eth_driver
net/vmxnet3: Don't use eth_driver
ethdev: remove unused ethdev PCI probe/remove
ethdev: remove unused ethdev driver
ethdev: remove PCI specific helper from generic ethdev header
ethdev: don't include PCI header
drivers/net/af_packet/rte_eth_af_packet.c | 42 +++----
drivers/net/bnx2x/bnx2x_ethdev.c | 64 ++++++----
drivers/net/bnxt/bnxt_ethdev.c | 36 ++++--
drivers/net/bonding/rte_eth_bond_api.c | 171 ++++----------------------
drivers/net/bonding/rte_eth_bond_args.c | 2 +-
drivers/net/bonding/rte_eth_bond_pmd.c | 160 +++++++++++++++++++++++--
drivers/net/cxgbe/cxgbe_ethdev.c | 29 +++--
drivers/net/cxgbe/cxgbe_main.c | 2 +-
drivers/net/cxgbe/sge.c | 6 +-
drivers/net/e1000/em_ethdev.c | 30 +++--
drivers/net/e1000/igb_ethdev.c | 60 ++++++----
drivers/net/ena/ena_ethdev.c | 29 +++--
drivers/net/enic/enic_ethdev.c | 29 +++--
drivers/net/fm10k/fm10k_ethdev.c | 30 +++--
drivers/net/i40e/i40e_ethdev.c | 36 +++---
drivers/net/i40e/i40e_ethdev_vf.c | 31 +++--
drivers/net/i40e/i40e_fdir.c | 2 +-
drivers/net/ixgbe/ixgbe_ethdev.c | 66 +++++++----
drivers/net/mlx4/mlx4.c | 17 ++-
drivers/net/mlx5/mlx5.c | 19 ++-
drivers/net/nfp/nfp_net.c | 59 ++++-----
drivers/net/null/Makefile | 7 +-
drivers/net/null/rte_eth_null.c | 55 +++------
drivers/net/null/rte_eth_null.h | 40 -------
drivers/net/null/rte_pmd_null_version.map | 7 --
drivers/net/qede/qede_ethdev.c | 60 ++++++----
drivers/net/qede/qede_ethdev.h | 1 +
drivers/net/ring/rte_eth_ring.c | 1 -
drivers/net/sfc/sfc_ethdev.c | 34 ++++--
drivers/net/szedata2/rte_eth_szedata2.c | 29 +++--
drivers/net/tap/rte_eth_tap.c | 37 ++----
drivers/net/thunderx/nicvf_ethdev.c | 29 +++--
drivers/net/vhost/rte_eth_vhost.c | 54 ++++-----
drivers/net/virtio/virtio_ethdev.c | 34 ++++--
drivers/net/virtio/virtio_user_ethdev.c | 20 +---
drivers/net/vmxnet3/vmxnet3_ethdev.c | 30 +++--
drivers/net/vmxnet3/vmxnet3_rxtx.c | 30 +----
lib/librte_eal/bsdapp/eal/eal_pci.c | 3 +
lib/librte_eal/common/eal_common_dev.c | 3 +
lib/librte_eal/common/eal_common_vdev.c | 50 +++++++-
lib/librte_eal/common/include/rte_dev.h | 1 +
lib/librte_eal/common/include/rte_pci.h | 1 +
lib/librte_eal/linuxapp/eal/eal_pci.c | 3 +
lib/librte_ether/Makefile | 2 +
lib/librte_ether/rte_ethdev.c | 117 ------------------
lib/librte_ether/rte_ethdev.h | 105 +---------------
lib/librte_ether/rte_ethdev_pci.h | 191 ++++++++++++++++++++++++++++++
lib/librte_ether/rte_ethdev_vdev.h | 84 +++++++++++++
lib/librte_ether/rte_ether_version.map | 4 -
test/test/test_link_bonding_rssconf.c | 4 +-
50 files changed, 1065 insertions(+), 891 deletions(-)
delete mode 100644 drivers/net/null/rte_eth_null.h
create mode 100644 lib/librte_ether/rte_ethdev_pci.h
create mode 100644 lib/librte_ether/rte_ethdev_vdev.h
Could you put a tree with the patches up on github?
On Thu, Mar 23, 2017 at 4:34 PM, Stephen Hemminger
[off-list ref] wrote: On Mon, 6 Mar 2017 10:59:52 +0100
Jan Blunck [off-list ref] wrote:
quoted This series is removing the PCI specific struct eth_driver from rte_ether. The
PCI drivers are changed to use the newly introduced header-only helpers
instead. Although the virtual drivers did not make use of the ethdev's driver
field they are converted to use the VDEV specific allocation helpers. The
motivation for this change is to properly embed a reference to the generic
rte_device in the ethdev.
The series is based on:
* http://dpdk.org/dev/patchwork/patch/20416/
* http://dpdk.org/dev/patchwork/patch/20417/
* my "Rework vdev probing to use rte_bus infrastructure" series
* http://dpdk.org/dev/patchwork/patch/21058/
If requested I can push a tree with all dependent patches.
Could you put a tree with the patches up on github?
https://github.com/jblunck/dpdk/commits/eth_driver/20170306
I rebased the following work of Jan:
This series is removing the PCI specific struct eth_driver from rte_ether. The
PCI drivers are changed to use the newly introduced header-only helpers
instead. Although the virtual drivers did not make use of the ethdev's driver
field they are converted to use the VDEV specific allocation helpers. The
motivation for this change is to properly embed a reference to the generic
rte_device in the ethdev.
The series is based on:
* http://dpdk.org/dev/patchwork/patch/20416/
* http://dpdk.org/dev/patchwork/patch/20417/
* The "Rework vdev probing to use rte_bus infrastructure" series
* http://dpdk.org/dev/patchwork/patch/21058/
Changes in v2:
* Removed the patch "net/vmxnet3: use library function for DMA zone reserve"
It is essentially duplicating the following commit:
04df93d1edac ("net/vmxnet3: fix queue size changes")
* Fixed header includes for mlx4 and mlx5 PMD
* Followed the changes of the series for new PMDs (AVP, liquidio)
* Made KNI use the new API
* Made PCAP use the new API
* Fixed undefined behavior on vdev driver arg parsing
* Fixed virtual_pmd for unit test
Gaetan Rivet (5):
net/kni: use ethdev allocation helper for virtual devices
net/pcap: use ethdev allocation helper for virtual devices
net/avp: Don't use eth_driver
net/liquidio: Don't use eth_driver
test: remove unused ethdev driver
Jan Blunck (37):
eal: add name field to generic device
eal: parse "driver" device argument before probing drivers
net/nfp: use library function for DMA zone reserve
ether: add allocation helper for virtual drivers
net/tap: use ethdev allocation helper for virtual devices
net/vhost: use ethdev allocation helper for virtual devices
net/virtio: use ethdev allocation helper for virtual devices
net/af_packet: use ethdev allocation helper for virtual devices
app/test: don't short-circuit null device creation
net/null: internalize eth_dev_null_create()
net/null: use ethdev allocation helper for virtual devices
net/bonding: make bonding API call through EAL on create/free
net/bonding: use ethdev allocation helper for virtual devices
ethdev: add PCI driver helpers
net/virtio: Don't use eth_driver
net/bnx2x: Don't use eth_driver
net/bnxt: Don't use eth_driver
net/cxgbe: Don't use eth_driver
net/em: Don't use eth_driver
net/igb: Don't use eth_driver
net/ena: Don't use eth_driver
net/enic: Don't use eth_driver
net/fm10k: Don't use eth_driver
net/i40e: Don't use eth_driver
net/i40evf: Don't use eth_driver
net/ixgbe: Don't use eth_driver
net/mlx: Don't reference eth_driver
net/nfp: Don't use eth_driver
net/qede: Don't use eth_driver
net/sfc: Don't use eth_driver
net/szedata2: Don't use eth_driver
net/thunderx: Don't use eth_driver
net/vmxnet3: Don't use eth_driver
ethdev: remove unused ethdev PCI probe/remove
ethdev: remove unused ethdev driver
ethdev: remove PCI specific helper from generic ethdev header
ethdev: don't include PCI header
drivers/net/af_packet/rte_eth_af_packet.c | 42 +++----
drivers/net/avp/avp_ethdev.c | 43 +++++--
drivers/net/bnx2x/bnx2x_ethdev.c | 64 ++++++----
drivers/net/bnx2x/bnx2x_rxtx.c | 2 +-
drivers/net/bnxt/bnxt_ethdev.c | 36 ++++--
drivers/net/bonding/rte_eth_bond_api.c | 171 ++++----------------------
drivers/net/bonding/rte_eth_bond_args.c | 2 +-
drivers/net/bonding/rte_eth_bond_pmd.c | 160 +++++++++++++++++++++++--
drivers/net/cxgbe/cxgbe_ethdev.c | 29 +++--
drivers/net/cxgbe/cxgbe_main.c | 2 +-
drivers/net/cxgbe/sge.c | 6 +-
drivers/net/e1000/em_ethdev.c | 30 +++--
drivers/net/e1000/igb_ethdev.c | 60 ++++++----
drivers/net/ena/ena_ethdev.c | 29 +++--
drivers/net/enic/enic_ethdev.c | 29 +++--
drivers/net/fm10k/fm10k_ethdev.c | 30 +++--
drivers/net/i40e/i40e_ethdev.c | 36 +++---
drivers/net/i40e/i40e_ethdev_vf.c | 31 +++--
drivers/net/i40e/i40e_fdir.c | 2 +-
drivers/net/ixgbe/ixgbe_ethdev.c | 66 +++++++----
drivers/net/kni/rte_eth_kni.c | 39 +++---
drivers/net/liquidio/lio_ethdev.c | 44 +++++--
drivers/net/mlx4/mlx4.c | 24 ++--
drivers/net/mlx5/mlx5.c | 24 ++--
drivers/net/nfp/nfp_net.c | 59 ++++-----
drivers/net/null/Makefile | 7 +-
drivers/net/null/rte_eth_null.c | 55 +++------
drivers/net/null/rte_eth_null.h | 40 -------
drivers/net/null/rte_pmd_null_version.map | 7 --
drivers/net/pcap/rte_eth_pcap.c | 62 +++++-----
drivers/net/qede/qede_ethdev.c | 60 ++++++----
drivers/net/qede/qede_ethdev.h | 1 +
drivers/net/ring/rte_eth_ring.c | 1 -
drivers/net/sfc/sfc_ethdev.c | 34 ++++--
drivers/net/szedata2/rte_eth_szedata2.c | 29 +++--
drivers/net/tap/rte_eth_tap.c | 38 ++----
drivers/net/thunderx/nicvf_ethdev.c | 29 +++--
drivers/net/vhost/rte_eth_vhost.c | 54 ++++-----
drivers/net/virtio/virtio_ethdev.c | 34 ++++--
drivers/net/virtio/virtio_user_ethdev.c | 20 +---
drivers/net/vmxnet3/vmxnet3_ethdev.c | 30 +++--
lib/librte_eal/bsdapp/eal/eal_pci.c | 3 +
lib/librte_eal/common/eal_common_dev.c | 3 +
lib/librte_eal/common/eal_common_vdev.c | 53 ++++++++-
lib/librte_eal/common/include/rte_dev.h | 1 +
lib/librte_eal/common/include/rte_pci.h | 1 +
lib/librte_eal/linuxapp/eal/eal_pci.c | 3 +
lib/librte_ether/Makefile | 2 +
lib/librte_ether/rte_ethdev.c | 117 ------------------
lib/librte_ether/rte_ethdev.h | 105 +---------------
lib/librte_ether/rte_ethdev_pci.h | 191 ++++++++++++++++++++++++++++++
lib/librte_ether/rte_ethdev_vdev.h | 84 +++++++++++++
lib/librte_ether/rte_ether_version.map | 11 +-
test/test/test_link_bonding_rssconf.c | 4 +-
test/test/virtual_pmd.c | 12 +-
55 files changed, 1185 insertions(+), 966 deletions(-)
delete mode 100644 drivers/net/null/rte_eth_null.h
create mode 100644 lib/librte_ether/rte_ethdev_pci.h
create mode 100644 lib/librte_ether/rte_ethdev_vdev.h
--
2.1.4
From: Jan Blunck <redacted>
This adds a name field to the generic struct rte_device. The EAL is
checking for the name being populated when registering a device but
doesn't enforce global unique names as this is left to the bus
implementations.
Signed-off-by: Jan Blunck <redacted>
---
lib/librte_eal/bsdapp/eal/eal_pci.c | 3 +++
lib/librte_eal/common/eal_common_dev.c | 3 +++
lib/librte_eal/common/eal_common_vdev.c | 2 ++
lib/librte_eal/common/include/rte_dev.h | 1 +
lib/librte_eal/common/include/rte_pci.h | 1 +
lib/librte_eal/linuxapp/eal/eal_pci.c | 3 +++
6 files changed, 13 insertions(+)
diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 1e9031c..6e289da 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c @@ -282,6 +282,9 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
/* FreeBSD has no NUMA support (yet) */
dev -> device . numa_node = 0 ;
+ rte_eal_pci_device_name ( & dev -> addr , dev -> name , sizeof ( dev -> name ));
+ dev -> device . name = dev -> name ;
+
/* FreeBSD has only one pass through driver */
dev -> kdrv = RTE_KDRV_NIC_UIO ;
diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
index 01e37c4..badf918 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c @@ -70,6 +70,9 @@ rte_eal_driver_unregister(struct rte_driver *driver)
void rte_eal_device_insert ( struct rte_device * dev )
{
+ RTE_VERIFY ( dev -> name );
+ RTE_VERIFY ( dev -> name [ 0 ] != '\0' );
+
TAILQ_INSERT_TAIL ( & dev_device_list , dev , next );
}
diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index 22fe2ca..c922297 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c @@ -180,6 +180,7 @@ rte_eal_vdev_init(const char *name, const char *args)
dev -> device . devargs = devargs ;
dev -> device . numa_node = SOCKET_ID_ANY ;
+ dev -> device . name = devargs -> virt . drv_name ;
ret = vdev_probe_all_drivers ( dev );
if ( ret ) { @@ -271,6 +272,7 @@ vdev_scan(void)
dev -> device . devargs = devargs ;
dev -> device . numa_node = SOCKET_ID_ANY ;
+ dev -> device . name = devargs -> virt . drv_name ;
rte_eal_device_insert ( & dev -> device );
TAILQ_INSERT_TAIL ( & vdev_device_list , dev , next ); diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h
index 4251099..67c2b0c 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h @@ -122,6 +122,7 @@ struct rte_driver;
*/
struct rte_device {
TAILQ_ENTRY ( rte_device ) next ; /**< Next device */
+ const char * name ; /**< Device name */
const struct rte_driver * driver ; /**< Associated driver */
int numa_node ; /**< NUMA node connection */
struct rte_devargs * devargs ; /**< Device user arguments */ diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index de0641a..7ec9980 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h @@ -172,6 +172,7 @@ struct rte_pci_device {
struct rte_pci_driver * driver ; /**< Associated driver */
uint16_t max_vfs ; /**< sriov enable if not zero */
enum rte_kernel_driver kdrv ; /**< Kernel driver passthrough */
+ char name [ PCI_PRI_STR_SIZE + 1 ]; /**< PCI location (ASCII) */
};
/** diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c
index 7897e15..ab5f8c6 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -324,6 +324,9 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)
dev -> device . numa_node = tmp ;
}
+ rte_eal_pci_device_name ( addr , dev -> name , sizeof ( dev -> name ));
+ dev -> device . name = dev -> name ;
+
/* parse resources */
snprintf ( filename , sizeof ( filename ), "%s/resource" , dirname );
if ( pci_parse_sysfs_resource ( filename , dev ) < 0 ) { --
2.1.4
From: Jan Blunck <redacted>
In some cases the virtual device name should be totally different than
the driver being used for the device. Therefore lets parse the devargs for
the "driver" argument before probing drivers in vdev_probe_all_drivers().
Signed-off-by: Jan Blunck <redacted>
---
lib/librte_eal/common/eal_common_vdev.c | 51 +++++++++++++++++++++++++++++----
1 file changed, 46 insertions(+), 5 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index c922297..9158a1c 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c @@ -72,12 +72,51 @@ rte_eal_vdrv_unregister(struct rte_vdev_driver *driver)
TAILQ_REMOVE ( & vdev_driver_list , driver , next );
}
+ /*
+ * Parse "driver" devargs without adding a dependency on rte_kvargs . h
+ */
+ static char * parse_driver_arg ( const char * args )
+ {
+ const char * c ;
+ char * str ;
+
+ if ( ! args || args [ 0 ] == '\0' )
+ return NULL ;
+
+ c = args ;
+
+ do {
+ if ( strncmp ( c , "driver=" , 7 ) == 0 ) {
+ c += 7 ;
+ break ;
+ }
+
+ c = strchr ( c , ',' );
+ if ( c )
+ c ++ ;
+ } while ( c );
+
+ if ( c )
+ str = strdup ( c );
+ else
+ str = NULL ;
+
+ return str ;
+ }
+
static int
vdev_probe_all_drivers ( struct rte_vdev_device * dev )
{
- const char * name = rte_vdev_device_name ( dev );
+ const char * name ;
+ char * drv_name ;
struct rte_vdev_driver * driver ;
- int ret ;
+ int ret = 1 ;
+
+ drv_name = parse_driver_arg ( rte_vdev_device_args ( dev ));
+ name = drv_name ? drv_name : rte_vdev_device_name ( dev );
+
+ RTE_LOG ( DEBUG , EAL , "Search driver %s to probe device %s \n " , name ,
+ rte_vdev_device_name ( dev ));
TAILQ_FOREACH ( driver , & vdev_driver_list , next ) {
/* @@ -92,7 +131,7 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev)
ret = driver -> probe ( dev );
if ( ret )
dev -> device . driver = NULL ;
- return ret ;
+ goto out ;
}
}
@@ -105,11 +144,13 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev)
ret = driver -> probe ( dev );
if ( ret )
dev -> device . driver = NULL ;
- return ret ;
+ break ;
}
}
- return 1 ;
+ out :
+ free ( drv_name );
+ return ret ;
}
static struct rte_vdev_device * --
2.1.4
From: Jan Blunck <redacted>
This driver can use the library function rte_eth_dma_zone_reserve()
instead of duplicating the code.
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/nfp/nfp_net.c | 30 ++++++------------------------
1 file changed, 6 insertions(+), 24 deletions(-)
diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index 1a7a992..d06b10a 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c @@ -204,26 +204,6 @@ nn_cfg_writeq(struct nfp_net_hw *hw, int off, uint64_t val)
nn_writeq ( rte_cpu_to_le_64 ( val ), hw -> ctrl_bar + off );
}
- /* Creating memzone for hardware rings. */
- static const struct rte_memzone *
- ring_dma_zone_reserve ( struct rte_eth_dev * dev , const char * ring_name ,
- uint16_t queue_id , uint32_t ring_size , int socket_id )
- {
- char z_name [ RTE_MEMZONE_NAMESIZE ];
- const struct rte_memzone * mz ;
-
- snprintf ( z_name , sizeof ( z_name ), "%s_%s_%d_%d" ,
- dev -> driver -> pci_drv . driver . name ,
- ring_name , dev -> data -> port_id , queue_id );
-
- mz = rte_memzone_lookup ( z_name );
- if ( mz )
- return mz ;
-
- return rte_memzone_reserve_aligned ( z_name , ring_size , socket_id , 0 ,
- NFP_MEMZONE_ALIGN );
- }
-
/*
* Atomically reads link status information from global structure rte_eth_dev .
* @@ -1455,9 +1435,10 @@ nfp_net_rx_queue_setup(struct rte_eth_dev *dev,
* handle the maximum ring size is allocated in order to allow for
* resizing in later calls to the queue setup function .
*/
- tz = ring_dma_zone_reserve ( dev , "rx_ring" , queue_idx ,
+ tz = rte_eth_dma_zone_reserve ( dev , "rx_ring" , queue_idx ,
sizeof ( struct nfp_net_rx_desc ) *
- NFP_NET_MAX_RX_DESC , socket_id );
+ NFP_NET_MAX_RX_DESC , NFP_MEMZONE_ALIGN ,
+ socket_id );
if ( tz == NULL ) {
RTE_LOG ( ERR , PMD , "Error allocatig rx dma \n " ); @@ -1597,9 +1578,10 @@ nfp_net_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
* handle the maximum ring size is allocated in order to allow for
* resizing in later calls to the queue setup function .
*/
- tz = ring_dma_zone_reserve ( dev , "tx_ring" , queue_idx ,
+ tz = rte_eth_dma_zone_reserve ( dev , "tx_ring" , queue_idx ,
sizeof ( struct nfp_net_tx_desc ) *
- NFP_NET_MAX_TX_DESC , socket_id );
+ NFP_NET_MAX_TX_DESC , NFP_MEMZONE_ALIGN ,
+ socket_id );
if ( tz == NULL ) {
RTE_LOG ( ERR , PMD , "Error allocating tx dma \n " );
nfp_net_tx_queue_release ( txq ); --
2.1.4
From: Jan Blunck <redacted>
This helper should be used by ethdev drivers supporting virtual devices
to help allocating a new ethdev and properly filling the default fields.
Signed-off-by: Jan Blunck <redacted>
---
lib/librte_ether/Makefile | 1 +
lib/librte_ether/rte_ethdev_vdev.h | 85 ++++++++++++++++++++++++++++++++++++++
2 files changed, 86 insertions(+)
create mode 100644 lib/librte_ether/rte_ethdev_vdev.h
diff --git a/lib/librte_ether/Makefile b/lib/librte_ether/Makefile
index 066114b..d0017b8 100644
--- a/lib/librte_ether/Makefile
+++ b/lib/librte_ether/Makefile @@ -50,6 +50,7 @@ SRCS-y += rte_flow.c
# Export include files
#
SYMLINK-y-include += rte_ethdev.h
+ SYMLINK-y-include += rte_ethdev_vdev.h
SYMLINK-y-include += rte_eth_ctrl.h
SYMLINK-y-include += rte_dev_info.h
SYMLINK-y-include += rte_flow.h diff --git a/lib/librte_ether/rte_ethdev_vdev.h b/lib/librte_ether/rte_ethdev_vdev.h
new file mode 100644
index 0000000..0b47535
--- /dev/null
+++ b/lib/librte_ether/rte_ethdev_vdev.h @@ -0,0 +1,85 @@
+ /*-
+ * BSD LICENSE
+ *
+ * Copyright ( c ) 2017 Brocade Communications Systems , Inc .
+ * Author : Jan Blunck < jblunck @ infradead . org >
+ *
+ * Redistribution and use in source and binary forms , with or without
+ * modification , are permitted provided that the following conditions
+ * are met :
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice , this list of conditions and the following disclaimer .
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice , this list of conditions and the following disclaimer in
+ * the documentation and / or other materials provided with the
+ * distribution .
+ * * Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission .
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT
+ * LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL ,
+ * SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT
+ * LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE ,
+ * DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT
+ * ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
+ */
+
+ #ifndef _RTE_ETHDEV_VDEV_H_
+ #define _RTE_ETHDEV_VDEV_H_
+
+ #include <rte_malloc.h>
+ #include <rte_vdev.h>
+ #include <rte_ethdev.h>
+
+ /**
+ * @ internal
+ * Allocates a new ethdev slot for an ethernet device and returns the pointer
+ * to that slot for the driver to use .
+ *
+ * @ param dev
+ * Pointer to virtual device
+ *
+ * @ param private_data_size
+ * Size of private data structure
+ *
+ * @ return
+ * A pointer to a rte_eth_dev or NULL if allocation failed .
+ */
+ static inline struct rte_eth_dev *
+ rte_eth_vdev_allocate ( struct rte_vdev_device * dev , size_t private_data_size )
+ {
+ struct rte_eth_dev * eth_dev ;
+ const char * name = rte_vdev_device_name ( dev );
+
+ eth_dev = rte_eth_dev_allocate ( name );
+ if ( ! eth_dev )
+ return NULL ;
+
+ if ( private_data_size ) {
+ eth_dev -> data -> dev_private = rte_zmalloc_socket ( name ,
+ private_data_size , RTE_CACHE_LINE_SIZE ,
+ dev -> device . numa_node );
+ if ( ! eth_dev -> data -> dev_private ) {
+ rte_eth_dev_release_port ( eth_dev );
+ return NULL ;
+ }
+ }
+
+ eth_dev -> device = & dev -> device ;
+ eth_dev -> driver = NULL ;
+ eth_dev -> intr_handle = NULL ;
+
+ eth_dev -> data -> kdrv = RTE_KDRV_NONE ;
+ eth_dev -> data -> numa_node = dev -> device . numa_node ;
+ eth_dev -> data -> drv_name = dev -> device . driver -> name ;
+ return eth_dev ;
+ }
+
+ #endif /* _RTE_ETHDEV_VDEV_H_ */ --
2.1.4
From: Jan Blunck <redacted>
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/tap/rte_eth_tap.c | 38 +++++++++++++-------------------------
1 file changed, 13 insertions(+), 25 deletions(-)
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 698e14b..206a0d6 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c @@ -36,6 +36,7 @@
#include <rte_common.h>
#include <rte_mbuf.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_vdev.h>
#include <rte_malloc.h>
#include <rte_vdev.h>
#include <rte_kvargs.h> @@ -1131,12 +1132,13 @@ tap_kernel_support(struct pmd_internals *pmd)
}
static int
- eth_dev_tap_create ( const char * name , char * tap_name , char * remote_iface )
+ eth_dev_tap_create ( struct rte_vdev_device * vdev , char * tap_name ,
+ char * remote_iface )
{
int numa_node = rte_socket_id ();
- struct rte_eth_dev * dev = NULL ;
- struct pmd_internals * pmd = NULL ;
- struct rte_eth_dev_data * data = NULL ;
+ struct rte_eth_dev * dev ;
+ struct pmd_internals * pmd ;
+ struct rte_eth_dev_data * data ;
int i ;
RTE_LOG ( DEBUG , PMD , " TAP device on numa %u \n " , rte_socket_id ()); @@ -1147,22 +1149,14 @@ eth_dev_tap_create(const char *name, char *tap_name, char *remote_iface)
goto error_exit ;
}
- pmd = rte_zmalloc_socket ( tap_name , sizeof ( * pmd ), 0 , numa_node );
- if ( ! pmd ) {
- RTE_LOG ( ERR , PMD , "TAP Unable to allocate internal struct \n " );
- goto error_exit ;
- }
-
- /* name in allocation and data->name must be consistent */
- snprintf ( data -> name , sizeof ( data -> name ), "%s" , name );
- dev = rte_eth_dev_allocate ( name );
+ dev = rte_eth_vdev_allocate ( vdev , sizeof ( * pmd ));
if ( ! dev ) {
RTE_LOG ( ERR , PMD , "TAP Unable to allocate device struct \n " );
goto error_exit ;
}
+ pmd = dev -> data -> dev_private ;
snprintf ( pmd -> name , sizeof ( pmd -> name ), "%s" , tap_name );
-
pmd -> nb_queues = RTE_PMD_TAP_MAX_QUEUES ;
pmd -> ioctl_sock = socket ( AF_INET , SOCK_DGRAM , 0 ); @@ -1174,13 +1168,11 @@ eth_dev_tap_create(const char *name, char *tap_name, char *remote_iface)
}
/* Setup some default values */
+ rte_memcpy ( data , dev -> data , sizeof ( * data ));
data -> dev_private = pmd ;
- data -> port_id = dev -> data -> port_id ;
- data -> mtu = dev -> data -> mtu ;
data -> dev_flags = RTE_ETH_DEV_DETACHABLE | RTE_ETH_DEV_INTR_LSC ;
- data -> kdrv = RTE_KDRV_NONE ;
- data -> drv_name = pmd_tap_drv . driver . name ;
data -> numa_node = numa_node ;
+ data -> drv_name = pmd_tap_drv . driver . name ;
data -> dev_link = pmd_link ;
data -> mac_addrs = & pmd -> eth_addr ; @@ -1189,7 +1181,6 @@ eth_dev_tap_create(const char *name, char *tap_name, char *remote_iface)
dev -> data = data ;
dev -> dev_ops = & ops ;
- dev -> driver = NULL ;
dev -> rx_pkt_burst = pmd_rx_burst ;
dev -> tx_pkt_burst = pmd_tx_burst ;
@@ -1236,13 +1227,10 @@ eth_dev_tap_create(const char *name, char *tap_name, char *remote_iface)
return 0 ;
error_exit :
- RTE_LOG ( DEBUG , PMD , "TAP Unable to initialize %s \n " , name );
+ RTE_LOG ( DEBUG , PMD , "TAP Unable to initialize %s \n " ,
+ rte_vdev_device_name ( vdev ));
rte_free ( data );
- rte_free ( pmd );
-
- rte_eth_dev_release_port ( dev );
-
return - EINVAL ;
}
@@ -1343,7 +1331,7 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)
RTE_LOG ( NOTICE , PMD , "Initializing pmd_tap for %s as %s \n " ,
name , tap_name );
- ret = eth_dev_tap_create ( name , tap_name , remote_iface );
+ ret = eth_dev_tap_create ( dev , tap_name , remote_iface );
leave :
if ( ret == -1 ) { --
2.1.4
From: Jan Blunck <redacted>
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/vhost/rte_eth_vhost.c | 54 +++++++++++++++++++--------------------
1 file changed, 26 insertions(+), 28 deletions(-)
diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index cdd8c31..9663e55 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c @@ -36,6 +36,7 @@
#include <rte_mbuf.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_vdev.h>
#include <rte_malloc.h>
#include <rte_memcpy.h>
#include <rte_vdev.h> @@ -983,9 +984,10 @@ static const struct eth_dev_ops ops = {
static struct rte_vdev_driver pmd_vhost_drv ;
static int
- eth_dev_vhost_create ( const char * name , char * iface_name , int16_t queues ,
- const unsigned numa_node , uint64_t flags )
+ eth_dev_vhost_create ( struct rte_vdev_device * dev , char * iface_name ,
+ int16_t queues , const unsigned int numa_node , uint64_t flags )
{
+ const char * name = rte_vdev_device_name ( dev );
struct rte_eth_dev_data * data = NULL ;
struct pmd_internal * internal = NULL ;
struct rte_eth_dev * eth_dev = NULL ; @@ -996,23 +998,19 @@ eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues,
RTE_LOG ( INFO , PMD , "Creating VHOST-USER backend on numa socket %u \n " ,
numa_node );
- /* now do all data allocation - for eth_dev structure, dummy pci driver
- * and internal ( private ) data
+ /* now do all data allocation - for eth_dev structure and internal
+ * ( private ) data
*/
data = rte_zmalloc_socket ( name , sizeof ( * data ), 0 , numa_node );
if ( data == NULL )
goto error ;
- internal = rte_zmalloc_socket ( name , sizeof ( * internal ), 0 , numa_node );
- if ( internal == NULL )
- goto error ;
-
list = rte_zmalloc_socket ( name , sizeof ( * list ), 0 , numa_node );
if ( list == NULL )
goto error ;
/* reserve an ethdev entry */
- eth_dev = rte_eth_dev_allocate ( name );
+ eth_dev = rte_eth_vdev_allocate ( dev , sizeof ( * internal ));
if ( eth_dev == NULL )
goto error ;
@@ -1029,10 +1027,10 @@ eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues,
/* now put it all together
* - store queue data in internal ,
- * - store numa_node info in ethdev data
* - point eth_dev_data to internals
* - and point eth_dev structure to new eth_dev_data structure
*/
+ internal = eth_dev -> data -> dev_private ;
internal -> dev_name = strdup ( name );
if ( internal -> dev_name == NULL )
goto error ; @@ -1048,26 +1046,21 @@ eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues,
rte_spinlock_init ( & vring_state -> lock );
vring_states [ eth_dev -> data -> port_id ] = vring_state ;
- data -> dev_private = internal ;
- data -> port_id = eth_dev -> data -> port_id ;
- memmove ( data -> name , eth_dev -> data -> name , sizeof ( data -> name ));
+ /* We'll replace the 'data' originally allocated by eth_dev. So the
+ * vhost PMD resources won ' t be shared between multi processes .
+ */
+ rte_memcpy ( data , eth_dev -> data , sizeof ( * data ));
+ eth_dev -> data = data ;
+
data -> nb_rx_queues = queues ;
data -> nb_tx_queues = queues ;
internal -> max_queues = queues ;
data -> dev_link = pmd_link ;
data -> mac_addrs = eth_addr ;
-
- /* We'll replace the 'data' originally allocated by eth_dev. So the
- * vhost PMD resources won ' t be shared between multi processes .
- */
- eth_dev -> data = data ;
- eth_dev -> dev_ops = & ops ;
- eth_dev -> driver = NULL ;
data -> dev_flags =
RTE_ETH_DEV_DETACHABLE | RTE_ETH_DEV_INTR_LSC ;
- data -> kdrv = RTE_KDRV_NONE ;
- data -> drv_name = pmd_vhost_drv . driver . name ;
- data -> numa_node = numa_node ;
+
+ eth_dev -> dev_ops = & ops ;
/* finally assign rx and tx ops */
eth_dev -> rx_pkt_burst = eth_vhost_rx ; @@ -1090,8 +1083,10 @@ eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues,
return data -> port_id ;
error :
- if ( internal )
+ if ( internal ) {
+ free ( internal -> iface_name );
free ( internal -> dev_name );
+ }
rte_free ( vring_state );
rte_free ( eth_addr );
if ( eth_dev ) @@ -1134,7 +1129,6 @@ open_int(const char *key __rte_unused, const char *value, void *extra_args)
static int
rte_pmd_vhost_probe ( struct rte_vdev_device * dev )
{
- const char * name ;
struct rte_kvargs * kvlist = NULL ;
int ret = 0 ;
char * iface_name ; @@ -1143,8 +1137,8 @@ rte_pmd_vhost_probe(struct rte_vdev_device *dev)
int client_mode = 0 ;
int dequeue_zero_copy = 0 ;
- name = rte_vdev_device_name ( dev );
- RTE_LOG ( INFO , PMD , "Initializing pmd_vhost for %s \n " , name );
+ RTE_LOG ( INFO , PMD , "Initializing pmd_vhost for %s \n " ,
+ rte_vdev_device_name ( dev ));
kvlist = rte_kvargs_parse ( rte_vdev_device_args ( dev ), valid_arguments );
if ( kvlist == NULL ) @@ -1189,7 +1183,11 @@ rte_pmd_vhost_probe(struct rte_vdev_device *dev)
flags |= RTE_VHOST_USER_DEQUEUE_ZERO_COPY ;
}
- eth_dev_vhost_create ( name , iface_name , queues , rte_socket_id (), flags );
+ if ( dev -> device . numa_node == SOCKET_ID_ANY )
+ dev -> device . numa_node = rte_socket_id ();
+
+ eth_dev_vhost_create ( dev , iface_name , queues , dev -> device . numa_node ,
+ flags );
out_free :
rte_kvargs_free ( kvlist ); --
2.1.4
From: Jan Blunck <redacted>
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/virtio/virtio_user_ethdev.c | 20 +++++---------------
1 file changed, 5 insertions(+), 15 deletions(-)
diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index 46276ee..361841a 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -40,6 +40,7 @@
#include <rte_malloc.h>
#include <rte_kvargs.h>
+ #include <rte_ethdev_vdev.h>
#include <rte_vdev.h>
#include <rte_alarm.h>
@@ -336,27 +337,21 @@ get_integer_arg(const char *key __rte_unused,
static struct rte_vdev_driver virtio_user_driver ;
static struct rte_eth_dev *
- virtio_user_eth_dev_alloc ( const char * name )
+ virtio_user_eth_dev_alloc ( struct rte_vdev_device * vdev )
{
struct rte_eth_dev * eth_dev ;
struct rte_eth_dev_data * data ;
struct virtio_hw * hw ;
struct virtio_user_dev * dev ;
- eth_dev = rte_eth_dev_allocate ( name );
+ eth_dev = rte_eth_vdev_allocate ( vdev , sizeof ( * hw ));
if ( ! eth_dev ) {
PMD_INIT_LOG ( ERR , "cannot alloc rte_eth_dev" );
return NULL ;
}
data = eth_dev -> data ;
-
- hw = rte_zmalloc ( NULL , sizeof ( * hw ), 0 );
- if ( ! hw ) {
- PMD_INIT_LOG ( ERR , "malloc virtio_hw failed" );
- rte_eth_dev_release_port ( eth_dev );
- return NULL ;
- }
+ hw = eth_dev -> data -> dev_private ;
dev = rte_zmalloc ( NULL , sizeof ( * dev ), 0 );
if ( ! dev ) { @@ -377,12 +372,7 @@ virtio_user_eth_dev_alloc(const char *name)
hw -> modern = 0 ;
hw -> use_simple_rxtx = 0 ;
hw -> virtio_user_dev = dev ;
- data -> dev_private = hw ;
- data -> drv_name = virtio_user_driver . driver . name ;
- data -> numa_node = SOCKET_ID_ANY ;
- data -> kdrv = RTE_KDRV_NONE ;
data -> dev_flags = RTE_ETH_DEV_DETACHABLE ;
- eth_dev -> driver = NULL ;
return eth_dev ;
}
@@ -500,7 +490,7 @@ virtio_user_pmd_probe(struct rte_vdev_device *dev)
goto end ;
}
- eth_dev = virtio_user_eth_dev_alloc ( rte_vdev_device_name ( dev ));
+ eth_dev = virtio_user_eth_dev_alloc ( dev );
if ( ! eth_dev ) {
PMD_INIT_LOG ( ERR , "virtio_user fails to alloc device" );
goto end ; --
2.1.4
From: Jan Blunck <redacted>
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/af_packet/rte_eth_af_packet.c | 42 ++++++++++++++-----------------
1 file changed, 19 insertions(+), 23 deletions(-)
diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 77536e8..6f6ba0c 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -38,6 +38,7 @@
#include <rte_mbuf.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_vdev.h>
#include <rte_malloc.h>
#include <rte_kvargs.h>
#include <rte_vdev.h> @@ -539,18 +540,19 @@ open_packet_iface(const char *key __rte_unused,
static struct rte_vdev_driver pmd_af_packet_drv ;
static int
- rte_pmd_init_internals ( const char * name ,
+ rte_pmd_init_internals ( struct rte_vdev_device * dev ,
const int sockfd ,
const unsigned nb_queues ,
unsigned int blocksize ,
unsigned int blockcnt ,
unsigned int framesize ,
unsigned int framecnt ,
- const unsigned numa_node ,
struct pmd_internals ** internals ,
struct rte_eth_dev ** eth_dev ,
struct rte_kvargs * kvlist )
{
+ const char * name = rte_vdev_device_name ( dev );
+ const unsigned int numa_node = dev -> device . numa_node ;
struct rte_eth_dev_data * data = NULL ;
struct rte_kvargs_pair * pair = NULL ;
struct ifreq ifr ; @@ -768,7 +770,7 @@ rte_pmd_init_internals(const char *name,
}
/* reserve an ethdev entry */
- * eth_dev = rte_eth_dev_allocate ( name );
+ * eth_dev = rte_eth_vdev_allocate ( dev , 0 );
if ( * eth_dev == NULL )
goto error ;
@@ -782,22 +784,16 @@ rte_pmd_init_internals(const char *name,
( * internals ) -> nb_queues = nb_queues ;
+ rte_memcpy ( data , ( * eth_dev ) -> data , sizeof ( * data ));
data -> dev_private = * internals ;
- data -> port_id = ( * eth_dev ) -> data -> port_id ;
data -> nb_rx_queues = ( uint16_t ) nb_queues ;
data -> nb_tx_queues = ( uint16_t ) nb_queues ;
data -> dev_link = pmd_link ;
data -> mac_addrs = & ( * internals ) -> eth_addr ;
- strncpy ( data -> name ,
- ( * eth_dev ) -> data -> name , strlen (( * eth_dev ) -> data -> name ));
( * eth_dev ) -> data = data ;
( * eth_dev ) -> dev_ops = & ops ;
- ( * eth_dev ) -> driver = NULL ;
( * eth_dev ) -> data -> dev_flags = RTE_ETH_DEV_DETACHABLE ;
- ( * eth_dev ) -> data -> drv_name = pmd_af_packet_drv . driver . name ;
- ( * eth_dev ) -> data -> kdrv = RTE_KDRV_NONE ;
- ( * eth_dev ) -> data -> numa_node = numa_node ;
return 0 ;
@@ -822,11 +818,11 @@ rte_pmd_init_internals(const char *name,
}
static int
- rte_eth_from_packet ( const char * name ,
+ rte_eth_from_packet ( struct rte_vdev_device * dev ,
int const * sockfd ,
- const unsigned numa_node ,
struct rte_kvargs * kvlist )
{
+ const char * name = rte_vdev_device_name ( dev );
struct pmd_internals * internals = NULL ;
struct rte_eth_dev * eth_dev = NULL ;
struct rte_kvargs_pair * pair = NULL ; @@ -909,11 +905,11 @@ rte_eth_from_packet(const char *name,
RTE_LOG ( INFO , PMD , "%s: \t frame size %d \n " , name , framesize );
RTE_LOG ( INFO , PMD , "%s: \t frame count %d \n " , name , framecount );
- if ( rte_pmd_init_internals ( name , * sockfd , qpairs ,
- blocksize , blockcount ,
- framesize , framecount ,
- numa_node , & internals , & eth_dev ,
- kvlist ) < 0 )
+ if ( rte_pmd_init_internals ( dev , * sockfd , qpairs ,
+ blocksize , blockcount ,
+ framesize , framecount ,
+ & internals , & eth_dev ,
+ kvlist ) < 0 )
return -1 ;
eth_dev -> rx_pkt_burst = eth_af_packet_rx ; @@ -925,15 +921,12 @@ rte_eth_from_packet(const char *name,
static int
rte_pmd_af_packet_probe ( struct rte_vdev_device * dev )
{
- const char * name = rte_vdev_device_name ( dev );
- unsigned numa_node ;
int ret = 0 ;
struct rte_kvargs * kvlist ;
int sockfd = -1 ;
- RTE_LOG ( INFO , PMD , "Initializing pmd_af_packet for %s \n " , name );
-
- numa_node = rte_socket_id ();
+ RTE_LOG ( INFO , PMD , "Initializing pmd_af_packet for %s \n " ,
+ rte_vdev_device_name ( dev ));
kvlist = rte_kvargs_parse ( rte_vdev_device_args ( dev ), valid_arguments );
if ( kvlist == NULL ) { @@ -953,7 +946,10 @@ rte_pmd_af_packet_probe(struct rte_vdev_device *dev)
goto exit ;
}
- ret = rte_eth_from_packet ( name , & sockfd , numa_node , kvlist );
+ if ( dev -> device . numa_node == SOCKET_ID_ANY )
+ dev -> device . numa_node = rte_socket_id ();
+
+ ret = rte_eth_from_packet ( dev , & sockfd , kvlist );
close ( sockfd ); /* no longer needed */
exit : --
2.1.4
From: Jan Blunck <redacted>
A virtual device should get initialized through the rte_eal_vdev_init()
function to properly initialize the driver.
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/null/rte_eth_null.c | 1 +
test/test/test_link_bonding_rssconf.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index a7b57bc..4a0d07d 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c @@ -50,6 +50,7 @@ static unsigned default_packet_copy;
static const char * valid_arguments [] = {
ETH_NULL_PACKET_SIZE_ARG ,
ETH_NULL_PACKET_COPY_ARG ,
+ "driver" ,
NULL
};
diff --git a/test/test/test_link_bonding_rssconf.c b/test/test/test_link_bonding_rssconf.c
index 9034f62..3a2cac3 100644
--- a/test/test/test_link_bonding_rssconf.c
+++ b/test/test/test_link_bonding_rssconf.c @@ -551,7 +551,8 @@ test_setup(void)
port_id = rte_eth_dev_count ();
snprintf ( name , sizeof ( name ), SLAVE_DEV_NAME_FMT , port_id );
- retval = eth_dev_null_create ( name , 0 , 64 , 0 );
+ retval = rte_eal_vdev_init ( name ,
+ "driver=net_null,size=64,copy=0" );
TEST_ASSERT_SUCCESS ( retval , "Failed to create null device '%s' \n " ,
name );
--
2.1.4
From: Jan Blunck <redacted>
There is no need to export this API. Remaining users should use the
rte_eal_vdev_init() function instead.
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/null/Makefile | 7 +-----
drivers/net/null/rte_eth_null.c | 4 +---
drivers/net/null/rte_eth_null.h | 40 -------------------------------
drivers/net/null/rte_pmd_null_version.map | 7 ------
test/test/test_link_bonding_rssconf.c | 1 -
5 files changed, 2 insertions(+), 57 deletions(-)
delete mode 100644 drivers/net/null/rte_eth_null.h
diff --git a/drivers/net/null/Makefile b/drivers/net/null/Makefile
index 40a839f..77810bc 100644
--- a/drivers/net/null/Makefile
+++ b/drivers/net/null/Makefile @@ -41,16 +41,11 @@ CFLAGS += $(WERROR_FLAGS)
EXPORT_MAP := rte_pmd_null_version.map
- LIBABIVER := 1
+ LIBABIVER := 2
#
# all source are stored in SRCS-y
#
SRCS-$(CONFIG_RTE_LIBRTE_PMD_NULL) += rte_eth_null.c
- #
- # Export include files
- #
- SYMLINK-y-include += rte_eth_null.h
-
include $(RTE_SDK)/mk/rte.lib.mk diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 4a0d07d..863fcc7 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c @@ -39,8 +39,6 @@
#include <rte_kvargs.h>
#include <rte_spinlock.h>
- #include "rte_eth_null.h"
-
#define ETH_NULL_PACKET_SIZE_ARG "size"
#define ETH_NULL_PACKET_COPY_ARG "copy"
@@ -478,7 +476,7 @@ static const struct eth_dev_ops ops = {
static struct rte_vdev_driver pmd_null_drv ;
- int
+ static int
eth_dev_null_create ( const char * name ,
const unsigned numa_node ,
unsigned packet_size , diff --git a/drivers/net/null/rte_eth_null.h b/drivers/net/null/rte_eth_null.h
deleted file mode 100644
index abada8c..0000000
--- a/drivers/net/null/rte_eth_null.h
+++ /dev/null @@ -1,40 +0,0 @@
- /*-
- * BSD LICENSE
- *
- * Copyright(c) 2015 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
- #ifndef RTE_ETH_NULL_H_
- #define RTE_ETH_NULL_H_
-
- int eth_dev_null_create(const char *name, const unsigned numa_node,
- unsigned packet_size, unsigned packet_copy);
-
- #endif /* RTE_ETH_NULL_H_ */diff --git a/drivers/net/null/rte_pmd_null_version.map b/drivers/net/null/rte_pmd_null_version.map
index 84b1d0f..ef35398 100644
--- a/drivers/net/null/rte_pmd_null_version.map
+++ b/drivers/net/null/rte_pmd_null_version.map @@ -2,10 +2,3 @@ DPDK_2.0 {
local: *;
};
-
- DPDK_2.2 {
- global:
-
- eth_dev_null_create;
-
- } DPDK_2.0;diff --git a/test/test/test_link_bonding_rssconf.c b/test/test/test_link_bonding_rssconf.c
index 3a2cac3..f356c95 100644
--- a/test/test/test_link_bonding_rssconf.c
+++ b/test/test/test_link_bonding_rssconf.c @@ -52,7 +52,6 @@
#include <rte_string_fns.h>
#include <rte_errno.h>
#include <rte_eth_bond.h>
- #include <rte_eth_null.h>
#include "test.h"
--
2.1.4
From: Jan Blunck <redacted>
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/null/rte_eth_null.c | 50 ++++++++++++++---------------------------
1 file changed, 17 insertions(+), 33 deletions(-)
diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 863fcc7..abf3ec7 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c @@ -33,6 +33,7 @@
#include <rte_mbuf.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_vdev.h>
#include <rte_malloc.h>
#include <rte_memcpy.h>
#include <rte_vdev.h> @@ -477,8 +478,7 @@ static const struct eth_dev_ops ops = {
static struct rte_vdev_driver pmd_null_drv ;
static int
- eth_dev_null_create ( const char * name ,
- const unsigned numa_node ,
+ eth_dev_null_create ( struct rte_vdev_device * dev ,
unsigned packet_size ,
unsigned packet_copy )
{ @@ -495,27 +495,25 @@ eth_dev_null_create(const char *name,
0xBE , 0xAC , 0x01 , 0xFA
};
- if ( name == NULL )
- return - EINVAL ;
+ if ( dev -> device . numa_node == SOCKET_ID_ANY )
+ dev -> device . numa_node = rte_socket_id ();
RTE_LOG ( INFO , PMD , "Creating null ethdev on numa socket %u \n " ,
- numa_node );
+ dev -> device . numa_node );
/* now do all data allocation - for eth_dev structure, dummy pci driver
* and internal ( private ) data
*/
- data = rte_zmalloc_socket ( name , sizeof ( * data ), 0 , numa_node );
- if ( data == NULL )
- goto error ;
-
- internals = rte_zmalloc_socket ( name , sizeof ( * internals ), 0 , numa_node );
- if ( internals == NULL )
- goto error ;
+ data = rte_zmalloc_socket ( rte_vdev_device_name ( dev ), sizeof ( * data ), 0 ,
+ dev -> device . numa_node );
+ if ( ! data )
+ return - ENOMEM ;
- /* reserve an ethdev entry */
- eth_dev = rte_eth_dev_allocate ( name );
- if ( eth_dev == NULL )
- goto error ;
+ eth_dev = rte_eth_vdev_allocate ( dev , sizeof ( * internals ));
+ if ( ! eth_dev ) {
+ rte_free ( data );
+ return - ENOMEM ;
+ }
/* now put it all together
* - store queue data in internals , @@ -526,6 +524,7 @@ eth_dev_null_create(const char *name,
/* NOTE: we'll replace the data element, of originally allocated eth_dev
* so the nulls are local per - process */
+ internals = eth_dev -> data -> dev_private ;
internals -> packet_size = packet_size ;
internals -> packet_copy = packet_copy ;
internals -> port_id = eth_dev -> data -> port_id ; @@ -535,22 +534,16 @@ eth_dev_null_create(const char *name,
rte_memcpy ( internals -> rss_key , default_rss_key , 40 );
- data -> dev_private = internals ;
- data -> port_id = eth_dev -> data -> port_id ;
+ rte_memcpy ( data , eth_dev -> data , sizeof ( * data ));
data -> nb_rx_queues = ( uint16_t ) nb_rx_queues ;
data -> nb_tx_queues = ( uint16_t ) nb_tx_queues ;
data -> dev_link = pmd_link ;
data -> mac_addrs = & eth_addr ;
- strncpy ( data -> name , eth_dev -> data -> name , strlen ( eth_dev -> data -> name ));
eth_dev -> data = data ;
eth_dev -> dev_ops = & ops ;
- eth_dev -> driver = NULL ;
data -> dev_flags = RTE_ETH_DEV_DETACHABLE ;
- data -> kdrv = RTE_KDRV_NONE ;
- data -> drv_name = pmd_null_drv . driver . name ;
- data -> numa_node = numa_node ;
/* finally assign rx and tx ops */
if ( packet_copy ) { @@ -562,12 +555,6 @@ eth_dev_null_create(const char *name,
}
return 0 ;
-
- error :
- rte_free ( data );
- rte_free ( internals );
-
- return -1 ;
}
static inline int @@ -608,7 +595,6 @@ static int
rte_pmd_null_probe ( struct rte_vdev_device * dev )
{
const char * name , * params ;
- unsigned numa_node ;
unsigned packet_size = default_packet_size ;
unsigned packet_copy = default_packet_copy ;
struct rte_kvargs * kvlist = NULL ; @@ -621,8 +607,6 @@ rte_pmd_null_probe(struct rte_vdev_device *dev)
params = rte_vdev_device_args ( dev );
RTE_LOG ( INFO , PMD , "Initializing pmd_null for %s \n " , name );
- numa_node = rte_socket_id ();
-
if ( params != NULL ) {
kvlist = rte_kvargs_parse ( params , valid_arguments );
if ( kvlist == NULL ) @@ -651,7 +635,7 @@ rte_pmd_null_probe(struct rte_vdev_device *dev)
"packet copy is %s \n " , packet_size ,
packet_copy ? "enabled" : "disabled" );
- ret = eth_dev_null_create ( name , numa_node , packet_size , packet_copy );
+ ret = eth_dev_null_create ( dev , packet_size , packet_copy );
free_kvlist :
if ( kvlist ) --
2.1.4
From: Jan Blunck <redacted>
To properly embed the generic rte_device into the rte_eth_dev this reworks
the bonding API to call through rte_eal_vdev_init().
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/bonding/rte_eth_bond_api.c | 171 +++++--------------------------
drivers/net/bonding/rte_eth_bond_args.c | 2 +-
drivers/net/bonding/rte_eth_bond_pmd.c | 174 ++++++++++++++++++++++++++++++--
3 files changed, 194 insertions(+), 153 deletions(-)
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index f552d96..80c7091 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c @@ -38,13 +38,12 @@
#include <rte_ethdev.h>
#include <rte_tcp.h>
#include <rte_vdev.h>
+ #include <rte_kvargs.h>
#include "rte_eth_bond.h"
#include "rte_eth_bond_private.h"
#include "rte_eth_bond_8023ad_private.h"
- #define DEFAULT_POLLING_INTERVAL_10_MS (10)
-
int
check_for_bonded_ethdev ( const struct rte_eth_dev * eth_dev )
{ @@ -163,163 +162,45 @@ number_of_sockets(void)
int
rte_eth_bond_create ( const char * name , uint8_t mode , uint8_t socket_id )
{
- struct bond_dev_private * internals = NULL ;
- struct rte_eth_dev * eth_dev = NULL ;
- uint32_t vlan_filter_bmp_size ;
-
- /* now do all data allocation - for eth_dev structure, dummy pci driver
- * and internal ( private ) data
- */
+ struct bond_dev_private * internals ;
+ char devargs [ 52 ];
+ uint8_t port_id ;
+ int ret ;
if ( name == NULL ) {
RTE_BOND_LOG ( ERR , "Invalid name specified" );
- goto err ;
- }
-
- if ( socket_id >= number_of_sockets ()) {
- RTE_BOND_LOG ( ERR ,
- "Invalid socket id specified to create bonded device on." );
- goto err ;
+ return - EINVAL ;
}
- internals = rte_zmalloc_socket ( name , sizeof ( * internals ), 0 , socket_id );
- if ( internals == NULL ) {
- RTE_BOND_LOG ( ERR , "Unable to malloc internals on socket" );
- goto err ;
- }
+ ret = snprintf ( devargs , sizeof ( devargs ),
+ "driver=net_bonding,mode=%d,socket_id=%d" , mode , socket_id );
+ if ( ret < 0 || ret >= ( int ) sizeof ( devargs ))
+ return - ENOMEM ;
- /* reserve an ethdev entry */
- eth_dev = rte_eth_dev_allocate ( name );
- if ( eth_dev == NULL ) {
- RTE_BOND_LOG ( ERR , "Unable to allocate rte_eth_dev" );
- goto err ;
- }
+ ret = rte_eal_vdev_init ( name , devargs );
+ if ( ret )
+ return - ENOMEM ;
- eth_dev -> data -> dev_private = internals ;
- eth_dev -> data -> nb_rx_queues = ( uint16_t ) 1 ;
- eth_dev -> data -> nb_tx_queues = ( uint16_t ) 1 ;
-
- eth_dev -> data -> mac_addrs = rte_zmalloc_socket ( name , ETHER_ADDR_LEN , 0 ,
- socket_id );
- if ( eth_dev -> data -> mac_addrs == NULL ) {
- RTE_BOND_LOG ( ERR , "Unable to malloc mac_addrs" );
- goto err ;
- }
-
- eth_dev -> dev_ops = & default_dev_ops ;
- eth_dev -> data -> dev_flags = RTE_ETH_DEV_INTR_LSC |
- RTE_ETH_DEV_DETACHABLE ;
- eth_dev -> driver = NULL ;
- eth_dev -> data -> kdrv = RTE_KDRV_NONE ;
- eth_dev -> data -> drv_name = pmd_bond_drv . driver . name ;
- eth_dev -> data -> numa_node = socket_id ;
-
- rte_spinlock_init ( & internals -> lock );
-
- internals -> port_id = eth_dev -> data -> port_id ;
- internals -> mode = BONDING_MODE_INVALID ;
- internals -> current_primary_port = RTE_MAX_ETHPORTS + 1 ;
- internals -> balance_xmit_policy = BALANCE_XMIT_POLICY_LAYER2 ;
- internals -> xmit_hash = xmit_l2_hash ;
- internals -> user_defined_mac = 0 ;
- internals -> link_props_set = 0 ;
-
- internals -> link_status_polling_enabled = 0 ;
-
- internals -> link_status_polling_interval_ms = DEFAULT_POLLING_INTERVAL_10_MS ;
- internals -> link_down_delay_ms = 0 ;
- internals -> link_up_delay_ms = 0 ;
-
- internals -> slave_count = 0 ;
- internals -> active_slave_count = 0 ;
- internals -> rx_offload_capa = 0 ;
- internals -> tx_offload_capa = 0 ;
- internals -> candidate_max_rx_pktlen = 0 ;
- internals -> max_rx_pktlen = 0 ;
-
- /* Initially allow to choose any offload type */
- internals -> flow_type_rss_offloads = ETH_RSS_PROTO_MASK ;
-
- memset ( internals -> active_slaves , 0 , sizeof ( internals -> active_slaves ));
- memset ( internals -> slaves , 0 , sizeof ( internals -> slaves ));
-
- /* Set mode 4 default configuration */
- bond_mode_8023ad_setup ( eth_dev , NULL );
- if ( bond_ethdev_mode_set ( eth_dev , mode )) {
- RTE_BOND_LOG ( ERR , "Failed to set bonded device %d mode too %d" ,
- eth_dev -> data -> port_id , mode );
- goto err ;
- }
+ ret = rte_eth_dev_get_port_by_name ( name , & port_id );
+ RTE_ASSERT ( ! ret );
- vlan_filter_bmp_size =
- rte_bitmap_get_memory_footprint ( ETHER_MAX_VLAN_ID + 1 );
- internals -> vlan_filter_bmpmem = rte_malloc ( name , vlan_filter_bmp_size ,
- RTE_CACHE_LINE_SIZE );
- if ( internals -> vlan_filter_bmpmem == NULL ) {
- RTE_BOND_LOG ( ERR ,
- "Failed to allocate vlan bitmap for bonded device %u \n " ,
- eth_dev -> data -> port_id );
- goto err ;
- }
-
- internals -> vlan_filter_bmp = rte_bitmap_init ( ETHER_MAX_VLAN_ID + 1 ,
- internals -> vlan_filter_bmpmem , vlan_filter_bmp_size );
- if ( internals -> vlan_filter_bmp == NULL ) {
- RTE_BOND_LOG ( ERR ,
- "Failed to init vlan bitmap for bonded device %u \n " ,
- eth_dev -> data -> port_id );
- rte_free ( internals -> vlan_filter_bmpmem );
- goto err ;
- }
-
- return eth_dev -> data -> port_id ;
+ /*
+ * To make bond_ethdev_configure () happy we need to free the
+ * internals -> kvlist here .
+ *
+ * Also see comment in bond_ethdev_configure ().
+ */
+ internals = rte_eth_devices [ port_id ]. data -> dev_private ;
+ rte_kvargs_free ( internals -> kvlist );
+ internals -> kvlist = NULL ;
- err :
- rte_free ( internals );
- if ( eth_dev != NULL ) {
- rte_free ( eth_dev -> data -> mac_addrs );
- rte_eth_dev_release_port ( eth_dev );
- }
- return -1 ;
+ return port_id ;
}
int
rte_eth_bond_free ( const char * name )
{
- struct rte_eth_dev * eth_dev = NULL ;
- struct bond_dev_private * internals ;
-
- /* now free all data allocation - for eth_dev structure,
- * dummy pci driver and internal ( private ) data
- */
-
- /* find an ethdev entry */
- eth_dev = rte_eth_dev_allocated ( name );
- if ( eth_dev == NULL )
- return - ENODEV ;
-
- internals = eth_dev -> data -> dev_private ;
- if ( internals -> slave_count != 0 )
- return - EBUSY ;
-
- if ( eth_dev -> data -> dev_started == 1 ) {
- bond_ethdev_stop ( eth_dev );
- bond_ethdev_close ( eth_dev );
- }
-
- eth_dev -> dev_ops = NULL ;
- eth_dev -> rx_pkt_burst = NULL ;
- eth_dev -> tx_pkt_burst = NULL ;
-
- internals = eth_dev -> data -> dev_private ;
- rte_bitmap_free ( internals -> vlan_filter_bmp );
- rte_free ( internals -> vlan_filter_bmpmem );
- rte_free ( eth_dev -> data -> dev_private );
- rte_free ( eth_dev -> data -> mac_addrs );
-
- rte_eth_dev_release_port ( eth_dev );
-
- return 0 ;
+ return rte_eal_vdev_uninit ( name );
}
static int diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c
index 3dca273..e3bdad9 100644
--- a/drivers/net/bonding/rte_eth_bond_args.c
+++ b/drivers/net/bonding/rte_eth_bond_args.c @@ -47,7 +47,7 @@ const char *pmd_bond_init_valid_arguments[] = {
PMD_BOND_XMIT_POLICY_KVARG ,
PMD_BOND_SOCKET_ID_KVARG ,
PMD_BOND_MAC_ADDR_KVARG ,
-
+ "driver" ,
NULL
};
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 340d793..2b1db0b 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -51,6 +51,7 @@
#include "rte_eth_bond_8023ad_private.h"
#define REORDER_PERIOD_MS 10
+ #define DEFAULT_POLLING_INTERVAL_10_MS (10)
#define HASH_L4_PORTS(h) ((h)->src_port ^ (h)->dst_port)
@@ -2240,6 +2241,132 @@ const struct eth_dev_ops default_dev_ops = {
};
static int
+ bond_alloc ( struct rte_vdev_device * dev , uint8_t mode )
+ {
+ const char * name = rte_vdev_device_name ( dev );
+ uint8_t socket_id = dev -> device . numa_node ;
+ struct bond_dev_private * internals = NULL ;
+ struct rte_eth_dev * eth_dev = NULL ;
+ uint32_t vlan_filter_bmp_size ;
+
+ /* now do all data allocation - for eth_dev structure, dummy pci driver
+ * and internal ( private ) data
+ */
+
+ if ( name == NULL ) {
+ RTE_BOND_LOG ( ERR , "Invalid name specified" );
+ goto err ;
+ }
+
+ if ( socket_id >= number_of_sockets ()) {
+ RTE_BOND_LOG ( ERR ,
+ "Invalid socket id specified to create bonded device on." );
+ goto err ;
+ }
+
+ internals = rte_zmalloc_socket ( name , sizeof ( * internals ), 0 , socket_id );
+ if ( internals == NULL ) {
+ RTE_BOND_LOG ( ERR , "Unable to malloc internals on socket" );
+ goto err ;
+ }
+
+ /* reserve an ethdev entry */
+ eth_dev = rte_eth_dev_allocate ( name );
+ if ( eth_dev == NULL ) {
+ RTE_BOND_LOG ( ERR , "Unable to allocate rte_eth_dev" );
+ goto err ;
+ }
+
+ eth_dev -> data -> dev_private = internals ;
+ eth_dev -> data -> nb_rx_queues = ( uint16_t ) 1 ;
+ eth_dev -> data -> nb_tx_queues = ( uint16_t ) 1 ;
+
+ eth_dev -> data -> mac_addrs = rte_zmalloc_socket ( name , ETHER_ADDR_LEN , 0 ,
+ socket_id );
+ if ( eth_dev -> data -> mac_addrs == NULL ) {
+ RTE_BOND_LOG ( ERR , "Unable to malloc mac_addrs" );
+ goto err ;
+ }
+
+ eth_dev -> dev_ops = & default_dev_ops ;
+ eth_dev -> data -> dev_flags = RTE_ETH_DEV_INTR_LSC |
+ RTE_ETH_DEV_DETACHABLE ;
+ eth_dev -> driver = NULL ;
+ eth_dev -> data -> kdrv = RTE_KDRV_NONE ;
+ eth_dev -> data -> drv_name = pmd_bond_drv . driver . name ;
+ eth_dev -> data -> numa_node = socket_id ;
+
+ rte_spinlock_init ( & internals -> lock );
+
+ internals -> port_id = eth_dev -> data -> port_id ;
+ internals -> mode = BONDING_MODE_INVALID ;
+ internals -> current_primary_port = RTE_MAX_ETHPORTS + 1 ;
+ internals -> balance_xmit_policy = BALANCE_XMIT_POLICY_LAYER2 ;
+ internals -> xmit_hash = xmit_l2_hash ;
+ internals -> user_defined_mac = 0 ;
+ internals -> link_props_set = 0 ;
+
+ internals -> link_status_polling_enabled = 0 ;
+
+ internals -> link_status_polling_interval_ms =
+ DEFAULT_POLLING_INTERVAL_10_MS ;
+ internals -> link_down_delay_ms = 0 ;
+ internals -> link_up_delay_ms = 0 ;
+
+ internals -> slave_count = 0 ;
+ internals -> active_slave_count = 0 ;
+ internals -> rx_offload_capa = 0 ;
+ internals -> tx_offload_capa = 0 ;
+ internals -> candidate_max_rx_pktlen = 0 ;
+ internals -> max_rx_pktlen = 0 ;
+
+ /* Initially allow to choose any offload type */
+ internals -> flow_type_rss_offloads = ETH_RSS_PROTO_MASK ;
+
+ memset ( internals -> active_slaves , 0 , sizeof ( internals -> active_slaves ));
+ memset ( internals -> slaves , 0 , sizeof ( internals -> slaves ));
+
+ /* Set mode 4 default configuration */
+ bond_mode_8023ad_setup ( eth_dev , NULL );
+ if ( bond_ethdev_mode_set ( eth_dev , mode )) {
+ RTE_BOND_LOG ( ERR , "Failed to set bonded device %d mode too %d" ,
+ eth_dev -> data -> port_id , mode );
+ goto err ;
+ }
+
+ vlan_filter_bmp_size =
+ rte_bitmap_get_memory_footprint ( ETHER_MAX_VLAN_ID + 1 );
+ internals -> vlan_filter_bmpmem = rte_malloc ( name , vlan_filter_bmp_size ,
+ RTE_CACHE_LINE_SIZE );
+ if ( internals -> vlan_filter_bmpmem == NULL ) {
+ RTE_BOND_LOG ( ERR ,
+ "Failed to allocate vlan bitmap for bonded device %u \n " ,
+ eth_dev -> data -> port_id );
+ goto err ;
+ }
+
+ internals -> vlan_filter_bmp = rte_bitmap_init ( ETHER_MAX_VLAN_ID + 1 ,
+ internals -> vlan_filter_bmpmem , vlan_filter_bmp_size );
+ if ( internals -> vlan_filter_bmp == NULL ) {
+ RTE_BOND_LOG ( ERR ,
+ "Failed to init vlan bitmap for bonded device %u \n " ,
+ eth_dev -> data -> port_id );
+ rte_free ( internals -> vlan_filter_bmpmem );
+ goto err ;
+ }
+
+ return eth_dev -> data -> port_id ;
+
+ err :
+ rte_free ( internals );
+ if ( eth_dev != NULL ) {
+ rte_free ( eth_dev -> data -> mac_addrs );
+ rte_eth_dev_release_port ( eth_dev );
+ }
+ return -1 ;
+ }
+
+ static int
bond_probe ( struct rte_vdev_device * dev )
{
const char * name ; @@ -2248,6 +2375,9 @@ bond_probe(struct rte_vdev_device *dev)
uint8_t bonding_mode , socket_id ;
int arg_count , port_id ;
+ if ( ! dev )
+ return - EINVAL ;
+
name = rte_vdev_device_name ( dev );
RTE_LOG ( INFO , EAL , "Initializing pmd_bond for %s \n " , name );
@@ -2289,8 +2419,10 @@ bond_probe(struct rte_vdev_device *dev)
socket_id = rte_socket_id ();
}
+ dev -> device . numa_node = socket_id ;
+
/* Create link bonding eth device */
- port_id = rte_eth_bond_create ( name , bonding_mode , socket_id );
+ port_id = bond_alloc ( dev , bonding_mode );
if ( port_id < 0 ) {
RTE_LOG ( ERR , EAL , "Failed to create socket %s in mode %u on "
"socket %u. \n " , name , bonding_mode , socket_id ); @@ -2312,8 +2444,9 @@ bond_probe(struct rte_vdev_device *dev)
static int
bond_remove ( struct rte_vdev_device * dev )
{
+ struct rte_eth_dev * eth_dev ;
+ struct bond_dev_private * internals ;
const char * name ;
- int ret ;
if ( ! dev )
return - EINVAL ; @@ -2321,12 +2454,39 @@ bond_remove(struct rte_vdev_device *dev)
name = rte_vdev_device_name ( dev );
RTE_LOG ( INFO , EAL , "Uninitializing pmd_bond for %s \n " , name );
- /* free link bonding eth device */
- ret = rte_eth_bond_free ( name );
- if ( ret < 0 )
- RTE_LOG ( ERR , EAL , "Failed to free %s \n " , name );
+ /* now free all data allocation - for eth_dev structure,
+ * dummy pci driver and internal ( private ) data
+ */
- return ret ;
+ /* find an ethdev entry */
+ eth_dev = rte_eth_dev_allocated ( name );
+ if ( eth_dev == NULL )
+ return - ENODEV ;
+
+ RTE_ASSERT ( eth_dev -> device == & dev -> device );
+
+ internals = eth_dev -> data -> dev_private ;
+ if ( internals -> slave_count != 0 )
+ return - EBUSY ;
+
+ if ( eth_dev -> data -> dev_started == 1 ) {
+ bond_ethdev_stop ( eth_dev );
+ bond_ethdev_close ( eth_dev );
+ }
+
+ eth_dev -> dev_ops = NULL ;
+ eth_dev -> rx_pkt_burst = NULL ;
+ eth_dev -> tx_pkt_burst = NULL ;
+
+ internals = eth_dev -> data -> dev_private ;
+ rte_bitmap_free ( internals -> vlan_filter_bmp );
+ rte_free ( internals -> vlan_filter_bmpmem );
+ rte_free ( eth_dev -> data -> dev_private );
+ rte_free ( eth_dev -> data -> mac_addrs );
+
+ rte_eth_dev_release_port ( eth_dev );
+
+ return 0 ;
}
/* this part will resolve the slave portids after all the other pdev and vdev --
2.1.4
From: Jan Blunck <redacted>
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/bonding/rte_eth_bond_pmd.c | 20 +++-----------------
1 file changed, 3 insertions(+), 17 deletions(-)
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 2b1db0b..2ddcd07 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -36,6 +36,7 @@
#include <rte_mbuf.h>
#include <rte_malloc.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_vdev.h>
#include <rte_tcp.h>
#include <rte_udp.h>
#include <rte_ip.h> @@ -2253,31 +2254,20 @@ bond_alloc(struct rte_vdev_device *dev, uint8_t mode)
* and internal ( private ) data
*/
- if ( name == NULL ) {
- RTE_BOND_LOG ( ERR , "Invalid name specified" );
- goto err ;
- }
-
if ( socket_id >= number_of_sockets ()) {
RTE_BOND_LOG ( ERR ,
"Invalid socket id specified to create bonded device on." );
goto err ;
}
- internals = rte_zmalloc_socket ( name , sizeof ( * internals ), 0 , socket_id );
- if ( internals == NULL ) {
- RTE_BOND_LOG ( ERR , "Unable to malloc internals on socket" );
- goto err ;
- }
-
/* reserve an ethdev entry */
- eth_dev = rte_eth_dev_allocate ( name );
+ eth_dev = rte_eth_vdev_allocate ( dev , sizeof ( * internals ));
if ( eth_dev == NULL ) {
RTE_BOND_LOG ( ERR , "Unable to allocate rte_eth_dev" );
goto err ;
}
- eth_dev -> data -> dev_private = internals ;
+ internals = eth_dev -> data -> dev_private ;
eth_dev -> data -> nb_rx_queues = ( uint16_t ) 1 ;
eth_dev -> data -> nb_tx_queues = ( uint16_t ) 1 ;
@@ -2291,10 +2281,6 @@ bond_alloc(struct rte_vdev_device *dev, uint8_t mode)
eth_dev -> dev_ops = & default_dev_ops ;
eth_dev -> data -> dev_flags = RTE_ETH_DEV_INTR_LSC |
RTE_ETH_DEV_DETACHABLE ;
- eth_dev -> driver = NULL ;
- eth_dev -> data -> kdrv = RTE_KDRV_NONE ;
- eth_dev -> data -> drv_name = pmd_bond_drv . driver . name ;
- eth_dev -> data -> numa_node = socket_id ;
rte_spinlock_init ( & internals -> lock );
--
2.1.4
Signed-off-by: Gaetan Rivet <redacted>
---
drivers/net/kni/rte_eth_kni.c | 39 +++++++++++++++------------------------
1 file changed, 15 insertions(+), 24 deletions(-)
diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c
index e3ce572..8f90034 100644
--- a/drivers/net/kni/rte_eth_kni.c
+++ b/drivers/net/kni/rte_eth_kni.c @@ -36,6 +36,7 @@
#include <unistd.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_vdev.h>
#include <rte_kni.h>
#include <rte_kvargs.h>
#include <rte_malloc.h> @@ -358,32 +359,32 @@ static const struct eth_dev_ops eth_kni_ops = {
static struct rte_vdev_driver eth_kni_drv ;
static struct rte_eth_dev *
- eth_kni_create ( const char * name , struct eth_kni_args * args ,
+ eth_kni_create ( struct rte_vdev_device * vdev ,
+ struct eth_kni_args * args ,
unsigned int numa_node )
{
- struct pmd_internals * internals = NULL ;
+ struct pmd_internals * internals ;
struct rte_eth_dev_data * data ;
struct rte_eth_dev * eth_dev ;
+ const char * name ;
RTE_LOG ( INFO , PMD , "Creating kni ethdev on numa socket %u \n " ,
numa_node );
+ name = rte_vdev_device_name ( vdev );
data = rte_zmalloc_socket ( name , sizeof ( * data ), 0 , numa_node );
if ( data == NULL )
- goto error ;
-
- internals = rte_zmalloc_socket ( name , sizeof ( * internals ), 0 , numa_node );
- if ( internals == NULL )
- goto error ;
+ return NULL ;
/* reserve an ethdev entry */
- eth_dev = rte_eth_dev_allocate ( name );
- if ( eth_dev == NULL )
- goto error ;
+ eth_dev = rte_eth_vdev_allocate ( vdev , sizeof ( * internals ));
+ if ( eth_dev == NULL ) {
+ rte_free ( data );
+ return NULL ;
+ }
- data -> dev_private = internals ;
- data -> port_id = eth_dev -> data -> port_id ;
- memmove ( data -> name , eth_dev -> data -> name , sizeof ( data -> name ));
+ internals = eth_dev -> data -> dev_private ;
+ rte_memcpy ( data , eth_dev -> data , sizeof ( * data ));
data -> nb_rx_queues = 1 ;
data -> nb_tx_queues = 1 ;
data -> dev_link = pmd_link ; @@ -393,22 +394,12 @@ eth_kni_create(const char *name, struct eth_kni_args *args,
eth_dev -> data = data ;
eth_dev -> dev_ops = & eth_kni_ops ;
- eth_dev -> device -> driver = NULL ;
data -> dev_flags = RTE_ETH_DEV_DETACHABLE ;
- data -> kdrv = RTE_KDRV_NONE ;
- data -> drv_name = eth_kni_drv . driver . name ;
- data -> numa_node = numa_node ;
internals -> no_request_thread = args -> no_request_thread ;
return eth_dev ;
-
- error :
- rte_free ( data );
- rte_free ( internals );
-
- return NULL ;
}
static int @@ -462,7 +453,7 @@ eth_kni_probe(struct rte_vdev_device *vdev)
if ( ret < 0 )
return ret ;
- eth_dev = eth_kni_create ( name , & args , rte_socket_id ());
+ eth_dev = eth_kni_create ( vdev , & args , rte_socket_id ());
if ( eth_dev == NULL )
goto kni_uninit ;
--
2.1.4
Signed-off-by: Gaetan Rivet <redacted>
---
drivers/net/pcap/rte_eth_pcap.c | 62 ++++++++++++++++++-----------------------
1 file changed, 27 insertions(+), 35 deletions(-)
diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 05cbd47..defb3b4 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c @@ -40,6 +40,7 @@
#include <rte_cycles.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_vdev.h>
#include <rte_kvargs.h>
#include <rte_malloc.h>
#include <rte_mbuf.h> @@ -790,14 +791,17 @@ open_tx_iface(const char *key, const char *value, void *extra_args)
static struct rte_vdev_driver pmd_pcap_drv ;
static int
- pmd_init_internals ( const char * name , const unsigned int nb_rx_queues ,
+ pmd_init_internals ( struct rte_vdev_device * vdev ,
+ const unsigned int nb_rx_queues ,
const unsigned int nb_tx_queues ,
struct pmd_internals ** internals ,
struct rte_eth_dev ** eth_dev )
{
struct rte_eth_dev_data * data = NULL ;
- unsigned int numa_node = rte_socket_id ();
+ unsigned int numa_node = vdev -> device . numa_node ;
+ const char * name ;
+ name = rte_vdev_device_name ( vdev );
RTE_LOG ( INFO , PMD , "Creating pcap-backed ethdev on numa socket %u \n " ,
numa_node );
@@ -806,17 +810,14 @@ pmd_init_internals(const char *name, const unsigned int nb_rx_queues,
*/
data = rte_zmalloc_socket ( name , sizeof ( * data ), 0 , numa_node );
if ( data == NULL )
- goto error ;
-
- * internals = rte_zmalloc_socket ( name , sizeof ( ** internals ), 0 ,
- numa_node );
- if ( * internals == NULL )
- goto error ;
+ return -1 ;
/* reserve an ethdev entry */
- * eth_dev = rte_eth_dev_allocate ( name );
- if ( * eth_dev == NULL )
- goto error ;
+ * eth_dev = rte_eth_vdev_allocate ( vdev , sizeof ( ** internals ));
+ if ( * eth_dev == NULL ) {
+ rte_free ( data );
+ return -1 ;
+ }
/* now put it all together
* - store queue data in internals , @@ -824,9 +825,8 @@ pmd_init_internals(const char *name, const unsigned int nb_rx_queues,
* - point eth_dev_data to internals
* - and point eth_dev structure to new eth_dev_data structure
*/
- data -> dev_private = * internals ;
- data -> port_id = ( * eth_dev ) -> data -> port_id ;
- snprintf ( data -> name , sizeof ( data -> name ), "%s" , ( * eth_dev ) -> data -> name );
+ * internals = ( * eth_dev ) -> data -> dev_private ;
+ rte_memcpy ( data , ( * eth_dev ) -> data , sizeof ( * data ));
data -> nb_rx_queues = ( uint16_t ) nb_rx_queues ;
data -> nb_tx_queues = ( uint16_t ) nb_tx_queues ;
data -> dev_link = pmd_link ; @@ -838,26 +838,17 @@ pmd_init_internals(const char *name, const unsigned int nb_rx_queues,
*/
( * eth_dev ) -> data = data ;
( * eth_dev ) -> dev_ops = & ops ;
- ( * eth_dev ) -> driver = NULL ;
data -> dev_flags = RTE_ETH_DEV_DETACHABLE ;
- data -> kdrv = RTE_KDRV_NONE ;
- data -> drv_name = pmd_pcap_drv . driver . name ;
- data -> numa_node = numa_node ;
return 0 ;
-
- error :
- rte_free ( data );
- rte_free ( * internals );
-
- return -1 ;
}
static int
- eth_from_pcaps_common ( const char * name , struct pmd_devargs * rx_queues ,
- const unsigned int nb_rx_queues , struct pmd_devargs * tx_queues ,
- const unsigned int nb_tx_queues , struct rte_kvargs * kvlist ,
- struct pmd_internals ** internals , struct rte_eth_dev ** eth_dev )
+ eth_from_pcaps_common ( struct rte_vdev_device * vdev ,
+ struct pmd_devargs * rx_queues , const unsigned int nb_rx_queues ,
+ struct pmd_devargs * tx_queues , const unsigned int nb_tx_queues ,
+ struct rte_kvargs * kvlist , struct pmd_internals ** internals ,
+ struct rte_eth_dev ** eth_dev )
{
struct rte_kvargs_pair * pair = NULL ;
unsigned int k_idx ; @@ -869,7 +860,7 @@ eth_from_pcaps_common(const char *name, struct pmd_devargs *rx_queues,
if ( tx_queues == NULL && nb_tx_queues > 0 )
return -1 ;
- if ( pmd_init_internals ( name , nb_rx_queues , nb_tx_queues , internals ,
+ if ( pmd_init_internals ( vdev , nb_rx_queues , nb_tx_queues , internals ,
eth_dev ) < 0 )
return -1 ;
@@ -907,16 +898,17 @@ eth_from_pcaps_common(const char *name, struct pmd_devargs *rx_queues,
}
static int
- eth_from_pcaps ( const char * name , struct pmd_devargs * rx_queues ,
- const unsigned int nb_rx_queues , struct pmd_devargs * tx_queues ,
- const unsigned int nb_tx_queues , struct rte_kvargs * kvlist ,
- int single_iface , unsigned int using_dumpers )
+ eth_from_pcaps ( struct rte_vdev_device * vdev ,
+ struct pmd_devargs * rx_queues , const unsigned int nb_rx_queues ,
+ struct pmd_devargs * tx_queues , const unsigned int nb_tx_queues ,
+ struct rte_kvargs * kvlist , int single_iface ,
+ unsigned int using_dumpers )
{
struct pmd_internals * internals = NULL ;
struct rte_eth_dev * eth_dev = NULL ;
int ret ;
- ret = eth_from_pcaps_common ( name , rx_queues , nb_rx_queues ,
+ ret = eth_from_pcaps_common ( vdev , rx_queues , nb_rx_queues ,
tx_queues , nb_tx_queues , kvlist , & internals , & eth_dev );
if ( ret < 0 ) @@ -1027,7 +1019,7 @@ pmd_pcap_probe(struct rte_vdev_device *dev)
goto free_kvlist ;
create_eth :
- ret = eth_from_pcaps ( name , & pcaps , pcaps . num_of_queue , & dumpers ,
+ ret = eth_from_pcaps ( dev , & pcaps , pcaps . num_of_queue , & dumpers ,
dumpers . num_of_queue , kvlist , single_iface , is_tx_pcap );
free_kvlist : --
2.1.4
From: Jan Blunck <redacted>
This adds the following helper intended to be used by rte_pci_driver
implementations working with ethdev:
- rte_eth_dev_pci_allocate
- rte_eth_dev_pci_release
- rte_eth_dev_pci_generic_probe
- rte_eth_dev_pci_generic_remove
Signed-off-by: Jan Blunck <redacted>
---
lib/librte_ether/Makefile | 1 +
lib/librte_ether/rte_ethdev_pci.h | 151 ++++++++++++++++++++++++++++++++++++++
2 files changed, 152 insertions(+)
create mode 100644 lib/librte_ether/rte_ethdev_pci.h
diff --git a/lib/librte_ether/Makefile b/lib/librte_ether/Makefile
index d0017b8..93fdde1 100644
--- a/lib/librte_ether/Makefile
+++ b/lib/librte_ether/Makefile @@ -50,6 +50,7 @@ SRCS-y += rte_flow.c
# Export include files
#
SYMLINK-y-include += rte_ethdev.h
+ SYMLINK-y-include += rte_ethdev_pci.h
SYMLINK-y-include += rte_ethdev_vdev.h
SYMLINK-y-include += rte_eth_ctrl.h
SYMLINK-y-include += rte_dev_info.h diff --git a/lib/librte_ether/rte_ethdev_pci.h b/lib/librte_ether/rte_ethdev_pci.h
new file mode 100644
index 0000000..4b728db
--- /dev/null
+++ b/lib/librte_ether/rte_ethdev_pci.h @@ -0,0 +1,151 @@
+ /*-
+ * BSD LICENSE
+ *
+ * Copyright ( c ) 2017 Brocade Communications Systems , Inc .
+ * Author : Jan Blunck < jblunck @ infradead . org >
+ *
+ * Redistribution and use in source and binary forms , with or without
+ * modification , are permitted provided that the following conditions
+ * are met :
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice , this list of conditions and the following disclaimer .
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice , this list of conditions and the following disclaimer in
+ * the documentation and / or other materials provided with the
+ * distribution .
+ * * Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission .
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT
+ * LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL ,
+ * SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT
+ * LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE ,
+ * DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT
+ * ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
+ */
+
+ #ifndef _RTE_ETHDEV_PCI_H_
+ #define _RTE_ETHDEV_PCI_H_
+
+ #include <rte_malloc.h>
+ #include <rte_pci.h>
+ #include <rte_ethdev.h>
+
+ /**
+ * @ internal
+ * Allocates a new ethdev slot for an ethernet device and returns the pointer
+ * to that slot for the driver to use .
+ *
+ * @ param dev
+ * Pointer to the PCI device
+ *
+ * @ param private_data_size
+ * Size of private data structure
+ *
+ * @ return
+ * A pointer to a rte_eth_dev or NULL if allocation failed .
+ */
+ static inline struct rte_eth_dev *
+ rte_eth_dev_pci_allocate ( struct rte_pci_device * dev , size_t private_data_size )
+ {
+ struct rte_eth_dev * eth_dev ;
+ const char * name ;
+
+ if ( ! dev )
+ return NULL ;
+
+ name = dev -> device . name ;
+
+ if ( rte_eal_process_type () == RTE_PROC_PRIMARY ) {
+ eth_dev = rte_eth_dev_allocate ( name );
+ if ( ! eth_dev )
+ return NULL ;
+
+ if ( private_data_size ) {
+ eth_dev -> data -> dev_private = rte_zmalloc_socket ( name ,
+ private_data_size , RTE_CACHE_LINE_SIZE ,
+ dev -> device . numa_node );
+ if ( ! eth_dev -> data -> dev_private ) {
+ rte_eth_dev_release_port ( eth_dev );
+ return NULL ;
+ }
+ }
+ } else {
+ eth_dev = rte_eth_dev_attach_secondary ( name );
+ if ( ! eth_dev )
+ return NULL ;
+ }
+
+ eth_dev -> device = & dev -> device ;
+ eth_dev -> driver = NULL ;
+ eth_dev -> intr_handle = & dev -> intr_handle ;
+ rte_eth_copy_pci_info ( eth_dev , dev );
+ return eth_dev ;
+ }
+
+ static inline void
+ rte_eth_dev_pci_release ( struct rte_eth_dev * eth_dev )
+ {
+ /* 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 -> data -> dev_private = NULL ;
+
+ eth_dev -> device = NULL ;
+ eth_dev -> driver = NULL ;
+ eth_dev -> intr_handle = NULL ;
+ }
+
+ typedef int ( * eth_dev_pci_callback_t )( struct rte_eth_dev * eth_dev );
+
+ static inline int
+ rte_eth_dev_pci_generic_probe ( struct rte_pci_device * pci_dev ,
+ size_t private_data_size , eth_dev_pci_callback_t dev_init )
+ {
+ struct rte_eth_dev * eth_dev ;
+ int ret ;
+
+ eth_dev = rte_eth_dev_pci_allocate ( pci_dev , private_data_size );
+ if ( ! eth_dev )
+ return - ENOMEM ;
+
+ RTE_FUNC_PTR_OR_ERR_RET ( * dev_init , - EINVAL );
+ ret = dev_init ( eth_dev );
+ if ( ret )
+ rte_eth_dev_pci_release ( eth_dev );
+
+ return ret ;
+ }
+
+ static inline int
+ rte_eth_dev_pci_generic_remove ( struct rte_pci_device * pci_dev ,
+ eth_dev_pci_callback_t dev_uninit )
+ {
+ struct rte_eth_dev * eth_dev ;
+ int ret ;
+
+ eth_dev = rte_eth_dev_allocated ( pci_dev -> device . name );
+ if ( ! eth_dev )
+ return - ENODEV ;
+
+ if ( dev_uninit ) {
+ ret = dev_uninit ( eth_dev );
+ if ( ret )
+ return ret ;
+ }
+
+ rte_eth_dev_pci_release ( eth_dev );
+ return 0 ;
+ }
+
+ #endif /* _RTE_ETHDEV_PCI_H_ */ --
2.1.4
From: Jan Blunck <redacted>
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/virtio/virtio_ethdev.c | 34 +++++++++++++++++++++-------------
1 file changed, 21 insertions(+), 13 deletions(-)
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 78cb3e8..f0a0219 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c @@ -38,6 +38,7 @@
#include <unistd.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_memcpy.h>
#include <rte_string_fns.h>
#include <rte_memzone.h> @@ -1612,19 +1613,26 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
return 0 ;
}
- static struct eth_driver rte_virtio_pmd = {
- . pci_drv = {
- . driver = {
- . name = "net_virtio" ,
- },
- . id_table = pci_id_virtio_map ,
- . drv_flags = 0 ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
+ static int eth_virtio_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev , sizeof ( struct virtio_hw ),
+ eth_virtio_dev_init );
+ }
+
+ static int eth_virtio_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , eth_virtio_dev_uninit );
+ }
+
+ static struct rte_pci_driver rte_virtio_pmd = {
+ . driver = {
+ . name = "net_virtio" ,
},
- . eth_dev_init = eth_virtio_dev_init ,
- . eth_dev_uninit = eth_virtio_dev_uninit ,
- . dev_private_size = sizeof ( struct virtio_hw ),
+ . id_table = pci_id_virtio_map ,
+ . drv_flags = 0 ,
+ . probe = eth_virtio_pci_probe ,
+ . remove = eth_virtio_pci_remove ,
};
RTE_INIT ( rte_virtio_pmd_init ); @@ -1636,7 +1644,7 @@ rte_virtio_pmd_init(void)
return ;
}
- rte_eal_pci_register ( & rte_virtio_pmd . pci_drv );
+ rte_eal_pci_register ( & rte_virtio_pmd );
}
/* --
2.1.4
From: Jan Blunck <redacted>
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/bnx2x/bnx2x_ethdev.c | 64 +++++++++++++++++++++++++++-------------
drivers/net/bnx2x/bnx2x_rxtx.c | 2 +-
2 files changed, 45 insertions(+), 21 deletions(-)
diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index 0e8b4d9..314e5ea 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c @@ -12,6 +12,7 @@
#include "bnx2x_rxtx.h"
#include <rte_dev.h>
+ #include <rte_ethdev_pci.h>
/*
* The set of PCI devices this driver supports @@ -627,34 +628,57 @@ eth_bnx2xvf_dev_init(struct rte_eth_dev *eth_dev)
return bnx2x_common_dev_init ( eth_dev , 1 );
}
- static struct eth_driver rte_bnx2x_pmd = {
- . pci_drv = {
- . id_table = pci_id_bnx2x_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_bnx2x_dev_init ,
- . dev_private_size = sizeof ( struct bnx2x_softc ),
+ static struct rte_pci_driver rte_bnx2x_pmd ;
+ static struct rte_pci_driver rte_bnx2xvf_pmd ;
+
+ static int eth_bnx2x_pci_probe ( struct rte_pci_driver * pci_drv ,
+ struct rte_pci_device * pci_dev )
+ {
+ struct rte_eth_dev * eth_dev ;
+ int ret ;
+
+ eth_dev = rte_eth_dev_pci_allocate ( pci_dev , sizeof ( struct bnx2x_softc ));
+ if ( ! eth_dev )
+ return - ENOMEM ;
+
+ if ( pci_drv == & rte_bnx2x_pmd )
+ ret = eth_bnx2x_dev_init ( eth_dev );
+ else if ( pci_drv == & rte_bnx2xvf_pmd )
+ ret = eth_bnx2xvf_dev_init ( eth_dev );
+ else
+ ret = - EINVAL ;
+
+ if ( ret )
+ rte_eth_dev_pci_release ( eth_dev );
+
+ return ret ;
+ }
+
+ static int eth_bnx2x_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , NULL );
+ }
+
+ static struct rte_pci_driver rte_bnx2x_pmd = {
+ . id_table = pci_id_bnx2x_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
+ . probe = eth_bnx2x_pci_probe ,
+ . remove = eth_bnx2x_pci_remove ,
};
/*
* virtual function driver struct
*/
- static struct eth_driver rte_bnx2xvf_pmd = {
- . pci_drv = {
- . id_table = pci_id_bnx2xvf_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_bnx2xvf_dev_init ,
- . dev_private_size = sizeof ( struct bnx2x_softc ),
+ static struct rte_pci_driver rte_bnx2xvf_pmd = {
+ . id_table = pci_id_bnx2xvf_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING ,
+ . probe = eth_bnx2x_pci_probe ,
+ . remove = eth_bnx2x_pci_remove ,
};
- RTE_PMD_REGISTER_PCI ( net_bnx2x , rte_bnx2x_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_bnx2x , rte_bnx2x_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_bnx2x , pci_id_bnx2x_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_bnx2x , "* igb_uio | uio_pci_generic | vfio" );
- RTE_PMD_REGISTER_PCI ( net_bnx2xvf , rte_bnx2xvf_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_bnx2xvf , rte_bnx2xvf_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_bnx2xvf , pci_id_bnx2xvf_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_bnx2xvf , "* igb_uio | vfio" ); diff --git a/drivers/net/bnx2x/bnx2x_rxtx.c b/drivers/net/bnx2x/bnx2x_rxtx.c
index adf0309..5dd4aee 100644
--- a/drivers/net/bnx2x/bnx2x_rxtx.c
+++ b/drivers/net/bnx2x/bnx2x_rxtx.c @@ -19,7 +19,7 @@ ring_dma_zone_reserve(struct rte_eth_dev *dev, const char *ring_name,
const struct rte_memzone * mz ;
snprintf ( z_name , sizeof ( z_name ), "%s_%s_%d_%d" ,
- dev -> driver -> pci_drv . driver . name , ring_name ,
+ dev -> device -> driver -> name , ring_name ,
dev -> data -> port_id , queue_id );
mz = rte_memzone_lookup ( z_name ); --
2.1.4
From: Jan Blunck <redacted>
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/bnxt/bnxt_ethdev.c | 36 +++++++++++++++++++++++-------------
1 file changed, 23 insertions(+), 13 deletions(-)
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 6167443..5dc3ff0 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -36,6 +36,7 @@
#include <rte_dev.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_malloc.h>
#include <rte_cycles.h>
@@ -1075,6 +1076,8 @@ static int bnxt_init_board(struct rte_eth_dev *eth_dev)
return rc ;
}
+ static int bnxt_dev_uninit ( struct rte_eth_dev * eth_dev );
+
static int
bnxt_dev_init ( struct rte_eth_dev * eth_dev )
{ @@ -1167,7 +1170,7 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
return 0 ;
error_free :
- eth_dev -> driver -> eth_dev_uninit ( eth_dev );
+ bnxt_dev_uninit ( eth_dev );
error :
return rc ;
} @@ -1196,19 +1199,26 @@ bnxt_dev_uninit(struct rte_eth_dev *eth_dev) {
return rc ;
}
- static struct eth_driver bnxt_rte_pmd = {
- . pci_drv = {
- . id_table = bnxt_pci_id_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING |
- RTE_PCI_DRV_INTR_LSC ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove
- },
- . eth_dev_init = bnxt_dev_init ,
- . eth_dev_uninit = bnxt_dev_uninit ,
- . dev_private_size = sizeof ( struct bnxt ),
+ static int bnxt_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev , sizeof ( struct bnxt ),
+ bnxt_dev_init );
+ }
+
+ static int bnxt_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , bnxt_dev_uninit );
+ }
+
+ static struct rte_pci_driver bnxt_rte_pmd = {
+ . id_table = bnxt_pci_id_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING |
+ RTE_PCI_DRV_INTR_LSC ,
+ . probe = bnxt_pci_probe ,
+ . remove = bnxt_pci_remove ,
};
- RTE_PMD_REGISTER_PCI ( net_bnxt , bnxt_rte_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_bnxt , bnxt_rte_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_bnxt , bnxt_pci_id_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_bnxt , "* igb_uio | uio_pci_generic | vfio" ); --
2.1.4
From: Jan Blunck <redacted>
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/cxgbe/cxgbe_ethdev.c | 29 +++++++++++++++++++----------
drivers/net/cxgbe/sge.c | 6 +++---
2 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 4d543a7..34fed84 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c @@ -57,6 +57,7 @@
#include <rte_alarm.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_atomic.h>
#include <rte_malloc.h>
#include <rte_random.h> @@ -1039,17 +1040,25 @@ static int eth_cxgbe_dev_init(struct rte_eth_dev *eth_dev)
return err ;
}
- static struct eth_driver rte_cxgbe_pmd = {
- . pci_drv = {
- . id_table = cxgb4_pci_tbl ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_cxgbe_dev_init ,
- . dev_private_size = sizeof ( struct port_info ),
+ static int eth_cxgbe_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct port_info ), eth_cxgbe_dev_init );
+ }
+
+ static int eth_cxgbe_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , NULL );
+ }
+
+ static struct rte_pci_driver rte_cxgbe_pmd = {
+ . id_table = cxgb4_pci_tbl ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
+ . probe = eth_cxgbe_pci_probe ,
+ . remove = eth_cxgbe_pci_remove ,
};
- RTE_PMD_REGISTER_PCI ( net_cxgbe , rte_cxgbe_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_cxgbe , rte_cxgbe_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_cxgbe , cxgb4_pci_tbl );
RTE_PMD_REGISTER_KMOD_DEP ( net_cxgbe , "* igb_uio | uio_pci_generic | vfio" ); diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
index 37b6090..2f9e12c 100644
--- a/drivers/net/cxgbe/sge.c
+++ b/drivers/net/cxgbe/sge.c @@ -1641,7 +1641,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
iq -> size = cxgbe_roundup ( iq -> size , 16 );
snprintf ( z_name , sizeof ( z_name ), "%s_%s_%d_%d" ,
- eth_dev -> driver -> pci_drv . driver . name ,
+ eth_dev -> data -> drv_name ,
fwevtq ? "fwq_ring" : "rx_ring" ,
eth_dev -> data -> port_id , queue_id );
snprintf ( z_name_sw , sizeof ( z_name_sw ), "%s_sw_ring" , z_name ); @@ -1694,7 +1694,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
fl -> size = cxgbe_roundup ( fl -> size , 8 );
snprintf ( z_name , sizeof ( z_name ), "%s_%s_%d_%d" ,
- eth_dev -> driver -> pci_drv . driver . name ,
+ eth_dev -> data -> drv_name ,
fwevtq ? "fwq_ring" : "fl_ring" ,
eth_dev -> data -> port_id , queue_id );
snprintf ( z_name_sw , sizeof ( z_name_sw ), "%s_sw_ring" , z_name ); @@ -1890,7 +1890,7 @@ int t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq,
nentries = txq -> q . size + s -> stat_len / sizeof ( struct tx_desc );
snprintf ( z_name , sizeof ( z_name ), "%s_%s_%d_%d" ,
- eth_dev -> driver -> pci_drv . driver . name , "tx_ring" ,
+ eth_dev -> data -> drv_name , "tx_ring" ,
eth_dev -> data -> port_id , queue_id );
snprintf ( z_name_sw , sizeof ( z_name_sw ), "%s_sw_ring" , z_name );
--
2.1.4
From: Jan Blunck <redacted>
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/e1000/em_ethdev.c | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index ecefa56..599b9e0 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c @@ -45,6 +45,7 @@
#include <rte_pci.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_memory.h>
#include <rte_memzone.h>
#include <rte_eal.h> @@ -417,16 +418,23 @@ eth_em_dev_uninit(struct rte_eth_dev *eth_dev)
return 0 ;
}
- static struct eth_driver rte_em_pmd = {
- . pci_drv = {
- . id_table = pci_id_em_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_em_dev_init ,
- . eth_dev_uninit = eth_em_dev_uninit ,
- . dev_private_size = sizeof ( struct e1000_adapter ),
+ static int eth_em_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct e1000_adapter ), eth_em_dev_init );
+ }
+
+ static int eth_em_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , eth_em_dev_uninit );
+ }
+
+ static struct rte_pci_driver rte_em_pmd = {
+ . id_table = pci_id_em_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
+ . probe = eth_em_pci_probe ,
+ . remove = eth_em_pci_remove ,
};
static int @@ -1857,6 +1865,6 @@ eth_em_set_mc_addr_list(struct rte_eth_dev *dev,
return 0 ;
}
- RTE_PMD_REGISTER_PCI ( net_e1000_em , rte_em_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_e1000_em , rte_em_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_e1000_em , pci_id_em_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_e1000_em , "* igb_uio | uio_pci_generic | vfio" ); --
2.1.4
From: Jan Blunck <redacted>
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/e1000/igb_ethdev.c | 60 ++++++++++++++++++++++++++----------------
1 file changed, 38 insertions(+), 22 deletions(-)
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index cc2c244..2bda4b3 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c @@ -45,6 +45,7 @@
#include <rte_pci.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_memory.h>
#include <rte_memzone.h>
#include <rte_eal.h> @@ -1088,31 +1089,46 @@ eth_igbvf_dev_uninit(struct rte_eth_dev *eth_dev)
return 0 ;
}
- static struct eth_driver rte_igb_pmd = {
- . pci_drv = {
- . id_table = pci_id_igb_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_igb_dev_init ,
- . eth_dev_uninit = eth_igb_dev_uninit ,
- . dev_private_size = sizeof ( struct e1000_adapter ),
+ static int eth_igb_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct e1000_adapter ), eth_igb_dev_init );
+ }
+
+ static int eth_igb_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , eth_igb_dev_uninit );
+ }
+
+ static struct rte_pci_driver rte_igb_pmd = {
+ . id_table = pci_id_igb_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
+ . probe = eth_igb_pci_probe ,
+ . remove = eth_igb_pci_remove ,
};
+
+ static int eth_igbvf_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct e1000_adapter ), eth_igbvf_dev_init );
+ }
+
+ static int eth_igbvf_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , eth_igbvf_dev_uninit );
+ }
+
/*
* virtual function driver struct
*/
- static struct eth_driver rte_igbvf_pmd = {
- . pci_drv = {
- . id_table = pci_id_igbvf_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_igbvf_dev_init ,
- . eth_dev_uninit = eth_igbvf_dev_uninit ,
- . dev_private_size = sizeof ( struct e1000_adapter ),
+ static struct rte_pci_driver rte_igbvf_pmd = {
+ . id_table = pci_id_igbvf_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING ,
+ . probe = eth_igbvf_pci_probe ,
+ . remove = eth_igbvf_pci_remove ,
};
static void @@ -5309,9 +5325,9 @@ eth_igb_configure_msix_intr(struct rte_eth_dev *dev)
E1000_WRITE_FLUSH ( hw );
}
- RTE_PMD_REGISTER_PCI ( net_e1000_igb , rte_igb_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_e1000_igb , rte_igb_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_e1000_igb , pci_id_igb_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_e1000_igb , "* igb_uio | uio_pci_generic | vfio" );
- RTE_PMD_REGISTER_PCI ( net_e1000_igb_vf , rte_igbvf_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_e1000_igb_vf , rte_igbvf_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_e1000_igb_vf , pci_id_igbvf_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_e1000_igb_vf , "* igb_uio | vfio" ); --
2.1.4
From: Jan Blunck <redacted>
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/ena/ena_ethdev.c | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index 5dd44d7..f5f748f 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c @@ -33,6 +33,7 @@
#include <rte_ether.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_tcp.h>
#include <rte_atomic.h>
#include <rte_dev.h> @@ -1776,17 +1777,25 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
return sent_idx ;
}
- static struct eth_driver rte_ena_pmd = {
- . pci_drv = {
- . id_table = pci_id_ena_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_ena_dev_init ,
- . dev_private_size = sizeof ( struct ena_adapter ),
+ static int eth_ena_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct ena_adapter ), eth_ena_dev_init );
+ }
+
+ static int eth_ena_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , NULL );
+ }
+
+ static struct rte_pci_driver rte_ena_pmd = {
+ . id_table = pci_id_ena_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING ,
+ . probe = eth_ena_pci_probe ,
+ . remove = eth_ena_pci_remove ,
};
- RTE_PMD_REGISTER_PCI ( net_ena , rte_ena_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_ena , rte_ena_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_ena , pci_id_ena_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_ena , "* igb_uio | uio_pci_generic | vfio" ); --
2.1.4
From: Jan Blunck <redacted>
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/enic/enic_ethdev.c | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c
index 2c2e29e..7579696 100644
--- a/drivers/net/enic/enic_ethdev.c
+++ b/drivers/net/enic/enic_ethdev.c @@ -38,6 +38,7 @@
#include <rte_dev.h>
#include <rte_pci.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_string_fns.h>
#include "vnic_intr.h" @@ -629,17 +630,25 @@ static int eth_enicpmd_dev_init(struct rte_eth_dev *eth_dev)
return enic_probe ( enic );
}
- static struct eth_driver rte_enic_pmd = {
- . pci_drv = {
- . id_table = pci_id_enic_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_enicpmd_dev_init ,
- . dev_private_size = sizeof ( struct enic ),
+ static int eth_enic_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev , sizeof ( struct enic ),
+ eth_enicpmd_dev_init );
+ }
+
+ static int eth_enic_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , NULL );
+ }
+
+ static struct rte_pci_driver rte_enic_pmd = {
+ . id_table = pci_id_enic_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
+ . probe = eth_enic_pci_probe ,
+ . remove = eth_enic_pci_remove ,
};
- RTE_PMD_REGISTER_PCI ( net_enic , rte_enic_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_enic , rte_enic_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_enic , pci_id_enic_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_enic , "* igb_uio | uio_pci_generic | vfio" ); --
2.1.4
From: Jan Blunck <redacted>
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/fm10k/fm10k_ethdev.c | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index de0352e..94b4d40 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -32,6 +32,7 @@
*/
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_malloc.h>
#include <rte_memzone.h>
#include <rte_string_fns.h> @@ -3112,6 +3113,18 @@ eth_fm10k_dev_uninit(struct rte_eth_dev *dev)
return 0 ;
}
+ static int eth_fm10k_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct fm10k_adapter ), eth_fm10k_dev_init );
+ }
+
+ static int eth_fm10k_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , eth_fm10k_dev_uninit );
+ }
+
/*
* The set of PCI devices this driver supports . This driver will enable both PF
* and SRIOV - VF devices . @@ -3123,18 +3136,13 @@ static const struct rte_pci_id pci_id_fm10k_map[] = {
{ . vendor_id = 0 , /* sentinel */ },
};
- static struct eth_driver rte_pmd_fm10k = {
- . pci_drv = {
- . id_table = pci_id_fm10k_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_fm10k_dev_init ,
- . eth_dev_uninit = eth_fm10k_dev_uninit ,
- . dev_private_size = sizeof ( struct fm10k_adapter ),
+ static struct rte_pci_driver rte_pmd_fm10k = {
+ . id_table = pci_id_fm10k_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
+ . probe = eth_fm10k_pci_probe ,
+ . remove = eth_fm10k_pci_remove ,
};
- RTE_PMD_REGISTER_PCI ( net_fm10k , rte_pmd_fm10k . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_fm10k , rte_pmd_fm10k );
RTE_PMD_REGISTER_PCI_TABLE ( net_fm10k , pci_id_fm10k_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_fm10k , "* igb_uio | uio_pci_generic | vfio" ); --
2.1.4
From: Jan Blunck <redacted>
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/i40e/i40e_ethdev.c | 36 ++++++++++++++++++++++--------------
drivers/net/i40e/i40e_fdir.c | 2 +-
2 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 6927fde..ac5e181 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c @@ -45,6 +45,7 @@
#include <rte_pci.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_memzone.h>
#include <rte_malloc.h>
#include <rte_memcpy.h> @@ -642,16 +643,23 @@ static const struct rte_i40e_xstats_name_off rte_i40e_txq_prio_strings[] = {
#define I40E_NB_TXQ_PRIO_XSTATS (sizeof(rte_i40e_txq_prio_strings) / \
sizeof ( rte_i40e_txq_prio_strings [ 0 ]))
- static struct eth_driver rte_i40e_pmd = {
- . pci_drv = {
- . id_table = pci_id_i40e_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_i40e_dev_init ,
- . eth_dev_uninit = eth_i40e_dev_uninit ,
- . dev_private_size = sizeof ( struct i40e_adapter ),
+ static int eth_i40e_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct i40e_adapter ), eth_i40e_dev_init );
+ }
+
+ static int eth_i40e_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , eth_i40e_dev_uninit );
+ }
+
+ static struct rte_pci_driver rte_i40e_pmd = {
+ . id_table = pci_id_i40e_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
+ . probe = eth_i40e_pci_probe ,
+ . remove = eth_i40e_pci_remove ,
};
static inline int @@ -682,7 +690,7 @@ rte_i40e_dev_atomic_write_link_status(struct rte_eth_dev *dev,
return 0 ;
}
- RTE_PMD_REGISTER_PCI ( net_i40e , rte_i40e_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_i40e , rte_i40e_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_i40e , pci_id_i40e_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_i40e , "* igb_uio | uio_pci_generic | vfio" );
@@ -10689,10 +10697,10 @@ i40e_filter_restore(struct i40e_pf *pf)
}
static bool
- is_device_supported ( struct rte_eth_dev * dev , struct eth_driver * drv )
+ is_device_supported ( struct rte_eth_dev * dev , struct rte_pci_driver * drv )
{
- if ( strcmp ( dev -> driver -> pci_drv . driver . name ,
- drv -> pci_drv . driver . name ))
+ if ( strcmp ( dev -> data -> drv_name ,
+ drv -> driver . name ))
return false ;
return true ; diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index 32d3b19..28cc554 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c @@ -257,7 +257,7 @@ i40e_fdir_setup(struct i40e_pf *pf)
/* reserve memory for the fdir programming packet */
snprintf ( z_name , sizeof ( z_name ), "%s_%s_%d" ,
- eth_dev -> driver -> pci_drv . driver . name ,
+ eth_dev -> data -> drv_name ,
I40E_FDIR_MZ_NAME ,
eth_dev -> data -> port_id );
mz = i40e_memzone_reserve ( z_name , I40E_FDIR_PKT_LEN , SOCKET_ID_ANY ); --
2.1.4
From: Jan Blunck <redacted>
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/i40e/i40e_ethdev_vf.c | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 7e48fea..cd9e51f 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -55,6 +55,7 @@
#include <rte_alarm.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_atomic.h>
#include <rte_malloc.h>
#include <rte_dev.h> @@ -1543,22 +1544,30 @@ i40evf_dev_uninit(struct rte_eth_dev *eth_dev)
return 0 ;
}
+
+ static int eth_i40evf_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct i40e_adapter ), i40evf_dev_init );
+ }
+
+ static int eth_i40evf_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , i40evf_dev_uninit );
+ }
+
/*
* virtual function driver struct
*/
- static struct eth_driver rte_i40evf_pmd = {
- . pci_drv = {
- . id_table = pci_id_i40evf_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = i40evf_dev_init ,
- . eth_dev_uninit = i40evf_dev_uninit ,
- . dev_private_size = sizeof ( struct i40e_adapter ),
+ static struct rte_pci_driver rte_i40evf_pmd = {
+ . id_table = pci_id_i40evf_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING ,
+ . probe = eth_i40evf_pci_probe ,
+ . remove = eth_i40evf_pci_remove ,
};
- RTE_PMD_REGISTER_PCI ( net_i40e_vf , rte_i40evf_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_i40e_vf , rte_i40evf_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_i40e_vf , pci_id_i40evf_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_i40e_vf , "* igb_uio | vfio" );
--
2.1.4
From: Jan Blunck <redacted>
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/ixgbe/ixgbe_ethdev.c | 66 ++++++++++++++++++++++++----------------
1 file changed, 40 insertions(+), 26 deletions(-)
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 1462324..ef781ca 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -56,6 +56,7 @@
#include <rte_alarm.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_atomic.h>
#include <rte_malloc.h>
#include <rte_random.h> @@ -247,7 +248,7 @@ static void ixgbe_set_default_mac_addr(struct rte_eth_dev *dev,
struct ether_addr * mac_addr );
static void ixgbe_dcb_init ( struct ixgbe_hw * hw , struct ixgbe_dcb_config * dcb_config );
static bool is_device_supported ( struct rte_eth_dev * dev ,
- struct eth_driver * drv );
+ struct rte_pci_driver * drv );
/* For Virtual Function support */
static int eth_ixgbevf_dev_init ( struct rte_eth_dev * eth_dev ); @@ -1768,31 +1769,45 @@ eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev)
return 0 ;
}
- static struct eth_driver rte_ixgbe_pmd = {
- . pci_drv = {
- . id_table = pci_id_ixgbe_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_ixgbe_dev_init ,
- . eth_dev_uninit = eth_ixgbe_dev_uninit ,
- . dev_private_size = sizeof ( struct ixgbe_adapter ),
+ static int eth_ixgbe_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct ixgbe_adapter ), eth_ixgbe_dev_init );
+ }
+
+ static int eth_ixgbe_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , eth_ixgbe_dev_uninit );
+ }
+
+ static struct rte_pci_driver rte_ixgbe_pmd = {
+ . id_table = pci_id_ixgbe_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC ,
+ . probe = eth_ixgbe_pci_probe ,
+ . remove = eth_ixgbe_pci_remove ,
};
+ static int eth_ixgbevf_pci_probe ( struct rte_pci_driver * pci_drv __rte_unused ,
+ struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_probe ( pci_dev ,
+ sizeof ( struct ixgbe_adapter ), eth_ixgbevf_dev_init );
+ }
+
+ static int eth_ixgbevf_pci_remove ( struct rte_pci_device * pci_dev )
+ {
+ return rte_eth_dev_pci_generic_remove ( pci_dev , eth_ixgbevf_dev_uninit );
+ }
+
/*
* virtual function driver struct
*/
- static struct eth_driver rte_ixgbevf_pmd = {
- . pci_drv = {
- . id_table = pci_id_ixgbevf_map ,
- . drv_flags = RTE_PCI_DRV_NEED_MAPPING ,
- . probe = rte_eth_dev_pci_probe ,
- . remove = rte_eth_dev_pci_remove ,
- },
- . eth_dev_init = eth_ixgbevf_dev_init ,
- . eth_dev_uninit = eth_ixgbevf_dev_uninit ,
- . dev_private_size = sizeof ( struct ixgbe_adapter ),
+ static struct rte_pci_driver rte_ixgbevf_pmd = {
+ . id_table = pci_id_ixgbevf_map ,
+ . drv_flags = RTE_PCI_DRV_NEED_MAPPING ,
+ . probe = eth_ixgbevf_pci_probe ,
+ . remove = eth_ixgbevf_pci_remove ,
};
static int @@ -4383,10 +4398,9 @@ ixgbe_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
}
static bool
- is_device_supported ( struct rte_eth_dev * dev , struct eth_driver * drv )
+ is_device_supported ( struct rte_eth_dev * dev , struct rte_pci_driver * drv )
{
- if ( strcmp ( dev -> driver -> pci_drv . driver . name ,
- drv -> pci_drv . driver . name ))
+ if ( strcmp ( dev -> data -> drv_name , drv -> driver . name ))
return false ;
return true ; @@ -8774,9 +8788,9 @@ rte_pmd_ixgbe_set_tc_bw_alloc(uint8_t port,
return 0 ;
}
- RTE_PMD_REGISTER_PCI ( net_ixgbe , rte_ixgbe_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_ixgbe , rte_ixgbe_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_ixgbe , pci_id_ixgbe_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_ixgbe , "* igb_uio | uio_pci_generic | vfio" );
- RTE_PMD_REGISTER_PCI ( net_ixgbe_vf , rte_ixgbevf_pmd . pci_drv );
+ RTE_PMD_REGISTER_PCI ( net_ixgbe_vf , rte_ixgbevf_pmd );
RTE_PMD_REGISTER_PCI_TABLE ( net_ixgbe_vf , pci_id_ixgbevf_map );
RTE_PMD_REGISTER_KMOD_DEP ( net_ixgbe_vf , "* igb_uio | vfio" ); --
2.1.4
From: Jan Blunck <redacted>
The eth_driver concept is unused in the mlx drivers so don't reference it.
Signed-off-by: Jan Blunck <redacted>
---
drivers/net/mlx4/mlx4.c | 24 +++++++++++-------------
drivers/net/mlx5/mlx5.c | 24 +++++++++++-------------
2 files changed, 22 insertions(+), 26 deletions(-)
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index aff9155..a1363c8 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c @@ -60,6 +60,7 @@
#include <rte_ether.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_dev.h>
#include <rte_mbuf.h>
#include <rte_errno.h> @@ -5477,7 +5478,7 @@ mlx4_args(struct rte_devargs *devargs, struct mlx4_conf *conf)
return ret ;
}
- static struct eth_driver mlx4_driver ;
+ static struct rte_pci_driver mlx4_driver ;
/**
* DPDK callback to register a PCI device . @@ -5509,7 +5510,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
int i ;
( void ) pci_drv ;
- assert ( pci_drv == & mlx4_driver . pci_drv );
+ assert ( pci_drv == & mlx4_driver );
/* Get mlx4_dev[] index. */
idx = mlx4_dev_idx ( & pci_dev -> addr );
if ( idx == -1 ) { @@ -5808,7 +5809,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
rte_eth_copy_pci_info ( eth_dev , pci_dev );
- eth_dev -> driver = & mlx4_driver ;
+ eth_dev -> device -> driver = & mlx4_driver . driver ;
priv -> dev = eth_dev ;
eth_dev -> dev_ops = & mlx4_dev_ops ; @@ -5872,16 +5873,13 @@ static const struct rte_pci_id mlx4_pci_id_map[] = {
}
};
- static struct eth_driver mlx4_driver = {
- . pci_drv = {
- . driver = {
- . name = MLX4_DRIVER_NAME
- },
- . id_table = mlx4_pci_id_map ,
- . probe = mlx4_pci_probe ,
- . drv_flags = RTE_PCI_DRV_INTR_LSC ,
+ static struct rte_pci_driver mlx4_driver = {
+ . driver = {
+ . name = MLX4_DRIVER_NAME
},
- . dev_private_size = sizeof ( struct priv )
+ . id_table = mlx4_pci_id_map ,
+ . probe = mlx4_pci_probe ,
+ . drv_flags = RTE_PCI_DRV_INTR_LSC ,
};
/** @@ -5900,7 +5898,7 @@ rte_mlx4_pmd_init(void)
*/
setenv ( "RDMAV_HUGEPAGES_SAFE" , "1" , 1 );
ibv_fork_init ();
- rte_eal_pci_register ( & mlx4_driver . pci_drv );
+ rte_eal_pci_register ( & mlx4_driver );
}
RTE_PMD_EXPORT_NAME ( net_mlx4 , __COUNTER__ ); diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index b7eb9b5..6de4e4c 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c @@ -56,6 +56,7 @@
#endif
#include <rte_malloc.h>
#include <rte_ethdev.h>
+ #include <rte_ethdev_pci.h>
#include <rte_pci.h>
#include <rte_common.h>
#include <rte_kvargs.h> @@ -365,7 +366,7 @@ mlx5_args(struct priv *priv, struct rte_devargs *devargs)
return 0 ;
}
- static struct eth_driver mlx5_driver ;
+ static struct rte_pci_driver mlx5_driver ;
/**
* DPDK callback to register a PCI device . @@ -396,7 +397,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
int i ;
( void ) pci_drv ;
- assert ( pci_drv == & mlx5_driver . pci_drv );
+ assert ( pci_drv == & mlx5_driver );
/* Get mlx5_dev[] index. */
idx = mlx5_dev_idx ( & pci_dev -> addr );
if ( idx == -1 ) { @@ -731,7 +732,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
eth_dev -> device = & pci_dev -> device ;
rte_eth_copy_pci_info ( eth_dev , pci_dev );
- eth_dev -> driver = & mlx5_driver ;
+ eth_dev -> device -> driver = & mlx5_driver . driver ;
priv -> dev = eth_dev ;
eth_dev -> dev_ops = & mlx5_dev_ops ;
@@ -813,16 +814,13 @@ static const struct rte_pci_id mlx5_pci_id_map[] = {
}
};
- static struct eth_driver mlx5_driver = {
- . pci_drv = {
- . driver = {
- . name = MLX5_DRIVER_NAME
- },
- . id_table = mlx5_pci_id_map ,
- . probe = mlx5_pci_probe ,
- . drv_flags = RTE_PCI_DRV_INTR_LSC ,
+ static struct rte_pci_driver mlx5_driver = {
+ . driver = {
+ . name = MLX5_DRIVER_NAME
},
- . dev_private_size = sizeof ( struct priv )
+ . id_table = mlx5_pci_id_map ,
+ . probe = mlx5_pci_probe ,
+ . drv_flags = RTE_PCI_DRV_INTR_LSC ,
};
/** @@ -840,7 +838,7 @@ rte_mlx5_pmd_init(void)
*/
setenv ( "RDMAV_HUGEPAGES_SAFE" , "1" , 1 );
ibv_fork_init ();
- rte_eal_pci_register ( & mlx5_driver . pci_drv );
+ rte_eal_pci_register ( & mlx5_driver );
}
RTE_PMD_EXPORT_NAME ( net_mlx5 , __COUNTER__ ); --
2.1.4