netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] bonding: exposure option coupled_control via sysfs
@ 2025-07-07  9:15 Wanchuan Li
  2025-07-07  9:15 ` [PATCH 2/2] bonding: add module param coupled_control Wanchuan Li
  2025-07-07 15:11 ` [PATCH 1/2] bonding: exposure option coupled_control via sysfs Jay Vosburgh
  0 siblings, 2 replies; 3+ messages in thread
From: Wanchuan Li @ 2025-07-07  9:15 UTC (permalink / raw)
  To: jv
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel, Wanchuan Li

Allow get/set of bonding parameter coupled_control
via sysfs.

Signed-off-by: Wanchuan Li <liwanchuan@xiaomi.com>
---
 drivers/net/bonding/bond_sysfs.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 1e13bb170515..5a8450b2269d 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -479,6 +479,18 @@ static ssize_t bonding_show_carrier(struct device *d,
 static DEVICE_ATTR(use_carrier, 0644,
 		   bonding_show_carrier, bonding_sysfs_store_option);
 
+/* Show the coupled_control flag. */
+static ssize_t bonding_show_coupled_control(struct device *d,
+				    struct device_attribute *attr,
+				    char *buf)
+{
+	struct bonding *bond = to_bond(d);
+
+	return sysfs_emit(buf, "%d\n", bond->params.coupled_control);
+}
+static DEVICE_ATTR(coupled_control, 0644,
+		   bonding_show_coupled_control, bonding_sysfs_store_option);
+
 
 /* Show currently active_slave. */
 static ssize_t bonding_show_active_slave(struct device *d,
@@ -791,6 +803,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_coupled_control.attr,
 	NULL,
 };
 
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] bonding: add module param coupled_control
  2025-07-07  9:15 [PATCH 1/2] bonding: exposure option coupled_control via sysfs Wanchuan Li
@ 2025-07-07  9:15 ` Wanchuan Li
  2025-07-07 15:11 ` [PATCH 1/2] bonding: exposure option coupled_control via sysfs Jay Vosburgh
  1 sibling, 0 replies; 3+ messages in thread
From: Wanchuan Li @ 2025-07-07  9:15 UTC (permalink / raw)
  To: jv
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel, Wanchuan Li

Allows configuration parameters coupled_control in
the module during initialization.

Signed-off-by: Wanchuan Li <liwanchuan@xiaomi.com>
---
 drivers/net/bonding/bond_main.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index c4d53e8e7c15..c86c72bb432c 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -123,6 +123,7 @@ static struct bond_params bonding_defaults;
 static int resend_igmp = BOND_DEFAULT_RESEND_IGMP;
 static int packets_per_slave = 1;
 static int lp_interval = BOND_ALB_DEFAULT_LP_INTERVAL;
+static int coupled_control = 1;
 
 module_param(max_bonds, int, 0);
 MODULE_PARM_DESC(max_bonds, "Max number of bonded devices");
@@ -144,6 +145,11 @@ MODULE_PARM_DESC(downdelay, "Delay before considering link down, "
 module_param(use_carrier, int, 0);
 MODULE_PARM_DESC(use_carrier, "Use netif_carrier_ok (vs MII ioctls) in miimon; "
 			      "0 for off, 1 for on (default)");
+
+module_param(coupled_control, int, 0);
+MODULE_PARM_DESC(coupled_control, "Coupled and Independent control state machine; "
+			      "0 for off, 1 for on (default)");
+
 module_param(mode, charp, 0);
 MODULE_PARM_DESC(mode, "Mode of operation; 0 for balance-rr, "
 		       "1 for active-backup, 2 for balance-xor, "
@@ -6195,6 +6201,12 @@ static int __init bond_check_params(struct bond_params *params)
 		use_carrier = 1;
 	}
 
+	if ((coupled_control != 0) && (coupled_control != 1)) {
+		pr_warn("Warning: coupled_control module parameter (%d), not of valid value (0/1), so it was set to 1\n",
+			coupled_control);
+		coupled_control = 1;
+	}
+
 	if (num_peer_notif < 0 || num_peer_notif > 255) {
 		pr_warn("Warning: num_grat_arp/num_unsol_na (%d) not in range 0-255 so it was reset to 1\n",
 			num_peer_notif);
@@ -6455,7 +6467,7 @@ static int __init bond_check_params(struct bond_params *params)
 	params->ad_actor_sys_prio = ad_actor_sys_prio;
 	eth_zero_addr(params->ad_actor_system);
 	params->ad_user_port_key = ad_user_port_key;
-	params->coupled_control = 1;
+	params->coupled_control = coupled_control;
 	if (packets_per_slave > 0) {
 		params->reciprocal_packets_per_slave =
 			reciprocal_value(packets_per_slave);
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] bonding: exposure option coupled_control via sysfs
  2025-07-07  9:15 [PATCH 1/2] bonding: exposure option coupled_control via sysfs Wanchuan Li
  2025-07-07  9:15 ` [PATCH 2/2] bonding: add module param coupled_control Wanchuan Li
@ 2025-07-07 15:11 ` Jay Vosburgh
  1 sibling, 0 replies; 3+ messages in thread
From: Jay Vosburgh @ 2025-07-07 15:11 UTC (permalink / raw)
  To: Wanchuan Li
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel, Wanchuan Li

Wanchuan Li <gnblao@gmail.com> wrote:

>Allow get/set of bonding parameter coupled_control
>via sysfs.
>
>Signed-off-by: Wanchuan Li <liwanchuan@xiaomi.com>

	No to both of these patches.

	For patch 1, the bonding sysfs API is deprecated, and should not
be extended to add new functionality.  All bonding functionality is
available via netlink and iproute2 (/sbin/ip).

	For patch 2, new module parameters are disallowed in general.

	-J

>---
> drivers/net/bonding/bond_sysfs.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
>diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
>index 1e13bb170515..5a8450b2269d 100644
>--- a/drivers/net/bonding/bond_sysfs.c
>+++ b/drivers/net/bonding/bond_sysfs.c
>@@ -479,6 +479,18 @@ static ssize_t bonding_show_carrier(struct device *d,
> static DEVICE_ATTR(use_carrier, 0644,
> 		   bonding_show_carrier, bonding_sysfs_store_option);
> 
>+/* Show the coupled_control flag. */
>+static ssize_t bonding_show_coupled_control(struct device *d,
>+				    struct device_attribute *attr,
>+				    char *buf)
>+{
>+	struct bonding *bond = to_bond(d);
>+
>+	return sysfs_emit(buf, "%d\n", bond->params.coupled_control);
>+}
>+static DEVICE_ATTR(coupled_control, 0644,
>+		   bonding_show_coupled_control, bonding_sysfs_store_option);
>+
> 
> /* Show currently active_slave. */
> static ssize_t bonding_show_active_slave(struct device *d,
>@@ -791,6 +803,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_coupled_control.attr,
> 	NULL,
> };
> 
>-- 
>2.49.0
>

---
	-Jay Vosburgh, jv@jvosburgh.net

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-07-07 15:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-07  9:15 [PATCH 1/2] bonding: exposure option coupled_control via sysfs Wanchuan Li
2025-07-07  9:15 ` [PATCH 2/2] bonding: add module param coupled_control Wanchuan Li
2025-07-07 15:11 ` [PATCH 1/2] bonding: exposure option coupled_control via sysfs Jay Vosburgh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).