All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 1/4] IB/core: add port state cache
@ 2017-01-02 12:17 Jinpu Wang
       [not found] ` <CAMGffEmYeYeRVk84GY1CWekNHF7_V4Lo4PDxoGb5wAd8-Tnn7Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Jinpu Wang @ 2017-01-02 12:17 UTC (permalink / raw)
  To: Doug Ledford, Hefty, Sean, Hal Rosenstock,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Michael Wang,
	Jason Gunthorpe

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

To avoid gmail mangle the format, I also put it attached.

>From 83a45b0e34bb8515ec9db51629aa4e7e37dfc2e8 Mon Sep 17 00:00:00 2001
From: Jack Wang <jinpu.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
Date: Mon, 12 Dec 2016 09:52:42 +0100
Subject: [PATCH 1/4] IB/core: add port state cache

We need a port state cache in ib_core, later we will use in rdma_cm.

Signed-off-by: Jack Wang <jinpu.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
Reviewed-by: Michael Wang <yun.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
Acked-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 drivers/infiniband/core/cache.c | 10 +++++++++-
 include/rdma/ib_verbs.h         |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
index ae04826..87fd7c3 100644
--- a/drivers/infiniband/core/cache.c
+++ b/drivers/infiniband/core/cache.c
@@ -1105,6 +1105,8 @@ static void ib_cache_update(struct ib_device *device,
     }

     device->cache.lmc_cache[port - rdma_start_port(device)] = tprops->lmc;
+    device->cache.port_state_cache[port - rdma_start_port(device)] =
+        tprops->state;

     write_unlock_irq(&device->cache.lock);

@@ -1164,7 +1166,11 @@ int ib_cache_setup_one(struct ib_device *device)
                       (rdma_end_port(device) -
                        rdma_start_port(device) + 1),
                       GFP_KERNEL);
-    if (!device->cache.pkey_cache ||
+    device->cache.port_state_cache = kmalloc(sizeof
*device->cache.port_state_cache *
+                      (rdma_end_port(device) -
+                       rdma_start_port(device) + 1),
+                      GFP_KERNEL);
+    if (!device->cache.pkey_cache || !device->cache.port_state_cache ||
         !device->cache.lmc_cache) {
         err = -ENOMEM;
         goto free;
@@ -1190,6 +1196,7 @@ int ib_cache_setup_one(struct ib_device *device)
 free:
     kfree(device->cache.pkey_cache);
     kfree(device->cache.lmc_cache);
+    kfree(device->cache.port_state_cache);
     return err;
 }

@@ -1211,6 +1218,7 @@ void ib_cache_release_one(struct ib_device *device)
     gid_table_release_one(device);
     kfree(device->cache.pkey_cache);
     kfree(device->cache.lmc_cache);
+    kfree(device->cache.port_state_cache);
 }

 void ib_cache_cleanup_one(struct ib_device *device)
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 8029d2a..7115c0f 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1781,6 +1781,7 @@ struct ib_cache {
     struct ib_pkey_cache  **pkey_cache;
     struct ib_gid_table   **gid_cache;
     u8                     *lmc_cache;
+    enum ib_port_state     *port_state_cache;
 };

 struct ib_dma_mapping_ops {
-- 
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

[-- Attachment #2: 0001-IB-core-add-port-state-cache.patch --]
[-- Type: text/x-patch, Size: 2434 bytes --]

From 83a45b0e34bb8515ec9db51629aa4e7e37dfc2e8 Mon Sep 17 00:00:00 2001
From: Jack Wang <jinpu.wang@profitbricks.com>
Date: Mon, 12 Dec 2016 09:52:42 +0100
Subject: [PATCH 1/4] IB/core: add port state cache

We need a port state cache in ib_core, later we will use in rdma_cm.

Signed-off-by: Jack Wang <jinpu.wang@profitbricks.com>
Reviewed-by: Michael Wang <yun.wang@profitbricks.com>
Acked-by: Sean Hefty <sean.hefty@intel.com>
---
 drivers/infiniband/core/cache.c | 10 +++++++++-
 include/rdma/ib_verbs.h         |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
index ae04826..87fd7c3 100644
--- a/drivers/infiniband/core/cache.c
+++ b/drivers/infiniband/core/cache.c
@@ -1105,6 +1105,8 @@ static void ib_cache_update(struct ib_device *device,
 	}
 
 	device->cache.lmc_cache[port - rdma_start_port(device)] = tprops->lmc;
+	device->cache.port_state_cache[port - rdma_start_port(device)] =
+		tprops->state;
 
 	write_unlock_irq(&device->cache.lock);
 
@@ -1164,7 +1166,11 @@ int ib_cache_setup_one(struct ib_device *device)
 					  (rdma_end_port(device) -
 					   rdma_start_port(device) + 1),
 					  GFP_KERNEL);
-	if (!device->cache.pkey_cache ||
+	device->cache.port_state_cache = kmalloc(sizeof *device->cache.port_state_cache *
+					  (rdma_end_port(device) -
+					   rdma_start_port(device) + 1),
+					  GFP_KERNEL);
+	if (!device->cache.pkey_cache || !device->cache.port_state_cache ||
 	    !device->cache.lmc_cache) {
 		err = -ENOMEM;
 		goto free;
@@ -1190,6 +1196,7 @@ int ib_cache_setup_one(struct ib_device *device)
 free:
 	kfree(device->cache.pkey_cache);
 	kfree(device->cache.lmc_cache);
+	kfree(device->cache.port_state_cache);
 	return err;
 }
 
@@ -1211,6 +1218,7 @@ void ib_cache_release_one(struct ib_device *device)
 	gid_table_release_one(device);
 	kfree(device->cache.pkey_cache);
 	kfree(device->cache.lmc_cache);
+	kfree(device->cache.port_state_cache);
 }
 
 void ib_cache_cleanup_one(struct ib_device *device)
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 8029d2a..7115c0f 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1781,6 +1781,7 @@ struct ib_cache {
 	struct ib_pkey_cache  **pkey_cache;
 	struct ib_gid_table   **gid_cache;
 	u8                     *lmc_cache;
+	enum ib_port_state     *port_state_cache;
 };
 
 struct ib_dma_mapping_ops {
-- 
2.7.4


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

end of thread, other threads:[~2017-01-04 13:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-02 12:17 [PATCHv2 1/4] IB/core: add port state cache Jinpu Wang
     [not found] ` <CAMGffEmYeYeRVk84GY1CWekNHF7_V4Lo4PDxoGb5wAd8-Tnn7Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-01-03 19:18   ` Jason Gunthorpe
     [not found]     ` <20170103191850.GD26706-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-01-04  8:50       ` Jinpu Wang
     [not found]         ` <CAMGffE=FWBZWKCo7X7EA70Hx+jpvMt_E0_WZo-TsHFemCzcaeQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-01-04 11:58           ` Jinpu Wang
     [not found]             ` <CAMGffE=kYTioNBqScgz0kaz4O3XKXkp=FGm=+Kg2fjxMo0xdQA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-01-04 13:53               ` Jinpu Wang

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.