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: 7948 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1369565wrr; Sat, 22 Oct 2022 15:07:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5MC3tk9HoaPXSz3wAFmn7NeSRzpVsmmhHZSiIgd84vyOCkcZjz9hJPIHfV5SUBl6PEHgD8 X-Received: by 2002:a17:907:2bcf:b0:79d:e8e6:d579 with SMTP id gv15-20020a1709072bcf00b0079de8e6d579mr6581931ejc.563.1666476477447; Sat, 22 Oct 2022 15:07:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666476477; cv=none; d=google.com; s=arc-20160816; b=uuWewnetRHivEEJ6Vz1qVccQTsiTIpQDB7qpuUgJ6QRTub4adBAD3nlPatAnUjq2oq SCw8hoAJO28l4wtHuLl7Vbcu+3z4maCgnrRZIMhk8prCW1PVIOlseTIUGnOiErmC50uO 2+fsPM5mQLlLQLtranDgB62ZOv5ZFx5JMGBU1UCc8zlxqlEa4c1BFvwa1mrMXhYd2s2k MSVuau8fsVKKG302ocs54belG5hvvZxq6BZ76Zx0ILFS9HWfWG/TO8vukAh0MyaBHMF/ s0v75/21jKz7PKnTfzuk+b6gWY/s7wSeHB8FRoCQgSf0bcXDwiSseuiRyZuWmL2rxZmp Cj4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=ImtRuZ/f3Zu5wK0ehE7s1RfFwlAhxkaYehC3I0Gy66E=; b=zwdJxV/zGdtbMOBaLOu9JctxpMmMhY481vN7/i2ULhHk2via5/zNPUs34gX2dJ6/T2 fDInsjrhm1eoP2IHS+KSXXeUjZiskjOxiHqXC5ZaZJCQsR/PudU+86UFxorOecF5BZJl 6QraoTP1jZmIS5R5h9vfpimcHrWs2c3nRAQNxzCuL5SwKVkYSPxUQQtOIidhkvSfRPHD de+Ub+a7MrEhmfA0c6xlodP80E69TD/YdR8sD26H4bnRSBdCkAaV9/iutHAG5vN50uLK OEI+wBz7426A5DxEOJj2TK5jWq9xc2yWZXyXYkRx3qpM4bCrUw+b4GY6tvxa886Tka8Y CO8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=SAjJ3YJp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r16-20020a170906705000b007309eb6dcbfsi22132493ejj.372.2022.10.22.15.07.32; Sat, 22 Oct 2022 15:07:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=SAjJ3YJp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229610AbiJVWCb (ORCPT + 99 others); Sat, 22 Oct 2022 18:02:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbiJVWC3 (ORCPT ); Sat, 22 Oct 2022 18:02:29 -0400 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4633C80F76 for ; Sat, 22 Oct 2022 15:02:28 -0700 (PDT) Received: by mail-qv1-xf2b.google.com with SMTP id i12so4265307qvs.2 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=ImtRuZ/f3Zu5wK0ehE7s1RfFwlAhxkaYehC3I0Gy66E=; b=SAjJ3YJpfLJQ6veb4GocfwEtBTyT2UJXr3hlxCtpSa4dm1UNuGvaJkB31NmsSqlkMC 7Ere5tvssJKptBGsQB5w2qXGYLQfE/vMcNp3MvFMttKOEysRYIHUcNY2bzz6++Vw704m U+pfVMQAS31HbFCAXlxxd5NtN0qznKXfCAzaA= 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=ImtRuZ/f3Zu5wK0ehE7s1RfFwlAhxkaYehC3I0Gy66E=; b=eHgQmH9afA0Tr0hrI4CFlbl/Q+L7agClR994pZ02G3YFOfTIJwlCcnAj0ISqkD4Vxu UPzzTJdI8GiyzZQ5K8qZ8W6FwJjI47/FyLeqjbDnJ5wSoZid3nsMVUvOf8F1/qlQHr6P KXJ9rnLo8Dl6kfFftNSaD4rNXHBwvMMunQklK6BDqx+sItY20gDs3NmkWPLyrepwhAIF rzEUFoi1NIXfNSLo6720CjBPO2bC82IGPClAxqyieflgmA47yICnPyPBV6c8XDWYqcr7 0+C3dtER1VmOXK+or0biQqKSj8PHeiclncUn1zRiRTXeu94EvuV/e7z54Ju7z/kMW0KO aQow== X-Gm-Message-State: ACrzQf0XaO6bMkSSH14g8Qj89mIvHmmhZE9ig7vhF4Hj/n5vQaVNs7wP yOxiED2uV1I5c/KgYGRZOvBsJkm9eCpJ3IvTk33Z9NCRkTv8+U7F5N4oN2VByYV0IZTSjocOd1Q t2xVcq9332G+NZw8= 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 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747427238666870600?= X-GMAIL-MSGID: =?utf-8?q?1747427238666870600?= 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;