aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/sw/rdmavt/vt.h
diff options
context:
space:
mode:
authorDennis Dalessandro <dennis.dalessandro@intel.com>2016-02-03 14:15:02 -0800
committerDoug Ledford <dledford@redhat.com>2016-03-10 20:37:31 -0500
commitf1badc716349cc2ac6e55ad50dcff598ef97bad5 (patch)
tree4185e010c23a99fc1118971bce88afa605f66a58 /drivers/infiniband/sw/rdmavt/vt.h
parentIB/rdmavt: Add Mem affinity support (diff)
downloadlinux-dev-f1badc716349cc2ac6e55ad50dcff598ef97bad5.tar.xz
linux-dev-f1badc716349cc2ac6e55ad50dcff598ef97bad5.zip
IB/rdmavt: Clean up distinction between port number and index
IB core uses 1 relative indexing for ports. All of our data structures use 0 based indexing. Add an inline function that we can use whenever we need to validate a legal value and try to convert a port number to a port index at the entrance into rdmavt. Try to follow the policy that when we are talking about a port from IB core point of view we refer to it as a port number. When port is an index into our arrays refer to it as a port index. Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com> Reviewed-by: Harish Chegondi <harish.chegondi@intel.com> Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers/infiniband/sw/rdmavt/vt.h')
-rw-r--r--drivers/infiniband/sw/rdmavt/vt.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/infiniband/sw/rdmavt/vt.h b/drivers/infiniband/sw/rdmavt/vt.h
index a5c36d32fa4d..e26f9e94d1ea 100644
--- a/drivers/infiniband/sw/rdmavt/vt.h
+++ b/drivers/infiniband/sw/rdmavt/vt.h
@@ -88,4 +88,16 @@
#define __rvt_pr_err(pdev, name, fmt, ...) \
dev_err(&pdev->dev, "%s: " fmt, name, ##__VA_ARGS__)
+static inline int ibport_num_to_idx(struct ib_device *ibdev, u8 port_num)
+{
+ struct rvt_dev_info *rdi = ib_to_rvt(ibdev);
+ int port_index;
+
+ port_index = port_num - 1; /* IB ports start at 1 our arrays at 0 */
+ if ((port_index < 0) || (port_index >= rdi->dparms.nports))
+ return -EINVAL;
+
+ return port_index;
+}
+
#endif /* DEF_RDMAVT_H */