From patchwork Mon Dec 12 12:19:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Bloch X-Patchwork-Id: 9471099 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 1D15860573 for ; Mon, 12 Dec 2016 18:52:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DB10284E0 for ; Mon, 12 Dec 2016 18:52:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 101D6284F8; Mon, 12 Dec 2016 18:52:17 +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 E0867284E0 for ; Mon, 12 Dec 2016 18:52:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752425AbcLLSwO (ORCPT ); Mon, 12 Dec 2016 13:52:14 -0500 Received: from mail-db5eur01on0067.outbound.protection.outlook.com ([104.47.2.67]:31088 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751615AbcLLSwN (ORCPT ); Mon, 12 Dec 2016 13:52:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=QS4FKC+TUPlTqgXPlEsn0IDeEEPtStK3fHHIf71zU4E=; b=R7twMQ68v3iz/tDiSyr9Cz606/eAeHbG3PdYaH4EaDDjZES86RJVCA1jGJL8cBVYKJ35mD5tbN8enJcA9lu1Qqd62vVDIycdeuqlPqQJ3e6mHymMhjnVkI3bFTFh3LZV65QEaxa9UmlfaJjowMIQtEIYWP2DdNj27qITdH12bM4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=markb@mellanox.com; Received: from [10.223.3.174] (193.47.165.251) by HE1PR05MB1388.eurprd05.prod.outlook.com (10.162.250.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.761.9; Mon, 12 Dec 2016 12:19:11 +0000 From: Mark Bloch 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" Message-ID: Date: Mon, 12 Dec 2016 14:19:05 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 X-Originating-IP: [193.47.165.251] X-ClientProxiedBy: VI1PR07CA0063.eurprd07.prod.outlook.com (10.164.94.159) To HE1PR05MB1388.eurprd05.prod.outlook.com (10.162.250.30) X-MS-Office365-Filtering-Correlation-Id: 8a5c5281-4c46-4603-6fc2-08d422891531 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:HE1PR05MB1388; X-Microsoft-Exchange-Diagnostics: 1; HE1PR05MB1388; 3:jpFhUONcm1+E8OnG6v6LWdCfXnf1oqFhRat8+xUzHpfcznhmJ7DyHsKt1jJsQ6OGpuFGrx36fjokCx64QasqnvlHlHTLwwF9zmpJhzJB9jyB62g9FZz9fGPnPazhYNsyQCeQ/TTspQIDFWTseQbaf2A/BKLmCPgZbsgbH1ZJ+yscAkDTVp4aVpD1Q8cZoR8zxd2MYQbb8hJBlWFJb2GNCGwpIHeCbgP94r9DkP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8zFU40hR256ZEScVe47DEUQq6rkGJavUlcPrkpIB9pLsxJfd8hhyIgE+B8LPXAN8EuRJlbv6rrb2Zy762OdfxazB1i1cAz5uXd2iyIh+5iQ8iSCQFcwUhGwZboke1A7k+ZxFv1EnPpMbXbG52SA5sYiHFZ4qCpGPPA1M6vq2GgukOh11+p9B6VNdthGB+iRtxb91rad17QGuFAoIIIE5EkOUgnjDIiH5WkAEVfTIL2eTTyXZeTy7mdh5qTT/Y9FB+1PigWgBDxtMYtV0d1p6boiKb80+s5mBQNH6lXvW+MPGFCfYW78BmK0PIFW X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6041248)(20161123555025)(20161123562025)(20161123564025)(20161123560025)(6072148); SRVR:HE1PR05MB1388; BCL:0; PCL:0; RULEID:; SRVR:HE1PR05MB1388; X-Microsoft-Exchange-Diagnostics: 1; HE1PR05MB1388; 4:EA41qt1r2qUGicsTWXvRzyIFLes2JG9BNLKLHA6XN/YGGRJcN8yKx6dpkAgYBMbVATKtps5SpwhyZECqtfVUGXjyC4/9dir6lmxLuEwLJ+zhTgyBIRX6PKwYs9SSwv29c1AK7GL+WAgIuU1MzJnipTNmfcfZ5OqfTRJy1HnEsTqPIRb/bD7Vx72RS3LefhZjErwCBqMd2um+++isTNgRG9K/bqAWQByaEIz8K9z3IcmPun4sOzbtMMoxooSzcZXovsEPISEVpBJ+tFFQHAObQzhTh3sXIFEgXy0FfFJSupFCEW6iOUm8/xvBIXamac6DoQTX8jZLR46UVO7sj1OPr22bzfo5m3AQP/33W3oSW4p/MpLYWcacMwzpbtq4tDi6Ts4xUYa7C2YckDqKhftjKPu1RQYjcHAqTJDM2s5W642tnx1uCB2fkbKauDe2x3pd2zavdLxHdKya+lKyJANsvoIPdUvvgkc7Fh2lp1gGjnKKmmsWICbbPXFZXvEOMQ9bvcUQUBMOHqZ0/TQS+sfIQi493VtlUX5shgUSmaLKW/oQST/nJxvEf03R8K6JuS6qXz/abySgwmMvAZ6ga95IGQ== X-Forefront-PRVS: 0154C61618 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6049001)(6009001)(7916002)(39840400002)(39850400002)(39450400003)(39410400002)(39860400002)(189002)(199003)(6666003)(101416001)(3846002)(42186005)(6116002)(38730400001)(106356001)(105586002)(31686004)(90366009)(33646002)(39060400001)(86362001)(77096006)(36756003)(23676002)(31696002)(2501003)(66066001)(65806001)(47776003)(107886002)(230700001)(65956001)(8676002)(65826007)(5001770100001)(4001350100001)(6486002)(97736004)(2906002)(81156014)(81166006)(50466002)(68736007)(5660300001)(54356999)(50986999)(64126003)(189998001)(7736002)(305945005)(83506001)(92566002); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR05MB1388; H:[10.223.3.174]; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtIRTFQUjA1TUIxMzg4OzIzOnFNRTR0MlljUmhwQnljbzFVSVZnYktqZFM3?= =?utf-8?B?ZmZYRHR0TC9ZN2RkZk41WlU5amRHU3JySlpWdmFOank3MkdlOWtZNGoxTGdP?= =?utf-8?B?Vjd6cmF4dVFWeWtlcituZHFSNDdLZUhydkd2eHZKcmYvOWdLZFFBNEhMMzZm?= =?utf-8?B?YTYrNkVhTWdxU3liT0VFbnp1QkZSc09lYnFhN3cxWnI3Smg0ZjZRL3Zqeis4?= =?utf-8?B?Yi9vZFBrbnY4Y1g1Q0txV3JuaXYzc2pwQ2xlMWZwU2d0MW52ckp5cGtJV0VS?= =?utf-8?B?QVp3K1ZkTVFONWR0SGE5M2l4b1BSdlpLUVYwTEIrdXE1akdUZVFSSTFNOTRI?= =?utf-8?B?ejZObXZIanNVQUMxaW9GRFlhenZ1L0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1EJU9dMaVeIGjXXIs0bVv0LHqt+NlO0XDweFIP3ZSIZe6pNBdTdgTHVXq4FMOzAEhRMMoOFKvuA4WQ+A/5Va48UqCi10JVWUAZSzzrbdpJaftxU0uhUkKn2oA4bww==; 5:Mmg2JfZCbYjczh/Yt+cLlYo1CktHJ1nnxiQDi+fR/UbQtwzHncxoGWDcQ5ieR0uQzenfooUc0wEzJlEEYjMd9OxYbwKrv7JiAAcwqoos1pyvFtDhf+1dH5vuSoe3eOUBh24eAayf5iWf6+6swnMKog==; 24:jnlmRV77pg7jCn9kuR7WjeFn+UD9yj8QhHer75wFa5mvl/ryTZrzWAICVkGto7Ta0hg59YagLabBbTJEJAJXQLmuutkSkVJ1ixhhXdtgW8M= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR05MB1388; 7:/TPwzU485v7MOK2nZiJarMLu35XKutTDFvJOe4RVuz1OSeffvrDln/KU50REp+Rd4zj+wP+q2MKzzzkrkIPtrZzyQMrIK+RTpWUmGYgfK65tME4il4Yn8pJIjDkGNnaQ0EVtInOp3DQKQnIAs6Nd9CXuMLn57Kj/5/rAcljDLiMUsj9FMOaUfHm+zZ9NnlkIecKndZe2C849cJ66b7OyRwQLrWXKoW4yGq/CtF443GvGMIB86qzot0vsEuefissmnex0QLC8DAtKWpiiJI/Mz15hfNwCOIc+GY8iYIp0f9nr1M/N6WYyjwlHFNFwHRQEq0Yk6pRUKZd3eJxJtHBTpprgreiQHLn/jJWqhszg0jbQsDVpXAEaNN0UeAlLAInv0v+xH+9tAc07BpDb/4/PQWIsmbC7puDqMrjY+DmP1YSiyq0DkULNGjT+y4ntO0Ed492spMlYMT9MQi6Z2B75Kw== X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2016 12:19:11.3445 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR05MB1388 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 Hi, #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) Can you please fix the style (indentation) +{ + 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; Why do you need ret? just return 0. +} +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); +