From patchwork Thu Feb 27 12:48:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Klein X-Patchwork-Id: 3732621 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 C3E979F38C for ; Thu, 27 Feb 2014 12:48:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DC9D52020A for ; Thu, 27 Feb 2014 12:48:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 483C420204 for ; Thu, 27 Feb 2014 12:48:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751573AbaB0Msr (ORCPT ); Thu, 27 Feb 2014 07:48:47 -0500 Received: from mailp.voltaire.com ([193.47.165.129]:42446 "EHLO mellanox.co.il" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751457AbaB0Msq (ORCPT ); Thu, 27 Feb 2014 07:48:46 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from danielk@mellanox.com) with SMTP; 27 Feb 2014 14:48:43 +0200 Received: from r-ufm106.mtr.labs.mlnx (r-ufm106.mtr.labs.mlnx [10.209.36.198]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id s1RCmeNW013588; Thu, 27 Feb 2014 14:48:40 +0200 Received: from r-ufm106.mtr.labs.mlnx (localhost [127.0.0.1]) by r-ufm106.mtr.labs.mlnx (8.14.4/8.14.4) with ESMTP id s1RCmeqB031146; Thu, 27 Feb 2014 14:48:40 +0200 Received: (from danielk@localhost) by r-ufm106.mtr.labs.mlnx (8.14.4/8.14.4/Submit) id s1RCme8K031145; Thu, 27 Feb 2014 14:48:40 +0200 From: Daniel Klein To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Eli Dorfman , Alex Netes Subject: [PATCH] ibsim: allocate mft according to number of switch ports Date: Thu, 27 Feb 2014 14:48:36 +0200 Message-Id: <1393505316-31115-1-git-send-email-danielk@mellanox.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: References: Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 From: Eli Dorfman calculate number of port masks according to number of switch ports and allocate MFT accordingly Signed-off-by: Eli Dorfman Signed-off-by: Alex Netes --- ibsim/sim.h | 5 ++--- ibsim/sim_mad.c | 5 +++-- ibsim/sim_net.c | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ibsim/sim.h b/ibsim/sim.h index daeecec..6b33a2c 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 @@ -318,6 +316,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 223d507..d851aa8 100644 --- a/ibsim/sim_mad.c +++ b/ibsim/sim_mad.c @@ -532,18 +532,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 10820ba..fe4687a 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; }