From patchwork Mon Jan 2 12:19:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 9493419 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 1C61562AB3 for ; Mon, 2 Jan 2017 12:19:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D83E205AD for ; Mon, 2 Jan 2017 12:19:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0098F2679B; Mon, 2 Jan 2017 12:19:47 +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 4E28D205AD for ; Mon, 2 Jan 2017 12:19:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751408AbdABMTq (ORCPT ); Mon, 2 Jan 2017 07:19:46 -0500 Received: from mail-oi0-f50.google.com ([209.85.218.50]:35572 "EHLO mail-oi0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751388AbdABMTp (ORCPT ); Mon, 2 Jan 2017 07:19:45 -0500 Received: by mail-oi0-f50.google.com with SMTP id b126so479933590oia.2 for ; Mon, 02 Jan 2017 04:19:45 -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=/eGAeqvURvuQUjNNC04wYG8VAvqJcuavC2yG1qRAAmU=; b=AKJoKbO+zuqIrmS6kctfTScMa931hZ45iZeyfPA4K4eN2EXkMxH6jMz92D6E/k+EA9 alhvMbEKABxAjWRI2+K+10bs7eOmF4ruP3kyKY1TywGxG/pqPZorEOiMd0ChditJh0yv 7Zco36X/ADZv9ueG2mBcZrtLgcXqTL5xUseYpVq7XcRrgGFe2f2FBot2tvBQ503AnvFy nvWV4fhp0ABlcD6TaisriOUkJJsBjSJivelsmLUNw7sD5bKbFaVlGVKMTedpCAkyZfbC jjKeMQHFIWwUPbebKBI03tr7GyhYOY81LJYBCaVF5MOm23gqcQtSJ02pKkDznOgFuBlj 7KnQ== 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=/eGAeqvURvuQUjNNC04wYG8VAvqJcuavC2yG1qRAAmU=; b=bBtJEW9/+XF8sMwC2ga3iPs6fRRM0kkMmQ1b16SGK5iRFovJCJI64Ho82VA2hMrDjt dkXTj3QvdH8hABKkY2Y2PupO9Hwus9UUhk9k7VlIHOc/gxtSZD9Ha8XNjJUB19JG1HvL uxIX4DVPDHRelQ2Ok778NSuxcgKgyud28ewowEyn2pTtJvmOYGSjP9m8ZM4wKS7z0K4X f++E6NFZZgWMSHzqt1zsZPc9rgXhtx3CVmDLbN1aeZBSaILtcl++OnxbZUKVT42gnRvp 7hAAGF6UFd8XM9XXsLs9Uu6LCNzYnU6JWzRzNWmkOBzhv0Alz3Bq/YFm+Y2tW5NgFwn/ yBIw== X-Gm-Message-State: AIkVDXLOiLQAHwDG3KOIB5iD+YSJp4V8m20PKqqPAcUFd8FxqCFpYtztA9nV6RxWQlwlVMUG8VduTagp7IJNek7r X-Received: by 10.157.62.10 with SMTP id a10mr30349650otd.95.1483359585028; Mon, 02 Jan 2017 04:19:45 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.241.198 with HTTP; Mon, 2 Jan 2017 04:19:24 -0800 (PST) From: Jinpu Wang Date: Mon, 2 Jan 2017 13:19:24 +0100 Message-ID: Subject: [PATCHv2 2/4] IB/core: export ib_get_cached_port_state 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 33f03b1f3a4e5a1f27b21378cd9e3e402e6e39fe Mon Sep 17 00:00:00 2001 From: Jack Wang Date: Mon, 12 Dec 2016 10:12:39 +0100 Subject: [PATCH 2/4] IB/core: export ib_get_cached_port_state Export function for rdma_cm, patch will follow. Signed-off-by: Jack Wang Reviewed-by: Michael Wang Acked-by: Sean Hefty --- drivers/infiniband/core/cache.c | 18 ++++++++++++++++++ include/rdma/ib_cache.h | 13 +++++++++++++ 2 files changed, 31 insertions(+) #endif /* _IB_CACHE_H */ From 33f03b1f3a4e5a1f27b21378cd9e3e402e6e39fe Mon Sep 17 00:00:00 2001 From: Jack Wang Date: Mon, 12 Dec 2016 10:12:39 +0100 Subject: [PATCH 2/4] IB/core: export ib_get_cached_port_state Export function for rdma_cm, patch will follow. Signed-off-by: Jack Wang Reviewed-by: Michael Wang Acked-by: Sean Hefty --- drivers/infiniband/core/cache.c | 18 ++++++++++++++++++ include/rdma/ib_cache.h | 13 +++++++++++++ 2 files changed, 31 insertions(+) diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c index 87fd7c3..f91886b 100644 --- a/drivers/infiniband/core/cache.c +++ b/drivers/infiniband/core/cache.c @@ -1021,6 +1021,24 @@ int ib_get_cached_lmc(struct ib_device *device, } EXPORT_SYMBOL(ib_get_cached_lmc); +int ib_get_cached_port_state(struct ib_device *device, + u8 port_num, + enum ib_port_state *port_state) +{ + unsigned long flags; + int ret = 0; + + if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device)) + return -EINVAL; + + read_lock_irqsave(&device->cache.lock, flags); + *port_state = device->cache.port_state_cache[port_num - rdma_start_port(device)]; + read_unlock_irqrestore(&device->cache.lock, flags); + + return ret; +} +EXPORT_SYMBOL(ib_get_cached_port_state); + static void ib_cache_update(struct ib_device *device, u8 port) { diff --git a/include/rdma/ib_cache.h b/include/rdma/ib_cache.h index e30f19b..385ec88 100644 --- a/include/rdma/ib_cache.h +++ b/include/rdma/ib_cache.h @@ -165,4 +165,17 @@ int ib_get_cached_lmc(struct ib_device *device, u8 port_num, u8 *lmc); +/** + * ib_get_cached_port_state - Returns a cached port state table entry + * @device: The device to query. + * @port_num: The port number of the device to query. + * @port_state: port_state for the specified port for that device. + * + * ib_get_cached_port_state() fetches the specified port_state table entry stored in + * the local software cache. + */ +int ib_get_cached_port_state(struct ib_device *device, + u8 port_num, + enum ib_port_state *port_active); + #endif /* _IB_CACHE_H */ -- 2.7.4