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 <[EMAIL PROTECTED]>
---
 opensm/opensm/osm_switch.c      |    5 +++++
 opensm/opensm/osm_ucast_cache.c |   31 +++++++++++++++++++++++++++----
 opensm/opensm/osm_ucast_mgr.c   |   15 +++++++++++++++
 3 files changed, 47 insertions(+), 4 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..b1ce182 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 {
@@ -1109,6 +1118,7 @@ osm_ucast_cache_process(osm_ucast_mgr_t * p_mgr)
 {
        cl_qmap_t *tbl = &p_mgr->p_subn->sw_guid_tbl;
        cl_map_item_t *item;
+       osm_switch_t * p_sw;

        if (!p_mgr->p_subn->opt.use_ucast_cache)
                return 1;
@@ -1121,8 +1131,21 @@ osm_ucast_cache_process(osm_ucast_mgr_t * p_mgr)
                "Configuring switch tables using cached routing\n");

        for (item = cl_qmap_head(tbl); item != cl_qmap_end(tbl);
-            item = cl_qmap_next(item))
-               osm_ucast_mgr_set_fwd_table(p_mgr, (osm_switch_t *)item);
+            item = cl_qmap_next(item)) {
+               p_sw = (osm_switch_t *)item;
+
+               if (p_sw->need_update && !p_sw->lft_buf) {
+                       /* no new routing was recently calculated for this
+                          switch, but the LFT needs to be updated anyway */
+                       p_sw->lft_buf = p_sw->lft;
+                       p_sw->lft = malloc(IB_LID_UCAST_END_HO + 1);
+                       if (!p_sw->lft)
+                               return IB_INSUFFICIENT_MEMORY;
+                       memset(p_sw->lft, OSM_NO_PATH, IB_LID_UCAST_END_HO + 1);
+               }
+
+               osm_ucast_mgr_set_fwd_table(p_mgr, p_sw);
+       }

        return 0;
 }
diff --git a/opensm/opensm/osm_ucast_mgr.c b/opensm/opensm/osm_ucast_mgr.c
index adb6688..175817c 100644
--- a/opensm/opensm/osm_ucast_mgr.c
+++ b/opensm/opensm/osm_ucast_mgr.c
@@ -392,6 +392,20 @@ 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;

+       if (!p_sw->lft_buf) {
+               /* any routing should provide the lft_buf */
+               CL_ASSERT(p_mgr->p_subn->opt.use_ucast_cache &&
+                         p_mgr->cache_valid && !p_sw->need_update);
+               goto Exit;
+       }
+
+       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;
+               goto Exit;
+       }
+
        for (block_id_ho = 0;
             osm_switch_get_lft_block(p_sw, block_id_ho, block);
             block_id_ho++) {
@@ -417,6 +431,7 @@ int osm_ucast_mgr_set_fwd_table(IN osm_ucast_mgr_t * const 
p_mgr,
                                ib_get_err_str(status));
        }

+Exit:
        OSM_LOG_EXIT(p_mgr->p_log);
        return 0;
 }
-- 
1.5.1.4


_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to