bonding: make a generic sysfs option store and fix comments
Subsystems (3)
PATCH 1/1 bonding: make a generic sysfs option store and fix comments
Introduce a generic option store function for sysfs and remove the specific ones. The attribute name is used to match against the option which is to be set.
Also adjust the "name" of tlb_dynamic_lb option to match the sysfs entry and fix the comments and comment style in bond_sysfs.c The comments which showed obvious behaviour (i.e. behaviour that's seen in the option's entry) are removed, the ones that explained important points about the setting function have been moved above the respective set function in bond_options.c
There's only 1 exception: num_unsol_na/num_grat_arp since it has 2 names
---
Note: I'm working on generic show() method as well, but that isn't ready yet. Also on a solution to the exception mentioned above. This patch was tested by setting all options in the bonding sysfs dir.
drivers/net/bonding/bond_options.c | 29 +- drivers/net/bonding/bond_options.h | 1 + drivers/net/bonding/bond_sysfs.c | 568 +++++-------------------------------- 3 files changed, 107 insertions(+), 491 deletions(-)
drivers/net/bonding/bond_options.c +28 -1
@@ -374,7 +374,7 @@ static const struct bond_option bond_opts[] = { }, [BOND_OPT_TLB_DYNAMIC_LB] = { .id = BOND_OPT_TLB_DYNAMIC_LB, - .name = "dynamic_lb", + .name = "tlb_dynamic_lb", .desc = "Enable dynamic flow shuffling", .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_TLB)), .values = bond_tlb_dynamic_lb_tbl,
@@ -384,6 +384,21 @@ static const struct bond_option bond_opts[] = { { } }; +/* Searches for an option by name */ +const struct bond_option *bond_opt_get_by_name (const char *name) +{ +const struct bond_option *opt; +int option; + +for (option =0 ; option <BOND_OPT_LAST ; option++) { + opt =bond_opt_get (option); +if (opt && !strcmp (opt->name, name)) +return opt; + } + +return NULL ; +} +/* Searches for a value in opt's values[] table */ const struct bond_opt_value *bond_opt_get_val (unsigned int option,u64 val) {
@@ -762,6 +777,10 @@ static int bond_option_active_slave_set(struct bonding *bond,return ret; } +/* There are two tricky bits here. First, if MII monitoring is activated, then +* we must disable ARP monitoring. Second, if the timer isn't running, we must +* start it. +*/ static int bond_option_miimon_set (struct bonding *bond,const struct bond_opt_value *newval) {
@@ -800,6 +819,10 @@ static int bond_option_miimon_set(struct bonding *bond,return 0 ; } +/* Set up and down delays. These must be multiples of the +* MII monitoring value, and are stored internally as the multiplier. +* Thus, we must translate to MS for the real world. +*/ static int bond_option_updelay_set (struct bonding *bond,const struct bond_opt_value *newval) {
@@ -858,6 +881,10 @@ static int bond_option_use_carrier_set(struct bonding *bond,return 0 ; } +/* There are two tricky bits here. First, if ARP monitoring is activated, then +* we must disable MII monitoring. Second, if the ARP timer isn't running, +* we must start it. +*/ static int bond_option_arp_interval_set (struct bonding *bond,const struct bond_opt_value *newval) {
drivers/net/bonding/bond_options.h +1 -0
@@ -105,6 +105,7 @@ int bond_opt_tryset_rtnl(struct bonding *bond, unsigned int option, char *buf);const struct bond_opt_value *bond_opt_parse (const struct bond_option *opt,struct bond_opt_value *val);const struct bond_option *bond_opt_get (unsigned int option); +const struct bond_option *bond_opt_get_by_name (const char *name);const struct bond_opt_value *bond_opt_get_val (unsigned int option,u64 val);/* This helper is used to initialize a bond_opt_value structure for parameter
drivers/net/bonding/bond_sysfs.c +78 -490
845 lines not on this page · raw message
Signature · 1 line
1.8.5.3
David Miller
maintainerFrom: Nikolay Aleksandrov <[email protected]>
Date: Thu, 8 May 2014 14:23:54 +0200
Quoted 10 lines
Introduce a generic option store function for sysfs and remove the specific ones. The attribute name is used to match against the option which is to be set.
Also adjust the "name" oftlb_dynamic_lboption to match the sysfs entry and fix the comments and comment style inbond_sysfs.cThe comments which showed obvious behaviour (i.e. behaviour that's seen in the option's entry) are removed, the ones that explained important points about the setting function have been moved above the respective set function inbond_options.c
Quoted 8 lines
There's only 1 exception: num_unsol_na/num_grat_arp since it has 2 names
CC Jay Vosburgh <[email protected]>CC Veaceslav Falico <[email protected]>CC Andy Gospodarek <[email protected]>CC David S. Miller <[email protected]>Signed-off-by Nikolay Aleksandrov <[email protected]>
Nice cleanup, applied to net-next, thanks.