summaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding/bond_options.c
diff options
context:
space:
mode:
authorNikolay Aleksandrov2014-01-22 14:53:18 +0100
committerDavid S. Miller2014-01-23 00:38:41 +0100
commitaa59d8517d1017e571b803ba6302c4b693b324ab (patch)
tree7746e9fb5e2d8204fa2777534cf14dfbf265a2a7 /drivers/net/bonding/bond_options.c
parentbonding: convert mode setting to use the new option API (diff)
downloadkernel-qcow2-linux-aa59d8517d1017e571b803ba6302c4b693b324ab.tar.gz
kernel-qcow2-linux-aa59d8517d1017e571b803ba6302c4b693b324ab.tar.xz
kernel-qcow2-linux-aa59d8517d1017e571b803ba6302c4b693b324ab.zip
bonding: convert packets_per_slave to use the new option API
This patch adds the necessary changes so packets_per_slave would use the new bonding option API. Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com> 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.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index 5696b2fb5cb4..6d2a7d9cee19 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -30,6 +30,12 @@ static struct bond_opt_value bond_mode_tbl[] = {
{ NULL, -1, 0},
};
+static struct bond_opt_value bond_pps_tbl[] = {
+ { "default", 1, BOND_VALFLAG_DEFAULT},
+ { "maxval", USHRT_MAX, BOND_VALFLAG_MAX},
+ { NULL, -1, 0},
+};
+
static struct bond_option bond_opts[] = {
[BOND_OPT_MODE] = {
.id = BOND_OPT_MODE,
@@ -39,6 +45,14 @@ static struct bond_option bond_opts[] = {
.values = bond_mode_tbl,
.set = bond_option_mode_set
},
+ [BOND_OPT_PACKETS_PER_SLAVE] = {
+ .id = BOND_OPT_PACKETS_PER_SLAVE,
+ .name = "packets_per_slave",
+ .desc = "Packets to send per slave in RR mode",
+ .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_ROUNDROBIN)),
+ .values = bond_pps_tbl,
+ .set = bond_option_pps_set
+ },
{ }
};
@@ -934,23 +948,12 @@ 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)
+int bond_option_pps_set(struct bonding *bond, struct bond_opt_value *newval)
{
- 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);
-
- bond->params.packets_per_slave = packets_per_slave;
- if (packets_per_slave > 0) {
+ bond->params.packets_per_slave = newval->value;
+ if (newval->value > 0) {
bond->params.reciprocal_packets_per_slave =
- reciprocal_value(packets_per_slave);
+ reciprocal_value(newval->value);
} else {
/* reciprocal_packets_per_slave is unused if
* packets_per_slave is 0 or 1, just initialize it