All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bonding: Make alb learning packet interval configurable
@ 2013-09-10 14:14 Neil Horman
  2013-09-10 18:11 ` Veaceslav Falico
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Neil Horman @ 2013-09-10 14:14 UTC (permalink / raw)
  To: netdev
  Cc: Neil Horman, Neil Horman, Jay Vosburgh, Andy Gospodarek, David S. Miller

From: Neil Horman <nhorman@redhat.com>

running bonding in ALB mode requires that learning packets be sent periodically,
so that the switch knows where to send responding traffic.  However, depending
on switch configuration, there may not be any need to send traffic at the
default rate of 3 packets per second, which represents little more than wasted
data.  Allow the ALB learning packet interval to be made configurable via sysfs

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: "David S. Miller" <davem@davemloft.net>
---
 drivers/net/bonding/bond_alb.c   |  2 +-
 drivers/net/bonding/bond_alb.h   |  8 ++++----
 drivers/net/bonding/bond_main.c  |  1 +
 drivers/net/bonding/bond_sysfs.c | 39 +++++++++++++++++++++++++++++++++++++++
 drivers/net/bonding/bonding.h    |  1 +
 5 files changed, 46 insertions(+), 5 deletions(-)

diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 91f179d..f428ef57 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -1472,7 +1472,7 @@ void bond_alb_monitor(struct work_struct *work)
 	bond_info->lp_counter++;
 
 	/* send learning packets */
-	if (bond_info->lp_counter >= BOND_ALB_LP_TICKS) {
+	if (bond_info->lp_counter >= BOND_ALB_LP_TICKS(bond)) {
 		/* change of curr_active_slave involves swapping of mac addresses.
 		 * in order to avoid this swapping from happening while
 		 * sending the learning packets, the curr_slave_lock must be held for
diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h
index 28d8e4c..e78fd9b 100644
--- a/drivers/net/bonding/bond_alb.h
+++ b/drivers/net/bonding/bond_alb.h
@@ -36,14 +36,14 @@ struct slave;
 					 * Used for division - never set
 					 * to zero !!!
 					 */
-#define BOND_ALB_LP_INTERVAL	    1	/* In seconds, periodic send of
-					 * learning packets to the switch
-					 */
+#define BOND_ALB_LP_INTERVAL(bond) (bond->params.lp_interval)	/* In seconds, periodic send of
+								 * learning packets to the switch
+								 */
 
 #define BOND_TLB_REBALANCE_TICKS (BOND_TLB_REBALANCE_INTERVAL \
 				  * ALB_TIMER_TICKS_PER_SEC)
 
-#define BOND_ALB_LP_TICKS (BOND_ALB_LP_INTERVAL \
+#define BOND_ALB_LP_TICKS(bond) (BOND_ALB_LP_INTERVAL(bond) \
 			   * ALB_TIMER_TICKS_PER_SEC)
 
 #define TLB_HASH_TABLE_SIZE 256	/* The size of the clients hash table.
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 39e5b1c..b8c9ec3 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4416,6 +4416,7 @@ static int bond_check_params(struct bond_params *params)
 	params->all_slaves_active = all_slaves_active;
 	params->resend_igmp = resend_igmp;
 	params->min_links = min_links;
+	params->lp_interval = 1;
 
 	if (primary) {
 		strncpy(params->primary, primary, IFNAMSIZ);
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index ce46776..4532259 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -1680,6 +1680,44 @@ out:
 static DEVICE_ATTR(resend_igmp, S_IRUGO | S_IWUSR,
 		   bonding_show_resend_igmp, bonding_store_resend_igmp);
 
+
+static ssize_t bonding_show_lp_interval(struct device *d,
+					struct device_attribute *attr,
+					char *buf)
+{
+	struct bonding *bond = to_bond(d);
+	return sprintf(buf, "%d\n", bond->params.lp_interval);
+}
+
+static ssize_t bonding_store_lp_interval(struct device *d,
+					 struct device_attribute *attr,
+					 const char *buf, size_t count)
+{
+	struct bonding *bond = to_bond(d);
+	int new_value, ret = count;
+
+	if (sscanf(buf, "%d", &new_value) != 1) {
+		pr_err("%s: no lp interval value specified.\n",
+			bond->dev->name);
+		ret = -EINVAL;
+		goto out;
+	}
+
+	if (new_value <= 0) {
+		pr_err ("%s: lp_interval must be between 1 and %d\n",
+			bond->dev->name, INT_MAX);
+		ret = -EINVAL;
+		goto out;
+	}
+
+	bond->params.lp_interval = new_value;
+out:
+	return ret;
+}
+
+static DEVICE_ATTR(lp_interval, S_IRUGO | S_IWUSR,
+		   bonding_show_lp_interval, bonding_store_lp_interval);
+
 static struct attribute *per_bond_attrs[] = {
 	&dev_attr_slaves.attr,
 	&dev_attr_mode.attr,
@@ -1710,6 +1748,7 @@ static struct attribute *per_bond_attrs[] = {
 	&dev_attr_all_slaves_active.attr,
 	&dev_attr_resend_igmp.attr,
 	&dev_attr_min_links.attr,
+	&dev_attr_lp_interval.attr,
 	NULL,
 };
 
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index f7ab161..4bd9d5b 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -176,6 +176,7 @@ struct bond_params {
 	int tx_queues;
 	int all_slaves_active;
 	int resend_igmp;
+	int lp_interval;
 };
 
 struct bond_parm_tbl {
-- 
1.8.3.1

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

* Re: bonding: Make alb learning packet interval configurable
  2013-09-10 14:14 [PATCH] bonding: Make alb learning packet interval configurable Neil Horman
@ 2013-09-10 18:11 ` Veaceslav Falico
  2013-09-10 19:04   ` Neil Horman
  2013-09-10 20:39 ` [PATCH v2] " Neil Horman
  2013-09-13 15:05 ` [PATCH v3] " Neil Horman
  2 siblings, 1 reply; 11+ messages in thread
From: Veaceslav Falico @ 2013-09-10 18:11 UTC (permalink / raw)
  To: Neil Horman
  Cc: netdev, Neil Horman, Jay Vosburgh, Andy Gospodarek, David S. Miller

On Tue, Sep 10, 2013 at 10:14:50AM -0400, Neil Horman wrote:
>From: Neil Horman <nhorman@redhat.com>
>
>running bonding in ALB mode requires that learning packets be sent periodically,
>so that the switch knows where to send responding traffic.  However, depending
>on switch configuration, there may not be any need to send traffic at the
>default rate of 3 packets per second, which represents little more than wasted
>data.  Allow the ALB learning packet interval to be made configurable via sysfs
>
>Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
>CC: Jay Vosburgh <fubar@us.ibm.com>
>CC: Andy Gospodarek <andy@greyhouse.net>
>CC: "David S. Miller" <davem@davemloft.net>
>
>---
>drivers/net/bonding/bond_alb.c   |  2 +-
> drivers/net/bonding/bond_alb.h   |  8 ++++----
> drivers/net/bonding/bond_main.c  |  1 +
> drivers/net/bonding/bond_sysfs.c | 39 +++++++++++++++++++++++++++++++++++++++
> drivers/net/bonding/bonding.h    |  1 +
> 5 files changed, 46 insertions(+), 5 deletions(-)

Maybe add some description about it to Documentation/networking/bonding.txt?

Otherwise seems good.

>
>diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
>index 91f179d..f428ef57 100644
>--- a/drivers/net/bonding/bond_alb.c
>+++ b/drivers/net/bonding/bond_alb.c
>@@ -1472,7 +1472,7 @@ void bond_alb_monitor(struct work_struct *work)
> 	bond_info->lp_counter++;
>
> 	/* send learning packets */
>-	if (bond_info->lp_counter >= BOND_ALB_LP_TICKS) {
>+	if (bond_info->lp_counter >= BOND_ALB_LP_TICKS(bond)) {
> 		/* change of curr_active_slave involves swapping of mac addresses.
> 		 * in order to avoid this swapping from happening while
> 		 * sending the learning packets, the curr_slave_lock must be held for
>diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h
>index 28d8e4c..e78fd9b 100644
>--- a/drivers/net/bonding/bond_alb.h
>+++ b/drivers/net/bonding/bond_alb.h
>@@ -36,14 +36,14 @@ struct slave;
> 					 * Used for division - never set
> 					 * to zero !!!
> 					 */
>-#define BOND_ALB_LP_INTERVAL	    1	/* In seconds, periodic send of
>-					 * learning packets to the switch
>-					 */
>+#define BOND_ALB_LP_INTERVAL(bond) (bond->params.lp_interval)	/* In seconds, periodic send of
>+								 * learning packets to the switch
>+								 */
>
> #define BOND_TLB_REBALANCE_TICKS (BOND_TLB_REBALANCE_INTERVAL \
> 				  * ALB_TIMER_TICKS_PER_SEC)
>
>-#define BOND_ALB_LP_TICKS (BOND_ALB_LP_INTERVAL \
>+#define BOND_ALB_LP_TICKS(bond) (BOND_ALB_LP_INTERVAL(bond) \
> 			   * ALB_TIMER_TICKS_PER_SEC)
>
> #define TLB_HASH_TABLE_SIZE 256	/* The size of the clients hash table.
>diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>index 39e5b1c..b8c9ec3 100644
>--- a/drivers/net/bonding/bond_main.c
>+++ b/drivers/net/bonding/bond_main.c
>@@ -4416,6 +4416,7 @@ static int bond_check_params(struct bond_params *params)
> 	params->all_slaves_active = all_slaves_active;
> 	params->resend_igmp = resend_igmp;
> 	params->min_links = min_links;
>+	params->lp_interval = 1;
>
> 	if (primary) {
> 		strncpy(params->primary, primary, IFNAMSIZ);
>diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
>index ce46776..4532259 100644
>--- a/drivers/net/bonding/bond_sysfs.c
>+++ b/drivers/net/bonding/bond_sysfs.c
>@@ -1680,6 +1680,44 @@ out:
> static DEVICE_ATTR(resend_igmp, S_IRUGO | S_IWUSR,
> 		   bonding_show_resend_igmp, bonding_store_resend_igmp);
>
>+
>+static ssize_t bonding_show_lp_interval(struct device *d,
>+					struct device_attribute *attr,
>+					char *buf)
>+{
>+	struct bonding *bond = to_bond(d);
>+	return sprintf(buf, "%d\n", bond->params.lp_interval);
>+}
>+
>+static ssize_t bonding_store_lp_interval(struct device *d,
>+					 struct device_attribute *attr,
>+					 const char *buf, size_t count)
>+{
>+	struct bonding *bond = to_bond(d);
>+	int new_value, ret = count;
>+
>+	if (sscanf(buf, "%d", &new_value) != 1) {
>+		pr_err("%s: no lp interval value specified.\n",
>+			bond->dev->name);
>+		ret = -EINVAL;
>+		goto out;
>+	}
>+
>+	if (new_value <= 0) {
>+		pr_err ("%s: lp_interval must be between 1 and %d\n",
>+			bond->dev->name, INT_MAX);
>+		ret = -EINVAL;
>+		goto out;
>+	}
>+
>+	bond->params.lp_interval = new_value;
>+out:
>+	return ret;
>+}
>+
>+static DEVICE_ATTR(lp_interval, S_IRUGO | S_IWUSR,
>+		   bonding_show_lp_interval, bonding_store_lp_interval);
>+
> static struct attribute *per_bond_attrs[] = {
> 	&dev_attr_slaves.attr,
> 	&dev_attr_mode.attr,
>@@ -1710,6 +1748,7 @@ static struct attribute *per_bond_attrs[] = {
> 	&dev_attr_all_slaves_active.attr,
> 	&dev_attr_resend_igmp.attr,
> 	&dev_attr_min_links.attr,
>+	&dev_attr_lp_interval.attr,
> 	NULL,
> };
>
>diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
>index f7ab161..4bd9d5b 100644
>--- a/drivers/net/bonding/bonding.h
>+++ b/drivers/net/bonding/bonding.h
>@@ -176,6 +176,7 @@ struct bond_params {
> 	int tx_queues;
> 	int all_slaves_active;
> 	int resend_igmp;
>+	int lp_interval;
> };
>
> struct bond_parm_tbl {

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

* Re: bonding: Make alb learning packet interval configurable
  2013-09-10 18:11 ` Veaceslav Falico
