From patchwork Mon Jun 24 13:08:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 2771331 X-Patchwork-Delegate: hal@mellanox.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E30C4C0AB1 for ; Mon, 24 Jun 2013 13:08:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8F5D420226 for ; Mon, 24 Jun 2013 13:08:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D181B20221 for ; Mon, 24 Jun 2013 13:08:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750797Ab3FXNIR (ORCPT ); Mon, 24 Jun 2013 09:08:17 -0400 Received: from mail-la0-f42.google.com ([209.85.215.42]:50585 "EHLO mail-la0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750783Ab3FXNIQ (ORCPT ); Mon, 24 Jun 2013 09:08:16 -0400 Received: by mail-la0-f42.google.com with SMTP id eb20so10219447lab.29 for ; Mon, 24 Jun 2013 06:08:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding:x-gm-message-state; bh=7tUTeVuSp4whKbIwSi5qrbTaO4ElrTphTiRmmAtf6BU=; b=Uel+TxmFWbOxLPUEsFNZmcT/VDEdafMW4NtifbONMB9PYPfTblYkvjxt2KRpcuHYe7 Pb3k2sTC5NfBQXTj6ZRHfhSmPVxuXI2GXYSC3DmIZ7AvxMyQWnn2ZgRyxSuF0Mq+dVH9 VniYXcFVPht0CJVbj8xf6eUsWp2XA+U6gAdCFi4janiEIw7Z41IpOlDoLwyoxyxSdo4n nRrat/kyU9CLfz04MEN7pe5HbXfs+mQHDDvzuk5RMOlMnlspKPAr5Q/k89eOwcYb+4hM aolK5JASmaMVd84kE9KFgUznP5g6xvPAyp3V3FHwd6/5BKjx7l3TRex7Gf7YiGRWdjMG yppQ== X-Received: by 10.112.51.16 with SMTP id g16mr12717963lbo.0.1372079294956; Mon, 24 Jun 2013 06:08:14 -0700 (PDT) Received: from [192.168.1.102] (c-71-234-225-85.hsd1.ct.comcast.net. [71.234.225.85]) by mx.google.com with ESMTPSA id et10sm6720255lbc.6.2013.06.24.06.08.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Jun 2013 06:08:13 -0700 (PDT) Message-ID: <51C844BA.1050608@dev.mellanox.co.il> Date: Mon, 24 Jun 2013 09:08:10 -0400 From: Hal Rosenstock User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: "Chu, Al" CC: "linux-rdma (linux-rdma@vger.kernel.org)" Subject: [PATCH ibsim] sim_client.c: Set issm flag on connect when SIM_SET_ISSM set X-Gm-Message-State: ALoCoQljZj+Skg9cpJf25FaqjE8LDDgRCWBOD9h02jpKxIEtJqGb1MzLyeWxpLxtGvTCKn9E7nDN Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-8.0 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 When the SIM_SET_ISSM environment variable is set, ibsim did not set the issm bit until after an ibsim connection was complete. This allowed multiple SMs to actively run as the SM on the the same port. Slight rework of original patch from Al Chu. Signed-off-by: Albert L. Chu Signed-off-by: Hal Rosenstock --- -- 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 diff --git a/umad2sim/sim_client.c b/umad2sim/sim_client.c index eb42a7c..cec72d9 100644 --- a/umad2sim/sim_client.c +++ b/umad2sim/sim_client.c @@ -173,12 +173,16 @@ static int sim_attach(int fd, union name_t *name, size_t size) return 0; } -static int sim_connect(struct sim_client *sc, int id, int qp, char *nodeid) +static int sim_connect(struct sim_client *sc, int id, int qp, char *nodeid, + char *issm) { struct sim_client_info info = { 0 }; info.id = id; - info.issm = 0; + if (issm) + info.issm = 1; + else + info.issm = 0; info.qp = qp; if (nodeid) @@ -200,7 +204,7 @@ static int sim_disconnect(struct sim_client *sc) return sim_ctl(sc, SIM_CTL_DISCONNECT, 0, 0); } -static int sim_init(struct sim_client *sc, char *nodeid) +static int sim_init(struct sim_client *sc, char *nodeid, char *issm) { union name_t name; socklen_t size; @@ -254,7 +258,7 @@ static int sim_init(struct sim_client *sc, char *nodeid) IBPANIC("can't read data from bound socket"); port = ntohs(name.name_i.sin_port); - sc->clientid = sim_connect(sc, remote_mode ? port : pid, 0, nodeid); + sc->clientid = sim_connect(sc, remote_mode ? port : pid, 0, nodeid, issm); if (sc->clientid < 0) IBPANIC("connect failed"); @@ -284,9 +288,11 @@ int sim_client_set_sm(struct sim_client *sc, unsigned issm) int sim_client_init(struct sim_client *sc) { char *nodeid; + char *issm; nodeid = getenv("SIM_HOST"); - if (sim_init(sc, nodeid) < 0) + issm = getenv("SIM_SET_ISSM"); + if (sim_init(sc, nodeid, issm) < 0) return -1; if (sim_ctl(sc, SIM_CTL_GET_VENDOR, &sc->vendor, sizeof(sc->vendor)) < 0) @@ -301,7 +307,7 @@ int sim_client_init(struct sim_client *sc) goto _exit; if (sim_ctl(sc, SIM_CTL_GET_PKEYS, sc->pkeys, sizeof(sc->pkeys)) < 0) goto _exit; - if (getenv("SIM_SET_ISSM")) + if (issm) sim_client_set_sm(sc, 1); return 0; _exit: