RDMA/core: export ib_get_cached_port_state
authorJack Wang <jinpu.wang@profitbricks.com>
Mon, 2 Jan 2017 12:19:24 +0000 (13:19 +0100)
committerDoug Ledford <dledford@redhat.com>
Fri, 13 Jan 2017 04:00:00 +0000 (23:00 -0500)
Export function for rdma_cm, patch for rdma_cm to follow.

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>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/cache.c
include/rdma/ib_cache.h

index 87fd7c39fbc0f5bf4d30f128e7e91e614242b038..f91886bab9d13daca133e9820c0dfff609826e2b 100644 (file)
@@ -1021,6 +1021,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)
 {
index e30f19bd4a41ef6900cda863c99f3b238a30cd47..385ec88ee9e544838ac15412addc32ea7ac202dd 100644 (file)
@@ -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 */