aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding/bond_sysfs.c
diff options
context:
space:
mode:
authorNikolay Aleksandrov <nikolay@redhat.com>2013-11-05 07:51:41 -0500
committerDavid S. Miller <davem@davemloft.net>2013-11-07 15:10:21 -0500
commit73958329ea1fe0dc149b51e5d8703015f65a03e0 (patch)
tree149b655cfa917f9239f68dfe0ad3bb55d7ad8a90 /drivers/net/bonding/bond_sysfs.c
parent6fb392b1a63ae36c31f62bc3fc8630b49d602b62 (diff)
bonding: extend round-robin mode with packets_per_slave
This patch aims to extend round-robin mode with a new option called packets_per_slave which can have the following values and effects: 0 - choose a random slave 1 (default) - standard round-robin, 1 packet per slave >1 - round-robin when >1 packets have been transmitted per slave The allowed values are between 0 and 65535. This patch also fixes the comment style in bond_xmit_roundrobin(). Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com> Acked-by: Veaceslav Falico <vfalico@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding/bond_sysfs.c')
-rw-r--r--drivers/net/bonding/bond_sysfs.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 47749c970a01..75dc4d0efb34 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -40,6 +40,7 @@
40#include <net/net_namespace.h> 40#include <net/net_namespace.h>
41#include <net/netns/generic.h> 41#include <net/netns/generic.h>
42#include <linux/nsproxy.h> 42#include <linux/nsproxy.h>
43#include <linux/reciprocal_div.h>
43 44
44#include "bonding.h" 45#include "bonding.h"
45 46
@@ -1640,6 +1641,53 @@ out:
1640static DEVICE_ATTR(lp_interval, S_IRUGO | S_IWUSR, 1641static DEVICE_ATTR(lp_interval, S_IRUGO | S_IWUSR,
1641 bonding_show_lp_interval, bonding_store_lp_interval); 1642 bonding_show_lp_interval, bonding_store_lp_interval);
1642 1643
1644static ssize_t bonding_show_packets_per_slave(struct device *d,
1645 struct device_attribute *attr,
1646 char *buf)
1647{
1648 struct bonding *bond = to_bond(d);
1649 int packets_per_slave = bond->params.packets_per_slave;
1650
1651 if (packets_per_slave > 1)
1652 packets_per_slave = reciprocal_value(packets_per_slave);
1653
1654 return sprintf(buf, "%d\n", packets_per_slave);
1655}
1656
1657static ssize_t bonding_store_packets_per_slave(struct device *d,
1658 struct device_attribute *attr,
1659 const char *buf, size_t count)
1660{
1661 struct bonding *bond = to_bond(d);
1662 int new_value, ret = count;
1663
1664 if (sscanf(buf, "%d", &new_value) != 1) {
1665 pr_err("%s: no packets_per_slave value specified.\n",
1666 bond->dev->name);
1667 ret = -EINVAL;
1668 goto out;
1669 }
1670 if (new_value < 0 || new_value > USHRT_MAX) {
1671 pr_err("%s: packets_per_slave must be between 0 and %u\n",
1672 bond->dev->name, USHRT_MAX);
1673 ret = -EINVAL;
1674 goto out;
1675 }
1676 if (bond->params.mode != BOND_MODE_ROUNDROBIN)
1677 pr_warn("%s: Warning: packets_per_slave has effect only in balance-rr mode\n",
1678 bond->dev->name);
1679 if (new_value > 1)
1680 bond->params.packets_per_slave = reciprocal_value(new_value);
1681 else
1682 bond->params.packets_per_slave = new_value;
1683out:
1684 return ret;
1685}
1686
1687static DEVICE_ATTR(packets_per_slave, S_IRUGO | S_IWUSR,
1688 bonding_show_packets_per_slave,
1689 bonding_store_packets_per_slave);
1690
1643static struct attribute *per_bond_attrs[] = { 1691static struct attribute *per_bond_attrs[] = {
1644 &dev_attr_slaves.attr, 1692 &dev_attr_slaves.attr,
1645 &dev_attr_mode.attr, 1693 &dev_attr_mode.attr,
@@ -1671,6 +1719,7 @@ static struct attribute *per_bond_attrs[] = {
1671 &dev_attr_resend_igmp.attr, 1719 &dev_attr_resend_igmp.attr,
1672 &dev_attr_min_links.attr, 1720 &dev_attr_min_links.attr,
1673 &dev_attr_lp_interval.attr, 1721 &dev_attr_lp_interval.attr,
1722 &dev_attr_packets_per_slave.attr,
1674 NULL, 1723 NULL,
1675}; 1724};
1676 1725