From patchwork Mon Dec 12 11:48:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 9470505 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 73A5A60476 for ; Mon, 12 Dec 2016 11:48:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6625828456 for ; Mon, 12 Dec 2016 11:48:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59AEA28472; Mon, 12 Dec 2016 11:48:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDE9128456 for ; Mon, 12 Dec 2016 11:48:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751356AbcLLLs2 (ORCPT ); Mon, 12 Dec 2016 06:48:28 -0500 Received: from mail-oi0-f47.google.com ([209.85.218.47]:34906 "EHLO mail-oi0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750899AbcLLLs2 (ORCPT ); Mon, 12 Dec 2016 06:48:28 -0500 Received: by mail-oi0-f47.google.com with SMTP id b126so84718065oia.2 for ; Mon, 12 Dec 2016 03:48:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=profitbricks-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=Ty7BShbb4GZJXZF3a2JFuSNpZETOPvsDTl5NHyqxj8g=; b=iV2XA1Rw5xaj4OMg41vxphXGHLB5onEhj6O9uDSTcEYd8BD6ewWXpJy4mEfzMfv5f6 IyFQ/gFDqop6lFEu9QKqx9bbdn69L/ysg2rDbMQIGwwDhRqt/tADoKLGnjroDcA/QwgU mu0mT4OeZDjMCbNH1pal3lthQzkrDjzy9Wt1JaGeBMWlVYJ+Q2/QvFgiuAtwY6kL8Uu4 bF/TZjiCfO4L94NA4MYDfD3OR1OFJKmaCUg312YVCDUFxeJC6VNvc28Iz5skAhhNdFN5 xMM9NH03iiSN0uPeqXx1vNIGuh3ku/LC24TyOxwUqD2uSAkPc79nxYPqYw4UsHaNX/2+ r+Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=Ty7BShbb4GZJXZF3a2JFuSNpZETOPvsDTl5NHyqxj8g=; b=azS1RjB2JiqVC5baCDtwBtyC7VC8PMpDE9IUZHT5QbLi+qtdbCOQxW/pUd/eVp2EUm 63er8lMFB7aju4cVd/1178ZFRK9nt6I57Te2xuthvOm71nltVf5AjMjoVY4jdHScqqED QxP9b3wI2uh8g39LogZILENy9K49epz0mmOFCV+k2NRczMNL1Ir3ZxPEqo04/t4hJRL7 ZaozPh8njDVSFsDo7UcfylhfTZGoHtfOVjcnONxae9i9Ene0UORAsfx6CDlaxjjdYh9G 30E02TS9J1bljz9gQlb6X+v7CYkUtuqjrErMSmtgzzb3snC0ZNZUOlEBWhjB+HUBFzw+ biJQ== X-Gm-Message-State: AKaTC01DtOUEY/EIiz9bkj+dNG2FiXdsG0iI9KfRLzc+l+xl32qq0VN4xGDhrQm1qKndxKFHfJKiHFkStC49ruG2 X-Received: by 10.157.5.166 with SMTP id 35mr48489154otd.50.1481543307440; Mon, 12 Dec 2016 03:48:27 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.165.135 with HTTP; Mon, 12 Dec 2016 03:48:07 -0800 (PST) From: Jinpu Wang Date: Mon, 12 Dec 2016 12:48:07 +0100 Message-ID: Subject: [PATCH 3/4] cma: resolve to first active ib port To: Doug Ledford , "Hefty, Sean" , Hal Rosenstock , "linux-rdma@vger.kernel.org" , Michael Wang , Jason Gunthorpe Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From 77323a633072966e358c8f684e5ff4b665a27881 Mon Sep 17 00:00:00 2001 From: Jack Wang Date: Mon, 12 Dec 2016 10:23:55 +0100 Subject: [PATCH 3/4] cma: resolve to first active ib port When resolve addr if we don't give src addr, cma core will try to resolve to ib device on itself, current logic is only check if it has same subnet_prefix, which is not enough if we use default well known gid, we should also check if port is active. v3: use cached port_active state in ib_core. Signed-off-by: Jack Wang Reviewed-by: Michael Wang --- drivers/infiniband/core/cma.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) cma_dev = NULL; @@ -681,6 +682,8 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv) if (ib_find_cached_pkey(cur_dev->device, p, pkey, &index)) continue; + if (ib_get_cached_port_state(cur_dev->device, p, &port_state)) + continue; for (i = 0; !ib_get_cached_gid(cur_dev->device, p, i, &gid, NULL); i++) { @@ -692,7 +695,8 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv) } if (!cma_dev && (gid.global.subnet_prefix == - dgid->global.subnet_prefix)) { + dgid->global.subnet_prefix) && + port_state == IB_PORT_ACTIVE) { cma_dev = cur_dev; sgid = gid; id_priv->id.port_num = p; diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 2a6fc47..3413aec 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -666,6 +666,7 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv) union ib_gid gid, sgid, *dgid; u16 pkey, index; u8 p; + enum ib_port_state port_state; int i;