DPDK patches and discussions
 help / color / mirror / Atom feed
From: Gaetan Rivet <gaetan.rivet@6wind.com>
To: dev@dpdk.org
Cc: Jan Blunck <jblunck@infradead.org>
Subject: [dpdk-dev] [PATCH v2 15/42] net/pcap: use ethdev allocation helper for virtual devices
Date: Tue, 11 Apr 2017 17:44:22 +0200	[thread overview]
Message-ID: <ba01f5b46a132c6f4bea72454616d0b0c59aa4a7.1491924900.git.gaetan.rivet@6wind.com> (raw)
In-Reply-To: <cover.1491924900.git.gaetan.rivet@6wind.com>
In-Reply-To: <cover.1491924900.git.gaetan.rivet@6wind.com>

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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

  parent reply	other threads:[~2017-04-11 15:45 UTC|newest]

Thread overview: 104+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-06  9:59 [dpdk-dev] [PATCH 00/38] Remove struct eth_driver Jan Blunck
2017-03-06  9:59 ` [dpdk-dev] [PATCH 01/38] eal: add name field to generic device Jan Blunck
2017-03-06  9:59 ` [dpdk-dev] [PATCH 02/38] eal: parse "driver" device argument before probing drivers Jan Blunck
2017-03-06  9:59 ` [dpdk-dev] [PATCH 03/38] net/nfp: use library function for DMA zone reserve Jan Blunck
2017-03-10  7:03   ` Shreyansh Jain
2017-03-10  7:20     ` Jan Blunck
2017-03-06  9:59 ` [dpdk-dev] [PATCH 04/38] net/vmxnet3: " Jan Blunck
2017-03-06  9:59 ` [dpdk-dev] [PATCH 05/38] ether: add allocation helper for virtual drivers Jan Blunck
2017-03-06  9:59 ` [dpdk-dev] [PATCH 06/38] net/tap: use ethdev allocation helper for virtual devices Jan Blunck
2017-03-06  9:59 ` [dpdk-dev] [PATCH 07/38] net/vhost: " Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 08/38] net/virtio: " Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 09/38] net/af_packet: " Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 10/38] app/test: don't short-circuit null device creation Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 11/38] net/null: internalize eth_dev_null_create() Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 12/38] net/null: use ethdev allocation helper for virtual devices Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 13/38] net/bonding: make bonding API call through EAL on create/free Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 14/38] net/bonding: use ethdev allocation helper for virtual devices Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 15/38] ethdev: add PCI driver helpers Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 16/38] net/virtio: Don't use eth_driver Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 17/38] net/bnx2x: " Jan Blunck
2017-03-06 19:32   ` Harish Patil
2017-03-06 10:00 ` [dpdk-dev] [PATCH 18/38] net/bnxt: " Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 19/38] net/cxgbe: " Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 20/38] net/em: " Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 21/38] net/igb: " Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 22/38] net/ena: " Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 23/38] net/enic: " Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 24/38] net/fm10k: " Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 25/38] net/i40e: " Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 26/38] net/i40evf: " Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 27/38] net/ixgbe: " Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 28/38] net/mlx: Don't reference eth_driver Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 29/38] net/nfp: Don't use eth_driver Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 30/38] net/qede: " Jan Blunck
2017-03-06 19:33   ` Harish Patil
2017-03-06 10:00 ` [dpdk-dev] [PATCH 31/38] net/sfc: " Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 32/38] net/szedata2: " Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 33/38] net/thunderx: " Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 34/38] net/vmxnet3: " Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 35/38] ethdev: remove unused ethdev PCI probe/remove Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 36/38] ethdev: remove unused ethdev driver Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 37/38] ethdev: remove PCI specific helper from generic ethdev header Jan Blunck
2017-03-06 10:00 ` [dpdk-dev] [PATCH 38/38] ethdev: don't include PCI header Jan Blunck
2017-03-23 15:34 ` [dpdk-dev] [PATCH 00/38] Remove struct eth_driver Stephen Hemminger
2017-03-25 10:50   ` Jan Blunck
2017-04-11 15:44 ` [dpdk-dev] [PATCH v2 00/42] " Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 01/42] eal: add name field to generic device Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 02/42] eal: parse "driver" device argument before probing drivers Gaetan Rivet
2017-05-10  2:34     ` Ferruh Yigit
2017-05-10 11:01       ` Ferruh Yigit
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 03/42] net/nfp: use library function for DMA zone reserve Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 04/42] ether: add allocation helper for virtual drivers Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 05/42] net/tap: use ethdev allocation helper for virtual devices Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 06/42] net/vhost: " Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 07/42] net/virtio: " Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 08/42] net/af_packet: " Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 09/42] app/test: don't short-circuit null device creation Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 10/42] net/null: internalize eth_dev_null_create() Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 11/42] net/null: use ethdev allocation helper for virtual devices Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 12/42] net/bonding: make bonding API call through EAL on create/free Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 13/42] net/bonding: use ethdev allocation helper for virtual devices Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 14/42] net/kni: " Gaetan Rivet
2017-04-11 15:44   ` Gaetan Rivet [this message]
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 16/42] ethdev: add PCI driver helpers Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 17/42] net/virtio: Don't use eth_driver Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 18/42] net/bnx2x: " Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 19/42] net/bnxt: " Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 20/42] net/cxgbe: " Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 21/42] net/em: " Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 22/42] net/igb: " Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 23/42] net/ena: " Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 24/42] net/enic: " Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 25/42] net/fm10k: " Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 26/42] net/i40e: " Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 27/42] net/i40evf: " Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 28/42] net/ixgbe: " Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 29/42] net/mlx: Don't reference eth_driver Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 30/42] net/nfp: Don't use eth_driver Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 31/42] net/qede: " Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 32/42] net/sfc: " Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 33/42] net/szedata2: " Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 34/42] net/thunderx: " Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 35/42] net/vmxnet3: " Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 36/42] net/avp: " Gaetan Rivet
2017-04-11 18:48     ` Legacy, Allain
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 37/42] net/liquidio: " Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 38/42] ethdev: remove unused ethdev PCI probe/remove Gaetan Rivet
2017-04-12 11:24     ` Neil Horman
2017-04-12 11:28       ` Neil Horman
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 39/42] ethdev: remove unused ethdev driver Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 40/42] test: " Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 41/42] ethdev: remove PCI specific helper from generic ethdev header Gaetan Rivet
2017-04-11 15:44   ` [dpdk-dev] [PATCH v2 42/42] ethdev: don't include PCI header Gaetan Rivet
2017-04-12 16:25   ` [dpdk-dev] [PATCH v2 00/42] Remove struct eth_driver Stephen Hemminger
2017-04-14 13:09     ` Thomas Monjalon
2017-04-18 18:27       ` [dpdk-dev] [PATCH 0/2] next-net: remove ethdev driver Ferruh Yigit
2017-04-18 18:27         ` [dpdk-dev] [PATCH 1/2] net/ark: remove eth_dev Ferruh Yigit
2017-04-18 19:24           ` Ed Czeck
2017-04-19 10:03             ` Ferruh Yigit
2017-04-18 18:27         ` [dpdk-dev] [PATCH 2/2] net/xenvirt: remove ethdev driver Ferruh Yigit
2017-04-19  9:52           ` [dpdk-dev] [PATCH v2] net/xenvirt: fix build error Ferruh Yigit
2017-04-19 12:12             ` Thomas Monjalon
2017-04-18 18:38         ` [dpdk-dev] [PATCH 0/2] next-net: remove ethdev driver Ferruh Yigit
2017-04-19 11:37         ` Shreyansh Jain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ba01f5b46a132c6f4bea72454616d0b0c59aa4a7.1491924900.git.gaetan.rivet@6wind.com \
    --to=gaetan.rivet@6wind.com \
    --cc=dev@dpdk.org \
    --cc=jblunck@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).