From patchwork Wed Sep 15 11:55:16 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: 182332 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 o8FBYBfc028400 for ; Wed, 15 Sep 2010 11:34:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751222Ab0IOLeK (ORCPT ); Wed, 15 Sep 2010 07:34:10 -0400 Received: from fwil.voltaire.com ([193.47.165.2]:27547 "EHLO exil.voltaire.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750844Ab0IOLeK (ORCPT ); Wed, 15 Sep 2010 07:34:10 -0400 Received: from [172.25.1.69] ([172.25.1.69]) by exil.voltaire.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 15 Sep 2010 13:34:07 +0200 Message-ID: <4C90B424.4060104@gmail.com> Date: Wed, 15 Sep 2010 13:55:16 +0200 From: "Eli Dorfman (Voltaire)" User-Agent: Thunderbird 2.0.0.17 (X11/20080914) MIME-Version: 1.0 To: Sasha Khapyorsky CC: linux-rdma , Vladimir Koushnir Subject: Re: [PATCH v2] ibsim: allocate mft according to number of switch ports References: <4C8E1470.8070106@gmail.com> In-Reply-To: <4C8E1470.8070106@gmail.com> X-OriginalArrivalTime: 15 Sep 2010 11:34:07.0316 (UTC) FILETIME=[E853D940:01CB54C9] 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]); Wed, 15 Sep 2010 11:34:11 +0000 (UTC) diff --git a/ibsim/sim.h b/ibsim/sim.h index 30f5075..c4ee11f 100644 --- a/ibsim/sim.h +++ b/ibsim/sim.h @@ -45,9 +45,7 @@ #define MAXLINEARCAP (30*1024) #define MAXMCASTCAP 1024 #define LASTBLOCK32 (MAXMCASTCAP/32-1) -// NUMBEROFPORTMASK means that 32port switches could only be build -#define NUMBEROFPORTMASK 2 -#define LASTPORTMASK (NUMBEROFPORTMASK-1) +#define MCASTMASKSIZE 16 // linkwidth == 4X - must be one width only 1,2 or 8 #define LINKWIDTH_1x 1 #define LINKWIDTH_4x 2 @@ -229,6 +227,7 @@ struct Switch { int linearFDBtop; int portchange; int lifetime; + int numportmask; uint8_t switchinfo[64]; Node *node; uint8_t *fdb; diff --git a/ibsim/sim_mad.c b/ibsim/sim_mad.c index 61d4866..3133bcf 100644 --- a/ibsim/sim_mad.c +++ b/ibsim/sim_mad.c @@ -513,18 +513,19 @@ static int do_multicastforwtbl(Port * port, unsigned op, uint32_t mod, int blockposition; Switch *sw = port->node->sw; + int lastportmask = sw->numportmask + 1; if (!sw) // not a Switch? return ERR_ATTR_UNSUPPORTED; VERB("requested : Block32 %d PortMask %d", numBlock32, numPortMsk); - if (numBlock32 > LASTBLOCK32 || numPortMsk > LASTPORTMASK) { + if (numBlock32 > LASTBLOCK32 || numPortMsk > lastportmask) { int8_t zeroblock[64] = { 0 }; mad_set_array(data, 0, IB_MULTICAST_FORW_TBL_F, zeroblock); return 0; } - blockposition = (numBlock32 * NUMBEROFPORTMASK + numPortMsk) * 64; + blockposition = (numBlock32 * sw->numportmask + numPortMsk) * 64; if (op == IB_MAD_METHOD_SET) mad_get_array(data, 0, IB_MULTICAST_FORW_TBL_F, sw->mfdb + blockposition); diff --git a/ibsim/sim_net.c b/ibsim/sim_net.c index 13c3b8c..f17f0b9 100644 --- a/ibsim/sim_net.c +++ b/ibsim/sim_net.c @@ -245,6 +245,7 @@ static Switch *new_switch(Node * nd, int set_esp0) sw->node = nd; sw->linearcap = maxlinearcap; // assume identical val for all switches sw->multicastcap = maxmcastcap; // assume identical val for all switches + sw->numportmask = (nd->numports + MCASTMASKSIZE) / MCASTMASKSIZE; memcpy(sw->switchinfo, switchinfo, sizeof(sw->switchinfo)); mad_set_field(sw->switchinfo, 0, IB_SW_LINEAR_FDB_CAP_F, sw->linearcap); mad_set_field(sw->switchinfo, 0, IB_SW_MCAST_FDB_CAP_F, @@ -253,13 +254,13 @@ static Switch *new_switch(Node * nd, int set_esp0) mad_set_field(sw->switchinfo, 0, IB_SW_ENHANCED_PORT0_F, set_esp0 > 0); sw->fdb = malloc(maxlinearcap*sizeof(sw->fdb[0])); - sw->mfdb = malloc(maxmcastcap*NUMBEROFPORTMASK*sizeof(uint16_t)); + sw->mfdb = malloc(maxmcastcap * sw->numportmask * sizeof(uint16_t)); if (!sw->fdb || !sw->mfdb) { IBPANIC("new_switch: no mem: %m"); return NULL; } memset(sw->fdb, 0xff, maxlinearcap*sizeof(sw->fdb[0])); - memset(sw->mfdb, 0, maxmcastcap*NUMBEROFPORTMASK*sizeof(uint16_t)); + memset(sw->mfdb, 0, maxmcastcap * sw->numportmask * sizeof(uint16_t)); return sw; }