iproute2: improve mqprio inputs for queue offsets and counts

This changes mqprio input format to be more user friendly.

Old usage,

 # ./tc/tc qdisc add dev eth3 root mqprio help
Usage: ... mqprio [num_tc NUMBER] [map P0 P1...]
                  [offset txq0 txq1 ...] [count cnt0 cnt1 ...] [hw 1|0]

New usage,

 # ./tc/tc qdisc add dev eth3 root mqprio help
Usage: ... mqprio [num_tc NUMBER] [map P0 P1 ...]
                  [queues count1@offset1 count2@offset2 ...] [hw 1|0]

Suggested-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
This commit is contained in:
John Fastabend 2011-04-26 12:44:42 -07:00 committed by Stephen Hemminger
parent 4d91e4f168
commit 892eba309f
1 changed files with 17 additions and 10 deletions

View File

@ -25,8 +25,8 @@
static void explain(void) static void explain(void)
{ {
fprintf(stderr, "Usage: ... mqprio [num_tc NUMBER] [map P0 P1 ...]\n"); fprintf(stderr, "Usage: ... mqprio [num_tc NUMBER] [map P0 P1 ...]\n");
fprintf(stderr, " [offset txq0 txq1 ...] "); fprintf(stderr, " [queues count1@offset1 count2@offset2 ...] ");
fprintf(stderr, "[count cnt0,cnt1 ...] [hw 1|0]\n"); fprintf(stderr, "[hw 1|0]\n");
} }
static int mqprio_parse_opt(struct qdisc_util *qu, int argc, static int mqprio_parse_opt(struct qdisc_util *qu, int argc,
@ -58,22 +58,29 @@ static int mqprio_parse_opt(struct qdisc_util *qu, int argc,
} }
for ( ; idx < TC_QOPT_MAX_QUEUE; idx++) for ( ; idx < TC_QOPT_MAX_QUEUE; idx++)
opt.prio_tc_map[idx] = 0; opt.prio_tc_map[idx] = 0;
} else if (strcmp(*argv, "offset") == 0) { } else if (strcmp(*argv, "queues") == 0) {
char *tmp, *tok;
while (idx < TC_QOPT_MAX_QUEUE && NEXT_ARG_OK()) { while (idx < TC_QOPT_MAX_QUEUE && NEXT_ARG_OK()) {
NEXT_ARG(); NEXT_ARG();
if (get_u16(&opt.offset[idx], *argv, 10)) {
tmp = strdup(*argv);
if (!tmp)
break;
tok = strtok(tmp, "@");
if (get_u16(&opt.count[idx], tok, 10)) {
free(tmp);
PREV_ARG(); PREV_ARG();
break; break;
} }
idx++; tok = strtok(NULL, "@");
} if (get_u16(&opt.offset[idx], tok, 10)) {
} else if (strcmp(*argv, "count") == 0) { free(tmp);
while (idx < TC_QOPT_MAX_QUEUE && NEXT_ARG_OK()) {
NEXT_ARG();
if (get_u16(&opt.count[idx], *argv, 10)) {
PREV_ARG(); PREV_ARG();
break; break;
} }
free(tmp);
idx++; idx++;
} }
} else if (strcmp(*argv, "hw") == 0) { } else if (strcmp(*argv, "hw") == 0) {