From: Ferruh Yigit Date: Fri, 26 Aug 2016 11:17:46 +0000 (+0100) Subject: net/pcap: remove duplicated max queue number check X-Git-Tag: spdx-start~5866 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=cdbfc79a26bc8c1af28e3e4a59f76b864fe31e1a;p=dpdk.git net/pcap: remove duplicated max queue number check Remove duplicated check by reorganizing the code, no functional change. Signed-off-by: Ferruh Yigit Acked-by: Stephen Hemminger --- diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index e36d393c4a..3a40e847af 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);