* [PATCH] ibsim: parse width and speed from ibnetdiscover output
@ 2010-09-02 7:37 Eli Dorfman (Voltaire)
[not found] ` <4C7F5444.4030302-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Eli Dorfman (Voltaire) @ 2010-09-02 7:37 UTC (permalink / raw)
To: Sasha Khapyorsky; +Cc: linux-rdma
Search for the pattern '[0-9]*x[SDQ]DR'
Validate that width value is valid.
Signed-off-by: Eli Dorfman <elid-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
ibsim/sim_net.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/ibsim/sim_net.c b/ibsim/sim_net.c
index 13c3b8c..278c065 100644
--- a/ibsim/sim_net.c
+++ b/ibsim/sim_net.c
@@ -611,6 +611,7 @@ static int parse_port(char *line, Node * node, int type, int maxports)
int portnum, isalias = 0;
Port *port;
char *s;
+ char *p;
if (line[0] == '@') {
isalias = 1;
@@ -671,6 +672,7 @@ static int parse_port(char *line, Node * node, int type, int maxports)
}
parse_opt:
line = s;
+ p = s;
while (s && (s = strchr(s + 1, '='))) {
char *opt = s;
while (opt && !isalpha(*opt))
@@ -685,6 +687,52 @@ static int parse_port(char *line, Node * node, int type, int maxports)
IBWARN("cannot parse lid, lmc");
return -1;
}
+
+ /* parse width speed from '[0-9]*x[SDQ]DR' pattern */
+ /* also checking for valid width value */
+ char wstr[3];
+ char sstr[3];
+ s = p;
+ while (s && (s = strchr(s + 1, 'x'))) {
+ int width;
+ p = s - 1;
+ while (p && !isdigit(*p))
+ p--;
+ width = atoi(p);
+ switch (width) {
+ case 1: strcpy(wstr, "1");
+ break;
+ case 4: strcpy(wstr, "2");
+ break;
+ case 8: strcpy(wstr, "4");
+ break;
+ case 12: strcpy(wstr, "8");
+ break;
+ default: wstr[0] = sstr[0] = 0;
+ continue;
+ }
+ p = p + 2;
+ if (!strncmp("SDR", p, 3))
+ strcpy(sstr, "1");
+ else if (!strncmp("DDR", p, 3))
+ strcpy(sstr, "2");
+ else if (!strncmp("QDR", p, 3))
+ strcpy(sstr, "4");
+ else {
+ wstr[0] = sstr[0] = 0;
+ continue;
+ }
+ }
+
+ if (parse_port_opt(port, "w", wstr) < 0) {
+ IBWARN("bad port option");
+ return -1;
+ }
+
+ if (parse_port_opt(port, "s", sstr) < 0) {
+ IBWARN("bad port option");
+ return -1;
+ }
return 1;
}
--
1.7.2.1
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 3+ messages in thread[parent not found: <4C7F5444.4030302-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH] ibsim: parse width and speed from ibnetdiscover output [not found] ` <4C7F5444.4030302-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2010-09-02 10:33 ` Hal Rosenstock [not found] ` <AANLkTi=3R5=obzp=hXmsh9HDswMMV770AB4cZvpTkhZc-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 3+ messages in thread From: Hal Rosenstock @ 2010-09-02 10:33 UTC (permalink / raw) To: Eli Dorfman (Voltaire); +Cc: Sasha Khapyorsky, linux-rdma On Thu, Sep 2, 2010 at 3:37 AM, Eli Dorfman (Voltaire) <dorfman.eli@gmail.com> wrote: > > Search for the pattern '[0-9]*x[SDQ]DR' > Validate that width value is valid. If this is done (to ibsim), is the previous patch for ibnetdiscover -f still needed ? -- Hal > Signed-off-by: Eli Dorfman <elid@voltaire.com> > --- > ibsim/sim_net.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 48 insertions(+), 0 deletions(-) > > diff --git a/ibsim/sim_net.c b/ibsim/sim_net.c > index 13c3b8c..278c065 100644 > --- a/ibsim/sim_net.c > +++ b/ibsim/sim_net.c > @@ -611,6 +611,7 @@ static int parse_port(char *line, Node * node, int type, int maxports) > int portnum, isalias = 0; > Port *port; > char *s; > + char *p; > > if (line[0] == '@') { > isalias = 1; > @@ -671,6 +672,7 @@ static int parse_port(char *line, Node * node, int type, int maxports) > } > parse_opt: > line = s; > + p = s; > while (s && (s = strchr(s + 1, '='))) { > char *opt = s; > while (opt && !isalpha(*opt)) > @@ -685,6 +687,52 @@ static int parse_port(char *line, Node * node, int type, int maxports) > IBWARN("cannot parse lid, lmc"); > return -1; > } > + > + /* parse width speed from '[0-9]*x[SDQ]DR' pattern */ > + /* also checking for valid width value */ > + char wstr[3]; > + char sstr[3]; > + s = p; > + while (s && (s = strchr(s + 1, 'x'))) { > + int width; > + p = s - 1; > + while (p && !isdigit(*p)) > + p--; > + width = atoi(p); > + switch (width) { > + case 1: strcpy(wstr, "1"); > + break; > + case 4: strcpy(wstr, "2"); > + break; > + case 8: strcpy(wstr, "4"); > + break; > + case 12: strcpy(wstr, "8"); > + break; > + default: wstr[0] = sstr[0] = 0; > + continue; > + } > + p = p + 2; > + if (!strncmp("SDR", p, 3)) > + strcpy(sstr, "1"); > + else if (!strncmp("DDR", p, 3)) > + strcpy(sstr, "2"); > + else if (!strncmp("QDR", p, 3)) > + strcpy(sstr, "4"); > + else { > + wstr[0] = sstr[0] = 0; > + continue; > + } > + } > + > + if (parse_port_opt(port, "w", wstr) < 0) { > + IBWARN("bad port option"); > + return -1; > + } > + > + if (parse_port_opt(port, "s", sstr) < 0) { > + IBWARN("bad port option"); > + return -1; > + } > return 1; > } > > -- > 1.7.2.1 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <AANLkTi=3R5=obzp=hXmsh9HDswMMV770AB4cZvpTkhZc-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH] ibsim: parse width and speed from ibnetdiscover output [not found] ` <AANLkTi=3R5=obzp=hXmsh9HDswMMV770AB4cZvpTkhZc-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2010-09-02 20:19 ` Eli Dorfman 0 siblings, 0 replies; 3+ messages in thread From: Eli Dorfman @ 2010-09-02 20:19 UTC (permalink / raw) To: Hal Rosenstock; +Cc: Sasha Khapyorsky, linux-rdma On Thu, Sep 2, 2010 at 1:33 PM, Hal Rosenstock <hal.rosenstock@gmail.com> wrote: > On Thu, Sep 2, 2010 at 3:37 AM, Eli Dorfman (Voltaire) > <dorfman.eli@gmail.com> wrote: >> >> Search for the pattern '[0-9]*x[SDQ]DR' >> Validate that width value is valid. > > If this is done (to ibsim), is the previous patch for ibnetdiscover -f > still needed ? I assume that it is redundant unless user names its devices with same pattern "[0-9]*x[SDQ]DR". I can give priority to the 's=' and 'w=' options and skip parsing of the above pattern. Eli > > -- Hal > >> Signed-off-by: Eli Dorfman <elid@voltaire.com> >> --- >> ibsim/sim_net.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ >> 1 files changed, 48 insertions(+), 0 deletions(-) >> >> diff --git a/ibsim/sim_net.c b/ibsim/sim_net.c >> index 13c3b8c..278c065 100644 >> --- a/ibsim/sim_net.c >> +++ b/ibsim/sim_net.c >> @@ -611,6 +611,7 @@ static int parse_port(char *line, Node * node, int type, int maxports) >> int portnum, isalias = 0; >> Port *port; >> char *s; >> + char *p; >> >> if (line[0] == '@') { >> isalias = 1; >> @@ -671,6 +672,7 @@ static int parse_port(char *line, Node * node, int type, int maxports) >> } >> parse_opt: >> line = s; >> + p = s; >> while (s && (s = strchr(s + 1, '='))) { >> char *opt = s; >> while (opt && !isalpha(*opt)) >> @@ -685,6 +687,52 @@ static int parse_port(char *line, Node * node, int type, int maxports) >> IBWARN("cannot parse lid, lmc"); >> return -1; >> } >> + >> + /* parse width speed from '[0-9]*x[SDQ]DR' pattern */ >> + /* also checking for valid width value */ >> + char wstr[3]; >> + char sstr[3]; >> + s = p; >> + while (s && (s = strchr(s + 1, 'x'))) { >> + int width; >> + p = s - 1; >> + while (p && !isdigit(*p)) >> + p--; >> + width = atoi(p); >> + switch (width) { >> + case 1: strcpy(wstr, "1"); >> + break; >> + case 4: strcpy(wstr, "2"); >> + break; >> + case 8: strcpy(wstr, "4"); >> + break; >> + case 12: strcpy(wstr, "8"); >> + break; >> + default: wstr[0] = sstr[0] = 0; >> + continue; >> + } >> + p = p + 2; >> + if (!strncmp("SDR", p, 3)) >> + strcpy(sstr, "1"); >> + else if (!strncmp("DDR", p, 3)) >> + strcpy(sstr, "2"); >> + else if (!strncmp("QDR", p, 3)) >> + strcpy(sstr, "4"); >> + else { >> + wstr[0] = sstr[0] = 0; >> + continue; >> + } >> + } >> + >> + if (parse_port_opt(port, "w", wstr) < 0) { >> + IBWARN("bad port option"); >> + return -1; >> + } >> + >> + if (parse_port_opt(port, "s", sstr) < 0) { >> + IBWARN("bad port option"); >> + return -1; >> + } >> return 1; >> } >> >> -- >> 1.7.2.1 >> >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html >> > ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-09-02 20:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-02 7:37 [PATCH] ibsim: parse width and speed from ibnetdiscover output Eli Dorfman (Voltaire)
[not found] ` <4C7F5444.4030302-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-09-02 10:33 ` Hal Rosenstock
[not found] ` <AANLkTi=3R5=obzp=hXmsh9HDswMMV770AB4cZvpTkhZc-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-09-02 20:19 ` Eli Dorfman
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox