summaryrefslogtreecommitdiffstats
path: root/include/rdma
diff options
context:
space:
mode:
authorIra Weiny <ira.weiny@intel.com>2015-05-14 02:02:55 +0200
committerDoug Ledford <dledford@redhat.com>2015-05-18 19:35:06 +0200
commit0cf18d7723055709faf51b50f5a33253b480637f (patch)
tree4057c072cb7cd39f80c4d35f359010afd17f734f /include/rdma
parentIB/Verbs: Improve docs for rdma-helpers (diff)
downloadlinux-0cf18d7723055709faf51b50f5a33253b480637f.tar.xz
linux-0cf18d7723055709faf51b50f5a33253b480637f.zip
IB/core: Create common start/end port functions
Previously start_port and end_port were defined in 2 places, cache.c and device.c and this prevented their use in other modules. Make these common functions, change the name to reflect the rdma name space, and update existing users. Signed-off-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'include/rdma')
-rw-r--r--include/rdma/ib_verbs.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 81740c14fdb1..be4465b5df7b 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1752,6 +1752,33 @@ int ib_query_port(struct ib_device *device,
enum rdma_link_layer rdma_port_get_link_layer(struct ib_device *device,
u8 port_num);
+/**
+ * rdma_start_port - Return the first valid port number for the device
+ * specified
+ *
+ * @device: Device to be checked
+ *
+ * Return start port number
+ */
+static inline u8 rdma_start_port(const struct ib_device *device)
+{
+ return (device->node_type == RDMA_NODE_IB_SWITCH) ? 0 : 1;
+}
+
+/**
+ * rdma_end_port - Return the last valid port number for the device
+ * specified
+ *
+ * @device: Device to be checked
+ *
+ * Return last port number
+ */
+static inline u8 rdma_end_port(const struct ib_device *device)
+{
+ return (device->node_type == RDMA_NODE_IB_SWITCH) ?
+ 0 : device->phys_port_cnt;
+}
+
static inline bool rdma_protocol_ib(struct ib_device *device, u8 port_num)
{
return device->query_protocol(device, port_num) == RDMA_PROTOCOL_IB;