From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 29DA9A00E6 for ; Fri, 14 Jun 2019 16:47:12 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7B20B1D53A; Fri, 14 Jun 2019 16:47:10 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 9B3381D519 for ; Fri, 14 Jun 2019 16:47:08 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jun 2019 07:47:07 -0700 X-ExtLoop1: 1 Received: from silpixa00393943.ir.intel.com (HELO silpixa00393943.ger.corp.intel.com) ([10.237.222.31]) by fmsmga005.fm.intel.com with ESMTP; 14 Jun 2019 07:47:06 -0700 From: Cian Ferriter To: Ferruh Yigit Cc: dev@dpdk.org, Cian Ferriter Date: Fri, 14 Jun 2019 15:43:36 +0100 Message-Id: <20190614144337.17177-1-cian.ferriter@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH 19.08 v3 1/2] net/pcap: use a struct to pass user options 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" 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 --- 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, ð_dev); + ret = eth_from_pcaps_common(vdev, devargs_all, &internals, ð_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