From patchwork Thu Sep 20 13:00:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 10607725 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 50100112B for ; Thu, 20 Sep 2018 13:01:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F8702D579 for ; Thu, 20 Sep 2018 13:01:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3DF022D57A; Thu, 20 Sep 2018 13:01:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F9042D590 for ; Thu, 20 Sep 2018 13:01:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732671AbeITSoY (ORCPT ); Thu, 20 Sep 2018 14:44:24 -0400 Received: from mail-qk1-f177.google.com ([209.85.222.177]:45180 "EHLO mail-qk1-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727633AbeITSoY (ORCPT ); Thu, 20 Sep 2018 14:44:24 -0400 Received: by mail-qk1-f177.google.com with SMTP id q20-v6so586027qkc.12 for ; Thu, 20 Sep 2018 06:00:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dev-mellanox-co-il.20150623.gappssmtp.com; s=20150623; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=A4ss4RPu7Mej8kwnS4R/7eXlcEMO1uz99XRYr1s8BPc=; b=Nm1Wr5EuPYLppqmie9GjqXi8P/qmbKykFaFI8H4VkWpRaTkCGBDRx9nq62kk8Vtb+d JO/f1Th9NqI35/RHd2hSitA+a6FrWMefzPX/4UJQhf6GI801MJPoaAxY7A9QNMwEbQg/ uOgxN1Ae45Bdai0zY7jUBOoz1esPwG7W4Z3jLjRaT5XnYrCYiI0BxsDQ4fW8lYPiJRY7 l0uScCmRXx+AWFQ8Mian282nTv0ThnrVqqxasRSAnxEeXk6Sc2SClNbIs4c9R3jkt5gZ wjYlT2WKMnQ5smGzt8Buee19HMRUjdxrRB1RStTS6Td0GXcNC2XAA7izE1mL5mv3gkKH Aofg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=A4ss4RPu7Mej8kwnS4R/7eXlcEMO1uz99XRYr1s8BPc=; b=CxEwPknqRghHxk3MeaDeOSvcv4Zp8ShIbBPcjQrsKmCurKaGk97ZsfV5HLi2AjtSBE S7NmGfGC+icxcyuh2H9ECSPpcWvu4kWTH3CDkOoGxAVrkJ9P4BKJsplRD7kOFLyKQugF GbeVdFAO7xGESnoCZ8Nn9QBIdwpL97WcMHIVh93s9svC2FmRz5pIBcpYmcjlJDcsqcMk SGnPmgcwc58X9GZW52JdG1WT/8+N5cbNTwGa3gOsK/LhOCnZ2fUKLnsJENvZ9e/9sLK7 TmQybq1ArNABOjgJdjeZTzoh4ngMfZ4ovaZlo61wgwXCStFnAWjeyyv9OhcAYcm2oDCO m1Ow== X-Gm-Message-State: APzg51DuO4I+j4HIci6vLStzSUxxXItgTJgT1b1pdlQeA+EnS3SvgbBT 1agQF69xPyJZEJ4zeXHjGVY+zjhopGA= X-Google-Smtp-Source: ANB0VdaxGHhNW22He3LrBlmxHRFEP5KZ8HU2GQI6BacGUg0Y3XgGjfejS/KV9lLkoLPHFn8j1cQunQ== X-Received: by 2002:a37:56c7:: with SMTP id k190-v6mr25583586qkb.29.1537448458768; Thu, 20 Sep 2018 06:00:58 -0700 (PDT) Received: from [192.168.1.183] (c-73-142-227-196.hsd1.ma.comcast.net. [73.142.227.196]) by smtp.googlemail.com with ESMTPSA id g39-v6sm17251148qtb.90.2018.09.20.06.00.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Sep 2018 06:00:57 -0700 (PDT) To: Jesus Camacho Cc: "linux-rdma@vger.kernel.org" From: Hal Rosenstock Subject: [PATCH opensm] Replace hard coded constants with defines for force_link_xxx options Message-ID: <660502ab-74c1-ea18-f0b5-35245bb2f66c@dev.mellanox.co.il> Date: Thu, 20 Sep 2018 09:00:56 -0400 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Language: en-US Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Hal Rosenstock --- include/iba/ib_types.h | 13 +++++++++++++ opensm/osm_link_mgr.c | 6 +++--- opensm/osm_subnet.c | 34 +++++++++++++++++++--------------- 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/include/iba/ib_types.h b/include/iba/ib_types.h index 3fde273..fb1c3f9 100644 --- a/include/iba/ib_types.h +++ b/include/iba/ib_types.h @@ -5180,14 +5180,27 @@ ib_port_info_get_link_speed_active(IN const ib_port_info_t * const p_pi) #define IB_LINK_WIDTH_ACTIVE_8X 4 #define IB_LINK_WIDTH_ACTIVE_12X 8 #define IB_LINK_WIDTH_ACTIVE_2X 16 +#define IB_LINK_WIDTH_1X_2X_4X_8X_OR_12X (IB_LINK_WIDTH_ACTIVE_1X | \ + IB_LINK_WIDTH_ACTIVE_2X | \ + IB_LINK_WIDTH_ACTIVE_4X | \ + IB_LINK_WIDTH_ACTIVE_8X | \ + IB_LINK_WIDTH_ACTIVE_12X) +#define IB_LINK_WIDTH_SET_LWS 255 #define IB_LINK_SPEED_ACTIVE_EXTENDED 0 #define IB_LINK_SPEED_ACTIVE_2_5 1 #define IB_LINK_SPEED_ACTIVE_5 2 #define IB_LINK_SPEED_ACTIVE_10 4 +#define IB_LINK_SPEED_2_5_5_OR_10 (IB_LINK_SPEED_ACTIVE_2_5 | \ + IB_LINK_SPEED_ACTIVE_5 | \ + IB_LINK_SPEED_ACTIVE_10) +#define IB_LINK_SPEED_SET_LSS 15 #define IB_LINK_SPEED_EXT_ACTIVE_NONE 0 #define IB_LINK_SPEED_EXT_ACTIVE_14 1 #define IB_LINK_SPEED_EXT_ACTIVE_25 2 #define IB_LINK_SPEED_EXT_ACTIVE_50 4 +#define IB_LINK_SPEED_EXT_14_25_OR_50 (IB_LINK_SPEED_EXT_ACTIVE_14 | \ + IB_LINK_SPEED_EXT_ACTIVE_25 | \ + IB_LINK_SPEED_EXT_ACTIVE_50) #define IB_LINK_SPEED_EXT_DISABLE 30 #define IB_LINK_SPEED_EXT_SET_LSES 31 diff --git a/opensm/osm_link_mgr.c b/opensm/osm_link_mgr.c index dcdbab8..64ddaf7 100644 --- a/opensm/osm_link_mgr.c +++ b/opensm/osm_link_mgr.c @@ -338,10 +338,10 @@ static int link_mgr_set_physp_pi(osm_sm_t * sm, IN osm_physp_t * p_physp, then determine the neighbor MTU. */ if (sm->p_subn->opt.force_link_width && - (sm->p_subn->opt.force_link_width < 16 || + (sm->p_subn->opt.force_link_width < IB_LINK_WIDTH_ACTIVE_2X || (p_pi->capability_mask2 & IB_PORT_CAP2_IS_LINK_WIDTH_2X_SUPPORTED)) && - (sm->p_subn->opt.force_link_width != 255 || + (sm->p_subn->opt.force_link_width != IB_LINK_WIDTH_SET_LWS || p_pi->link_width_enabled != p_pi->link_width_supported)) { p_pi->link_width_enabled = sm->p_subn->opt.force_link_width; if (p_pi->link_width_enabled != p_old_pi->link_width_enabled) @@ -349,7 +349,7 @@ static int link_mgr_set_physp_pi(osm_sm_t * sm, IN osm_physp_t * p_physp, } if (sm->p_subn->opt.force_link_speed && - (sm->p_subn->opt.force_link_speed != 15 || + (sm->p_subn->opt.force_link_speed != IB_LINK_SPEED_SET_LSS || ib_port_info_get_link_speed_enabled(p_pi) != ib_port_info_get_link_speed_sup(p_pi))) { ib_port_info_set_link_speed_enabled(p_pi, diff --git a/opensm/osm_subnet.c b/opensm/osm_subnet.c index 685d19b..8d0d46f 100644 --- a/opensm/osm_subnet.c +++ b/opensm/osm_subnet.c @@ -1566,9 +1566,9 @@ void osm_subn_set_default_opt(IN osm_subn_opt_t * p_opt) p_opt->lmc = OSM_DEFAULT_LMC; p_opt->lmc_esp0 = FALSE; p_opt->max_op_vls = OSM_DEFAULT_MAX_OP_VLS; - p_opt->force_link_speed = 15; - p_opt->force_link_speed_ext = 31; - p_opt->force_link_width = 255; + p_opt->force_link_speed = IB_LINK_SPEED_SET_LSS; + p_opt->force_link_speed_ext = IB_LINK_SPEED_EXT_SET_LSES; + p_opt->force_link_width = IB_LINK_WIDTH_SET_LWS; p_opt->fdr10 = 1; p_opt->reassign_lids = FALSE; p_opt->ignore_other_sm = FALSE; @@ -2050,27 +2050,31 @@ int osm_subn_verify_config(IN osm_subn_opt_t * p_opts) p_opts->sm_priority = OSM_DEFAULT_SM_PRIORITY; } - if ((15 < p_opts->force_link_speed) || - (p_opts->force_link_speed > 7 && p_opts->force_link_speed < 15)) { + if ((IB_LINK_SPEED_SET_LSS < p_opts->force_link_speed) || + (p_opts->force_link_speed > IB_LINK_SPEED_2_5_5_OR_10 && + p_opts->force_link_speed < IB_LINK_SPEED_SET_LSS)) { log_report(" Invalid Cached Option Value:force_link_speed = %u:" "Using Default:%u\n", p_opts->force_link_speed, - IB_PORT_LINK_SPEED_ENABLED_MASK); - p_opts->force_link_speed = IB_PORT_LINK_SPEED_ENABLED_MASK; + IB_LINK_SPEED_SET_LSS); + p_opts->force_link_speed = IB_LINK_SPEED_SET_LSS; } - if ((31 < p_opts->force_link_speed_ext) || - (p_opts->force_link_speed_ext > 7 && p_opts->force_link_speed_ext < 30)) { + if ((IB_LINK_SPEED_EXT_SET_LSES < p_opts->force_link_speed_ext) || + (p_opts->force_link_speed_ext > IB_LINK_SPEED_EXT_14_25_OR_50 && + p_opts->force_link_speed_ext < IB_LINK_SPEED_EXT_DISABLE)) { log_report(" Invalid Cached Option Value:force_link_speed_ext = %u:" "Using Default:%u\n", p_opts->force_link_speed_ext, - 31); - p_opts->force_link_speed_ext = 31; + IB_LINK_SPEED_EXT_SET_LSES); + p_opts->force_link_speed_ext = IB_LINK_SPEED_EXT_SET_LSES; } - if ((255 < p_opts->force_link_width) || - (p_opts->force_link_width > 31 && p_opts->force_link_width < 255)) { + if ((IB_LINK_WIDTH_SET_LWS < p_opts->force_link_width) || + (p_opts->force_link_width > IB_LINK_WIDTH_1X_2X_4X_8X_OR_12X && + p_opts->force_link_width < IB_LINK_WIDTH_SET_LWS)) { log_report(" Invalid Cached Option Value:force_link_width = %u:" - "Using Default:%u\n", p_opts->force_link_width, 255); - p_opts->force_link_width = 255; + "Using Default:%u\n", p_opts->force_link_width, + IB_LINK_WIDTH_SET_LWS); + p_opts->force_link_width = IB_LINK_WIDTH_SET_LWS; } if (2 < p_opts->fdr10) {