From patchwork Mon Dec 12 13:31:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 9470741 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 4B2FB60573 for ; Mon, 12 Dec 2016 13:31:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A60A2849B for ; Mon, 12 Dec 2016 13:31:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E6D02849D; Mon, 12 Dec 2016 13:31:29 +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 5E4872849B for ; Mon, 12 Dec 2016 13:31:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751640AbcLLNb1 (ORCPT ); Mon, 12 Dec 2016 08:31:27 -0500 Received: from mail-oi0-f54.google.com ([209.85.218.54]:34389 "EHLO mail-oi0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750712AbcLLNb0 (ORCPT ); Mon, 12 Dec 2016 08:31:26 -0500 Received: by mail-oi0-f54.google.com with SMTP id y198so87237236oia.1 for ; Mon, 12 Dec 2016 05:31:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=profitbricks-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=cmovTNyu+TYqhhXZkcecKbvkkaC89tnOTJkYavkcs0U=; b=xqKmMtRDv+J+/RIdPZW7pvO0RRJrESZUMkiJaM930lkrflrqYjWxb2OjVLwrDCtn9U p/NSyFxDQo1tPmaOByGjm2zQ3nDiKJRLPE8aFETzUrK1p7dTHHI557ueRDFlXj2IOeyF BTJtn3Bvy5kxqFyP9E9DwFIWmw2pVWFrO/FhbIxIpcJi9QlFe1s3S0v8akfVcJhK5ET5 +Q7Lh/KQ+8bVN5PkKtd55rj0Up8XzarJ9HgRTeNZtAw4ORUc8WRH+/IKlXkhhKLMYcMC 6ruR/Ly+3BV3uChWH6kaAMDpF37YuRlqBQT+m+9j2uxyrUYPAapP3d9GAUgo3d6fG0PX o3Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=cmovTNyu+TYqhhXZkcecKbvkkaC89tnOTJkYavkcs0U=; b=cDRSYqstrPNPegq3tlXUmMLH11tt2gbb2HOt1Gk8KVJFBDt8WQSKEtHYp0WCYjq9DX CO2LdWPij39pJE8MrSrGngKwg6TeKSg0epyQWNEoR3ySIq+33km/1LCuctvZ8Dc7pyvQ /UK2+jD5gBhaFJOLk49dOkeEyRbiARD46N0b4z1ZUcAr2n1RBpoXzMIfss/DLIKJXdat YrjWqQBeRwDtVzq7bn/2LntRJanofguG1Hr1/j37KTr+ipxd1NAI3PNa2nW3A2Iz7GFL nvUzRzIC0A7dJtF0V4lneTNsDIPyG6zvlGxyBVXdlw32HQ4NX5y+EIk448ZsjGIyzx8p Tm/w== X-Gm-Message-State: AKaTC038esZWCv2ecov9KF3kvqgOkLeEduOQnEZfeaRseDuL+l9X1O7THGtsCX7al1oxlGdFRxl2Tw8qEsvVohIB X-Received: by 10.157.45.1 with SMTP id v1mr54742888ota.95.1481549485828; Mon, 12 Dec 2016 05:31:25 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.165.135 with HTTP; Mon, 12 Dec 2016 05:31:05 -0800 (PST) In-Reply-To: References: From: Jinpu Wang Date: Mon, 12 Dec 2016 14:31:05 +0100 Message-ID: Subject: Re: [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 , Mark Bloch 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 Add Mark in reply. Hi, Mark, On Mon, Dec 12, 2016 at 12:45 PM, Jinpu Wang wrote: > 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 > --- > 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 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) Q: Can you please fix the style (indentation) A: format mangled by gmail, I attached the patch in attachment. > +{ > + 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); > + Q: Why do you need ret? just return 0. A: We just need to keep the same style as ib_get_cached_lmc(), ret could be reserved, indentation should be consistent if not. > 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 > > Thanks! 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 --- 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 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); + #endif /* _IB_CACHE_H */ -- 2.7.4