[ofa-general] [PATCH] opensm: simplify osm_port_t setup procedure
Sasha Khapyorsky
sashak at voltaire.com
Sun Jan 27 07:37:50 PST 2008
This simplifies osm_port_t setup procedure - it will always have valid
p_physp pointer (for switches it will be initialized at a node creation
time), we will not need to run over node's physp list anymore.
Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
opensm/include/opensm/osm_port.h | 29 -----------------------
opensm/opensm/osm_node.c | 19 +++++++++++++++
opensm/opensm/osm_port.c | 45 +++++-------------------------------
opensm/opensm/osm_port_info_rcv.c | 2 -
4 files changed, 26 insertions(+), 69 deletions(-)
diff --git a/opensm/include/opensm/osm_port.h b/opensm/include/opensm/osm_port.h
index bba4e44..1bf737c 100644
--- a/opensm/include/opensm/osm_port.h
+++ b/opensm/include/opensm/osm_port.h
@@ -1429,35 +1429,6 @@ osm_get_port_by_base_lid(IN const osm_subn_t * const p_subn,
* Port
*********/
-/****f* OpenSM: Port/osm_port_add_new_physp
-* NAME
-* osm_port_add_new_physp
-*
-* DESCRIPTION
-* Adds a new physical port to the logical collection owned by the Port.
-* Physical Ports added here must share the same GUID as the Port.
-*
-* SYNOPSIS
-*/
-void
-osm_port_add_new_physp(IN osm_port_t * const p_port, IN const uint8_t port_num);
-/*
-* PARAMETERS
-* p_port
-* [in] Pointer to a Port object.
-*
-* port_num
-* [in] Port number to add.
-*
-* RETURN VALUE
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-* Port
-*********/
-
/****f* OpenSM: Port/osm_port_add_mgrp
* NAME
* osm_port_add_mgrp
diff --git a/opensm/opensm/osm_node.c b/opensm/opensm/osm_node.c
index 39f4181..176f916 100644
--- a/opensm/opensm/osm_node.c
+++ b/opensm/opensm/osm_node.c
@@ -86,6 +86,23 @@ osm_node_init_physp(IN osm_node_t * const p_node,
/**********************************************************************
**********************************************************************/
+static void node_init_physp0(IN osm_node_t * const p_node,
+ IN const osm_madw_t * const p_madw)
+{
+ ib_smp_t *p_smp;
+ ib_node_info_t *p_ni;
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ p_ni = (ib_node_info_t *) ib_smp_get_payload_ptr(p_smp);
+
+ osm_physp_init(&p_node->physp_table[0],
+ p_ni->port_guid, 0, p_node,
+ osm_madw_get_bind_handle(p_madw),
+ p_smp->hop_count, p_smp->initial_path);
+}
+
+/**********************************************************************
+ **********************************************************************/
osm_node_t *osm_node_new(IN const osm_madw_t * const p_madw)
{
osm_node_t *p_node;
@@ -132,6 +149,8 @@ osm_node_t *osm_node_new(IN const osm_madw_t * const p_madw)
osm_physp_construct(&p_node->physp_table[i]);
osm_node_init_physp(p_node, p_madw);
+ if (p_ni->node_type == IB_NODE_TYPE_SWITCH)
+ node_init_physp0(p_node, p_madw);
p_node->print_desc = strdup("<unknown>");
return (p_node);
diff --git a/opensm/opensm/osm_port.c b/opensm/opensm/osm_port.c
index 79f42ac..ffc4fb0 100644
--- a/opensm/opensm/osm_port.c
+++ b/opensm/opensm/osm_port.c
@@ -153,9 +153,9 @@ osm_port_init(IN osm_port_t * const p_port,
IN const ib_node_info_t * p_ni,
IN const osm_node_t * const p_parent_node)
{
- uint32_t port_index;
ib_net64_t port_guid;
osm_physp_t *p_physp;
+ uint8_t port_num;
CL_ASSERT(p_port);
CL_ASSERT(p_ni);
@@ -166,27 +166,18 @@ osm_port_init(IN osm_port_t * const p_port,
p_port->p_node = (struct _osm_node *)p_parent_node;
port_guid = p_ni->port_guid;
p_port->guid = port_guid;
+ port_num = p_ni->node_type == IB_NODE_TYPE_SWITCH ?
+ 0 : ib_node_info_get_local_port_num(p_ni);
/*
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,
+ For switches, port '0' is owned; for HCA's and routers,
only the singular part that has this GUID is owned.
*/
- 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->p_physp = p_physp;
- break;
- }
- }
+ p_physp = osm_node_get_physp_ptr(p_parent_node, port_num);
+ CL_ASSERT(port_guid == osm_physp_get_port_guid(p_physp));
+ p_port->p_physp = p_physp;
}
/**********************************************************************
@@ -258,28 +249,6 @@ osm_get_port_by_base_lid(IN const osm_subn_t * const p_subn,
/**********************************************************************
**********************************************************************/
-void
-osm_port_add_new_physp(IN osm_port_t * const p_port, IN const uint8_t port_num)
-{
- osm_physp_t *p_physp;
-
- p_physp = osm_node_get_physp_ptr(p_port->p_node, port_num);
- CL_ASSERT(osm_physp_is_valid(p_physp));
- CL_ASSERT(osm_physp_get_port_guid(p_physp) == p_port->guid);
-
- /*
- For switches, we generally want to use Port 0, which is
- the management port as the default Physical Port.
- The LID value in the PortInfo for example, is only valid
- for port 0 on switches.
- */
- if (!osm_physp_is_valid(p_port->p_physp) ||
- port_num < p_port->p_physp->port_num)
- p_port->p_physp = p_physp;
-}
-
-/**********************************************************************
- **********************************************************************/
ib_api_status_t
osm_port_add_mgrp(IN osm_port_t * const p_port, IN const ib_net16_t mlid)
{
diff --git a/opensm/opensm/osm_port_info_rcv.c b/opensm/opensm/osm_port_info_rcv.c
index 8cc33c5..b91d1a5 100644
--- a/opensm/opensm/osm_port_info_rcv.c
+++ b/opensm/opensm/osm_port_info_rcv.c
@@ -652,8 +652,6 @@ void osm_pi_rcv_process(IN void *context, IN void *data)
p_node,
osm_madw_get_bind_handle(p_madw),
p_smp->hop_count, p_smp->initial_path);
-
- osm_port_add_new_physp(p_port, port_num);
} else {
/*
Update the directed route path to this port
--
1.5.4.rc5
More information about the general
mailing list