[openib-general] [PATCH] opensm: consolidate switch LMC capability checks
Sasha Khapyorsky
sashak at voltaire.com
Tue Nov 21 18:38:02 PST 2006
Instead of duplicated verification of Enhancded SP0 capability and that
LMC is enabled for such ports do this in one function. This fixes two
such checks and should help to eliminate similar errors in a future.
Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
osm/include/opensm/osm_sa_portinfo_record.h | 4 +-
osm/include/opensm/osm_switch.h | 32 ++++++++++++--------------
osm/opensm/osm_lid_mgr.c | 14 +++--------
osm/opensm/osm_sa_portinfo_record.c | 18 ++++++---------
osm/opensm/osm_ucast_mgr.c | 2 +-
5 files changed, 29 insertions(+), 41 deletions(-)
diff --git a/osm/include/opensm/osm_sa_portinfo_record.h b/osm/include/opensm/osm_sa_portinfo_record.h
index 6f417be..b05c1b6 100644
--- a/osm/include/opensm/osm_sa_portinfo_record.h
+++ b/osm/include/opensm/osm_sa_portinfo_record.h
@@ -102,7 +102,7 @@ BEGIN_C_DECLS
*/
typedef struct _osm_pir_rcv
{
- const osm_subn_t *p_subn;
+ osm_subn_t *p_subn;
osm_sa_resp_t *p_resp;
osm_mad_pool_t *p_mad_pool;
osm_log_t *p_log;
@@ -213,7 +213,7 @@ osm_pir_rcv_init(
IN osm_pir_rcv_t* const p_rcv,
IN osm_sa_resp_t* const p_resp,
IN osm_mad_pool_t* const p_mad_pool,
- IN const osm_subn_t* const p_subn,
+ IN osm_subn_t* const p_subn,
IN osm_log_t* const p_log,
IN cl_plock_t* const p_lock );
/*
diff --git a/osm/include/opensm/osm_switch.h b/osm/include/opensm/osm_switch.h
index 0cf7542..f0bb286 100644
--- a/osm/include/opensm/osm_switch.h
+++ b/osm/include/opensm/osm_switch.h
@@ -656,40 +656,38 @@ osm_switch_get_si_ptr(
* Switch object
*********/
-/****f* OpenSM: Switch/osm_switch_is_sp0_enhanced
+/****f* OpenSM: Switch/osm_switch_is_lmc_capable
* NAME
-* osm_switch_is_sp0_enhanced
+* osm_switch_is_lmc_capable
*
* DESCRIPTION
-* Returns whether switch port 0 (SP0) is enhanced or base
+* Returns whether switch port 0 (SP0) can support LMC
*
*/
-static inline uint16_t
-osm_switch_is_sp0_enhanced(
- IN const osm_switch_t* const p_sw )
+static inline unsigned
+osm_switch_is_lmc_capable(
+ IN const osm_switch_t* const p_sw,
+ IN osm_subn_t *p_subn)
{
- ib_switch_info_t *p_si;
-
- if (p_sw && (p_si = osm_switch_get_si_ptr(p_sw)) &&
- ib_switch_info_is_enhanced_port0(p_si))
- {
- return 1; /* enhanced SP0 */
- }
-
- return 0; /* base SP 0 */
+ return (p_subn->opt.lmc_esp0 &&
+ ib_switch_info_is_enhanced_port0(&p_sw->switch_info)) ? 1 : 0;
}
/*
* PARAMETERS
* p_sw
* [in] Pointer to an osm_switch_t object.
*
+* p_subn
+* [in] Pointer to an osm_subn_t object.
+*
* RETURN VALUES
-* TRUE if SP0 is enhanced. FALSE otherwise.
+* TRUE if SP0 is enhanced and globally enabled. FALSE otherwise.
*
* NOTES
+* This is workaround function, it takes into account user defined
+* p_subn->opt.lmc_esp0 parameter.
*
* SEE ALSO
-* Switch object
*********/
/****f* OpenSM: Switch/osm_switch_get_max_block_id
diff --git a/osm/opensm/osm_lid_mgr.c b/osm/opensm/osm_lid_mgr.c
index e9bc295..c2f2643 100644
--- a/osm/opensm/osm_lid_mgr.c
+++ b/osm/opensm/osm_lid_mgr.c
@@ -454,14 +454,10 @@ __osm_lid_mgr_init_sweep(
/* Determine if enhanced switch port 0 */
p_sw = osm_get_switch_by_guid(p_mgr->p_subn,
osm_node_get_node_guid(osm_port_get_parent_node(p_port)));
- if (p_mgr->p_subn->opt.lmc_esp0 && osm_switch_is_sp0_enhanced(p_sw))
- {
+ if (osm_switch_is_lmc_capable(p_sw, p_mgr->p_subn))
num_lids = lmc_num_lids;
- }
else
- {
num_lids = 1;
- }
}
if ((num_lids != 1) &&
@@ -568,7 +564,7 @@ __osm_lid_mgr_init_sweep(
/* Determine if enhanced switch port 0 */
p_sw = osm_get_switch_by_guid(p_mgr->p_subn,
osm_node_get_node_guid(osm_port_get_parent_node(p_port)));
- if (p_mgr->p_subn->opt.lmc_esp0 && osm_switch_is_sp0_enhanced(p_sw))
+ if (osm_switch_is_lmc_capable(p_sw, p_mgr->p_subn))
{
disc_max_lid = disc_min_lid + lmc_num_lids - 1;
num_lids = lmc_num_lids;
@@ -856,10 +852,8 @@ __osm_lid_mgr_get_port_lid(
/* Determine if base switch port 0 */
p_sw = osm_get_switch_by_guid(p_mgr->p_subn,
osm_node_get_node_guid(osm_port_get_parent_node(p_port)));
- if (!p_mgr->p_subn->opt.lmc_esp0 || !osm_switch_is_sp0_enhanced(p_sw))
- {
+ if (!osm_switch_is_lmc_capable(p_sw, p_mgr->p_subn))
num_lids = 1;
- }
}
/* if the port matches the guid2lid */
@@ -1242,7 +1236,7 @@ __osm_lid_mgr_set_physp_pi(
/* Determine if enhanced switch port 0 and if so set LMC */
p_sw = osm_get_switch_by_guid( p_mgr->p_subn, p_node->node_info.node_guid );
- if (p_mgr->p_subn->opt.lmc_esp0 && osm_switch_is_sp0_enhanced(p_sw))
+ if (osm_switch_is_lmc_capable(p_sw, p_mgr->p_subn))
{
/* M_KeyProtectBits are always zero */
p_pi->mkey_lmc = p_mgr->p_subn->opt.lmc;
diff --git a/osm/opensm/osm_sa_portinfo_record.c b/osm/opensm/osm_sa_portinfo_record.c
index 95ce846..4baed9c 100644
--- a/osm/opensm/osm_sa_portinfo_record.c
+++ b/osm/opensm/osm_sa_portinfo_record.c
@@ -109,12 +109,12 @@ osm_pir_rcv_destroy(
**********************************************************************/
ib_api_status_t
osm_pir_rcv_init(
- IN osm_pir_rcv_t* const p_rcv,
- IN osm_sa_resp_t* const p_resp,
- IN osm_mad_pool_t* const p_mad_pool,
- IN const osm_subn_t* const p_subn,
- IN osm_log_t* const p_log,
- IN cl_plock_t* const p_lock )
+ IN osm_pir_rcv_t* const p_rcv,
+ IN osm_sa_resp_t* const p_resp,
+ IN osm_mad_pool_t* const p_mad_pool,
+ IN osm_subn_t* const p_subn,
+ IN osm_log_t* const p_log,
+ IN cl_plock_t* const p_lock )
{
ib_api_status_t status;
@@ -209,14 +209,10 @@ __osm_sa_pir_create(
base_lid_ho = cl_ntoh16( osm_physp_get_base_lid( p_node_physp ) );
p_sw = osm_get_switch_by_guid( p_rcv->p_subn,
osm_physp_get_port_guid( p_node_physp ) );
- if (osm_switch_is_sp0_enhanced(p_sw))
- {
+ if (osm_switch_is_lmc_capable(p_sw, p_rcv->p_subn))
lmc = osm_physp_get_lmc( p_node_physp );
- }
else
- {
lmc = 0;
- }
}
else
{
diff --git a/osm/opensm/osm_ucast_mgr.c b/osm/opensm/osm_ucast_mgr.c
index 4ae7fc3..2da0da3 100644
--- a/osm/opensm/osm_ucast_mgr.c
+++ b/osm/opensm/osm_ucast_mgr.c
@@ -437,7 +437,7 @@ __osm_ucast_mgr_process_hop_0(
osm_switch_prepare_path_rebuild( p_sw );
base_lid_ho = cl_ntoh16( osm_node_get_base_lid( p_node, 0 ) );
- if (osm_switch_is_sp0_enhanced( p_sw ))
+ if (osm_switch_is_lmc_capable( p_sw, p_mgr->p_subn ))
lmc = osm_node_get_lmc( p_node, 0 );
else
lmc = 0;
--
1.4.4.g031c-dirty
More information about the general
mailing list