@ 2013-09-10 19:04   ` Neil Horman
  0 siblings, 0 replies; 11+ messages in thread
From: Neil Horman @ 2013-09-10 19:04 UTC (permalink / raw)
  To: Veaceslav Falico
  Cc: netdev, Neil Horman, Jay Vosburgh, Andy Gospodarek, David S. Miller

On Tue, Sep 10, 2013 at 08:11:49PM +0200, Veaceslav Falico wrote:
> On Tue, Sep 10, 2013 at 10:14:50AM -0400, Neil Horman wrote:
> >From: Neil Horman <nhorman@redhat.com>
> >
> >running bonding in ALB mode requires that learning packets be sent periodically,
> >so that the switch knows where to send responding traffic.  However, depending
> >on switch configuration, there may not be any need to send traffic at the
> >default rate of 3 packets per second, which represents little more than wasted
> >data.  Allow the ALB learning packet interval to be made configurable via sysfs
> >
> >Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
> >CC: Jay Vosburgh <fubar@us.ibm.com>
> >CC: Andy Gospodarek <andy@greyhouse.net>
> >CC: "David S. Miller" <davem@davemloft.net>
> >
> >---
> >drivers/net/bonding/bond_alb.c   |  2 +-
> >drivers/net/bonding/bond_alb.h   |  8 ++++----
> >drivers/net/bonding/bond_main.c  |  1 +
> >drivers/net/bonding/bond_sysfs.c | 39 +++++++++++++++++++++++++++++++++++++++
> >drivers/net/bonding/bonding.h    |  1 +
> >5 files changed, 46 insertions(+), 5 deletions(-)
> 
> Maybe add some description about it to Documentation/networking/bonding.txt?
> 
Crap, yes, you're right of course.  Thanks.  I'll respin with that added.

Thanks
Neil

> Otherwise seems good.
> 
> >
> >diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
> >index 91f179d..f428ef57 100644
> >--- a/drivers/net/bonding/bond_alb.c
> >+++ b/drivers/net/bonding/bond_alb.c
> >@@ -1472,7 +1472,7 @@ void bond_alb_monitor(struct work_struct *work)
> >	bond_info->lp_counter++;
> >
> >	/* send learning packets */
> >-	if (bond_info->lp_counter >= BOND_ALB_LP_TICKS) {
> >+	if (bond_info->lp_counter >= BOND_ALB_LP_TICKS(bond)) {
> >		/* change of curr_active_slave involves swapping of mac addresses.
> >		 * in order to avoid this swapping from happening while
> >		 * sending the learning packets, the curr_slave_lock must be held for
> >diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h
> >index 28d8e4c..e78fd9b 100644
> >--- a/drivers/net/bonding/bond_alb.h
> >+++ b/drivers/net/bonding/bond_alb.h
> >@@ -36,14 +36,14 @@ struct slave;
> >					 * Used for division - never set
> >					 * to zero !!!
> >					 */
> >-#define BOND_ALB_LP_INTERVAL	    1	/* In seconds, periodic send of
> >-					 * learning packets to the switch
> >-					 */
> >+#define BOND_ALB_LP_INTERVAL(bond) (bond->params.lp_interval)	/* In seconds, periodic send of
> >+								 * learning packets to the switch
> >+								 */
> >
> >#define BOND_TLB_REBALANCE_TICKS (BOND_TLB_REBALANCE_INTERVAL \
> >				  * ALB_TIMER_TICKS_PER_SEC)
> >
> >-#define BOND_ALB_LP_TICKS (BOND_ALB_LP_INTERVAL \
> >+#define BOND_ALB_LP_TICKS(bond) (BOND_ALB_LP_INTERVAL(bond) \
> >			   * ALB_TIMER_TICKS_PER_SEC)
> >
> >#define TLB_HASH_TABLE_SIZE 256	/* The size of the clients hash table.
> >diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> >index 39e5b1c..b8c9ec3 100644
> >--- a/drivers/net/bonding/bond_main.c
> >+++ b/drivers/net/bonding/bond_main.c
> >@@ -4416,6 +4416,7 @@ static int bond_check_params(struct bond_params *params)
> >	params->all_slaves_active = all_slaves_active;
> >	params->resend_igmp = resend_igmp;
> >	params->min_links = min_links;
> >+	params->lp_interval = 1;
> >
> >	if (primary) {
> >		strncpy(params->primary, primary, IFNAMSIZ);
> >diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
> >index ce46776..4532259 100644
> >--- a/drivers/net/bonding/bond_sysfs.c
> >+++ b/drivers/net/bonding/bond_sysfs.c
> >@@ -1680,6 +1680,44 @@ out:
> >static DEVICE_ATTR(resend_igmp, S_IRUGO | S_IWUSR,
> >		   bonding_show_resend_igmp, bonding_store_resend_igmp);
> >
> >+
> >+static ssize_t bonding_show_lp_interval(struct device *d,
> >+					struct device_attribute *attr,
> >+					char *buf)
> >+{
> >+	struct bonding *bond = to_bond(d);
> >+	return sprintf(buf, "%d\n", bond->params.lp_interval);
> >+}
> >+
> >+static ssize_t bonding_store_lp_interval(struct device *d,
> >+					 struct device_attribute *attr,
> >+					 const char *buf, size_t count)
> >+{
> >+	struct bonding *bond = to_bond(d);
> >+	int new_value, ret = count;
> >+
> >+	if (sscanf(buf, "%d", &new_value) != 1) {
> >+		pr_err("%s: no lp interval value specified.\n",
> >+			bond->dev->name);
> >+		ret = -EINVAL;
> >+		goto out;
> >+	}
> >+
> >+	if (new_value <= 0) {
> >+		pr_err ("%s: lp_interval must be between 1 and %d\n",
> >+			bond->dev->name, INT_MAX);
> >+		ret = -EINVAL;
> >+		goto out;
> >+	}
> >+
> >+	bond->params.lp_interval = new_value;
> >+out:
> >+	return ret;
> >+}
> >+
> >+static DEVICE_ATTR(lp_interval, S_IRUGO | S_IWUSR,
> >+		   bonding_show_lp_interval, bonding_store_lp_interval);
> >+
> >static struct attribute *per_bond_attrs[] = {
> >	&dev_attr_slaves.attr,
> >	&dev_attr_mode.attr,
> >@@ -1710,6 +1748,7 @@ static struct attribute *per_bond_attrs[] = {
> >	&dev_attr_all_slaves_active.attr,
> >	&dev_attr_resend_igmp.attr,
> >	&dev_attr_min_links.attr,
> >+	&dev_attr_lp_interval.attr,
> >	NULL,
> >};
> >
> >diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
> >index f7ab161..4bd9d5b 100644
> >--- a/drivers/net/bonding/bonding.h
> >+++ b/drivers/net/bonding/bonding.h
> >@@ -176,6 +176,7 @@ struct bond_params {
> >	int tx_queues;
> >	int all_slaves_active;
> >	int resend_igmp;
> >+	int lp_interval;
> >};
> >
> >struct bond_parm_tbl {
> 

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

* [PATCH v2] bonding: Make alb learning packet interval configurable
  2013-09-10 14:14 [PATCH] bonding: Make alb learning packet interval configurable Neil Horman
  2013-09-10 18:11 ` Veaceslav Falico
@ 2013-09-10 20:39 ` Neil Horman
  2013-09-10 20:55   ` Veaceslav Falico
  2013-09-12 20:49   ` David Miller
  2013-09-13 15:05 ` [PATCH v3] " Neil Horman
  2 siblings, 2 replies; 11+ messages in thread
From: Neil Horman @ 2013-09-10 20:39 UTC (permalink / raw)
  To: netdev
  Cc: vfalico, Neil Horman, Neil Horman, Jay Vosburgh, Andy Gospodarek,
	David S. Miller

From: Neil Horman <nhorman@redhat.com>

running bonding in ALB mode requires that learning packets be sent periodically,
so that the switch knows where to send responding traffic.  However, depending
on switch configuration, there may not be any need to send traffic at the
default rate of 3 packets per second, which represents little more than wasted
data.  Allow the ALB learning packet interval to be made configurable via sysfs

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: "David S. Miller" <davem@davemloft.net>

---
Change Notes:
v2)
Add documentation
---
 Documentation/networking/bonding.txt |  5 +++++
 drivers/net/bonding/bond_alb.c       |  2 +-
 drivers/net/bonding/bond_alb.h       |  8 ++++----
 drivers/net/bonding/bond_main.c      |  1 +
 drivers/net/bonding/bond_sysfs.c     | 39 ++++++++++++++++++++++++++++++++++++
 drivers/net/bonding/bonding.h        |  1 +
 6 files changed, 51 insertions(+), 5 deletions(-)

