DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/2] sched: add support for 64 bit values
@ 2019-10-14 17:24 Jasvinder Singh
  2019-10-14 17:24 ` [dpdk-dev] [PATCH 2/2] sched: modify internal structs and functions " Jasvinder Singh
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Jasvinder Singh @ 2019-10-14 17:24 UTC (permalink / raw)
  To: dev; +Cc: cristian.dumitrescu, Lukasz Krakowiak

To support high bandwidth NICs, all rates (port, subport level
token bucket and traffic class rates, pipe level token bucket
and traffic class rates) and stats counters defined in public
data structures (rte_sched.h) are modified to support 64-bit
values.

Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
---
 examples/ip_pipeline/cli.c    | 18 +++++-----
 examples/ip_pipeline/tmgr.h   |  2 +-
 examples/qos_sched/cfg_file.c | 64 +++++++++++++++++------------------
 examples/qos_sched/stats.c    |  6 ++--
 lib/librte_sched/rte_sched.h  | 38 ++++++++++-----------
 5 files changed, 64 insertions(+), 64 deletions(-)

diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c
index c72030682..3e23f4e7b 100644
--- a/examples/ip_pipeline/cli.c
+++ b/examples/ip_pipeline/cli.c
@@ -414,23 +414,23 @@ cmd_tmgr_subport_profile(char **tokens,
 		return;
 	}
 
-	if (parser_read_uint32(&p.tb_rate, tokens[3]) != 0) {
+	if (parser_read_uint64(&p.tb_rate, tokens[3]) != 0) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "tb_rate");
 		return;
 	}
 
-	if (parser_read_uint32(&p.tb_size, tokens[4]) != 0) {
+	if (parser_read_uint64(&p.tb_size, tokens[4]) != 0) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "tb_size");
 		return;
 	}
 
 	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
-		if (parser_read_uint32(&p.tc_rate[i], tokens[5 + i]) != 0) {
+		if (parser_read_uint64(&p.tc_rate[i], tokens[5 + i]) != 0) {
 			snprintf(out, out_size, MSG_ARG_INVALID, "tc_rate");
 			return;
 		}
 
-	if (parser_read_uint32(&p.tc_period, tokens[18]) != 0) {
+	if (parser_read_uint64(&p.tc_period, tokens[18]) != 0) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "tc_period");
 		return;
 	}
@@ -487,23 +487,23 @@ cmd_tmgr_pipe_profile(char **tokens,
 		return;
 	}
 
-	if (parser_read_uint32(&p.tb_rate, tokens[3]) != 0) {
+	if (parser_read_uint64(&p.tb_rate, tokens[3]) != 0) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "tb_rate");
 		return;
 	}
 
-	if (parser_read_uint32(&p.tb_size, tokens[4]) != 0) {
+	if (parser_read_uint64(&p.tb_size, tokens[4]) != 0) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "tb_size");
 		return;
 	}
 
 	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
-		if (parser_read_uint32(&p.tc_rate[i], tokens[5 + i]) != 0) {
+		if (parser_read_uint64(&p.tc_rate[i], tokens[5 + i]) != 0) {
 			snprintf(out, out_size, MSG_ARG_INVALID, "tc_rate");
 			return;
 		}
 
-	if (parser_read_uint32(&p.tc_period, tokens[18]) != 0) {
+	if (parser_read_uint64(&p.tc_period, tokens[18]) != 0) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "tc_period");
 		return;
 	}
@@ -556,7 +556,7 @@ cmd_tmgr(char **tokens,
 		return;
 	}
 
-	if (parser_read_uint32(&p.rate, tokens[3]) != 0) {
+	if (parser_read_uint64(&p.rate, tokens[3]) != 0) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "rate");
 		return;
 	}
diff --git a/examples/ip_pipeline/tmgr.h b/examples/ip_pipeline/tmgr.h
index 1fcf66ee1..ee50cf7cc 100644
--- a/examples/ip_pipeline/tmgr.h
+++ b/examples/ip_pipeline/tmgr.h
@@ -40,7 +40,7 @@ struct tmgr_port *
 tmgr_port_find(const char *name);
 
 struct tmgr_port_params {
-	uint32_t rate;
+	uint64_t rate;
 	uint32_t n_subports_per_port;
 	uint32_t frame_overhead;
 	uint32_t mtu;
diff --git a/examples/qos_sched/cfg_file.c b/examples/qos_sched/cfg_file.c
index c6d3f5ab6..5714c3f36 100644
--- a/examples/qos_sched/cfg_file.c
+++ b/examples/qos_sched/cfg_file.c
@@ -59,67 +59,67 @@ cfg_load_pipe(struct rte_cfgfile *cfg, struct rte_sched_pipe_params *pipe_params
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tb rate");
 		if (entry)
-			pipe_params[j].tb_rate = (uint32_t)atoi(entry);
+			pipe_params[j].tb_rate = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tb size");
 		if (entry)
-			pipe_params[j].tb_size = (uint32_t)atoi(entry);
+			pipe_params[j].tb_size = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc period");
 		if (entry)
-			pipe_params[j].tc_period = (uint32_t)atoi(entry);
+			pipe_params[j].tc_period = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 0 rate");
 		if (entry)
-			pipe_params[j].tc_rate[0] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[0] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 1 rate");
 		if (entry)
-			pipe_params[j].tc_rate[1] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[1] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 2 rate");
 		if (entry)
-			pipe_params[j].tc_rate[2] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[2] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 3 rate");
 		if (entry)
-			pipe_params[j].tc_rate[3] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[3] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 4 rate");
 		if (entry)
-			pipe_params[j].tc_rate[4] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[4] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 5 rate");
 		if (entry)
-			pipe_params[j].tc_rate[5] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[5] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 6 rate");
 		if (entry)
-			pipe_params[j].tc_rate[6] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[6] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 7 rate");
 		if (entry)
-			pipe_params[j].tc_rate[7] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[7] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 8 rate");
 		if (entry)
-			pipe_params[j].tc_rate[8] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[8] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 9 rate");
 		if (entry)
-			pipe_params[j].tc_rate[9] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[9] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 10 rate");
 		if (entry)
-			pipe_params[j].tc_rate[10] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[10] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 11 rate");
 		if (entry)
-			pipe_params[j].tc_rate[11] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[11] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 12 rate");
 		if (entry)
-			pipe_params[j].tc_rate[12] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[12] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 12 oversubscription weight");
 		if (entry)
@@ -266,67 +266,67 @@ cfg_load_subport(struct rte_cfgfile *cfg, struct rte_sched_subport_params *subpo
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tb rate");
 			if (entry)
-				subport_params[i].tb_rate = (uint32_t)atoi(entry);
+				subport_params[i].tb_rate = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tb size");
 			if (entry)
-				subport_params[i].tb_size = (uint32_t)atoi(entry);
+				subport_params[i].tb_size = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc period");
 			if (entry)
-				subport_params[i].tc_period = (uint32_t)atoi(entry);
+				subport_params[i].tc_period = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 0 rate");
 			if (entry)
-				subport_params[i].tc_rate[0] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[0] = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 1 rate");
 			if (entry)
-				subport_params[i].tc_rate[1] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[1] = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 2 rate");
 			if (entry)
-				subport_params[i].tc_rate[2] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[2] = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 3 rate");
 			if (entry)
-				subport_params[i].tc_rate[3] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[3] = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 4 rate");
 			if (entry)
-				subport_params[i].tc_rate[4] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[4] = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 5 rate");
 			if (entry)
-				subport_params[i].tc_rate[5] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[5] = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 6 rate");
 			if (entry)
-				subport_params[i].tc_rate[6] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[6] = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 7 rate");
 			if (entry)
-				subport_params[i].tc_rate[7] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[7] = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 8 rate");
 			if (entry)
-				subport_params[i].tc_rate[8] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[8] = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 9 rate");
 			if (entry)
-				subport_params[i].tc_rate[9] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[9] = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 10 rate");
 			if (entry)
-				subport_params[i].tc_rate[10] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[10] = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 11 rate");
 			if (entry)
-				subport_params[i].tc_rate[11] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[11] = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 12 rate");
 			if (entry)
-				subport_params[i].tc_rate[12] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[12] = (uint64_t)atoi(entry);
 
 			int n_entries = rte_cfgfile_section_num_entries(cfg, sec_name);
 			struct rte_cfgfile_entry entries[n_entries];
diff --git a/examples/qos_sched/stats.c b/examples/qos_sched/stats.c
index ce34b6c7c..161f086f1 100644
--- a/examples/qos_sched/stats.c
+++ b/examples/qos_sched/stats.c
@@ -307,7 +307,7 @@ subport_stat(uint16_t port_id, uint32_t subport_id)
 	printf("+----+-------------+-------------+-------------+-------------+-------------+\n");
 
 	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
-		printf("|  %d | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " |\n",
+		printf("|  %d | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu32 " |\n",
 			i, stats.n_pkts_tc[i], stats.n_pkts_tc_dropped[i],
 		stats.n_bytes_tc[i], stats.n_bytes_tc_dropped[i], tc_ov[i]);
 		printf("+----+-------------+-------------+-------------+-------------+-------------+\n");
@@ -351,7 +351,7 @@ pipe_stat(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id)
 	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
 		if (i < RTE_SCHED_TRAFFIC_CLASS_BE) {
 			rte_sched_queue_read_stats(port, queue_id + i, &stats, &qlen);
-			printf("|  %d |   %d   | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " | %11i |\n",
+			printf("|  %d |   %d   | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu64 " | %11i |\n",
 				i, 0, stats.n_pkts, stats.n_pkts_dropped, stats.n_bytes,
 				stats.n_bytes_dropped, qlen);
 			printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");
@@ -359,7 +359,7 @@ pipe_stat(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id)
 			for (j = 0; j < RTE_SCHED_BE_QUEUES_PER_PIPE; j++) {
 				rte_sched_queue_read_stats(port, queue_id + i + j,
 					&stats, &qlen);
-				printf("|  %d |   %d   | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " | %11i |\n",
+				printf("|  %d |   %d   | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu64 " | %11i |\n",
 					i, j, stats.n_pkts, stats.n_pkts_dropped, stats.n_bytes,
 					stats.n_bytes_dropped, qlen);
 				printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");
diff --git a/lib/librte_sched/rte_sched.h b/lib/librte_sched/rte_sched.h
index c82c23c14..8a5a93c98 100644
--- a/lib/librte_sched/rte_sched.h
+++ b/lib/librte_sched/rte_sched.h
@@ -121,16 +121,16 @@ extern "C" {
  */
 struct rte_sched_pipe_params {
 	/** Token bucket rate (measured in bytes per second) */
-	uint32_t tb_rate;
+	uint64_t tb_rate;
 
 	/** Token bucket size (measured in credits) */
-	uint32_t tb_size;
+	uint64_t tb_size;
 
 	/** Traffic class rates (measured in bytes per second) */
-	uint32_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 
 	/** Enforcement period (measured in milliseconds) */
-	uint32_t tc_period;
+	uint64_t tc_period;
 
 	/** Best-effort traffic class oversubscription weight */
 	uint8_t tc_ov_weight;
@@ -150,16 +150,16 @@ struct rte_sched_pipe_params {
  */
 struct rte_sched_subport_params {
 	/** Token bucket rate (measured in bytes per second) */
-	uint32_t tb_rate;
+	uint64_t tb_rate;
 
 	/** Token bucket size (measured in credits) */
-	uint32_t tb_size;
+	uint64_t tb_size;
 
 	/** Traffic class rates (measured in bytes per second) */
-	uint32_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 
 	/** Enforcement period for rates (measured in milliseconds) */
-	uint32_t tc_period;
+	uint64_t tc_period;
 
 	/** Number of subport pipes.
 	 * The subport can enable/allocate fewer pipes than the maximum
@@ -195,41 +195,41 @@ struct rte_sched_subport_params {
 /** Subport statistics */
 struct rte_sched_subport_stats {
 	/** Number of packets successfully written */
-	uint32_t n_pkts_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	uint64_t n_pkts_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 
 	/** Number of packets dropped */
-	uint32_t n_pkts_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	uint64_t n_pkts_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 
 	/** Number of bytes successfully written for each traffic class */
-	uint32_t n_bytes_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	uint64_t n_bytes_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 
 	/** Number of bytes dropped for each traffic class */
-	uint32_t n_bytes_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	uint64_t n_bytes_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 
 #ifdef RTE_SCHED_RED
 	/** Number of packets dropped by red */
-	uint32_t n_pkts_red_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	uint64_t n_pkts_red_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 #endif
 };
 
 /** Queue statistics */
 struct rte_sched_queue_stats {
 	/** Packets successfully written */
-	uint32_t n_pkts;
+	uint64_t n_pkts;
 
 	/** Packets dropped */
-	uint32_t n_pkts_dropped;
+	uint64_t n_pkts_dropped;
 
 #ifdef RTE_SCHED_RED
 	/** Packets dropped by RED */
-	uint32_t n_pkts_red_dropped;
+	uint64_t n_pkts_red_dropped;
 #endif
 
 	/** Bytes successfully written */
-	uint32_t n_bytes;
+	uint64_t n_bytes;
 
 	/** Bytes dropped */
-	uint32_t n_bytes_dropped;
+	uint64_t n_bytes_dropped;
 };
 
 /** Port configuration parameters. */
@@ -241,7 +241,7 @@ struct rte_sched_port_params {
 	int socket;
 
 	/** Output port rate (measured in bytes per second) */
-	uint32_t rate;
+	uint64_t rate;
 
 	/** Maximum Ethernet frame size (measured in bytes).
 	 * Should not include the framing overhead.
-- 
2.21.0


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

* [dpdk-dev] [PATCH 2/2] sched: modify internal structs and functions for 64 bit values
  2019-10-14 17:24 [dpdk-dev] [PATCH 1/2] sched: add support for 64 bit values Jasvinder Singh
@ 2019-10-14 17:24 ` Jasvinder Singh
  2019-10-15 15:47   ` Dumitrescu, Cristian
  2019-10-15 15:27 ` [dpdk-dev] [PATCH 1/2] sched: add support " Dumitrescu, Cristian
  2019-10-16 14:17 ` [dpdk-dev] [PATCH v2 " Jasvinder Singh
  2 siblings, 1 reply; 9+ messages in thread
From: Jasvinder Singh @ 2019-10-14 17:24 UTC (permalink / raw)
  To: dev; +Cc: cristian.dumitrescu, Lukasz Krakowiak

Modify internal structure and functions to support 64-bit
values for rates and stats parameters.

Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
---
 lib/librte_sched/rte_approx.c       |  57 ++++----
 lib/librte_sched/rte_approx.h       |   3 +-
 lib/librte_sched/rte_sched.c        | 211 +++++++++++++++-------------
 lib/librte_sched/rte_sched_common.h |  12 +-
 4 files changed, 156 insertions(+), 127 deletions(-)

diff --git a/lib/librte_sched/rte_approx.c b/lib/librte_sched/rte_approx.c
index 30620b83d..4883d3969 100644
--- a/lib/librte_sched/rte_approx.c
+++ b/lib/librte_sched/rte_approx.c
@@ -18,22 +18,23 @@
  */
 
 /* fraction comparison: compare (a/b) and (c/d) */
-static inline uint32_t
-less(uint32_t a, uint32_t b, uint32_t c, uint32_t d)
+static inline sched_counter_t
+less(sched_counter_t a, sched_counter_t b, sched_counter_t c, sched_counter_t d)
 {
 	return a*d < b*c;
 }
 
-static inline uint32_t
-less_or_equal(uint32_t a, uint32_t b, uint32_t c, uint32_t d)
+static inline sched_counter_t
+less_or_equal(sched_counter_t a, sched_counter_t b, sched_counter_t c,
+	sched_counter_t d)
 {
 	return a*d <= b*c;
 }
 
 /* check whether a/b is a valid approximation */
-static inline uint32_t
-matches(uint32_t a, uint32_t b,
-	uint32_t alpha_num, uint32_t d_num, uint32_t denum)
+static inline sched_counter_t
+matches(sched_counter_t a, sched_counter_t b,
+	sched_counter_t alpha_num, sched_counter_t d_num, sched_counter_t denum)
 {
 	if (less_or_equal(a, b, alpha_num - d_num, denum))
 		return 0;
@@ -45,33 +46,39 @@ matches(uint32_t a, uint32_t b,
 }
 
 static inline void
-find_exact_solution_left(uint32_t p_a, uint32_t q_a, uint32_t p_b, uint32_t q_b,
-	uint32_t alpha_num, uint32_t d_num, uint32_t denum, uint32_t *p, uint32_t *q)
+find_exact_solution_left(sched_counter_t p_a, sched_counter_t q_a,
+	sched_counter_t p_b, sched_counter_t q_b, sched_counter_t alpha_num,
+	sched_counter_t d_num, sched_counter_t denum, sched_counter_t *p,
+	sched_counter_t *q)
 {
-	uint32_t k_num = denum * p_b - (alpha_num + d_num) * q_b;
-	uint32_t k_denum = (alpha_num + d_num) * q_a - denum * p_a;
-	uint32_t k = (k_num / k_denum) + 1;
+	sched_counter_t k_num = denum * p_b - (alpha_num + d_num) * q_b;
+	sched_counter_t k_denum = (alpha_num + d_num) * q_a - denum * p_a;
+	sched_counter_t k = (k_num / k_denum) + 1;
 
 	*p = p_b + k * p_a;
 	*q = q_b + k * q_a;
 }
 
 static inline void
-find_exact_solution_right(uint32_t p_a, uint32_t q_a, uint32_t p_b, uint32_t q_b,
-	uint32_t alpha_num, uint32_t d_num, uint32_t denum, uint32_t *p, uint32_t *q)
+find_exact_solution_right(sched_counter_t p_a, sched_counter_t q_a,
+	sched_counter_t p_b, sched_counter_t q_b, sched_counter_t alpha_num,
+	sched_counter_t d_num, sched_counter_t denum, sched_counter_t *p,
+	sched_counter_t *q)
 {
-	uint32_t k_num = - denum * p_b + (alpha_num - d_num) * q_b;
-	uint32_t k_denum = - (alpha_num - d_num) * q_a + denum * p_a;
-	uint32_t k = (k_num / k_denum) + 1;
+	sched_counter_t k_num = -denum * p_b + (alpha_num - d_num) * q_b;
+	sched_counter_t k_denum = -(alpha_num - d_num) * q_a + denum * p_a;
+	sched_counter_t k = (k_num / k_denum) + 1;
 
 	*p = p_b + k * p_a;
 	*q = q_b + k * q_a;
 }
 
 static int
-find_best_rational_approximation(uint32_t alpha_num, uint32_t d_num, uint32_t denum, uint32_t *p, uint32_t *q)
+find_best_rational_approximation(sched_counter_t alpha_num,
+	sched_counter_t d_num, sched_counter_t denum, sched_counter_t *p,
+	sched_counter_t *q)
 {
-	uint32_t p_a, q_a, p_b, q_b;
+	sched_counter_t p_a, q_a, p_b, q_b;
 
 	/* check assumptions on the inputs */
 	if (!((0 < d_num) && (d_num < alpha_num) && (alpha_num < denum) && (d_num + alpha_num < denum))) {
@@ -85,8 +92,8 @@ find_best_rational_approximation(uint32_t alpha_num, uint32_t d_num, uint32_t de
 	q_b = 1;
 
 	while (1) {
-		uint32_t new_p_a, new_q_a, new_p_b, new_q_b;
-		uint32_t x_num, x_denum, x;
+		sched_counter_t new_p_a, new_q_a, new_p_b, new_q_b;
+		sched_counter_t x_num, x_denum, x;
 		int aa, bb;
 
 		/* compute the number of steps to the left */
@@ -139,9 +146,9 @@ find_best_rational_approximation(uint32_t alpha_num, uint32_t d_num, uint32_t de
 	}
 }
 
-int rte_approx(double alpha, double d, uint32_t *p, uint32_t *q)
+int rte_approx(double alpha, double d, sched_counter_t *p, sched_counter_t *q)
 {
-	uint32_t alpha_num, d_num, denum;
+	sched_counter_t alpha_num, d_num, denum;
 
 	/* Check input arguments */
 	if (!((0.0 < d) && (d < alpha) && (alpha < 1.0))) {
@@ -159,8 +166,8 @@ int rte_approx(double alpha, double d, uint32_t *p, uint32_t *q)
 		d *= 10;
 		denum *= 10;
 	}
-	alpha_num = (uint32_t) alpha;
-	d_num = (uint32_t) d;
+	alpha_num = (sched_counter_t) alpha;
+	d_num = (sched_counter_t) d;
 
 	/* Perform approximation */
 	return find_best_rational_approximation(alpha_num, d_num, denum, p, q);
diff --git a/lib/librte_sched/rte_approx.h b/lib/librte_sched/rte_approx.h
index 0244d98f1..e591e122d 100644
--- a/lib/librte_sched/rte_approx.h
+++ b/lib/librte_sched/rte_approx.h
@@ -20,6 +20,7 @@ extern "C" {
  ***/
 
 #include <stdint.h>
+#include "rte_sched_common.h"
 
 /**
  * Find best rational approximation
@@ -37,7 +38,7 @@ extern "C" {
  * @return
  *   0 upon success, error code otherwise
  */
-int rte_approx(double alpha, double d, uint32_t *p, uint32_t *q);
+int rte_approx(double alpha, double d, sched_counter_t *p, sched_counter_t *q);
 
 #ifdef __cplusplus
 }
diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c
index 710ecf65a..11d1febe2 100644
--- a/lib/librte_sched/rte_sched.c
+++ b/lib/librte_sched/rte_sched.c
@@ -49,13 +49,13 @@
 
 struct rte_sched_pipe_profile {
 	/* Token bucket (TB) */
-	uint32_t tb_period;
-	uint32_t tb_credits_per_period;
-	uint32_t tb_size;
+	sched_counter_t tb_period;
+	sched_counter_t tb_credits_per_period;
+	sched_counter_t tb_size;
 
 	/* Pipe traffic classes */
-	uint32_t tc_period;
-	uint32_t tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	sched_counter_t tc_period;
+	sched_counter_t tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 	uint8_t tc_ov_weight;
 
 	/* Pipe best-effort traffic class queues */
@@ -65,20 +65,20 @@ struct rte_sched_pipe_profile {
 struct rte_sched_pipe {
 	/* Token bucket (TB) */
 	uint64_t tb_time; /* time of last update */
-	uint32_t tb_credits;
+	sched_counter_t tb_credits;
 
 	/* Pipe profile and flags */
 	uint32_t profile;
 
 	/* Traffic classes (TCs) */
 	uint64_t tc_time; /* time of next update */
-	uint32_t tc_credits[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	sched_counter_t tc_credits[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 
 	/* Weighted Round Robin (WRR) */
 	uint8_t wrr_tokens[RTE_SCHED_BE_QUEUES_PER_PIPE];
 
 	/* TC oversubscription */
-	uint32_t tc_ov_credits;
+	sched_counter_t tc_ov_credits;
 	uint8_t tc_ov_period_id;
 } __rte_cache_aligned;
 
@@ -141,28 +141,28 @@ struct rte_sched_grinder {
 struct rte_sched_subport {
 	/* Token bucket (TB) */
 	uint64_t tb_time; /* time of last update */
-	uint32_t tb_period;
-	uint32_t tb_credits_per_period;
-	uint32_t tb_size;
-	uint32_t tb_credits;
+	sched_counter_t tb_period;
+	sched_counter_t tb_credits_per_period;
+	sched_counter_t tb_size;
+	sched_counter_t tb_credits;
 
 	/* Traffic classes (TCs) */
 	uint64_t tc_time; /* time of next update */
-	uint32_t tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
-	uint32_t tc_credits[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
-	uint32_t tc_period;
+	sched_counter_t tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	sched_counter_t tc_credits[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	sched_counter_t tc_period;
 
 	/* TC oversubscription */
-	uint32_t tc_ov_wm;
-	uint32_t tc_ov_wm_min;
-	uint32_t tc_ov_wm_max;
+	sched_counter_t tc_ov_wm;
+	sched_counter_t tc_ov_wm_min;
+	sched_counter_t tc_ov_wm_max;
 	uint8_t tc_ov_period_id;
 	uint8_t tc_ov;
 	uint32_t tc_ov_n;
 	double tc_ov_rate;
 
 	/* Statistics */
-	struct rte_sched_subport_stats stats;
+	struct rte_sched_subport_stats stats __rte_cache_aligned;
 
 	/* Subport pipes */
 	uint32_t n_pipes_per_subport_enabled;
@@ -170,7 +170,7 @@ struct rte_sched_subport {
 	uint32_t n_max_pipe_profiles;
 
 	/* Pipe best-effort TC rate */
-	uint32_t pipe_tc_be_rate_max;
+	sched_counter_t pipe_tc_be_rate_max;
 
 	/* Pipe queues size */
 	uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
@@ -212,7 +212,7 @@ struct rte_sched_port {
 	uint16_t pipe_queue[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 	uint8_t pipe_tc[RTE_SCHED_QUEUES_PER_PIPE];
 	uint8_t tc_queue[RTE_SCHED_QUEUES_PER_PIPE];
-	uint32_t rate;
+	sched_counter_t rate;
 	uint32_t mtu;
 	uint32_t frame_overhead;
 	int socket;
@@ -517,33 +517,35 @@ rte_sched_port_log_pipe_profile(struct rte_sched_subport *subport, uint32_t i)
 	struct rte_sched_pipe_profile *p = subport->pipe_profiles + i;
 
 	RTE_LOG(DEBUG, SCHED, "Low level config for pipe profile %u:\n"
-		"	Token bucket: period = %u, credits per period = %u, size = %u\n"
-		"	Traffic classes: period = %u,\n"
-		"	credits per period = [%u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u]\n"
+		"	Token bucket: period = %"PRIu64", credits per period = %"PRIu64", size = %"PRIu64"\n"
+		"	Traffic classes: period = %"PRIu64",\n"
+		"	credits per period = [%"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
+		", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
+		", %"PRIu64", %"PRIu64", %"PRIu64"]\n"
 		"	Best-effort traffic class oversubscription: weight = %hhu\n"
 		"	WRR cost: [%hhu, %hhu, %hhu, %hhu]\n",
 		i,
 
 		/* Token bucket */
-		p->tb_period,
-		p->tb_credits_per_period,
-		p->tb_size,
+		(uint64_t)p->tb_period,
+		(uint64_t)p->tb_credits_per_period,
+		(uint64_t)p->tb_size,
 
 		/* Traffic classes */
-		p->tc_period,
-		p->tc_credits_per_period[0],
-		p->tc_credits_per_period[1],
-		p->tc_credits_per_period[2],
-		p->tc_credits_per_period[3],
-		p->tc_credits_per_period[4],
-		p->tc_credits_per_period[5],
-		p->tc_credits_per_period[6],
-		p->tc_credits_per_period[7],
-		p->tc_credits_per_period[8],
-		p->tc_credits_per_period[9],
-		p->tc_credits_per_period[10],
-		p->tc_credits_per_period[11],
-		p->tc_credits_per_period[12],
+		(uint64_t)p->tc_period,
+		(uint64_t)p->tc_credits_per_period[0],
+		(uint64_t)p->tc_credits_per_period[1],
+		(uint64_t)p->tc_credits_per_period[2],
+		(uint64_t)p->tc_credits_per_period[3],
+		(uint64_t)p->tc_credits_per_period[4],
+		(uint64_t)p->tc_credits_per_period[5],
+		(uint64_t)p->tc_credits_per_period[6],
+		(uint64_t)p->tc_credits_per_period[7],
+		(uint64_t)p->tc_credits_per_period[8],
+		(uint64_t)p->tc_credits_per_period[9],
+		(uint64_t)p->tc_credits_per_period[10],
+		(uint64_t)p->tc_credits_per_period[11],
+		(uint64_t)p->tc_credits_per_period[12],
 
 		/* Best-effort traffic class oversubscription */
 		p->tc_ov_weight,
@@ -553,7 +555,7 @@ rte_sched_port_log_pipe_profile(struct rte_sched_subport *subport, uint32_t i)
 }
 
 static inline uint64_t
-rte_sched_time_ms_to_bytes(uint32_t time_ms, uint32_t rate)
+rte_sched_time_ms_to_bytes(sched_counter_t time_ms, sched_counter_t rate)
 {
 	uint64_t time = time_ms;
 
@@ -566,7 +568,7 @@ static void
 rte_sched_pipe_profile_convert(struct rte_sched_subport *subport,
 	struct rte_sched_pipe_params *src,
 	struct rte_sched_pipe_profile *dst,
-	uint32_t rate)
+	sched_counter_t rate)
 {
 	uint32_t wrr_cost[RTE_SCHED_BE_QUEUES_PER_PIPE];
 	uint32_t lcd1, lcd2, lcd;
@@ -581,8 +583,8 @@ rte_sched_pipe_profile_convert(struct rte_sched_subport *subport,
 				/ (double) rate;
 		double d = RTE_SCHED_TB_RATE_CONFIG_ERR;
 
-		rte_approx(tb_rate, d,
-			&dst->tb_credits_per_period, &dst->tb_period);
+		rte_approx(tb_rate, d, &dst->tb_credits_per_period,
+			&dst->tb_period);
 	}
 
 	dst->tb_size = src->tb_size;
@@ -594,8 +596,8 @@ rte_sched_pipe_profile_convert(struct rte_sched_subport *subport,
 	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
 		if (subport->qsize[i])
 			dst->tc_credits_per_period[i]
-				= rte_sched_time_ms_to_bytes(src->tc_period,
-					src->tc_rate[i]);
+				= (sched_counter_t) rte_sched_time_ms_to_bytes(
+					src->tc_period, src->tc_rate[i]);
 
 	dst->tc_ov_weight = src->tc_ov_weight;
 
@@ -637,7 +639,8 @@ rte_sched_subport_config_pipe_profile_table(struct rte_sched_subport *subport,
 	subport->pipe_tc_be_rate_max = 0;
 	for (i = 0; i < subport->n_pipe_profiles; i++) {
 		struct rte_sched_pipe_params *src = params->pipe_profiles + i;
-		uint32_t pipe_tc_be_rate = src->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE];
+		sched_counter_t pipe_tc_be_rate =
+			src->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE];
 
 		if (subport->pipe_tc_be_rate_max < pipe_tc_be_rate)
 			subport->pipe_tc_be_rate_max = pipe_tc_be_rate;
@@ -647,7 +650,7 @@ rte_sched_subport_config_pipe_profile_table(struct rte_sched_subport *subport,
 static int
 rte_sched_subport_check_params(struct rte_sched_subport_params *params,
 	uint32_t n_max_pipes_per_subport,
-	uint32_t rate)
+	sched_counter_t rate)
 {
 	uint32_t i;
 
@@ -684,7 +687,7 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params,
 	}
 
 	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
-		uint32_t tc_rate = params->tc_rate[i];
+		sched_counter_t tc_rate = params->tc_rate[i];
 		uint16_t qsize = params->qsize[i];
 
 		if ((qsize == 0 && tc_rate != 0) ||
@@ -910,36 +913,40 @@ rte_sched_port_log_subport_config(struct rte_sched_port *port, uint32_t i)
 	struct rte_sched_subport *s = port->subports[i];
 
 	RTE_LOG(DEBUG, SCHED, "Low level config for subport %u:\n"
-		"	Token bucket: period = %u, credits per period = %u, size = %u\n"
-		"	Traffic classes: period = %u\n"
-		"	credits per period = [%u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u]\n"
-		"	Best effort traffic class oversubscription: wm min = %u, wm max = %u\n",
+		"	Token bucket: period = %"PRIu64", credits per period = %"PRIu64
+		", size = %"PRIu64"\n"
+		"	Traffic classes: period = %"PRIu64"\n"
+		"	credits per period = [%"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
+		", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
+		", %"PRIu64", %"PRIu64", %"PRIu64"]\n"
+		"	Best effort traffic class oversubscription: wm min = %"PRIu64
+		", wm max = %"PRIu64"\n",
 		i,
 
 		/* Token bucket */
-		s->tb_period,
-		s->tb_credits_per_period,
-		s->tb_size,
+		(uint64_t)s->tb_period,
+		(uint64_t)s->tb_credits_per_period,
+		(uint64_t)s->tb_size,
 
 		/* Traffic classes */
-		s->tc_period,
-		s->tc_credits_per_period[0],
-		s->tc_credits_per_period[1],
-		s->tc_credits_per_period[2],
-		s->tc_credits_per_period[3],
-		s->tc_credits_per_period[4],
-		s->tc_credits_per_period[5],
-		s->tc_credits_per_period[6],
-		s->tc_credits_per_period[7],
-		s->tc_credits_per_period[8],
-		s->tc_credits_per_period[9],
-		s->tc_credits_per_period[10],
-		s->tc_credits_per_period[11],
-		s->tc_credits_per_period[12],
+		(uint64_t)s->tc_period,
+		(uint64_t)s->tc_credits_per_period[0],
+		(uint64_t)s->tc_credits_per_period[1],
+		(uint64_t)s->tc_credits_per_period[2],
+		(uint64_t)s->tc_credits_per_period[3],
+		(uint64_t)s->tc_credits_per_period[4],
+		(uint64_t)s->tc_credits_per_period[5],
+		(uint64_t)s->tc_credits_per_period[6],
+		(uint64_t)s->tc_credits_per_period[7],
+		(uint64_t)s->tc_credits_per_period[8],
+		(uint64_t)s->tc_credits_per_period[9],
+		(uint64_t)s->tc_credits_per_period[10],
+		(uint64_t)s->tc_credits_per_period[11],
+		(uint64_t)s->tc_credits_per_period[12],
 
 		/* Best effort traffic class oversubscription */
-		s->tc_ov_wm_min,
-		s->tc_ov_wm_max);
+		(uint64_t)s->tc_ov_wm_min,
+		(uint64_t)s->tc_ov_wm_max);
 }
 
 static void
@@ -1023,7 +1030,8 @@ rte_sched_subport_config(struct rte_sched_port *port,
 		double tb_rate = ((double) params->tb_rate) / ((double) port->rate);
 		double d = RTE_SCHED_TB_RATE_CONFIG_ERR;
 
-		rte_approx(tb_rate, d, &s->tb_credits_per_period, &s->tb_period);
+		rte_approx(tb_rate, d, &s->tb_credits_per_period,
+			&s->tb_period);
 	}
 
 	s->tb_size = params->tb_size;
@@ -1035,8 +1043,8 @@ rte_sched_subport_config(struct rte_sched_port *port,
 	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
 		if (params->qsize[i])
 			s->tc_credits_per_period[i]
-				= rte_sched_time_ms_to_bytes(params->tc_period,
-					params->tc_rate[i]);
+				= (sched_counter_t) rte_sched_time_ms_to_bytes(
+					params->tc_period, params->tc_rate[i]);
 	}
 	s->tc_time = port->time + s->tc_period;
 	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
@@ -1970,13 +1978,15 @@ grinder_credits_update(struct rte_sched_port *port,
 	/* Subport TB */
 	n_periods = (port->time - subport->tb_time) / subport->tb_period;
 	subport->tb_credits += n_periods * subport->tb_credits_per_period;
-	subport->tb_credits = rte_sched_min_val_2_u32(subport->tb_credits, subport->tb_size);
+	subport->tb_credits = rte_sched_min_val_2(subport->tb_credits,
+				subport->tb_size);
 	subport->tb_time += n_periods * subport->tb_period;
 
 	/* Pipe TB */
 	n_periods = (port->time - pipe->tb_time) / params->tb_period;
 	pipe->tb_credits += n_periods * params->tb_credits_per_period;
-	pipe->tb_credits = rte_sched_min_val_2_u32(pipe->tb_credits, params->tb_size);
+	pipe->tb_credits = rte_sched_min_val_2(pipe->tb_credits,
+				params->tb_size);
 	pipe->tb_time += n_periods * params->tb_period;
 
 	/* Subport TCs */
@@ -1998,13 +2008,13 @@ grinder_credits_update(struct rte_sched_port *port,
 
 #else
 
-static inline uint32_t
+static inline sched_counter_t
 grinder_tc_ov_credits_update(struct rte_sched_port *port,
 	struct rte_sched_subport *subport)
 {
-	uint32_t tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
-	uint32_t tc_consumption = 0, tc_ov_consumption_max;
-	uint32_t tc_ov_wm = subport->tc_ov_wm;
+	sched_counter_t tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	sched_counter_t tc_consumption = 0, tc_ov_consumption_max;
+	sched_counter_t tc_ov_wm = subport->tc_ov_wm;
 	uint32_t i;
 
 	if (subport->tc_ov == 0)
@@ -2053,13 +2063,15 @@ grinder_credits_update(struct rte_sched_port *port,
 	/* Subport TB */
 	n_periods = (port->time - subport->tb_time) / subport->tb_period;
 	subport->tb_credits += n_periods * subport->tb_credits_per_period;
-	subport->tb_credits = rte_sched_min_val_2_u32(subport->tb_credits, subport->tb_size);
+	subport->tb_credits = rte_sched_min_val_2(subport->tb_credits,
+				subport->tb_size);
 	subport->tb_time += n_periods * subport->tb_period;
 
 	/* Pipe TB */
 	n_periods = (port->time - pipe->tb_time) / params->tb_period;
 	pipe->tb_credits += n_periods * params->tb_credits_per_period;
-	pipe->tb_credits = rte_sched_min_val_2_u32(pipe->tb_credits, params->tb_size);
+	pipe->tb_credits = rte_sched_min_val_2(pipe->tb_credits,
+				params->tb_size);
 	pipe->tb_time += n_periods * params->tb_period;
 
 	/* Subport TCs */
@@ -2101,11 +2113,11 @@ grinder_credits_check(struct rte_sched_port *port,
 	struct rte_sched_pipe *pipe = grinder->pipe;
 	struct rte_mbuf *pkt = grinder->pkt;
 	uint32_t tc_index = grinder->tc_index;
-	uint32_t pkt_len = pkt->pkt_len + port->frame_overhead;
-	uint32_t subport_tb_credits = subport->tb_credits;
-	uint32_t subport_tc_credits = subport->tc_credits[tc_index];
-	uint32_t pipe_tb_credits = pipe->tb_credits;
-	uint32_t pipe_tc_credits = pipe->tc_credits[tc_index];
+	sched_counter_t pkt_len = pkt->pkt_len + port->frame_overhead;
+	sched_counter_t subport_tb_credits = subport->tb_credits;
+	sched_counter_t subport_tc_credits = subport->tc_credits[tc_index];
+	sched_counter_t pipe_tb_credits = pipe->tb_credits;
+	sched_counter_t pipe_tc_credits = pipe->tc_credits[tc_index];
 	int enough_credits;
 
 	/* Check queue credits */
@@ -2136,21 +2148,22 @@ grinder_credits_check(struct rte_sched_port *port,
 	struct rte_sched_pipe *pipe = grinder->pipe;
 	struct rte_mbuf *pkt = grinder->pkt;
 	uint32_t tc_index = grinder->tc_index;
-	uint32_t pkt_len = pkt->pkt_len + port->frame_overhead;
-	uint32_t subport_tb_credits = subport->tb_credits;
-	uint32_t subport_tc_credits = subport->tc_credits[tc_index];
-	uint32_t pipe_tb_credits = pipe->tb_credits;
-	uint32_t pipe_tc_credits = pipe->tc_credits[tc_index];
-	uint32_t pipe_tc_ov_mask1[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
-	uint32_t pipe_tc_ov_mask2[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE] = {0};
-	uint32_t pipe_tc_ov_credits, i;
+	sched_counter_t pkt_len = pkt->pkt_len + port->frame_overhead;
+	sched_counter_t subport_tb_credits = subport->tb_credits;
+	sched_counter_t subport_tc_credits = subport->tc_credits[tc_index];
+	sched_counter_t pipe_tb_credits = pipe->tb_credits;
+	sched_counter_t pipe_tc_credits = pipe->tc_credits[tc_index];
+	sched_counter_t pipe_tc_ov_mask1[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	sched_counter_t pipe_tc_ov_mask2[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE] = {0};
+	sched_counter_t pipe_tc_ov_credits;
+	uint32_t i;
 	int enough_credits;
 
 	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
-		pipe_tc_ov_mask1[i] = UINT32_MAX;
+		pipe_tc_ov_mask1[i] = ~0;
 
 	pipe_tc_ov_mask1[RTE_SCHED_TRAFFIC_CLASS_BE] = pipe->tc_ov_credits;
-	pipe_tc_ov_mask2[RTE_SCHED_TRAFFIC_CLASS_BE] = UINT32_MAX;
+	pipe_tc_ov_mask2[RTE_SCHED_TRAFFIC_CLASS_BE] = ~0;
 	pipe_tc_ov_credits = pipe_tc_ov_mask1[tc_index];
 
 	/* Check pipe and subport credits */
diff --git a/lib/librte_sched/rte_sched_common.h b/lib/librte_sched/rte_sched_common.h
index 8c191a9b8..06520a686 100644
--- a/lib/librte_sched/rte_sched_common.h
+++ b/lib/librte_sched/rte_sched_common.h
@@ -14,8 +14,16 @@ extern "C" {
 
 #define __rte_aligned_16 __attribute__((__aligned__(16)))
 
-static inline uint32_t
-rte_sched_min_val_2_u32(uint32_t x, uint32_t y)
+//#define COUNTER_SIZE_64
+
+#ifdef COUNTER_SIZE_64
+typedef uint64_t sched_counter_t;
+#else
+typedef uint32_t sched_counter_t;
+#endif
+
+static inline sched_counter_t
+rte_sched_min_val_2(sched_counter_t x, sched_counter_t y)
 {
 	return (x < y)? x : y;
 }
-- 
2.21.0


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

* Re: [dpdk-dev] [PATCH 1/2] sched: add support for 64 bit values
  2019-10-14 17:24 [dpdk-dev] [PATCH 1/2] sched: add support for 64 bit values Jasvinder Singh
  2019-10-14 17:24 ` [dpdk-dev] [PATCH 2/2] sched: modify internal structs and functions " Jasvinder Singh
