DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] examples: remove useless checking
@ 2016-04-29 15:48 Mauricio Vasquez B
  2016-05-03 14:39 ` Ferruh Yigit
  2016-05-03 21:16 ` [dpdk-dev] [PATCH v2] " Mauricio Vasquez B
  0 siblings, 2 replies; 5+ messages in thread
From: Mauricio Vasquez B @ 2016-04-29 15:48 UTC (permalink / raw)
  To: dev

The rte_eth_dev_count() function will never return a value greater
than RTE_MAX_ETHPORTS, so that checking is useless.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezbernal@studenti.polito.it>
---
 app/proc_info/main.c                                 | 4 ----
 app/test/test_pmd_perf.c                             | 3 ---
 doc/guides/sample_app_ug/l2_forward_job_stats.rst    | 3 ---
 doc/guides/sample_app_ug/l2_forward_real_virtual.rst | 3 ---
 doc/guides/sample_app_ug/link_status_intr.rst        | 3 ---
 examples/dpdk_qat/main.c                             | 2 --
 examples/ip_fragmentation/main.c                     | 4 +---
 examples/ip_reassembly/main.c                        | 4 +---
 examples/ipsec-secgw/ipsec-secgw.c                   | 4 ----
 examples/l2fwd-crypto/main.c                         | 3 ---
 examples/l2fwd-ivshmem/host/host.c                   | 3 ---
 examples/l2fwd-jobstats/main.c                       | 3 ---
 examples/l2fwd-keepalive/main.c                      | 3 ---
 examples/l2fwd/main.c                                | 3 ---
 examples/l3fwd-acl/main.c                            | 2 --
 examples/l3fwd-power/main.c                          | 3 ---
 examples/l3fwd-vf/main.c                             | 2 --
 examples/l3fwd/main.c                                | 2 --
 examples/link_status_interrupt/main.c                | 3 ---
 examples/multi_process/l2fwd_fork/main.c             | 3 ---
 examples/performance-thread/l3fwd-thread/main.c      | 2 --
 examples/tep_termination/main.c                      | 2 --
 examples/vhost/main.c                                | 2 --
 examples/vhost_xen/main.c                            | 2 --
 examples/vmdq/main.c                                 | 2 --
 examples/vmdq_dcb/main.c                             | 2 --
 26 files changed, 2 insertions(+), 70 deletions(-)

diff --git a/app/proc_info/main.c b/app/proc_info/main.c
index 341176d..5f83092 100644
--- a/app/proc_info/main.c
+++ b/app/proc_info/main.c
@@ -327,10 +327,6 @@ main(int argc, char **argv)
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
 
-
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
-
 	/* If no port mask was specified*/
 	if (enabled_port_mask == 0)
 		enabled_port_mask = 0xffff;
diff --git a/app/test/test_pmd_perf.c b/app/test/test_pmd_perf.c
index 59803f7..3d56cd2 100644
--- a/app/test/test_pmd_perf.c
+++ b/app/test/test_pmd_perf.c
@@ -709,9 +709,6 @@ test_pmd_perf(void)
 		return -1;
 	}
 
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
-
 	nb_lcores = rte_lcore_count();
 
 	memset(lcore_conf, 0, sizeof(lcore_conf));
diff --git a/doc/guides/sample_app_ug/l2_forward_job_stats.rst b/doc/guides/sample_app_ug/l2_forward_job_stats.rst
index 03d9977..2444e36 100644
--- a/doc/guides/sample_app_ug/l2_forward_job_stats.rst
+++ b/doc/guides/sample_app_ug/l2_forward_job_stats.rst
@@ -238,9 +238,6 @@ in the *DPDK Programmer's Guide* and the *DPDK API Reference*.
     if (nb_ports == 0)
         rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
 
-    if (nb_ports > RTE_MAX_ETHPORTS)
-        nb_ports = RTE_MAX_ETHPORTS;
-
     /* reset l2fwd_dst_ports */
 
     for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++)
