From patchwork Mon Mar 2 17:36:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 66196 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 41DF3A056A; Mon, 2 Mar 2020 18:37:29 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2BF7B1C001; Mon, 2 Mar 2020 18:37:02 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 33DEB1C022 for ; Mon, 2 Mar 2020 18:37:00 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2020 09:36:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,507,1574150400"; d="scan'208";a="228535181" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.180]) by orsmga007.jf.intel.com with ESMTP; 02 Mar 2020 09:36:58 -0800 From: Ferruh Yigit To: dev@dpdk.org, Tetsuya Mukawa Cc: Ferruh Yigit Date: Mon, 2 Mar 2020 17:36:44 +0000 Message-Id: <20200302173646.54984-5-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200302173646.54984-1-ferruh.yigit@intel.com> References: <20200302173646.54984-1-ferruh.yigit@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 5/6] net/null: group device arguments X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Group device argument to the struct, to increase code readability. Signed-off-by: Ferruh Yigit --- 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)