All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Fastabend <john.r.fastabend@intel.com>
To: shemminger@vyatta.com, bhutchings@solarflare.com
Cc: netdev@vger.kernel.org
Subject: [PATCH] iproute2: improve mqprio inputs for queue offsets and counts
Date: Tue, 26 Apr 2011 12:44:42 -0700	[thread overview]
Message-ID: <20110426194441.23726.23489.stgit@jf-dev1-dcblab> (raw)

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 uage,

# ./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>
---

 tc/q_mqprio.c |   27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/tc/q_mqprio.c b/tc/q_mqprio.c
index c589b4c..bf734a0 100644
--- a/tc/q_mqprio.c
+++ b/tc/q_mqprio.c
@@ -25,8 +25,8 @@
 static void explain(void)
 {
 	fprintf(stderr, "Usage: ... mqprio [num_tc NUMBER] [map P0 P1 ...]\n");
-	fprintf(stderr, "                  [offset txq0 txq1 ...] ");
-	fprintf(stderr, "[count cnt0,cnt1 ...] [hw 1|0]\n");
+	fprintf(stderr, "                  [queues count1@offset1 count2@offset2 ...] ");
+	fprintf(stderr, "[hw 1|0]\n");
 }
 
 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++)
 				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()) {
 				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();
 					break;
 				}
-				idx++;
-			}
-		} else if (strcmp(*argv, "count") == 0) {
-			while (idx < TC_QOPT_MAX_QUEUE && NEXT_ARG_OK()) {
-				NEXT_ARG();
-				if (get_u16(&opt.count[idx], *argv, 10)) {
+				tok = strtok(NULL, "@");
+				if (get_u16(&opt.offset[idx], tok, 10)) {
+					free(tmp);
 					PREV_ARG();
 					break;
 				}
+				free(tmp);
 				idx++;
 			}
 		} else if (strcmp(*argv, "hw") == 0) {


             reply	other threads:[~2011-04-26 19:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-26 19:44 John Fastabend [this message]
2011-04-26 22:00 ` [PATCH] iproute2: improve mqprio inputs for queue offsets and counts Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110426194441.23726.23489.stgit@jf-dev1-dcblab \
    --to=john.r.fastabend@intel.com \
    --cc=bhutchings@solarflare.com \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@vyatta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.