All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/4] IB/core: export ib_get_cached_port_state
@ 2016-12-12 11:45 Jinpu Wang
       [not found] ` <CAMGffEnCU-8sodNH_i-KKPAhe3ekkt+Yd34wiUVqvXJ+ujSRwQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Jinpu Wang @ 2016-12-12 11:45 UTC (permalink / raw)
  To: Doug Ledford, Hefty, Sean, Hal Rosenstock,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, Michael Wang, Jason Gunthorpe

>From 1cf770be635e987e31feed2f7c82b9f4f3bd316a Mon Sep 17 00:00:00 2001
From: Jack Wang <jinpu.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
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 <jinpu.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
Reviewed-by: Michael Wang <yun.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
---
 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


-- 
Jinpu Wang
Linux Kernel Developer

ProfitBricks GmbH
Greifswalder Str. 207
D - 10405 Berlin

Tel:       +49 30 577 008  042
Fax:      +49 30 577 008 299
Email:    jinpu.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org
URL:      https://www.profitbricks.de

Sitz der Gesellschaft: Berlin
Registergericht: Amtsgericht Charlottenburg, HRB 125506 B
Geschäftsführer: Achim Weiss
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/4] IB/core: export ib_get_cached_port_state
       [not found] ` <CAMGffEnCU-8sodNH_i-KKPAhe3ekkt+Yd34wiUVqvXJ+ujSRwQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2016-12-12 13:31   ` Jinpu Wang
  2016-12-19 17:29   ` Hefty, Sean
  1 sibling, 0 replies; 4+ messages in thread
From: Jinpu Wang @ 2016-12-12 13:31 UTC (permalink / raw)
  To: Doug Ledford, Hefty, Sean, Hal Rosenstock,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, Michael Wang, Jason Gunthorpe,
	Mark Bloch

[-- Attachment #1: Type: text/plain, Size: 3460 bytes --]

Add Mark in reply.

Hi, Mark,



On Mon, Dec 12, 2016 at 12:45 PM, Jinpu Wang
<jinpu.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org> wrote:
> From 1cf770be635e987e31feed2f7c82b9f4f3bd316a Mon Sep 17 00:00:00 2001
> From: Jack Wang <jinpu.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
> 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 <jinpu.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
> Reviewed-by: Michael Wang <yun.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
> ---
>  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!
-- 
Jinpu Wang
Linux Kernel Developer

ProfitBricks GmbH
Greifswalder Str. 207
D - 10405 Berlin

Tel:       +49 30 577 008  042
Fax:      +49 30 577 008 299
Email:    jinpu.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org
URL:      https://www.profitbricks.de

Sitz der Gesellschaft: Berlin
Registergericht: Amtsgericht Charlottenburg, HRB 125506 B
Geschäftsführer: Achim Weiss

[-- Attachment #2: 0002-IB-core-export-ib_get_cached_port_state.patch --]
[-- Type: text/x-patch, Size: 2271 bytes --]

From 1cf770be635e987e31feed2f7c82b9f4f3bd316a Mon Sep 17 00:00:00 2001
From: Jack Wang <jinpu.wang@profitbricks.com>
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 <jinpu.wang@profitbricks.com>
Reviewed-by: Michael Wang <yun.wang@profitbricks.com>
---
 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH 2/4] IB/core: export ib_get_cached_port_state
       [not found] ` <CAMGffEnCU-8sodNH_i-KKPAhe3ekkt+Yd34wiUVqvXJ+ujSRwQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2016-12-12 13:31   ` Jinpu Wang
@ 2016-12-19 17:29   ` Hefty, Sean
  1 sibling, 0 replies; 4+ messages in thread
From: Hefty, Sean @ 2016-12-19 17:29 UTC (permalink / raw)
  To: Jinpu Wang, Doug Ledford, Hal Rosenstock,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, Michael Wang, Jason Gunthorpe

> Export function for rdma_cm, patch will follow.
> 
> Signed-off-by: Jack Wang <jinpu.wang@profitbricks.com>
> Reviewed-by: Michael Wang <yun.wang@profitbricks.com>

While I agree with Mark's comments, this series as-is is an overall improvement.

Acked-by: Sean Hefty <sean.hefty@intel.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/4] IB/core: export ib_get_cached_port_state
@ 2016-12-12 12:19 Mark Bloch
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Bloch @ 2016-12-12 12:19 UTC (permalink / raw)
  To: Doug Ledford, Hefty, Sean, Hal Rosenstock,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, Michael Wang, Jason Gunthorpe

Hi,

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);
+
 #endif /* _IB_CACHE_H */
-- 
2.7.4


Mark.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-12-19 17:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-12 11:45 [PATCH 2/4] IB/core: export ib_get_cached_port_state Jinpu Wang
     [not found] ` <CAMGffEnCU-8sodNH_i-KKPAhe3ekkt+Yd34wiUVqvXJ+ujSRwQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-12-12 13:31   ` Jinpu Wang
2016-12-19 17:29   ` Hefty, Sean
2016-12-12 12:19 Mark Bloch

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.