[ofa-general] [PATCH 1/6 v2] opensm/Unicast Routing Cache: move lft_buf from ucast_mgr to osm_switch

Yevgeny Kliteynik kliteyn at dev.mellanox.co.il
Wed Oct 15 14:34:58 PDT 2008


Instead of having single lft_buf in ucast_mgr,
each switch will hold lft_buf which is the LFT
that was calculated by the recent routing engine
execution.

Signed-off-by: Yevgeny Kliteynik <kliteyn at dev.mellanox.co.il>
---
 opensm/include/opensm/osm_switch.h    |    7 ++++++-
 opensm/include/opensm/osm_ucast_mgr.h |    6 +-----
 opensm/opensm/osm_switch.c            |   12 +++++++++++-
 opensm/opensm/osm_ucast_file.c        |    5 +++--
 opensm/opensm/osm_ucast_ftree.c       |    2 +-
 opensm/opensm/osm_ucast_lash.c        |    8 ++++----
 opensm/opensm/osm_ucast_mgr.c         |   18 +++++-------------
 7 files changed, 31 insertions(+), 27 deletions(-)

diff --git a/opensm/include/opensm/osm_switch.h b/opensm/include/opensm/osm_switch.h
index 1c0f6e9..3d9a72d 100644
--- a/opensm/include/opensm/osm_switch.h
+++ b/opensm/include/opensm/osm_switch.h
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -102,6 +102,7 @@ typedef struct osm_switch {
 	uint8_t **hops;
 	osm_port_profile_t *p_prof;
 	osm_fwd_tbl_t fwd_tbl;
+	uint8_t *lft_buf;
 	osm_mcast_tbl_t mcast_tbl;
 	uint32_t discovery_count;
 	unsigned need_update;
@@ -137,6 +138,10 @@ typedef struct osm_switch {
 *	fwd_tbl
 *		This switch's forwarding table.
 *
+*	lft_buf
+*		This switch's linear forwarding table, as was
+*		calculated by the last routing engine execution.
+*
 *	mcast_tbl
 *		Multicast forwarding table for this switch.
 *
diff --git a/opensm/include/opensm/osm_ucast_mgr.h b/opensm/include/opensm/osm_ucast_mgr.h
index 12be97a..27e89e9 100644
--- a/opensm/include/opensm/osm_ucast_mgr.h
+++ b/opensm/include/opensm/osm_ucast_mgr.h
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -97,7 +97,6 @@ typedef struct osm_ucast_mgr {
 	cl_qlist_t port_order_list;
 	boolean_t is_dor;
 	boolean_t some_hop_count_set;
-	uint8_t *lft_buf;
 } osm_ucast_mgr_t;
 /*
 * FIELDS
@@ -129,9 +128,6 @@ typedef struct osm_ucast_mgr {
 *		tables calculation iteration cycle, set to TRUE to indicate
 *		that some hop count changes were done.
 *
-*	lft_buf
-*		LFT buffer - used during LFT calculation/setup.
-*
 * SEE ALSO
 *	Unicast Manager object
 *********/
diff --git a/opensm/opensm/osm_switch.c b/opensm/opensm/osm_switch.c
index 77ef61e..9bf76e0 100644
--- a/opensm/opensm/osm_switch.c
+++ b/opensm/opensm/osm_switch.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -101,6 +101,13 @@ osm_switch_init(IN osm_switch_t * const p_sw,
 	if (status != IB_SUCCESS)
 		goto Exit;

+	p_sw->lft_buf = malloc(IB_LID_UCAST_END_HO + 1);
+	if (!p_sw->lft_buf) {
+		status = IB_INSUFFICIENT_MEMORY;
+		goto Exit;
+	}
+	memset(p_sw->lft_buf, OSM_NO_PATH, IB_LID_UCAST_END_HO + 1);
+
 	p_sw->p_prof = malloc(sizeof(*p_sw->p_prof) * num_ports);
 	if (p_sw->p_prof == NULL) {
 		status = IB_INSUFFICIENT_MEMORY;
@@ -132,6 +139,8 @@ void osm_switch_delete(IN OUT osm_switch_t ** const pp_sw)
 	osm_mcast_tbl_destroy(&p_sw->mcast_tbl);
 	free(p_sw->p_prof);
 	osm_fwd_tbl_destroy(&p_sw->fwd_tbl);
+	if (p_sw->lft_buf)
+		free(p_sw->lft_buf);
 	if (p_sw->hops) {
 		for (i = 0; i < p_sw->num_hops; i++)
 			if (p_sw->hops[i])
@@ -537,6 +546,7 @@ osm_switch_prepare_path_rebuild(IN osm_switch_t * p_sw, IN uint16_t max_lids)
 		osm_port_prof_construct(&p_sw->p_prof[i]);

 	osm_switch_clear_hops(p_sw);
+	memset(p_sw->lft_buf, OSM_NO_PATH, IB_LID_UCAST_END_HO + 1);

 	if (!p_sw->hops) {
 		hops = malloc((max_lids + 1) * sizeof(hops[0]));
diff --git a/opensm/opensm/osm_ucast_file.c b/opensm/opensm/osm_ucast_file.c
index cbd65c1..a6edf5d 100644
--- a/opensm/opensm/osm_ucast_file.c
+++ b/opensm/opensm/osm_ucast_file.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2006,2007 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2008      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
@@ -91,7 +92,7 @@ static void add_path(osm_opensm_t * p_osm,
 			new_lid);
 	}

-	p_osm->sm.ucast_mgr.lft_buf[new_lid] = port_num;
+	p_sw->lft_buf[new_lid] = port_num;
 	if (!(p_osm->subn.opt.port_profile_switch_nodes && port_guid &&
 	      osm_get_switch_by_guid(&p_osm->subn, port_guid)))
 		osm_switch_count_path(p_sw, port_num);
@@ -195,7 +196,7 @@ static int do_ucast_file_load(void *context)
 					cl_ntoh64(sw_guid));
 				continue;
 			}
-			memset(p_osm->sm.ucast_mgr.lft_buf, OSM_NO_PATH,
+			memset(p_sw->lft_buf, OSM_NO_PATH,
 			       IB_LID_UCAST_END_HO + 1);
 		} else if (p_sw && !strncmp(p, "0x", 2)) {
 			p += 2;
diff --git a/opensm/opensm/osm_ucast_ftree.c b/opensm/opensm/osm_ucast_ftree.c
index 15168b7..35a6a1c 100644
--- a/opensm/opensm/osm_ucast_ftree.c
+++ b/opensm/opensm/osm_ucast_ftree.c
@@ -1945,7 +1945,7 @@ static void __osm_ftree_set_sw_fwd_table(IN cl_map_item_t * const p_map_item,

 	p_sw->p_osm_sw->max_lid_ho = p_ftree->lft_max_lid_ho;

-	memcpy(p_ftree->p_osm->sm.ucast_mgr.lft_buf, p_sw->lft_buf, lft_len);
+	memcpy(p_sw->p_osm_sw->lft_buf, p_sw->lft_buf, lft_len);
 	osm_ucast_mgr_set_fwd_table(&p_ftree->p_osm->sm.ucast_mgr,
 				    p_sw->p_osm_sw);
 }
diff --git a/opensm/opensm/osm_ucast_lash.c b/opensm/opensm/osm_ucast_lash.c
index 929c288..c7dbade 100644
--- a/opensm/opensm/osm_ucast_lash.c
+++ b/opensm/opensm/osm_ucast_lash.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
  * Copyright (c) 2007      Simula Research Laboratory. All rights reserved.
  * Copyright (c) 2007      Silicon Graphics Inc. All rights reserved.
@@ -1064,7 +1064,7 @@ static void populate_fwd_tbls(lash_t * p_lash)
 		current_guid = p_sw->p_node->node_info.port_guid;
 		sw = p_sw->priv;

-		memset(p_osm->sm.ucast_mgr.lft_buf, 0xff,
+		memset(p_sw->lft_buf, OSM_NO_PATH,
 		       IB_LID_UCAST_END_HO + 1);

 		for (lid = 1; lid <= max_lid_ho; lid++) {
@@ -1076,7 +1076,7 @@ static void populate_fwd_tbls(lash_t * p_lash)
 			if (p_dst_sw == p_sw) {
 				uint8_t egress_port = port->p_node->sw ? 0 :
 					port->p_physp->p_remote_physp->port_num;
-				p_osm->sm.ucast_mgr.lft_buf[lid] = egress_port;
+				p_sw->lft_buf[lid] = egress_port;
 				OSM_LOG(p_log, OSM_LOG_VERBOSE,
 					"LASH fwd MY SRC SRC GUID 0x%016" PRIx64
 					" src lash id (%d), src lid no (%u) src lash port (%d) "
@@ -1096,7 +1096,7 @@ static void populate_fwd_tbls(lash_t * p_lash)
 				    virtual_physical_port_table
 				    [lash_egress_port];

-				p_osm->sm.ucast_mgr.lft_buf[lid] =
+				p_sw->lft_buf[lid] =
 				    physical_egress_port;
 				OSM_LOG(p_log, OSM_LOG_VERBOSE,
 					"LASH fwd SRC GUID 0x%016" PRIx64
diff --git a/opensm/opensm/osm_ucast_mgr.c b/opensm/opensm/osm_ucast_mgr.c
index be8e724..2dc5dd4 100644
--- a/opensm/opensm/osm_ucast_mgr.c
+++ b/opensm/opensm/osm_ucast_mgr.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -73,10 +73,6 @@ void osm_ucast_mgr_destroy(IN osm_ucast_mgr_t * const p_mgr)
 	CL_ASSERT(p_mgr);

 	OSM_LOG_ENTER(p_mgr->p_log);
-
-	if (p_mgr->lft_buf)
-		free(p_mgr->lft_buf);
-
 	OSM_LOG_EXIT(p_mgr->p_log);
 }

@@ -96,10 +92,6 @@ osm_ucast_mgr_init(IN osm_ucast_mgr_t * const p_mgr, IN osm_sm_t * sm)
 	p_mgr->p_subn = sm->p_subn;
 	p_mgr->p_lock = sm->p_lock;

-	p_mgr->lft_buf = malloc(IB_LID_UCAST_END_HO + 1);
-	if (!p_mgr->lft_buf)
-		return IB_INSUFFICIENT_MEMORY;
-
 	OSM_LOG_EXIT(p_mgr->p_log);
 	return (status);
 }
@@ -297,7 +289,7 @@ __osm_ucast_mgr_process_port(IN osm_ucast_mgr_t * const p_mgr,
 	   We have selected the port for this LID.
 	   Write it to the forwarding tables.
 	 */
-	p_mgr->lft_buf[lid_ho] = port;
+	p_sw->lft_buf[lid_ho] = port;
 	if (!is_ignored_by_port_prof) {
 		struct osm_remote_node *rem_node_used;
 		osm_switch_count_path(p_sw, port);
@@ -397,14 +389,14 @@ int osm_ucast_mgr_set_fwd_table(IN osm_ucast_mgr_t * const p_mgr,
 	     osm_switch_get_fwd_tbl_block(p_sw, block_id_ho, block);
 	     block_id_ho++) {
 		if (!p_sw->need_update &&
-		    !memcmp(block, p_mgr->lft_buf + block_id_ho * 64, 64))
+		    !memcmp(block, p_sw->lft_buf + block_id_ho * 64, 64))
 			continue;

 		OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
 			"Writing FT block %u\n", block_id_ho);

 		status = osm_req_set(p_mgr->sm, p_path,
-				     p_mgr->lft_buf + block_id_ho * 64,
+				     p_sw->lft_buf + block_id_ho * 64,
 				     sizeof(block),
 				     IB_MAD_ATTR_LIN_FWD_TBL,
 				     cl_hton32(block_id_ho),
@@ -481,7 +473,7 @@ __osm_ucast_mgr_process_tbl(IN cl_map_item_t * const p_map_item,
 		cl_ntoh64(osm_node_get_node_guid(p_sw->p_node)));

 	/* Initialize LIDs in buffer to invalid port number. */
-	memset(p_mgr->lft_buf, OSM_NO_PATH, IB_LID_UCAST_END_HO + 1);
+	memset(p_sw->lft_buf, OSM_NO_PATH, IB_LID_UCAST_END_HO + 1);

 	if (p_mgr->p_subn->opt.lmc)
 		alloc_ports_priv(p_mgr);
-- 
1.5.1.4





More information about the general mailing list