mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Hsieh <steven.hsieh@broadcom.com>
To: Steven Hsieh <steven.hsieh@broadcom.com>
Cc: Andy Gospodarek <andy@greyhouse.net>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Jay Vosburgh <j.vosburgh@gmail.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Veaceslav Falico <vfalico@gmail.com>,
	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	[thread overview]
Message-ID: <20221022220158.74933-1-steven.hsieh@broadcom.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 6796 bytes --]

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 <steven.hsieh@broadcom.com>

---

 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;
-- 
2.34.1


-- 
This electronic communication and the information and any files transmitted 
with it, or attached to it, are confidential and are intended solely for 
the use of the individual or entity to whom it is addressed and may contain 
information that is confidential, legally privileged, protected by privacy 
laws, or otherwise restricted from disclosure to anyone else. If you are 
not the intended recipient or the person responsible for delivering the 
e-mail to the intended recipient, you are hereby notified that any use, 
copying, distributing, dissemination, forwarding, printing, or copying of 
this e-mail is strictly prohibited. If you received this e-mail in error, 
please return the e-mail to the sender, delete it from your computer, and 
destroy any printed copy of it.

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]

             reply	other threads:[~2022-10-22 22:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-22 22:01 Steven Hsieh [this message]
2022-10-24 16:25 ` Jay Vosburgh
2022-10-31 17:06   ` Steven Hsieh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221022220158.74933-1-steven.hsieh@broadcom.com \
    --to=steven.hsieh@broadcom.com \
    --cc=andy@greyhouse.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=j.vosburgh@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=vfalico@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®