From patchwork Thu Jun 13 21:30:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Chu X-Patchwork-Id: 2718611 X-Patchwork-Delegate: hal@mellanox.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E65FF9F967 for ; Thu, 13 Jun 2013 21:31:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 449FD2028A for ; Thu, 13 Jun 2013 21:31:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2FCFF20262 for ; Thu, 13 Jun 2013 21:31:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757810Ab3FMVbs (ORCPT ); Thu, 13 Jun 2013 17:31:48 -0400 Received: from prdiron-2.llnl.gov ([128.15.143.172]:1861 "EHLO prdiron-2.llnl.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755565Ab3FMVbs (ORCPT ); Thu, 13 Jun 2013 17:31:48 -0400 X-Attachments: Received: from auk59.llnl.gov (HELO [134.9.93.24]) ([134.9.93.24]) by prdiron-2.llnl.gov with ESMTP; 13 Jun 2013 14:30:45 -0700 Subject: [PATCH 2/2] ibsim: Add support for fabric VL Cap in network definition file From: Albert Chu To: linux-rdma@vger.kernel.org Date: Thu, 13 Jun 2013 14:30:45 -0700 Message-Id: <1371159045.13124.182.camel@auk59.llnl.gov> Mime-Version: 1.0 X-Mailer: Evolution 2.12.3 (2.12.3-19.el5) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Albert L. Chu --- ibsim/sim.h | 1 + ibsim/sim_mad.c | 2 ++ ibsim/sim_net.c | 28 ++++++++++++++++++++++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/ibsim/sim.h b/ibsim/sim.h index daeecec..831b4a5 100644 --- a/ibsim/sim.h +++ b/ibsim/sim.h @@ -289,6 +289,7 @@ struct Port { int physstate; int lmc; int hoqlife; + int vlcap; uint8_t portinfo[64]; uint8_t op_vls; diff --git a/ibsim/sim_mad.c b/ibsim/sim_mad.c index 0b52c52..a589d13 100644 --- a/ibsim/sim_mad.c +++ b/ibsim/sim_mad.c @@ -490,6 +490,8 @@ do_portinfo(Port * port, unsigned op, uint32_t portnum, uint8_t * data) val = mad_get_field(data, 0, IB_PORT_OPER_VLS_F); if (val > mad_get_field(data, 0, IB_PORT_VL_CAP_F)) return ERR_BAD_PARAM; + if (p->vlcap && val > p->vlcap) + return ERR_BAD_PARAM; p->op_vls = val; } diff --git a/ibsim/sim_net.c b/ibsim/sim_net.c index 10820ba..e8c07eb 100644 --- a/ibsim/sim_net.c +++ b/ibsim/sim_net.c @@ -413,6 +413,15 @@ static int is_linkspeed_valid(int speed) return 1; } +static int is_vlcap_valid(int vlcap) +{ + if (vlcap < 1 || vlcap > 5) { + IBWARN("bad vlcap %d - should be between 1 to 5", vlcap); + return 0; + } + return 1; +} + static int parse_switch_esp0(char *line) { if (strstr(line, "enhanced port 0")) @@ -462,6 +471,14 @@ static int parse_port_opt(Port * port, char *opt, char *val) DEBUG("port %p linkspeed enabled set to %d", port, port->linkspeedena); break; + case 'v': + v = strtoul(val, 0, 0); + if (!is_vlcap_valid(v)) + return -1; + + port->vlcap = v; + DEBUG("port %p vlcap set to %d", port, port->vlcap); + break; default: break; } @@ -1088,13 +1105,20 @@ void update_portinfo(Port * p) mad_set_field(pi, 0, IB_PORT_HOQ_LIFE_F, p->hoqlife); mad_set_field(pi, 0, IB_PORT_PHYS_STATE_F, p->physstate); mad_set_field(pi, 0, IB_PORT_STATE_F, p->state); + if (p->vlcap) + mad_set_field(pi, 0, IB_PORT_VL_CAP_F, p->vlcap); } static void set_portinfo(Port * p, const uint8_t portinfo[]) { memcpy(p->portinfo, portinfo, sizeof(p->portinfo)); - if (!p->op_vls) - p->op_vls = mad_get_field(p->portinfo, 0, IB_PORT_VL_CAP_F); + if (!p->op_vls) { + if (p->vlcap) + p->op_vls = p->vlcap; + else + p->op_vls = mad_get_field(p->portinfo, 0, + IB_PORT_VL_CAP_F); + } } int link_ports(Port * lport, Port * rport)