diff --git a/doc/guides/sample_app_ug/l2_forward_real_virtual.rst b/doc/guides/sample_app_ug/l2_forward_real_virtual.rst
index e77d67c..b51b2dc 100644
--- a/doc/guides/sample_app_ug/l2_forward_real_virtual.rst
+++ b/doc/guides/sample_app_ug/l2_forward_real_virtual.rst
@@ -242,9 +242,6 @@ in the *DPDK Programmer's Guide* - Rel 1.4 EAR and the *DPDK API Reference*.
     if (nb_ports == 0)
         rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
 
-    if (nb_ports > RTE_MAX_ETHPORTS)
-        nb_ports = RTE_MAX_ETHPORTS;
-
     /* reset l2fwd_dst_ports */
 
     for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++)
diff --git a/doc/guides/sample_app_ug/link_status_intr.rst b/doc/guides/sample_app_ug/link_status_intr.rst
index a4dbb54..779df97 100644
--- a/doc/guides/sample_app_ug/link_status_intr.rst
+++ b/doc/guides/sample_app_ug/link_status_intr.rst
@@ -145,9 +145,6 @@ To fully understand this code, it is recommended to study the chapters that rela
     if (nb_ports == 0)
         rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
 
-    if (nb_ports > RTE_MAX_ETHPORTS)
-        nb_ports = RTE_MAX_ETHPORTS;
-
     /*
      * Each logical core is assigned a dedicated TX queue on each port.
      */
diff --git a/examples/dpdk_qat/main.c b/examples/dpdk_qat/main.c
index dc68989..3c6112d 100644
--- a/examples/dpdk_qat/main.c
+++ b/examples/dpdk_qat/main.c
@@ -661,8 +661,6 @@ main(int argc, char **argv)
 		return -1;
 
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	if (check_port_config(nb_ports) < 0)
 		rte_panic("check_port_config failed\n");
diff --git a/examples/ip_fragmentation/main.c b/examples/ip_fragmentation/main.c
index 81a4918..b00f1e6 100644
--- a/examples/ip_fragmentation/main.c
+++ b/examples/ip_fragmentation/main.c
@@ -824,9 +824,7 @@ main(int argc, char **argv)
 		rte_exit(EXIT_FAILURE, "Invalid arguments");
 
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
-	else if (nb_ports == 0)
+	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No ports found!\n");
 
 	nb_lcores = rte_lcore_count();
diff --git a/examples/ip_reassembly/main.c b/examples/ip_reassembly/main.c
index c27e735..a8aabdc 100644
--- a/examples/ip_reassembly/main.c
+++ b/examples/ip_reassembly/main.c
@@ -1040,9 +1040,7 @@ main(int argc, char **argv)
 		rte_exit(EXIT_FAILURE, "Invalid IP reassembly parameters\n");
 
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
-	else if (nb_ports == 0)
+	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No ports found!\n");
 
 	nb_lcores = rte_lcore_count();
diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
index 00ab2d8..1dc505c 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -636,8 +636,6 @@ check_params(void)
 	}
 
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	for (i = 0; i < nb_lcore_params; ++i) {
 		lcore = lcore_params[i].lcore_id;
@@ -1286,8 +1284,6 @@ main(int32_t argc, char **argv)
 				unprotected_port_mask);
 
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	if (check_params() < 0)
 		rte_exit(EXIT_FAILURE, "check_params failed\n");
diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index d4e2d8d..d18c813 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -1785,9 +1785,6 @@ initialize_ports(struct l2fwd_crypto_options *options)
 		return -1;
 	}
 
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
-
 	/* Reset l2fwd_dst_ports */
 	for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++)
 		l2fwd_dst_ports[portid] = 0;
diff --git a/examples/l2fwd-ivshmem/host/host.c b/examples/l2fwd-ivshmem/host/host.c
index 4bd7c41..cd284b7 100644
--- a/examples/l2fwd-ivshmem/host/host.c
+++ b/examples/l2fwd-ivshmem/host/host.c
@@ -677,9 +677,6 @@ int main(int argc, char **argv)
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
 
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
-
 	/*
 	 * reserve memzone to communicate with VMs - we cannot use rte_malloc here
 	 * because while it is technically possible, it is a very bad idea to share
diff --git a/examples/l2fwd-jobstats/main.c b/examples/l2fwd-jobstats/main.c
index 9f3a77d..c193840 100644
--- a/examples/l2fwd-jobstats/main.c
+++ b/examples/l2fwd-jobstats/main.c
@@ -811,9 +811,6 @@ main(int argc, char **argv)
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
 
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
-
 	/* reset l2fwd_dst_ports */
 	for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++)
 		l2fwd_dst_ports[portid] = 0;
