From patchwork Wed Mar 10 18:06:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Schutt X-Patchwork-Id: 84652 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2AI7eZM024931 for ; Wed, 10 Mar 2010 18:07:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932608Ab0CJSHl (ORCPT ); Wed, 10 Mar 2010 13:07:41 -0500 Received: from sentry-three.sandia.gov ([132.175.109.17]:52168 "EHLO sentry-three.sandia.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932600Ab0CJSHh (ORCPT ); Wed, 10 Mar 2010 13:07:37 -0500 X-WSS-ID: 0KZ2VOK-0C-MLT-02 X-M-MSG: Received: from sentry.sandia.gov (mm03snlnto.sandia.gov [132.175.109.20]) by sentry-three.sandia.gov (Postfix) with ESMTP id 12A404D5673; Wed, 10 Mar 2010 11:07:32 -0700 (MST) Received: from [132.175.109.1] by sentry.sandia.gov with ESMTP (SMTP Relay 01 (Email Firewall v6.3.2)); Wed, 10 Mar 2010 11:07:26 -0700 X-Server-Uuid: AF72F651-81B1-4134-BA8C-A8E1A4E620FF Received: from localhost.localdomain (jast01.sandia.gov [134.253.4.112]) by mailgate.sandia.gov (8.14.1/8.14.1) with ESMTP id o2AI7OpC016900; Wed, 10 Mar 2010 11:07:24 -0700 From: "Jim Schutt" To: linux-rdma@vger.kernel.org cc: sashak@voltaire.com, eitan@mellanox.co.il, jaschut@sandia.gov Subject: [PATCH v2 01/15] opensm: Prepare for routing engine input to path record SL lookup and SL2VL map setup. Date: Wed, 10 Mar 2010 11:06:43 -0700 Message-ID: <1268244416-20351-2-git-send-email-jaschut@sandia.gov> X-Mailer: git-send-email 1.6.6.1 In-Reply-To: <1268244416-20351-1-git-send-email-jaschut@sandia.gov> References: <1268244416-20351-1-git-send-email-jaschut@sandia.gov> X-PMX-Version: 5.5.9.388399, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2010.3.10.175422 X-PerlMx-Spam: Gauge=IIIIIIII, Probability=8%, Report=' BODY_SIZE_10000_PLUS 0, TO_NO_NAME 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __MIME_TEXT_ONLY 0, __SANE_MSGID 0, __STOCK_PHRASE_7 0, __TO_MALFORMED_2 0, __URI_NO_PATH 0, __URI_NO_WWW 0, __URI_NS ' X-TMWD-Spam-Summary: TS=20100310180727; ID=1; SEV=2.3.1; DFV=B2010031017; IFV=NA; AIF=B2010031017; RPD=5.03.0010; ENG=NA; RPDID=7374723D303030312E30413031303230392E34423937444644462E303034393A534346535441543838363133332C73733D312C6667733D30; CAT=NONE; CON=NONE; SIG=AAAAAAAAAAAAAAAAAAAAAAAAfQ== X-MMS-Spam-Filter-ID: B2010031017_5.03.0010 MIME-Version: 1.0 X-WSS-ID: 678900540JG908642-01-01 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 10 Mar 2010 18:07:42 +0000 (UTC) diff --git a/opensm/include/opensm/osm_opensm.h b/opensm/include/opensm/osm_opensm.h index c6c9bdb..e97142e 100644 --- a/opensm/include/opensm/osm_opensm.h +++ b/opensm/include/opensm/osm_opensm.h @@ -120,6 +120,7 @@ typedef enum _osm_routing_engine_type { * added later. */ struct osm_routing_engine { + osm_routing_engine_type_t type; const char *name; void *context; int (*build_lid_matrices) (void *context); @@ -183,7 +184,8 @@ typedef struct osm_opensm { cl_dispatcher_t disp; cl_plock_t lock; struct osm_routing_engine *routing_engine_list; - osm_routing_engine_type_t routing_engine_used; + struct osm_routing_engine *routing_engine_used; + struct osm_routing_engine *default_routing_engine; osm_stats_t stats; osm_console_t console; nn_map_t *node_name_map; diff --git a/opensm/opensm/osm_console.c b/opensm/opensm/osm_console.c index a27bee3..31394a7 100644 --- a/opensm/opensm/osm_console.c +++ b/opensm/opensm/osm_console.c @@ -372,6 +372,8 @@ static void print_status(osm_opensm_t * p_osm, FILE * out) cl_list_item_t *item; if (out) { + const char *re_str; + cl_plock_acquire(&p_osm->lock); fprintf(out, " OpenSM Version : %s\n", p_osm->osm_version); fprintf(out, " SM State : %s\n", @@ -380,9 +382,11 @@ static void print_status(osm_opensm_t * p_osm, FILE * out) p_osm->subn.opt.sm_priority); fprintf(out, " SA State : %s\n", sa_state_str(p_osm->sa.state)); - fprintf(out, " Routing Engine : %s\n", - osm_routing_engine_type_str(p_osm-> - routing_engine_used)); + + re_str = p_osm->routing_engine_used ? + osm_routing_engine_type_str(p_osm->routing_engine_used->type) : + osm_routing_engine_type_str(OSM_ROUTING_ENGINE_TYPE_NONE); + fprintf(out, " Routing Engine : %s\n", re_str); fprintf(out, " Loaded event plugins :"); if (cl_qlist_head(&p_osm->plugin_list) == diff --git a/opensm/opensm/osm_dump.c b/opensm/opensm/osm_dump.c index 86e9c00..f3f4623 100644 --- a/opensm/opensm/osm_dump.c +++ b/opensm/opensm/osm_dump.c @@ -135,7 +135,8 @@ static void dump_ucast_routes(cl_map_item_t * item, FILE * file, void *cxt) "Switch 0x%016" PRIx64 "\nLID : Port : Hops : Optimal\n", cl_ntoh64(osm_node_get_node_guid(p_node))); - dor = (p_osm->routing_engine_used == OSM_ROUTING_ENGINE_TYPE_DOR); + dor = (p_osm->routing_engine_used && + p_osm->routing_engine_used->type == OSM_ROUTING_ENGINE_TYPE_DOR); for (lid_ho = 1; lid_ho <= max_lid_ho; lid_ho++) { fprintf(file, "0x%04X : ", lid_ho); diff --git a/opensm/opensm/osm_link_mgr.c b/opensm/opensm/osm_link_mgr.c index 03a585b..aaeebc7 100644 --- a/opensm/opensm/osm_link_mgr.c +++ b/opensm/opensm/osm_link_mgr.c @@ -64,8 +64,9 @@ static uint8_t link_mgr_get_smsl(IN osm_sm_t * sm, IN osm_physp_t * p_physp) OSM_LOG_ENTER(sm->p_log); - if (p_osm->routing_engine_used != OSM_ROUTING_ENGINE_TYPE_LASH - || !(slid = osm_physp_get_base_lid(p_physp))) { + if (!(p_osm->routing_engine_used && + p_osm->routing_engine_used->type == OSM_ROUTING_ENGINE_TYPE_LASH && + (slid = osm_physp_get_base_lid(p_physp)))) { /* Use default SL if lash routing is not used */ OSM_LOG_EXIT(sm->p_log); return sm->p_subn->opt.sm_sl; diff --git a/opensm/opensm/osm_opensm.c b/opensm/opensm/osm_opensm.c index d0f39da..be1f153 100644 --- a/opensm/opensm/osm_opensm.c +++ b/opensm/opensm/osm_opensm.c @@ -147,7 +147,8 @@ static void append_routing_engine(osm_opensm_t *osm, r->next = routing_engine; } -static void setup_routing_engine(osm_opensm_t *osm, const char *name) +static struct osm_routing_engine *setup_routing_engine(osm_opensm_t *osm, + const char *name) { struct osm_routing_engine *re; const struct routing_engine_module *m; @@ -158,47 +159,53 @@ static void setup_routing_engine(osm_opensm_t *osm, const char *name) if (!re) { OSM_LOG(&osm->log, OSM_LOG_VERBOSE, "memory allocation failed\n"); - return; + return NULL; } memset(re, 0, sizeof(struct osm_routing_engine)); re->name = m->name; + re->type = osm_routing_engine_type(m->name); if (m->setup(re, osm)) { OSM_LOG(&osm->log, OSM_LOG_VERBOSE, "setup of routing" " engine \'%s\' failed\n", name); - return; + free(re); + return NULL; } OSM_LOG(&osm->log, OSM_LOG_DEBUG, "\'%s\' routing engine set up\n", re->name); - append_routing_engine(osm, re); - return; + if (re->type == OSM_ROUTING_ENGINE_TYPE_MINHOP) + osm->default_routing_engine = re; + return re; } } OSM_LOG(&osm->log, OSM_LOG_ERROR, "cannot find or setup routing engine \'%s\'\n", name); + return NULL; } static void setup_routing_engines(osm_opensm_t *osm, const char *engine_names) { char *name, *str, *p; + struct osm_routing_engine *re; - if (!engine_names || !*engine_names) { - setup_routing_engine(osm, "minhop"); - return; + if (engine_names && *engine_names) { + str = strdup(engine_names); + name = strtok_r(str, ", \t\n", &p); + while (name && *name) { + re = setup_routing_engine(osm, name); + if (re) + append_routing_engine(osm, re); + name = strtok_r(NULL, ", \t\n", &p); + } + free(str); } - - str = strdup(engine_names); - name = strtok_r(str, ", \t\n", &p); - while (name && *name) { - setup_routing_engine(osm, name); - name = strtok_r(NULL, ", \t\n", &p); + if (!osm->default_routing_engine) { + re = setup_routing_engine(osm, "minhop"); + if (!osm->routing_engine_list && re) + append_routing_engine(osm, re); } - free(str); - - if (!osm->routing_engine_list) - setup_routing_engine(osm, "minhop"); } void osm_opensm_construct(IN osm_opensm_t * p_osm) diff --git a/opensm/opensm/osm_sa_path_record.c b/opensm/opensm/osm_sa_path_record.c index c4c3f86..d88832b 100644 --- a/opensm/opensm/osm_sa_path_record.c +++ b/opensm/opensm/osm_sa_path_record.c @@ -646,7 +646,8 @@ static ib_api_status_t pr_rcv_get_path_parms(IN osm_sa_t * sa, * Set PathRecord SL */ - is_lash = (p_osm->routing_engine_used == OSM_ROUTING_ENGINE_TYPE_LASH); + is_lash = (p_osm->routing_engine_used && + p_osm->routing_engine_used->type == OSM_ROUTING_ENGINE_TYPE_LASH); if (comp_mask & IB_PR_COMPMASK_SL) { /* diff --git a/opensm/opensm/osm_ucast_lash.c b/opensm/opensm/osm_ucast_lash.c index 3054a56..626887f 100644 --- a/opensm/opensm/osm_ucast_lash.c +++ b/opensm/opensm/osm_ucast_lash.c @@ -1284,7 +1284,8 @@ uint8_t osm_get_lash_sl(osm_opensm_t * p_osm, const osm_port_t * p_src_port, unsigned src_id; osm_switch_t *p_sw; - if (p_osm->routing_engine_used != OSM_ROUTING_ENGINE_TYPE_LASH) + if (!(p_osm->routing_engine_used && + p_osm->routing_engine_used->type == OSM_ROUTING_ENGINE_TYPE_LASH)) return OSM_DEFAULT_SL; p_sw = get_osm_switch_from_port(p_dst_port); diff --git a/opensm/opensm/osm_ucast_mgr.c b/opensm/opensm/osm_ucast_mgr.c index 7ec58b5..dd6568f 100644 --- a/opensm/opensm/osm_ucast_mgr.c +++ b/opensm/opensm/osm_ucast_mgr.c @@ -942,7 +942,7 @@ static int ucast_mgr_route(struct osm_routing_engine *r, osm_opensm_t * osm) return ret; } - osm->routing_engine_used = osm_routing_engine_type(r->name); + osm->routing_engine_used = r; osm_ucast_mgr_set_fwd_tables(&osm->sm.ucast_mgr); @@ -970,24 +970,27 @@ int osm_ucast_mgr_process(IN osm_ucast_mgr_t * p_mgr) ucast_mgr_setup_all_switches(p_mgr->p_subn) < 0) goto Exit; - p_osm->routing_engine_used = OSM_ROUTING_ENGINE_TYPE_NONE; + p_osm->routing_engine_used = NULL; while (p_routing_eng) { if (!ucast_mgr_route(p_routing_eng, p_osm)) break; p_routing_eng = p_routing_eng->next; } - if (p_osm->routing_engine_used == OSM_ROUTING_ENGINE_TYPE_NONE) { + if (!p_osm->routing_engine_used) { /* If configured routing algorithm failed, use default MinHop */ - osm_ucast_mgr_build_lid_matrices(p_mgr); - ucast_mgr_build_lfts(p_mgr); + struct osm_routing_engine *r = p_osm->default_routing_engine; + + r->build_lid_matrices(r->context); + r->ucast_build_fwd_tables(r->context); + p_osm->routing_engine_used = r; osm_ucast_mgr_set_fwd_tables(p_mgr); - p_osm->routing_engine_used = OSM_ROUTING_ENGINE_TYPE_MINHOP; } OSM_LOG(p_mgr->p_log, OSM_LOG_INFO, "%s tables configured on all switches\n", - osm_routing_engine_type_str(p_osm->routing_engine_used)); + osm_routing_engine_type_str(p_osm-> + routing_engine_used->type)); if (p_mgr->p_subn->opt.use_ucast_cache) p_mgr->cache_valid = TRUE;