From patchwork Thu Sep 2 07:37:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eli Dorfman (Voltaire)" X-Patchwork-Id: 148491 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o827H8RK032336 for ; Thu, 2 Sep 2010 07:17:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752359Ab0IBHRH (ORCPT ); Thu, 2 Sep 2010 03:17:07 -0400 Received: from fwil.voltaire.com ([193.47.165.2]:37609 "EHLO exil.voltaire.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751675Ab0IBHRH (ORCPT ); Thu, 2 Sep 2010 03:17:07 -0400 Received: from [172.25.1.69] ([172.25.1.69]) by exil.voltaire.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 2 Sep 2010 10:17:04 +0300 Message-ID: <4C7F5444.4030302@gmail.com> Date: Thu, 02 Sep 2010 10:37:40 +0300 From: "Eli Dorfman (Voltaire)" User-Agent: Thunderbird 2.0.0.17 (X11/20080914) MIME-Version: 1.0 To: Sasha Khapyorsky CC: linux-rdma Subject: [PATCH] ibsim: parse width and speed from ibnetdiscover output X-OriginalArrivalTime: 02 Sep 2010 07:17:04.0023 (UTC) FILETIME=[D7F55A70:01CB4A6E] Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 02 Sep 2010 07:18:07 +0000 (UTC) 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; }