[09/15] sched: update pkt dequeue for subport config flexibility
diff mbox series

Message ID 20190823144602.58213-10-jasvinder.singh@intel.com
State Superseded, archived
Delegated to: Cristian Dumitrescu
Headers show
Series
  • sched: subport level configuration of pipe nodes
Related show

Checks

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

Commit Message

Jasvinder Singh Aug. 23, 2019, 2:45 p.m. UTC
Modify scheduler packet dequeue operation to allow different
subports of the same port to have different configuration in terms
of number of pipes, pipe queue sizes, etc.

Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
---
 lib/librte_sched/rte_sched.c | 51 ++++++++++++++++++++++++++++--------
 1 file changed, 40 insertions(+), 11 deletions(-)

Patch
diff mbox series

diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c
index 0451e10ea..e0ef86f40 100644
--- a/lib/librte_sched/rte_sched.c
+++ b/lib/librte_sched/rte_sched.c
@@ -245,6 +245,7 @@  struct rte_sched_port {
 	uint32_t busy_grinders;
 	struct rte_mbuf **pkts_out;
 	uint32_t n_pkts_out;
+	uint32_t subport_id;
 
 	/* Queue base calculation */
 	uint32_t qsize_add[RTE_SCHED_QUEUES_PER_PIPE];
@@ -911,6 +912,7 @@  rte_sched_port_config(struct rte_sched_port_params *params)
 	/* Grinders */
 	port->pkts_out = NULL;
 	port->n_pkts_out = 0;
+	port->subport_id = 0;
 
 	return port;
 }
@@ -2616,9 +2618,9 @@  grinder_prefetch_mbuf(struct rte_sched_subport *subport, uint32_t pos)
 }
 
 static inline uint32_t
-grinder_handle(struct rte_sched_port *port, uint32_t pos)
+grinder_handle(struct rte_sched_port *port,
+	struct rte_sched_subport *subport, uint32_t pos)
 {
-	struct rte_sched_subport *subport = port->subport;
 	struct rte_sched_grinder *grinder = subport->grinder + pos;
 
 	switch (grinder->state) {
@@ -2717,6 +2719,7 @@  rte_sched_port_time_resync(struct rte_sched_port *port)
 	uint64_t cycles = rte_get_tsc_cycles();
 	uint64_t cycles_diff = cycles - port->time_cpu_cycles;
 	uint64_t bytes_diff;
+	uint32_t i;
 
 	/* Compute elapsed time in bytes */
 	bytes_diff = rte_reciprocal_divide(cycles_diff << RTE_SCHED_TIME_SHIFT,
@@ -2729,20 +2732,21 @@  rte_sched_port_time_resync(struct rte_sched_port *port)
 		port->time = port->time_cpu_bytes;
 
 	/* Reset pipe loop detection */
-	port->pipe_loop = RTE_SCHED_PIPE_INVALID;
+	for (i = 0; i < port->n_subports_per_port; i++)
+		port->subports[i]->pipe_loop = RTE_SCHED_PIPE_INVALID;
 }
 
 static inline int
-rte_sched_port_exceptions(struct rte_sched_port *port, int second_pass)
+rte_sched_port_exceptions(struct rte_sched_subport *subport, int second_pass)
 {
 	int exceptions;
 
 	/* Check if any exception flag is set */
-	exceptions = (second_pass && port->busy_grinders == 0) ||
-		(port->pipe_exhaustion == 1);
+	exceptions = (second_pass && subport->busy_grinders == 0) ||
+		(subport->pipe_exhaustion == 1);
 
 	/* Clear exception flags */
-	port->pipe_exhaustion = 0;
+	subport->pipe_exhaustion = 0;
 
 	return exceptions;
 }
@@ -2750,7 +2754,9 @@  rte_sched_port_exceptions(struct rte_sched_port *port, int second_pass)
 int
 rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts)
 {
-	uint32_t i, count;
+	struct rte_sched_subport *subport;
+	uint32_t subport_id = port->subport_id;
+	uint32_t i, n_subports = 0, count;
 
 	port->pkts_out = pkts;
 	port->n_pkts_out = 0;
@@ -2759,9 +2765,32 @@  rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint
 
 	/* Take each queue in the grinder one step further */
 	for (i = 0, count = 0; ; i++)  {
-		count += grinder_handle(port, i & (RTE_SCHED_PORT_N_GRINDERS - 1));
-		if ((count == n_pkts) ||
-		    rte_sched_port_exceptions(port, i >= RTE_SCHED_PORT_N_GRINDERS)) {
+		subport = port->subports[subport_id];
+
+		count += grinder_handle(port, subport,
+				i & (RTE_SCHED_PORT_N_GRINDERS - 1));
+
+		if (count == n_pkts) {
+			subport_id++;
+
+			if (subport_id == port->n_subports_per_port)
+				subport_id = 0;
+
+			port->subport_id = subport_id;
+			break;
+		}
+
+		if (rte_sched_port_exceptions(subport, i >= RTE_SCHED_PORT_N_GRINDERS)) {
+			i = 0;
+			subport_id++;
+			n_subports++;
+		}
+
+		if (subport_id == port->n_subports_per_port)
+			subport_id = 0;
+
+		if (n_subports == port->n_subports_per_port) {
+			port->subport_id = subport_id;
 			break;
 		}
 	}