<br><br>
<div><span class="gmail_quote">On 8/28/09, <b class="gmail_sendername">Sasha Khapyorsky</b> <<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:sashak@voltaire.com" target="_blank">sashak@voltaire.com</a>> wrote:</span> 
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><br>The function set_next_lft_block() is called in loop with block number<br>incremented, inside it loops by itself in looking for changed block,<br>
caller will call this function with original block number incremented<br>so this internal loop could be repeated again and again. This patch<br>cleans this ineffectiveness.<br><br>Also rename it to set_lft_block() since block number is treated as<br>
parameters and *not* next block is processed and merges some code.<br><br>Signed-off-by: Sasha Khapyorsky <<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:sashak@voltaire.com" target="_blank">sashak@voltaire.com</a>></blockquote>

<div> </div>
<div>Acked-by: Hal Rosenstock <a href="mailto:hal.rosenstock@gmail.com">hal.rosenstock@gmail.com</a><br> </div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">---<br>opensm/include/opensm/osm_ucast_mgr.h |    1 +<br>opensm/opensm/osm_ucast_mgr.c         |  126 +++++++++++----------------------<br>
2 files changed, 43 insertions(+), 84 deletions(-)<br><br>diff --git a/opensm/include/opensm/osm_ucast_mgr.h b/opensm/include/opensm/osm_ucast_mgr.h<br>index 4ef045c..78a88f0 100644<br>--- a/opensm/include/opensm/osm_ucast_mgr.h<br>
+++ b/opensm/include/opensm/osm_ucast_mgr.h<br>@@ -95,6 +95,7 @@ typedef struct osm_ucast_mgr {<br>       osm_subn_t *p_subn;<br>       osm_log_t *p_log;<br>       cl_plock_t *p_lock;<br>+       uint16_t max_lid;<br>       cl_qlist_t port_order_list;<br>
       boolean_t is_dor;<br>       boolean_t some_hop_count_set;<br>diff --git a/opensm/opensm/osm_ucast_mgr.c b/opensm/opensm/osm_ucast_mgr.c<br>index 8ba78f8..a111c10 100644<br>--- a/opensm/opensm/osm_ucast_mgr.c<br>+++ b/opensm/opensm/osm_ucast_mgr.c<br>
@@ -336,6 +336,9 @@ static int set_fwd_tbl_top(IN osm_ucast_mgr_t * p_mgr, IN osm_switch_t * p_sw)<br><br>       CL_ASSERT(p_node);<br><br>+       if (p_mgr->max_lid < p_sw->max_lid_ho)<br>+               p_mgr->max_lid = p_sw->max_lid_ho;<br>
+<br>       p_path = osm_physp_get_dr_path_ptr(osm_node_get_physp_ptr(p_node, 0));<br><br>       /*<br>@@ -478,65 +481,13 @@ static void ucast_mgr_process_top(IN cl_map_item_t * p_map_item,<br>       set_fwd_tbl_top(p_mgr, p_sw);<br>
}<br><br>-static boolean_t set_next_lft_block(IN osm_switch_t * p_sw, IN osm_sm_t * p_sm,<br>-                                   IN uint8_t * p_block,<br>-                                   IN osm_dr_path_t * p_path,<br>-                                   IN uint16_t block_id_ho,<br>
-                                   IN osm_madw_context_t * p_context)<br>-{<br>-       ib_api_status_t status;<br>-       boolean_t sts;<br>-<br>-       OSM_LOG_ENTER(p_sm->p_log);<br>-<br>-       for (;<br>-            (sts = osm_switch_get_lft_block(p_sw, block_id_ho, p_block));<br>
-            block_id_ho++) {<br>-               if (!p_sw->need_update && !p_sm->p_subn->need_update &&<br>-                   !memcmp(p_block,<br>-                           p_sw->new_lft + block_id_ho * IB_SMP_DATA_SIZE,<br>
-                           IB_SMP_DATA_SIZE))<br>-                       continue;<br>-<br>-               OSM_LOG(p_sm->p_log, OSM_LOG_DEBUG,<br>-                       "Writing FT block %u to switch 0x%" PRIx64 "\n",<br>
-                       block_id_ho,<br>-                       cl_ntoh64(p_context->lft_context.node_guid));<br>-<br>-               status = osm_req_set(p_sm, p_path,<br>-                                    p_sw->new_lft +<br>
-                                    block_id_ho * IB_SMP_DATA_SIZE,<br>-                                    IB_SMP_DATA_SIZE, IB_MAD_ATTR_LIN_FWD_TBL,<br>-                                    cl_hton32(block_id_ho),<br>-                                    CL_DISP_MSGID_NONE, p_context);<br>
-<br>-               if (status != IB_SUCCESS)<br>-                       OSM_LOG(p_sm->p_log, OSM_LOG_ERROR, "ERR 3A05: "<br>-                               "Sending linear fwd. tbl. block failed (%s)\n",<br>
-                               ib_get_err_str(status));<br>-               break;<br>-       }<br>-<br>-       OSM_LOG_EXIT(p_sm->p_log);<br>-       return sts;<br>-}<br>-<br>-static boolean_t pipeline_next_lft_block(IN osm_switch_t *p_sw,<br>
-                                        IN osm_ucast_mgr_t *p_mgr,<br>-                                        IN uint16_t block_id_ho)<br>+static int set_lft_block(IN osm_switch_t *p_sw, IN osm_ucast_mgr_t *p_mgr,<br>+                        IN uint16_t block_id_ho)<br>
{<br>-       osm_dr_path_t *p_path;<br>-       osm_madw_context_t context;<br>       uint8_t block[IB_SMP_DATA_SIZE];<br>-       boolean_t status;<br>-<br>-       OSM_LOG_ENTER(p_mgr->p_log);<br>-<br>-       CL_ASSERT(p_sw && p_sw->p_node);<br>
-<br>-       OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,<br>-               "Processing switch 0x%" PRIx64 "\n",<br>-               cl_ntoh64(osm_node_get_node_guid(p_sw->p_node)));<br>+       osm_madw_context_t context;<br>
+       osm_dr_path_t *p_path;<br>+       ib_api_status_t status;<br><br>       /*<br>          Send linear forwarding table blocks to the switch<br>@@ -547,8 +498,7 @@ static boolean_t pipeline_next_lft_block(IN osm_switch_t *p_sw,<br>
               /* any routing should provide the new_lft */<br>               CL_ASSERT(p_mgr->p_subn->opt.use_ucast_cache &&<br>                         p_mgr->cache_valid && !p_sw->need_update);<br>
-               status = FALSE;<br>-               goto Exit;<br>+               return -1;<br>       }<br><br>       p_path = osm_physp_get_dr_path_ptr(osm_node_get_physp_ptr(p_sw->p_node, 0));<br>@@ -556,12 +506,29 @@ static boolean_t pipeline_next_lft_block(IN osm_switch_t *p_sw,<br>
       context.lft_context.node_guid = osm_node_get_node_guid(p_sw->p_node);<br>       context.lft_context.set_method = TRUE;<br><br>-       status = set_next_lft_block(p_sw, p_mgr->sm, &block[0], p_path,<br>-                                   block_id_ho, &context);<br>
+       if (!osm_switch_get_lft_block(p_sw, block_id_ho, block) ||<br>+           (!p_sw->need_update && !p_mgr->p_subn->need_update &&<br>+            !memcmp(block, p_sw->new_lft + block_id_ho * IB_SMP_DATA_SIZE,<br>
+                    IB_SMP_DATA_SIZE)))<br>+               return 0;<br><br>-Exit:<br>-       OSM_LOG_EXIT(p_mgr->p_log);<br>-       return status;<br>+       OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,<br>+               "Writing FT block %u to switch 0x%" PRIx64 "\n", block_id_ho,<br>
+               cl_ntoh64(context.lft_context.node_guid));<br>+<br>+       status = osm_req_set(p_mgr->sm, p_path,<br>+                            p_sw->new_lft + block_id_ho * IB_SMP_DATA_SIZE,<br>+                            IB_SMP_DATA_SIZE, IB_MAD_ATTR_LIN_FWD_TBL,<br>
+                            cl_hton32(block_id_ho),<br>+                            CL_DISP_MSGID_NONE, &context);<br>+       if (status != IB_SUCCESS) {<br>+               OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 3A05: "<br>
+                       "Sending linear fwd. tbl. block failed (%s)\n",<br>+                       ib_get_err_str(status));<br>+               return -1;<br>+       }<br>+<br>+       return 0;<br>}<br><br>/**********************************************************************<br>
@@ -919,26 +886,15 @@ static void sort_ports_by_switch_load(osm_ucast_mgr_t * m)<br><br>static void ucast_mgr_pipeline_fwd_tbl(osm_ucast_mgr_t * p_mgr)<br>{<br>-       cl_qmap_t *p_sw_tbl;<br>-       osm_switch_t *p_sw;<br>
-       uint16_t block_id_ho = 0;<br>-       int sws_notdone;<br>-       boolean_t sts;<br>-<br>-       p_sw_tbl = &p_mgr->p_subn->sw_guid_tbl;<br>-       while (1) {<br>-               p_sw = (osm_switch_t *) cl_qmap_head(p_sw_tbl);<br>
-               sws_notdone = 0;<br>-               while (p_sw != (osm_switch_t *) cl_qmap_end(p_sw_tbl)) {<br>-                       sts = pipeline_next_lft_block(p_sw, p_mgr, block_id_ho);<br>-                       if (sts)<br>
-                               sws_notdone++;<br>-                       p_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item);<br>-               }<br>-               if (!sws_notdone)<br>-                       break;<br>
-               block_id_ho++;<br>-       }<br>+       cl_qmap_t *tbl;<br>+       cl_map_item_t *item;<br>+       unsigned i, max_block = p_mgr->max_lid / 64 + 1;<br>+<br>+       tbl = &p_mgr->p_subn->sw_guid_tbl;<br>
+       for (i = 0; i < max_block; i++)<br>+               for (item = cl_qmap_head(tbl); item != cl_qmap_end(tbl);<br>+                    item = cl_qmap_next(item))<br>+                       set_lft_block((osm_switch_t *)item, p_mgr, i);<br>
}<br><br>static int ucast_mgr_build_lfts(osm_ucast_mgr_t * p_mgr)<br>@@ -984,6 +940,8 @@ static int ucast_mgr_build_lfts(osm_ucast_mgr_t * p_mgr)<br>**********************************************************************/<br>
void osm_ucast_mgr_set_fwd_table(osm_ucast_mgr_t * p_mgr)<br>{<br>+       p_mgr->max_lid = 0;<br>+<br>       cl_qmap_apply_func(&p_mgr->p_subn->sw_guid_tbl,<br>                          ucast_mgr_process_top, p_mgr);<br>
<br>--<br>1.6.4<br><br>_______________________________________________<br>general mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:general@lists.openfabrics.org" target="_blank">general@lists.openfabrics.org</a><br>
<a onclick="return top.js.OpenExtLink(window,event,this)" href="http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general" target="_blank">http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general</a><br><br>To unsubscribe, please visit <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://openib.org/mailman/listinfo/openib-general" target="_blank">http://openib.org/mailman/listinfo/openib-general</a><br>
</blockquote></div><br>