summaryrefslogtreecommitdiff
path: root/drivers/net/bonding/bond_options.c
diff options
context:
space:
mode:
authorNikolay Aleksandrov <nikolay@redhat.com>2014-01-22 14:53:27 +0100
committerDavid S. Miller <davem@davemloft.net>2014-01-22 15:38:42 -0800
commitd3131de76b1b1a4d95f145846bd61f96e72f0411 (patch)
treee78a441b8ece24edd7fb049d67a70a6836b282ca /drivers/net/bonding/bond_options.c
parente499461275023e20c4aecb6a546e7e213631b99f (diff)
bonding: convert lacp_rate to use the new option API
This patch adds the necessary changes so lacp_rate would use the new bonding option API. Also some trivial/style error fixes. 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.c44
1 files changed, 20 insertions, 24 deletions
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index 9cc21628032f..680296c279dc 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -72,6 +72,12 @@ static struct bond_opt_value bond_intmax_tbl[] = {
{ "maxval", INT_MAX, BOND_VALFLAG_MAX},
};
+static struct bond_opt_value bond_lacp_rate_tbl[] = {
+ { "slow", AD_LACP_SLOW, 0},
+ { "fast", AD_LACP_FAST, 0},
+ { NULL, -1, 0},
+};
+
static struct bond_option bond_opts[] = {
[BOND_OPT_MODE] = {
.id = BOND_OPT_MODE,
@@ -149,7 +155,15 @@ static struct bond_option bond_opts[] = {
.values = bond_intmax_tbl,
.set = bond_option_updelay_set
},
-
+ [BOND_OPT_LACP_RATE] = {
+ .id = BOND_OPT_LACP_RATE,
+ .name = "lacp_rate",
+ .desc = "LACPDU tx rate to request from 802.3ad partner",
+ .flags = BOND_OPTFLAG_IFDOWN,
+ .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)),
+ .values = bond_lacp_rate_tbl,
+ .set = bond_option_lacp_rate_set
+ },
{ }
};
@@ -1015,31 +1029,13 @@ int bond_option_pps_set(struct bonding *bond, struct bond_opt_value *newval)
return 0;
}
-int bond_option_lacp_rate_set(struct bonding *bond, int lacp_rate)
+int bond_option_lacp_rate_set(struct bonding *bond,
+ struct bond_opt_value *newval)
{
- if (bond_parm_tbl_lookup(lacp_rate, bond_lacp_tbl) < 0) {
- pr_err("%s: Ignoring invalid LACP rate value %d.\n",
- bond->dev->name, lacp_rate);
- return -EINVAL;
- }
-
- if (bond->dev->flags & IFF_UP) {
- pr_err("%s: Unable to update LACP rate because interface is up.\n",
- bond->dev->name);
- return -EPERM;
- }
-
- if (bond->params.mode != BOND_MODE_8023AD) {
- pr_err("%s: Unable to update LACP rate because bond is not in 802.3ad mode.\n",
- bond->dev->name);
- return -EPERM;
- }
-
- bond->params.lacp_fast = lacp_rate;
+ pr_info("%s: Setting LACP rate to %s (%llu).\n",
+ bond->dev->name, newval->string, newval->value);
+ bond->params.lacp_fast = newval->value;
bond_3ad_update_lacp_rate(bond);
- pr_info("%s: Setting LACP rate to %s (%d).\n",
- bond->dev->name, bond_lacp_tbl[lacp_rate].modename,
- lacp_rate);
return 0;
}