diff mbox series

[opensm] Replace hard coded constants with defines for force_link_xxx options

Message ID 660502ab-74c1-ea18-f0b5-35245bb2f66c@dev.mellanox.co.il (mailing list archive)
State Not Applicable
Headers show
Series [opensm] Replace hard coded constants with defines for force_link_xxx options | expand

Commit Message

Hal Rosenstock Sept. 20, 2018, 1 p.m. UTC
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
---
 include/iba/ib_types.h | 13 +++++++++++++
 opensm/osm_link_mgr.c  |  6 +++---
 opensm/osm_subnet.c    | 34 +++++++++++++++++++---------------
 3 files changed, 35 insertions(+), 18 deletions(-)
diff mbox series

Patch

diff --git a/include/iba/ib_types.h b/include/iba/ib_types.h
index 3fde273..fb1c3f9 100644
--- a/include/iba/ib_types.h
+++ b/include/iba/ib_types.h
@@ -5180,14 +5180,27 @@  ib_port_info_get_link_speed_active(IN const ib_port_info_t * const p_pi)
 #define IB_LINK_WIDTH_ACTIVE_8X			4
 #define IB_LINK_WIDTH_ACTIVE_12X 		8
 #define IB_LINK_WIDTH_ACTIVE_2X			16
+#define IB_LINK_WIDTH_1X_2X_4X_8X_OR_12X	(IB_LINK_WIDTH_ACTIVE_1X | \
+						 IB_LINK_WIDTH_ACTIVE_2X | \
+						 IB_LINK_WIDTH_ACTIVE_4X | \
+						 IB_LINK_WIDTH_ACTIVE_8X | \
+						 IB_LINK_WIDTH_ACTIVE_12X)
+#define IB_LINK_WIDTH_SET_LWS			255
 #define IB_LINK_SPEED_ACTIVE_EXTENDED		0
 #define IB_LINK_SPEED_ACTIVE_2_5		1
 #define IB_LINK_SPEED_ACTIVE_5			2
 #define IB_LINK_SPEED_ACTIVE_10			4
+#define IB_LINK_SPEED_2_5_5_OR_10		(IB_LINK_SPEED_ACTIVE_2_5 | \
+						 IB_LINK_SPEED_ACTIVE_5 | \
+						 IB_LINK_SPEED_ACTIVE_10)
+#define IB_LINK_SPEED_SET_LSS			15
 #define IB_LINK_SPEED_EXT_ACTIVE_NONE		0
 #define IB_LINK_SPEED_EXT_ACTIVE_14		1
 #define IB_LINK_SPEED_EXT_ACTIVE_25		2
 #define IB_LINK_SPEED_EXT_ACTIVE_50		4
+#define IB_LINK_SPEED_EXT_14_25_OR_50		(IB_LINK_SPEED_EXT_ACTIVE_14 | \
+						 IB_LINK_SPEED_EXT_ACTIVE_25 | \
+						 IB_LINK_SPEED_EXT_ACTIVE_50)
 #define IB_LINK_SPEED_EXT_DISABLE		30
 #define IB_LINK_SPEED_EXT_SET_LSES		31
 