diff --git a/examples/l2fwd-keepalive/main.c b/examples/l2fwd-keepalive/main.c
index 8da89aa..4a0d9b6 100644
--- a/examples/l2fwd-keepalive/main.c
+++ b/examples/l2fwd-keepalive/main.c
@@ -570,9 +570,6 @@ main(int argc, char **argv)
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
 
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
-
 	/* reset l2fwd_dst_ports */
 	for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++)
 		l2fwd_dst_ports[portid] = 0;
diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c
index 1ad9488..c093d4d 100644
--- a/examples/l2fwd/main.c
+++ b/examples/l2fwd/main.c
@@ -551,9 +551,6 @@ main(int argc, char **argv)
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
 
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
-
 	/* reset l2fwd_dst_ports */
 	for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++)
 		l2fwd_dst_ports[portid] = 0;
diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c
index 26d9f5e..dbf4c1e 100644
--- a/examples/l3fwd-acl/main.c
+++ b/examples/l3fwd-acl/main.c
@@ -1914,8 +1914,6 @@ main(int argc, char **argv)
 		rte_exit(EXIT_FAILURE, "init_lcore_rx_queues failed\n");
 
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	if (check_port_config(nb_ports) < 0)
 		rte_exit(EXIT_FAILURE, "check_port_config failed\n");
diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index cb42bfb..f746960 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -1572,10 +1572,7 @@ main(int argc, char **argv)
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "init_lcore_rx_queues failed\n");
 
-
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	if (check_port_config(nb_ports) < 0)
 		rte_exit(EXIT_FAILURE, "check_port_config failed\n");
diff --git a/examples/l3fwd-vf/main.c b/examples/l3fwd-vf/main.c
index 034c22a..ca01b11 100644
--- a/examples/l3fwd-vf/main.c
+++ b/examples/l3fwd-vf/main.c
@@ -982,8 +982,6 @@ main(int argc, char **argv)
 		rte_exit(EXIT_FAILURE, "init_lcore_rx_queues failed\n");
 
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	if (check_port_config(nb_ports) < 0)
 		rte_exit(EXIT_FAILURE, "check_port_config failed\n");
diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
index bf6d885..7a79cd2 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -868,8 +868,6 @@ main(int argc, char **argv)
 		rte_exit(EXIT_FAILURE, "init_lcore_rx_queues failed\n");
 
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	if (check_port_config(nb_ports) < 0)
 		rte_exit(EXIT_FAILURE, "check_port_config failed\n");
diff --git a/examples/link_status_interrupt/main.c b/examples/link_status_interrupt/main.c
index 9981598..04dc3e4 100644
--- a/examples/link_status_interrupt/main.c
+++ b/examples/link_status_interrupt/main.c
@@ -580,9 +580,6 @@ main(int argc, char **argv)
 	if (nb_ports == 0)
 		rte_panic("No Ethernet port - bye\n");
 
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
-
 	/*
 	 * Each logical core is assigned a dedicated TX queue on each port.
 	 */
