From patchwork Sat Oct 22 22:01:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Steven Hsieh X-Patchwork-Id: 13016071 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12C08C433FE for ; Sat, 22 Oct 2022 22:02:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229744AbiJVWCb (ORCPT ); Sat, 22 Oct 2022 18:02:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229610AbiJVWC3 (ORCPT ); Sat, 22 Oct 2022 18:02:29 -0400 Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8810D80F79 for ; Sat, 22 Oct 2022 15:02:28 -0700 (PDT) Received: by mail-qv1-xf30.google.com with SMTP id u7so4225345qvn.13 for ; Sat, 22 Oct 2022 15:02:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=2nyTtb16GO7O1EXRrlxGdLq/LW/yRO//Vbu/6WFaHRA=; b=MzLIU8UQAGJDuOgmw5YOkEuREtpYis5sqihw8Pw0jDsOOm3m+80fW29JMMrkMeqe9i jF7A4fBXNBnlQ57bP0mxzXDbt1HMml7FAsgHWi+Sv/yIN7MrKwEQFB/pFxZbDvVSj9ZZ U4QTT+ap7mY8ME1fboyvG6Kv8eE62WXJefoQQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=2nyTtb16GO7O1EXRrlxGdLq/LW/yRO//Vbu/6WFaHRA=; b=q+BGAqeVLkjXCRvQRqVUNWRxlq4b9IpiMClJC7VUEB4Ms/WHWSaMPbMSx1LU+vl+ma K+9ndem3Zg8LvOhufwrU3CF+SANm5dUyVd7TOGEuDOwA7v82/QLpWHvLWKOHmoe85/iX g8Iqg4mkgbvknRM3GxqYShNfIX0V0MjRXyk4oK0nyUpqYYr0EAlbOsnofYLd2EDpedkD R1SWKw7O/lqjsKuUl19ClZLHSnbHPCUuAQZzKxijex/wPLcUe0YIaslxksw7c0pRQzhI 0qtVtTUM592bT1f5Cih1HuJsFDvnYDbRVU3ElnDI7em7428Y/9eAkDAXLJu6JMFvygTo xuqQ== X-Gm-Message-State: ACrzQf0yZLv5EDrlK+dwdMruXuyDr5+41g1H1YUFBgt9r+1ikvy5Eo2y yl0wg7akgsV8YLpjYbwHVNmYmIwmQf7sQ+FzXt0Tw8a/KPTDd7AxmcTQjoI1o68z6Zbfmq3JAfI 9geG/rTw= X-Google-Smtp-Source: AMsMyM6pD7/1CfdXqj/jNvsCEXbeAqhoVu9Uyd4d36sH4okR02sUiuyQQnNgAkymlRretOQELMYE7w== X-Received: by 2002:a05:6214:f04:b0:4b1:cb3b:79bd with SMTP id gw4-20020a0562140f0400b004b1cb3b79bdmr22163338qvb.22.1666476147196; Sat, 22 Oct 2022 15:02:27 -0700 (PDT) Received: from linuxpc-ThinkServer-TS140.dhcp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id i8-20020a05620a074800b006cea2984c9bsm11739295qki.100.2022.10.22.15.02.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Oct 2022 15:02:25 -0700 (PDT) From: Steven Hsieh To: Steven Hsieh Cc: Andy Gospodarek , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jay Vosburgh , Paolo Abeni , Veaceslav Falico , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next] bonding: 3ad: bonding of links with different data rate Date: Sat, 22 Oct 2022 15:01:58 -0700 Message-Id: <20221022220158.74933-1-steven.hsieh@broadcom.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Current Linux Bonding driver supports IEEE802.3ad-2000. Operation across multiple data rates— All links in a Link Aggregation Group operate at the same data rate. In IEEE802.1AX-2014 Aggregation of links of different data rates is not prohibited nor required by this standard. This patch provides configuration option to allow aggregation of links with different speed. Enhancement is disabled by default and can be enabled thru echo 1 > /sys/class/net/bond*/bonding/async_linkspeed Signed-off-by: Steven Hsieh --- drivers/net/bonding/bond_3ad.c | 12 +++++++++++- drivers/net/bonding/bond_options.c | 26 ++++++++++++++++++++++++++ drivers/net/bonding/bond_sysfs.c | 15 +++++++++++++++ include/net/bond_options.h | 1 + include/net/bonding.h | 1 + 5 files changed, 54 insertions(+), 1 deletion(-) diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index e58a1e0cadd2..f5689dae88c3 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c @@ -385,6 +385,13 @@ static void __ad_actor_update_port(struct port *port) port->actor_system_priority = BOND_AD_INFO(bond).system.sys_priority; } +static inline u32 __get_agg_async_linkspeed(struct port *port) +{ + const struct bonding *bond = bond_get_bond_by_slave(port->slave); + + return (bond) ? bond->params.async_linkspeed : 0; +} + /* Conversions */ /** @@ -2476,7 +2483,10 @@ static void ad_update_actor_keys(struct port *port, bool reset) speed = __get_link_speed(port); ospeed = (old_oper_key & AD_SPEED_KEY_MASKS) >> 1; duplex = __get_duplex(port); - port->actor_admin_port_key |= (speed << 1) | duplex; + if (__get_agg_async_linkspeed(port)) + port->actor_admin_port_key |= duplex; + else + port->actor_admin_port_key |= (speed << 1) | duplex; } port->actor_oper_port_key = port->actor_admin_port_key; diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index 3498db1c1b3c..cd871075b85c 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c @@ -84,6 +84,8 @@ static int bond_option_ad_user_port_key_set(struct bonding *bond, const struct bond_opt_value *newval); static int bond_option_missed_max_set(struct bonding *bond, const struct bond_opt_value *newval); +static int bond_option_async_linkspeed_set(struct bonding *bond, + const struct bond_opt_value *newval); static const struct bond_opt_value bond_mode_tbl[] = { @@ -226,6 +228,12 @@ static const struct bond_opt_value bond_missed_max_tbl[] = { { NULL, -1, 0}, }; +static const struct bond_opt_value bond_async_linkspeed_tbl[] = { + { "off", 0, BOND_VALFLAG_DEFAULT}, + { "on", 1, 0}, + { NULL, -1, 0}, +}; + static const struct bond_option bond_opts[BOND_OPT_LAST] = { [BOND_OPT_MODE] = { .id = BOND_OPT_MODE, @@ -360,6 +368,14 @@ static const struct bond_option bond_opts[BOND_OPT_LAST] = { .values = bond_num_peer_notif_tbl, .set = bond_option_num_peer_notif_set }, + [BOND_OPT_ASYNC_LINKSPEED] = { + .id = BOND_OPT_ASYNC_LINKSPEED, + .name = "async_linkspeed", + .desc = "Enable aggregation of links of different data rates", + .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)), + .values = bond_async_linkspeed_tbl, + .set = bond_option_async_linkspeed_set + }, [BOND_OPT_MIIMON] = { .id = BOND_OPT_MIIMON, .name = "miimon", @@ -1702,3 +1718,13 @@ static int bond_option_ad_user_port_key_set(struct bonding *bond, bond->params.ad_user_port_key = newval->value; return 0; } + +static int bond_option_async_linkspeed_set(struct bonding *bond, + const struct bond_opt_value *newval) +{ + netdev_info(bond->dev, "Setting async_linkspeed to %s (%llu)\n", + newval->string, newval->value); + bond->params.async_linkspeed = newval->value; + + return 0; +} diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 8996bd0a194a..6a0b4e1098af 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c @@ -753,6 +753,20 @@ static ssize_t bonding_show_ad_user_port_key(struct device *d, static DEVICE_ATTR(ad_user_port_key, 0644, bonding_show_ad_user_port_key, bonding_sysfs_store_option); +static ssize_t bonding_show_async_linkspeed(struct device *d, + struct device_attribute *attr, + char *buf) +{ + struct bonding *bond = to_bond(d); + const struct bond_opt_value *val; + + val = bond_opt_get_val(BOND_OPT_ASYNC_LINKSPEED, bond->params.async_linkspeed); + + return sprintf(buf, "%s %d\n", val->string, bond->params.async_linkspeed); +} +static DEVICE_ATTR(async_linkspeed, (00400 | 00040 | 00004) | 00200, /*S_IRUGO | S_IWUSR,*/ + bonding_show_async_linkspeed, bonding_sysfs_store_option); + static struct attribute *per_bond_attrs[] = { &dev_attr_slaves.attr, &dev_attr_mode.attr, @@ -792,6 +806,7 @@ static struct attribute *per_bond_attrs[] = { &dev_attr_ad_actor_system.attr, &dev_attr_ad_user_port_key.attr, &dev_attr_arp_missed_max.attr, + &dev_attr_async_linkspeed.attr, NULL, }; diff --git a/include/net/bond_options.h b/include/net/bond_options.h index 69292ecc0325..5b33f8b3e1c7 100644 --- a/include/net/bond_options.h +++ b/include/net/bond_options.h @@ -76,6 +76,7 @@ enum { BOND_OPT_MISSED_MAX, BOND_OPT_NS_TARGETS, BOND_OPT_PRIO, + BOND_OPT_ASYNC_LINKSPEED, BOND_OPT_LAST }; diff --git a/include/net/bonding.h b/include/net/bonding.h index e999f851738b..5d83daab0669 100644 --- a/include/net/bonding.h +++ b/include/net/bonding.h @@ -146,6 +146,7 @@ struct bond_params { int lp_interval; int packets_per_slave; int tlb_dynamic_lb; + int async_linkspeed; struct reciprocal_value reciprocal_packets_per_slave; u16 ad_actor_sys_prio; u16 ad_user_port_key;