diff --git a/Documentation/networking/bonding.txt b/Documentation/networking/bonding.txt
index 87bbcfe..5928f6f 100644
--- a/Documentation/networking/bonding.txt
+++ b/Documentation/networking/bonding.txt
@@ -1362,6 +1362,11 @@ To add ARP targets:
 To remove an ARP target:
 # echo -192.168.0.100 > /sys/class/net/bond0/bonding/arp_ip_target
 
+To configure the interval between learning packet transmits:
+# echo 12 > /sys/class/net/bond0/bonding/lp_interval
+	NOTE: the lp_inteval is the number of seconds between instances where
+the bonding driver sends learning packets to each slaves peer switch.
+
 Example Configuration
 ---------------------
 	We begin with the same example that is shown in section 3.3,
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 91f179d..f428ef57 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -1472,7 +1472,7 @@ void bond_alb_monitor(struct work_struct *work)
 	bond_info->lp_counter++;
 
 	/* send learning packets */
-	if (bond_info->lp_counter >= BOND_ALB_LP_TICKS) {
+	if (bond_info->lp_counter >= BOND_ALB_LP_TICKS(bond)) {
 		/* change of curr_active_slave involves swapping of mac addresses.
 		 * in order to avoid this swapping from happening while
 		 * sending the learning packets, the curr_slave_lock must be held for
diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h
index 28d8e4c..e78fd9b 100644
--- a/drivers/net/bonding/bond_alb.h
+++ b/drivers/net/bonding/bond_alb.h
@@ -36,14 +36,14 @@ struct slave;
 					 * Used for division - never set
 					 * to zero !!!
 					 */
-#define BOND_ALB_LP_INTERVAL	    1	/* In seconds, periodic send of
-					 * learning packets to the switch
-					 */
+#define BOND_ALB_LP_INTERVAL(bond) (bond->params.lp_interval)	/* In seconds, periodic send of
+								 * learning packets to the switch
+								 */
 
 #define BOND_TLB_REBALANCE_TICKS (BOND_TLB_REBALANCE_INTERVAL \
 				  * ALB_TIMER_TICKS_PER_SEC)
 
-#define BOND_ALB_LP_TICKS (BOND_ALB_LP_INTERVAL \
+#define BOND_ALB_LP_TICKS(bond) (BOND_ALB_LP_INTERVAL(bond) \
 			   * ALB_TIMER_TICKS_PER_SEC)
 
 #define TLB_HASH_TABLE_SIZE 256	/* The size of the clients hash table.
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 39e5b1c..b8c9ec3 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4416,6 +4416,7 @@ static int bond_check_params(struct bond_params *params)
 	params->all_slaves_active = all_slaves_active;
 	params->resend_igmp = resend_igmp;
 	params->min_links = min_links;
