Skip to contentSkip to conversation

opensm/osm_helper: Add ib_mtu_is_valid

PATCH Applied Hal Rosenstock 2 participants 2 messages Oct 4, 2011 – Oct 5, 2011 1 message not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 opensm/osm_helper: Add ib_mtu_is_valid

for use in mtu validation by SA

---
 include/opensm/osm_helper.h |   24 ++++++++++++++++++++++++
 opensm/libopensm.map        |    1 +
 opensm/osm_helper.c         |    7 +++++++
 3 files changed, 32 insertions(+), 0 deletions(-)
include/opensm/osm_helper.h +24 -0
index 7eb4e2a..57d1b00 100644
@@ -588,6 +588,30 @@ const char *osm_get_sm_mgr_state_str(IN uint16_t state);
 * SEE ALSO
 *********/
 
+/****f* IBA Base: Types/ib_mtu_is_valid
+* NAME
+*	ib_mtu_is_valid
+*
+* DESCRIPTION
+*	Validates encoded MTU 
+*
+* SYNOPSIS
+*/
+int ib_mtu_is_valid(IN const int mtu);
+/*
+* PARAMETERS
+*	mtu
+*		[in] Encoded path mtu.
+*
+* RETURN VALUES
+*	Returns an int indicating mtu is valid (1)
+*	or invalid (0).
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
 /****f* IBA Base: Types/ib_rate_is_valid
 * NAME
 *	ib_rate_is_valid
opensm/libopensm.map +1 -0
index 5e8dae8..90c2857 100644
@@ -57,6 +57,7 @@ OPENSM_1.5 {
 		osm_get_lsa_str;
 		osm_get_sm_mgr_signal_str;
 		osm_get_sm_mgr_state_str;
+		ib_mtu_is_valid;
 		ib_rate_is_valid;
 		ib_path_compare_rates;
 		ib_path_rate_get_prev;
opensm/osm_helper.c +7 -0
index 05becb5..f9f3d9d 100644
@@ -2362,6 +2362,13 @@ const char *osm_get_sm_mgr_state_str(IN uint16_t state)
 	    sm_mgr_state_str[ARR_SIZE(sm_mgr_state_str) - 1];
 }
 
+int ib_mtu_is_valid(IN const int mtu)
+{
+	if (mtu < IB_MIN_MTU || mtu > IB_MAX_MTU)
+		return 0;
+	return 1;
+}
+
 int ib_rate_is_valid(IN const int rate)
 {
 	if (rate < IB_MIN_RATE || rate > IB_MAX_RATE)
Signature · 6 lines
1.7.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
In reply to a message not in the archive

opensm/osm_helper.c const char *osm_get_sm_mgr_state_str(IN uint16_t state) · line 2370

Quoted 6 lines · Hal Rosenstock
opensm/osm_helper.c +6 -0
+int ib_mtu_is_valid(IN const int mtu)
+{
+       if (mtu < IB_MIN_MTU || mtu > IB_MAX_MTU)
+               return 0;
+       return 1;
+}

Not that it matters, but the above three lines can also be written as follows:

    return (mtu >= IB_MIN_MTU && mtu <= IB_MAX_MTU);

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html