diff --git a/opensm/osm_link_mgr.c b/opensm/osm_link_mgr.c
index dcdbab8..64ddaf7 100644
--- a/opensm/osm_link_mgr.c
+++ b/opensm/osm_link_mgr.c
@@ -338,10 +338,10 @@  static int link_mgr_set_physp_pi(osm_sm_t * sm, IN osm_physp_t * p_physp,
 		   then determine the neighbor MTU.
 		 */
 		if (sm->p_subn->opt.force_link_width &&
-		    (sm->p_subn->opt.force_link_width < 16 ||
+		    (sm->p_subn->opt.force_link_width < IB_LINK_WIDTH_ACTIVE_2X ||
 		     (p_pi->capability_mask2 &
 		      IB_PORT_CAP2_IS_LINK_WIDTH_2X_SUPPORTED)) &&
-		    (sm->p_subn->opt.force_link_width != 255 ||
+		    (sm->p_subn->opt.force_link_width != IB_LINK_WIDTH_SET_LWS ||
 		     p_pi->link_width_enabled != p_pi->link_width_supported)) {
 			p_pi->link_width_enabled = sm->p_subn->opt.force_link_width;
 			if (p_pi->link_width_enabled != p_old_pi->link_width_enabled)
@@ -349,7 +349,7 @@  static int link_mgr_set_physp_pi(osm_sm_t * sm, IN osm_physp_t * p_physp,
 		}
 
 		if (sm->p_subn->opt.force_link_speed &&
-		    (sm->p_subn->opt.force_link_speed != 15 ||
+		    (sm->p_subn->opt.force_link_speed != IB_LINK_SPEED_SET_LSS ||
 		     ib_port_info_get_link_speed_enabled(p_pi) !=
 		     ib_port_info_get_link_speed_sup(p_pi))) {
 			ib_port_info_set_link_speed_enabled(p_pi,
diff --git a/opensm/osm_subnet.c b/opensm/osm_subnet.c
index 685d19b..8d0d46f 100644
--- a/opensm/osm_subnet.c
+++ b/opensm/osm_subnet.c
@@ -1566,9 +1566,9 @@  void osm_subn_set_default_opt(IN osm_subn_opt_t * p_opt)
 	p_opt->lmc = OSM_DEFAULT_LMC;
 	p_opt->lmc_esp0 = FALSE;
 	p_opt->max_op_vls = OSM_DEFAULT_MAX_OP_VLS;
-	p_opt->force_link_speed = 15;
-	p_opt->force_link_speed_ext = 31;
-	p_opt->force_link_width = 255;
+	p_opt->force_link_speed = IB_LINK_SPEED_SET_LSS;
+	p_opt->force_link_speed_ext = IB_LINK_SPEED_EXT_SET_LSES;
+	p_opt->force_link_width = IB_LINK_WIDTH_SET_LWS;
 	p_opt->fdr10 = 1;
 	p_opt->reassign_lids = FALSE;
 	p_opt->ignore_other_sm = FALSE;
@@ -2050,27 +2050,31 @@  int osm_subn_verify_config(IN osm_subn_opt_t * p_opts)
 		p_opts->sm_priority = OSM_DEFAULT_SM_PRIORITY;
 	}
 
-	if ((15 < p_opts->force_link_speed) ||
-	    (p_opts->force_link_speed > 7 && p_opts->force_link_speed < 15)) {
+	if ((IB_LINK_SPEED_SET_LSS < p_opts->force_link_speed) ||
+	    (p_opts->force_link_speed > IB_LINK_SPEED_2_5_5_OR_10 &&
+	     p_opts->force_link_speed < IB_LINK_SPEED_SET_LSS)) {
 		log_report(" Invalid Cached Option Value:force_link_speed = %u:"
 			   "Using Default:%u\n", p_opts->force_link_speed,
-			   IB_PORT_LINK_SPEED_ENABLED_MASK);
-		p_opts->force_link_speed = IB_PORT_LINK_SPEED_ENABLED_MASK;
+			   IB_LINK_SPEED_SET_LSS);
+		p_opts->force_link_speed = IB_LINK_SPEED_SET_LSS;
 	}
 
-	if ((31 < p_opts->force_link_speed_ext) ||
-	    (p_opts->force_link_speed_ext > 7 && p_opts->force_link_speed_ext < 30)) {
+	if ((IB_LINK_SPEED_EXT_SET_LSES < p_opts->force_link_speed_ext) ||
+	    (p_opts->force_link_speed_ext > IB_LINK_SPEED_EXT_14_25_OR_50 &&
+	     p_opts->force_link_speed_ext < IB_LINK_SPEED_EXT_DISABLE)) {
 		log_report(" Invalid Cached Option Value:force_link_speed_ext = %u:"
 			   "Using Default:%u\n", p_opts->force_link_speed_ext,
-			   31);
-		p_opts->force_link_speed_ext = 31;
+			   IB_LINK_SPEED_EXT_SET_LSES);
+		p_opts->force_link_speed_ext = IB_LINK_SPEED_EXT_SET_LSES;
 	}
 
-	if ((255 < p_opts->force_link_width) ||
-	    (p_opts->force_link_width > 31 && p_opts->force_link_width < 255)) {
+	if ((IB_LINK_WIDTH_SET_LWS < p_opts->force_link_width) ||
+	    (p_opts->force_link_width > IB_LINK_WIDTH_1X_2X_4X_8X_OR_12X &&
+	     p_opts->force_link_width < IB_LINK_WIDTH_SET_LWS)) {
 		log_report(" Invalid Cached Option Value:force_link_width = %u:"
-			   "Using Default:%u\n", p_opts->force_link_width, 255);
-		p_opts->force_link_width = 255;
+			   "Using Default:%u\n", p_opts->force_link_width,
+			   IB_LINK_WIDTH_SET_LWS);
+		p_opts->force_link_width = IB_LINK_WIDTH_SET_LWS;
 	}
 
 	if (2 < p_opts->fdr10) {