Received: by 10.192.165.148 with SMTP id m20csp5292225imm; Wed, 9 May 2018 02:35:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrAkny8sQU7jxSPAs3KQQmhnYJklULTXxZkVxV7XlKbfe9C+bCMn6JqlrIvmmnU7EvkSofI X-Received: by 10.98.58.28 with SMTP id h28mr43362377pfa.209.1525858512101; Wed, 09 May 2018 02:35:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525858512; cv=none; d=google.com; s=arc-20160816; b=vjypzekyCJgNoQX2JOnk0ZtAM1TbkgAqvoPLNHq/VnN+8dHck5HofJTJ/7oYL95cv3 wYUgoxhnTVmOV7GOyT4AjM+38qACFUOgdIPErs7mIuSC4+tHCx6yDGF11L1LKlJrePbN zx+IvohHj1yI2j+Y5ypqCNCX1XWojePvrN+w5J0fjBTewBIREA7+q1FTdALU3ephl8X0 kbbvDhUmf/sCSAiooNG0Avc2M5ZWPKGQAbpxT2MDMiZ+Eoebc7GiMRUBV00o8sADzDLq Sd/Dj8T+yZ0QoBkMowZ9PDsBtJ10PM82s6vM/9K+KDniBMEjlWueVi800O5nQjIccAsd 0f5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=sMPOaU2mcNwmAdsJmNp2/zVzsbomPB5RdlCBisQzdiU=; b=SFl9HyyibaHD3PkIvKsc8zvDEtUovjr64O4s8YFduKTOICghWHNDFy5BEE7b28H1mk pY9NtYknbvcC36tC+fW7/qD3QMR0ujgTMnkazI9SKVT+TLn8FXMZpkQKYFY/HD0uvSrw detqsytVvyV/BXUNpOndGpxIgYBBuJKXNnpr6nab9E4lI5oQS2G83kugajKyuSWlBrhz Q/hWXIjVprhsAxYPf4rGWkxnCtgh6O49TwP07KysdY+jS6Y4pxahbojAR0vvXE9MH3YE o86FAjNvqZXvMx+0WvpOPsnqqViPXpOpefe8mSRVwtJCLvChsgBYBCCUhVnpLEd9GAIJ WUUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=By9BmBBg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w24-v6si17345627plq.254.2018.05.09.02.34.57; Wed, 09 May 2018 02:35:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=By9BmBBg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934674AbeEIJbJ (ORCPT + 99 others); Wed, 9 May 2018 05:31:09 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:45040 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933860AbeEIJau (ORCPT ); Wed, 9 May 2018 05:30:50 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w499Q4T5182744; Wed, 9 May 2018 09:30:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=sMPOaU2mcNwmAdsJmNp2/zVzsbomPB5RdlCBisQzdiU=; b=By9BmBBgE9Stg0rJFtre8eCHv71E8dgtKYFZR61i6jVfrc0EVlsB2uy9os40H8CIzVUa 6Cl8THvnXvnVqS/AIvSCIMeNT/ZkgYObB9J119GQRE8cw0IXL6UqXku3G7jFlFZOz98k QAazPl1sPTrk+d2DLk8OzSd8qPu0EkS1PsCQ1AdZlWg7axjmoF2Ebc2Ijq0idJ6a3usH uj+8p23ZkGQLBrVJ9hVUR1lKN3ONRcbQZ6XG+7YYDtBEVJZu1PHoiR7K9akI6CF1VM/W oMgGRj54uUWHabFspn3EJ/tm7U7V40W8iQ5j5RH5MeSZFL6v0hjQKjDSLpnrl1IG5+an OA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2hs4k2cge6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 May 2018 09:30:32 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w499UVsx019637 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 9 May 2018 09:30:31 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w499UUDR014999; Wed, 9 May 2018 09:30:30 GMT Received: from lab02.no.oracle.com (/10.172.144.56) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 09 May 2018 02:30:30 -0700 From: =?UTF-8?q?H=C3=A5kon=20Bugge?= To: Doug Ledford , Don Hiatt , Ira Weiny , Sean Hefty Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?H=C3=A5kon=20Bugge?= Subject: [PATCH IB/core 1/2] IB/core: A full pkey is required to match a limited one Date: Wed, 9 May 2018 11:30:19 +0200 Message-Id: <20180509093020.24503-2-Haakon.Bugge@oracle.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180509093020.24503-1-Haakon.Bugge@oracle.com> References: <20180509093020.24503-1-Haakon.Bugge@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8887 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=922 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1805090090 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In ib_find_cached_pkey(), the preference is to return the pkey-index of the full pkey, if both a limited and the full exists in the cache. However, if both pkeys are limited, the function return success. To detect if two pkeys are eligible for communication, ib_find_matched_cached_pkey() is introduced, which requires at least one of the pkeys to be a full member, in order to return success. Signed-off-by: HÃ¥kon Bugge --- drivers/infiniband/core/cache.c | 32 +++++++++++++++++++++++++++----- include/rdma/ib_cache.h | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c index fb2d347f760f..cb7e9818a226 100644 --- a/drivers/infiniband/core/cache.c +++ b/drivers/infiniband/core/cache.c @@ -983,10 +983,11 @@ int ib_get_cached_subnet_prefix(struct ib_device *device, } EXPORT_SYMBOL(ib_get_cached_subnet_prefix); -int ib_find_cached_pkey(struct ib_device *device, - u8 port_num, - u16 pkey, - u16 *index) +static int __ib_find_cached_pkey(struct ib_device *device, + u8 port_num, + u16 pkey, + u16 *index, + bool allow_lim_to_lim_match) { struct ib_pkey_cache *cache; unsigned long flags; @@ -1013,7 +1014,11 @@ int ib_find_cached_pkey(struct ib_device *device, partial_ix = i; } - if (ret && partial_ix >= 0) { + /* + * If table content is limited, pkey must be full to match, + * unless allow_lim_to_lim_match is set + */ + if (ret && partial_ix >= 0 && (pkey & 0x8000 || allow_lim_to_lim_match)) { *index = partial_ix; ret = 0; } @@ -1022,6 +1027,23 @@ int ib_find_cached_pkey(struct ib_device *device, return ret; } + +int ib_find_matched_cached_pkey(struct ib_device *device, + u8 port_num, + u16 pkey, + u16 *index) +{ + return __ib_find_cached_pkey(device, port_num, pkey, index, false); +} +EXPORT_SYMBOL(ib_find_matched_cached_pkey); + +int ib_find_cached_pkey(struct ib_device *device, + u8 port_num, + u16 pkey, + u16 *index) +{ + return __ib_find_cached_pkey(device, port_num, pkey, index, true); +} EXPORT_SYMBOL(ib_find_cached_pkey); int ib_find_exact_cached_pkey(struct ib_device *device, diff --git a/include/rdma/ib_cache.h b/include/rdma/ib_cache.h index eb49cc8d1f95..748bd27559b6 100644 --- a/include/rdma/ib_cache.h +++ b/include/rdma/ib_cache.h @@ -92,6 +92,24 @@ int ib_get_cached_pkey(struct ib_device *device_handle, u16 *pkey); /** + * ib_find_matched_cached_pkey - Returns the PKey table index where a + * specified PKey value occurs. Success requires at least one of the + * PKeys to be a full-member. + * @device: The device to query. + * @port_num: The port number of the device to search for the PKey. + * @pkey: The PKey value to search for. + * @index: The index into the cached PKey table where the PKey was found. + * + * ib_find_matched_cached_pkey() searches the specified PKey table in + * the local software cache and return success unless both PKeys are + * limited. + */ +int ib_find_matched_cached_pkey(struct ib_device *device, + u8 port_num, + u16 pkey, + u16 *index); + +/** * ib_find_cached_pkey - Returns the PKey table index where a specified * PKey value occurs. * @device: The device to query. -- 2.13.6