diff --git a/examples/multi_process/l2fwd_fork/main.c b/examples/multi_process/l2fwd_fork/main.c
index 2dc8b82..368b309 100644
--- a/examples/multi_process/l2fwd_fork/main.c
+++ b/examples/multi_process/l2fwd_fork/main.c
@@ -979,9 +979,6 @@ main(int argc, char **argv)
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
 
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
-
 	/* create the mbuf pool */
 	for (portid = 0; portid < nb_ports; portid++) {
 		/* skip ports that are not enabled */
diff --git a/examples/performance-thread/l3fwd-thread/main.c b/examples/performance-thread/l3fwd-thread/main.c
index 4ad16ea..400daed 100644
--- a/examples/performance-thread/l3fwd-thread/main.c
+++ b/examples/performance-thread/l3fwd-thread/main.c
@@ -3482,8 +3482,6 @@ main(int argc, char **argv)
 		rte_exit(EXIT_FAILURE, "init_rx_rings failed\n");
 
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	if (check_port_config(nb_ports) < 0)
 		rte_exit(EXIT_FAILURE, "check_port_config failed\n");
diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c
index f97d552..887cb26 100644
--- a/examples/tep_termination/main.c
+++ b/examples/tep_termination/main.c
@@ -1190,8 +1190,6 @@ main(int argc, char *argv[])
 
 	/* Get the number of physical ports. */
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	/*
 	 * Update the global var NB_PORTS and global array PORTS
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 28c17af..b22138f 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -2992,8 +2992,6 @@ main(int argc, char *argv[])
 
 	/* Get the number of physical ports. */
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	/*
 	 * Update the global var NUM_PORTS and global array PORTS
diff --git a/examples/vhost_xen/main.c b/examples/vhost_xen/main.c
index d83138d..2d69849 100644
--- a/examples/vhost_xen/main.c
+++ b/examples/vhost_xen/main.c
@@ -1460,8 +1460,6 @@ main(int argc, char *argv[])
 
 	/* Get the number of physical ports. */
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	/*
 	 * Update the global var NUM_PORTS and global array PORTS
diff --git a/examples/vmdq/main.c b/examples/vmdq/main.c
index 178af2f..360492b 100644
--- a/examples/vmdq/main.c
+++ b/examples/vmdq/main.c
@@ -599,8 +599,6 @@ main(int argc, char *argv[])
 		rte_exit(EXIT_FAILURE, "Not enough cores\n");
 
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	/*
 	 * Update the global var NUM_PORTS and global array PORTS
diff --git a/examples/vmdq_dcb/main.c b/examples/vmdq_dcb/main.c
index 62e1422..617263b 100644
--- a/examples/vmdq_dcb/main.c
+++ b/examples/vmdq_dcb/main.c
@@ -662,8 +662,6 @@ main(int argc, char *argv[])
 	}
 
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	/*
 	 * Update the global var NUM_PORTS and global array PORTS
-- 
1.9.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] examples: remove useless checking
  2016-04-29 15:48 [dpdk-dev] [PATCH] examples: remove useless checking Mauricio Vasquez B
@ 2016-05-03 14:39 ` Ferruh Yigit
  2016-05-03 21:16 ` [dpdk-dev] [PATCH v2] " Mauricio Vasquez B
  1 sibling, 0 replies; 5+ messages in thread
From: Ferruh Yigit @ 2016-05-03 14:39 UTC (permalink / raw)
  To: dev, Mauricio Vasquez B

On 4/29/2016 4:48 PM, Mauricio Vasquez B wrote:
> The rte_eth_dev_count() function will never return a value greater
> than RTE_MAX_ETHPORTS, so that checking is useless.
> 
> Signed-off-by: Mauricio Vasquez B <mauricio.vasquezbernal@studenti.polito.it>

Patch looks good to me.

Only there is one missed in examples/kni/main.c, can you please include
that one too?

Thanks,
ferruh

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-dev] [PATCH v2] examples: remove useless checking
  2016-04-29 15:48 [dpdk-dev] [PATCH] examples: remove useless checking Mauricio Vasquez B
  2016-05-03 14:39 ` Ferruh Yigit
@ 2016-05-03 21:16 ` Mauricio Vasquez B
  2016-05-04  8:04   ` Ferruh Yigit
  1 sibling, 1 reply; 5+ messages in thread
From: Mauricio Vasquez B @ 2016-05-03 21:16 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit

The rte_eth_dev_count() function will never return a value greater
than RTE_MAX_ETHPORTS, so that checking is useless.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezbernal@studenti.polito.it>
---
v2:
 Add missed case in examples/kni/main.c
 app/proc_info/main.c                                 | 4 ----
 app/test/test_pmd_perf.c                             | 3 ---
 doc/guides/sample_app_ug/l2_forward_job_stats.rst    | 3 ---
 doc/guides/sample_app_ug/l2_forward_real_virtual.rst | 3 ---
 doc/guides/sample_app_ug/link_status_intr.rst        | 3 ---
 examples/dpdk_qat/main.c                             | 2 --
 examples/ip_fragmentation/main.c                     | 4 +---
 examples/ip_reassembly/main.c                        | 4 +---
 examples/ipsec-secgw/ipsec-secgw.c                   | 4 ----
 examples/kni/main.c                                  | 2 --
 examples/l2fwd-crypto/main.c                         | 3 ---
 examples/l2fwd-ivshmem/host/host.c                   | 3 ---
 examples/l2fwd-jobstats/main.c                       | 3 ---
 examples/l2fwd-keepalive/main.c                      | 3 ---
 examples/l2fwd/main.c                                | 3 ---
 examples/l3fwd-acl/main.c                            | 2 --
 examples/l3fwd-power/main.c                          | 3 ---
 examples/l3fwd-vf/main.c                             | 2 --
 examples/l3fwd/main.c                                | 2 --
 examples/link_status_interrupt/main.c                | 3 ---
 examples/multi_process/l2fwd_fork/main.c             | 3 ---
 examples/performance-thread/l3fwd-thread/main.c      | 2 --
 examples/tep_termination/main.c                      | 2 --
 examples/vhost/main.c                                | 2 --
 examples/vhost_xen/main.c                            | 2 --
 examples/vmdq/main.c                                 | 2 --
 examples/vmdq_dcb/main.c                             | 2 --
 27 files changed, 2 insertions(+), 72 deletions(-)

diff --git a/app/proc_info/main.c b/app/proc_info/main.c
index 341176d..5f83092 100644
--- a/app/proc_info/main.c
+++ b/app/proc_info/main.c
@@ -327,10 +327,6 @@ main(int argc, char **argv)
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
 
-
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
-
 	/* If no port mask was specified*/
 	if (enabled_port_mask == 0)
 		enabled_port_mask = 0xffff;
diff --git a/app/test/test_pmd_perf.c b/app/test/test_pmd_perf.c
index 59803f7..3d56cd2 100644
--- a/app/test/test_pmd_perf.c
+++ b/app/test/test_pmd_perf.c
@@ -709,9 +709,6 @@ test_pmd_perf(void)
 		return -1;
 	}
 
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
-
 	nb_lcores = rte_lcore_count();
 
 	memset(lcore_conf, 0, sizeof(lcore_conf));
