[ofa-general] [PATCH] opensm: free lft_buf if it matches switch's lft

Yevgeny Kliteynik kliteyn at dev.mellanox.co.il
Thu Oct 30 07:12:12 PDT 2008


Sasha,

This patch frees the switch's lft_buf if it matches the
LFT that is currently configured on switch.

Signed-off-by: Yevgeny Kliteynik <kliteyn at dev.mellanox.co.il>
---
 opensm/opensm/osm_switch.c      |    5 ++++
 opensm/opensm/osm_ucast_cache.c |   13 ++++++++-
 opensm/opensm/osm_ucast_mgr.c   |   50 ++++++++++++++++++++++----------------
 3 files changed, 45 insertions(+), 23 deletions(-)

diff --git a/opensm/opensm/osm_switch.c b/opensm/opensm/osm_switch.c
index 4b07dbc..30d617b 100644
--- a/opensm/opensm/osm_switch.c
+++ b/opensm/opensm/osm_switch.c
@@ -532,6 +532,11 @@ 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);
+
+	if (!p_sw->lft_buf)
+		if (!(p_sw->lft_buf = malloc(IB_LID_UCAST_END_HO + 1)))
+			return IB_INSUFFICIENT_MEMORY;
+
 	memset(p_sw->lft_buf, OSM_NO_PATH, IB_LID_UCAST_END_HO + 1);

 	if (!p_sw->hops) {
diff --git a/opensm/opensm/osm_ucast_cache.c b/opensm/opensm/osm_ucast_cache.c
index 9287e6c..199fdf0 100644
--- a/opensm/opensm/osm_ucast_cache.c
+++ b/opensm/opensm/osm_ucast_cache.c
@@ -1075,8 +1075,17 @@ osm_ucast_cache_add_node(osm_ucast_mgr_t * p_mgr,

 		/* linear forwarding table */

-		p_cache_sw->lft = p_node->sw->lft_buf;
-		p_node->sw->lft_buf = NULL;
+		if (p_node->sw->lft_buf) {
+			/* LFT buffer exists - we use it, because
+			   it is more updated than the switch's LFT */
+			p_cache_sw->lft = p_node->sw->lft_buf;
+			p_node->sw->lft_buf = NULL;
+		}
+		else {
+			/* no LFT buffer, so we use the switch's LFT */
+			p_cache_sw->lft = p_node->sw->lft;
+			p_node->sw->lft = NULL;
+		}
 		p_cache_sw->max_lid_ho = p_node->sw->max_lid_ho;
 	}
 	else {
diff --git a/opensm/opensm/osm_ucast_mgr.c b/opensm/opensm/osm_ucast_mgr.c
index adb6688..3a1c9a4 100644
--- a/opensm/opensm/osm_ucast_mgr.c
+++ b/opensm/opensm/osm_ucast_mgr.c
@@ -392,29 +392,37 @@ int osm_ucast_mgr_set_fwd_table(IN osm_ucast_mgr_t * const p_mgr,
 	context.lft_context.node_guid = osm_node_get_node_guid(p_node);
 	context.lft_context.set_method = TRUE;

-	for (block_id_ho = 0;
-	     osm_switch_get_lft_block(p_sw, block_id_ho, block);
-	     block_id_ho++) {
-		if (!p_sw->need_update &&
-		    !memcmp(block,
-			    p_sw->lft_buf + block_id_ho * IB_SMP_DATA_SIZE,
-			    IB_SMP_DATA_SIZE))
-			continue;
-
-		OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
-			"Writing FT block %u\n", block_id_ho);
+	if (!p_sw->need_update &&
+	    !memcmp(p_sw->lft, p_sw->lft_buf, IB_LID_UCAST_END_HO + 1)) {
+		free(p_sw->lft_buf);
+		p_sw->lft_buf = NULL;

-		status = osm_req_set(p_mgr->sm, p_path,
-				     p_sw->lft_buf + block_id_ho * IB_SMP_DATA_SIZE,
-				     sizeof(block),
-				     IB_MAD_ATTR_LIN_FWD_TBL,
-				     cl_hton32(block_id_ho),
-				     CL_DISP_MSGID_NONE, &context);
+	} else {

-		if (status != IB_SUCCESS)
-			OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 3A05: "
-				"Sending linear fwd. tbl. block failed (%s)\n",
-				ib_get_err_str(status));
+		for (block_id_ho = 0;
+		     osm_switch_get_lft_block(p_sw, block_id_ho, block);
+		     block_id_ho++) {
+			if (!p_sw->need_update &&
+			    !memcmp(block,
+				    p_sw->lft_buf + block_id_ho * IB_SMP_DATA_SIZE,
+				    IB_SMP_DATA_SIZE))
+				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_sw->lft_buf + block_id_ho * IB_SMP_DATA_SIZE,
+					     sizeof(block),
+					     IB_MAD_ATTR_LIN_FWD_TBL,
+					     cl_hton32(block_id_ho),
+					     CL_DISP_MSGID_NONE, &context);
+	
+			if (status != IB_SUCCESS)
+				OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 3A05: "
+					"Sending linear fwd. tbl. block failed (%s)\n",
+					ib_get_err_str(status));
+		}
 	}

 	OSM_LOG_EXIT(p_mgr->p_log);
-- 
1.5.1.4




More information about the general mailing list