From patchwork Fri Aug 3 08:40:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jackm X-Patchwork-Id: 1269791 X-Patchwork-Delegate: roland@digitalvampire.org Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id B2B08DF25A for ; Fri, 3 Aug 2012 08:41:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753139Ab2HCIlZ (ORCPT ); Fri, 3 Aug 2012 04:41:25 -0400 Received: from eu1sys200aog104.obsmtp.com ([207.126.144.117]:40094 "HELO eu1sys200aog104.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751533Ab2HCIlY (ORCPT ); Fri, 3 Aug 2012 04:41:24 -0400 Received: from mtlsws123.lab.mtl.com ([82.166.227.17]) (using TLSv1) by eu1sys200aob104.postini.com ([207.126.147.11]) with SMTP ID DSNKUBuOr6k2wMsKmLxURjq+8t1s3lJyJ38z@postini.com; Fri, 03 Aug 2012 08:41:23 UTC Received: from r-vnc04.lab.mtl.com (r-vnc04.lab.mtl.com [10.208.0.116]) by mtlsws123.lab.mtl.com (8.13.8/8.13.8) with ESMTP id q738f2Oe027921; Fri, 3 Aug 2012 11:41:19 +0300 From: Jack Morgenstein To: roland@kernel.org Cc: linux-rdma@vger.kernel.org, ogerlitz@mellanox.com, Jack Morgenstein , Liran Liss Subject: [PATCH for-next V2 02/22] IB/core: change pkey table lookups to support full and partial membership for the same pkey Date: Fri, 3 Aug 2012 11:40:38 +0300 Message-Id: <1343983258-6268-3-git-send-email-jackm@dev.mellanox.co.il> X-Mailer: git-send-email 1.7.8.2 In-Reply-To: <1343983258-6268-1-git-send-email-jackm@dev.mellanox.co.il> References: <1343983258-6268-1-git-send-email-jackm@dev.mellanox.co.il> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Enhance the cached and non-cached pkey table lookups to enable limited and full members of the same pkey to co-exist in the pkey table. This is necessary for SRIOV to allow for a scheme where some guests would have the full membership pkey in their virtual pkey table, where other guests on the same hypervisor would have the limited one. In that sense, its an extension of the IBTA model for non virtualized nodes. To accomplish this, we need both the limited and full membership pkeys to be present in the master's (hypervisor physical port) pkey table. The algorithm for supporting pkey tables which contain both the limited and the full membership versions of the same pkey works as follows: When scanning the pkey table for a 15 bit pkey: A. If there is a full member version of that pkey anywhere in the table, return its index (even if a limited-member version of the pkey exists earlier in the table). B. If the full member version is not in the table, but the limited-member version is in the table, return the index of the limited pkey. Signed-off-by: Liran Liss Signed-off-by: Jack Morgenstein Signed-off-by: Or Gerlitz --- drivers/infiniband/core/cache.c | 14 +++++++++++--- drivers/infiniband/core/device.c | 17 +++++++++++++---- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c index 9353992..0f2f2b7 100644 --- a/drivers/infiniband/core/cache.c +++ b/drivers/infiniband/core/cache.c @@ -167,6 +167,7 @@ int ib_find_cached_pkey(struct ib_device *device, unsigned long flags; int i; int ret = -ENOENT; + int partial_ix = -1; if (port_num < start_port(device) || port_num > end_port(device)) return -EINVAL; @@ -179,10 +180,17 @@ int ib_find_cached_pkey(struct ib_device *device, for (i = 0; i < cache->table_len; ++i) if ((cache->table[i] & 0x7fff) == (pkey & 0x7fff)) { - *index = i; - ret = 0; - break; + if (cache->table[i] & 0x8000) { + *index = i; + ret = 0; + break; + } else + partial_ix = i; } + if (ret && partial_ix >= 0) { + *index = partial_ix; + ret = 0; + } read_unlock_irqrestore(&device->cache.lock, flags); diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index e711de4..a645c68 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -707,18 +707,27 @@ int ib_find_pkey(struct ib_device *device, { int ret, i; u16 tmp_pkey; + int partial_ix = -1; for (i = 0; i < device->pkey_tbl_len[port_num - start_port(device)]; ++i) { ret = ib_query_pkey(device, port_num, i, &tmp_pkey); if (ret) return ret; - if ((pkey & 0x7fff) == (tmp_pkey & 0x7fff)) { - *index = i; - return 0; + /* if there is full-member pkey take it.*/ + if (tmp_pkey & 0x8000) { + *index = i; + return 0; + } + if (partial_ix < 0) + partial_ix = i; } } - + /*no full-member, if exists take the limited*/ + if (partial_ix >= 0) { + *index = partial_ix; + return 0; + } return -ENOENT; } EXPORT_SYMBOL(ib_find_pkey);