Skip to contentSkip to conversation

iproute2: sch_rr support in tc

PATCH New PJ Waskiewicz 1 participant 1 message Jun 23, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iproute2: sch_rr support in tc

Updated: This patch applies on top of Patrick McHardy's RTNETLINK patches to add nested compat attributes. This is needed to maintain ABI for sch_{rr|prio} in the kernel with respect to tc. A new option, namely multiqueue, was added to sch_prio and sch_rr. This will allow a user to turn multiqueue support on for sch_prio or sch_rr at loadtime. Also, tc qdisc ls will display whether or not multiqueue is enabled on that qdisc.

This patch is to support the new sch_rr (round-robin) qdisc being proposed in NET for multiqueue network device support in the Linux network stack. It uses q_prio.c as the template, since the qdiscs are nearly identical, outside of the ->dequeue() routine.

---

 include/linux/pkt_sched.h |    2 -
 tc/Makefile               |    1 
 tc/q_prio.c               |   15 ++++-
 tc/q_rr.c                 |  126 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 138 insertions(+), 6 deletions(-)
include/linux/pkt_sched.h +1 -1
index fa0ec53..ec3a9a5 100644
@@ -104,7 +104,7 @@ struct tc_prio_qopt
 enum
 {
 	TCA_PRIO_UNSPEC,
-	TCA_PRIO_TEST,
+	TCA_PRIO_MQ,
 	__TCA_PRIO_MAX
 };
 
tc/Makefile +1 -0
index 9d618ff..62e2697 100644
@@ -9,6 +9,7 @@ TCMODULES += q_fifo.o
 TCMODULES += q_sfq.o
 TCMODULES += q_red.o
 TCMODULES += q_prio.o
+TCMODULES += q_rr.o
 TCMODULES += q_tbf.o
 TCMODULES += q_cbq.o
 TCMODULES += f_rsvp.o
tc/q_prio.c +10 -5
index 4934416..b34bc05 100644
@@ -29,7 +29,7 @@
 
 static void explain(void)
 {
-	fprintf(stderr, "Usage: ... prio bands NUMBER priomap P1 P2...\n");
+	fprintf(stderr, "Usage: ... prio bands NUMBER priomap P1 P2...[multiqueue]\n");
 }
 
 #define usage() return(-1)
@@ -41,6 +41,7 @@ static int prio_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct n
 	int idx = 0;
 	struct tc_prio_qopt opt={3,{ 1, 2, 2, 2, 1, 2, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 }};
 	struct rtattr *nest;
+	unsigned char mq = 0;
 
 	while (argc > 0) {
 		if (strcmp(*argv, "bands") == 0) {
@@ -58,6 +59,8 @@ static int prio_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct n
 				return -1;
 			}
 			pmap_mode = 1;
+		} else if (strcmp(*argv, "multiqueue") == 0) {
+			mq = 1;
 		} else if (strcmp(*argv, "help") == 0) {
 			explain();
 			return -1;
@@ -92,7 +95,7 @@ static int prio_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct n
 	}
 */
 	nest = addattr_nest_compat(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
-	addattr32(n, 1024, TCA_PRIO_TEST, 123);
+	addattr32(n, 1024, TCA_PRIO_MQ, mq);
 	addattr_nest_compat_end(n, nest);
 	return 0;
 }
@@ -106,15 +109,17 @@ int prio_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 	if (opt == NULL)
 		return 0;
 
-	if (parse_rtattr_nested_compat(tb, TCA_PRIO_MAX, opt, (void *)&qopt, sizeof(*qopt)))
+	if (parse_rtattr_nested_compat(tb, TCA_PRIO_MAX, opt, qopt, sizeof(*qopt)))
 		return -1;
 
 	fprintf(f, "bands %u priomap ", qopt->bands);
 	for (i=0; i<=TC_PRIO_MAX; i++)
 		fprintf(f, " %d", qopt->priomap[i]);
 
-	if (tb[TCA_PRIO_TEST])
-		fprintf(f, " TCA_PRIO_TEST: %u ", *(__u32 *)RTA_DATA(tb[TCA_PRIO_TEST]));
+	if (tb[TCA_PRIO_MQ])
+		fprintf(f, " multiqueue: %s ",
+		    *(unsigned char *)RTA_DATA(tb[TCA_PRIO_MQ]) ? "on" : "off");
+
 	return 0;
 }
 
tc/q_rr.c new file +126 -0

126 lines not on this page · raw message