aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorstephen hemminger <stephen@networkplumber.org>2014-03-04 19:36:44 -0500
committerDavid S. Miller <davem@davemloft.net>2014-03-06 16:08:52 -0500
commitf3253339a47ff3690ce52e2acd95ec295f8521b3 (patch)
treeb1785d926e67f74c09549a3b070541c17e409b5e /drivers
parentfca28094cd628e187520f412caa0fb687bfbc8d4 (diff)
bonding: options handling cleanup
Make local functions static (ie. only used in bond_options.c) Make bond options parsing tables constant. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/bonding/bond_main.c3
-rw-r--r--drivers/net/bonding/bond_options.c190
-rw-r--r--drivers/net/bonding/bond_options.h57
-rw-r--r--drivers/net/bonding/bond_sysfs.c16
-rw-r--r--drivers/net/bonding/bonding.h2
5 files changed, 141 insertions, 127 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index e299c54ec185..324389b44915 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3950,7 +3950,8 @@ static void bond_uninit(struct net_device *bond_dev)
3950static int bond_check_params(struct bond_params *params) 3950static int bond_check_params(struct bond_params *params)
3951{ 3951{
3952 int arp_validate_value, fail_over_mac_value, primary_reselect_value, i; 3952 int arp_validate_value, fail_over_mac_value, primary_reselect_value, i;
3953 struct bond_opt_value newval, *valptr; 3953 struct bond_opt_value newval;
3954 const struct bond_opt_value *valptr;
3954 int arp_all_targets_value; 3955 int arp_all_targets_value;
3955 3956
3956 /* 3957 /*
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index 23f365510b58..fc6d25e7d053 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -20,7 +20,59 @@
20#include <linux/inet.h> 20#include <linux/inet.h>
21#include "bonding.h" 21#include "bonding.h"
22 22
23static struct bond_opt_value bond_mode_tbl[] = { 23static int bond_option_active_slave_set(struct bonding *bond,
24 struct bond_opt_value *newval);
25static int bond_option_miimon_set(struct bonding *bond,
26 struct bond_opt_value *newval);
27static int bond_option_updelay_set(struct bonding *bond,
28 struct bond_opt_value *newval);
29static int bond_option_downdelay_set(struct bonding *bond,
30 struct bond_opt_value *newval);
31static int bond_option_use_carrier_set(struct bonding *bond,
32 struct bond_opt_value *newval);
33static int bond_option_arp_interval_set(struct bonding *bond,
34 struct bond_opt_value *newval);
35static int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target);
36static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target);
37static int bond_option_arp_ip_targets_set(struct bonding *bond,
38 struct bond_opt_value *newval);
39static int bond_option_arp_validate_set(struct bonding *bond,
40 struct bond_opt_value *newval);
41static int bond_option_arp_all_targets_set(struct bonding *bond,
42 struct bond_opt_value *newval);
43static int bond_option_primary_set(struct bonding *bond,
44 struct bond_opt_value *newval);
45static int bond_option_primary_reselect_set(struct bonding *bond,
46 struct bond_opt_value *newval);
47static int bond_option_fail_over_mac_set(struct bonding *bond,
48 struct bond_opt_value *newval);
49static int bond_option_xmit_hash_policy_set(struct bonding *bond,
50 struct bond_opt_value *newval);
51static int bond_option_resend_igmp_set(struct bonding *bond,
52 struct bond_opt_value *newval);
53static int bond_option_num_peer_notif_set(struct bonding *bond,
54 struct bond_opt_value *newval);
55static int bond_option_all_slaves_active_set(struct bonding *bond,
56 struct bond_opt_value *newval);
57static int bond_option_min_links_set(struct bonding *bond,
58 struct bond_opt_value *newval);
59static int bond_option_lp_interval_set(struct bonding *bond,
60 struct bond_opt_value *newval);
61static int bond_option_pps_set(struct bonding *bond,
62 struct bond_opt_value *newval);
63static int bond_option_lacp_rate_set(struct bonding *bond,
64 struct bond_opt_value *newval);
65static int bond_option_ad_select_set(struct bonding *bond,
66 struct bond_opt_value *newval);
67static int bond_option_queue_id_set(struct bonding *bond,
68 struct bond_opt_value *newval);
69static int bond_option_mode_set(struct bonding *bond,
70 struct bond_opt_value *newval);
71static int bond_option_slaves_set(struct bonding *bond,
72 struct bond_opt_value *newval);
73
74
75static const struct bond_opt_value bond_mode_tbl[] = {
24 { "balance-rr", BOND_MODE_ROUNDROBIN, BOND_VALFLAG_DEFAULT}, 76 { "balance-rr", BOND_MODE_ROUNDROBIN, BOND_VALFLAG_DEFAULT},
25 { "active-backup", BOND_MODE_ACTIVEBACKUP, 0}, 77 { "active-backup", BOND_MODE_ACTIVEBACKUP, 0},
26 { "balance-xor", BOND_MODE_XOR, 0}, 78 { "balance-xor", BOND_MODE_XOR, 0},
@@ -31,13 +83,13 @@ static struct bond_opt_value bond_mode_tbl[] = {
31 { NULL, -1, 0}, 83 { NULL, -1, 0},
32}; 84};
33 85
34static struct bond_opt_value bond_pps_tbl[] = { 86static const struct bond_opt_value bond_pps_tbl[] = {
35 { "default", 1, BOND_VALFLAG_DEFAULT}, 87 { "default", 1, BOND_VALFLAG_DEFAULT},
36 { "maxval", USHRT_MAX, BOND_VALFLAG_MAX}, 88 { "maxval", USHRT_MAX, BOND_VALFLAG_MAX},
37 { NULL, -1, 0}, 89 { NULL, -1, 0},
38}; 90};
39 91
40static struct bond_opt_value bond_xmit_hashtype_tbl[] = { 92static const struct bond_opt_value bond_xmit_hashtype_tbl[] = {
41 { "layer2", BOND_XMIT_POLICY_LAYER2, BOND_VALFLAG_DEFAULT}, 93 { "layer2", BOND_XMIT_POLICY_LAYER2, BOND_VALFLAG_DEFAULT},
42 { "layer3+4", BOND_XMIT_POLICY_LAYER34, 0}, 94 { "layer3+4", BOND_XMIT_POLICY_LAYER34, 0},
43 { "layer2+3", BOND_XMIT_POLICY_LAYER23, 0}, 95 { "layer2+3", BOND_XMIT_POLICY_LAYER23, 0},
@@ -46,7 +98,7 @@ static struct bond_opt_value bond_xmit_hashtype_tbl[] = {
46 { NULL, -1, 0}, 98 { NULL, -1, 0},
47}; 99};
48 100
49static struct bond_opt_value bond_arp_validate_tbl[] = { 101static const struct bond_opt_value bond_arp_validate_tbl[] = {
50 { "none", BOND_ARP_VALIDATE_NONE, BOND_VALFLAG_DEFAULT}, 102 { "none", BOND_ARP_VALIDATE_NONE, BOND_VALFLAG_DEFAULT},
51 { "active", BOND_ARP_VALIDATE_ACTIVE, 0}, 103 { "active", BOND_ARP_VALIDATE_ACTIVE, 0},
52 { "backup", BOND_ARP_VALIDATE_BACKUP, 0}, 104 { "backup", BOND_ARP_VALIDATE_BACKUP, 0},
@@ -57,76 +109,76 @@ static struct bond_opt_value bond_arp_validate_tbl[] = {
57 { NULL, -1, 0}, 109 { NULL, -1, 0},
58}; 110};
59 111
60static struct bond_opt_value bond_arp_all_targets_tbl[] = { 112static const struct bond_opt_value bond_arp_all_targets_tbl[] = {
61 { "any", BOND_ARP_TARGETS_ANY, BOND_VALFLAG_DEFAULT}, 113 { "any", BOND_ARP_TARGETS_ANY, BOND_VALFLAG_DEFAULT},
62 { "all", BOND_ARP_TARGETS_ALL, 0}, 114 { "all", BOND_ARP_TARGETS_ALL, 0},
63 { NULL, -1, 0}, 115 { NULL, -1, 0},
64}; 116};
65 117
66static struct bond_opt_value bond_fail_over_mac_tbl[] = { 118static const struct bond_opt_value bond_fail_over_mac_tbl[] = {
67 { "none", BOND_FOM_NONE, BOND_VALFLAG_DEFAULT}, 119 { "none", BOND_FOM_NONE, BOND_VALFLAG_DEFAULT},
68 { "active", BOND_FOM_ACTIVE, 0}, 120 { "active", BOND_FOM_ACTIVE, 0},
69 { "follow", BOND_FOM_FOLLOW, 0}, 121 { "follow", BOND_FOM_FOLLOW, 0},
70 { NULL, -1, 0}, 122 { NULL, -1, 0},
71}; 123};
72 124
73static struct bond_opt_value bond_intmax_tbl[] = { 125static const struct bond_opt_value bond_intmax_tbl[] = {
74 { "off", 0, BOND_VALFLAG_DEFAULT}, 126 { "off", 0, BOND_VALFLAG_DEFAULT},
75 { "maxval", INT_MAX, BOND_VALFLAG_MAX}, 127 { "maxval", INT_MAX, BOND_VALFLAG_MAX},
76}; 128};
77 129
78static struct bond_opt_value bond_lacp_rate_tbl[] = { 130static const struct bond_opt_value bond_lacp_rate_tbl[] = {
79 { "slow", AD_LACP_SLOW, 0}, 131 { "slow", AD_LACP_SLOW, 0},
80 { "fast", AD_LACP_FAST, 0}, 132 { "fast", AD_LACP_FAST, 0},
81 { NULL, -1, 0}, 133 { NULL, -1, 0},
82}; 134};
83 135
84static struct bond_opt_value bond_ad_select_tbl[] = { 136static const struct bond_opt_value bond_ad_select_tbl[] = {
85 { "stable", BOND_AD_STABLE, BOND_VALFLAG_DEFAULT}, 137 { "stable", BOND_AD_STABLE, BOND_VALFLAG_DEFAULT},
86 { "bandwidth", BOND_AD_BANDWIDTH, 0}, 138 { "bandwidth", BOND_AD_BANDWIDTH, 0},
87 { "count", BOND_AD_COUNT, 0}, 139 { "count", BOND_AD_COUNT, 0},
88 { NULL, -1, 0}, 140 { NULL, -1, 0},
89}; 141};
90 142
91static struct bond_opt_value bond_num_peer_notif_tbl[] = { 143static const struct bond_opt_value bond_num_peer_notif_tbl[] = {
92 { "off", 0, 0}, 144 { "off", 0, 0},
93 { "maxval", 255, BOND_VALFLAG_MAX}, 145 { "maxval", 255, BOND_VALFLAG_MAX},
94 { "default", 1, BOND_VALFLAG_DEFAULT}, 146 { "default", 1, BOND_VALFLAG_DEFAULT},
95 { NULL, -1, 0} 147 { NULL, -1, 0}
96}; 148};
97 149
98static struct bond_opt_value bond_primary_reselect_tbl[] = { 150static const struct bond_opt_value bond_primary_reselect_tbl[] = {
99 { "always", BOND_PRI_RESELECT_ALWAYS, BOND_VALFLAG_DEFAULT}, 151 { "always", BOND_PRI_RESELECT_ALWAYS, BOND_VALFLAG_DEFAULT},
100 { "better", BOND_PRI_RESELECT_BETTER, 0}, 152 { "better", BOND_PRI_RESELECT_BETTER, 0},
101 { "failure", BOND_PRI_RESELECT_FAILURE, 0}, 153 { "failure", BOND_PRI_RESELECT_FAILURE, 0},
102 { NULL, -1}, 154 { NULL, -1},
103}; 155};
104 156
105static struct bond_opt_value bond_use_carrier_tbl[] = { 157static const struct bond_opt_value bond_use_carrier_tbl[] = {
106 { "off", 0, 0}, 158 { "off", 0, 0},
107 { "on", 1, BOND_VALFLAG_DEFAULT}, 159 { "on", 1, BOND_VALFLAG_DEFAULT},
108 { NULL, -1, 0} 160 { NULL, -1, 0}
109}; 161};
110 162
111static struct bond_opt_value bond_all_slaves_active_tbl[] = { 163static const struct bond_opt_value bond_all_slaves_active_tbl[] = {
112 { "off", 0, BOND_VALFLAG_DEFAULT}, 164 { "off", 0, BOND_VALFLAG_DEFAULT},
113 { "on", 1, 0}, 165 { "on", 1, 0},
114 { NULL, -1, 0} 166 { NULL, -1, 0}
115}; 167};
116 168
117static struct bond_opt_value bond_resend_igmp_tbl[] = { 169static const struct bond_opt_value bond_resend_igmp_tbl[] = {
118 { "off", 0, 0}, 170 { "off", 0, 0},
119 { "maxval", 255, BOND_VALFLAG_MAX}, 171 { "maxval", 255, BOND_VALFLAG_MAX},
120 { "default", 1, BOND_VALFLAG_DEFAULT}, 172 { "default", 1, BOND_VALFLAG_DEFAULT},
121 { NULL, -1, 0} 173 { NULL, -1, 0}
122}; 174};
123 175
124static struct bond_opt_value bond_lp_interval_tbl[] = { 176static const struct bond_opt_value bond_lp_interval_tbl[] = {
125 { "minval", 1, BOND_VALFLAG_MIN | BOND_VALFLAG_DEFAULT}, 177 { "minval", 1, BOND_VALFLAG_MIN | BOND_VALFLAG_DEFAULT},
126 { "maxval", INT_MAX, BOND_VALFLAG_MAX}, 178 { "maxval", INT_MAX, BOND_VALFLAG_MAX},
127}; 179};
128 180
129static struct bond_option bond_opts[] = { 181static const struct bond_option bond_opts[] = {
130 [BOND_OPT_MODE] = { 182 [BOND_OPT_MODE] = {
131 .id = BOND_OPT_MODE, 183 .id = BOND_OPT_MODE,
132 .name = "mode", 184 .name = "mode",
@@ -315,9 +367,9 @@ static struct bond_option bond_opts[] = {
315}; 367};
316 368
317/* Searches for a value in opt's values[] table */ 369/* Searches for a value in opt's values[] table */
318struct bond_opt_value *bond_opt_get_val(unsigned int option, u64 val) 370const struct bond_opt_value *bond_opt_get_val(unsigned int option, u64 val)
319{ 371{
320 struct bond_option *opt; 372 const struct bond_option *opt;
321 int i; 373 int i;
322 374
323 opt = bond_opt_get(option); 375 opt = bond_opt_get(option);
@@ -331,7 +383,7 @@ struct bond_opt_value *bond_opt_get_val(unsigned int option, u64 val)
331} 383}
332 384
333/* Searches for a value in opt's values[] table which matches the flagmask */ 385/* Searches for a value in opt's values[] table which matches the flagmask */
334static struct bond_opt_value *bond_opt_get_flags(const struct bond_option *opt, 386static const struct bond_opt_value *bond_opt_get_flags(const struct bond_option *opt,
335 u32 flagmask) 387 u32 flagmask)
336{ 388{
337 int i; 389 int i;
@@ -348,7 +400,7 @@ static struct bond_opt_value *bond_opt_get_flags(const struct bond_option *opt,
348 */ 400 */
349static bool bond_opt_check_range(const struct bond_option *opt, u64 val) 401static bool bond_opt_check_range(const struct bond_option *opt, u64 val)
350{ 402{
351 struct bond_opt_value *minval, *maxval; 403 const struct bond_opt_value *minval, *maxval;
352 404
353 minval = bond_opt_get_flags(opt, BOND_VALFLAG_MIN); 405 minval = bond_opt_get_flags(opt, BOND_VALFLAG_MIN);
354 maxval = bond_opt_get_flags(opt, BOND_VALFLAG_MAX); 406 maxval = bond_opt_get_flags(opt, BOND_VALFLAG_MAX);
@@ -368,11 +420,12 @@ static bool bond_opt_check_range(const struct bond_option *opt, u64 val)
368 * or the struct_opt_value that matched. It also strips the new line from 420 * or the struct_opt_value that matched. It also strips the new line from
369 * @val->string if it's present. 421 * @val->string if it's present.
370 */ 422 */
371struct bond_opt_value *bond_opt_parse(const struct bond_option *opt, 423const struct bond_opt_value *bond_opt_parse(const struct bond_option *opt,
372 struct bond_opt_value *val) 424 struct bond_opt_value *val)
373{ 425{
374 char *p, valstr[BOND_OPT_MAX_NAMELEN + 1] = { 0, }; 426 char *p, valstr[BOND_OPT_MAX_NAMELEN + 1] = { 0, };
375 struct bond_opt_value *tbl, *ret = NULL; 427 const struct bond_opt_value *tbl;
428 const struct bond_opt_value *ret = NULL;
376 bool checkval; 429 bool checkval;
377 int i, rv; 430 int i, rv;
378 431
@@ -576,7 +629,7 @@ int bond_opt_tryset_rtnl(struct bonding *bond, unsigned int option, char *buf)
576 * This function checks if option is valid and if so returns a pointer 629 * This function checks if option is valid and if so returns a pointer
577 * to its entry in the bond_opts[] option array. 630 * to its entry in the bond_opts[] option array.
578 */ 631 */
579struct bond_option *bond_opt_get(unsigned int option) 632const struct bond_option *bond_opt_get(unsigned int option)
580{ 633{
581 if (!BOND_OPT_VALID(option)) 634 if (!BOND_OPT_VALID(option))
582 return NULL; 635 return NULL;
@@ -622,8 +675,8 @@ struct net_device *bond_option_active_slave_get(struct bonding *bond)
622 return __bond_option_active_slave_get(bond, bond->curr_active_slave); 675 return __bond_option_active_slave_get(bond, bond->curr_active_slave);
623} 676}
624 677
625int bond_option_active_slave_set(struct bonding *bond, 678static int bond_option_active_slave_set(struct bonding *bond,
626 struct bond_opt_value *newval) 679 struct bond_opt_value *newval)
627{ 680{
628 char ifname[IFNAMSIZ] = { 0, }; 681 char ifname[IFNAMSIZ] = { 0, };
629 struct net_device *slave_dev; 682 struct net_device *slave_dev;
@@ -691,7 +744,8 @@ int bond_option_active_slave_set(struct bonding *bond,
691 return ret; 744 return ret;
692} 745}
693 746
694int bond_option_miimon_set(struct bonding *bond, struct bond_opt_value *newval) 747static int bond_option_miimon_set(struct bonding *bond,
748 struct bond_opt_value *newval)
695{ 749{
696 pr_info("%s: Setting MII monitoring interval to %llu\n", 750 pr_info("%s: Setting MII monitoring interval to %llu\n",
697 bond->dev->name, newval->value); 751 bond->dev->name, newval->value);
@@ -728,7 +782,8 @@ int bond_option_miimon_set(struct bonding *bond, struct bond_opt_value *newval)
728 return 0; 782 return 0;
729} 783}
730 784
731int bond_option_updelay_set(struct bonding *bond, struct bond_opt_value *newval) 785static int bond_option_updelay_set(struct bonding *bond,
786 struct bond_opt_value *newval)
732{ 787{
733 int value = newval->value; 788 int value = newval->value;
734 789
@@ -751,8 +806,8 @@ int bond_option_updelay_set(struct bonding *bond, struct bond_opt_value *newval)
751 return 0; 806 return 0;
752} 807}
753 808
754int bond_option_downdelay_set(struct bonding *bond, 809static int bond_option_downdelay_set(struct bonding *bond,
755 struct bond_opt_value *newval) 810 struct bond_opt_value *newval)
756{ 811{
757 int value = newval->value; 812 int value = newval->value;
758 813
@@ -775,8 +830,8 @@ int bond_option_downdelay_set(struct bonding *bond,
775 return 0; 830 return 0;
776} 831}
777 832
778int bond_option_use_carrier_set(struct bonding *bond, 833static int bond_option_use_carrier_set(struct bonding *bond,
779 struct bond_opt_value *newval) 834 struct bond_opt_value *newval)
780{ 835{
781 pr_info("%s: Setting use_carrier to %llu\n", 836 pr_info("%s: Setting use_carrier to %llu\n",
782 bond->dev->name, newval->value); 837 bond->dev->name, newval->value);
@@ -785,8 +840,8 @@ int bond_option_use_carrier_set(struct bonding *bond,
785 return 0; 840 return 0;
786} 841}
787 842
788int bond_option_arp_interval_set(struct bonding *bond, 843static int bond_option_arp_interval_set(struct bonding *bond,
789 struct bond_opt_value *newval) 844 struct bond_opt_value *newval)
790{ 845{
791 pr_info("%s: Setting ARP monitoring interval to %llu\n", 846 pr_info("%s: Setting ARP monitoring interval to %llu\n",
792 bond->dev->name, newval->value); 847 bond->dev->name, newval->value);
@@ -867,7 +922,7 @@ static int _bond_option_arp_ip_target_add(struct bonding *bond, __be32 target)
867 return 0; 922 return 0;
868} 923}
869 924
870int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target) 925static int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target)
871{ 926{
872 int ret; 927 int ret;
873 928
@@ -879,7 +934,7 @@ int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target)
879 return ret; 934 return ret;
880} 935}
881 936
882int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target) 937static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target)
883{ 938{
884 __be32 *targets = bond->params.arp_targets; 939 __be32 *targets = bond->params.arp_targets;
885 struct list_head *iter; 940 struct list_head *iter;
@@ -935,8 +990,8 @@ void bond_option_arp_ip_targets_clear(struct bonding *bond)
935 write_unlock_bh(&bond->lock); 990 write_unlock_bh(&bond->lock);
936} 991}
937 992
938int bond_option_arp_ip_targets_set(struct bonding *bond, 993static int bond_option_arp_ip_targets_set(struct bonding *bond,
939 struct bond_opt_value *newval) 994 struct bond_opt_value *newval)
940{ 995{
941 int ret = -EPERM; 996 int ret = -EPERM;
942 __be32 target; 997 __be32 target;
@@ -962,8 +1017,8 @@ int bond_option_arp_ip_targets_set(struct bonding *bond,
962 return ret; 1017 return ret;
963} 1018}
964 1019
965int bond_option_arp_validate_set(struct bonding *bond, 1020static int bond_option_arp_validate_set(struct bonding *bond,
966 struct bond_opt_value *newval) 1021 struct bond_opt_value *newval)
967{ 1022{
968 pr_info("%s: Setting arp_validate to %s (%llu)\n", 1023 pr_info("%s: Setting arp_validate to %s (%llu)\n",
969 bond->dev->name, newval->string, newval->value); 1024 bond->dev->name, newval->string, newval->value);
@@ -979,8 +1034,8 @@ int bond_option_arp_validate_set(struct bonding *bond,
979 return 0; 1034 return 0;
980} 1035}
981 1036
982int bond_option_arp_all_targets_set(struct bonding *bond, 1037static int bond_option_arp_all_targets_set(struct bonding *bond,
983 struct bond_opt_value *newval) 1038 struct bond_opt_value *newval)
984{ 1039{
985 pr_info("%s: Setting arp_all_targets to %s (%llu)\n", 1040 pr_info("%s: Setting arp_all_targets to %s (%llu)\n",
986 bond->dev->name, newval->string, newval->value); 1041 bond->dev->name, newval->string, newval->value);
@@ -989,7 +1044,8 @@ int bond_option_arp_all_targets_set(struct bonding *bond,
989 return 0; 1044 return 0;
990} 1045}
991 1046
992int bond_option_primary_set(struct bonding *bond, struct bond_opt_value *newval) 1047static int bond_option_primary_set(struct bonding *bond,
1048 struct bond_opt_value *newval)
993{ 1049{
994 char *p, *primary = newval->string; 1050 char *p, *primary = newval->string;
995 struct list_head *iter; 1051 struct list_head *iter;
@@ -1041,8 +1097,8 @@ out:
1041 return 0; 1097 return 0;
1042} 1098}
1043 1099
1044int bond_option_primary_reselect_set(struct bonding *bond, 1100static int bond_option_primary_reselect_set(struct bonding *bond,
1045 struct bond_opt_value *newval) 1101 struct bond_opt_value *newval)
1046{ 1102{
1047 pr_info("%s: Setting primary_reselect to %s (%llu)\n", 1103 pr_info("%s: Setting primary_reselect to %s (%llu)\n",
1048 bond->dev->name, newval->string, newval->value); 1104 bond->dev->name, newval->string, newval->value);
@@ -1057,8 +1113,8 @@ int bond_option_primary_reselect_set(struct bonding *bond,
1057 return 0; 1113 return 0;
1058} 1114}
1059 1115
1060int bond_option_fail_over_mac_set(struct bonding *bond, 1116static int bond_option_fail_over_mac_set(struct bonding *bond,
1061 struct bond_opt_value *newval) 1117 struct bond_opt_value *newval)
1062{ 1118{
1063 pr_info("%s: Setting fail_over_mac to %s (%llu)\n", 1119 pr_info("%s: Setting fail_over_mac to %s (%llu)\n",
1064 bond->dev->name, newval->string, newval->value); 1120 bond->dev->name, newval->string, newval->value);
@@ -1067,8 +1123,8 @@ int bond_option_fail_over_mac_set(struct bonding *bond,
1067 return 0; 1123 return 0;
1068} 1124}
1069 1125
1070int bond_option_xmit_hash_policy_set(struct bonding *bond, 1126static int bond_option_xmit_hash_policy_set(struct bonding *bond,
1071 struct bond_opt_value *newval) 1127 struct bond_opt_value *newval)
1072{ 1128{
1073 pr_info("%s: Setting xmit hash policy to %s (%llu)\n", 1129 pr_info("%s: Setting xmit hash policy to %s (%llu)\n",
1074 bond->dev->name, newval->string, newval->value); 1130 bond->dev->name, newval->string, newval->value);
@@ -1077,8 +1133,8 @@ int bond_option_xmit_hash_policy_set(struct bonding *bond,
1077 return 0; 1133 return 0;
1078} 1134}
1079 1135
1080int bond_option_resend_igmp_set(struct bonding *bond, 1136static int bond_option_resend_igmp_set(struct bonding *bond,
1081 struct bond_opt_value *newval) 1137 struct bond_opt_value *newval)
1082{ 1138{
1083 pr_info("%s: Setting resend_igmp to %llu\n", 1139 pr_info("%s: Setting resend_igmp to %llu\n",
1084 bond->dev->name, newval->value); 1140 bond->dev->name, newval->value);
@@ -1087,7 +1143,7 @@ int bond_option_resend_igmp_set(struct bonding *bond,
1087 return 0; 1143 return 0;
1088} 1144}
1089 1145
1090int bond_option_num_peer_notif_set(struct bonding *bond, 1146static int bond_option_num_peer_notif_set(struct bonding *bond,
1091 struct bond_opt_value *newval) 1147 struct bond_opt_value *newval)
1092{ 1148{
1093 bond->params.num_peer_notif = newval->value; 1149 bond->params.num_peer_notif = newval->value;
@@ -1095,8 +1151,8 @@ int bond_option_num_peer_notif_set(struct bonding *bond,
1095 return 0; 1151 return 0;
1096} 1152}
1097 1153
1098int bond_option_all_slaves_active_set(struct bonding *bond, 1154static int bond_option_all_slaves_active_set(struct bonding *bond,
1099 struct bond_opt_value *newval) 1155 struct bond_opt_value *newval)
1100{ 1156{
1101 struct list_head *iter; 1157 struct list_head *iter;
1102 struct slave *slave; 1158 struct slave *slave;
@@ -1116,8 +1172,8 @@ int bond_option_all_slaves_active_set(struct bonding *bond,
1116 return 0; 1172 return 0;
1117} 1173}
1118 1174
1119int bond_option_min_links_set(struct bonding *bond, 1175static int bond_option_min_links_set(struct bonding *bond,
1120 struct bond_opt_value *newval) 1176 struct bond_opt_value *newval)
1121{ 1177{
1122 pr_info("%s: Setting min links value to %llu\n", 1178 pr_info("%s: Setting min links value to %llu\n",
1123 bond->dev->name, newval->value); 1179 bond->dev->name, newval->value);
@@ -1126,15 +1182,16 @@ int bond_option_min_links_set(struct bonding *bond,
1126 return 0; 1182 return 0;
1127} 1183}
1128 1184
1129int bond_option_lp_interval_set(struct bonding *bond, 1185static int bond_option_lp_interval_set(struct bonding *bond,
1130 struct bond_opt_value *newval) 1186 struct bond_opt_value *newval)
1131{ 1187{
1132 bond->params.lp_interval = newval->value; 1188 bond->params.lp_interval = newval->value;
1133 1189
1134 return 0; 1190 return 0;
1135} 1191}
1136 1192
1137int bond_option_pps_set(struct bonding *bond, struct bond_opt_value *newval) 1193static int bond_option_pps_set(struct bonding *bond,
1194 struct bond_opt_value *newval)
1138{ 1195{
1139 bond->params.packets_per_slave = newval->value; 1196 bond->params.packets_per_slave = newval->value;
1140 if (newval->value > 0) { 1197 if (newval->value > 0) {
@@ -1151,8 +1208,8 @@ int bond_option_pps_set(struct bonding *bond, struct bond_opt_value *newval)
1151 return 0; 1208 return 0;
1152} 1209}
1153 1210
1154int bond_option_lacp_rate_set(struct bonding *bond, 1211static int bond_option_lacp_rate_set(struct bonding *bond,
1155 struct bond_opt_value *newval) 1212 struct bond_opt_value *newval)
1156{ 1213{
1157 pr_info("%s: Setting LACP rate to %s (%llu)\n", 1214 pr_info("%s: Setting LACP rate to %s (%llu)\n",
1158 bond->dev->name, newval->string, newval->value); 1215 bond->dev->name, newval->string, newval->value);
@@ -1162,8 +1219,8 @@ int bond_option_lacp_rate_set(struct bonding *bond,
1162 return 0; 1219 return 0;
1163} 1220}
1164 1221
1165int bond_option_ad_select_set(struct bonding *bond, 1222static int bond_option_ad_select_set(struct bonding *bond,
1166 struct bond_opt_value *newval) 1223 struct bond_opt_value *newval)
1167{ 1224{
1168 pr_info("%s: Setting ad_select to %s (%llu)\n", 1225 pr_info("%s: Setting ad_select to %s (%llu)\n",
1169 bond->dev->name, newval->string, newval->value); 1226 bond->dev->name, newval->string, newval->value);
@@ -1172,8 +1229,8 @@ int bond_option_ad_select_set(struct bonding *bond,
1172 return 0; 1229 return 0;
1173} 1230}
1174 1231
1175int bond_option_queue_id_set(struct bonding *bond, 1232static int bond_option_queue_id_set(struct bonding *bond,
1176 struct bond_opt_value *newval) 1233 struct bond_opt_value *newval)
1177{ 1234{
1178 struct slave *slave, *update_slave; 1235 struct slave *slave, *update_slave;
1179 struct net_device *sdev; 1236 struct net_device *sdev;
@@ -1233,7 +1290,8 @@ err_no_cmd:
1233 1290
1234} 1291}
1235 1292
1236int bond_option_slaves_set(struct bonding *bond, struct bond_opt_value *newval) 1293static int bond_option_slaves_set(struct bonding *bond,
1294 struct bond_opt_value *newval)
1237{ 1295{
1238 char command[IFNAMSIZ + 1] = { 0, }; 1296 char command[IFNAMSIZ + 1] = { 0, };
1239 struct net_device *dev; 1297 struct net_device *dev;
diff --git a/drivers/net/bonding/bond_options.h b/drivers/net/bonding/bond_options.h
index 433d37f6940b..6c5ba0ffc31c 100644
--- a/drivers/net/bonding/bond_options.h
+++ b/drivers/net/bonding/bond_options.h
@@ -81,8 +81,8 @@ struct bonding;
81 81
82struct bond_option { 82struct bond_option {
83 int id; 83 int id;
84 char *name; 84 const char *name;
85 char *desc; 85 const char *desc;
86 u32 flags; 86 u32 flags;
87 87
88 /* unsuppmodes is used to denote modes in which the option isn't 88 /* unsuppmodes is used to denote modes in which the option isn't
@@ -92,7 +92,7 @@ struct bond_option {
92 /* supported values which this option can have, can be a subset of 92 /* supported values which this option can have, can be a subset of
93 * BOND_OPTVAL_RANGE's value range 93 * BOND_OPTVAL_RANGE's value range
94 */ 94 */
95 struct bond_opt_value *values; 95 const struct bond_opt_value *values;
96 96
97 int (*set)(struct bonding *bond, struct bond_opt_value *val); 97 int (*set)(struct bonding *bond, struct bond_opt_value *val);
98}; 98};
@@ -100,10 +100,10 @@ struct bond_option {
100int __bond_opt_set(struct bonding *bond, unsigned int option, 100int __bond_opt_set(struct bonding *bond, unsigned int option,
101 struct bond_opt_value *val); 101 struct bond_opt_value *val);
102int bond_opt_tryset_rtnl(struct bonding *bond, unsigned int option, char *buf); 102int bond_opt_tryset_rtnl(struct bonding *bond, unsigned int option, char *buf);
103struct bond_opt_value *bond_opt_parse(const struct bond_option *opt, 103const struct bond_opt_value *bond_opt_parse(const struct bond_option *opt,
104 struct bond_opt_value *val); 104 struct bond_opt_value *val);
105struct bond_option *bond_opt_get(unsigned int option); 105const struct bond_option *bond_opt_get(unsigned int option);
106struct bond_opt_value *bond_opt_get_val(unsigned int option, u64 val); 106const struct bond_opt_value *bond_opt_get_val(unsigned int option, u64 val);
107 107
108/* This helper is used to initialize a bond_opt_value structure for parameter 108/* This helper is used to initialize a bond_opt_value structure for parameter
109 * passing. There should be either a valid string or value, but not both. 109 * passing. There should be either a valid string or value, but not both.
@@ -122,49 +122,6 @@ static inline void __bond_opt_init(struct bond_opt_value *optval,
122#define bond_opt_initval(optval, value) __bond_opt_init(optval, NULL, value) 122#define bond_opt_initval(optval, value) __bond_opt_init(optval, NULL, value)
123#define bond_opt_initstr(optval, str) __bond_opt_init(optval, str, ULLONG_MAX) 123#define bond_opt_initstr(optval, str) __bond_opt_init(optval, str, ULLONG_MAX)
124 124
125int bond_option_mode_set(struct bonding *bond, struct bond_opt_value *newval);
126int bond_option_pps_set(struct bonding *bond, struct bond_opt_value *newval);
127int bond_option_xmit_hash_policy_set(struct bonding *bond,
128 struct bond_opt_value *newval);
129int bond_option_arp_validate_set(struct bonding *bond,
130 struct bond_opt_value *newval);
131int bond_option_arp_all_targets_set(struct bonding *bond,
132 struct bond_opt_value *newval);
133int bond_option_fail_over_mac_set(struct bonding *bond,
134 struct bond_opt_value *newval);
135int bond_option_arp_interval_set(struct bonding *bond,
136 struct bond_opt_value *newval);
137int bond_option_arp_ip_targets_set(struct bonding *bond,
138 struct bond_opt_value *newval);
139void bond_option_arp_ip_targets_clear(struct bonding *bond); 125void bond_option_arp_ip_targets_clear(struct bonding *bond);
140int bond_option_downdelay_set(struct bonding *bond, 126
141 struct bond_opt_value *newval);
142int bond_option_updelay_set(struct bonding *bond,
143 struct bond_opt_value *newval);
144int bond_option_lacp_rate_set(struct bonding *bond,
145 struct bond_opt_value *newval);
146int bond_option_min_links_set(struct bonding *bond,
147 struct bond_opt_value *newval);
148int bond_option_ad_select_set(struct bonding *bond,
149 struct bond_opt_value *newval);
150int bond_option_num_peer_notif_set(struct bonding *bond,
151 struct bond_opt_value *newval);
152int bond_option_miimon_set(struct bonding *bond, struct bond_opt_value *newval);
153int bond_option_primary_set(struct bonding *bond,
154 struct bond_opt_value *newval);
155int bond_option_primary_reselect_set(struct bonding *bond,
156 struct bond_opt_value *newval);
157int bond_option_use_carrier_set(struct bonding *bond,
158 struct bond_opt_value *newval);
159int bond_option_active_slave_set(struct bonding *bond,
160 struct bond_opt_value *newval);
161int bond_option_queue_id_set(struct bonding *bond,
162 struct bond_opt_value *newval);
163int bond_option_all_slaves_active_set(struct bonding *bond,
164 struct bond_opt_value *newval);
165int bond_option_resend_igmp_set(struct bonding *bond,
166 struct bond_opt_value *newval);
167int bond_option_lp_interval_set(struct bonding *bond,
168 struct bond_opt_value *newval);
169int bond_option_slaves_set(struct bonding *bond, struct bond_opt_value *newval);
170#endif /* _BOND_OPTIONS_H */ 127#endif /* _BOND_OPTIONS_H */
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 225ee696db05..0e8b268da0a0 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -220,7 +220,7 @@ static ssize_t bonding_show_mode(struct device *d,
220 struct device_attribute *attr, char *buf) 220 struct device_attribute *attr, char *buf)
221{ 221{
222 struct bonding *bond = to_bond(d); 222 struct bonding *bond = to_bond(d);
223 struct bond_opt_value *val; 223 const struct bond_opt_value *val;
224 224
225 val = bond_opt_get_val(BOND_OPT_MODE, bond->params.mode); 225 val = bond_opt_get_val(BOND_OPT_MODE, bond->params.mode);
226 226
@@ -251,7 +251,7 @@ static ssize_t bonding_show_xmit_hash(struct device *d,
251 char *buf) 251 char *buf)
252{ 252{
253 struct bonding *bond = to_bond(d); 253 struct bonding *bond = to_bond(d);
254 struct bond_opt_value *val; 254 const struct bond_opt_value *val;
255 255
256 val = bond_opt_get_val(BOND_OPT_XMIT_HASH, bond->params.xmit_policy); 256 val = bond_opt_get_val(BOND_OPT_XMIT_HASH, bond->params.xmit_policy);
257 257
@@ -282,7 +282,7 @@ static ssize_t bonding_show_arp_validate(struct device *d,
282 char *buf) 282 char *buf)
283{ 283{
284 struct bonding *bond = to_bond(d); 284 struct bonding *bond = to_bond(d);
285 struct bond_opt_value *val; 285 const struct bond_opt_value *val;
286 286
287 val = bond_opt_get_val(BOND_OPT_ARP_VALIDATE, 287 val = bond_opt_get_val(BOND_OPT_ARP_VALIDATE,
288 bond->params.arp_validate); 288 bond->params.arp_validate);
@@ -314,7 +314,7 @@ static ssize_t bonding_show_arp_all_targets(struct device *d,
314 char *buf) 314 char *buf)
315{ 315{
316 struct bonding *bond = to_bond(d); 316 struct bonding *bond = to_bond(d);
317 struct bond_opt_value *val; 317 const struct bond_opt_value *val;
318 318
319 val = bond_opt_get_val(BOND_OPT_ARP_ALL_TARGETS, 319 val = bond_opt_get_val(BOND_OPT_ARP_ALL_TARGETS,
320 bond->params.arp_all_targets); 320 bond->params.arp_all_targets);
@@ -348,7 +348,7 @@ static ssize_t bonding_show_fail_over_mac(struct device *d,
348 char *buf) 348 char *buf)
349{ 349{
350 struct bonding *bond = to_bond(d); 350 struct bonding *bond = to_bond(d);
351 struct bond_opt_value *val; 351 const struct bond_opt_value *val;
352 352
353 val = bond_opt_get_val(BOND_OPT_FAIL_OVER_MAC, 353 val = bond_opt_get_val(BOND_OPT_FAIL_OVER_MAC,
354 bond->params.fail_over_mac); 354 bond->params.fail_over_mac);
@@ -505,7 +505,7 @@ static ssize_t bonding_show_lacp(struct device *d,
505 char *buf) 505 char *buf)
506{ 506{
507 struct bonding *bond = to_bond(d); 507 struct bonding *bond = to_bond(d);
508 struct bond_opt_value *val; 508 const struct bond_opt_value *val;
509 509
510 val = bond_opt_get_val(BOND_OPT_LACP_RATE, bond->params.lacp_fast); 510 val = bond_opt_get_val(BOND_OPT_LACP_RATE, bond->params.lacp_fast);
511 511
@@ -558,7 +558,7 @@ static ssize_t bonding_show_ad_select(struct device *d,
558 char *buf) 558 char *buf)
559{ 559{
560 struct bonding *bond = to_bond(d); 560 struct bonding *bond = to_bond(d);
561 struct bond_opt_value *val; 561 const struct bond_opt_value *val;
562 562
563 val = bond_opt_get_val(BOND_OPT_AD_SELECT, bond->params.ad_select); 563 val = bond_opt_get_val(BOND_OPT_AD_SELECT, bond->params.ad_select);
564 564
@@ -686,7 +686,7 @@ static ssize_t bonding_show_primary_reselect(struct device *d,
686 char *buf) 686 char *buf)
687{ 687{
688 struct bonding *bond = to_bond(d); 688 struct bonding *bond = to_bond(d);
689 struct bond_opt_value *val; 689 const struct bond_opt_value *val;
690 690
691 val = bond_opt_get_val(BOND_OPT_PRIMARY_RESELECT, 691 val = bond_opt_get_val(BOND_OPT_PRIMARY_RESELECT,
692 bond->params.primary_reselect); 692 bond->params.primary_reselect);
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 1680fd235659..0896f1db24db 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -507,8 +507,6 @@ void bond_setup(struct net_device *bond_dev);
507unsigned int bond_get_num_tx_queues(void); 507unsigned int bond_get_num_tx_queues(void);
508int bond_netlink_init(void); 508int bond_netlink_init(void);
509void bond_netlink_fini(void); 509void bond_netlink_fini(void);
510int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target);
511int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target);
512struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond); 510struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond);
513struct net_device *bond_option_active_slave_get(struct bonding *bond); 511struct net_device *bond_option_active_slave_get(struct bonding *bond);
514const char *bond_slave_link_status(s8 link); 512const char *bond_slave_link_status(s8 link);