DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: dev@dpdk.org, Tetsuya Mukawa <mtetsuyah@gmail.com>
Cc: Ferruh Yigit <ferruh.yigit@intel.com>
Subject: [dpdk-dev] [PATCH 5/6] net/null: group device arguments
Date: Mon,  2 Mar 2020 17:36:44 +0000	[thread overview]
Message-ID: <20200302173646.54984-5-ferruh.yigit@intel.com> (raw)
In-Reply-To: <20200302173646.54984-1-ferruh.yigit@intel.com>

Group device argument to the struct, to increase code readability.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/net/null/rte_eth_null.c | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 7fa3b9e45..2c08ebf8c 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -36,6 +36,11 @@ struct null_queue {
 	rte_atomic64_t tx_pkts;
 };
 
+struct pmd_options {
+	unsigned int packet_copy;
+	unsigned int packet_size;
+};
+
 struct pmd_internals {
 	unsigned int packet_size;
 	unsigned int packet_copy;
@@ -462,9 +467,7 @@ static const struct eth_dev_ops ops = {
 };
 
 static int
-eth_dev_null_create(struct rte_vdev_device *dev,
-		unsigned int packet_size,
-		unsigned int packet_copy)
+eth_dev_null_create(struct rte_vdev_device *dev, struct pmd_options *args)
 {
 	const unsigned int nb_rx_queues = 1;
 	const unsigned int nb_tx_queues = 1;
@@ -499,8 +502,8 @@ eth_dev_null_create(struct rte_vdev_device *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->packet_size = args->packet_size;
+	internals->packet_copy = args->packet_copy;
 	internals->port_id = eth_dev->data->port_id;
 	rte_eth_random_addr(internals->eth_addr.addr_bytes);
 
@@ -520,7 +523,7 @@ eth_dev_null_create(struct rte_vdev_device *dev,
 	eth_dev->dev_ops = &ops;
 
 	/* finally assign rx and tx ops */
-	if (packet_copy) {
+	if (internals->packet_copy) {
 		eth_dev->rx_pkt_burst = eth_null_copy_rx;
 		eth_dev->tx_pkt_burst = eth_null_copy_tx;
 	} else {
@@ -570,8 +573,10 @@ static int
 rte_pmd_null_probe(struct rte_vdev_device *dev)
 {
 	const char *name, *params;
-	unsigned int packet_size = default_packet_size;
-	unsigned int packet_copy = default_packet_copy;
+	struct pmd_options args = {
+		.packet_copy = default_packet_copy,
+		.packet_size = default_packet_size,
+	};
 	struct rte_kvargs *kvlist = NULL;
 	struct rte_eth_dev *eth_dev;
 	int ret;
@@ -612,23 +617,23 @@ rte_pmd_null_probe(struct rte_vdev_device *dev)
 
 		ret = rte_kvargs_process(kvlist,
 				ETH_NULL_PACKET_SIZE_ARG,
-				&get_packet_size_arg, &packet_size);
+				&get_packet_size_arg, &args.packet_size);
 		if (ret < 0)
 			goto free_kvlist;
 
 
 		ret = rte_kvargs_process(kvlist,
 				ETH_NULL_PACKET_COPY_ARG,
-				&get_packet_copy_arg, &packet_copy);
+				&get_packet_copy_arg, &args.packet_copy);
 		if (ret < 0)
 			goto free_kvlist;
 	}
 
 	PMD_LOG(INFO, "Configure pmd_null: packet size is %d, "
-			"packet copy is %s", packet_size,
-			packet_copy ? "enabled" : "disabled");
+			"packet copy is %s", args.packet_size,
+			args.packet_copy ? "enabled" : "disabled");
 
-	ret = eth_dev_null_create(dev, packet_size, packet_copy);
+	ret = eth_dev_null_create(dev, &args);
 
 free_kvlist:
 	if (kvlist)
-- 
2.24.1


  parent reply	other threads:[~2020-03-02 17:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-02 17:36 [dpdk-dev] [PATCH 1/6] net/null: fix secondary burst function selection Ferruh Yigit
2020-03-02 17:36 ` [dpdk-dev] [PATCH 2/6] doc: add net null PMD guide Ferruh Yigit
2020-03-02 17:36 ` [dpdk-dev] [PATCH 3/6] net/null: remove redundant check Ferruh Yigit
2020-03-02 17:36 ` [dpdk-dev] [PATCH 4/6] net/null: prefer unsigned int Ferruh Yigit
2020-03-02 17:36 ` Ferruh Yigit [this message]
2020-03-02 17:36 ` [dpdk-dev] [PATCH 6/6] net/null: add argument for no Rx Ferruh Yigit
2020-04-07  8:38 ` [dpdk-dev] [PATCH 1/6] net/null: fix secondary burst function selection Ferruh Yigit
2020-04-10  8:33   ` [dpdk-dev] [dpdk-stable] " 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=20200302173646.54984-5-ferruh.yigit@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=dev@dpdk.org \
    --cc=mtetsuyah@gmail.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).