[openib-general] [PATCH] opensm: fix byte ordering in ib_member_get/set_sl_flow_hop()

Sasha Khapyorsky sashak at voltaire.com
Mon May 22 08:10:20 PDT 2006


This fixes net/host byte ordering in ib_member_get/set_sl_flow_hop()
functions.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>


---

 osm/include/iba/ib_types.h |   29 +++++++++++------------------
 1 files changed, 11 insertions(+), 18 deletions(-)

f8c16e36c5294d25136737c7855ffcf718866898
diff --git a/osm/include/iba/ib_types.h b/osm/include/iba/ib_types.h
index 86133ed..7526b4b 100644
--- a/osm/include/iba/ib_types.h
+++ b/osm/include/iba/ib_types.h
@@ -6304,20 +6304,18 @@ ib_member_get_sl_flow_hop(
 	OUT uint32_t* const p_flow_lbl,
 	OUT uint8_t* const p_hop )
 {
-	ib_net32_t tmp_sl_flow_hop;
+	uint32_t tmp = cl_ntoh32(sl_flow_hop);
 
-	if (p_sl)
-		*p_sl = (uint8_t)(sl_flow_hop & 0x0f);
-
-	tmp_sl_flow_hop = sl_flow_hop >> 4;
+	if (p_hop)
+		*p_hop = (uint8_t)tmp;
+	tmp >>= 8;
 
 	if (p_flow_lbl)
-		*p_flow_lbl = (uint32_t)(tmp_sl_flow_hop & 0xfffff);
-
-	tmp_sl_flow_hop = tmp_sl_flow_hop >> 20;
+		*p_flow_lbl = (uint32_t)(tmp & 0xfffff);
+	tmp >>= 20;
 
-	if (p_hop)
-		*p_hop = (uint8_t)(tmp_sl_flow_hop & 0xff);
+	if (p_sl)
+		*p_sl = (uint8_t)tmp;
 }
 /*
 * PARAMETERS
@@ -6355,14 +6353,9 @@ ib_member_set_sl_flow_hop(
 	IN const uint32_t flow_label,
 	IN const uint8_t hop_limit )
 {
-	ib_net32_t sl_flow_hop;
-
-	sl_flow_hop = hop_limit;
-	sl_flow_hop = sl_flow_hop << 20;
-	sl_flow_hop = sl_flow_hop | flow_label;
-	sl_flow_hop = sl_flow_hop << 2;
-	sl_flow_hop = sl_flow_hop | sl;
-	return (sl_flow_hop);
+	uint32_t tmp;
+	tmp = (sl << 28) | ((flow_label & 0xfffff) << 8) | hop_limit;
+	return cl_hton32(tmp);
 }
 /*
 * PARAMETERS
-- 
1.3.2




More information about the general mailing list