@ 2019-10-15 15:27 ` Dumitrescu, Cristian
  2019-10-16 14:17 ` [dpdk-dev] [PATCH v2 " Jasvinder Singh
  2 siblings, 0 replies; 9+ messages in thread
From: Dumitrescu, Cristian @ 2019-10-15 15:27 UTC (permalink / raw)
  To: Singh, Jasvinder, dev; +Cc: Krakowiak, LukaszX



> -----Original Message-----
> From: Singh, Jasvinder
> Sent: Monday, October 14, 2019 6:25 PM
> To: dev@dpdk.org
> Cc: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>; Krakowiak,
> LukaszX <lukaszx.krakowiak@intel.com>
> Subject: [PATCH 1/2] sched: add support for 64 bit values
> 
> To support high bandwidth NICs, all rates (port, subport level
> token bucket and traffic class rates, pipe level token bucket
> and traffic class rates) and stats counters defined in public
> data structures (rte_sched.h) are modified to support 64-bit
> values.
> 
> Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
> Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
> ---
>  examples/ip_pipeline/cli.c    | 18 +++++-----
>  examples/ip_pipeline/tmgr.h   |  2 +-
>  examples/qos_sched/cfg_file.c | 64 +++++++++++++++++------------------
>  examples/qos_sched/stats.c    |  6 ++--
>  lib/librte_sched/rte_sched.h  | 38 ++++++++++-----------
>  5 files changed, 64 insertions(+), 64 deletions(-)
> 

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>


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

* Re: [dpdk-dev] [PATCH 2/2] sched: modify internal structs and functions for 64 bit values
  2019-10-14 17:24 ` [dpdk-dev] [PATCH 2/2] sched: modify internal structs and functions " Jasvinder Singh
@ 2019-10-15 15:47   ` Dumitrescu, Cristian
  2019-10-15 16:01     ` Singh, Jasvinder
  0 siblings, 1 reply; 9+ messages in thread
From: Dumitrescu, Cristian @ 2019-10-15 15:47 UTC (permalink / raw)
  To: Singh, Jasvinder, dev; +Cc: Krakowiak, LukaszX

Hi Jasvinder,

> -----Original Message-----
> From: Singh, Jasvinder
> Sent: Monday, October 14, 2019 6:25 PM
> To: dev@dpdk.org
> Cc: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>; Krakowiak,
> LukaszX <lukaszx.krakowiak@intel.com>
> Subject: [PATCH 2/2] sched: modify internal structs and functions for 64 bit
> values
> 
> Modify internal structure and functions to support 64-bit
> values for rates and stats parameters.
> 
> Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
> Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
> ---
>  lib/librte_sched/rte_approx.c       |  57 ++++----
>  lib/librte_sched/rte_approx.h       |   3 +-
>  lib/librte_sched/rte_sched.c        | 211 +++++++++++++++-------------
>  lib/librte_sched/rte_sched_common.h |  12 +-
>  4 files changed, 156 insertions(+), 127 deletions(-)
> 
> diff --git a/lib/librte_sched/rte_approx.c b/lib/librte_sched/rte_approx.c
> index 30620b83d..4883d3969 100644
> --- a/lib/librte_sched/rte_approx.c
> +++ b/lib/librte_sched/rte_approx.c
> @@ -18,22 +18,23 @@
>   */
> 
>  /* fraction comparison: compare (a/b) and (c/d) */
> -static inline uint32_t
> -less(uint32_t a, uint32_t b, uint32_t c, uint32_t d)
> +static inline sched_counter_t
> +less(sched_counter_t a, sched_counter_t b, sched_counter_t c,
> sched_counter_t d)
>  {
>  	return a*d < b*c;
>  }
> 
> -static inline uint32_t
> -less_or_equal(uint32_t a, uint32_t b, uint32_t c, uint32_t d)
> +static inline sched_counter_t
> +less_or_equal(sched_counter_t a, sched_counter_t b, sched_counter_t c,
> +	sched_counter_t d)
>  {
>  	return a*d <= b*c;
>  }
> 
>  /* check whether a/b is a valid approximation */
> -static inline uint32_t
> -matches(uint32_t a, uint32_t b,
> -	uint32_t alpha_num, uint32_t d_num, uint32_t denum)
> +static inline sched_counter_t
> +matches(sched_counter_t a, sched_counter_t b,
> +	sched_counter_t alpha_num, sched_counter_t d_num,
> sched_counter_t denum)
>  {
>  	if (less_or_equal(a, b, alpha_num - d_num, denum))
>  		return 0;
> @@ -45,33 +46,39 @@ matches(uint32_t a, uint32_t b,
>  }
> 
>  static inline void
> -find_exact_solution_left(uint32_t p_a, uint32_t q_a, uint32_t p_b, uint32_t
> q_b,
> -	uint32_t alpha_num, uint32_t d_num, uint32_t denum, uint32_t *p,
> uint32_t *q)
> +find_exact_solution_left(sched_counter_t p_a, sched_counter_t q_a,
> +	sched_counter_t p_b, sched_counter_t q_b, sched_counter_t
> alpha_num,
> +	sched_counter_t d_num, sched_counter_t denum,
> sched_counter_t *p,
> +	sched_counter_t *q)
>  {
> -	uint32_t k_num = denum * p_b - (alpha_num + d_num) * q_b;
> -	uint32_t k_denum = (alpha_num + d_num) * q_a - denum * p_a;
> -	uint32_t k = (k_num / k_denum) + 1;
> +	sched_counter_t k_num = denum * p_b - (alpha_num + d_num) *
> q_b;
> +	sched_counter_t k_denum = (alpha_num + d_num) * q_a - denum *
> p_a;
> +	sched_counter_t k = (k_num / k_denum) + 1;
> 
>  	*p = p_b + k * p_a;
>  	*q = q_b + k * q_a;
>  }
> 
>  static inline void
> -find_exact_solution_right(uint32_t p_a, uint32_t q_a, uint32_t p_b,
> uint32_t q_b,
> -	uint32_t alpha_num, uint32_t d_num, uint32_t denum, uint32_t *p,
> uint32_t *q)
> +find_exact_solution_right(sched_counter_t p_a, sched_counter_t q_a,
> +	sched_counter_t p_b, sched_counter_t q_b, sched_counter_t
> alpha_num,
> +	sched_counter_t d_num, sched_counter_t denum,
> sched_counter_t *p,
> +	sched_counter_t *q)
>  {
> -	uint32_t k_num = - denum * p_b + (alpha_num - d_num) * q_b;
> -	uint32_t k_denum = - (alpha_num - d_num) * q_a + denum * p_a;
> -	uint32_t k = (k_num / k_denum) + 1;
> +	sched_counter_t k_num = -denum * p_b + (alpha_num - d_num) *
> q_b;
> +	sched_counter_t k_denum = -(alpha_num - d_num) * q_a + denum
> * p_a;
> +	sched_counter_t k = (k_num / k_denum) + 1;
> 
>  	*p = p_b + k * p_a;
>  	*q = q_b + k * q_a;
>  }
> 
>  static int
> -find_best_rational_approximation(uint32_t alpha_num, uint32_t d_num,
> uint32_t denum, uint32_t *p, uint32_t *q)
> +find_best_rational_approximation(sched_counter_t alpha_num,
> +	sched_counter_t d_num, sched_counter_t denum,
> sched_counter_t *p,
> +	sched_counter_t *q)
>  {
> -	uint32_t p_a, q_a, p_b, q_b;
> +	sched_counter_t p_a, q_a, p_b, q_b;
> 
>  	/* check assumptions on the inputs */
>  	if (!((0 < d_num) && (d_num < alpha_num) && (alpha_num <
> denum) && (d_num + alpha_num < denum))) {
> @@ -85,8 +92,8 @@ find_best_rational_approximation(uint32_t alpha_num,
> uint32_t d_num, uint32_t de
>  	q_b = 1;
> 
>  	while (1) {
> -		uint32_t new_p_a, new_q_a, new_p_b, new_q_b;
> -		uint32_t x_num, x_denum, x;
> +		sched_counter_t new_p_a, new_q_a, new_p_b, new_q_b;
> +		sched_counter_t x_num, x_denum, x;
>  		int aa, bb;
> 
>  		/* compute the number of steps to the left */
> @@ -139,9 +146,9 @@ find_best_rational_approximation(uint32_t
> alpha_num, uint32_t d_num, uint32_t de
>  	}
>  }
> 
> -int rte_approx(double alpha, double d, uint32_t *p, uint32_t *q)
> +int rte_approx(double alpha, double d, sched_counter_t *p,
> sched_counter_t *q)
>  {
> -	uint32_t alpha_num, d_num, denum;
> +	sched_counter_t alpha_num, d_num, denum;
> 
>  	/* Check input arguments */
>  	if (!((0.0 < d) && (d < alpha) && (alpha < 1.0))) {
> @@ -159,8 +166,8 @@ int rte_approx(double alpha, double d, uint32_t *p,
> uint32_t *q)
>  		d *= 10;
>  		denum *= 10;
>  	}
> -	alpha_num = (uint32_t) alpha;
> -	d_num = (uint32_t) d;
> +	alpha_num = (sched_counter_t) alpha;
> +	d_num = (sched_counter_t) d;
> 
>  	/* Perform approximation */
>  	return find_best_rational_approximation(alpha_num, d_num,
> denum, p, q);
> diff --git a/lib/librte_sched/rte_approx.h b/lib/librte_sched/rte_approx.h
> index 0244d98f1..e591e122d 100644
> --- a/lib/librte_sched/rte_approx.h
> +++ b/lib/librte_sched/rte_approx.h
> @@ -20,6 +20,7 @@ extern "C" {
>   ***/
> 
>  #include <stdint.h>
> +#include "rte_sched_common.h"
> 
>  /**
>   * Find best rational approximation
> @@ -37,7 +38,7 @@ extern "C" {
>   * @return
>   *   0 upon success, error code otherwise
>   */
> -int rte_approx(double alpha, double d, uint32_t *p, uint32_t *q);
> +int rte_approx(double alpha, double d, sched_counter_t *p,
> sched_counter_t *q);
> 
>  #ifdef __cplusplus
>  }

Please keep the rte_approx.[hc] independent of the librte_sched library, so use unit32_t or uint64_t instead of sched_counter_t that is librte_sched dependent. Also, for the same reason, remove the above inclusion of rte_sched_common.h.

Please keep the existing 32-bit functions with their current name & prototype and create new 64-bit functions that have the "64" suffix to their name, and use the 64-bit versions in the rte_sched.c implementation. Makes sense?

The rte_approx.[hc] files represent the implementation of an arithmetic algorithm that is completely independent of the scheduler library. In fact, they could be moved to a more generic location in DPDK where they could be leveraged by other libraries without the need to create a (fake) dependency to librte_sched.

> diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c
> index 710ecf65a..11d1febe2 100644
> --- a/lib/librte_sched/rte_sched.c
> +++ b/lib/librte_sched/rte_sched.c
> @@ -49,13 +49,13 @@
> 
>  struct rte_sched_pipe_profile {
>  	/* Token bucket (TB) */
> -	uint32_t tb_period;
> -	uint32_t tb_credits_per_period;
> -	uint32_t tb_size;
> +	sched_counter_t tb_period;
> +	sched_counter_t tb_credits_per_period;
> +	sched_counter_t tb_size;
> 
>  	/* Pipe traffic classes */
> -	uint32_t tc_period;
> -	uint32_t
> tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> +	sched_counter_t tc_period;
> +	sched_counter_t
> tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
>  	uint8_t tc_ov_weight;
> 
>  	/* Pipe best-effort traffic class queues */
> @@ -65,20 +65,20 @@ struct rte_sched_pipe_profile {
>  struct rte_sched_pipe {
>  	/* Token bucket (TB) */
>  	uint64_t tb_time; /* time of last update */
> -	uint32_t tb_credits;
> +	sched_counter_t tb_credits;
> 
>  	/* Pipe profile and flags */
>  	uint32_t profile;
> 
>  	/* Traffic classes (TCs) */
>  	uint64_t tc_time; /* time of next update */
> -	uint32_t tc_credits[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> +	sched_counter_t
> tc_credits[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> 
>  	/* Weighted Round Robin (WRR) */
>  	uint8_t wrr_tokens[RTE_SCHED_BE_QUEUES_PER_PIPE];
> 
>  	/* TC oversubscription */
> -	uint32_t tc_ov_credits;
> +	sched_counter_t tc_ov_credits;
>  	uint8_t tc_ov_period_id;
>  } __rte_cache_aligned;
> 
> @@ -141,28 +141,28 @@ struct rte_sched_grinder {
>  struct rte_sched_subport {
>  	/* Token bucket (TB) */
>  	uint64_t tb_time; /* time of last update */
> -	uint32_t tb_period;
> -	uint32_t tb_credits_per_period;
> -	uint32_t tb_size;
> -	uint32_t tb_credits;
> +	sched_counter_t tb_period;
> +	sched_counter_t tb_credits_per_period;
> +	sched_counter_t tb_size;
> +	sched_counter_t tb_credits;
> 
>  	/* Traffic classes (TCs) */
>  	uint64_t tc_time; /* time of next update */
> -	uint32_t
> tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> -	uint32_t tc_credits[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> -	uint32_t tc_period;
> +	sched_counter_t
> tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> +	sched_counter_t
> tc_credits[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> +	sched_counter_t tc_period;
> 
>  	/* TC oversubscription */
> -	uint32_t tc_ov_wm;
> -	uint32_t tc_ov_wm_min;
> -	uint32_t tc_ov_wm_max;
> +	sched_counter_t tc_ov_wm;
> +	sched_counter_t tc_ov_wm_min;
> +	sched_counter_t tc_ov_wm_max;
>  	uint8_t tc_ov_period_id;
>  	uint8_t tc_ov;
>  	uint32_t tc_ov_n;
>  	double tc_ov_rate;
> 
>  	/* Statistics */
> -	struct rte_sched_subport_stats stats;
> +	struct rte_sched_subport_stats stats __rte_cache_aligned;
> 
>  	/* Subport pipes */
>  	uint32_t n_pipes_per_subport_enabled;
> @@ -170,7 +170,7 @@ struct rte_sched_subport {
>  	uint32_t n_max_pipe_profiles;
> 
>  	/* Pipe best-effort TC rate */
> -	uint32_t pipe_tc_be_rate_max;
> +	sched_counter_t pipe_tc_be_rate_max;
> 
>  	/* Pipe queues size */
>  	uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> @@ -212,7 +212,7 @@ struct rte_sched_port {
>  	uint16_t pipe_queue[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
>  	uint8_t pipe_tc[RTE_SCHED_QUEUES_PER_PIPE];
>  	uint8_t tc_queue[RTE_SCHED_QUEUES_PER_PIPE];
> -	uint32_t rate;
> +	sched_counter_t rate;
>  	uint32_t mtu;
>  	uint32_t frame_overhead;
>  	int socket;
> @@ -517,33 +517,35 @@ rte_sched_port_log_pipe_profile(struct
> rte_sched_subport *subport, uint32_t i)
>  	struct rte_sched_pipe_profile *p = subport->pipe_profiles + i;
> 
>  	RTE_LOG(DEBUG, SCHED, "Low level config for pipe profile %u:\n"
> -		"	Token bucket: period = %u, credits per period = %u,
> size = %u\n"
> -		"	Traffic classes: period = %u,\n"
> -		"	credits per period = [%u, %u, %u, %u, %u, %u, %u,
> %u, %u, %u, %u, %u, %u]\n"
> +		"	Token bucket: period = %"PRIu64", credits per period
> = %"PRIu64", size = %"PRIu64"\n"
> +		"	Traffic classes: period = %"PRIu64",\n"
> +		"	credits per period = [%"PRIu64", %"PRIu64",
> %"PRIu64", %"PRIu64
> +		", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64",
> %"PRIu64
> +		", %"PRIu64", %"PRIu64", %"PRIu64"]\n"
>  		"	Best-effort traffic class oversubscription: weight =
> %hhu\n"
>  		"	WRR cost: [%hhu, %hhu, %hhu, %hhu]\n",
>  		i,
> 
>  		/* Token bucket */
> -		p->tb_period,
> -		p->tb_credits_per_period,
> -		p->tb_size,
> +		(uint64_t)p->tb_period,
> +		(uint64_t)p->tb_credits_per_period,
> +		(uint64_t)p->tb_size,
> 
>  		/* Traffic classes */
> -		p->tc_period,
> -		p->tc_credits_per_period[0],
> -		p->tc_credits_per_period[1],
> -		p->tc_credits_per_period[2],
> -		p->tc_credits_per_period[3],
> -		p->tc_credits_per_period[4],
> -		p->tc_credits_per_period[5],
> -		p->tc_credits_per_period[6],
> -		p->tc_credits_per_period[7],
> -		p->tc_credits_per_period[8],
> -		p->tc_credits_per_period[9],
> -		p->tc_credits_per_period[10],
> -		p->tc_credits_per_period[11],
> -		p->tc_credits_per_period[12],
> +		(uint64_t)p->tc_period,
> +		(uint64_t)p->tc_credits_per_period[0],
> +		(uint64_t)p->tc_credits_per_period[1],
> +		(uint64_t)p->tc_credits_per_period[2],
> +		(uint64_t)p->tc_credits_per_period[3],
> +		(uint64_t)p->tc_credits_per_period[4],
> +		(uint64_t)p->tc_credits_per_period[5],
> +		(uint64_t)p->tc_credits_per_period[6],
> +		(uint64_t)p->tc_credits_per_period[7],
> +		(uint64_t)p->tc_credits_per_period[8],
> +		(uint64_t)p->tc_credits_per_period[9],
> +		(uint64_t)p->tc_credits_per_period[10],
> +		(uint64_t)p->tc_credits_per_period[11],
> +		(uint64_t)p->tc_credits_per_period[12],
> 
>  		/* Best-effort traffic class oversubscription */
>  		p->tc_ov_weight,
> @@ -553,7 +555,7 @@ rte_sched_port_log_pipe_profile(struct
> rte_sched_subport *subport, uint32_t i)
>  }
> 
>  static inline uint64_t
> -rte_sched_time_ms_to_bytes(uint32_t time_ms, uint32_t rate)
> +rte_sched_time_ms_to_bytes(sched_counter_t time_ms,
> sched_counter_t rate)
>  {
>  	uint64_t time = time_ms;
> 
> @@ -566,7 +568,7 @@ static void
>  rte_sched_pipe_profile_convert(struct rte_sched_subport *subport,
>  	struct rte_sched_pipe_params *src,
>  	struct rte_sched_pipe_profile *dst,
> -	uint32_t rate)
> +	sched_counter_t rate)
>  {
>  	uint32_t wrr_cost[RTE_SCHED_BE_QUEUES_PER_PIPE];
>  	uint32_t lcd1, lcd2, lcd;
> @@ -581,8 +583,8 @@ rte_sched_pipe_profile_convert(struct
> rte_sched_subport *subport,
>  				/ (double) rate;
>  		double d = RTE_SCHED_TB_RATE_CONFIG_ERR;
> 
> -		rte_approx(tb_rate, d,
> -			&dst->tb_credits_per_period, &dst->tb_period);
> +		rte_approx(tb_rate, d, &dst->tb_credits_per_period,
> +			&dst->tb_period);
>  	}
> 
>  	dst->tb_size = src->tb_size;
> @@ -594,8 +596,8 @@ rte_sched_pipe_profile_convert(struct
> rte_sched_subport *subport,
>  	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
>  		if (subport->qsize[i])
>  			dst->tc_credits_per_period[i]
> -				= rte_sched_time_ms_to_bytes(src-
> >tc_period,
> -					src->tc_rate[i]);
> +				= (sched_counter_t)
> rte_sched_time_ms_to_bytes(
> +					src->tc_period, src->tc_rate[i]);
> 
>  	dst->tc_ov_weight = src->tc_ov_weight;
> 
> @@ -637,7 +639,8 @@ rte_sched_subport_config_pipe_profile_table(struct
> rte_sched_subport *subport,
>  	subport->pipe_tc_be_rate_max = 0;
>  	for (i = 0; i < subport->n_pipe_profiles; i++) {
>  		struct rte_sched_pipe_params *src = params->pipe_profiles
> + i;
> -		uint32_t pipe_tc_be_rate = src-
> >tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE];
> +		sched_counter_t pipe_tc_be_rate =
> +			src->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE];
> 
>  		if (subport->pipe_tc_be_rate_max < pipe_tc_be_rate)
>  			subport->pipe_tc_be_rate_max = pipe_tc_be_rate;
> @@ -647,7 +650,7 @@ rte_sched_subport_config_pipe_profile_table(struct
> rte_sched_subport *subport,
>  static int
>  rte_sched_subport_check_params(struct rte_sched_subport_params
> *params,
>  	uint32_t n_max_pipes_per_subport,
> -	uint32_t rate)
> +	sched_counter_t rate)
>  {
>  	uint32_t i;
> 
> @@ -684,7 +687,7 @@ rte_sched_subport_check_params(struct
> rte_sched_subport_params *params,
>  	}
> 
>  	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
> -		uint32_t tc_rate = params->tc_rate[i];
> +		sched_counter_t tc_rate = params->tc_rate[i];
>  		uint16_t qsize = params->qsize[i];
> 
>  		if ((qsize == 0 && tc_rate != 0) ||
> @@ -910,36 +913,40 @@ rte_sched_port_log_subport_config(struct
> rte_sched_port *port, uint32_t i)
>  	struct rte_sched_subport *s = port->subports[i];
> 
>  	RTE_LOG(DEBUG, SCHED, "Low level config for subport %u:\n"
> -		"	Token bucket: period = %u, credits per period = %u,
> size = %u\n"
> -		"	Traffic classes: period = %u\n"
> -		"	credits per period = [%u, %u, %u, %u, %u, %u, %u,
> %u, %u, %u, %u, %u, %u]\n"
> -		"	Best effort traffic class oversubscription: wm min =
> %u, wm max = %u\n",
> +		"	Token bucket: period = %"PRIu64", credits per period
> = %"PRIu64
> +		", size = %"PRIu64"\n"
> +		"	Traffic classes: period = %"PRIu64"\n"
> +		"	credits per period = [%"PRIu64", %"PRIu64",
> %"PRIu64", %"PRIu64
> +		", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64",
> %"PRIu64
> +		", %"PRIu64", %"PRIu64", %"PRIu64"]\n"
> +		"	Best effort traffic class oversubscription: wm min =
> %"PRIu64
> +		", wm max = %"PRIu64"\n",
>  		i,
> 
>  		/* Token bucket */
> -		s->tb_period,
> -		s->tb_credits_per_period,
> -		s->tb_size,
> +		(uint64_t)s->tb_period,
> +		(uint64_t)s->tb_credits_per_period,
> +		(uint64_t)s->tb_size,
> 
>  		/* Traffic classes */
> -		s->tc_period,
> -		s->tc_credits_per_period[0],
> -		s->tc_credits_per_period[1],
> -		s->tc_credits_per_period[2],
> -		s->tc_credits_per_period[3],
> -		s->tc_credits_per_period[4],
> -		s->tc_credits_per_period[5],
> -		s->tc_credits_per_period[6],
> -		s->tc_credits_per_period[7],
> -		s->tc_credits_per_period[8],
> -		s->tc_credits_per_period[9],
> -		s->tc_credits_per_period[10],
> -		s->tc_credits_per_period[11],
> -		s->tc_credits_per_period[12],
> +		(uint64_t)s->tc_period,
> +		(uint64_t)s->tc_credits_per_period[0],
> +		(uint64_t)s->tc_credits_per_period[1],
> +		(uint64_t)s->tc_credits_per_period[2],
> +		(uint64_t)s->tc_credits_per_period[3],
> +		(uint64_t)s->tc_credits_per_period[4],
> +		(uint64_t)s->tc_credits_per_period[5],
> +		(uint64_t)s->tc_credits_per_period[6],
> +		(uint64_t)s->tc_credits_per_period[7],
> +		(uint64_t)s->tc_credits_per_period[8],
> +		(uint64_t)s->tc_credits_per_period[9],
> +		(uint64_t)s->tc_credits_per_period[10],
> +		(uint64_t)s->tc_credits_per_period[11],
> +		(uint64_t)s->tc_credits_per_period[12],
> 
>  		/* Best effort traffic class oversubscription */
> -		s->tc_ov_wm_min,
> -		s->tc_ov_wm_max);
> +		(uint64_t)s->tc_ov_wm_min,
> +		(uint64_t)s->tc_ov_wm_max);
>  }
> 
>  static void
> @@ -1023,7 +1030,8 @@ rte_sched_subport_config(struct rte_sched_port
> *port,
>  		double tb_rate = ((double) params->tb_rate) / ((double)
> port->rate);
>  		double d = RTE_SCHED_TB_RATE_CONFIG_ERR;
> 
> -		rte_approx(tb_rate, d, &s->tb_credits_per_period, &s-
> >tb_period);
> +		rte_approx(tb_rate, d, &s->tb_credits_per_period,
> +			&s->tb_period);
>  	}
> 
>  	s->tb_size = params->tb_size;
> @@ -1035,8 +1043,8 @@ rte_sched_subport_config(struct rte_sched_port
> *port,
>  	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
>  		if (params->qsize[i])
>  			s->tc_credits_per_period[i]
> -				= rte_sched_time_ms_to_bytes(params-
> >tc_period,
> -					params->tc_rate[i]);
> +				= (sched_counter_t)
> rte_sched_time_ms_to_bytes(
> +					params->tc_period, params-
> >tc_rate[i]);
>  	}
>  	s->tc_time = port->time + s->tc_period;
>  	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
> @@ -1970,13 +1978,15 @@ grinder_credits_update(struct rte_sched_port
> *port,
>  	/* Subport TB */
>  	n_periods = (port->time - subport->tb_time) / subport->tb_period;
>  	subport->tb_credits += n_periods * subport-
> >tb_credits_per_period;
> -	subport->tb_credits = rte_sched_min_val_2_u32(subport-
> >tb_credits, subport->tb_size);
> +	subport->tb_credits = rte_sched_min_val_2(subport->tb_credits,
> +				subport->tb_size);
>  	subport->tb_time += n_periods * subport->tb_period;
> 
>  	/* Pipe TB */
>  	n_periods = (port->time - pipe->tb_time) / params->tb_period;
>  	pipe->tb_credits += n_periods * params->tb_credits_per_period;
> -	pipe->tb_credits = rte_sched_min_val_2_u32(pipe->tb_credits,
> params->tb_size);
> +	pipe->tb_credits = rte_sched_min_val_2(pipe->tb_credits,
> +				params->tb_size);

Can we remove all the usages of rte_sched_min_val() (including its definition in rte_sched_common.h) and replace it with RTE_MIN, please?

>  	pipe->tb_time += n_periods * params->tb_period;
> 
>  	/* Subport TCs */
> @@ -1998,13 +2008,13 @@ grinder_credits_update(struct rte_sched_port
> *port,
> 
>  #else
> 
> -static inline uint32_t
> +static inline sched_counter_t
>  grinder_tc_ov_credits_update(struct rte_sched_port *port,
>  	struct rte_sched_subport *subport)
>  {
> -	uint32_t
> tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> -	uint32_t tc_consumption = 0, tc_ov_consumption_max;
> -	uint32_t tc_ov_wm = subport->tc_ov_wm;
> +	sched_counter_t
> tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> +	sched_counter_t tc_consumption = 0, tc_ov_consumption_max;
> +	sched_counter_t tc_ov_wm = subport->tc_ov_wm;
>  	uint32_t i;
> 
>  	if (subport->tc_ov == 0)
> @@ -2053,13 +2063,15 @@ grinder_credits_update(struct rte_sched_port
> *port,
>  	/* Subport TB */
>  	n_periods = (port->time - subport->tb_time) / subport->tb_period;
>  	subport->tb_credits += n_periods * subport-
> >tb_credits_per_period;
> -	subport->tb_credits = rte_sched_min_val_2_u32(subport-
> >tb_credits, subport->tb_size);
> +	subport->tb_credits = rte_sched_min_val_2(subport->tb_credits,
> +				subport->tb_size);
>  	subport->tb_time += n_periods * subport->tb_period;
> 
>  	/* Pipe TB */
>  	n_periods = (port->time - pipe->tb_time) / params->tb_period;
>  	pipe->tb_credits += n_periods * params->tb_credits_per_period;
> -	pipe->tb_credits = rte_sched_min_val_2_u32(pipe->tb_credits,
> params->tb_size);
> +	pipe->tb_credits = rte_sched_min_val_2(pipe->tb_credits,
> +				params->tb_size);
>  	pipe->tb_time += n_periods * params->tb_period;
> 
>  	/* Subport TCs */
> @@ -2101,11 +2113,11 @@ grinder_credits_check(struct rte_sched_port
> *port,
>  	struct rte_sched_pipe *pipe = grinder->pipe;
>  	struct rte_mbuf *pkt = grinder->pkt;
>  	uint32_t tc_index = grinder->tc_index;
> -	uint32_t pkt_len = pkt->pkt_len + port->frame_overhead;
> -	uint32_t subport_tb_credits = subport->tb_credits;
> -	uint32_t subport_tc_credits = subport->tc_credits[tc_index];
> -	uint32_t pipe_tb_credits = pipe->tb_credits;
> -	uint32_t pipe_tc_credits = pipe->tc_credits[tc_index];
> +	sched_counter_t pkt_len = pkt->pkt_len + port->frame_overhead;
> +	sched_counter_t subport_tb_credits = subport->tb_credits;
> +	sched_counter_t subport_tc_credits = subport-
> >tc_credits[tc_index];
> +	sched_counter_t pipe_tb_credits = pipe->tb_credits;
> +	sched_counter_t pipe_tc_credits = pipe->tc_credits[tc_index];
>  	int enough_credits;
> 
>  	/* Check queue credits */
> @@ -2136,21 +2148,22 @@ grinder_credits_check(struct rte_sched_port
> *port,
>  	struct rte_sched_pipe *pipe = grinder->pipe;
>  	struct rte_mbuf *pkt = grinder->pkt;
>  	uint32_t tc_index = grinder->tc_index;
> -	uint32_t pkt_len = pkt->pkt_len + port->frame_overhead;
> -	uint32_t subport_tb_credits = subport->tb_credits;
> -	uint32_t subport_tc_credits = subport->tc_credits[tc_index];
> -	uint32_t pipe_tb_credits = pipe->tb_credits;
> -	uint32_t pipe_tc_credits = pipe->tc_credits[tc_index];
> -	uint32_t
> pipe_tc_ov_mask1[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> -	uint32_t
> pipe_tc_ov_mask2[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE] = {0};
> -	uint32_t pipe_tc_ov_credits, i;
> +	sched_counter_t pkt_len = pkt->pkt_len + port->frame_overhead;
> +	sched_counter_t subport_tb_credits = subport->tb_credits;
> +	sched_counter_t subport_tc_credits = subport-
> >tc_credits[tc_index];
> +	sched_counter_t pipe_tb_credits = pipe->tb_credits;
> +	sched_counter_t pipe_tc_credits = pipe->tc_credits[tc_index];
> +	sched_counter_t
> pipe_tc_ov_mask1[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> +	sched_counter_t
> pipe_tc_ov_mask2[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE] = {0};
> +	sched_counter_t pipe_tc_ov_credits;
> +	uint32_t i;
>  	int enough_credits;
> 
>  	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
> -		pipe_tc_ov_mask1[i] = UINT32_MAX;
> +		pipe_tc_ov_mask1[i] = ~0;

Please use ~0LLU (or UINT64_MAX) to cover the 64-bit case gracefully. Please also double-check that there are no usages of UINT32_MAX left in this code, unless there is a reason for it. Translation from 32-bit to 64-bit arithmetic can be very tricky and yield some very difficult to debug issues.

> 
>  	pipe_tc_ov_mask1[RTE_SCHED_TRAFFIC_CLASS_BE] = pipe-
> >tc_ov_credits;
> -	pipe_tc_ov_mask2[RTE_SCHED_TRAFFIC_CLASS_BE] =
> UINT32_MAX;
> +	pipe_tc_ov_mask2[RTE_SCHED_TRAFFIC_CLASS_BE] = ~0;
>  	pipe_tc_ov_credits = pipe_tc_ov_mask1[tc_index];
> 
>  	/* Check pipe and subport credits */
> diff --git a/lib/librte_sched/rte_sched_common.h
> b/lib/librte_sched/rte_sched_common.h
> index 8c191a9b8..06520a686 100644
> --- a/lib/librte_sched/rte_sched_common.h
> +++ b/lib/librte_sched/rte_sched_common.h
> @@ -14,8 +14,16 @@ extern "C" {
> 
>  #define __rte_aligned_16 __attribute__((__aligned__(16)))
> 
> -static inline uint32_t
> -rte_sched_min_val_2_u32(uint32_t x, uint32_t y)
> +//#define COUNTER_SIZE_64
> +
> +#ifdef COUNTER_SIZE_64
> +typedef uint64_t sched_counter_t;
> +#else
> +typedef uint32_t sched_counter_t;
> +#endif
> +
> +static inline sched_counter_t
> +rte_sched_min_val_2(sched_counter_t x, sched_counter_t y)
>  {
>  	return (x < y)? x : y;
>  }
> --
> 2.21.0

I know I have previously suggested the creation of sched_counter_t, but this was meant to be a temporary solution until the full implementation is made available. Now that 19.11 is meant to be an ABI stable release, we cannot really afford this trick (which might not be necessary either, since you have the full implementation), as this #ifdef COUNTER_SIZE is a massive ABI breakage.

Therefore, I strongly suggest we remove the sched_counter_t and use uint64_t everywhere throughout the implementation. Agree?

Regards,
Cristian

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

* Re: [dpdk-dev] [PATCH 2/2] sched: modify internal structs and functions for 64 bit values
  2019-10-15 15:47   ` Dumitrescu, Cristian
@ 2019-10-15 16:01     ` Singh, Jasvinder
  0 siblings, 0 replies; 9+ messages in thread
From: Singh, Jasvinder @ 2019-10-15 16:01 UTC (permalink / raw)
  To: Dumitrescu, Cristian, dev; +Cc: Krakowiak, LukaszX



> -----Original Message-----
> From: Dumitrescu, Cristian
> Sent: Tuesday, October 15, 2019 4:47 PM
> To: Singh, Jasvinder <jasvinder.singh@intel.com>; dev@dpdk.org
> Cc: Krakowiak, LukaszX <lukaszx.krakowiak@intel.com>
> Subject: RE: [PATCH 2/2] sched: modify internal structs and functions for 64 bit
> values
> 
> Hi Jasvinder,
> 
> > -----Original Message-----
> > From: Singh, Jasvinder
> > Sent: Monday, October 14, 2019 6:25 PM
> > To: dev@dpdk.org
> > Cc: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>; Krakowiak,
> > LukaszX <lukaszx.krakowiak@intel.com>
> > Subject: [PATCH 2/2] sched: modify internal structs and functions for
> > 64 bit values
> >
> > Modify internal structure and functions to support 64-bit values for
> > rates and stats parameters.
> >
> > Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
> > Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
> > ---
> >  lib/librte_sched/rte_approx.c       |  57 ++++----
> >  lib/librte_sched/rte_approx.h       |   3 +-
> >  lib/librte_sched/rte_sched.c        | 211 +++++++++++++++-------------
> >  lib/librte_sched/rte_sched_common.h |  12 +-
> >  4 files changed, 156 insertions(+), 127 deletions(-)
> >
> > diff --git a/lib/librte_sched/rte_approx.c
> > b/lib/librte_sched/rte_approx.c index 30620b83d..4883d3969 100644
> > --- a/lib/librte_sched/rte_approx.c
> > +++ b/lib/librte_sched/rte_approx.c
> > @@ -18,22 +18,23 @@
> >   */
> >
> >  /* fraction comparison: compare (a/b) and (c/d) */ -static inline
> > uint32_t -less(uint32_t a, uint32_t b, uint32_t c, uint32_t d)
> > +static inline sched_counter_t
> > +less(sched_counter_t a, sched_counter_t b, sched_counter_t c,
> > sched_counter_t d)
> >  {
> >  	return a*d < b*c;
> >  }
> >
> > -static inline uint32_t
> > -less_or_equal(uint32_t a, uint32_t b, uint32_t c, uint32_t d)
> > +static inline sched_counter_t
> > +less_or_equal(sched_counter_t a, sched_counter_t b, sched_counter_t c,
> > +	sched_counter_t d)
> >  {
> >  	return a*d <= b*c;
> >  }
> >
> >  /* check whether a/b is a valid approximation */ -static inline
> > uint32_t -matches(uint32_t a, uint32_t b,
> > -	uint32_t alpha_num, uint32_t d_num, uint32_t denum)
> > +static inline sched_counter_t
> > +matches(sched_counter_t a, sched_counter_t b,
> > +	sched_counter_t alpha_num, sched_counter_t d_num,
> > sched_counter_t denum)
> >  {
> >  	if (less_or_equal(a, b, alpha_num - d_num, denum))
> >  		return 0;
> > @@ -45,33 +46,39 @@ matches(uint32_t a, uint32_t b,  }
> >
> >  static inline void
> > -find_exact_solution_left(uint32_t p_a, uint32_t q_a, uint32_t p_b,
> > uint32_t q_b,
> > -	uint32_t alpha_num, uint32_t d_num, uint32_t denum, uint32_t *p,
> > uint32_t *q)
> > +find_exact_solution_left(sched_counter_t p_a, sched_counter_t q_a,
> > +	sched_counter_t p_b, sched_counter_t q_b, sched_counter_t
> > alpha_num,
> > +	sched_counter_t d_num, sched_counter_t denum,
> > sched_counter_t *p,
> > +	sched_counter_t *q)
> >  {
> > -	uint32_t k_num = denum * p_b - (alpha_num + d_num) * q_b;
> > -	uint32_t k_denum = (alpha_num + d_num) * q_a - denum * p_a;
> > -	uint32_t k = (k_num / k_denum) + 1;
> > +	sched_counter_t k_num = denum * p_b - (alpha_num + d_num) *
> > q_b;
> > +	sched_counter_t k_denum = (alpha_num + d_num) * q_a - denum *
> > p_a;
> > +	sched_counter_t k = (k_num / k_denum) + 1;
> >
> >  	*p = p_b + k * p_a;
> >  	*q = q_b + k * q_a;
> >  }
> >
> >  static inline void
> > -find_exact_solution_right(uint32_t p_a, uint32_t q_a, uint32_t p_b,
> > uint32_t q_b,
> > -	uint32_t alpha_num, uint32_t d_num, uint32_t denum, uint32_t *p,
> > uint32_t *q)
> > +find_exact_solution_right(sched_counter_t p_a, sched_counter_t q_a,
> > +	sched_counter_t p_b, sched_counter_t q_b, sched_counter_t
> > alpha_num,
> > +	sched_counter_t d_num, sched_counter_t denum,
> > sched_counter_t *p,
> > +	sched_counter_t *q)
> >  {
> > -	uint32_t k_num = - denum * p_b + (alpha_num - d_num) * q_b;
> > -	uint32_t k_denum = - (alpha_num - d_num) * q_a + denum * p_a;
> > -	uint32_t k = (k_num / k_denum) + 1;
> > +	sched_counter_t k_num = -denum * p_b + (alpha_num - d_num) *
> > q_b;
> > +	sched_counter_t k_denum = -(alpha_num - d_num) * q_a + denum
> > * p_a;
> > +	sched_counter_t k = (k_num / k_denum) + 1;
> >
> >  	*p = p_b + k * p_a;
> >  	*q = q_b + k * q_a;
> >  }
> >
> >  static int
> > -find_best_rational_approximation(uint32_t alpha_num, uint32_t d_num,
> > uint32_t denum, uint32_t *p, uint32_t *q)
> > +find_best_rational_approximation(sched_counter_t alpha_num,
> > +	sched_counter_t d_num, sched_counter_t denum,
> > sched_counter_t *p,
> > +	sched_counter_t *q)
> >  {
> > -	uint32_t p_a, q_a, p_b, q_b;
> > +	sched_counter_t p_a, q_a, p_b, q_b;
> >
> >  	/* check assumptions on the inputs */
> >  	if (!((0 < d_num) && (d_num < alpha_num) && (alpha_num <
> > denum) && (d_num + alpha_num < denum))) { @@ -85,8 +92,8 @@
> > find_best_rational_approximation(uint32_t alpha_num, uint32_t d_num,
> > uint32_t de
> >  	q_b = 1;
> >
> >  	while (1) {
> > -		uint32_t new_p_a, new_q_a, new_p_b, new_q_b;
> > -		uint32_t x_num, x_denum, x;
> > +		sched_counter_t new_p_a, new_q_a, new_p_b, new_q_b;
> > +		sched_counter_t x_num, x_denum, x;
> >  		int aa, bb;
> >
> >  		/* compute the number of steps to the left */ @@ -139,9
> +146,9 @@
> > find_best_rational_approximation(uint32_t
> > alpha_num, uint32_t d_num, uint32_t de
> >  	}
> >  }
> >
> > -int rte_approx(double alpha, double d, uint32_t *p, uint32_t *q)
> > +int rte_approx(double alpha, double d, sched_counter_t *p,
> > sched_counter_t *q)
> >  {
> > -	uint32_t alpha_num, d_num, denum;
> > +	sched_counter_t alpha_num, d_num, denum;
> >
> >  	/* Check input arguments */
> >  	if (!((0.0 < d) && (d < alpha) && (alpha < 1.0))) { @@ -159,8 +166,8
> > @@ int rte_approx(double alpha, double d, uint32_t *p, uint32_t *q)
> >  		d *= 10;
> >  		denum *= 10;
> >  	}
> > -	alpha_num = (uint32_t) alpha;
> > -	d_num = (uint32_t) d;
> > +	alpha_num = (sched_counter_t) alpha;
> > +	d_num = (sched_counter_t) d;
> >
> >  	/* Perform approximation */
> >  	return find_best_rational_approximation(alpha_num, d_num, denum,
> p,
> > q); diff --git a/lib/librte_sched/rte_approx.h
> > b/lib/librte_sched/rte_approx.h index 0244d98f1..e591e122d 100644
> > --- a/lib/librte_sched/rte_approx.h
> > +++ b/lib/librte_sched/rte_approx.h
> > @@ -20,6 +20,7 @@ extern "C" {
> >   ***/
> >
> >  #include <stdint.h>
> > +#include "rte_sched_common.h"
> >
> >  /**
> >   * Find best rational approximation
> > @@ -37,7 +38,7 @@ extern "C" {
> >   * @return
> >   *   0 upon success, error code otherwise
> >   */
> > -int rte_approx(double alpha, double d, uint32_t *p, uint32_t *q);
> > +int rte_approx(double alpha, double d, sched_counter_t *p,
> > sched_counter_t *q);
> >
> >  #ifdef __cplusplus
> >  }
> 
> Please keep the rte_approx.[hc] independent of the librte_sched library, so use
> unit32_t or uint64_t instead of sched_counter_t that is librte_sched dependent.
> Also, for the same reason, remove the above inclusion of rte_sched_common.h.

Ok, will make these changes.

 
> Please keep the existing 32-bit functions with their current name & prototype
> and create new 64-bit functions that have the "64" suffix to their name, and use
> the 64-bit versions in the rte_sched.c implementation. Makes sense?


Yes, will add new functions with suffix "64"  in rte_approx.[hc].

> The rte_approx.[hc] files represent the implementation of an arithmetic
> algorithm that is completely independent of the scheduler library. In fact, they
> could be moved to a more generic location in DPDK where they could be
> leveraged by other libraries without the need to create a (fake) dependency to
> librte_sched.
> 
> > diff --git a/lib/librte_sched/rte_sched.c
> > b/lib/librte_sched/rte_sched.c index 710ecf65a..11d1febe2 100644
> > --- a/lib/librte_sched/rte_sched.c
> > +++ b/lib/librte_sched/rte_sched.c
> > @@ -49,13 +49,13 @@
> >
> >  struct rte_sched_pipe_profile {
> >  	/* Token bucket (TB) */
> > -	uint32_t tb_period;
> > -	uint32_t tb_credits_per_period;
> > -	uint32_t tb_size;
> > +	sched_counter_t tb_period;
> > +	sched_counter_t tb_credits_per_period;
> > +	sched_counter_t tb_size;
> >
> >  	/* Pipe traffic classes */
> > -	uint32_t tc_period;
> > -	uint32_t
> > tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> > +	sched_counter_t tc_period;
> > +	sched_counter_t
> > tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> >  	uint8_t tc_ov_weight;
> >
> >  	/* Pipe best-effort traffic class queues */ @@ -65,20 +65,20 @@
> > struct rte_sched_pipe_profile {  struct rte_sched_pipe {
> >  	/* Token bucket (TB) */
> >  	uint64_t tb_time; /* time of last update */
> > -	uint32_t tb_credits;
> > +	sched_counter_t tb_credits;
> >
> >  	/* Pipe profile and flags */
> >  	uint32_t profile;
> >
> >  	/* Traffic classes (TCs) */
> >  	uint64_t tc_time; /* time of next update */
> > -	uint32_t tc_credits[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> > +	sched_counter_t
> > tc_credits[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> >
> >  	/* Weighted Round Robin (WRR) */
> >  	uint8_t wrr_tokens[RTE_SCHED_BE_QUEUES_PER_PIPE];
> >
> >  	/* TC oversubscription */
> > -	uint32_t tc_ov_credits;
> > +	sched_counter_t tc_ov_credits;
> >  	uint8_t tc_ov_period_id;
> >  } __rte_cache_aligned;
> >
> > @@ -141,28 +141,28 @@ struct rte_sched_grinder {  struct
> > rte_sched_subport {
> >  	/* Token bucket (TB) */
> >  	uint64_t tb_time; /* time of last update */
> > -	uint32_t tb_period;
> > -	uint32_t tb_credits_per_period;
> > -	uint32_t tb_size;
> > -	uint32_t tb_credits;
> > +	sched_counter_t tb_period;
> > +	sched_counter_t tb_credits_per_period;
> > +	sched_counter_t tb_size;
> > +	sched_counter_t tb_credits;
> >
> >  	/* Traffic classes (TCs) */
> >  	uint64_t tc_time; /* time of next update */
> > -	uint32_t
> > tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> > -	uint32_t tc_credits[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> > -	uint32_t tc_period;
> > +	sched_counter_t
> > tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> > +	sched_counter_t
> > tc_credits[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> > +	sched_counter_t tc_period;
> >
> >  	/* TC oversubscription */
> > -	uint32_t tc_ov_wm;
> > -	uint32_t tc_ov_wm_min;
> > -	uint32_t tc_ov_wm_max;
> > +	sched_counter_t tc_ov_wm;
> > +	sched_counter_t tc_ov_wm_min;
> > +	sched_counter_t tc_ov_wm_max;
> >  	uint8_t tc_ov_period_id;
> >  	uint8_t tc_ov;
> >  	uint32_t tc_ov_n;
> >  	double tc_ov_rate;
> >
> >  	/* Statistics */
> > -	struct rte_sched_subport_stats stats;
> > +	struct rte_sched_subport_stats stats __rte_cache_aligned;
> >
> >  	/* Subport pipes */
> >  	uint32_t n_pipes_per_subport_enabled; @@ -170,7 +170,7 @@ struct
> > rte_sched_subport {
> >  	uint32_t n_max_pipe_profiles;
> >
> >  	/* Pipe best-effort TC rate */
> > -	uint32_t pipe_tc_be_rate_max;
> > +	sched_counter_t pipe_tc_be_rate_max;
> >
> >  	/* Pipe queues size */
> >  	uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> > @@ -212,7 +212,7 @@ struct rte_sched_port {
> >  	uint16_t pipe_queue[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> >  	uint8_t pipe_tc[RTE_SCHED_QUEUES_PER_PIPE];
> >  	uint8_t tc_queue[RTE_SCHED_QUEUES_PER_PIPE];
> > -	uint32_t rate;
> > +	sched_counter_t rate;
> >  	uint32_t mtu;
> >  	uint32_t frame_overhead;
> >  	int socket;
> > @@ -517,33 +517,35 @@ rte_sched_port_log_pipe_profile(struct
> > rte_sched_subport *subport, uint32_t i)
> >  	struct rte_sched_pipe_profile *p = subport->pipe_profiles + i;
> >
> >  	RTE_LOG(DEBUG, SCHED, "Low level config for pipe profile %u:\n"
> > -		"	Token bucket: period = %u, credits per period = %u,
> > size = %u\n"
> > -		"	Traffic classes: period = %u,\n"
> > -		"	credits per period = [%u, %u, %u, %u, %u, %u, %u,
> > %u, %u, %u, %u, %u, %u]\n"
> > +		"	Token bucket: period = %"PRIu64", credits per period
> > = %"PRIu64", size = %"PRIu64"\n"
> > +		"	Traffic classes: period = %"PRIu64",\n"
> > +		"	credits per period = [%"PRIu64", %"PRIu64",
> > %"PRIu64", %"PRIu64
> > +		", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64",
> > %"PRIu64
> > +		", %"PRIu64", %"PRIu64", %"PRIu64"]\n"
> >  		"	Best-effort traffic class oversubscription: weight =
> > %hhu\n"
> >  		"	WRR cost: [%hhu, %hhu, %hhu, %hhu]\n",
> >  		i,
> >
> >  		/* Token bucket */
> > -		p->tb_period,
> > -		p->tb_credits_per_period,
> > -		p->tb_size,
> > +		(uint64_t)p->tb_period,
> > +		(uint64_t)p->tb_credits_per_period,
> > +		(uint64_t)p->tb_size,
> >
> >  		/* Traffic classes */
> > -		p->tc_period,
> > -		p->tc_credits_per_period[0],
> > -		p->tc_credits_per_period[1],
> > -		p->tc_credits_per_period[2],
> > -		p->tc_credits_per_period[3],
> > -		p->tc_credits_per_period[4],
> > -		p->tc_credits_per_period[5],
> > -		p->tc_credits_per_period[6],
> > -		p->tc_credits_per_period[7],
> > -		p->tc_credits_per_period[8],
> > -		p->tc_credits_per_period[9],
> > -		p->tc_credits_per_period[10],
> > -		p->tc_credits_per_period[11],
> > -		p->tc_credits_per_period[12],
> > +		(uint64_t)p->tc_period,
> > +		(uint64_t)p->tc_credits_per_period[0],
> > +		(uint64_t)p->tc_credits_per_period[1],
> > +		(uint64_t)p->tc_credits_per_period[2],
> > +		(uint64_t)p->tc_credits_per_period[3],
> > +		(uint64_t)p->tc_credits_per_period[4],
> > +		(uint64_t)p->tc_credits_per_period[5],
> > +		(uint64_t)p->tc_credits_per_period[6],
> > +		(uint64_t)p->tc_credits_per_period[7],
> > +		(uint64_t)p->tc_credits_per_period[8],
> > +		(uint64_t)p->tc_credits_per_period[9],
> > +		(uint64_t)p->tc_credits_per_period[10],
> > +		(uint64_t)p->tc_credits_per_period[11],
> > +		(uint64_t)p->tc_credits_per_period[12],
> >
> >  		/* Best-effort traffic class oversubscription */
> >  		p->tc_ov_weight,
> > @@ -553,7 +555,7 @@ rte_sched_port_log_pipe_profile(struct
> > rte_sched_subport *subport, uint32_t i)  }
> >
> >  static inline uint64_t
> > -rte_sched_time_ms_to_bytes(uint32_t time_ms, uint32_t rate)
> > +rte_sched_time_ms_to_bytes(sched_counter_t time_ms,
> > sched_counter_t rate)
> >  {
> >  	uint64_t time = time_ms;
> >
> > @@ -566,7 +568,7 @@ static void
> >  rte_sched_pipe_profile_convert(struct rte_sched_subport *subport,
> >  	struct rte_sched_pipe_params *src,
> >  	struct rte_sched_pipe_profile *dst,
> > -	uint32_t rate)
> > +	sched_counter_t rate)
> >  {
> >  	uint32_t wrr_cost[RTE_SCHED_BE_QUEUES_PER_PIPE];
> >  	uint32_t lcd1, lcd2, lcd;
> > @@ -581,8 +583,8 @@ rte_sched_pipe_profile_convert(struct
> > rte_sched_subport *subport,
> >  				/ (double) rate;
> >  		double d = RTE_SCHED_TB_RATE_CONFIG_ERR;
> >
> > -		rte_approx(tb_rate, d,
> > -			&dst->tb_credits_per_period, &dst->tb_period);
> > +		rte_approx(tb_rate, d, &dst->tb_credits_per_period,
> > +			&dst->tb_period);
> >  	}
> >
> >  	dst->tb_size = src->tb_size;
> > @@ -594,8 +596,8 @@ rte_sched_pipe_profile_convert(struct
> > rte_sched_subport *subport,
> >  	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
> >  		if (subport->qsize[i])
> >  			dst->tc_credits_per_period[i]
> > -				= rte_sched_time_ms_to_bytes(src-
> > >tc_period,
> > -					src->tc_rate[i]);
> > +				= (sched_counter_t)
> > rte_sched_time_ms_to_bytes(
> > +					src->tc_period, src->tc_rate[i]);
> >
> >  	dst->tc_ov_weight = src->tc_ov_weight;
> >
> > @@ -637,7 +639,8 @@ rte_sched_subport_config_pipe_profile_table(struct
> > rte_sched_subport *subport,
> >  	subport->pipe_tc_be_rate_max = 0;
> >  	for (i = 0; i < subport->n_pipe_profiles; i++) {
> >  		struct rte_sched_pipe_params *src = params->pipe_profiles
> > + i;
> > -		uint32_t pipe_tc_be_rate = src-
> > >tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE];
> > +		sched_counter_t pipe_tc_be_rate =
> > +			src->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE];
> >
> >  		if (subport->pipe_tc_be_rate_max < pipe_tc_be_rate)
> >  			subport->pipe_tc_be_rate_max = pipe_tc_be_rate;
> @@ -647,7 +650,7
> > @@ rte_sched_subport_config_pipe_profile_table(struct
> > rte_sched_subport *subport,
> >  static int
> >  rte_sched_subport_check_params(struct rte_sched_subport_params
> > *params,
> >  	uint32_t n_max_pipes_per_subport,
> > -	uint32_t rate)
> > +	sched_counter_t rate)
> >  {
> >  	uint32_t i;
> >
> > @@ -684,7 +687,7 @@ rte_sched_subport_check_params(struct
> > rte_sched_subport_params *params,
> >  	}
> >
> >  	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
> > -		uint32_t tc_rate = params->tc_rate[i];
> > +		sched_counter_t tc_rate = params->tc_rate[i];
> >  		uint16_t qsize = params->qsize[i];
> >
> >  		if ((qsize == 0 && tc_rate != 0) || @@ -910,36 +913,40 @@
> > rte_sched_port_log_subport_config(struct
> > rte_sched_port *port, uint32_t i)
> >  	struct rte_sched_subport *s = port->subports[i];
> >
> >  	RTE_LOG(DEBUG, SCHED, "Low level config for subport %u:\n"
> > -		"	Token bucket: period = %u, credits per period = %u,
> > size = %u\n"
> > -		"	Traffic classes: period = %u\n"
> > -		"	credits per period = [%u, %u, %u, %u, %u, %u, %u,
> > %u, %u, %u, %u, %u, %u]\n"
> > -		"	Best effort traffic class oversubscription: wm min =
> > %u, wm max = %u\n",
> > +		"	Token bucket: period = %"PRIu64", credits per period
> > = %"PRIu64
> > +		", size = %"PRIu64"\n"
> > +		"	Traffic classes: period = %"PRIu64"\n"
> > +		"	credits per period = [%"PRIu64", %"PRIu64",
> > %"PRIu64", %"PRIu64
> > +		", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64",
> > %"PRIu64
> > +		", %"PRIu64", %"PRIu64", %"PRIu64"]\n"
> > +		"	Best effort traffic class oversubscription: wm min =
> > %"PRIu64
> > +		", wm max = %"PRIu64"\n",
> >  		i,
> >
> >  		/* Token bucket */
> > -		s->tb_period,
> > -		s->tb_credits_per_period,
> > -		s->tb_size,
> > +		(uint64_t)s->tb_period,
> > +		(uint64_t)s->tb_credits_per_period,
> > +		(uint64_t)s->tb_size,
> >
> >  		/* Traffic classes */
> > -		s->tc_period,
> > -		s->tc_credits_per_period[0],
> > -		s->tc_credits_per_period[1],
> > -		s->tc_credits_per_period[2],
> > -		s->tc_credits_per_period[3],
> > -		s->tc_credits_per_period[4],
> > -		s->tc_credits_per_period[5],
> > -		s->tc_credits_per_period[6],
> > -		s->tc_credits_per_period[7],
> > -		s->tc_credits_per_period[8],
> > -		s->tc_credits_per_period[9],
> > -		s->tc_credits_per_period[10],
> > -		s->tc_credits_per_period[11],
> > -		s->tc_credits_per_period[12],
> > +		(uint64_t)s->tc_period,
> > +		(uint64_t)s->tc_credits_per_period[0],
> > +		(uint64_t)s->tc_credits_per_period[1],
> > +		(uint64_t)s->tc_credits_per_period[2],
> > +		(uint64_t)s->tc_credits_per_period[3],
> > +		(uint64_t)s->tc_credits_per_period[4],
> > +		(uint64_t)s->tc_credits_per_period[5],
> > +		(uint64_t)s->tc_credits_per_period[6],
> > +		(uint64_t)s->tc_credits_per_period[7],
> > +		(uint64_t)s->tc_credits_per_period[8],
> > +		(uint64_t)s->tc_credits_per_period[9],
> > +		(uint64_t)s->tc_credits_per_period[10],
> > +		(uint64_t)s->tc_credits_per_period[11],
> > +		(uint64_t)s->tc_credits_per_period[12],
> >
> >  		/* Best effort traffic class oversubscription */
> > -		s->tc_ov_wm_min,
> > -		s->tc_ov_wm_max);
> > +		(uint64_t)s->tc_ov_wm_min,
> > +		(uint64_t)s->tc_ov_wm_max);
> >  }
> >
> >  static void
> > @@ -1023,7 +1030,8 @@ rte_sched_subport_config(struct rte_sched_port
> > *port,
> >  		double tb_rate = ((double) params->tb_rate) / ((double)
> > port->rate);
> >  		double d = RTE_SCHED_TB_RATE_CONFIG_ERR;
> >
> > -		rte_approx(tb_rate, d, &s->tb_credits_per_period, &s-
> > >tb_period);
> > +		rte_approx(tb_rate, d, &s->tb_credits_per_period,
> > +			&s->tb_period);
> >  	}
> >
> >  	s->tb_size = params->tb_size;
> > @@ -1035,8 +1043,8 @@ rte_sched_subport_config(struct rte_sched_port
> > *port,
> >  	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
> >  		if (params->qsize[i])
> >  			s->tc_credits_per_period[i]
> > -				= rte_sched_time_ms_to_bytes(params-
> > >tc_period,
> > -					params->tc_rate[i]);
> > +				= (sched_counter_t)
> > rte_sched_time_ms_to_bytes(
> > +					params->tc_period, params-
> > >tc_rate[i]);
> >  	}
> >  	s->tc_time = port->time + s->tc_period;
> >  	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) @@ -
> 1970,13
> > +1978,15 @@ grinder_credits_update(struct rte_sched_port *port,
> >  	/* Subport TB */
> >  	n_periods = (port->time - subport->tb_time) / subport->tb_period;
> >  	subport->tb_credits += n_periods * subport-
> > >tb_credits_per_period;
> > -	subport->tb_credits = rte_sched_min_val_2_u32(subport-
> > >tb_credits, subport->tb_size);
> > +	subport->tb_credits = rte_sched_min_val_2(subport->tb_credits,
> > +				subport->tb_size);
> >  	subport->tb_time += n_periods * subport->tb_period;
> >
> >  	/* Pipe TB */
> >  	n_periods = (port->time - pipe->tb_time) / params->tb_period;
> >  	pipe->tb_credits += n_periods * params->tb_credits_per_period;
> > -	pipe->tb_credits = rte_sched_min_val_2_u32(pipe->tb_credits,
> > params->tb_size);
> > +	pipe->tb_credits = rte_sched_min_val_2(pipe->tb_credits,
> > +				params->tb_size);
> 
> Can we remove all the usages of rte_sched_min_val() (including its definition in
> rte_sched_common.h) and replace it with RTE_MIN, please?
> 
> >  	pipe->tb_time += n_periods * params->tb_period;
> >
> >  	/* Subport TCs */
> > @@ -1998,13 +2008,13 @@ grinder_credits_update(struct rte_sched_port
> > *port,
> >
> >  #else
> >
> > -static inline uint32_t
> > +static inline sched_counter_t
> >  grinder_tc_ov_credits_update(struct rte_sched_port *port,
> >  	struct rte_sched_subport *subport)
> >  {
> > -	uint32_t
> > tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> > -	uint32_t tc_consumption = 0, tc_ov_consumption_max;
> > -	uint32_t tc_ov_wm = subport->tc_ov_wm;
> > +	sched_counter_t
> > tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> > +	sched_counter_t tc_consumption = 0, tc_ov_consumption_max;
> > +	sched_counter_t tc_ov_wm = subport->tc_ov_wm;
> >  	uint32_t i;
> >
> >  	if (subport->tc_ov == 0)
> > @@ -2053,13 +2063,15 @@ grinder_credits_update(struct rte_sched_port
> > *port,
> >  	/* Subport TB */
> >  	n_periods = (port->time - subport->tb_time) / subport->tb_period;
> >  	subport->tb_credits += n_periods * subport-
> > >tb_credits_per_period;
> > -	subport->tb_credits = rte_sched_min_val_2_u32(subport-
> > >tb_credits, subport->tb_size);
> > +	subport->tb_credits = rte_sched_min_val_2(subport->tb_credits,
> > +				subport->tb_size);
> >  	subport->tb_time += n_periods * subport->tb_period;
> >
> >  	/* Pipe TB */
> >  	n_periods = (port->time - pipe->tb_time) / params->tb_period;
> >  	pipe->tb_credits += n_periods * params->tb_credits_per_period;
> > -	pipe->tb_credits = rte_sched_min_val_2_u32(pipe->tb_credits,
> > params->tb_size);
> > +	pipe->tb_credits = rte_sched_min_val_2(pipe->tb_credits,
> > +				params->tb_size);
> >  	pipe->tb_time += n_periods * params->tb_period;
> >
> >  	/* Subport TCs */
> > @@ -2101,11 +2113,11 @@ grinder_credits_check(struct rte_sched_port
> > *port,
> >  	struct rte_sched_pipe *pipe = grinder->pipe;
> >  	struct rte_mbuf *pkt = grinder->pkt;
> >  	uint32_t tc_index = grinder->tc_index;
> > -	uint32_t pkt_len = pkt->pkt_len + port->frame_overhead;
> > -	uint32_t subport_tb_credits = subport->tb_credits;
> > -	uint32_t subport_tc_credits = subport->tc_credits[tc_index];
> > -	uint32_t pipe_tb_credits = pipe->tb_credits;
> > -	uint32_t pipe_tc_credits = pipe->tc_credits[tc_index];
> > +	sched_counter_t pkt_len = pkt->pkt_len + port->frame_overhead;
> > +	sched_counter_t subport_tb_credits = subport->tb_credits;
> > +	sched_counter_t subport_tc_credits = subport-
> > >tc_credits[tc_index];
> > +	sched_counter_t pipe_tb_credits = pipe->tb_credits;
> > +	sched_counter_t pipe_tc_credits = pipe->tc_credits[tc_index];
> >  	int enough_credits;
> >
> >  	/* Check queue credits */
> > @@ -2136,21 +2148,22 @@ grinder_credits_check(struct rte_sched_port
> > *port,
> >  	struct rte_sched_pipe *pipe = grinder->pipe;
> >  	struct rte_mbuf *pkt = grinder->pkt;
> >  	uint32_t tc_index = grinder->tc_index;
> > -	uint32_t pkt_len = pkt->pkt_len + port->frame_overhead;
> > -	uint32_t subport_tb_credits = subport->tb_credits;
> > -	uint32_t subport_tc_credits = subport->tc_credits[tc_index];
> > -	uint32_t pipe_tb_credits = pipe->tb_credits;
> > -	uint32_t pipe_tc_credits = pipe->tc_credits[tc_index];
> > -	uint32_t
> > pipe_tc_ov_mask1[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> > -	uint32_t
> > pipe_tc_ov_mask2[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE] = {0};
> > -	uint32_t pipe_tc_ov_credits, i;
> > +	sched_counter_t pkt_len = pkt->pkt_len + port->frame_overhead;
> > +	sched_counter_t subport_tb_credits = subport->tb_credits;
> > +	sched_counter_t subport_tc_credits = subport-
> > >tc_credits[tc_index];
> > +	sched_counter_t pipe_tb_credits = pipe->tb_credits;
> > +	sched_counter_t pipe_tc_credits = pipe->tc_credits[tc_index];
> > +	sched_counter_t
> > pipe_tc_ov_mask1[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
> > +	sched_counter_t
> > pipe_tc_ov_mask2[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE] = {0};
> > +	sched_counter_t pipe_tc_ov_credits;
> > +	uint32_t i;
> >  	int enough_credits;
> >
> >  	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
> > -		pipe_tc_ov_mask1[i] = UINT32_MAX;
> > +		pipe_tc_ov_mask1[i] = ~0;
> 
> Please use ~0LLU (or UINT64_MAX) to cover the 64-bit case gracefully. Please
> also double-check that there are no usages of UINT32_MAX left in this code,
> unless there is a reason for it. Translation from 32-bit to 64-bit arithmetic can
> be very tricky and yield some very difficult to debug issues.


Ok, will make this change. Also will make sure the there are no usage of UINT32_MAX left.


> >
> >  	pipe_tc_ov_mask1[RTE_SCHED_TRAFFIC_CLASS_BE] = pipe-
> > >tc_ov_credits;
> > -	pipe_tc_ov_mask2[RTE_SCHED_TRAFFIC_CLASS_BE] =
> > UINT32_MAX;
> > +	pipe_tc_ov_mask2[RTE_SCHED_TRAFFIC_CLASS_BE] = ~0;
> >  	pipe_tc_ov_credits = pipe_tc_ov_mask1[tc_index];
> >
> >  	/* Check pipe and subport credits */ diff --git
> > a/lib/librte_sched/rte_sched_common.h
> > b/lib/librte_sched/rte_sched_common.h
> > index 8c191a9b8..06520a686 100644
> > --- a/lib/librte_sched/rte_sched_common.h
> > +++ b/lib/librte_sched/rte_sched_common.h
> > @@ -14,8 +14,16 @@ extern "C" {
> >
> >  #define __rte_aligned_16 __attribute__((__aligned__(16)))
> >
> > -static inline uint32_t
> > -rte_sched_min_val_2_u32(uint32_t x, uint32_t y)
> > +//#define COUNTER_SIZE_64
> > +
> > +#ifdef COUNTER_SIZE_64
> > +typedef uint64_t sched_counter_t;
> > +#else
> > +typedef uint32_t sched_counter_t;
> > +#endif
> > +
> > +static inline sched_counter_t
> > +rte_sched_min_val_2(sched_counter_t x, sched_counter_t y)
> >  {
> >  	return (x < y)? x : y;
> >  }
> > --
> > 2.21.0
> 
> I know I have previously suggested the creation of sched_counter_t, but this
> was meant to be a temporary solution until the full implementation is made
> available. Now that 19.11 is meant to be an ABI stable release, we cannot
> really afford this trick (which might not be necessary either, since you have the
> full implementation), as this #ifdef COUNTER_SIZE is a massive ABI breakage.
> 
> Therefore, I strongly suggest we remove the sched_counter_t and use uint64_t
> everywhere throughout the implementation. Agree?

Yes, will make changes.
Thank you for the detailed review. I'll send revised version. 

Regards,
Jasvinder


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

* [dpdk-dev] [PATCH v2 1/2] sched: add support for 64 bit values
  2019-10-14 17:24 [dpdk-dev] [PATCH 1/2] sched: add support for 64 bit values Jasvinder Singh
  2019-10-14 17:24 ` [dpdk-dev] [PATCH 2/2] sched: modify internal structs and functions " Jasvinder Singh
  2019-10-15 15:27 ` [dpdk-dev] [PATCH 1/2] sched: add support " Dumitrescu, Cristian
@ 2019-10-16 14:17 ` Jasvinder Singh
  2019-10-16 14:17   ` [dpdk-dev] [PATCH v2 2/2] sched: modify internal structs and functions " Jasvinder Singh
  2 siblings, 1 reply; 9+ messages in thread
From: Jasvinder Singh @ 2019-10-16 14:17 UTC (permalink / raw)
  To: dev; +Cc: cristian.dumitrescu, Lukasz Krakowiak

To support high bandwidth network interfaces, all rates (port,
subport level token bucket and traffic class rates, pipe level
token bucket and traffic class rates) and stats counters defined
in public data structures (rte_sched.h) are modified to support
64 bit counters.

Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
v2: 
Please note that this patch has dependency on patchset at 
https://mails.dpdk.org/archives/dev/2019-October/147015.html

 examples/ip_pipeline/cli.c    | 18 +++++-----
 examples/ip_pipeline/tmgr.h   |  2 +-
 examples/qos_sched/cfg_file.c | 64 +++++++++++++++++------------------
 examples/qos_sched/stats.c    |  6 ++--
 lib/librte_sched/rte_sched.h  | 38 ++++++++++-----------
 5 files changed, 64 insertions(+), 64 deletions(-)

diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c
index c72030682..3e23f4e7b 100644
--- a/examples/ip_pipeline/cli.c
+++ b/examples/ip_pipeline/cli.c
@@ -414,23 +414,23 @@ cmd_tmgr_subport_profile(char **tokens,
 		return;
 	}
 
-	if (parser_read_uint32(&p.tb_rate, tokens[3]) != 0) {
+	if (parser_read_uint64(&p.tb_rate, tokens[3]) != 0) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "tb_rate");
 		return;
 	}
 
-	if (parser_read_uint32(&p.tb_size, tokens[4]) != 0) {
+	if (parser_read_uint64(&p.tb_size, tokens[4]) != 0) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "tb_size");
 		return;
 	}
 
 	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
-		if (parser_read_uint32(&p.tc_rate[i], tokens[5 + i]) != 0) {
+		if (parser_read_uint64(&p.tc_rate[i], tokens[5 + i]) != 0) {
 			snprintf(out, out_size, MSG_ARG_INVALID, "tc_rate");
 			return;
 		}
 
-	if (parser_read_uint32(&p.tc_period, tokens[18]) != 0) {
+	if (parser_read_uint64(&p.tc_period, tokens[18]) != 0) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "tc_period");
 		return;
 	}
@@ -487,23 +487,23 @@ cmd_tmgr_pipe_profile(char **tokens,
 		return;
 	}
 
-	if (parser_read_uint32(&p.tb_rate, tokens[3]) != 0) {
+	if (parser_read_uint64(&p.tb_rate, tokens[3]) != 0) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "tb_rate");
 		return;
 	}
 
-	if (parser_read_uint32(&p.tb_size, tokens[4]) != 0) {
+	if (parser_read_uint64(&p.tb_size, tokens[4]) != 0) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "tb_size");
 		return;
 	}
 
 	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
-		if (parser_read_uint32(&p.tc_rate[i], tokens[5 + i]) != 0) {
+		if (parser_read_uint64(&p.tc_rate[i], tokens[5 + i]) != 0) {
 			snprintf(out, out_size, MSG_ARG_INVALID, "tc_rate");
 			return;
 		}
 
-	if (parser_read_uint32(&p.tc_period, tokens[18]) != 0) {
+	if (parser_read_uint64(&p.tc_period, tokens[18]) != 0) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "tc_period");
 		return;
 	}
@@ -556,7 +556,7 @@ cmd_tmgr(char **tokens,
 		return;
 	}
 
-	if (parser_read_uint32(&p.rate, tokens[3]) != 0) {
+	if (parser_read_uint64(&p.rate, tokens[3]) != 0) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "rate");
 		return;
 	}
diff --git a/examples/ip_pipeline/tmgr.h b/examples/ip_pipeline/tmgr.h
index 1fcf66ee1..ee50cf7cc 100644
--- a/examples/ip_pipeline/tmgr.h
+++ b/examples/ip_pipeline/tmgr.h
@@ -40,7 +40,7 @@ struct tmgr_port *
 tmgr_port_find(const char *name);
 
 struct tmgr_port_params {
-	uint32_t rate;
+	uint64_t rate;
 	uint32_t n_subports_per_port;
 	uint32_t frame_overhead;
 	uint32_t mtu;
diff --git a/examples/qos_sched/cfg_file.c b/examples/qos_sched/cfg_file.c
index c6d3f5ab6..5714c3f36 100644
--- a/examples/qos_sched/cfg_file.c
+++ b/examples/qos_sched/cfg_file.c
@@ -59,67 +59,67 @@ cfg_load_pipe(struct rte_cfgfile *cfg, struct rte_sched_pipe_params *pipe_params
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tb rate");
 		if (entry)
-			pipe_params[j].tb_rate = (uint32_t)atoi(entry);
+			pipe_params[j].tb_rate = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tb size");
 		if (entry)
-			pipe_params[j].tb_size = (uint32_t)atoi(entry);
+			pipe_params[j].tb_size = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc period");
 		if (entry)
-			pipe_params[j].tc_period = (uint32_t)atoi(entry);
+			pipe_params[j].tc_period = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 0 rate");
 		if (entry)
-			pipe_params[j].tc_rate[0] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[0] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 1 rate");
 		if (entry)
-			pipe_params[j].tc_rate[1] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[1] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 2 rate");
 		if (entry)
-			pipe_params[j].tc_rate[2] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[2] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 3 rate");
 		if (entry)
-			pipe_params[j].tc_rate[3] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[3] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 4 rate");
 		if (entry)
-			pipe_params[j].tc_rate[4] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[4] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 5 rate");
 		if (entry)
-			pipe_params[j].tc_rate[5] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[5] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 6 rate");
 		if (entry)
-			pipe_params[j].tc_rate[6] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[6] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 7 rate");
 		if (entry)
-			pipe_params[j].tc_rate[7] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[7] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 8 rate");
 		if (entry)
-			pipe_params[j].tc_rate[8] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[8] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 9 rate");
 		if (entry)
-			pipe_params[j].tc_rate[9] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[9] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 10 rate");
 		if (entry)
-			pipe_params[j].tc_rate[10] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[10] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 11 rate");
 		if (entry)
-			pipe_params[j].tc_rate[11] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[11] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 12 rate");
 		if (entry)
-			pipe_params[j].tc_rate[12] = (uint32_t)atoi(entry);
+			pipe_params[j].tc_rate[12] = (uint64_t)atoi(entry);
 
 		entry = rte_cfgfile_get_entry(cfg, pipe_name, "tc 12 oversubscription weight");
 		if (entry)
@@ -266,67 +266,67 @@ cfg_load_subport(struct rte_cfgfile *cfg, struct rte_sched_subport_params *subpo
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tb rate");
 			if (entry)
-				subport_params[i].tb_rate = (uint32_t)atoi(entry);
+				subport_params[i].tb_rate = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tb size");
 			if (entry)
-				subport_params[i].tb_size = (uint32_t)atoi(entry);
+				subport_params[i].tb_size = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc period");
 			if (entry)
-				subport_params[i].tc_period = (uint32_t)atoi(entry);
+				subport_params[i].tc_period = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 0 rate");
 			if (entry)
-				subport_params[i].tc_rate[0] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[0] = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 1 rate");
 			if (entry)
-				subport_params[i].tc_rate[1] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[1] = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 2 rate");
 			if (entry)
-				subport_params[i].tc_rate[2] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[2] = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 3 rate");
 			if (entry)
-				subport_params[i].tc_rate[3] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[3] = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 4 rate");
 			if (entry)
-				subport_params[i].tc_rate[4] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[4] = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 5 rate");
 			if (entry)
-				subport_params[i].tc_rate[5] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[5] = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 6 rate");
 			if (entry)
-				subport_params[i].tc_rate[6] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[6] = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 7 rate");
 			if (entry)
-				subport_params[i].tc_rate[7] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[7] = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 8 rate");
 			if (entry)
-				subport_params[i].tc_rate[8] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[8] = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 9 rate");
 			if (entry)
-				subport_params[i].tc_rate[9] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[9] = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 10 rate");
 			if (entry)
-				subport_params[i].tc_rate[10] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[10] = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 11 rate");
 			if (entry)
-				subport_params[i].tc_rate[11] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[11] = (uint64_t)atoi(entry);
 
 			entry = rte_cfgfile_get_entry(cfg, sec_name, "tc 12 rate");
 			if (entry)
-				subport_params[i].tc_rate[12] = (uint32_t)atoi(entry);
+				subport_params[i].tc_rate[12] = (uint64_t)atoi(entry);
 
 			int n_entries = rte_cfgfile_section_num_entries(cfg, sec_name);
 			struct rte_cfgfile_entry entries[n_entries];
diff --git a/examples/qos_sched/stats.c b/examples/qos_sched/stats.c
index ce34b6c7c..161f086f1 100644
--- a/examples/qos_sched/stats.c
+++ b/examples/qos_sched/stats.c
@@ -307,7 +307,7 @@ subport_stat(uint16_t port_id, uint32_t subport_id)
 	printf("+----+-------------+-------------+-------------+-------------+-------------+\n");
 
 	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
-		printf("|  %d | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " |\n",
+		printf("|  %d | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu32 " |\n",
 			i, stats.n_pkts_tc[i], stats.n_pkts_tc_dropped[i],
 		stats.n_bytes_tc[i], stats.n_bytes_tc_dropped[i], tc_ov[i]);
 		printf("+----+-------------+-------------+-------------+-------------+-------------+\n");
@@ -351,7 +351,7 @@ pipe_stat(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id)
 	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
 		if (i < RTE_SCHED_TRAFFIC_CLASS_BE) {
 			rte_sched_queue_read_stats(port, queue_id + i, &stats, &qlen);
-			printf("|  %d |   %d   | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " | %11i |\n",
+			printf("|  %d |   %d   | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu64 " | %11i |\n",
 				i, 0, stats.n_pkts, stats.n_pkts_dropped, stats.n_bytes,
 				stats.n_bytes_dropped, qlen);
 			printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");
@@ -359,7 +359,7 @@ pipe_stat(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id)
 			for (j = 0; j < RTE_SCHED_BE_QUEUES_PER_PIPE; j++) {
 				rte_sched_queue_read_stats(port, queue_id + i + j,
 					&stats, &qlen);
-				printf("|  %d |   %d   | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " | %11i |\n",
+				printf("|  %d |   %d   | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu64 " | %11i |\n",
 					i, j, stats.n_pkts, stats.n_pkts_dropped, stats.n_bytes,
 					stats.n_bytes_dropped, qlen);
 				printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");
diff --git a/lib/librte_sched/rte_sched.h b/lib/librte_sched/rte_sched.h
index c82c23c14..8a5a93c98 100644
--- a/lib/librte_sched/rte_sched.h
+++ b/lib/librte_sched/rte_sched.h
@@ -121,16 +121,16 @@ extern "C" {
  */
 struct rte_sched_pipe_params {
 	/** Token bucket rate (measured in bytes per second) */
-	uint32_t tb_rate;
+	uint64_t tb_rate;
 
 	/** Token bucket size (measured in credits) */
-	uint32_t tb_size;
+	uint64_t tb_size;
 
 	/** Traffic class rates (measured in bytes per second) */
-	uint32_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 
 	/** Enforcement period (measured in milliseconds) */
-	uint32_t tc_period;
+	uint64_t tc_period;
 
 	/** Best-effort traffic class oversubscription weight */
 	uint8_t tc_ov_weight;
@@ -150,16 +150,16 @@ struct rte_sched_pipe_params {
  */
 struct rte_sched_subport_params {
 	/** Token bucket rate (measured in bytes per second) */
-	uint32_t tb_rate;
+	uint64_t tb_rate;
 
 	/** Token bucket size (measured in credits) */
-	uint32_t tb_size;
+	uint64_t tb_size;
 
 	/** Traffic class rates (measured in bytes per second) */
-	uint32_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 
 	/** Enforcement period for rates (measured in milliseconds) */
-	uint32_t tc_period;
+	uint64_t tc_period;
 
 	/** Number of subport pipes.
 	 * The subport can enable/allocate fewer pipes than the maximum
@@ -195,41 +195,41 @@ struct rte_sched_subport_params {
 /** Subport statistics */
 struct rte_sched_subport_stats {
 	/** Number of packets successfully written */
-	uint32_t n_pkts_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	uint64_t n_pkts_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 
 	/** Number of packets dropped */
-	uint32_t n_pkts_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	uint64_t n_pkts_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 
 	/** Number of bytes successfully written for each traffic class */
-	uint32_t n_bytes_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	uint64_t n_bytes_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 
 	/** Number of bytes dropped for each traffic class */
-	uint32_t n_bytes_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	uint64_t n_bytes_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 
 #ifdef RTE_SCHED_RED
 	/** Number of packets dropped by red */
-	uint32_t n_pkts_red_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	uint64_t n_pkts_red_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 #endif
 };
 
 /** Queue statistics */
 struct rte_sched_queue_stats {
 	/** Packets successfully written */
-	uint32_t n_pkts;
+	uint64_t n_pkts;
 
 	/** Packets dropped */
-	uint32_t n_pkts_dropped;
+	uint64_t n_pkts_dropped;
 
 #ifdef RTE_SCHED_RED
 	/** Packets dropped by RED */
-	uint32_t n_pkts_red_dropped;
+	uint64_t n_pkts_red_dropped;
 #endif
 
 	/** Bytes successfully written */
-	uint32_t n_bytes;
+	uint64_t n_bytes;
 
 	/** Bytes dropped */
-	uint32_t n_bytes_dropped;
+	uint64_t n_bytes_dropped;
 };
 
 /** Port configuration parameters. */
@@ -241,7 +241,7 @@ struct rte_sched_port_params {
 	int socket;
 
 	/** Output port rate (measured in bytes per second) */
-	uint32_t rate;
+	uint64_t rate;
 
 	/** Maximum Ethernet frame size (measured in bytes).
 	 * Should not include the framing overhead.
-- 
2.21.0


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

* [dpdk-dev] [PATCH v2 2/2] sched: modify internal structs and functions for 64 bit values
  2019-10-16 14:17 ` [dpdk-dev] [PATCH v2 " Jasvinder Singh
@ 2019-10-16 14:17   ` Jasvinder Singh
  2019-10-16 15:14     ` Dumitrescu, Cristian
  0 siblings, 1 reply; 9+ messages in thread
From: Jasvinder Singh @ 2019-10-16 14:17 UTC (permalink / raw)
  To: dev; +Cc: cristian.dumitrescu, Lukasz Krakowiak

Modify internal structure and functions to support 64-bit
values for rates and stats parameters.

Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
---
v2:
- remove rte_sched_min_val_2_u32() from rte_sched_common.h
- replace rte_sched_min_val_2_u32() by RTE_MIN in rte_sched.c
- replace sched_counter_t by uint64_t
- add 64 bit version of rte_approx

 lib/librte_sched/rte_approx.c       | 153 ++++++++++++++++++++++++++++
 lib/librte_sched/rte_approx.h       |  18 ++++
 lib/librte_sched/rte_sched.c        | 125 ++++++++++++-----------
 lib/librte_sched/rte_sched_common.h |   6 --
 4 files changed, 237 insertions(+), 65 deletions(-)

diff --git a/lib/librte_sched/rte_approx.c b/lib/librte_sched/rte_approx.c
index 30620b83d..edc8d9113 100644
--- a/lib/librte_sched/rte_approx.c
+++ b/lib/librte_sched/rte_approx.c
@@ -165,3 +165,156 @@ int rte_approx(double alpha, double d, uint32_t *p, uint32_t *q)
 	/* Perform approximation */
 	return find_best_rational_approximation(alpha_num, d_num, denum, p, q);
 }
+
+/* fraction comparison (64 bit version): compare (a/b) and (c/d) */
+static inline uint64_t
+less_64(uint64_t a, uint64_t b, uint64_t c, uint64_t d)
+{
+	return a*d < b*c;
+}
+
+static inline uint64_t
+less_or_equal_64(uint64_t a, uint64_t b, uint64_t c, uint64_t d)
+{
+	return a*d <= b*c;
+}
+
+/* check whether a/b is a valid approximation (64 bit version) */
+static inline uint64_t
+matches_64(uint64_t a, uint64_t b,
+	uint64_t alpha_num, uint64_t d_num, uint64_t denum)
+{
+	if (less_or_equal_64(a, b, alpha_num - d_num, denum))
+		return 0;
+
+	if (less_64(a, b, alpha_num + d_num, denum))
+		return 1;
+
+	return 0;
+}
+
+static inline void
+find_exact_solution_left_64(uint64_t p_a, uint64_t q_a, uint64_t p_b, uint64_t q_b,
+	uint64_t alpha_num, uint64_t d_num, uint64_t denum, uint64_t *p, uint64_t *q)
+{
+	uint64_t k_num = denum * p_b - (alpha_num + d_num) * q_b;
+	uint64_t k_denum = (alpha_num + d_num) * q_a - denum * p_a;
+	uint64_t k = (k_num / k_denum) + 1;
+
+	*p = p_b + k * p_a;
+	*q = q_b + k * q_a;
+}
+
+static inline void
+find_exact_solution_right_64(uint64_t p_a, uint64_t q_a, uint64_t p_b, uint64_t q_b,
+	uint64_t alpha_num, uint64_t d_num, uint64_t denum, uint64_t *p, uint64_t *q)
+{
+	uint64_t k_num = -denum * p_b + (alpha_num - d_num) * q_b;
+	uint64_t k_denum = -(alpha_num - d_num) * q_a + denum * p_a;
+	uint64_t k = (k_num / k_denum) + 1;
+
+	*p = p_b + k * p_a;
+	*q = q_b + k * q_a;
+}
+
+static int
+find_best_rational_approximation_64(uint64_t alpha_num, uint64_t d_num,
+	uint64_t denum, uint64_t *p, uint64_t *q)
+{
+	uint64_t p_a, q_a, p_b, q_b;
+
+	/* check assumptions on the inputs */
+	if (!((d_num > 0) && (d_num < alpha_num) &&
+		(alpha_num < denum) && (d_num + alpha_num < denum))) {
+		return -1;
+	}
+
+	/* set initial bounds for the search */
+	p_a = 0;
+	q_a = 1;
+	p_b = 1;
+	q_b = 1;
+
+	while (1) {
+		uint64_t new_p_a, new_q_a, new_p_b, new_q_b;
+		uint64_t x_num, x_denum, x;
+		int aa, bb;
+
+		/* compute the number of steps to the left */
+		x_num = denum * p_b - alpha_num * q_b;
+		x_denum = -denum * p_a + alpha_num * q_a;
+		x = (x_num + x_denum - 1) / x_denum; /* x = ceil(x_num / x_denum) */
+
+		/* check whether we have a valid approximation */
+		aa = matches_64(p_b + x * p_a, q_b + x * q_a, alpha_num, d_num, denum);
+		bb = matches_64(p_b + (x-1) * p_a, q_b + (x - 1) * q_a,
+			alpha_num, d_num, denum);
+		if (aa || bb) {
+			find_exact_solution_left_64(p_a, q_a, p_b, q_b,
+				alpha_num, d_num, denum, p, q);
+			return 0;
+		}
+
+		/* update the interval */
+		new_p_a = p_b + (x - 1) * p_a;
+		new_q_a = q_b + (x - 1) * q_a;
+		new_p_b = p_b + x * p_a;
+		new_q_b = q_b + x * q_a;
+
+		p_a = new_p_a;
+		q_a = new_q_a;
+		p_b = new_p_b;
+		q_b = new_q_b;
+
+		/* compute the number of steps to the right */
+		x_num = alpha_num * q_b - denum * p_b;
+		x_denum = -alpha_num * q_a + denum * p_a;
+		x = (x_num + x_denum - 1) / x_denum; /* x = ceil(x_num / x_denum) */
+
+		/* check whether we have a valid approximation */
+		aa = matches_64(p_b + x * p_a, q_b + x * q_a, alpha_num, d_num, denum);
+		bb = matches_64(p_b + (x - 1) * p_a, q_b + (x - 1) * q_a,
+			alpha_num, d_num, denum);
+		if (aa || bb) {
+			find_exact_solution_right_64(p_a, q_a, p_b, q_b,
+				alpha_num, d_num, denum, p, q);
+			return 0;
+		}
+
+		/* update the interval */
+		new_p_a = p_b + (x - 1) * p_a;
+		new_q_a = q_b + (x - 1) * q_a;
+		new_p_b = p_b + x * p_a;
+		new_q_b = q_b + x * q_a;
+
+		p_a = new_p_a;
+		q_a = new_q_a;
+		p_b = new_p_b;
+		q_b = new_q_b;
+	}
+}
+
+int rte_approx_64(double alpha, double d, uint64_t *p, uint64_t *q)
+{
+	uint64_t alpha_num, d_num, denum;
+
+	/* Check input arguments */
+	if (!((0.0 < d) && (d < alpha) && (alpha < 1.0)))
+		return -1;
+
+	if ((p == NULL) || (q == NULL))
+		return -2;
+
+	/* Compute alpha_num, d_num and denum */
+	denum = 1;
+	while (d < 1) {
+		alpha *= 10;
+		d *= 10;
+		denum *= 10;
+	}
+	alpha_num = (uint64_t) alpha;
+	d_num = (uint64_t) d;
+
+	/* Perform approximation */
+	return find_best_rational_approximation_64(alpha_num, d_num, denum, p, q);
+}
diff --git a/lib/librte_sched/rte_approx.h b/lib/librte_sched/rte_approx.h
index 0244d98f1..74d55f457 100644
--- a/lib/librte_sched/rte_approx.h
+++ b/lib/librte_sched/rte_approx.h
@@ -39,6 +39,24 @@ extern "C" {
  */
 int rte_approx(double alpha, double d, uint32_t *p, uint32_t *q);
 
+/**
+ * Find best rational approximation (64 bit version)
+ *
+ * @param alpha
+ *   Rational number to approximate
+ * @param d
+ *   Precision for the rational approximation
+ * @param p
+ *   Pointer to pre-allocated space where the numerator of the rational
+ *   approximation will be stored when operation is successful
+ * @param q
+ *   Pointer to pre-allocated space where the denominator of the rational
+ *   approximation will be stored when operation is successful
+ * @return
+ *   0 upon success, error code otherwise
+ */
+int rte_approx_64(double alpha, double d, uint64_t *p, uint64_t *q);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c
index 710ecf65a..c0983ddda 100644
--- a/lib/librte_sched/rte_sched.c
+++ b/lib/librte_sched/rte_sched.c
@@ -49,13 +49,13 @@
 
 struct rte_sched_pipe_profile {
 	/* Token bucket (TB) */
-	uint32_t tb_period;
-	uint32_t tb_credits_per_period;
-	uint32_t tb_size;
+	uint64_t tb_period;
+	uint64_t tb_credits_per_period;
+	uint64_t tb_size;
 
 	/* Pipe traffic classes */
-	uint32_t tc_period;
-	uint32_t tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	uint64_t tc_period;
+	uint64_t tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 	uint8_t tc_ov_weight;
 
 	/* Pipe best-effort traffic class queues */
@@ -65,20 +65,20 @@ struct rte_sched_pipe_profile {
 struct rte_sched_pipe {
 	/* Token bucket (TB) */
 	uint64_t tb_time; /* time of last update */
-	uint32_t tb_credits;
+	uint64_t tb_credits;
 
 	/* Pipe profile and flags */
 	uint32_t profile;
 
 	/* Traffic classes (TCs) */
 	uint64_t tc_time; /* time of next update */
-	uint32_t tc_credits[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	uint64_t tc_credits[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 
 	/* Weighted Round Robin (WRR) */
 	uint8_t wrr_tokens[RTE_SCHED_BE_QUEUES_PER_PIPE];
 
 	/* TC oversubscription */
-	uint32_t tc_ov_credits;
+	uint64_t tc_ov_credits;
 	uint8_t tc_ov_period_id;
 } __rte_cache_aligned;
 
@@ -141,28 +141,28 @@ struct rte_sched_grinder {
 struct rte_sched_subport {
 	/* Token bucket (TB) */
 	uint64_t tb_time; /* time of last update */
-	uint32_t tb_period;
-	uint32_t tb_credits_per_period;
-	uint32_t tb_size;
-	uint32_t tb_credits;
+	uint64_t tb_period;
+	uint64_t tb_credits_per_period;
+	uint64_t tb_size;
+	uint64_t tb_credits;
 
 	/* Traffic classes (TCs) */
 	uint64_t tc_time; /* time of next update */
-	uint32_t tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
-	uint32_t tc_credits[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
-	uint32_t tc_period;
+	uint64_t tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	uint64_t tc_credits[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	uint64_t tc_period;
 
 	/* TC oversubscription */
-	uint32_t tc_ov_wm;
-	uint32_t tc_ov_wm_min;
-	uint32_t tc_ov_wm_max;
+	uint64_t tc_ov_wm;
+	uint64_t tc_ov_wm_min;
+	uint64_t tc_ov_wm_max;
 	uint8_t tc_ov_period_id;
 	uint8_t tc_ov;
 	uint32_t tc_ov_n;
 	double tc_ov_rate;
 
 	/* Statistics */
-	struct rte_sched_subport_stats stats;
+	struct rte_sched_subport_stats stats __rte_cache_aligned;
 
 	/* Subport pipes */
 	uint32_t n_pipes_per_subport_enabled;
@@ -170,7 +170,7 @@ struct rte_sched_subport {
 	uint32_t n_max_pipe_profiles;
 
 	/* Pipe best-effort TC rate */
-	uint32_t pipe_tc_be_rate_max;
+	uint64_t pipe_tc_be_rate_max;
 
 	/* Pipe queues size */
 	uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
@@ -212,7 +212,7 @@ struct rte_sched_port {
 	uint16_t pipe_queue[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 	uint8_t pipe_tc[RTE_SCHED_QUEUES_PER_PIPE];
 	uint8_t tc_queue[RTE_SCHED_QUEUES_PER_PIPE];
-	uint32_t rate;
+	uint64_t rate;
 	uint32_t mtu;
 	uint32_t frame_overhead;
 	int socket;
@@ -517,9 +517,11 @@ rte_sched_port_log_pipe_profile(struct rte_sched_subport *subport, uint32_t i)
 	struct rte_sched_pipe_profile *p = subport->pipe_profiles + i;
 
 	RTE_LOG(DEBUG, SCHED, "Low level config for pipe profile %u:\n"
-		"	Token bucket: period = %u, credits per period = %u, size = %u\n"
-		"	Traffic classes: period = %u,\n"
-		"	credits per period = [%u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u]\n"
+		"	Token bucket: period = %"PRIu64", credits per period = %"PRIu64", size = %"PRIu64"\n"
+		"	Traffic classes: period = %"PRIu64",\n"
+		"	credits per period = [%"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
+		", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
+		", %"PRIu64", %"PRIu64", %"PRIu64"]\n"
 		"	Best-effort traffic class oversubscription: weight = %hhu\n"
 		"	WRR cost: [%hhu, %hhu, %hhu, %hhu]\n",
 		i,
@@ -553,7 +555,7 @@ rte_sched_port_log_pipe_profile(struct rte_sched_subport *subport, uint32_t i)
 }
 
 static inline uint64_t
-rte_sched_time_ms_to_bytes(uint32_t time_ms, uint32_t rate)
+rte_sched_time_ms_to_bytes(uint64_t time_ms, uint64_t rate)
 {
 	uint64_t time = time_ms;
 
@@ -566,7 +568,7 @@ static void
 rte_sched_pipe_profile_convert(struct rte_sched_subport *subport,
 	struct rte_sched_pipe_params *src,
 	struct rte_sched_pipe_profile *dst,
-	uint32_t rate)
+	uint64_t rate)
 {
 	uint32_t wrr_cost[RTE_SCHED_BE_QUEUES_PER_PIPE];
 	uint32_t lcd1, lcd2, lcd;
@@ -581,8 +583,8 @@ rte_sched_pipe_profile_convert(struct rte_sched_subport *subport,
 				/ (double) rate;
 		double d = RTE_SCHED_TB_RATE_CONFIG_ERR;
 
-		rte_approx(tb_rate, d,
-			&dst->tb_credits_per_period, &dst->tb_period);
+		rte_approx_64(tb_rate, d, &dst->tb_credits_per_period,
+			&dst->tb_period);
 	}
 
 	dst->tb_size = src->tb_size;
@@ -637,7 +639,7 @@ rte_sched_subport_config_pipe_profile_table(struct rte_sched_subport *subport,
 	subport->pipe_tc_be_rate_max = 0;
 	for (i = 0; i < subport->n_pipe_profiles; i++) {
 		struct rte_sched_pipe_params *src = params->pipe_profiles + i;
-		uint32_t pipe_tc_be_rate = src->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE];
+		uint64_t pipe_tc_be_rate = src->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE];
 
 		if (subport->pipe_tc_be_rate_max < pipe_tc_be_rate)
 			subport->pipe_tc_be_rate_max = pipe_tc_be_rate;
@@ -647,7 +649,7 @@ rte_sched_subport_config_pipe_profile_table(struct rte_sched_subport *subport,
 static int
 rte_sched_subport_check_params(struct rte_sched_subport_params *params,
 	uint32_t n_max_pipes_per_subport,
-	uint32_t rate)
+	uint64_t rate)
 {
 	uint32_t i;
 
@@ -684,7 +686,7 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params,
 	}
 
 	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
-		uint32_t tc_rate = params->tc_rate[i];
+		uint64_t tc_rate = params->tc_rate[i];
 		uint16_t qsize = params->qsize[i];
 
 		if ((qsize == 0 && tc_rate != 0) ||
@@ -910,10 +912,14 @@ rte_sched_port_log_subport_config(struct rte_sched_port *port, uint32_t i)
 	struct rte_sched_subport *s = port->subports[i];
 
 	RTE_LOG(DEBUG, SCHED, "Low level config for subport %u:\n"
-		"	Token bucket: period = %u, credits per period = %u, size = %u\n"
-		"	Traffic classes: period = %u\n"
-		"	credits per period = [%u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u]\n"
-		"	Best effort traffic class oversubscription: wm min = %u, wm max = %u\n",
+		"	Token bucket: period = %"PRIu64", credits per period = %"PRIu64
+		", size = %"PRIu64"\n"
+		"	Traffic classes: period = %"PRIu64"\n"
+		"	credits per period = [%"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
+		", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64
+		", %"PRIu64", %"PRIu64", %"PRIu64"]\n"
+		"	Best effort traffic class oversubscription: wm min = %"PRIu64
+		", wm max = %"PRIu64"\n",
 		i,
 
 		/* Token bucket */
@@ -1023,7 +1029,7 @@ rte_sched_subport_config(struct rte_sched_port *port,
 		double tb_rate = ((double) params->tb_rate) / ((double) port->rate);
 		double d = RTE_SCHED_TB_RATE_CONFIG_ERR;
 
-		rte_approx(tb_rate, d, &s->tb_credits_per_period, &s->tb_period);
+		rte_approx_64(tb_rate, d, &s->tb_credits_per_period, &s->tb_period);
 	}
 
 	s->tb_size = params->tb_size;
@@ -1970,13 +1976,13 @@ grinder_credits_update(struct rte_sched_port *port,
 	/* Subport TB */
 	n_periods = (port->time - subport->tb_time) / subport->tb_period;
 	subport->tb_credits += n_periods * subport->tb_credits_per_period;
-	subport->tb_credits = rte_sched_min_val_2_u32(subport->tb_credits, subport->tb_size);
+	subport->tb_credits = RTE_MIN(subport->tb_credits, subport->tb_size);
 	subport->tb_time += n_periods * subport->tb_period;
 
 	/* Pipe TB */
 	n_periods = (port->time - pipe->tb_time) / params->tb_period;
 	pipe->tb_credits += n_periods * params->tb_credits_per_period;
-	pipe->tb_credits = rte_sched_min_val_2_u32(pipe->tb_credits, params->tb_size);
+	pipe->tb_credits = RTE_MIN(pipe->tb_credits, params->tb_size);
 	pipe->tb_time += n_periods * params->tb_period;
 
 	/* Subport TCs */
@@ -1998,13 +2004,13 @@ grinder_credits_update(struct rte_sched_port *port,
 
 #else
 
-static inline uint32_t
+static inline uint64_t
 grinder_tc_ov_credits_update(struct rte_sched_port *port,
 	struct rte_sched_subport *subport)
 {
-	uint32_t tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
-	uint32_t tc_consumption = 0, tc_ov_consumption_max;
-	uint32_t tc_ov_wm = subport->tc_ov_wm;
+	uint64_t tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	uint64_t tc_consumption = 0, tc_ov_consumption_max;
+	uint64_t tc_ov_wm = subport->tc_ov_wm;
 	uint32_t i;
 
 	if (subport->tc_ov == 0)
@@ -2053,13 +2059,13 @@ grinder_credits_update(struct rte_sched_port *port,
 	/* Subport TB */
 	n_periods = (port->time - subport->tb_time) / subport->tb_period;
 	subport->tb_credits += n_periods * subport->tb_credits_per_period;
-	subport->tb_credits = rte_sched_min_val_2_u32(subport->tb_credits, subport->tb_size);
+	subport->tb_credits = RTE_MIN(subport->tb_credits, subport->tb_size);
 	subport->tb_time += n_periods * subport->tb_period;
 
 	/* Pipe TB */
 	n_periods = (port->time - pipe->tb_time) / params->tb_period;
 	pipe->tb_credits += n_periods * params->tb_credits_per_period;
-	pipe->tb_credits = rte_sched_min_val_2_u32(pipe->tb_credits, params->tb_size);
+	pipe->tb_credits = RTE_MIN(pipe->tb_credits, params->tb_size);
 	pipe->tb_time += n_periods * params->tb_period;
 
 	/* Subport TCs */
@@ -2101,11 +2107,11 @@ grinder_credits_check(struct rte_sched_port *port,
 	struct rte_sched_pipe *pipe = grinder->pipe;
 	struct rte_mbuf *pkt = grinder->pkt;
 	uint32_t tc_index = grinder->tc_index;
-	uint32_t pkt_len = pkt->pkt_len + port->frame_overhead;
-	uint32_t subport_tb_credits = subport->tb_credits;
-	uint32_t subport_tc_credits = subport->tc_credits[tc_index];
-	uint32_t pipe_tb_credits = pipe->tb_credits;
-	uint32_t pipe_tc_credits = pipe->tc_credits[tc_index];
+	uint64_t pkt_len = pkt->pkt_len + port->frame_overhead;
+	uint64_t subport_tb_credits = subport->tb_credits;
+	uint64_t subport_tc_credits = subport->tc_credits[tc_index];
+	uint64_t pipe_tb_credits = pipe->tb_credits;
+	uint64_t pipe_tc_credits = pipe->tc_credits[tc_index];
 	int enough_credits;
 
 	/* Check queue credits */
@@ -2136,21 +2142,22 @@ grinder_credits_check(struct rte_sched_port *port,
 	struct rte_sched_pipe *pipe = grinder->pipe;
 	struct rte_mbuf *pkt = grinder->pkt;
 	uint32_t tc_index = grinder->tc_index;
-	uint32_t pkt_len = pkt->pkt_len + port->frame_overhead;
-	uint32_t subport_tb_credits = subport->tb_credits;
-	uint32_t subport_tc_credits = subport->tc_credits[tc_index];
-	uint32_t pipe_tb_credits = pipe->tb_credits;
-	uint32_t pipe_tc_credits = pipe->tc_credits[tc_index];
-	uint32_t pipe_tc_ov_mask1[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
-	uint32_t pipe_tc_ov_mask2[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE] = {0};
-	uint32_t pipe_tc_ov_credits, i;
+	uint64_t pkt_len = pkt->pkt_len + port->frame_overhead;
+	uint64_t subport_tb_credits = subport->tb_credits;
+	uint64_t subport_tc_credits = subport->tc_credits[tc_index];
+	uint64_t pipe_tb_credits = pipe->tb_credits;
+	uint64_t pipe_tc_credits = pipe->tc_credits[tc_index];
+	uint64_t pipe_tc_ov_mask1[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
+	uint64_t pipe_tc_ov_mask2[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE] = {0};
+	uint64_t pipe_tc_ov_credits;
+	uint32_t i;
 	int enough_credits;
 
 	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
-		pipe_tc_ov_mask1[i] = UINT32_MAX;
+		pipe_tc_ov_mask1[i] = ~0LLU;
 
 	pipe_tc_ov_mask1[RTE_SCHED_TRAFFIC_CLASS_BE] = pipe->tc_ov_credits;
-	pipe_tc_ov_mask2[RTE_SCHED_TRAFFIC_CLASS_BE] = UINT32_MAX;
+	pipe_tc_ov_mask2[RTE_SCHED_TRAFFIC_CLASS_BE] = ~0LLU;
 	pipe_tc_ov_credits = pipe_tc_ov_mask1[tc_index];
 
 	/* Check pipe and subport credits */
diff --git a/lib/librte_sched/rte_sched_common.h b/lib/librte_sched/rte_sched_common.h
index 8c191a9b8..b58282de8 100644
--- a/lib/librte_sched/rte_sched_common.h
+++ b/lib/librte_sched/rte_sched_common.h
@@ -14,12 +14,6 @@ extern "C" {
 
 #define __rte_aligned_16 __attribute__((__aligned__(16)))
 
-static inline uint32_t
-rte_sched_min_val_2_u32(uint32_t x, uint32_t y)
-{
-	return (x < y)? x : y;
-}
-
 #if 0
 static inline uint32_t
 rte_min_pos_4_u16(uint16_t *x)
-- 
2.21.0


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

* Re: [dpdk-dev] [PATCH v2 2/2] sched: modify internal structs and functions for 64 bit values
  2019-10-16 14:17   ` [dpdk-dev] [PATCH v2 2/2] sched: modify internal structs and functions " Jasvinder Singh
@ 2019-10-16 15:14     ` Dumitrescu, Cristian
  2019-10-25 16:08       ` Thomas Monjalon
  0 siblings, 1 reply; 9+ messages in thread
From: Dumitrescu, Cristian @ 2019-10-16 15:14 UTC (permalink / raw)
  To: Singh, Jasvinder, dev; +Cc: Krakowiak, LukaszX



> -----Original Message-----
> From: Singh, Jasvinder
> Sent: Wednesday, October 16, 2019 3:17 PM
> To: dev@dpdk.org
> Cc: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>; Krakowiak,
> LukaszX <lukaszx.krakowiak@intel.com>
> Subject: [PATCH v2 2/2] sched: modify internal structs and functions for 64 bit
> values
> 
> Modify internal structure and functions to support 64-bit
> values for rates and stats parameters.
> 
> Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
> Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
> ---
> v2:
> - remove rte_sched_min_val_2_u32() from rte_sched_common.h
> - replace rte_sched_min_val_2_u32() by RTE_MIN in rte_sched.c
> - replace sched_counter_t by uint64_t
> - add 64 bit version of rte_approx
> 

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>


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

* Re: [dpdk-dev] [PATCH v2 2/2] sched: modify internal structs and functions for 64 bit values
  2019-10-16 15:14     ` Dumitrescu, Cristian
@ 2019-10-25 16:08       ` Thomas Monjalon
  0 siblings, 0 replies; 9+ messages in thread
From: Thomas Monjalon @ 2019-10-25 16:08 UTC (permalink / raw)
  To: Singh, Jasvinder; +Cc: dev, Dumitrescu, Cristian, Krakowiak, LukaszX

16/10/2019 17:14, Dumitrescu, Cristian:
> From: Singh, Jasvinder
> > 
> > Modify internal structure and functions to support 64-bit
> > values for rates and stats parameters.
> > 
> > Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
> > Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
> > ---
> > v2:
> > - remove rte_sched_min_val_2_u32() from rte_sched_common.h
> > - replace rte_sched_min_val_2_u32() by RTE_MIN in rte_sched.c
> > - replace sched_counter_t by uint64_t
> > - add 64 bit version of rte_approx
> > 
> 
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Applied, thanks



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

end of thread, other threads:[~2019-10-25 16:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-14 17:24 [dpdk-dev] [PATCH 1/2] sched: add support for 64 bit values Jasvinder Singh
2019-10-14 17:24 ` [dpdk-dev] [PATCH 2/2] sched: modify internal structs and functions " Jasvinder Singh
2019-10-15 15:47   ` Dumitrescu, Cristian
2019-10-15 16:01     ` Singh, Jasvinder
2019-10-15 15:27 ` [dpdk-dev] [PATCH 1/2] sched: add support " Dumitrescu, Cristian
2019-10-16 14:17 ` [dpdk-dev] [PATCH v2 " Jasvinder Singh
2019-10-16 14:17   ` [dpdk-dev] [PATCH v2 2/2] sched: modify internal structs and functions " Jasvinder Singh
2019-10-16 15:14     ` Dumitrescu, Cristian
2019-10-25 16:08       ` 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).