From patchwork Mon Dec 12 11:45:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 9470497 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 4098460476 for ; Mon, 12 Dec 2016 11:45:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 321862846A for ; Mon, 12 Dec 2016 11:45:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24AA328477; Mon, 12 Dec 2016 11:45:50 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 6E3772846A for ; Mon, 12 Dec 2016 11:45:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751640AbcLLLps (ORCPT ); Mon, 12 Dec 2016 06:45:48 -0500 Received: from mail-oi0-f50.google.com ([209.85.218.50]:35678 "EHLO mail-oi0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750910AbcLLLpr (ORCPT ); Mon, 12 Dec 2016 06:45:47 -0500 Received: by mail-oi0-f50.google.com with SMTP id b126so84663532oia.2 for ; Mon, 12 Dec 2016 03:45:47 -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=eCJNEJdW4Ad788llg+2sZR7QTO3DMC97ylrIHnN39YM=; b=rQj/MpdjL1l9EFoy6U5ie+FFbbOMLEhYUdKYtzp0D7D61XWHRAqMvshPLiqj3ogtYQ EdnMsJakLuMyiqgKqijg00Md5YF4c7ZdT94qoGH7dBf/srfCOkqXXoz8FjkQQ00Cxdgp fKgVhXOXFhJouUwFNK7znm98mEvT9MsokgwdnFiqp7mjeMlZo9pyheBYXlp0rEcDYH4Z Fk2J64UBJQpubEQR1CGPIIgWesLqLrtYdrUDiflyx8tsAkx5b5MdmrE+r9uyX3rGVeTQ VOzIZPYceBN++WKs0OtPX0UQHwo2bEVqGQl1l1OzlbD3XCUrOdPD1F0sQPOPz+xqYJ3i VmUw== 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=eCJNEJdW4Ad788llg+2sZR7QTO3DMC97ylrIHnN39YM=; b=kZqpztOu11kVE2yFjYv4I0W1omoRqgeDoC+D7UWkh9dKbEzNNO9HMsKpfqlX2HMWFY oSZcN1Wt1Gxy60SMs11ZvMC6um7A2RCrwoMrsPiwDks1/C6CDihLZQCl8JxS+JvbytvN GvmrH88GDZPgLroYNblS8tCBgo7vkHYHYWexqqgNtkpSYGbLSXBO6sCTlqfdkSuf7sFe KnrNIYYZl1jEqUnUqcManLdQeAB6zOWj34ZSUdJYgGRmgXLHJE8E5DZsKG4CE8hVK2no 2YUrPp8d/mDF9BUpITfW/0aoMTO8vh+qngl76oRzAPE0zPGjQO6dwVyVLy4AJsGEzT1J qV+Q== X-Gm-Message-State: AKaTC02pIbdzCTiiMbqTWNimZ7WIf7D6cwfy/TsQ6XuLW7rFrlzTZ5WfWm4StHDAAz7sa0a3UoZHJUcG82Obqb1Z X-Received: by 10.202.50.4 with SMTP id y4mr35469394oiy.180.1481543147060; Mon, 12 Dec 2016 03:45:47 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.165.135 with HTTP; Mon, 12 Dec 2016 03:45:26 -0800 (PST) From: Jinpu Wang Date: Mon, 12 Dec 2016 12:45:26 +0100 Message-ID: Subject: [PATCH 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 1cf770be635e987e31feed2f7c82b9f4f3bd316a 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 */ diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c index 025db27..1b064cf 100644 --- a/drivers/infiniband/core/cache.c +++ b/drivers/infiniband/core/cache.c @@ -1025,6 +1025,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); +