summaryrefslogtreecommitdiff
path: root/drivers/net/bonding/bond_options.c
diff options
context:
space:
mode:
authorsfeldma@cumulusnetworks.com <sfeldma@cumulusnetworks.com>2013-12-17 21:30:37 -0800
committerDavid S. Miller <davem@davemloft.net>2013-12-19 18:32:10 -0500
commitc13ab3ff176eab78b6ee93817484584af5807cf2 (patch)
treebd02fab1dc6136cfd9f3b8cf2a5ef7619dbb8a7c /drivers/net/bonding/bond_options.c
parent8d836d092ed7b77d13ac1108399165ee7de7463f (diff)
bonding: add packets_per_slave attribute netlink support
Add IFLA_BOND_PACKETS_PER_SLAVE to allow get/set of bonding parameter packets_per_slave via netlink. Signed-off-by: Scott Feldman <sfeldma@cumulusnetworks.com> Signed-off-by: Jiri Pirko <jiri@resnulli.us> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding/bond_options.c')
-rw-r--r--drivers/net/bonding/bond_options.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index e313a8f8fae0..f8a2cd8c7b57 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -16,6 +16,7 @@
#include <linux/netdevice.h>
#include <linux/rwlock.h>
#include <linux/rcupdate.h>
+#include <linux/reciprocal_div.h>
#include "bonding.h"
static bool bond_mode_is_valid(int mode)
@@ -633,3 +634,25 @@ int bond_option_lp_interval_set(struct bonding *bond, int lp_interval)
return 0;
}
+
+int bond_option_packets_per_slave_set(struct bonding *bond,
+ int packets_per_slave)
+{
+ if (packets_per_slave < 0 || packets_per_slave > USHRT_MAX) {
+ pr_err("%s: packets_per_slave must be between 0 and %u\n",
+ bond->dev->name, USHRT_MAX);
+ return -EINVAL;
+ }
+
+ if (bond->params.mode != BOND_MODE_ROUNDROBIN)
+ pr_warn("%s: Warning: packets_per_slave has effect only in balance-rr mode\n",
+ bond->dev->name);
+
+ if (packets_per_slave > 1)
+ bond->params.packets_per_slave =
+ reciprocal_value(packets_per_slave);
+ else
+ bond->params.packets_per_slave = packets_per_slave;
+
+ return 0;
+}