DPDK patches and discussions
 help / color / mirror / Atom feed
From: Cian Ferriter <cian.ferriter@intel.com>
To: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: dev@dpdk.org, Cian Ferriter <cian.ferriter@intel.com>
Subject: [dpdk-dev] [PATCH 19.08 v3 1/2] net/pcap: use a struct to pass user options
Date: Fri, 14 Jun 2019 15:43:36 +0100	[thread overview]
Message-ID: <20190614144337.17177-1-cian.ferriter@intel.com> (raw)

The argument lists on some of the device creation functions are quite
large. Using a struct to hold the user options parsed in
'pmd_pcap_probe' will allow for cleaner function calls and definitions.
Adding user options will also be easier.

Signed-off-by: Cian Ferriter <cian.ferriter@intel.com>
---
 drivers/net/pcap/rte_eth_pcap.c | 51 ++++++++++++++++++++++-----------
 1 file changed, 35 insertions(+), 16 deletions(-)

diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 10277b9b6..c35f501cf 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -101,6 +101,14 @@ struct pmd_devargs {
 	int phy_mac;
 };
 
+struct pmd_devargs_all {
+	struct pmd_devargs rx_queues;
+	struct pmd_devargs tx_queues;
+	int single_iface;
+	unsigned int is_tx_pcap;
+	unsigned int is_tx_iface;
+};
+
 static const char *valid_arguments[] = {
 	ETH_PCAP_RX_PCAP_ARG,
 	ETH_PCAP_TX_PCAP_ARG,
@@ -1061,11 +1069,14 @@ eth_pcap_update_mac(const char *if_name, struct rte_eth_dev *eth_dev,
 
 static int
 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 pmd_devargs_all *devargs_all,
 		struct pmd_internals **internals, struct rte_eth_dev **eth_dev)
 {
 	struct pmd_process_private *pp;
+	struct pmd_devargs *rx_queues = &devargs_all->rx_queues;
+	struct pmd_devargs *tx_queues = &devargs_all->tx_queues;
+	const unsigned int nb_rx_queues = rx_queues->num_of_queue;
+	const unsigned int nb_tx_queues = tx_queues->num_of_queue;
 	unsigned int i;
 
 	/* do some parameter checking */
@@ -1103,16 +1114,15 @@ eth_from_pcaps_common(struct rte_vdev_device *vdev,
 
 static int
 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,
-		int single_iface, unsigned int using_dumpers)
+		struct pmd_devargs_all *devargs_all)
 {
 	struct pmd_internals *internals = NULL;
 	struct rte_eth_dev *eth_dev = NULL;
+	struct pmd_devargs *rx_queues = &devargs_all->rx_queues;
+	int single_iface = devargs_all->single_iface;
 	int ret;
 
-	ret = eth_from_pcaps_common(vdev, rx_queues, nb_rx_queues,
-		tx_queues, nb_tx_queues, &internals, &eth_dev);
+	ret = eth_from_pcaps_common(vdev, devargs_all, &internals, &eth_dev);
 
 	if (ret < 0)
 		return ret;
@@ -1134,7 +1144,8 @@ eth_from_pcaps(struct rte_vdev_device *vdev,
 
 	eth_dev->rx_pkt_burst = eth_pcap_rx;
 
-	if (using_dumpers)
+	/* Assign tx ops. */
+	if (devargs_all->is_tx_pcap)
 		eth_dev->tx_pkt_burst = eth_pcap_tx_dumper;
 	else
 		eth_dev->tx_pkt_burst = eth_pcap_tx;
@@ -1147,15 +1158,20 @@ static int
 pmd_pcap_probe(struct rte_vdev_device *dev)
 {
 	const char *name;
-	unsigned int is_rx_pcap = 0, is_tx_pcap = 0;
+	unsigned int is_rx_pcap = 0;
 	struct rte_kvargs *kvlist;
 	struct pmd_devargs pcaps = {0};
 	struct pmd_devargs dumpers = {0};
 	struct rte_eth_dev *eth_dev =  NULL;
 	struct pmd_internals *internal;
-	int single_iface = 0;
 	int ret;
 
+	struct pmd_devargs_all devargs_all = {
+		.single_iface = 0,
+		.is_tx_pcap = 0,
+		.is_tx_iface = 0,
+	};
+
 	name = rte_vdev_device_name(dev);
 	PMD_LOG(INFO, "Initializing pmd_pcap for %s", name);
 
@@ -1202,7 +1218,7 @@ pmd_pcap_probe(struct rte_vdev_device *dev)
 
 		dumpers.phy_mac = pcaps.phy_mac;
 
-		single_iface = 1;
+		devargs_all.single_iface = 1;
 		pcaps.num_of_queue = 1;
 		dumpers.num_of_queue = 1;
 
@@ -1231,10 +1247,11 @@ pmd_pcap_probe(struct rte_vdev_device *dev)
 	 * We check whether we want to open a TX stream to a real NIC or a
 	 * pcap file
 	 */
-	is_tx_pcap = rte_kvargs_count(kvlist, ETH_PCAP_TX_PCAP_ARG) ? 1 : 0;
+	devargs_all.is_tx_pcap =
+		rte_kvargs_count(kvlist, ETH_PCAP_TX_PCAP_ARG) ? 1 : 0;
 	dumpers.num_of_queue = 0;
 
-	if (is_tx_pcap)
+	if (devargs_all.is_tx_pcap)
 		ret = rte_kvargs_process(kvlist, ETH_PCAP_TX_PCAP_ARG,
 				&open_tx_pcap, &dumpers);
 	else
@@ -1276,7 +1293,7 @@ pmd_pcap_probe(struct rte_vdev_device *dev)
 
 		eth_dev->process_private = pp;
 		eth_dev->rx_pkt_burst = eth_pcap_rx;
-		if (is_tx_pcap)
+		if (devargs_all.is_tx_pcap)
 			eth_dev->tx_pkt_burst = eth_pcap_tx_dumper;
 		else
 			eth_dev->tx_pkt_burst = eth_pcap_tx;
@@ -1285,8 +1302,10 @@ pmd_pcap_probe(struct rte_vdev_device *dev)
 		goto free_kvlist;
 	}
 
-	ret = eth_from_pcaps(dev, &pcaps, pcaps.num_of_queue, &dumpers,
-		dumpers.num_of_queue, single_iface, is_tx_pcap);
+	devargs_all.rx_queues = pcaps;
+	devargs_all.tx_queues = dumpers;
+
+	ret = eth_from_pcaps(dev, &devargs_all);
 
 free_kvlist:
 	rte_kvargs_free(kvlist);
-- 
2.17.1


             reply	other threads:[~2019-06-14 14:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-14 14:43 Cian Ferriter [this message]
2019-06-14 14:43 ` [dpdk-dev] [PATCH 19.08 v3 2/2] net/pcap: enable infinitely rxing a pcap file Cian Ferriter
2019-06-27 17:56   ` Ferruh Yigit
2019-06-28 12:32     ` Ferriter, Cian
2019-06-28 13:00       ` Ferruh Yigit
2019-06-28 15:30 ` [dpdk-dev] [PATCH 19.08 v3 1/2] net/pcap: use a struct to pass user options Ferruh Yigit

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=20190614144337.17177-1-cian.ferriter@intel.com \
    --to=cian.ferriter@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    /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).