static int discover_network_properties(lash_t * p_lash) { int i, id = 0; uint8_t vl_min; osm_subn_t *p_subn = &p_lash->p_osm->subn; osm_switch_t *p_next_sw, *p_sw; osm_log_t *p_log = &p_lash->p_osm->log; p_lash->num_switches = cl_qmap_count(&p_subn->sw_guid_tbl); p_lash->switches = calloc(p_lash->num_switches, sizeof(switch_t *)); if (!p_lash->switches) return -1; vl_min = 5; /* set to a high value */ 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); p_lash->switches[id] = switch_create(p_lash, id, p_sw); if (!p_lash->switches[id]) return -1; id++; port_count = osm_node_get_num_physp(p_sw->p_node); /* Note, ignoring port 0. management port */ for (i = 1; i < port_count; i++) { osm_physp_t *p_current_physp = osm_node_get_physp_ptr(p_sw->p_node, i); if (p_current_physp && p_current_physp->p_remote_physp) { ib_port_info_t *p_port_info = &p_current_physp->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; } } /* for */ } /* while */ vl_min = 1 << (vl_min - 1); if (vl_min > 15) vl_min = 15; if (p_lash->p_osm->subn.opt.lash_start_vl >= vl_min) { OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 4D03: " "Start VL(%d) too high for min operational vl(%d)\n", p_lash->p_osm->subn.opt.lash_start_vl, vl_min); return -1; } p_lash->vl_min = vl_min - p_lash->p_osm->subn.opt.lash_start_vl; OSM_LOG(p_log, OSM_LOG_INFO, "min operational vl(%d) start vl(%d) max_switches(%d)\n", p_lash->vl_min, p_lash->p_osm->subn.opt.lash_start_vl, p_lash->num_switches); return 0; }
/* * item_create() * Creates a new item */ item_t *item_create(int type) { item_t *item = NULL; switch(type) { case IT_RING: item = collectible_create(); break; case IT_BOUNCINGRING: item = bouncingcollectible_create(); break; case IT_LIFEBOX: item = lifebox_create(); break; case IT_RINGBOX: item = collectiblebox_create(); break; case IT_STARBOX: item = starbox_create(); break; case IT_SPEEDBOX: item = speedbox_create(); break; case IT_GLASSESBOX: item = glassesbox_create(); break; case IT_SHIELDBOX: item = shieldbox_create(); break; case IT_FIRESHIELDBOX: item = fireshieldbox_create(); break; case IT_THUNDERSHIELDBOX: item = thundershieldbox_create(); break; case IT_WATERSHIELDBOX: item = watershieldbox_create(); break; case IT_ACIDSHIELDBOX: item = acidshieldbox_create(); break; case IT_WINDSHIELDBOX: item = windshieldbox_create(); break; case IT_TRAPBOX: item = trapbox_create(); break; case IT_EMPTYBOX: item = emptybox_create(); break; case IT_CRUSHEDBOX: item = crushedbox_create(); break; case IT_ICON: item = icon_create(); break; case IT_EXPLOSION: item = explosion_create(); break; case IT_FLYINGTEXT: item = flyingtext_create(); break; case IT_ANIMAL: item = animal_create(); break; case IT_LOOPRIGHT: item = loopright_create(); break; case IT_LOOPMIDDLE: item = looptop_create(); break; case IT_LOOPLEFT: item = loopleft_create(); break; case IT_LOOPNONE: item = loopnone_create(); break; case IT_LOOPFLOOR: item = loopfloor_create(); break; case IT_LOOPFLOORNONE: item = loopfloornone_create(); break; case IT_LOOPFLOORTOP: item = loopfloortop_create(); break; case IT_YELLOWSPRING: item = yellowspring_create(); break; case IT_BYELLOWSPRING: item = byellowspring_create(); break; case IT_TRYELLOWSPRING: item = tryellowspring_create(); break; case IT_RYELLOWSPRING: item = ryellowspring_create(); break; case IT_BRYELLOWSPRING: item = bryellowspring_create(); break; case IT_BLYELLOWSPRING: item = blyellowspring_create(); break; case IT_LYELLOWSPRING: item = lyellowspring_create(); break; case IT_TLYELLOWSPRING: item = tlyellowspring_create(); break; case IT_REDSPRING: item = redspring_create(); break; case IT_BREDSPRING: item = bredspring_create(); break; case IT_TRREDSPRING: item = trredspring_create(); break; case IT_RREDSPRING: item = rredspring_create(); break; case IT_BRREDSPRING: item = brredspring_create(); break; case IT_BLREDSPRING: item = blredspring_create(); break; case IT_LREDSPRING: item = lredspring_create(); break; case IT_TLREDSPRING: item = tlredspring_create(); break; case IT_BLUESPRING: item = bluespring_create(); break; case IT_BBLUESPRING: item = bbluespring_create(); break; case IT_TRBLUESPRING: item = trbluespring_create(); break; case IT_RBLUESPRING: item = rbluespring_create(); break; case IT_BRBLUESPRING: item = brbluespring_create(); break; case IT_BLBLUESPRING: item = blbluespring_create(); break; case IT_LBLUESPRING: item = lbluespring_create(); break; case IT_TLBLUESPRING: item = tlbluespring_create(); break; case IT_BLUERING: item = supercollectible_create(); break; case IT_SWITCH: item = switch_create(); break; case IT_DOOR: item = door_create(); break; case IT_TELEPORTER: item = teleporter_create(); break; case IT_BIGRING: item = bigring_create(); break; case IT_CHECKPOINT: item = checkpointorb_create(); break; case IT_GOAL: item = goalsign_create(); break; case IT_ENDSIGN: item = endsign_create(); break; case IT_ENDLEVEL: item = animalprison_create(); break; case IT_BUMPER: item = bumper_create(); break; case IT_DANGER: item = horizontaldanger_create(); break; case IT_VDANGER: item = verticaldanger_create(); break; case IT_FIREDANGER: item = horizontalfiredanger_create(); break; case IT_VFIREDANGER: item = verticalfiredanger_create(); break; case IT_SPIKES: item = floorspikes_create(); break; case IT_CEILSPIKES: item = ceilingspikes_create(); break; case IT_LWSPIKES: item = leftwallspikes_create(); break; case IT_RWSPIKES: item = rightwallspikes_create(); break; case IT_PERSPIKES: item = periodic_floorspikes_create(); break; case IT_PERCEILSPIKES: item = periodic_ceilingspikes_create(); break; case IT_PERLWSPIKES: item = periodic_leftwallspikes_create(); break; case IT_PERRWSPIKES: item = periodic_rightwallspikes_create(); break; case IT_DNADOOR: item = surge_dnadoor_create(); break; case IT_DNADOORNEON: item = neon_dnadoor_create(); break; case IT_DNADOORCHARGE: item = charge_dnadoor_create(); break; case IT_HDNADOOR: item = surge_horizontal_dnadoor_create(); break; case IT_HDNADOORNEON: item = neon_horizontal_dnadoor_create(); break; case IT_HDNADOORCHARGE: item = charge_horizontal_dnadoor_create(); break; case IT_LOOPGREEN: item = loopgreen_create(); break; case IT_LOOPYELLOW: item = loopyellow_create(); break; } if(item != NULL) { item->type = type; item->state = IS_IDLE; item->init(item); } return item; }