@@ -525,6 +525,7 @@ typedef struct osm_subn {
cl_qmap_t sw_guid_tbl;
cl_qmap_t node_guid_tbl;
cl_qmap_t port_guid_tbl;
+ cl_qmap_t alias_port_guid_tbl;
cl_qmap_t rtr_guid_tbl;
cl_qlist_t prefix_routes_list;
cl_qmap_t prtn_pkey_tbl;
@@ -1007,6 +1008,36 @@ struct osm_port *osm_get_port_by_lid_ho(const osm_subn_t * subn, uint16_t lid);
* Subnet object, osm_port_t
*********/
+/****f* OpenSM: Subnet/osm_get_port_by_alias_guid
+* NAME
+* osm_get_port_by_alias_guid
+*
+* DESCRIPTION
+* This looks for the given port guid in the subnet table of ports by
+* alias guid.
+* NOTE: this code is not thread safe. Need to grab the lock before
+* calling it.
+*
+* SYNOPSIS
+*/
+struct osm_port *osm_get_port_by_alias_guid(IN osm_subn_t const *p_subn,
+ IN ib_net64_t guid);
+/*
+* PARAMETERS
+* p_subn
+* [in] Pointer to an osm_subn_t object
+*
+* guid
+* [in] The alias port guid in network order
+*
+* RETURN VALUES
+* The port structure pointer if found. NULL otherwise.
+*
+* SEE ALSO
+* Subnet object, osm_subn_construct, osm_subn_destroy,
+* osm_port_t
+*********/
+
/****f* OpenSM: Port/osm_get_port_by_lid
* NAME
* osm_get_port_by_lid
@@ -1,6 +1,7 @@
/*
* Copyright (c) 2005-2009 Voltaire, Inc. All rights reserved.
* Copyright (c) 2009,2010 HNR Consulting. All rights reserved.
+ * Copyright (c) 2010 Mellanox Technologies LTD. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
@@ -1422,8 +1423,8 @@ typedef struct _regexp_list {
static void dump_portguid_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
{
- cl_qmap_t *p_port_guid_tbl;
- osm_port_t *p_port, *p_next_port;
+ cl_qmap_t *p_alias_port_guid_tbl;
+ osm_alias_guid_t *p_alias_guid, *p_next_alias_guid;
regexp_list_t *p_regexp, *p_head_regexp = NULL;
FILE *output = out;
@@ -1472,22 +1473,23 @@ static void dump_portguid_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
/* Subnet doesn't need to be updated so we can carry on */
+ p_alias_port_guid_tbl = &(p_osm->sm.p_subn->alias_port_guid_tbl);
CL_PLOCK_ACQUIRE(p_osm->sm.p_lock);
- p_port_guid_tbl = &(p_osm->sm.p_subn->port_guid_tbl);
- p_next_port = (osm_port_t *) cl_qmap_head(p_port_guid_tbl);
- while (p_next_port != (osm_port_t *) cl_qmap_end(p_port_guid_tbl)) {
+ p_next_alias_guid = (osm_alias_guid_t *) cl_qmap_head(p_alias_port_guid_tbl);
+ while (p_next_alias_guid != (osm_alias_guid_t *) cl_qmap_end(p_alias_port_guid_tbl)) {
- p_port = p_next_port;
- p_next_port =
- (osm_port_t *) cl_qmap_next(&p_next_port->map_item);
+ p_alias_guid = p_next_alias_guid;
+ p_next_alias_guid =
+ (osm_alias_guid_t *) cl_qmap_next(&p_next_alias_guid->map_item);
for (p_regexp = p_head_regexp; p_regexp != NULL;
p_regexp = p_regexp->next)
- if (regexec(&p_regexp->exp, p_port->p_node->print_desc,
+ if (regexec(&p_regexp->exp,
+ p_alias_guid->p_base_port->p_node->print_desc,
0, NULL, 0) == 0) {
fprintf(output, "0x%" PRIxLEAST64 "\n",
- cl_ntoh64(p_port->p_physp->port_guid));
+ cl_ntoh64(p_alias_guid->alias_guid));
break;
}
}
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2002-2010 Mellanox Technologies LTD. All rights reserved.
* Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
* Copyright (c) 2008 Xsigo Systems Inc. All rights reserved.
*
@@ -152,6 +152,7 @@ static void drop_mgr_remove_port(osm_sm_t * sm, IN osm_port_t * p_port)
{
ib_net64_t port_guid;
osm_port_t *p_port_check;
+ cl_qmap_t *p_alias_guid_tbl;
cl_qmap_t *p_sm_guid_tbl;
osm_mcm_port_t *mcm_port;
cl_ptr_vector_t *p_port_lid_tbl;
@@ -160,6 +161,7 @@ static void drop_mgr_remove_port(osm_sm_t * sm, IN osm_port_t * p_port)
uint16_t lid_ho;
osm_node_t *p_node;
osm_remote_sm_t *p_sm;
+ osm_alias_guid_t *p_alias_guid, *p_alias_guid_check;
ib_gid_t port_gid;
ib_mad_notice_attr_t notice;
ib_api_status_t status;
@@ -207,6 +209,21 @@ static void drop_mgr_remove_port(osm_sm_t * sm, IN osm_port_t * p_port)
ib_get_err_str(status));
}
+ p_alias_guid_tbl = &sm->p_subn->alias_port_guid_tbl;
+ p_alias_guid_check = (osm_alias_guid_t *) cl_qmap_head(p_alias_guid_tbl);
+ while (p_alias_guid_check != (osm_alias_guid_t *) cl_qmap_end(p_alias_guid_tbl)) {
+ if (p_alias_guid_check->p_base_port == p_port)
+ p_alias_guid = p_alias_guid_check;
+ else
+ p_alias_guid = NULL;
+ p_alias_guid_check = (osm_alias_guid_t *) cl_qmap_next(&p_alias_guid_check->map_item);
+ if (p_alias_guid) {
+ cl_qmap_remove_item(p_alias_guid_tbl,
+ &p_alias_guid->map_item);
+ osm_alias_guid_delete(&p_alias_guid);
+ }
+ }
+
p_sm_guid_tbl = &sm->p_subn->sm_guid_tbl;
p_sm = (osm_remote_sm_t *) cl_qmap_remove(p_sm_guid_tbl, port_guid);
if (p_sm != (osm_remote_sm_t *) cl_qmap_end(p_sm_guid_tbl)) {
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2009 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2002-2010 Mellanox Technologies LTD. All rights reserved.
* Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
* Copyright (c) 2009 HNR Consulting. All rights reserved.
*
@@ -376,6 +376,7 @@ static void ni_rcv_process_existing_ca_or_router(IN osm_sm_t * sm,
osm_port_t *p_port_check;
uint8_t port_num;
osm_dr_path_t *p_dr_path;
+ osm_alias_guid_t *p_alias_guid, *p_alias_guid_check;
osm_bind_handle_t h_bind;
OSM_LOG_ENTER(sm->p_log);
@@ -425,6 +426,30 @@ static void ni_rcv_process_existing_ca_or_router(IN osm_sm_t * sm,
goto Exit;
}
+ p_alias_guid = osm_alias_guid_new(p_ni->port_guid,
+ p_port);
+ if (!p_alias_guid) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D11: "
+ "alias guid memory allocation failed"
+ " for port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(p_ni->port_guid));
+ goto alias_done;
+ }
+
+ /* insert into alias guid table */
+ p_alias_guid_check =
+ (osm_alias_guid_t *) cl_qmap_insert(&sm->p_subn->alias_port_guid_tbl,
+ p_alias_guid->alias_guid,
+ &p_alias_guid->map_item);
+ if (p_alias_guid_check != p_alias_guid) {
+ /* alias GUID is a duplicate */
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D13: "
+ "Duplicate alias port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(p_ni->port_guid));
+ osm_alias_guid_delete(&p_alias_guid);
+ }
+
+alias_done:
/* If we are a master, then this means the port is new on the subnet.
Mark it as new - need to send trap 64 for these ports.
The condition that we are master is true, since if we are in discovering
@@ -555,6 +580,7 @@ static void ni_rcv_process_new(IN osm_sm_t * sm, IN const osm_madw_t * p_madw)
ib_node_info_t *p_ni;
ib_smp_t *p_smp;
osm_ni_context_t *p_ni_context;
+ osm_alias_guid_t *p_alias_guid, *p_alias_guid_check;
uint8_t port_num;
OSM_LOG_ENTER(sm->p_log);
@@ -618,6 +644,30 @@ static void ni_rcv_process_new(IN osm_sm_t * sm, IN const osm_madw_t * p_madw)
goto Exit;
}
+ p_alias_guid = osm_alias_guid_new(p_ni->port_guid,
+ p_port);
+ if (!p_alias_guid) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D18: "
+ "alias guid memory allocation failed"
+ " for port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(p_ni->port_guid));
+ goto alias_done2;
+ }
+
+ /* insert into alias guid table */
+ p_alias_guid_check =
+ (osm_alias_guid_t *) cl_qmap_insert(&sm->p_subn->alias_port_guid_tbl,
+ p_alias_guid->alias_guid,
+ &p_alias_guid->map_item);
+ if (p_alias_guid_check != p_alias_guid) {
+ /* alias GUID is a duplicate */
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D19: "
+ "Duplicate alias port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(p_ni->port_guid));
+ osm_alias_guid_delete(&p_alias_guid);
+ }
+
+alias_done2:
/* If we are a master, then this means the port is new on the subnet.
Mark it as new - need to send trap 64 on these ports.
The condition that we are master is true, since if we are in discovering
@@ -417,6 +417,7 @@ void osm_subn_construct(IN osm_subn_t * p_subn)
cl_qmap_init(&p_subn->sw_guid_tbl);
cl_qmap_init(&p_subn->node_guid_tbl);
cl_qmap_init(&p_subn->port_guid_tbl);
+ cl_qmap_init(&p_subn->alias_port_guid_tbl);
cl_qmap_init(&p_subn->sm_guid_tbl);
cl_qlist_init(&p_subn->sa_sr_list);
cl_qlist_init(&p_subn->sa_infr_list);
@@ -430,6 +431,7 @@ void osm_subn_destroy(IN osm_subn_t * p_subn)
{
int i;
osm_node_t *p_node, *p_next_node;
+ osm_alias_guid_t *p_alias_guid, *p_next_alias_guid;
osm_port_t *p_port, *p_next_port;
osm_switch_t *p_sw, *p_next_sw;
osm_remote_sm_t *p_rsm, *p_next_rsm;
@@ -445,6 +447,14 @@ void osm_subn_destroy(IN osm_subn_t * p_subn)
osm_node_delete(&p_node);
}
+ p_next_alias_guid = (osm_alias_guid_t *) cl_qmap_head(&p_subn->alias_port_guid_tbl);
+ while (p_next_alias_guid !=
+ (osm_alias_guid_t *) cl_qmap_end(&p_subn->alias_port_guid_tbl)) {
+ p_alias_guid = p_next_alias_guid;
+ p_next_alias_guid = (osm_alias_guid_t *) cl_qmap_next(&p_alias_guid->map_item);
+ osm_alias_guid_delete(&p_alias_guid);
+ }
+
p_next_port = (osm_port_t *) cl_qmap_head(&p_subn->port_guid_tbl);
while (p_next_port !=
(osm_port_t *) cl_qmap_end(&p_subn->port_guid_tbl)) {
@@ -620,6 +630,17 @@ osm_port_t *osm_get_port_by_guid(IN osm_subn_t const *p_subn, IN ib_net64_t guid
return p_port;
}
+osm_port_t *osm_get_port_by_alias_guid(IN osm_subn_t const *p_subn,
+ IN ib_net64_t guid)
+{
+ osm_alias_guid_t *p_alias_guid;
+
+ p_alias_guid = (osm_alias_guid_t *) cl_qmap_get(&(p_subn->alias_port_guid_tbl), guid);
+ if (p_alias_guid == (osm_alias_guid_t *) cl_qmap_end(&(p_subn->alias_port_guid_tbl)))
+ return NULL;
+ return p_alias_guid->p_base_port;
+}
+
osm_port_t *osm_get_port_by_lid_ho(IN osm_subn_t const * subn, IN uint16_t lid)
{
if (lid < cl_ptr_vector_get_size(&subn->port_lid_tbl))
This change prepares for support of alias GUIDs by adding an alias guid port table and currently populates it only with the base port GUID in the response to the SM NodeInfo attribute query. Ultimately, base as well as alternate (alias) guids will be included in this table. Signed-off-by: Hal Rosenstock <hal@mellanox.com> --- -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html