From patchwork Mon Dec 12 11:43:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 9470485 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 A278760476 for ; Mon, 12 Dec 2016 11:43:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 938582846A for ; Mon, 12 Dec 2016 11:43:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 855FA28477; Mon, 12 Dec 2016 11:43:51 +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 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 7697E2846A for ; Mon, 12 Dec 2016 11:43:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750727AbcLLLnt (ORCPT ); Mon, 12 Dec 2016 06:43:49 -0500 Received: from mail-oi0-f49.google.com ([209.85.218.49]:36111 "EHLO mail-oi0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750712AbcLLLns (ORCPT ); Mon, 12 Dec 2016 06:43:48 -0500 Received: by mail-oi0-f49.google.com with SMTP id v84so84404737oie.3 for ; Mon, 12 Dec 2016 03:43:48 -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=e3LsujYFcrCmlUQJqdmZuwWUoWYnDA2I+CaMlH3sNR8=; b=p98UxyOeRXkD+NVBcTln0h86G30YFuklbHqwLoEDdF2wMwSDtMqWMfkLYEuwQBIxz4 fXpEfae1Zq71YfZ5Ph5vWzHIC4vtorITm8UZ8X1Kv5QOnWgFlB3WUho7khHqbHuc7R/9 y19KKzwhb0Hvk0zj0cI9oAIiOFpvAa2C7k753JcaLYQaObSn/RfwxG9xshuGvIT8ZCIf rmup3vkS/ygZq0BtkdlE/xsrOk2viXyYXO91tonen2po+e3DiudyO69OL1pTMuHrvyyf osT+02gMbY7S+8cQB75gMA1BsVfYEKLD74x1xkPxivIk6FdV/YXDkYrSq0HBCSjK+JW2 AyCA== 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=e3LsujYFcrCmlUQJqdmZuwWUoWYnDA2I+CaMlH3sNR8=; b=FQroFUYO1OMIdaYJaUjq3AGPsw3mZ9EszUewVS9ehPZge0ziEwcADesSD1yympNeUB 3XRZ+evD0RiF0ErzeSCKZ49w1hZ/6ftL2poxoqJCIrDPvZ5CBGq8VNlUSdMwJ8dWj8PM t0qyjVAXKlpT7zMyZnpBNvOfOY8aHgF1OvCptaAJtN30jA9ahR2vBaUZioM58wgVfUBg ZSuTuUH3129jx6JmNsSMDJCiEMTt7pDy4tdVRmjKra1FINOFC0OyoA+tVWGSor8P/pVE YjxtV8fFfITUiHtdtij5vHchs2y5KwHdarTiRJ9EzEwmVRdJQM0D0wTf/SKuduD2SzEm Sz2w== X-Gm-Message-State: AKaTC02O5C1Tfn+LUfetLRMjASaxt8sCkiaPTS9mLlNTGy5zEydZoLPnjYdhnXX7qjbUMlHd5sfmaOCI2+l13FJ3 X-Received: by 10.157.27.134 with SMTP id z6mr51590027otd.189.1481543027946; Mon, 12 Dec 2016 03:43:47 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.165.135 with HTTP; Mon, 12 Dec 2016 03:43:27 -0800 (PST) From: Jinpu Wang Date: Mon, 12 Dec 2016 12:43:27 +0100 Message-ID: Subject: [PATCH 1/4] IB/core: add port state cache 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 fc80c1730d94a38934c5c60f9b9561745723dfd9 Mon Sep 17 00:00:00 2001 From: Jack Wang Date: Mon, 12 Dec 2016 09:52:42 +0100 Subject: [PATCH 1/4] IB/core: add port state cache We need a port state cache in ib_core, later we will use in rdma_cm. Signed-off-by: Jack Wang Reviewed-by: Michael Wang --- drivers/infiniband/core/cache.c | 9 ++++++++- include/rdma/ib_verbs.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c index 1a2984c..025db27 100644 --- a/drivers/infiniband/core/cache.c +++ b/drivers/infiniband/core/cache.c @@ -1109,6 +1109,8 @@ static void ib_cache_update(struct ib_device *device, } device->cache.lmc_cache[port - rdma_start_port(device)] = tprops->lmc; + device->cache.port_state_cache[port - rdma_start_port(device)] = + tprops->state; write_unlock_irq(&device->cache.lock); @@ -1168,7 +1170,11 @@ int ib_cache_setup_one(struct ib_device *device) (rdma_end_port(device) - rdma_start_port(device) + 1), GFP_KERNEL); - if (!device->cache.pkey_cache || + device->cache.port_state_cache = kmalloc(sizeof *device->cache.port_state_cache * + (rdma_end_port(device) - + rdma_start_port(device) + 1), + GFP_KERNEL); + if (!device->cache.pkey_cache || !device->cache.port_state_cache || !device->cache.lmc_cache) { pr_warn("Couldn't allocate cache for %s\n", device->name); return -ENOMEM; @@ -1213,6 +1219,7 @@ void ib_cache_release_one(struct ib_device *device) gid_table_release_one(device); kfree(device->cache.pkey_cache); kfree(device->cache.lmc_cache); + kfree(device->cache.port_state_cache); } void ib_cache_cleanup_one(struct ib_device *device) diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 5ad43a4..a167ae0 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1761,6 +1761,7 @@ struct ib_cache { struct ib_pkey_cache **pkey_cache; struct ib_gid_table **gid_cache; u8 *lmc_cache; + enum ib_port_state *port_state_cache; }; struct ib_dma_mapping_ops {