summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAmrani, Ram <Ram.Amrani@cavium.com>2016-12-26 08:40:57 +0200
committerDoug Ledford <dledford@redhat.com>2017-01-24 15:34:22 -0500
commitd3f4aadd614c4627244452ad64eaf351179f2c31 (patch)
tree05b887462f77741d410c5ee31caabb0489d4ba6c /include
parentff89b070b7c98eb6782361310ca7a15186f15b2c (diff)
downloadlinux-d3f4aadd614c4627244452ad64eaf351179f2c31.tar.bz2
RDMA/core: Add the function ib_mtu_int_to_enum
As the functionality to convert the MTU from a number to enum_ib_mtu is ubiquitous, define a dedicated function and remove the duplicated code. Signed-off-by: Ram Amrani <Ram.Amrani@cavium.com> Reviewed-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/rdma/ib_verbs.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 958a24d8fae7..b567e4452a47 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -352,6 +352,20 @@ static inline int ib_mtu_enum_to_int(enum ib_mtu mtu)
}
}
+static inline enum ib_mtu ib_mtu_int_to_enum(int mtu)
+{
+ if (mtu >= 4096)
+ return IB_MTU_4096;
+ else if (mtu >= 2048)
+ return IB_MTU_2048;
+ else if (mtu >= 1024)
+ return IB_MTU_1024;
+ else if (mtu >= 512)
+ return IB_MTU_512;
+ else
+ return IB_MTU_256;
+}
+
enum ib_port_state {
IB_PORT_NOP = 0,
IB_PORT_DOWN = 1,