From patchwork Sun Oct 20 12:30:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 3073131 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 88C30BF924 for ; Sun, 20 Oct 2013 12:30:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9D56B2059C for ; Sun, 20 Oct 2013 12:30:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B5CA420597 for ; Sun, 20 Oct 2013 12:30:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751443Ab3JTMaN (ORCPT ); Sun, 20 Oct 2013 08:30:13 -0400 Received: from mail-we0-f176.google.com ([74.125.82.176]:40958 "EHLO mail-we0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751326Ab3JTMaM (ORCPT ); Sun, 20 Oct 2013 08:30:12 -0400 Received: by mail-we0-f176.google.com with SMTP id w62so5435956wes.35 for ; Sun, 20 Oct 2013 05:30:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:content-type:content-transfer-encoding; bh=FigShfiCNdIKFV+jOC2L6MWvm0VnpgOoJypgZ0u6FAM=; b=eUPcVMcD60OpUDJddJvnEsaf6MggZ4uM/SHmv+jjGKVfoj/CuEbvkpntgSs0QDb6+y ZDoWEhxbBJnja0JiaX64jXeC6aS6T2rviqcIWPU7kbNOegbC283Y3n6ODLHCddIlm6EL 48003e/rASL0iXO7HQzB07VPaAtD59PLBy8pUqTIKkCgQOnjwQ015+9VDsJtHG0HmH8x sgO4ZPRwzbcqj5B9j+L5YzMLZcMmoTmbhvaM8dt6DvFbKEqlslxVpLJw3eR/2nUJ+xH9 vX74Pg9ZtczpReVclKmcayXY2XjY9OFpy5/RC14Hm3KyJVm6Z3aK4rMkK8sZCrJaUjZK xScA== X-Gm-Message-State: ALoCoQkhQFT1sR6brASOZeAPVJHLbm9I1XWOI/4rdBgP61AbBuC6WSJLigEagRSCP+F7Z66f4IFe X-Received: by 10.194.241.228 with SMTP id wl4mr9706688wjc.2.1382272211349; Sun, 20 Oct 2013 05:30:11 -0700 (PDT) Received: from [10.222.163.5] (out.voltaire.com. [193.47.165.251]) by mx.google.com with ESMTPSA id q17sm21873299wiv.10.2013.10.20.05.30.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 20 Oct 2013 05:30:10 -0700 (PDT) Message-ID: <5263CCD0.2010605@dev.mellanox.co.il> Date: Sun, 20 Oct 2013 08:30:08 -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: "linux-rdma (linux-rdma@vger.kernel.org)" CC: Daniel Klein , Alex Netes Subject: [PATCH opensm] osm_pkey.c: Fix find common pkey bug fix Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.3 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: Daniel Klein When OpenSM supports keeping both full and limited membership pkeys for same port, search common pkey algorithm might miss a pkey shared by two ports. OpenSM iterates over pkey table of both ports, trying to find a matching pkey, where the pkeys are sorted by network order value of the pkeys (including membership bit). When OpenSM searches for the shared pkey, it advances the iterator with the lower key value. when comparing the keys without ignoring the membership bit, OpenSM might miss a shared pkey. For example: Port 1 pkeys : 0x0081 0x0082 Port 2 pkeys : 0x0002 0x0003 Signed-off-by: Daniel Klein Signed-off-by: Alex Netes Signed-off-by: Hal Rosenstock --- opensm/osm_pkey.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/opensm/osm_pkey.c b/opensm/osm_pkey.c index 4f5aa73..7a24156 100644 --- a/opensm/osm_pkey.c +++ b/opensm/osm_pkey.c @@ -430,8 +430,8 @@ ib_net16_t osm_physp_find_common_pkey(IN const osm_physp_t * p_physp1, return *pkey1; /* advance the lower value if they are not equal */ - pkey1_base = cl_map_key(map_iter1); - pkey2_base = cl_map_key(map_iter2); + pkey1_base = ib_pkey_get_base(cl_map_key(map_iter1)); + pkey2_base = ib_pkey_get_base(cl_map_key(map_iter2)); if (pkey2_base == pkey1_base) { map_iter1 = cl_map_next(map_iter1); map_iter2 = cl_map_next(map_iter2); @@ -463,8 +463,8 @@ ib_net16_t osm_physp_find_common_pkey(IN const osm_physp_t * p_physp1, return *pkey1; /* advance the lower value if they are not equal */ - pkey1_base = cl_map_key(map_iter1); - pkey2_base = cl_map_key(map_iter2); + pkey1_base = ib_pkey_get_base(cl_map_key(map_iter1)); + pkey2_base = ib_pkey_get_base(cl_map_key(map_iter2)); if (pkey2_base == pkey1_base) { map_iter1 = cl_map_next(map_iter1); map_iter2 = cl_map_next(map_iter2);