diff --git a/doc/guides/sample_app_ug/l2_forward_job_stats.rst b/doc/guides/sample_app_ug/l2_forward_job_stats.rst
index 03d9977..2444e36 100644
--- a/doc/guides/sample_app_ug/l2_forward_job_stats.rst
+++ b/doc/guides/sample_app_ug/l2_forward_job_stats.rst
@@ -238,9 +238,6 @@ in the *DPDK Programmer's Guide* and the *DPDK API Reference*.
     if (nb_ports == 0)
         rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
 
-    if (nb_ports > RTE_MAX_ETHPORTS)
-        nb_ports = RTE_MAX_ETHPORTS;
-
     /* reset l2fwd_dst_ports */
 
     for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++)
diff --git a/doc/guides/sample_app_ug/l2_forward_real_virtual.rst b/doc/guides/sample_app_ug/l2_forward_real_virtual.rst
index e77d67c..b51b2dc 100644
--- a/doc/guides/sample_app_ug/l2_forward_real_virtual.rst
+++ b/doc/guides/sample_app_ug/l2_forward_real_virtual.rst
@@ -242,9 +242,6 @@ in the *DPDK Programmer's Guide* - Rel 1.4 EAR and the *DPDK API Reference*.
     if (nb_ports == 0)
         rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
 
-    if (nb_ports > RTE_MAX_ETHPORTS)
-        nb_ports = RTE_MAX_ETHPORTS;
-
     /* reset l2fwd_dst_ports */
 
     for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++)