+	params->lp_interval = 1;
 
 	if (primary) {
 		strncpy(params->primary, primary, IFNAMSIZ);
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index ce46776..4532259 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -1680,6 +1680,44 @@ out:
 static DEVICE_ATTR(resend_igmp, S_IRUGO | S_IWUSR,
 		   bonding_show_resend_igmp, bonding_store_resend_igmp);
 
+
+static ssize_t bonding_show_lp_interval(struct device *d,
+					struct device_attribute *attr,
+					char *buf)
+{
+	struct bonding *bond = to_bond(d);
+	return sprintf(buf, "%d\n", bond->params.lp_interval);
+}
+
+static ssize_t bonding_store_lp_interval(struct device *d,
+					 struct device_attribute *attr,
+					 const char *buf, size_t count)
+{
+	struct bonding *bond = to_bond(d);
+	int new_value, ret = count;
+
+	if (sscanf(buf, "%d", &new_value) != 1) {
+		pr_err("%s: no lp interval value specified.\n",
+			bond->dev->name);
+		ret = -EINVAL;
+		goto out;
+	}
+
+	if (new_value <= 0) {
+		pr_err ("%s: lp_interval must be between 1 and %d\n",
+			bond->dev->name, INT_MAX);
+		ret = -EINVAL;
+		goto out;
+	}
+
+	bond->params.lp_interval = new_value;
+out:
+	return ret;
+}
+
+static DEVICE_ATTR(lp_interval, S_IRUGO | S_IWUSR,
+		   bonding_show_lp_interval, bonding_store_lp_interval);
+
 static struct attribute *per_bond_attrs[] = {
 	&dev_attr_slaves.attr,
 	&dev_attr_mode.attr,
@@ -1710,6 +1748,7 @@ static struct attribute *per_bond_attrs[] = {
 	&dev_attr_all_slaves_active.attr,
 	&dev_attr_resend_igmp.attr,
 	&dev_attr_min_links.attr,
+	&dev_attr_lp_interval.attr,
 	NULL,
 };
 
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index f7ab161..4bd9d5b 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -176,6 +176,7 @@ struct bond_params {
 	int tx_queues;
 	int all_slaves_active;
 	int resend_igmp;
+	int lp_interval;
 };
 
 struct bond_parm_tbl {
-- 
1.8.3.1

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

* Re: [PATCH v2] bonding: Make alb learning packet interval configurable
  2013-09-10 20:39 ` [PATCH v2] " Neil Horman
@ 2013-09-10 20:55   ` Veaceslav Falico
  2013-09-12 20:49   ` David Miller
  1 sibling, 0 replies; 11+ messages in thread
From: Veaceslav Falico @ 2013-09-10 20:55 UTC (permalink / raw)
  To: Neil Horman
  Cc: netdev, Neil Horman, Jay Vosburgh, Andy Gospodarek, David S. Miller

On Tue, Sep 10, 2013 at 04:39:03PM -0400, Neil Horman wrote:
>From: Neil Horman <nhorman@redhat.com>
>
>running bonding in ALB mode requires that learning packets be sent periodically,
>so that the switch knows where to send responding traffic.  However, depending
>on switch configuration, there may not be any need to send traffic at the
>default rate of 3 packets per second, which represents little more than wasted
>data.  Allow the ALB learning packet interval to be made configurable via sysfs
>
>Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
>CC: Jay Vosburgh <fubar@us.ibm.com>
>CC: Andy Gospodarek <andy@greyhouse.net>
>CC: "David S. Miller" <davem@davemloft.net>
>
>---
>Change Notes:
>v2)
>Add documentation

Nice, thank you!

Acked-by: Veaceslav Falico <vfalico@redhat.com>

>---
> Documentation/networking/bonding.txt |  5 +++++
> drivers/net/bonding/bond_alb.c       |  2 +-
> drivers/net/bonding/bond_alb.h       |  8 ++++----
> drivers/net/bonding/bond_main.c      |  1 +
> drivers/net/bonding/bond_sysfs.c     | 39 ++++++++++++++++++++++++++++++++++++
> drivers/net/bonding/bonding.h        |  1 +
> 6 files changed, 51 insertions(+), 5 deletions(-)
>
>diff --git a/Documentation/networking/bonding.txt b/Documentation/networking/bonding.txt
>index 87bbcfe..5928f6f 100644
>--- a/Documentation/networking/bonding.txt
>+++ b/Documentation/networking/bonding.txt
>@@ -1362,6 +1362,11 @@ To add ARP targets:
> To remove an ARP target:
> # echo -192.168.0.100 > /sys/class/net/bond0/bonding/arp_ip_target
>
>+To configure the interval between learning packet transmits:
>+# echo 12 > /sys/class/net/bond0/bonding/lp_interval
>+	NOTE: the lp_inteval is the number of seconds between instances where
>+the bonding driver sends learning packets to each slaves peer switch.
>+
> Example Configuration
> ---------------------
> 	We begin with the same example that is shown in section 3.3,
>diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
>index 91f179d..f428ef57 100644
>--- a/drivers/net/bonding/bond_alb.c
>+++ b/drivers/net/bonding/bond_alb.c
>@@ -1472,7 +1472,7 @@ void bond_alb_monitor(struct work_struct *work)
> 	bond_info->lp_counter++;
>
> 	/* send learning packets */
>-	if (bond_info->lp_counter >= BOND_ALB_LP_TICKS) {
>+	if (bond_info->lp_counter >= BOND_ALB_LP_TICKS(bond)) {
> 		/* change of curr_active_slave involves swapping of mac addresses.
> 		 * in order to avoid this swapping from happening while
> 		 * sending the learning packets, the curr_slave_lock must be held for
>diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h
>index 28d8e4c..e78fd9b 100644
>--- a/drivers/net/bonding/bond_alb.h
>+++ b/drivers/net/bonding/bond_alb.h
>@@ -36,14 +36,14 @@ struct slave;
> 					 * Used for division - never set
> 					 * to zero !!!
> 					 */
>-#define BOND_ALB_LP_INTERVAL	    1	/* In seconds, periodic send of
>-					 * learning packets to the switch
>-					 */
>+#define BOND_ALB_LP_INTERVAL(bond) (bond->params.lp_interval)	/* In seconds, periodic send of
>+								 * learning packets to the switch
>+								 */
>
> #define BOND_TLB_REBALANCE_TICKS (BOND_TLB_REBALANCE_INTERVAL \
> 				  * ALB_TIMER_TICKS_PER_SEC)
>
>-#define BOND_ALB_LP_TICKS (BOND_ALB_LP_INTERVAL \
>+#define BOND_ALB_LP_TICKS(bond) (BOND_ALB_LP_INTERVAL(bond) \
> 			   * ALB_TIMER_TICKS_PER_SEC)
>
> #define TLB_HASH_TABLE_SIZE 256	/* The size of the clients hash table.
>diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>index 39e5b1c..b8c9ec3 100644
>--- a/drivers/net/bonding/bond_main.c
>+++ b/drivers/net/bonding/bond_main.c
>@@ -4416,6 +4416,7 @@ static int bond_check_params(struct bond_params *params)
> 	params->all_slaves_active = all_slaves_active;
> 	params->resend_igmp = resend_igmp;
> 	params->min_links = min_links;
>+	params->lp_interval = 1;
>
> 	if (primary) {
> 		strncpy(params->primary, primary, IFNAMSIZ);
>diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
>index ce46776..4532259 100644
>--- a/drivers/net/bonding/bond_sysfs.c
>+++ b/drivers/net/bonding/bond_sysfs.c
>@@ -1680,6 +1680,44 @@ out:
> static DEVICE_ATTR(resend_igmp, S_IRUGO | S_IWUSR,
> 		   bonding_show_resend_igmp, bonding_store_resend_igmp);
>
>+
>+static ssize_t bonding_show_lp_interval(struct device *d,
>+					struct device_attribute *attr,
>+					char *buf)
>+{
>+	struct bonding *bond = to_bond(d);
>+	return sprintf(buf, "%d\n", bond->params.lp_interval);
>+}
>+
>+static ssize_t bonding_store_lp_interval(struct device *d,
>+					 struct device_attribute *attr,
>+					 const char *buf, size_t count)
>+{
>+	struct bonding *bond = to_bond(d);
>+	int new_value, ret = count;
>+
>+	if (sscanf(buf, "%d", &new_value) != 1) {
>+		pr_err("%s: no lp interval value specified.\n",
>+			bond->dev->name);
>+		ret = -EINVAL;
>+		goto out;
>+	}
>+
>+	if (new_value <= 0) {
>+		pr_err ("%s: lp_interval must be between 1 and %d\n",
>+			bond->dev->name, INT_MAX);
>+		ret = -EINVAL;
>+		goto out;
>+	}
>+
>+	bond->params.lp_interval = new_value;
>+out:
>+	return ret;
>+}
>+
>+static DEVICE_ATTR(lp_interval, S_IRUGO | S_IWUSR,
>+		   bonding_show_lp_interval, bonding_store_lp_interval);
>+
> static struct attribute *per_bond_attrs[] = {
> 	&dev_attr_slaves.attr,
> 	&dev_attr_mode.attr,
>@@ -1710,6 +1748,7 @@ static struct attribute *per_bond_attrs[] = {
> 	&dev_attr_all_slaves_active.attr,
> 	&dev_attr_resend_igmp.attr,
> 	&dev_attr_min_links.attr,
>+	&dev_attr_lp_interval.attr,
> 	NULL,
> };
>
>diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
>index f7ab161..4bd9d5b 100644
>--- a/drivers/net/bonding/bonding.h
>+++ b/drivers/net/bonding/bonding.h
>@@ -176,6 +176,7 @@ struct bond_params {
> 	int tx_queues;
> 	int all_slaves_active;
> 	int resend_igmp;
>+	int lp_interval;
> };
>
> struct bond_parm_tbl {
>-- 
>1.8.3.1
>

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

* Re: [PATCH v2] bonding: Make alb learning packet interval configurable
  2013-09-10 20:39 ` [PATCH v2] " Neil Horman
  2013-09-10 20:55   ` Veaceslav Falico
@ 2013-09-12 20:49   ` David Miller
  2013-09-12 21:06     ` Andy Gospodarek
  1 sibling, 1 reply; 11+ messages in thread
From: David Miller @ 2013-09-12 20:49 UTC (permalink / raw)
  To: nhorman; +Cc: netdev, vfalico, nhorman, fubar, andy

From: Neil Horman <nhorman@tuxdriver.com>
Date: Tue, 10 Sep 2013 16:39:03 -0400

> From: Neil Horman <nhorman@redhat.com>
> 
> running bonding in ALB mode requires that learning packets be sent periodically,
> so that the switch knows where to send responding traffic.  However, depending
> on switch configuration, there may not be any need to send traffic at the
> default rate of 3 packets per second, which represents little more than wasted
> data.  Allow the ALB learning packet interval to be made configurable via sysfs
> 
> Signed-off-by: Neil Horman <nhorman@tuxdriver.com>

I hate to be a stickler, but I'd like you to make the default value
documented both in the code and in the documentation.

Use some macro for the code "#define BOND_ALB_DEFAULT_LP_INTERVAL 1" and
mention the default in the bonding.txt changes.

Thanks.

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

* Re: [PATCH v2] bonding: Make alb learning packet interval configurable
  2013-09-12 20:49   ` David Miller
@ 2013-09-12 21:06     ` Andy Gospodarek
  2013-09-13  3:01       ` Neil Horman
  0 siblings, 1 reply; 11+ messages in thread
From: Andy Gospodarek @ 2013-09-12 21:06 UTC (permalink / raw)
  To: David Miller; +Cc: nhorman, netdev, vfalico, nhorman, fubar

On Thu, Sep 12, 2013 at 04:49:48PM -0400, David Miller wrote:
> From: Neil Horman <nhorman@tuxdriver.com>
> Date: Tue, 10 Sep 2013 16:39:03 -0400
> 
> > From: Neil Horman <nhorman@redhat.com>
> > 
> > running bonding in ALB mode requires that learning packets be sent periodically,
> > so that the switch knows where to send responding traffic.  However, depending
> > on switch configuration, there may not be any need to send traffic at the
> > default rate of 3 packets per second, which represents little more than wasted
> > data.  Allow the ALB learning packet interval to be made configurable via sysfs
> > 
> > Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
> 
> I hate to be a stickler, but I'd like you to make the default value
> documented both in the code and in the documentation.
> 
> Use some macro for the code "#define BOND_ALB_DEFAULT_LP_INTERVAL 1" and
> mention the default in the bonding.txt changes.
> 

Agree with DaveM on this.  You can just keep the one that was there and
it should be pretty easy.

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

* Re: [PATCH v2] bonding: Make alb learning packet interval configurable
  2013-09-12 21:06     ` Andy Gospodarek
@ 2013-09-13  3:01       ` Neil Horman
  0 siblings, 0 replies; 11+ messages in thread
From: Neil Horman @ 2013-09-13  3:01 UTC (permalink / raw)
  To: Andy Gospodarek; +Cc: David Miller, netdev, vfalico, nhorman, fubar

On Thu, Sep 12, 2013 at 05:06:13PM -0400, Andy Gospodarek wrote:
> On Thu, Sep 12, 2013 at 04:49:48PM -0400, David Miller wrote:
> > From: Neil Horman <nhorman@tuxdriver.com>
> > Date: Tue, 10 Sep 2013 16:39:03 -0400
> > 
> > > From: Neil Horman <nhorman@redhat.com>
> > > 
> > > running bonding in ALB mode requires that learning packets be sent periodically,
> > > so that the switch knows where to send responding traffic.  However, depending
> > > on switch configuration, there may not be any need to send traffic at the
> > > default rate of 3 packets per second, which represents little more than wasted
> > > data.  Allow the ALB learning packet interval to be made configurable via sysfs
> > > 
> > > Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
> > 
> > I hate to be a stickler, but I'd like you to make the default value
> > documented both in the code and in the documentation.
> > 
> > Use some macro for the code "#define BOND_ALB_DEFAULT_LP_INTERVAL 1" and
> > mention the default in the bonding.txt changes.
> > 
> 
> Agree with DaveM on this.  You can just keep the one that was there and
> it should be pretty easy.
> 
Yeah, sure I can do that. v3 in the AM
Neil

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

* [PATCH v3] bonding: Make alb learning packet interval configurable
  2013-09-10 14:14 [PATCH] bonding: Make alb learning packet interval configurable Neil Horman
  2013-09-10 18:11 ` Veaceslav Falico
  2013-09-10 20:39 ` [PATCH v2] " Neil Horman
@ 2013-09-13 15:05 ` Neil Horman
  2013-09-13 15:38   ` Andy Gospodarek
  2013-09-16  4:53   ` David Miller
  2 siblings, 2 replies; 11+ messages in thread
From: Neil Horman @ 2013-09-13 15:05 UTC (permalink / raw)
  To: netdev
  Cc: vfalico, Neil Horman, Jay Vosburgh, Andy Gospodarek, David S. Miller

running bonding in ALB mode requires that learning packets be sent periodically,
so that the switch knows where to send responding traffic.  However, depending
on switch configuration, there may not be any need to send traffic at the
default rate of 3 packets per second, which represents little more than wasted
data.  Allow the ALB learning packet interval to be made configurable via sysfs

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Acked-by: Veaceslav Falico <vfalico@redhat.com>
CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: "David S. Miller" <davem@davemloft.net>

---
Change Notes:
v2)
Add documentation

v3)
Document the default value and make it a new macro
---
 Documentation/networking/bonding.txt |  6 ++++++
 drivers/net/bonding/bond_alb.c       |  2 +-
 drivers/net/bonding/bond_alb.h       |  9 +++++----
 drivers/net/bonding/bond_main.c      |  1 +
 drivers/net/bonding/bond_sysfs.c     | 39 ++++++++++++++++++++++++++++++++++++
 drivers/net/bonding/bonding.h        |  1 +
 6 files changed, 53 insertions(+), 5 deletions(-)

diff --git a/Documentation/networking/bonding.txt b/Documentation/networking/bonding.txt
index 87bbcfe..9b28e71 100644
--- a/Documentation/networking/bonding.txt
+++ b/Documentation/networking/bonding.txt
@@ -1362,6 +1362,12 @@ To add ARP targets:
 To remove an ARP target:
 # echo -192.168.0.100 > /sys/class/net/bond0/bonding/arp_ip_target
 
+To configure the interval between learning packet transmits:
+# echo 12 > /sys/class/net/bond0/bonding/lp_interval
+	NOTE: the lp_inteval is the number of seconds between instances where
+the bonding driver sends learning packets to each slaves peer switch.  The
+default interval is 1 second.
+
 Example Configuration
 ---------------------
 	We begin with the same example that is shown in section 3.3,
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 91f179d..f428ef57 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -1472,7 +1472,7 @@ void bond_alb_monitor(struct work_struct *work)
 	bond_info->lp_counter++;
 
 	/* send learning packets */
-	if (bond_info->lp_counter >= BOND_ALB_LP_TICKS) {
+	if (bond_info->lp_counter >= BOND_ALB_LP_TICKS(bond)) {
 		/* change of curr_active_slave involves swapping of mac addresses.
 		 * in order to avoid this swapping from happening while
 		 * sending the learning packets, the curr_slave_lock must be held for
diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h
index 28d8e4c..c5eff5d 100644
--- a/drivers/net/bonding/bond_alb.h
+++ b/drivers/net/bonding/bond_alb.h
@@ -36,14 +36,15 @@ struct slave;
 					 * Used for division - never set
 					 * to zero !!!
 					 */
-#define BOND_ALB_LP_INTERVAL	    1	/* In seconds, periodic send of
-					 * learning packets to the switch
-					 */
+#define BOND_ALB_DEFAULT_LP_INTERVAL 1
+#define BOND_ALB_LP_INTERVAL(bond) (bond->params.lp_interval)	/* In seconds, periodic send of
+								 * learning packets to the switch
+								 */
 
 #define BOND_TLB_REBALANCE_TICKS (BOND_TLB_REBALANCE_INTERVAL \
 				  * ALB_TIMER_TICKS_PER_SEC)
 
-#define BOND_ALB_LP_TICKS (BOND_ALB_LP_INTERVAL \
+#define BOND_ALB_LP_TICKS(bond) (BOND_ALB_LP_INTERVAL(bond) \
 			   * ALB_TIMER_TICKS_PER_SEC)
 
 #define TLB_HASH_TABLE_SIZE 256	/* The size of the clients hash table.
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 39e5b1c..31106b5 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4416,6 +4416,7 @@ static int bond_check_params(struct bond_params *params)
 	params->all_slaves_active = all_slaves_active;
 	params->resend_igmp = resend_igmp;
 	params->min_links = min_links;
+	params->lp_interval = BOND_ALB_DEFAULT_LP_INTERVAL;
 
 	if (primary) {
 		strncpy(params->primary, primary, IFNAMSIZ);
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index ce46776..4532259 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -1680,6 +1680,44 @@ out:
 static DEVICE_ATTR(resend_igmp, S_IRUGO | S_IWUSR,
 		   bonding_show_resend_igmp, bonding_store_resend_igmp);
 
+
+static ssize_t bonding_show_lp_interval(struct device *d,
+					struct device_attribute *attr,
+					char *buf)
+{
+	struct bonding *bond = to_bond(d);
+	return sprintf(buf, "%d\n", bond->params.lp_interval);
+}
+
+static ssize_t bonding_store_lp_interval(struct device *d,
+					 struct device_attribute *attr,
+					 const char *buf, size_t count)
+{
+	struct bonding *bond = to_bond(d);
+	int new_value, ret = count;
+
+	if (sscanf(buf, "%d", &new_value) != 1) {
+		pr_err("%s: no lp interval value specified.\n",
+			bond->dev->name);
+		ret = -EINVAL;
+		goto out;
+	}
+
+	if (new_value <= 0) {
+		pr_err ("%s: lp_interval must be between 1 and %d\n",
+			bond->dev->name, INT_MAX);
+		ret = -EINVAL;
+		goto out;
+	}
+
+	bond->params.lp_interval = new_value;
+out:
+	return ret;
+}
+
+static DEVICE_ATTR(lp_interval, S_IRUGO | S_IWUSR,
+		   bonding_show_lp_interval, bonding_store_lp_interval);
+
 static struct attribute *per_bond_attrs[] = {
 	&dev_attr_slaves.attr,
 	&dev_attr_mode.attr,
@@ -1710,6 +1748,7 @@ static struct attribute *per_bond_attrs[] = {
 	&dev_attr_all_slaves_active.attr,
 	&dev_attr_resend_igmp.attr,
 	&dev_attr_min_links.attr,
+	&dev_attr_lp_interval.attr,
 	NULL,
 };
 
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index f7ab161..4bd9d5b 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -176,6 +176,7 @@ struct bond_params {
 	int tx_queues;
 	int all_slaves_active;
 	int resend_igmp;
+	int lp_interval;
 };
 
 struct bond_parm_tbl {
-- 
1.8.3.1

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

* Re: [PATCH v3] bonding: Make alb learning packet interval configurable
  2013-09-13 15:05 ` [PATCH v3] " Neil Horman
@ 2013-09-13 15:38   ` Andy Gospodarek
  2013-09-16  4:53   ` David Miller
  1 sibling, 0 replies; 11+ messages in thread
From: Andy Gospodarek @ 2013-09-13 15:38 UTC (permalink / raw)
  To: netdev

On Fri, Sep 13, 2013 at 11:05:33AM -0400, Neil Horman wrote:
> running bonding in ALB mode requires that learning packets be sent periodically,
> so that the switch knows where to send responding traffic.  However, depending
> on switch configuration, there may not be any need to send traffic at the
> default rate of 3 packets per second, which represents little more than wasted
> data.  Allow the ALB learning packet interval to be made configurable via sysfs
> 
> Signed-off-by: Neil Horman <nhorman@tuxdriver.com>

Thanks for making those changes, Neil.

Signed-off-by: Andy Gospodarek <andy@greyhouse.net>

> Acked-by: Acked-by: Veaceslav Falico <vfalico@redhat.com>
> CC: Jay Vosburgh <fubar@us.ibm.com>
> CC: Andy Gospodarek <andy@greyhouse.net>
> CC: "David S. Miller" <davem@davemloft.net>
> 
> ---
> Change Notes:
> v2)
> Add documentation
> 
> v3)
> Document the default value and make it a new macro
> ---
>  Documentation/networking/bonding.txt |  6 ++++++
>  drivers/net/bonding/bond_alb.c       |  2 +-
>  drivers/net/bonding/bond_alb.h       |  9 +++++----
>  drivers/net/bonding/bond_main.c      |  1 +
>  drivers/net/bonding/bond_sysfs.c     | 39 ++++++++++++++++++++++++++++++++++++
>  drivers/net/bonding/bonding.h        |  1 +
>  6 files changed, 53 insertions(+), 5 deletions(-)
> 
> diff --git a/Documentation/networking/bonding.txt b/Documentation/networking/bonding.txt
> index 87bbcfe..9b28e71 100644
> --- a/Documentation/networking/bonding.txt
> +++ b/Documentation/networking/bonding.txt
> @@ -1362,6 +1362,12 @@ To add ARP targets:
>  To remove an ARP target:
>  # echo -192.168.0.100 > /sys/class/net/bond0/bonding/arp_ip_target
>  
> +To configure the interval between learning packet transmits:
> +# echo 12 > /sys/class/net/bond0/bonding/lp_interval
> +	NOTE: the lp_inteval is the number of seconds between instances where
> +the bonding driver sends learning packets to each slaves peer switch.  The
> +default interval is 1 second.
> +
>  Example Configuration
>  ---------------------
>  	We begin with the same example that is shown in section 3.3,
> diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
> index 91f179d..f428ef57 100644
> --- a/drivers/net/bonding/bond_alb.c
> +++ b/drivers/net/bonding/bond_alb.c
> @@ -1472,7 +1472,7 @@ void bond_alb_monitor(struct work_struct *work)
>  	bond_info->lp_counter++;
>  
>  	/* send learning packets */
> -	if (bond_info->lp_counter >= BOND_ALB_LP_TICKS) {
> +	if (bond_info->lp_counter >= BOND_ALB_LP_TICKS(bond)) {
>  		/* change of curr_active_slave involves swapping of mac addresses.
>  		 * in order to avoid this swapping from happening while
>  		 * sending the learning packets, the curr_slave_lock must be held for
> diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h
> index 28d8e4c..c5eff5d 100644
> --- a/drivers/net/bonding/bond_alb.h
> +++ b/drivers/net/bonding/bond_alb.h
> @@ -36,14 +36,15 @@ struct slave;
>  					 * Used for division - never set
>  					 * to zero !!!
>  					 */
> -#define BOND_ALB_LP_INTERVAL	    1	/* In seconds, periodic send of
> -					 * learning packets to the switch
> -					 */
> +#define BOND_ALB_DEFAULT_LP_INTERVAL 1
> +#define BOND_ALB_LP_INTERVAL(bond) (bond->params.lp_interval)	/* In seconds, periodic send of
> +								 * learning packets to the switch
> +								 */
>  
>  #define BOND_TLB_REBALANCE_TICKS (BOND_TLB_REBALANCE_INTERVAL \
>  				  * ALB_TIMER_TICKS_PER_SEC)
>  
> -#define BOND_ALB_LP_TICKS (BOND_ALB_LP_INTERVAL \
> +#define BOND_ALB_LP_TICKS(bond) (BOND_ALB_LP_INTERVAL(bond) \
>  			   * ALB_TIMER_TICKS_PER_SEC)
>  
>  #define TLB_HASH_TABLE_SIZE 256	/* The size of the clients hash table.
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 39e5b1c..31106b5 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -4416,6 +4416,7 @@ static int bond_check_params(struct bond_params *params)
>  	params->all_slaves_active = all_slaves_active;
>  	params->resend_igmp = resend_igmp;
>  	params->min_links = min_links;
> +	params->lp_interval = BOND_ALB_DEFAULT_LP_INTERVAL;
>  
>  	if (primary) {
>  		strncpy(params->primary, primary, IFNAMSIZ);
> diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
> index ce46776..4532259 100644
> --- a/drivers/net/bonding/bond_sysfs.c
> +++ b/drivers/net/bonding/bond_sysfs.c
> @@ -1680,6 +1680,44 @@ out:
>  static DEVICE_ATTR(resend_igmp, S_IRUGO | S_IWUSR,
>  		   bonding_show_resend_igmp, bonding_store_resend_igmp);
>  
> +
> +static ssize_t bonding_show_lp_interval(struct device *d,
> +					struct device_attribute *attr,
> +					char *buf)
> +{
> +	struct bonding *bond = to_bond(d);
> +	return sprintf(buf, "%d\n", bond->params.lp_interval);
> +}
> +
> +static ssize_t bonding_store_lp_interval(struct device *d,
> +					 struct device_attribute *attr,
> +					 const char *buf, size_t count)
> +{
> +	struct bonding *bond = to_bond(d);
> +	int new_value, ret = count;
> +
> +	if (sscanf(buf, "%d", &new_value) != 1) {
> +		pr_err("%s: no lp interval value specified.\n",
> +			bond->dev->name);
> +		ret = -EINVAL;
> +		goto out;
> +	}
> +
> +	if (new_value <= 0) {
> +		pr_err ("%s: lp_interval must be between 1 and %d\n",
> +			bond->dev->name, INT_MAX);
> +		ret = -EINVAL;
> +		goto out;
> +	}
> +
> +	bond->params.lp_interval = new_value;
> +out:
> +	return ret;
> +}
> +
> +static DEVICE_ATTR(lp_interval, S_IRUGO | S_IWUSR,
> +		   bonding_show_lp_interval, bonding_store_lp_interval);
> +
>  static struct attribute *per_bond_attrs[] = {
>  	&dev_attr_slaves.attr,
>  	&dev_attr_mode.attr,
> @@ -1710,6 +1748,7 @@ static struct attribute *per_bond_attrs[] = {
>  	&dev_attr_all_slaves_active.attr,
>  	&dev_attr_resend_igmp.attr,
>  	&dev_attr_min_links.attr,
> +	&dev_attr_lp_interval.attr,
>  	NULL,
>  };
>  
> diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
> index f7ab161..4bd9d5b 100644
> --- a/drivers/net/bonding/bonding.h
> +++ b/drivers/net/bonding/bonding.h
> @@ -176,6 +176,7 @@ struct bond_params {
>  	int tx_queues;
>  	int all_slaves_active;
>  	int resend_igmp;
> +	int lp_interval;
>  };
>  
>  struct bond_parm_tbl {
> -- 
> 1.8.3.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v3] bonding: Make alb learning packet interval configurable
  2013-09-13 15:05 ` [PATCH v3] " Neil Horman
  2013-09-13 15:38   ` Andy Gospodarek
@ 2013-09-16  4:53   ` David Miller
  1 sibling, 0 replies; 11+ messages in thread
From: David Miller @ 2013-09-16  4:53 UTC (permalink / raw)
  To: nhorman; +Cc: netdev, vfalico, fubar, andy

From: Neil Horman <nhorman@tuxdriver.com>
Date: Fri, 13 Sep 2013 11:05:33 -0400

> running bonding in ALB mode requires that learning packets be sent periodically,
> so that the switch knows where to send responding traffic.  However, depending
> on switch configuration, there may not be any need to send traffic at the
> default rate of 3 packets per second, which represents little more than wasted
> data.  Allow the ALB learning packet interval to be made configurable via sysfs
> 
> Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
> Acked-by: Acked-by: Veaceslav Falico <vfalico@redhat.com>

Applied, thanks Neil.

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

end of thread, other threads:[~2013-09-16  4:53 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-10 14:14 [PATCH] bonding: Make alb learning packet interval configurable Neil Horman
2013-09-10 18:11 ` Veaceslav Falico
2013-09-10 19:04   ` Neil Horman
2013-09-10 20:39 ` [PATCH v2] " Neil Horman
2013-09-10 20:55   ` Veaceslav Falico
2013-09-12 20:49   ` David Miller
2013-09-12 21:06     ` Andy Gospodarek
2013-09-13  3:01       ` Neil Horman
2013-09-13 15:05 ` [PATCH v3] " Neil Horman
2013-09-13 15:38   ` Andy Gospodarek
2013-09-16  4:53   ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.