From patchwork Fri Nov 12 22:11:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Schutt X-Patchwork-Id: 321472 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oACMBd9D018672 for ; Fri, 12 Nov 2010 22:11:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933009Ab0KLWLl (ORCPT ); Fri, 12 Nov 2010 17:11:41 -0500 Received: from sentry-three.sandia.gov ([132.175.109.17]:38940 "EHLO sentry-three.sandia.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932584Ab0KLWLk (ORCPT ); Fri, 12 Nov 2010 17:11:40 -0500 X-WSS-ID: 0LBSLNB-0C-26L-02 X-M-MSG: Received: from sentry.sandia.gov (mm04snlnto.sandia.gov [132.175.109.21]) by sentry-three.sandia.gov (Postfix) with ESMTP id 1124E4CA5F6; Fri, 12 Nov 2010 15:11:35 -0700 (MST) Received: from [132.175.109.1] by sentry.sandia.gov with ESMTP (SMTP Relay 01 (Email Firewall v6.3.2)); Fri, 12 Nov 2010 15:11:26 -0700 X-Server-Uuid: AF72F651-81B1-4134-BA8C-A8E1A4E620FF Received: from localhost.localdomain (sale659.sandia.gov [134.253.4.20]) by mailgate.sandia.gov (8.14.4/8.14.4) with ESMTP id oACMBDak000385; Fri, 12 Nov 2010 15:11:16 -0700 From: "Jim Schutt" To: sashak@voltaire.com cc: linux-rdma@vger.kernel.org, "Jim Schutt" Subject: [PATCH 04/13] opensm: Fill in default QoS values at last possible moment. Date: Fri, 12 Nov 2010 15:11:13 -0700 Message-ID: <1289599882-15165-5-git-send-email-jaschut@sandia.gov> X-Mailer: git-send-email 1.6.2.2 In-Reply-To: <1289599882-15165-1-git-send-email-jaschut@sandia.gov> References: <1289599882-15165-1-git-send-email-jaschut@sandia.gov> X-PMX-Version: 5.6.0.2009776, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2010.11.12.220015 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' DATE_TZ_NA 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __MIME_TEXT_ONLY 0, __SANE_MSGID 0, __STOCK_PHRASE_7 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_PATH 0, __URI_NO_WWW 0, __URI_NS ' X-TMWD-Spam-Summary: TS=20101112221127; ID=1; SEV=2.3.1; DFV=B2010111222; IFV=NA; AIF=B2010111222; RPD=5.03.0010; ENG=NA; RPDID=7374723D303030312E30413031303230352E34434444424238462E303032383A534346535441543838363133332C73733D312C6667733D30; CAT=NONE; CON=NONE; SIG=AAAAAAAAAAAAAAAAAAAAAAAAfQ== X-MMS-Spam-Filter-ID: B2010111222_5.03.0010 MIME-Version: 1.0 X-WSS-ID: 60C364044KO2689008-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 (demeter1.kernel.org [140.211.167.41]); Fri, 12 Nov 2010 22:11:43 +0000 (UTC) diff --git a/opensm/opensm/osm_qos.c b/opensm/opensm/osm_qos.c index ba198a0..afea7bb 100644 --- a/opensm/opensm/osm_qos.c +++ b/opensm/opensm/osm_qos.c @@ -376,7 +376,7 @@ int osm_qos_setup(osm_opensm_t * p_osm) /* * QoS config stuff */ -static int parse_one_unsigned(char *str, char delim, unsigned *val) +static int parse_one_unsigned(const char *str, char delim, unsigned *val) { char *end; *val = strtoul(str, &end, 0); @@ -385,10 +385,10 @@ static int parse_one_unsigned(char *str, char delim, unsigned *val) return (int)(end - str); } -static int parse_vlarb_entry(char *str, ib_vl_arb_element_t * e) +static int parse_vlarb_entry(const char *str, ib_vl_arb_element_t * e) { unsigned val; - char *p = str; + const char *p = str; p += parse_one_unsigned(p, ':', &val); e->vl = val % 15; p += parse_one_unsigned(p, ',', &val); @@ -396,10 +396,10 @@ static int parse_vlarb_entry(char *str, ib_vl_arb_element_t * e) return (int)(p - str); } -static int parse_sl2vl_entry(char *str, uint8_t * raw) +static int parse_sl2vl_entry(const char *str, uint8_t * raw) { unsigned val1, val2; - char *p = str; + const char *p = str; p += parse_one_unsigned(p, ',', &val1); p += parse_one_unsigned(p, ',', &val2); *raw = (val1 << 4) | (val2 & 0xf); @@ -410,18 +410,36 @@ static void qos_build_config(struct qos_config *cfg, osm_qos_options_t * opt, osm_qos_options_t * dflt) { int i; - char *p; + const char *p; memset(cfg, 0, sizeof(*cfg)); - cfg->max_vls = opt->max_vls > 0 ? opt->max_vls : dflt->max_vls; + if (opt->max_vls > 0) + cfg->max_vls = opt->max_vls; + else { + if (dflt->max_vls > 0) + cfg->max_vls = dflt->max_vls; + else + cfg->max_vls = OSM_DEFAULT_QOS_MAX_VLS; + } if (opt->high_limit >= 0) cfg->vl_high_limit = (uint8_t) opt->high_limit; - else - cfg->vl_high_limit = (uint8_t) dflt->high_limit; + else { + if (dflt->high_limit >= 0) + cfg->vl_high_limit = (uint8_t) dflt->high_limit; + else + cfg->vl_high_limit = (uint8_t) OSM_DEFAULT_QOS_HIGH_LIMIT; + } - p = opt->vlarb_high ? opt->vlarb_high : dflt->vlarb_high; + if (opt->vlarb_high) + p = opt->vlarb_high; + else { + if (dflt->vlarb_high) + p = dflt->vlarb_high; + else + p = OSM_DEFAULT_QOS_VLARB_HIGH; + } for (i = 0; i < 2 * IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK; i++) { p += parse_vlarb_entry(p, &cfg->vlarb_high[i / @@ -430,7 +448,14 @@ static void qos_build_config(struct qos_config *cfg, osm_qos_options_t * opt, IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK]); } - p = opt->vlarb_low ? opt->vlarb_low : dflt->vlarb_low; + if (opt->vlarb_low) + p = opt->vlarb_low; + else { + if (dflt->vlarb_low) + p = dflt->vlarb_low; + else + p = OSM_DEFAULT_QOS_VLARB_LOW; + } for (i = 0; i < 2 * IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK; i++) { p += parse_vlarb_entry(p, &cfg->vlarb_low[i / @@ -440,6 +465,14 @@ static void qos_build_config(struct qos_config *cfg, osm_qos_options_t * opt, } p = opt->sl2vl ? opt->sl2vl : dflt->sl2vl; + if (opt->sl2vl) + p = opt->sl2vl; + else { + if (dflt->sl2vl) + p = dflt->sl2vl; + else + p = OSM_DEFAULT_QOS_SL2VL; + } for (i = 0; i < IB_MAX_NUM_VLS / 2; i++) p += parse_sl2vl_entry(p, &cfg->sl2vl.raw_vl_by_sl[i]); } diff --git a/opensm/opensm/osm_subnet.c b/opensm/opensm/osm_subnet.c index bc34a0f..be406ac 100644 --- a/opensm/opensm/osm_subnet.c +++ b/opensm/opensm/osm_subnet.c @@ -636,15 +636,6 @@ osm_mgrp_t *osm_get_mgrp_by_mgid(IN osm_subn_t * subn, IN ib_gid_t * mgid) return NULL; } -static void subn_set_default_qos_options(IN osm_qos_options_t * opt) -{ - opt->max_vls = OSM_DEFAULT_QOS_MAX_VLS; - opt->high_limit = OSM_DEFAULT_QOS_HIGH_LIMIT; - opt->vlarb_high = OSM_DEFAULT_QOS_VLARB_HIGH; - opt->vlarb_low = OSM_DEFAULT_QOS_VLARB_LOW; - opt->sl2vl = OSM_DEFAULT_QOS_SL2VL; -} - static void subn_init_qos_options(osm_qos_options_t *opt, osm_qos_options_t *f) { opt->max_vls = 0; @@ -911,38 +902,37 @@ static ib_api_status_t parse_prefix_routes_file(IN osm_subn_t * p_subn) return (errors == 0) ? IB_SUCCESS : IB_ERROR; } -static void subn_verify_max_vls(unsigned *max_vls, const char *prefix, unsigned dflt) +static void subn_verify_max_vls(unsigned *max_vls, const char *prefix) { if (!*max_vls || *max_vls > 15) { if (*max_vls) log_report(" Invalid Cached Option: %s_max_vls=%u: " "Using Default = %u\n", - prefix, *max_vls, dflt); - *max_vls = dflt; + prefix, *max_vls, OSM_DEFAULT_QOS_MAX_VLS); + *max_vls = 0; } } -static void subn_verify_high_limit(int *high_limit, const char *prefix, int dflt) +static void subn_verify_high_limit(int *high_limit, const char *prefix) { if (*high_limit < 0 || *high_limit > 255) { if (*high_limit > 255) log_report(" Invalid Cached Option: %s_high_limit=%d: " "Using Default: %d\n", - prefix, *high_limit, dflt); - *high_limit = dflt; + prefix, *high_limit, + OSM_DEFAULT_QOS_HIGH_LIMIT); + *high_limit = -1; } } static void subn_verify_vlarb(char **vlarb, const char *prefix, - const char *suffix, char *dflt) + const char *suffix) { char *str, *tok, *end, *ptr; int count = 0; - if (*vlarb == NULL) { - *vlarb = strdup(dflt); + if (*vlarb == NULL) return; - } str = strdup(*vlarb); @@ -1001,15 +991,13 @@ static void subn_verify_vlarb(char **vlarb, const char *prefix, free(str); } -static void subn_verify_sl2vl(char **sl2vl, const char *prefix, char *dflt) +static void subn_verify_sl2vl(char **sl2vl, const char *prefix) { char *str, *tok, *end, *ptr; int count = 0; - if (*sl2vl == NULL) { - *sl2vl = strdup(dflt); + if (*sl2vl == NULL) return; - } str = strdup(*sl2vl); @@ -1039,14 +1027,13 @@ static void subn_verify_sl2vl(char **sl2vl, const char *prefix, char *dflt) free(str); } -static void subn_verify_qos_set(osm_qos_options_t *set, const char *prefix, - osm_qos_options_t *dflt) +static void subn_verify_qos_set(osm_qos_options_t *set, const char *prefix) { - subn_verify_max_vls(&set->max_vls, prefix, dflt->max_vls); - subn_verify_high_limit(&set->high_limit, prefix, dflt->high_limit); - subn_verify_vlarb(&set->vlarb_low, prefix, "low", dflt->vlarb_low); - subn_verify_vlarb(&set->vlarb_high, prefix, "high", dflt->vlarb_high); - subn_verify_sl2vl(&set->sl2vl, prefix, dflt->sl2vl); + subn_verify_max_vls(&set->max_vls, prefix); + subn_verify_high_limit(&set->high_limit, prefix); + subn_verify_vlarb(&set->vlarb_low, prefix, "low"); + subn_verify_vlarb(&set->vlarb_high, prefix, "high"); + subn_verify_sl2vl(&set->sl2vl, prefix); } int osm_subn_verify_config(IN osm_subn_opt_t * p_opts) @@ -1102,24 +1089,11 @@ int osm_subn_verify_config(IN osm_subn_opt_t * p_opts) } if (p_opts->qos) { - osm_qos_options_t dflt; - - /* the default options in qos_options must be correct. - * every other one need not be, b/c those will default - * back to whatever is in qos_options. - */ - - subn_set_default_qos_options(&dflt); - - subn_verify_qos_set(&p_opts->qos_options, "qos", &dflt); - subn_verify_qos_set(&p_opts->qos_ca_options, "qos_ca", - &p_opts->qos_options); - subn_verify_qos_set(&p_opts->qos_sw0_options, "qos_sw0", - &p_opts->qos_options); - subn_verify_qos_set(&p_opts->qos_swe_options, "qos_swe", - &p_opts->qos_options); - subn_verify_qos_set(&p_opts->qos_rtr_options, "qos_rtr", - &p_opts->qos_options); + subn_verify_qos_set(&p_opts->qos_options, "qos"); + subn_verify_qos_set(&p_opts->qos_ca_options, "qos_ca"); + subn_verify_qos_set(&p_opts->qos_sw0_options, "qos_sw0"); + subn_verify_qos_set(&p_opts->qos_swe_options, "qos_swe"); + subn_verify_qos_set(&p_opts->qos_rtr_options, "qos_rtr"); } #ifdef ENABLE_OSM_PERF_MGR