diff --git a/doc/guides/sample_app_ug/link_status_intr.rst b/doc/guides/sample_app_ug/link_status_intr.rst
index a4dbb54..779df97 100644
--- a/doc/guides/sample_app_ug/link_status_intr.rst
+++ b/doc/guides/sample_app_ug/link_status_intr.rst
@@ -145,9 +145,6 @@ To fully understand this code, it is recommended to study the chapters that rela
     if (nb_ports == 0)
         rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
 
-    if (nb_ports > RTE_MAX_ETHPORTS)
-        nb_ports = RTE_MAX_ETHPORTS;
-
     /*
      * Each logical core is assigned a dedicated TX queue on each port.
      */
diff --git a/examples/dpdk_qat/main.c b/examples/dpdk_qat/main.c
index dc68989..3c6112d 100644
--- a/examples/dpdk_qat/main.c
+++ b/examples/dpdk_qat/main.c
@@ -661,8 +661,6 @@ main(int argc, char **argv)
 		return -1;
 
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	if (check_port_config(nb_ports) < 0)
 		rte_panic("check_port_config failed\n");
diff --git a/examples/ip_fragmentation/main.c b/examples/ip_fragmentation/main.c
index 81a4918..b00f1e6 100644
--- a/examples/ip_fragmentation/main.c
+++ b/examples/ip_fragmentation/main.c
@@ -824,9 +824,7 @@ main(int argc, char **argv)
 		rte_exit(EXIT_FAILURE, "Invalid arguments");
 
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
-	else if (nb_ports == 0)
+	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No ports found!\n");
 
 	nb_lcores = rte_lcore_count();
diff --git a/examples/ip_reassembly/main.c b/examples/ip_reassembly/main.c
index c27e735..a8aabdc 100644
--- a/examples/ip_reassembly/main.c
+++ b/examples/ip_reassembly/main.c
@@ -1040,9 +1040,7 @@ main(int argc, char **argv)
 		rte_exit(EXIT_FAILURE, "Invalid IP reassembly parameters\n");
 
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
-	else if (nb_ports == 0)
+	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No ports found!\n");
 
 	nb_lcores = rte_lcore_count();
diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
index 00ab2d8..1dc505c 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -636,8 +636,6 @@ check_params(void)
 	}
 
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	for (i = 0; i < nb_lcore_params; ++i) {
 		lcore = lcore_params[i].lcore_id;
@@ -1286,8 +1284,6 @@ main(int32_t argc, char **argv)
 				unprotected_port_mask);
 
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	if (check_params() < 0)
 		rte_exit(EXIT_FAILURE, "check_params failed\n");
diff --git a/examples/kni/main.c b/examples/kni/main.c
index a5297f2..ee8342f 100644
--- a/examples/kni/main.c
+++ b/examples/kni/main.c
@@ -318,8 +318,6 @@ main_loop(__rte_unused void *arg)
 	};
 	enum lcore_rxtx flag = LCORE_NONE;
 
-	nb_ports = (uint8_t)(nb_ports < RTE_MAX_ETHPORTS ?
-				nb_ports : RTE_MAX_ETHPORTS);
 	for (i = 0; i < nb_ports; i++) {
 		if (!kni_port_params_array[i])
 			continue;
diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index d4e2d8d..d18c813 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -1785,9 +1785,6 @@ initialize_ports(struct l2fwd_crypto_options *options)
 		return -1;
 	}
 
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
-
 	/* Reset l2fwd_dst_ports */
 	for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++)
 		l2fwd_dst_ports[portid] = 0;
diff --git a/examples/l2fwd-ivshmem/host/host.c b/examples/l2fwd-ivshmem/host/host.c
index 4bd7c41..cd284b7 100644
--- a/examples/l2fwd-ivshmem/host/host.c
+++ b/examples/l2fwd-ivshmem/host/host.c
@@ -677,9 +677,6 @@ int main(int argc, char **argv)
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
 
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
-
 	/*
 	 * reserve memzone to communicate with VMs - we cannot use rte_malloc here
 	 * because while it is technically possible, it is a very bad idea to share
diff --git a/examples/l2fwd-jobstats/main.c b/examples/l2fwd-jobstats/main.c
index 9f3a77d..c193840 100644
--- a/examples/l2fwd-jobstats/main.c
+++ b/examples/l2fwd-jobstats/main.c
@@ -811,9 +811,6 @@ main(int argc, char **argv)
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
 
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
-
 	/* reset l2fwd_dst_ports */
 	for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++)
 		l2fwd_dst_ports[portid] = 0;
