From patchwork Mon Jan 2 12:20:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 9493421 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 3961062AB3 for ; Mon, 2 Jan 2017 12:21:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B801205AD for ; Mon, 2 Jan 2017 12:21:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F0F2267EC; Mon, 2 Jan 2017 12:21:08 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID,T_TVD_MIME_EPI 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 7A619205AD for ; Mon, 2 Jan 2017 12:21:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755612AbdABMVG (ORCPT ); Mon, 2 Jan 2017 07:21:06 -0500 Received: from mail-oi0-f48.google.com ([209.85.218.48]:34782 "EHLO mail-oi0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751755AbdABMVF (ORCPT ); Mon, 2 Jan 2017 07:21:05 -0500 Received: by mail-oi0-f48.google.com with SMTP id 3so297063997oih.1 for ; Mon, 02 Jan 2017 04:21:05 -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; bh=RbBDQV1uhUsKthm1m56xjjFqXqPX5byHO0HFQG6gIsI=; b=hzsuzh8hAA4BGDHn39nXycbZFblTLkkLEPaz1hxwJeNLuckPjLXNYIKwykObcQxeld CWJIaYnbOJCYfr8Wv1b0F7gGGgbhr24La98KZuwZDyqvIGWBFqZS3k4XZzhdM4/2r9t+ scGfMb478xOGZCCe2mw0TPYPeHKjlnYBDKMIy1hOXexa2uKgEhRUbnTMt+J4kPyVqKem isF7/PfNflnRk/D0UGhRNdvKw9qqHx8Ex4XPu293y26ReYKBgieqdR6z5ahtLQF4444T 4rObl9MpfVAYXJm8MVgt5prcagQF97APwEgZ1rdjl4CSxa0nZIiYMKCqUQryCUMm0Xtb ZdtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=RbBDQV1uhUsKthm1m56xjjFqXqPX5byHO0HFQG6gIsI=; b=EPaq0jjVl09p2zo0EEuebtuXSnq+eYhbmKQ3OZW/GwEX5uNHciyod0fF1ZUBimNaYr HfFYsU5poswjlPiXCCEDQpJ/EyXoYYDfAcc1Hb/iotryZ6lVdDggTj6gySEtjkAlWeGE dQO/ITzySCNzBdUarsPEYlDpFwFVVzI/cWa3kBKi9/dnwxSy3hdVSQXeczSo3o6PeY5d 1He5lhPqNW+B/0razF8h9jgM+9egWzeZn34LX7YYIfC7Jn2y0LInYt1+YO/OL9PQqZMg efoE4iAn55MG9FFvP/2hJ2Ukwo7lu/S0EdeZFBt0K44YLAeztsSKeJZWpg6UXG+KQaku Eg3w== X-Gm-Message-State: AIkVDXKFdWFSse7i2jEOW4Y+3h1lA0tMi46rphVCMeDb29mul/hJPWNm5mAs88lIpDoHVHqjg8cc9g8Mvd4JF5pf X-Received: by 10.202.50.4 with SMTP id y4mr28948345oiy.180.1483359665098; Mon, 02 Jan 2017 04:21:05 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.241.198 with HTTP; Mon, 2 Jan 2017 04:20:44 -0800 (PST) From: Jinpu Wang Date: Mon, 2 Jan 2017 13:20:44 +0100 Message-ID: Subject: [PATCHv2 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 b52637c12a7805ee3e500dc3d97c2fe300c02ff8 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 Acked-by: Sean Hefty --- drivers/infiniband/core/cma.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) cma_dev = NULL; @@ -724,6 +725,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++) { @@ -735,7 +738,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; From b52637c12a7805ee3e500dc3d97c2fe300c02ff8 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 Acked-by: Sean Hefty --- drivers/infiniband/core/cma.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 8c30e3d..fcd5047 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -709,6 +709,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; cma_dev = NULL; @@ -724,6 +725,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++) { @@ -735,7 +738,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; -- 2.7.4