[dpdk-dev] [PATCH v4 16/17] sched: add support for 64 bit values

Jasvinder Singh jasvinder.singh at intel.com
Mon Oct 14 14:09:50 CEST 2019


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 at intel.com>
Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak at 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



More information about the dev mailing list