[dpdk-dev] [PATCH v2 07/10] sched: cleanup defined constants

Stephen Hemminger stephen at networkplumber.org
Fri Nov 13 18:58:33 CET 2015


From: Stephen Hemminger <shemming at brocade.com>

Only use RTE_SCHED_PORT_N_GRINDERS from config.
Use RTE_BUILD_BUG_ON for errors.
The remaining implementation constants can be put together.

Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
 lib/librte_sched/rte_sched.c | 22 ++++------------------
 1 file changed, 4 insertions(+), 18 deletions(-)

diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c
index 1f8d3f8..a98c757 100644
--- a/lib/librte_sched/rte_sched.c
+++ b/lib/librte_sched/rte_sched.c
@@ -60,28 +60,10 @@
 #include <immintrin.h>
 #endif
 
-#ifndef RTE_SCHED_TB_RATE_CONFIG_ERR
 #define RTE_SCHED_TB_RATE_CONFIG_ERR          (1e-7)
-#endif
-
-#ifndef RTE_SCHED_WRR_SHIFT
 #define RTE_SCHED_WRR_SHIFT                   3
-#endif
-
-#ifndef RTE_SCHED_PORT_N_GRINDERS
-#define RTE_SCHED_PORT_N_GRINDERS             8
-#endif
-#if (RTE_SCHED_PORT_N_GRINDERS == 0) || (RTE_SCHED_PORT_N_GRINDERS & (RTE_SCHED_PORT_N_GRINDERS - 1))
-#error Number of grinders must be non-zero and a power of 2
-#endif
-#if (RTE_SCHED_OPTIMIZATIONS && (RTE_SCHED_PORT_N_GRINDERS != 8))
-#error Number of grinders must be 8 when RTE_SCHED_OPTIMIZATIONS is set
-#endif
-
 #define RTE_SCHED_GRINDER_PCACHE_SIZE         (64 / RTE_SCHED_QUEUES_PER_PIPE)
-
 #define RTE_SCHED_PIPE_INVALID                UINT32_MAX
-
 #define RTE_SCHED_BMP_POS_INVALID             UINT32_MAX
 
 struct rte_sched_subport {
@@ -621,6 +603,10 @@ rte_sched_port_config(struct rte_sched_port_params *params)
 		return NULL;
 	}
 
+	/* compile time checks */
+	RTE_BUILD_BUG_ON(RTE_SCHED_PORT_N_GRINDERS == 0);
+	RTE_BUILD_BUG_ON(RTE_SCHED_PORT_N_GRINDERS & (RTE_SCHED_PORT_N_GRINDERS - 1));
+
 	/* User parameters */
 	port->n_subports_per_port = params->n_subports_per_port;
 	port->n_pipes_per_subport = params->n_pipes_per_subport;
-- 
2.1.4



More information about the dev mailing list