iproute2: sch_rr support in tc
Subsystems (2)
PATCH 1/1 iproute2: sch_rr support in tc
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. When in multiqueue mode, a user can specify a value of 0 for bands, and the number of bands will be created to match the number of queues on the device.
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 | 9 +++ tc/Makefile | 1 tc/q_prio.c | 24 +++++++-- tc/q_rr.c | 127 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 156 insertions(+), 5 deletions(-)
include/linux/pkt_sched.h +9 -0
@@ -101,6 +101,15 @@ struct tc_prio_qopt__u8 priomap[TC_PRIO_MAX +1 ];/* Map: logical priority -> PRIO band */ }; +enum +{ +TCA_PRIO_UNSPEC , +TCA_PRIO_MQ , + __TCA_PRIO_MAX +}; + +#define TCA_PRIO_MAX (__TCA_PRIO_MAX - 1) +/* TBF section */ struct tc_tbf_qopt
tc/Makefile +1 -0
@@ -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 += q_netem.so
tc/q_prio.c +19 -5
@@ -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)
@@ -40,6 +40,8 @@ static int prio_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nint pmap_mode =0 ;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 ) {
@@ -57,6 +59,8 @@ static int prio_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nreturn -1 ; } pmap_mode =1 ; + }else if (strcmp (*argv,"multiqueue" ) ==0 ) { + mq =1 ; }else if (strcmp (*argv,"help" ) ==0 ) {explain ();return -1 ;
@@ -90,7 +94,10 @@ static int prio_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nopt.priomap[idx] = opt.priomap[TC_PRIO_BESTEFFORT]; } */ -addattr_l (n,1024 ,TCA_OPTIONS , &opt,sizeof (opt)); + nest =addattr_nest_compat (n,1024 ,TCA_OPTIONS , &opt,sizeof (opt)); +if (mq) +addattr_l (n,1024 ,TCA_PRIO_MQ ,NULL ,0 ); +addattr_nest_compat_end (n, nest);return 0 ; }
@@ -98,16 +105,23 @@ int prio_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) {int i;struct tc_prio_qopt *qopt; +struct rtattr *tb[TCA_PRIO_MAX +1 ];if (opt ==NULL )return 0 ; -if (RTA_PAYLOAD (opt) <sizeof (*qopt)) -return -1 ; - qopt =RTA_DATA (opt); +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_MQ ]) +fprintf (f," multiqueue: %s " , + *(unsigned char *)RTA_DATA (tb[TCA_PRIO_MQ ]) ?"on" :"off" ); +return 0 ; }
tc/q_rr.c new file +127 -0
127 lines not on this page · raw message
Quoted 15 lines · PJ Waskiewicz
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_prioandsch_rr. This will allow a user to turn multiqueue support on forsch_prioorsch_rrat loadtime. Also, tc qdisc ls will display whether or not multiqueue is enabled on that qdisc. When in multiqueue mode, a user can specify a value of 0 for bands, and the number of bands will be created to match the number of queues on the device.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 usesq_prio.cas the template, since the qdiscs are nearly identical, outside of the ->dequeue() routine.
Quoted 7 lines
Signed-off-by Peter P Waskiewicz Jr <[email protected]>---
include/linux/pkt_sched.h | 9 +++ tc/Makefile | 1 tc/q_prio.c | 24 +++++++-- tc/q_rr.c | 127 +++++++++++++++++++++++++++++++++++++++++++++
Since rr is not built as a module you could actually put everything in q_prio and share the code. But I don't really care :)
Quoted 3 lines
Since rr is not built as a module you could actually put everything in
q_prioand share the code. But I don't really care :)
I tried doing this, but I couldn't get things working quite right with selecting the correct module from sch_prio to sch_rr. So I just added the q_rr.c portion of tc, and it fixed the selection issues I was seeing. At least for userspace, it may be better to explicitly show the existance of rr being independent; that's just my personal preference.
Cheers,
-PJ