[openib-general] [PATCH] osm: some trivial chages in the osm_ucast_lash for compilation on windows

Yevgeny Kliteynik kliteyn at dev.mellanox.co.il
Thu Feb 1 03:48:48 PST 2007


Hi Hal,

This patch has some trivial changes in the osm_ucast_lash.c 
for compilation on windows.

In general, this file needs a major cosmetic (and not only)
patch to fit better into the OSM code. Will get back to it 
at some point in the future.

-- Yevgeny

Signed-off-by: Yevgeny Kliteynik <kliteyn at dev.mellanox.co.il>
---
 osm/opensm/osm_ucast_lash.c |   80 ++++++++++++++++++++++--------------------
 1 files changed, 42 insertions(+), 38 deletions(-)

diff --git a/osm/opensm/osm_ucast_lash.c b/osm/opensm/osm_ucast_lash.c
index 70e5cbe..95f3ec9 100644
--- a/osm/opensm/osm_ucast_lash.c
+++ b/osm/opensm/osm_ucast_lash.c
@@ -217,6 +217,8 @@ static uint8_t find_port_from_lid(IN con
   uint8_t port_count = 0;
   uint8_t i=0;
   osm_physp_t *p_current_physp, *p_remote_physp = NULL;
+  ib_port_info_t *port_info;
+  ib_net16_t port_lid;
 
   uint8_t egress_port = 255;
 
@@ -227,8 +229,8 @@ static uint8_t find_port_from_lid(IN con
   // process management port first
   p_current_physp = osm_node_get_physp_ptr(p_sw->p_node, 0);
 
-  ib_port_info_t *port_info = &p_current_physp->port_info;
-  ib_net16_t port_lid =  port_info->base_lid;
+  port_info = &p_current_physp->port_info;
+  port_lid =  port_info->base_lid;
   if (port_lid == lid_no) {
     egress_port = 0;
     goto Exit;
@@ -294,15 +296,15 @@ static int cycle_exists(cdg_vertex_t * s
   } else {
     if(current == NULL) {
       current = start;
-      assert(prev == NULL);
+      CL_ASSERT(prev == NULL);
     }
 
     current->visiting_number = visit_num;
 
     if(prev != NULL) {
       prev->next = current;
-      assert(prev->to == current->from);
-      assert(prev->visiting_number > 0);
+      CL_ASSERT(prev->to == current->from);
+      CL_ASSERT(prev->visiting_number > 0);
     }
 
     new_visit_num = visit_num + 1;
@@ -346,7 +348,7 @@ static void remove_semipermanent_depend_
 
   while(sw != dest_switch){
     v = cdg_vertex_matrix[lane][sw][i_next_switch];
-    assert(v != NULL);
+    CL_ASSERT(v != NULL);
 
     if(v->num_using_vertex == 1) {
 
@@ -366,7 +368,7 @@ static void remove_semipermanent_depend_
 	    depend = i;
 	  }
 
-	assert(found);
+	CL_ASSERT(found);
 
 	if(v->num_using_this_depend[depend] == 1) {
 	  for(i=depend; i<v->num_dependencies-1; i++) {
@@ -403,7 +405,7 @@ static void enqueue(lash_t *p_lash, int
   switch_t **switches = p_lash->switches;
   q_item_t *q_head;
 
-  assert(switches[sw]->q_member == 0);
+  CL_ASSERT(switches[sw]->q_member == 0);
   switches[sw]->q_member = 1;
   switches[sw]->dist = dist;
   switches[sw]->prev = prev;
@@ -454,7 +456,7 @@ static void dequeue(lash_t *p_lash, int
   *dist = switches[q_min->sw]->dist;
   *prev = switches[q_min->sw]->prev;
 
-  assert(switches[q_min->sw]->q_member == 1 && !switches[q_min->sw]->mst_member);
+  CL_ASSERT(switches[q_min->sw]->q_member == 1 && !switches[q_min->sw]->mst_member);
   switches[q_min->sw]->q_member = 0;
   free(q_min);
 }
@@ -468,12 +470,11 @@ static void dequeue(lash_t *p_lash, int
 
 static int get_phys_connection(switch_t **switches, int switch_from, int switch_to)
 {
-  int i = 0;
+  unsigned int i = 0;
 
   for (i = 0; i < switches[switch_from]->num_connections; i++)
     if(switches[switch_from]->phys_connections[i] == switch_to)
       return i;
-  assert(1==1);
   return i;
 }
 
@@ -557,7 +558,7 @@ static void generate_routing_func_for_ms
       i_dest = i_dest->next;
     }
 
-    assert(prev->next == NULL);
+    CL_ASSERT(prev->next == NULL);
     prev->next = concat_dest;
     concat_dest = dest;
   }
@@ -590,10 +591,9 @@ static void generate_cdg_for_sp(lash_t*p
   while(sw != dest_switch) {
 
     if(cdg_vertex_matrix[lane][sw][next_switch] == NULL) {
+      unsigned i;
       v = create_cdg_vertex(num_switches);
 
-      int i;
-
       for(i=0; i<num_switches-1; i++) {
 	v->dependency[i] = NULL;
 	v->num_using_this_depend[i] = 0;
@@ -630,7 +630,7 @@ static void generate_cdg_for_sp(lash_t*p
 	prev->num_using_this_depend[prev->num_dependencies]++;
 	prev->num_dependencies++;
 
-	assert(prev->num_dependencies < num_switches);
+	CL_ASSERT(prev->num_dependencies < (int)num_switches);
 
 	if(prev->temp==0)
 	  prev->num_temp_depend++;
@@ -642,7 +642,7 @@ static void generate_cdg_for_sp(lash_t*p
     output_link = switches[sw]->routing_table[dest_switch].out_link;
 
     if(sw != dest_switch) {
-      assert(output_link != NONE);
+      CL_ASSERT(output_link != NONE);
       next_switch = switches[sw]->phys_connections[output_link];
     }
 
@@ -670,7 +670,7 @@ static void set_temp_depend_to_permanent
 
   while(sw != dest_switch) {
     v = cdg_vertex_matrix[lane][sw][next_switch];
-    assert(v != NULL);
+    CL_ASSERT(v != NULL);
 
     if(v->temp == 1) {
       v->temp = 0;
@@ -706,13 +706,13 @@ static void remove_temp_depend_for_sp(la
 
   while(sw != dest_switch) {
     v = cdg_vertex_matrix[lane][sw][next_switch];
-    assert(v != NULL);
+    CL_ASSERT(v != NULL);
 
     if(v->temp==1) {
       cdg_vertex_matrix[lane][sw][next_switch] = NULL;
       free(v);
     } else {
-      assert(v->num_temp_depend <= v->num_dependencies);
+      CL_ASSERT(v->num_temp_depend <= v->num_dependencies);
       v->num_dependencies = v->num_dependencies - v->num_temp_depend;
       v->num_temp_depend = 0;
       v->num_using_vertex--;
@@ -744,7 +744,8 @@ static void balance_virtual_lanes(lash_t
   int *num_mst_in_lane = p_lash->num_mst_in_lane;
   int ***virtual_location = p_lash->virtual_location;
   int min_filled_lane, max_filled_lane, medium_filled_lane, trials;
-  int old_min_filled_lane, old_max_filled_lane, i, j, new_num_min_lane, new_num_max_lane;
+  int old_min_filled_lane, old_max_filled_lane, new_num_min_lane, new_num_max_lane;
+  unsigned int i, j;
   int src, dest, start, next_switch, output_link;
   int stop = 0, cycle_found;
 
@@ -788,7 +789,7 @@ static void balance_virtual_lanes(lash_t
     output_link = p_lash->switches[src]->routing_table[dest].out_link;
     next_switch = p_lash->switches[src]->phys_connections[output_link];
 
-    assert(cdg_vertex_matrix[min_filled_lane][src][next_switch] != NULL);
+    CL_ASSERT(cdg_vertex_matrix[min_filled_lane][src][next_switch] != NULL);
     cycle_found = cycle_exists(cdg_vertex_matrix[min_filled_lane][src][next_switch], NULL, NULL, 1);
 
     for(i=0; i<num_switches; i++)
@@ -863,7 +864,7 @@ static switch_t *switch_create(lash_t *p
 {
 	unsigned num_switches = p_lash->num_switches;
 	switch_t *sw;
-	int i;
+	unsigned int i;
 
 	sw = malloc(sizeof(*sw));
 	if (!sw)
@@ -926,7 +927,7 @@ static void switch_delete(switch_t *sw)
 
 static void free_lash_structures(lash_t *p_lash)
 {
-  int i,j,k;
+  unsigned int i,j,k;
   unsigned num_switches = p_lash->num_switches;
   osm_log_t *p_log = &p_lash->p_osm->log;
 
@@ -988,12 +989,11 @@ static int init_lash_structures(lash_t *
   unsigned vl_min = p_lash->vl_min;
   unsigned num_switches = p_lash->num_switches;
   osm_log_t *p_log = &p_lash->p_osm->log;
+  int status = IB_SUCCESS;
+  unsigned int  i, j, k;
 
   OSM_LOG_ENTER( p_log, init_lash_structures);
 
-  int status = IB_SUCCESS;
-  int  i, j, k;
-
   // initialise cdg_vertex_matrix[num_switches][num_switches][num_switches]
   p_lash->cdg_vertex_matrix = (cdg_vertex_t****)malloc(vl_min * sizeof(cdg_vertex_t ****));
   for (i = 0; i < vl_min; i++) {
@@ -1084,10 +1084,11 @@ static int lash_core(lash_t *p_lash)
   unsigned num_switches = p_lash->num_switches;
   switch_t **switches = p_lash->switches;
   unsigned lanes_needed = 1;
-  int i, j, k, dest_switch = 0;
+  unsigned int i, j, k, dest_switch = 0;
   reachable_dest_t * dests, * idest;
   int cycle_found = 0;
-  int v_lane, stop = 0, output_link, i_next_switch;
+  unsigned v_lane;
+  int stop = 0, output_link, i_next_switch;
   int status = IB_SUCCESS;
 
   OSM_LOG_ENTER( p_log, lash_core);
@@ -1113,7 +1114,7 @@ static int lash_core(lash_t *p_lash)
 	    output_link = switches[i]->routing_table[dest_switch].out_link;
 	    i_next_switch = switches[i]->phys_connections[output_link];
 
-	    assert(p_lash->cdg_vertex_matrix[v_lane][i][i_next_switch] != NULL);
+	    CL_ASSERT(p_lash->cdg_vertex_matrix[v_lane][i][i_next_switch] != NULL);
 	    cycle_found = cycle_exists(p_lash->cdg_vertex_matrix[v_lane][i][i_next_switch], NULL, NULL, 1);
 
 	    for(j=0; j<num_switches; j++)
@@ -1214,12 +1215,14 @@ static void populate_fwd_tbls(lash_t *p_
 
   // Go through each swtich individually
   while(p_next_sw != (osm_switch_t*)cl_qmap_end( &p_subn->sw_guid_tbl )) {
+      uint64_t current_guid;
+      switch_t *sw;
       p_sw = p_next_sw;
       p_next_sw = (osm_switch_t*)cl_qmap_next( &p_sw->map_item );
 
       max_lid_ho = osm_switch_get_max_lid_ho(p_sw);
-      uint64_t current_guid = p_sw->p_node->node_info.port_guid;
-      switch_t *sw = p_sw->priv;
+      current_guid = p_sw->p_node->node_info.port_guid;
+      sw = p_sw->priv;
 
       memset(p_osm->sm.ucast_mgr.lft_buf, 0xff, IB_LID_UCAST_END_HO + 1);
 
@@ -1244,8 +1247,8 @@ static void populate_fwd_tbls(lash_t *p_
 		  cl_ntoh64(current_guid), -1, egress_port);
         } else {
 	  unsigned dst_lash_switch_id = get_lash_id(p_dst_sw);
-	  uint8_t lash_egress_port = sw->routing_table[dst_lash_switch_id].out_link;
-	  uint8_t physical_egress_port = sw->virtual_physical_port_table[lash_egress_port];
+	  uint8_t lash_egress_port = (uint8_t)sw->routing_table[dst_lash_switch_id].out_link;
+	  uint8_t physical_egress_port = (uint8_t)sw->virtual_physical_port_table[lash_egress_port];
 
 	  p_osm->sm.ucast_mgr.lft_buf[lid] = physical_egress_port;
 	  osm_log(p_log, OSM_LOG_DEBUG,
@@ -1366,7 +1369,7 @@ static void lash_cleanup(lash_t *p_lash)
 
 	if (p_lash->switches) {
 		unsigned id;
-		for (id = 0; id < p_lash->num_switches ; id++)
+		for (id = 0; ((int)id) < p_lash->num_switches ; id++)
 			if (p_lash->switches[id])
 				switch_delete(p_lash->switches[id]);
 		free(p_lash->switches);
@@ -1400,6 +1403,7 @@ static int discover_network_properties(l
 
   p_next_sw = (osm_switch_t*)cl_qmap_head( &p_subn->sw_guid_tbl );
   while(p_next_sw != (osm_switch_t*)cl_qmap_end( &p_subn->sw_guid_tbl ) ) {
+      uint16_t port_count;
       p_sw = p_next_sw;
       p_next_sw = (osm_switch_t*)cl_qmap_next( &p_sw->map_item );
 
@@ -1408,7 +1412,7 @@ static int discover_network_properties(l
         return -1;
       id++;
 
-      uint16_t port_count = osm_node_get_num_physp (p_sw->p_node);
+      port_count = osm_node_get_num_physp (p_sw->p_node);
 
       // Note, ignoring port 0. management port
       for (i=1; i<port_count; i++) {
@@ -1418,7 +1422,7 @@ static int discover_network_properties(l
 	      p_current_physp->p_remote_physp) {
 
 	    ib_port_info_t *p_port_info = &p_current_physp->port_info;
-	    int port_vl_min = ib_port_info_get_op_vls(p_port_info);
+	    uint8_t port_vl_min = ib_port_info_get_op_vls(p_port_info);
 	    if (port_vl_min && port_vl_min < vl_min)
 	      vl_min = port_vl_min;
 	  }
@@ -1508,7 +1512,7 @@ static void lash_delete(void *context)
 	lash_t *p_lash = context;
 	if (p_lash->switches) {
 		unsigned id;
-		for (id = 0; id < p_lash->num_switches ; id++)
+		for (id = 0; ((int)id) < p_lash->num_switches ; id++)
 			if (p_lash->switches[id])
 				switch_delete(p_lash->switches[id]);
 		free(p_lash->switches);
@@ -1534,7 +1538,7 @@ uint8_t osm_get_lash_sl(osm_opensm_t *p_
 	if (!p_sw || !p_sw->priv)
 		return OSM_DEFAULT_SL;
 
-	return ((switch_t *)p_sw->priv)->routing_table[dst_id].lane;
+	return (uint8_t)((switch_t *)p_sw->priv)->routing_table[dst_id].lane;
 }
 
 int osm_ucast_lash_setup(osm_opensm_t *p_osm)
-- 
1.4.4.1.GIT

 




More information about the general mailing list