[v2,26/28] examples/ip_pipeline: update ip pipeline sample app

Message ID 20190625153217.24301-27-jasvinder.singh@intel.com (mailing list archive)
State Changes Requested, archived
Delegated to: Cristian Dumitrescu
Headers
Series sched: feature enhancements |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Jasvinder Singh June 25, 2019, 3:32 p.m. UTC
  Update ip pipeline sample app to allow configuration flexiblity
for pipe traffic classes and queues, and subport level configuration
of the pipe parameters.

Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
Signed-off-by: Abraham Tovar <abrahamx.tovar@intel.com>
Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
---
 examples/ip_pipeline/cli.c             | 85 +++++++++++++-------------
 examples/ip_pipeline/tmgr.c            | 22 +++----
 examples/ip_pipeline/tmgr.h            |  3 -
 lib/librte_pipeline/rte_table_action.c |  1 -
 lib/librte_pipeline/rte_table_action.h |  4 +-
 5 files changed, 54 insertions(+), 61 deletions(-)
  

Patch

diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c
index 309b2936e..1c19d0e21 100644
--- a/examples/ip_pipeline/cli.c
+++ b/examples/ip_pipeline/cli.c
@@ -377,8 +377,11 @@  cmd_swq(char **tokens,
 static const char cmd_tmgr_subport_profile_help[] =
 "tmgr subport profile\n"
 "   <tb_rate> <tb_size>\n"
-"   <tc0_rate> <tc1_rate> <tc2_rate> <tc3_rate>\n"
-"   <tc_period>\n";
+"   <tc0_rate> <tc1_rate> <tc2_rate> <tc3_rate>"
+"        <tc4_rate> <tc5_rate> <tc6_rate> <tc7_rate> <tc8_rate>\n"
+"   <tc_period>\n"
+"   pps <n_pipes_per_subport>\n"
+"   qsize <qsize_q0..15>";
 
 static void
 cmd_tmgr_subport_profile(char **tokens,
@@ -389,7 +392,7 @@  cmd_tmgr_subport_profile(char **tokens,
 	struct rte_sched_subport_params p;
 	int status, i;
 
-	if (n_tokens != 10) {
+	if (n_tokens != 34) {
 		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
 		return;
 	}
@@ -410,11 +413,32 @@  cmd_tmgr_subport_profile(char **tokens,
 			return;
 		}
 
-	if (parser_read_uint32(&p.tc_period, tokens[9]) != 0) {
+	if (parser_read_uint32(&p.tc_period, tokens[14]) != 0) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "tc_period");
 		return;
 	}
 
+	if (strcmp(tokens[15], "pps") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pps");
+		return;
+	}
+
+	if (parser_read_uint32(&p.n_subport_pipes, tokens[16]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "n_subport_pipes");
+		return;
+	}
+
+	if (strcmp(tokens[17], "qsize") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "qsize");
+		return;
+	}
+
+	for (i = 0; i < RTE_SCHED_QUEUES_PER_PIPE; i++)
+		if (parser_read_uint16(&p.qsize[i], tokens[18 + i]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "qsize");
+			return;
+		}
+
 	status = tmgr_subport_profile_add(&p);
 	if (status != 0) {
 		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
@@ -425,10 +449,11 @@  cmd_tmgr_subport_profile(char **tokens,
 static const char cmd_tmgr_pipe_profile_help[] =
 "tmgr pipe profile\n"
 "   <tb_rate> <tb_size>\n"
-"   <tc0_rate> <tc1_rate> <tc2_rate> <tc3_rate>\n"
+"   <tc0_rate> <tc1_rate> <tc2_rate> <tc3_rate>"
+"     <tc0_rate> <tc1_rate> <tc2_rate> <tc3_rate>\n"
 "   <tc_period>\n"
 "   <tc_ov_weight>\n"
-"   <wrr_weight0..15>\n";
+"   <wrr_weight0..7>\n";
 
 static void
 cmd_tmgr_pipe_profile(char **tokens,
@@ -439,7 +464,7 @@  cmd_tmgr_pipe_profile(char **tokens,
 	struct rte_sched_pipe_params p;
 	int status, i;
 
-	if (n_tokens != 27) {
+	if (n_tokens != 24) {
 		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
 		return;
 	}
@@ -460,20 +485,20 @@  cmd_tmgr_pipe_profile(char **tokens,
 			return;
 		}
 
-	if (parser_read_uint32(&p.tc_period, tokens[9]) != 0) {
+	if (parser_read_uint32(&p.tc_period, tokens[14]) != 0) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "tc_period");
 		return;
 	}
 
 #ifdef RTE_SCHED_SUBPORT_TC_OV
-	if (parser_read_uint8(&p.tc_ov_weight, tokens[10]) != 0) {
+	if (parser_read_uint8(&p.tc_ov_weight, tokens[15]) != 0) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "tc_ov_weight");
 		return;
 	}
 #endif
 
-	for (i = 0; i < RTE_SCHED_QUEUES_PER_PIPE; i++)
-		if (parser_read_uint8(&p.wrr_weights[i], tokens[11 + i]) != 0) {
+	for (i = 0; i < RTE_SCHED_BE_QUEUES_PER_PIPE; i++)
+		if (parser_read_uint8(&p.wrr_weights[i], tokens[16 + i]) != 0) {
 			snprintf(out, out_size, MSG_ARG_INVALID, "wrr_weights");
 			return;
 		}
@@ -489,8 +514,6 @@  static const char cmd_tmgr_help[] =
 "tmgr <tmgr_name>\n"
 "   rate <rate>\n"
 "   spp <n_subports_per_port>\n"
-"   pps <n_pipes_per_subport>\n"
-"   qsize <qsize_tc0> <qsize_tc1> <qsize_tc2> <qsize_tc3>\n"
 "   fo <frame_overhead>\n"
 "   mtu <mtu>\n"
 "   cpu <cpu_id>\n";
@@ -504,9 +527,8 @@  cmd_tmgr(char **tokens,
 	struct tmgr_port_params p;
 	char *name;
 	struct tmgr_port *tmgr_port;
-	int i;
 
-	if (n_tokens != 19) {
+	if (n_tokens != 12) {
 		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
 		return;
 	}
@@ -533,53 +555,32 @@  cmd_tmgr(char **tokens,
 		return;
 	}
 
-	if (strcmp(tokens[6], "pps") != 0) {
-		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pps");
-		return;
-	}
-
-	if (parser_read_uint32(&p.n_pipes_per_subport, tokens[7]) != 0) {
-		snprintf(out, out_size, MSG_ARG_INVALID, "n_pipes_per_subport");
-		return;
-	}
-
-	if (strcmp(tokens[8], "qsize") != 0) {
-		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "qsize");
-		return;
-	}
-
-	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
-		if (parser_read_uint16(&p.qsize[i], tokens[9 + i]) != 0) {
-			snprintf(out, out_size, MSG_ARG_INVALID, "qsize");
-			return;
-		}
-
-	if (strcmp(tokens[13], "fo") != 0) {
+	if (strcmp(tokens[6], "fo") != 0) {
 		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "fo");
 		return;
 	}
 
-	if (parser_read_uint32(&p.frame_overhead, tokens[14]) != 0) {
+	if (parser_read_uint32(&p.frame_overhead, tokens[7]) != 0) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "frame_overhead");
 		return;
 	}
 
-	if (strcmp(tokens[15], "mtu") != 0) {
+	if (strcmp(tokens[8], "mtu") != 0) {
 		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mtu");
 		return;
 	}
 
-	if (parser_read_uint32(&p.mtu, tokens[16]) != 0) {
+	if (parser_read_uint32(&p.mtu, tokens[9]) != 0) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "mtu");
 		return;
 	}
 
-	if (strcmp(tokens[17], "cpu") != 0) {
+	if (strcmp(tokens[10], "cpu") != 0) {
 		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cpu");
 		return;
 	}
 
-	if (parser_read_uint32(&p.cpu_id, tokens[18]) != 0) {
+	if (parser_read_uint32(&p.cpu_id, tokens[11]) != 0) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "cpu_id");
 		return;
 	}
diff --git a/examples/ip_pipeline/tmgr.c b/examples/ip_pipeline/tmgr.c
index 40cbf1d0a..5e55e8ef1 100644
--- a/examples/ip_pipeline/tmgr.c
+++ b/examples/ip_pipeline/tmgr.c
@@ -47,7 +47,8 @@  int
 tmgr_subport_profile_add(struct rte_sched_subport_params *p)
 {
 	/* Check input params */
-	if (p == NULL)
+	if (p == NULL ||
+		p->n_subport_pipes == 0)
 		return -1;
 
 	/* Save profile */
@@ -90,7 +91,6 @@  tmgr_port_create(const char *name, struct tmgr_port_params *params)
 		tmgr_port_find(name) ||
 		(params == NULL) ||
 		(params->n_subports_per_port == 0) ||
-		(params->n_pipes_per_subport == 0) ||
 		(params->cpu_id >= RTE_MAX_NUMA_NODES) ||
 		(n_subport_profiles == 0) ||
 		(n_pipe_profiles == 0))
@@ -103,18 +103,15 @@  tmgr_port_create(const char *name, struct tmgr_port_params *params)
 	p.mtu = params->mtu;
 	p.frame_overhead = params->frame_overhead;
 	p.n_subports_per_port = params->n_subports_per_port;
-	p.n_pipes_per_subport = params->n_pipes_per_subport;
-
-	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
-		p.qsize[i] = params->qsize[i];
-
-	p.pipe_profiles = pipe_profile;
-	p.n_pipe_profiles = n_pipe_profiles;
 
 	s = rte_sched_port_config(&p);
 	if (s == NULL)
 		return NULL;
 
+	subport_profile[0].pipe_profiles = pipe_profile;
+	subport_profile[0].n_pipe_profiles = n_pipe_profiles;
+	subport_profile[0].n_max_pipe_profiles = TMGR_PIPE_PROFILE_MAX;
+
 	for (i = 0; i < params->n_subports_per_port; i++) {
 		int status;
 
@@ -128,7 +125,7 @@  tmgr_port_create(const char *name, struct tmgr_port_params *params)
 			return NULL;
 		}
 
-		for (j = 0; j < params->n_pipes_per_subport; j++) {
+		for (j = 0; j < subport_profile[0].n_subport_pipes; j++) {
 			status = rte_sched_pipe_config(
 				s,
 				i,
@@ -153,7 +150,6 @@  tmgr_port_create(const char *name, struct tmgr_port_params *params)
 	strlcpy(tmgr_port->name, name, sizeof(tmgr_port->name));
 	tmgr_port->s = s;
 	tmgr_port->n_subports_per_port = params->n_subports_per_port;
-	tmgr_port->n_pipes_per_subport = params->n_pipes_per_subport;
 
 	/* Node add to list */
 	TAILQ_INSERT_TAIL(&tmgr_port_list, tmgr_port, node);
@@ -205,8 +201,8 @@  tmgr_pipe_config(const char *port_name,
 	port = tmgr_port_find(port_name);
 	if ((port == NULL) ||
 		(subport_id >= port->n_subports_per_port) ||
-		(pipe_id_first >= port->n_pipes_per_subport) ||
-		(pipe_id_last >= port->n_pipes_per_subport) ||
+		(pipe_id_first >= subport_profile[0].n_subport_pipes) ||
+		(pipe_id_last >= subport_profile[0].n_subport_pipes) ||
 		(pipe_id_first > pipe_id_last) ||
 		(pipe_profile_id >= n_pipe_profiles))
 		return -1;
diff --git a/examples/ip_pipeline/tmgr.h b/examples/ip_pipeline/tmgr.h
index 0b497e795..3a958492c 100644
--- a/examples/ip_pipeline/tmgr.h
+++ b/examples/ip_pipeline/tmgr.h
@@ -25,7 +25,6 @@  struct tmgr_port {
 	char name[NAME_SIZE];
 	struct rte_sched_port *s;
 	uint32_t n_subports_per_port;
-	uint32_t n_pipes_per_subport;
 };
 
 TAILQ_HEAD(tmgr_port_list, tmgr_port);
@@ -39,8 +38,6 @@  tmgr_port_find(const char *name);
 struct tmgr_port_params {
 	uint32_t rate;
 	uint32_t n_subports_per_port;
-	uint32_t n_pipes_per_subport;
-	uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 	uint32_t frame_overhead;
 	uint32_t mtu;
 	uint32_t cpu_id;
diff --git a/lib/librte_pipeline/rte_table_action.c b/lib/librte_pipeline/rte_table_action.c
index a54ec46bc..47d7efbc1 100644
--- a/lib/librte_pipeline/rte_table_action.c
+++ b/lib/librte_pipeline/rte_table_action.c
@@ -401,7 +401,6 @@  pkt_work_tm(struct rte_mbuf *mbuf,
 {
 	struct dscp_table_entry_data *dscp_entry = &dscp_table->entry[dscp];
 	uint32_t queue_id = data->queue_id |
-				(dscp_entry->tc << 2) |
 				dscp_entry->tc_queue;
 	rte_mbuf_sched_set(mbuf, queue_id, dscp_entry->tc,
 				(uint8_t)dscp_entry->color);
diff --git a/lib/librte_pipeline/rte_table_action.h b/lib/librte_pipeline/rte_table_action.h
index ef45a3023..4a68deb2e 100644
--- a/lib/librte_pipeline/rte_table_action.h
+++ b/lib/librte_pipeline/rte_table_action.h
@@ -181,10 +181,10 @@  struct rte_table_action_lb_params {
  * RTE_TABLE_ACTION_MTR
  */
 /** Max number of traffic classes (TCs). */
-#define RTE_TABLE_ACTION_TC_MAX                                  4
+#define RTE_TABLE_ACTION_TC_MAX                                  16
 
 /** Max number of queues per traffic class. */
-#define RTE_TABLE_ACTION_TC_QUEUE_MAX                            4
+#define RTE_TABLE_ACTION_TC_QUEUE_MAX                            16
 
 /** Differentiated Services Code Point (DSCP) translation table entry. */
 struct rte_table_action_dscp_table_entry {