diff --git a/examples/l2fwd-keepalive/main.c b/examples/l2fwd-keepalive/main.c
index 8da89aa..4a0d9b6 100644
--- a/examples/l2fwd-keepalive/main.c
+++ b/examples/l2fwd-keepalive/main.c
@@ -570,9 +570,6 @@ main(int argc, char **argv)
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
 
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
-
 	/* reset l2fwd_dst_ports */
 	for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++)
 		l2fwd_dst_ports[portid] = 0;
diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c
index 1ad9488..c093d4d 100644
--- a/examples/l2fwd/main.c
+++ b/examples/l2fwd/main.c
@@ -551,9 +551,6 @@ main(int argc, char **argv)
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
 
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
-
 	/* reset l2fwd_dst_ports */
 	for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++)
 		l2fwd_dst_ports[portid] = 0;
diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c
index 26d9f5e..dbf4c1e 100644
--- a/examples/l3fwd-acl/main.c
+++ b/examples/l3fwd-acl/main.c
@@ -1914,8 +1914,6 @@ main(int argc, char **argv)
 		rte_exit(EXIT_FAILURE, "init_lcore_rx_queues failed\n");
 
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	if (check_port_config(nb_ports) < 0)
 		rte_exit(EXIT_FAILURE, "check_port_config failed\n");
diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index cb42bfb..f746960 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -1572,10 +1572,7 @@ main(int argc, char **argv)
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "init_lcore_rx_queues failed\n");
 
-
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	if (check_port_config(nb_ports) < 0)
 		rte_exit(EXIT_FAILURE, "check_port_config failed\n");
diff --git a/examples/l3fwd-vf/main.c b/examples/l3fwd-vf/main.c
index 034c22a..ca01b11 100644
--- a/examples/l3fwd-vf/main.c
+++ b/examples/l3fwd-vf/main.c
@@ -982,8 +982,6 @@ main(int argc, char **argv)
 		rte_exit(EXIT_FAILURE, "init_lcore_rx_queues failed\n");
 
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	if (check_port_config(nb_ports) < 0)
 		rte_exit(EXIT_FAILURE, "check_port_config failed\n");
diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
index bf6d885..7a79cd2 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -868,8 +868,6 @@ main(int argc, char **argv)
 		rte_exit(EXIT_FAILURE, "init_lcore_rx_queues failed\n");
 
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	if (check_port_config(nb_ports) < 0)
 		rte_exit(EXIT_FAILURE, "check_port_config failed\n");
diff --git a/examples/link_status_interrupt/main.c b/examples/link_status_interrupt/main.c
index 9981598..04dc3e4 100644
--- a/examples/link_status_interrupt/main.c
+++ b/examples/link_status_interrupt/main.c
@@ -580,9 +580,6 @@ main(int argc, char **argv)
 	if (nb_ports == 0)
 		rte_panic("No Ethernet port - bye\n");
 
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
-
 	/*
 	 * Each logical core is assigned a dedicated TX queue on each port.
 	 */
