From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id A72915A31 for ; Fri, 26 Aug 2016 13:21:36 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP; 26 Aug 2016 04:21:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,580,1464678000"; d="scan'208";a="753779130" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by FMSMGA003.fm.intel.com with ESMTP; 26 Aug 2016 04:21:36 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u7QBLYZq030731 for ; Fri, 26 Aug 2016 12:21:34 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id u7QBLYPe008871 for ; Fri, 26 Aug 2016 12:21:34 +0100 Received: (from fyigit@localhost) by sivswdev02.ir.intel.com with id u7QBLY9i008867 for dev@dpdk.org; Fri, 26 Aug 2016 12:21:34 +0100 X-Authentication-Warning: sivswdev02.ir.intel.com: fyigit set sender to ferruh.yigit@intel.com using -f From: Ferruh Yigit To: dev@dpdk.org Date: Fri, 26 Aug 2016 12:17:46 +0100 Message-Id: <1472210279-8286-10-git-send-email-ferruh.yigit@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1472210279-8286-1-git-send-email-ferruh.yigit@intel.com> References: <1472210279-8286-1-git-send-email-ferruh.yigit@intel.com> Subject: [dpdk-dev] [PATCH 09/22] net/pcap: remove duplicated max queue number check X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Aug 2016 11:21:37 -0000 Remove duplicated check by reorganizing the code, no functional change. Signed-off-by: Ferruh Yigit --- drivers/net/pcap/rte_eth_pcap.c | 49 ++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index ff61d62..276d6e0 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -941,11 +941,11 @@ rte_eth_from_pcaps(const char *name, struct pmd_devargs *rx_queues, static int rte_pmd_pcap_devinit(const char *name, const char *params) { - unsigned using_dumpers = 0; - int ret; + unsigned int is_rx_pcap = 0, is_tx_pcap = 0; struct rte_kvargs *kvlist; struct pmd_devargs pcaps = {0}; struct pmd_devargs dumpers = {0}; + int ret; RTE_LOG(INFO, PMD, "Initializing pmd_pcap for %s\n", name); @@ -971,7 +971,7 @@ rte_pmd_pcap_devinit(const char *name, const char *params) dumpers.queue[0].name = pcaps.queue[0].name; dumpers.queue[0].type = pcaps.queue[0].type; ret = rte_eth_from_pcaps(name, &pcaps, 1, &dumpers, 1, - kvlist, 1, using_dumpers); + kvlist, 1, is_tx_pcap); goto free_kvlist; } @@ -980,23 +980,21 @@ rte_pmd_pcap_devinit(const char *name, const char *params) * pcap file */ pcaps.num_of_queue = rte_kvargs_count(kvlist, ETH_PCAP_RX_PCAP_ARG); - - if (pcaps.num_of_queue) { - if (pcaps.num_of_queue > RTE_PMD_PCAP_MAX_QUEUES) - pcaps.num_of_queue = RTE_PMD_PCAP_MAX_QUEUES; - - ret = rte_kvargs_process(kvlist, ETH_PCAP_RX_PCAP_ARG, - &open_rx_pcap, &pcaps); - } else { + if (pcaps.num_of_queue) + is_rx_pcap = 1; + else pcaps.num_of_queue = rte_kvargs_count(kvlist, ETH_PCAP_RX_IFACE_ARG); - if (pcaps.num_of_queue > RTE_PMD_PCAP_MAX_QUEUES) - pcaps.num_of_queue = RTE_PMD_PCAP_MAX_QUEUES; + if (pcaps.num_of_queue > RTE_PMD_PCAP_MAX_QUEUES) + pcaps.num_of_queue = RTE_PMD_PCAP_MAX_QUEUES; + if (is_rx_pcap) + ret = rte_kvargs_process(kvlist, ETH_PCAP_RX_PCAP_ARG, + &open_rx_pcap, &pcaps); + else ret = rte_kvargs_process(kvlist, ETH_PCAP_RX_IFACE_ARG, &open_rx_iface, &pcaps); - } if (ret < 0) goto free_kvlist; @@ -1006,30 +1004,27 @@ rte_pmd_pcap_devinit(const char *name, const char *params) * pcap file */ dumpers.num_of_queue = rte_kvargs_count(kvlist, ETH_PCAP_TX_PCAP_ARG); - - if (dumpers.num_of_queue) { - if (dumpers.num_of_queue > RTE_PMD_PCAP_MAX_QUEUES) - dumpers.num_of_queue = RTE_PMD_PCAP_MAX_QUEUES; - - ret = rte_kvargs_process(kvlist, ETH_PCAP_TX_PCAP_ARG, - &open_tx_pcap, &dumpers); - using_dumpers = 1; - } else { + if (dumpers.num_of_queue) + is_tx_pcap = 1; + else dumpers.num_of_queue = rte_kvargs_count(kvlist, ETH_PCAP_TX_IFACE_ARG); - if (dumpers.num_of_queue > RTE_PMD_PCAP_MAX_QUEUES) - dumpers.num_of_queue = RTE_PMD_PCAP_MAX_QUEUES; + if (dumpers.num_of_queue > RTE_PMD_PCAP_MAX_QUEUES) + dumpers.num_of_queue = RTE_PMD_PCAP_MAX_QUEUES; + if (is_tx_pcap) + ret = rte_kvargs_process(kvlist, ETH_PCAP_TX_PCAP_ARG, + &open_tx_pcap, &dumpers); + else ret = rte_kvargs_process(kvlist, ETH_PCAP_TX_IFACE_ARG, &open_tx_iface, &dumpers); - } if (ret < 0) goto free_kvlist; ret = rte_eth_from_pcaps(name, &pcaps, pcaps.num_of_queue, &dumpers, - dumpers.num_of_queue, kvlist, 0, using_dumpers); + dumpers.num_of_queue, kvlist, 0, is_tx_pcap); free_kvlist: rte_kvargs_free(kvlist); -- 2.7.4