[ofa-general] [PATCH 2/3] opensm: eliminate node's physical ports table duplication in osm_port_t
Sasha Khapyorsky
sashak at voltaire.com
Wed May 9 13:30:24 PDT 2007
Eliminate duplication of osm_node's physical ports table in osm_port_t
object.
Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
osm/include/opensm/osm_port.h | 37 +++++++----------------
osm/opensm/osm_pkey_rcv.c | 2 +-
osm/opensm/osm_port.c | 60 +++++++++-----------------------------
osm/opensm/osm_sa_link_record.c | 4 +-
osm/opensm/osm_sa_pkey_record.c | 2 +-
osm/opensm/osm_sa_slvl_record.c | 4 +-
osm/opensm/osm_sa_vlarb_record.c | 2 +-
osm/opensm/osm_slvl_map_rcv.c | 2 +-
osm/opensm/osm_sm_state_mgr.c | 2 +-
osm/opensm/osm_subnet.c | 4 +-
osm/opensm/osm_vl_arb_rcv.c | 2 +-
11 files changed, 37 insertions(+), 84 deletions(-)
diff --git a/osm/include/opensm/osm_port.h b/osm/include/opensm/osm_port.h
index 134012c..19a8502 100644
--- a/osm/include/opensm/osm_port.h
+++ b/osm/include/opensm/osm_port.h
@@ -1274,10 +1274,8 @@ typedef struct _osm_port
struct _osm_node *p_node;
ib_net64_t guid;
uint32_t discovery_count;
- uint8_t default_port_num;
- uint8_t physp_tbl_size;
+ osm_physp_t *p_physp;
cl_qlist_t mcm_list;
- osm_physp_t *tbl[1];
} osm_port_t;
/*
* FIELDS
@@ -1295,20 +1293,13 @@ typedef struct _osm_port
* during the current fabric sweep. This number is reset
* to zero at the start of a sweep.
*
-* default_port_num
-* Index of the physical port used when physical characteristics
-* contained in the Physical Port are needed.
-*
-* physp_tbl_size
-* Number of physical ports associated with this logical port.
+* p_physp
+* The pointer to physical port used when physical
+* characteristics contained in the Physical Port are needed.
*
* mcm_list
* Multicast member list
*
-* tbl
-* Array of pointers to Physical Port objects contained by this node.
-* MUST BE LAST ELEMENT SINCE IT CAN GROW !!!
-*
* SEE ALSO
* Port, Physical Port, Physical Port Table
*********/
@@ -1386,10 +1377,8 @@ static inline ib_net16_t
osm_port_get_base_lid(
IN const osm_port_t* const p_port )
{
- const osm_physp_t* const p_physp = p_port->tbl[p_port->default_port_num];
- CL_ASSERT( p_physp );
- CL_ASSERT( osm_physp_is_valid( p_physp ) );
- return( osm_physp_get_base_lid( p_physp ));
+ CL_ASSERT( p_port->p_physp && osm_physp_is_valid( p_port->p_physp ) );
+ return( osm_physp_get_base_lid( p_port->p_physp ));
}
/*
* PARAMETERS
@@ -1419,10 +1408,8 @@ static inline uint8_t
osm_port_get_lmc(
IN const osm_port_t* const p_port )
{
- const osm_physp_t* const p_physp = p_port->tbl[p_port->default_port_num];
- CL_ASSERT( p_physp );
- CL_ASSERT( osm_physp_is_valid( p_physp ) );
- return( osm_physp_get_lmc( p_physp ));
+ CL_ASSERT( p_port->p_physp && osm_physp_is_valid( p_port->p_physp ) );
+ return( osm_physp_get_lmc( p_port->p_physp ));
}
/*
* PARAMETERS
@@ -1481,8 +1468,7 @@ osm_port_get_phys_ptr(
IN const osm_port_t* const p_port,
IN const uint8_t port_num )
{
- CL_ASSERT( port_num < p_port->physp_tbl_size );
- return( p_port->tbl[port_num] );
+ return p_port->p_physp;
}
/*
* PARAMETERS
@@ -1519,9 +1505,8 @@ osm_physp_t*
osm_port_get_default_phys_ptr(
IN const osm_port_t* const p_port )
{
- CL_ASSERT( p_port->tbl[p_port->default_port_num] );
- CL_ASSERT( osm_physp_is_valid( p_port->tbl[p_port->default_port_num] ) );
- return( p_port->tbl[p_port->default_port_num] );
+ CL_ASSERT( osm_physp_is_valid( p_port->p_physp ) );
+ return p_port->p_physp;
}
/*
* PARAMETERS
diff --git a/osm/opensm/osm_pkey_rcv.c b/osm/opensm/osm_pkey_rcv.c
index 76af9fc..0e0ec46 100644
--- a/osm/opensm/osm_pkey_rcv.c
+++ b/osm/opensm/osm_pkey_rcv.c
@@ -172,7 +172,7 @@ osm_pkey_rcv_process(
else
{
p_physp = osm_port_get_default_phys_ptr(p_port);
- port_num = p_port->default_port_num;
+ port_num = p_physp->port_num;
}
CL_ASSERT( p_physp );
diff --git a/osm/opensm/osm_port.c b/osm/opensm/osm_port.c
index 053fc22..b0949a0 100644
--- a/osm/opensm/osm_port.c
+++ b/osm/opensm/osm_port.c
@@ -174,7 +174,6 @@ osm_port_init(
uint32_t port_index;
ib_net64_t port_guid;
osm_physp_t *p_physp;
- uint32_t size;
CL_ASSERT( p_port );
CL_ASSERT( p_ni );
@@ -187,36 +186,24 @@ osm_port_init(
p_port->guid = port_guid;
/*
- See comment in port_new for info about this...
- */
- size = p_ni->num_ports;
-
- p_port->physp_tbl_size = (uint8_t)(size + 1);
-
- /*
Get the pointers to the physical node objects "owned" by this
logical port GUID.
For switches, all the ports are owned; for HCA's and routers,
only the singular part that has this GUID is owned.
*/
- p_port->default_port_num = 0xFF;
- for( port_index = 0; port_index < p_port->physp_tbl_size; port_index++ )
+ for( port_index = 0; port_index < p_parent_node->physp_tbl_size; port_index++ )
{
p_physp = osm_node_get_physp_ptr( p_parent_node, port_index );
+ /*
+ Because much of the PortInfo data is only valid
+ for port 0 on switches, try to keep the lowest
+ possible value of default_port_num.
+ */
if( osm_physp_is_valid( p_physp ) &&
- port_guid == osm_physp_get_port_guid( p_physp ) )
- {
- p_port->tbl[port_index] = p_physp;
- /*
- Because much of the PortInfo data is only valid
- for port 0 on switches, try to keep the lowest
- possible value of default_port_num.
- */
- if( port_index < p_port->default_port_num )
- p_port->default_port_num = (uint8_t)port_index;
+ port_guid == osm_physp_get_port_guid( p_physp ) ) {
+ p_port->p_physp = p_physp;
+ break;
}
- else
- p_port->tbl[port_index] = NULL;
}
CL_ASSERT( p_port->default_port_num < 0xFF );
@@ -230,21 +217,11 @@ osm_port_new(
IN const osm_node_t* const p_parent_node )
{
osm_port_t* p_port;
- uint32_t size;
-
- /*
- The port object already contains one physical port object pointer.
- Therefore, subtract 1 from the number of physical ports
- used by the switch. This is not done for CA's since they
- need to occupy 1 more physp pointer than they physically have since
- we still reserve room for a "port 0".
- */
- size = p_ni->num_ports;
- p_port = malloc( sizeof(*p_port) + sizeof(void *) * size );
+ p_port = malloc( sizeof(*p_port) );
if( p_port != NULL )
{
- memset( p_port, 0, sizeof(*p_port) + sizeof(void *) * size );
+ memset( p_port, 0, sizeof(*p_port) );
osm_port_init( p_port, p_ni, p_parent_node );
}
@@ -326,7 +303,6 @@ osm_port_add_new_physp(
p_physp = osm_node_get_physp_ptr( p_node, port_num );
CL_ASSERT( osm_physp_is_valid( p_physp ) );
CL_ASSERT( osm_physp_get_port_guid( p_physp ) == p_port->guid );
- p_port->tbl[port_num] = p_physp;
/*
For switches, we generally want to use Port 0, which is
@@ -334,17 +310,9 @@ osm_port_add_new_physp(
The LID value in the PortInfo for example, is only valid
for port 0 on switches.
*/
- if( !osm_physp_is_valid( p_port->tbl[p_port->default_port_num] ) )
- {
- p_port->default_port_num = port_num;
- }
- else
- {
- if( port_num < p_port->default_port_num )
- {
- p_port->default_port_num = port_num;
- }
- }
+ if( !osm_physp_is_valid( osm_port_get_default_phys_ptr( p_port ) ) ||
+ port_num < p_port->p_physp->port_num )
+ p_port->p_physp = p_physp;
}
/**********************************************************************
diff --git a/osm/opensm/osm_sa_link_record.c b/osm/opensm/osm_sa_link_record.c
index 18f655c..17df424 100644
--- a/osm/opensm/osm_sa_link_record.c
+++ b/osm/opensm/osm_sa_link_record.c
@@ -374,7 +374,7 @@ __osm_lr_rcv_get_port_links(
port_num = p_lr->from_port_num;
/* If the port number is out of the range of the p_src_port, then
this couldn't be a relevant record. */
- if (port_num < p_src_port->physp_tbl_size)
+ if (port_num < p_src_port->p_node->physp_tbl_size)
{
p_src_physp = osm_port_get_phys_ptr( p_src_port, port_num );
if (p_src_physp)
@@ -409,7 +409,7 @@ __osm_lr_rcv_get_port_links(
port_num = p_lr->to_port_num;
/* If the port number is out of the range of the p_dest_port, then
this couldn't be a relevant record. */
- if (port_num < p_dest_port->physp_tbl_size )
+ if (port_num < p_dest_port->p_node->physp_tbl_size )
{
p_dest_physp = osm_port_get_phys_ptr(
p_dest_port, port_num );
diff --git a/osm/opensm/osm_sa_pkey_record.c b/osm/opensm/osm_sa_pkey_record.c
index 0a199f1..8186603 100644
--- a/osm/opensm/osm_sa_pkey_record.c
+++ b/osm/opensm/osm_sa_pkey_record.c
@@ -239,7 +239,7 @@ __osm_sa_pkey_by_comp_mask(
if ( p_port->p_node->node_info.node_type != IB_NODE_TYPE_SWITCH )
{
/* we put it in the comp mask and port num */
- port_num = p_port->default_port_num;
+ port_num = p_port->p_physp->port_num;
osm_log( p_rcv->p_log, OSM_LOG_DEBUG,
"__osm_sa_pkey_by_comp_mask: "
"Using Physical Default Port Number: 0x%X (for End Node)\n",
diff --git a/osm/opensm/osm_sa_slvl_record.c b/osm/opensm/osm_sa_slvl_record.c
index 3c4ff02..9fbb5c7 100644
--- a/osm/opensm/osm_sa_slvl_record.c
+++ b/osm/opensm/osm_sa_slvl_record.c
@@ -225,8 +225,8 @@ __osm_sa_slvl_by_comp_mask(
osm_log( p_rcv->p_log, OSM_LOG_DEBUG,
"__osm_sa_slvl_by_comp_mask: "
"Using Physical Default Port Number: 0x%X (for End Node)\n",
- p_port->default_port_num );
- p_out_physp = osm_port_get_phys_ptr( p_port, p_port->default_port_num );
+ p_port->p_physp->port_num );
+ p_out_physp = p_port->p_physp;
/* check that the p_out_physp and the p_req_physp share a pkey */
if (osm_physp_share_pkey( p_rcv->p_log, p_req_physp, p_out_physp ))
__osm_sa_slvl_create( p_rcv, p_out_physp, p_ctxt, 0 );
diff --git a/osm/opensm/osm_sa_vlarb_record.c b/osm/opensm/osm_sa_vlarb_record.c
index 6df5ed9..97fe060 100644
--- a/osm/opensm/osm_sa_vlarb_record.c
+++ b/osm/opensm/osm_sa_vlarb_record.c
@@ -243,7 +243,7 @@ __osm_sa_vl_arb_by_comp_mask(
if ( p_port->p_node->node_info.node_type != IB_NODE_TYPE_SWITCH)
{
/* we put it in the comp mask and port num */
- port_num = p_port->default_port_num;
+ port_num = p_port->p_physp->port_num;
osm_log( p_rcv->p_log, OSM_LOG_DEBUG,
"__osm_sa_vl_arb_by_comp_mask: "
"Using Physical Default Port Number: 0x%X (for End Node)\n",
diff --git a/osm/opensm/osm_slvl_map_rcv.c b/osm/opensm/osm_slvl_map_rcv.c
index 3fa3a7e..b109f75 100644
--- a/osm/opensm/osm_slvl_map_rcv.c
+++ b/osm/opensm/osm_slvl_map_rcv.c
@@ -183,7 +183,7 @@ osm_slvl_rcv_process(
else
{
p_physp = osm_port_get_default_phys_ptr(p_port);
- out_port_num = p_port->default_port_num;
+ out_port_num = p_physp->port_num;
in_port_num = 0;
}
diff --git a/osm/opensm/osm_sm_state_mgr.c b/osm/opensm/osm_sm_state_mgr.c
index 3aa92c8..0034320 100644
--- a/osm/opensm/osm_sm_state_mgr.c
+++ b/osm/opensm/osm_sm_state_mgr.c
@@ -194,7 +194,7 @@ __osm_sm_state_mgr_send_local_port_info_req(
osm_physp_get_dr_path_ptr
( osm_port_get_default_phys_ptr( p_port ) ),
IB_MAD_ATTR_PORT_INFO,
- cl_hton32( p_port->default_port_num ),
+ cl_hton32( p_port->p_physp->port_num ),
CL_DISP_MSGID_NONE, &context );
if( status != IB_SUCCESS )
diff --git a/osm/opensm/osm_subnet.c b/osm/opensm/osm_subnet.c
index c8c3ddc..3d9fdca 100644
--- a/osm/opensm/osm_subnet.c
+++ b/osm/opensm/osm_subnet.c
@@ -266,7 +266,7 @@ osm_get_gid_by_mad_addr(
);
return(IB_INVALID_PARAMETER);
}
- p_physp = osm_port_get_phys_ptr( p_port, p_port->default_port_num);
+ p_physp = p_port->p_physp;
p_gid->unicast.interface_id = p_physp->port_guid;
p_gid->unicast.prefix = p_subn->opt.subnet_prefix;
}
@@ -316,7 +316,7 @@ osm_get_physp_by_mad_addr(
goto Exit;
}
- p_physp = osm_port_get_phys_ptr( p_port, p_port->default_port_num);
+ p_physp = p_port->p_physp;
}
else
{
diff --git a/osm/opensm/osm_vl_arb_rcv.c b/osm/opensm/osm_vl_arb_rcv.c
index 930360a..ed8dfc5 100644
--- a/osm/opensm/osm_vl_arb_rcv.c
+++ b/osm/opensm/osm_vl_arb_rcv.c
@@ -184,7 +184,7 @@ osm_vla_rcv_process(
else
{
p_physp = osm_port_get_default_phys_ptr(p_port);
- port_num = p_port->default_port_num;
+ port_num = p_physp->port_num;
}
CL_ASSERT( p_physp );
--
1.5.2.rc2.20.gac2a
More information about the general
mailing list