diff --git a/examples/multi_process/l2fwd_fork/main.c b/examples/multi_process/l2fwd_fork/main.c
index 2dc8b82..368b309 100644
--- a/examples/multi_process/l2fwd_fork/main.c
+++ b/examples/multi_process/l2fwd_fork/main.c
@@ -979,9 +979,6 @@ main(int argc, char **argv)
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
 
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
-
 	/* create the mbuf pool */
 	for (portid = 0; portid < nb_ports; portid++) {
 		/* skip ports that are not enabled */
diff --git a/examples/performance-thread/l3fwd-thread/main.c b/examples/performance-thread/l3fwd-thread/main.c
index 4ad16ea..400daed 100644
--- a/examples/performance-thread/l3fwd-thread/main.c
+++ b/examples/performance-thread/l3fwd-thread/main.c
@@ -3482,8 +3482,6 @@ main(int argc, char **argv)
 		rte_exit(EXIT_FAILURE, "init_rx_rings failed\n");
 
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	if (check_port_config(nb_ports) < 0)
 		rte_exit(EXIT_FAILURE, "check_port_config failed\n");
diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c
index f97d552..887cb26 100644
--- a/examples/tep_termination/main.c
+++ b/examples/tep_termination/main.c
@@ -1190,8 +1190,6 @@ main(int argc, char *argv[])
 
 	/* Get the number of physical ports. */
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	/*
 	 * Update the global var NB_PORTS and global array PORTS
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 28c17af..b22138f 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -2992,8 +2992,6 @@ main(int argc, char *argv[])
 
 	/* Get the number of physical ports. */
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	/*
 	 * Update the global var NUM_PORTS and global array PORTS
diff --git a/examples/vhost_xen/main.c b/examples/vhost_xen/main.c
index d83138d..2d69849 100644
--- a/examples/vhost_xen/main.c
+++ b/examples/vhost_xen/main.c
@@ -1460,8 +1460,6 @@ main(int argc, char *argv[])
 
 	/* Get the number of physical ports. */
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	/*
 	 * Update the global var NUM_PORTS and global array PORTS
diff --git a/examples/vmdq/main.c b/examples/vmdq/main.c
index 178af2f..360492b 100644
--- a/examples/vmdq/main.c
+++ b/examples/vmdq/main.c
@@ -599,8 +599,6 @@ main(int argc, char *argv[])
 		rte_exit(EXIT_FAILURE, "Not enough cores\n");
 
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	/*
 	 * Update the global var NUM_PORTS and global array PORTS
diff --git a/examples/vmdq_dcb/main.c b/examples/vmdq_dcb/main.c
index 62e1422..617263b 100644
--- a/examples/vmdq_dcb/main.c
+++ b/examples/vmdq_dcb/main.c
@@ -662,8 +662,6 @@ main(int argc, char *argv[])
 	}
 
 	nb_ports = rte_eth_dev_count();
-	if (nb_ports > RTE_MAX_ETHPORTS)
-		nb_ports = RTE_MAX_ETHPORTS;
 
 	/*
 	 * Update the global var NUM_PORTS and global array PORTS
-- 
1.9.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH v2] examples: remove useless checking
  2016-05-03 21:16 ` [dpdk-dev] [PATCH v2] " Mauricio Vasquez B
@ 2016-05-04  8:04   ` Ferruh Yigit
  2016-05-16 19:02     ` Thomas Monjalon
  0 siblings, 1 reply; 5+ messages in thread
From: Ferruh Yigit @ 2016-05-04  8:04 UTC (permalink / raw)
  To: Mauricio Vasquez B, dev

On 5/3/2016 10:16 PM, Mauricio Vasquez B wrote:
> The rte_eth_dev_count() function will never return a value greater
> than RTE_MAX_ETHPORTS, so that checking is useless.
> 
> Signed-off-by: Mauricio Vasquez B <mauricio.vasquezbernal@studenti.polito.it>
> ---
> v2:
>  Add missed case in examples/kni/main.c

Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH v2] examples: remove useless checking
  2016-05-04  8:04   ` Ferruh Yigit
@ 2016-05-16 19:02     ` Thomas Monjalon
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Monjalon @ 2016-05-16 19:02 UTC (permalink / raw)
  To: Mauricio Vasquez B; +Cc: dev, Ferruh Yigit

> > The rte_eth_dev_count() function will never return a value greater
> > than RTE_MAX_ETHPORTS, so that checking is useless.
> > 
> > Signed-off-by: Mauricio Vasquez B <mauricio.vasquezbernal@studenti.polito.it>
> 
> Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-05-16 19:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-29 15:48 [dpdk-dev] [PATCH] examples: remove useless checking Mauricio Vasquez B
2016-05-03 14:39 ` Ferruh Yigit
2016-05-03 21:16 ` [dpdk-dev] [PATCH v2] " Mauricio Vasquez B
2016-05-04  8:04   ` Ferruh Yigit
2016-05-16 19:02     ` Thomas Monjalon

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).