diff options
Diffstat (limited to 'drivers/net/bonding/bonding.h')
-rw-r--r-- | drivers/net/bonding/bonding.h | 113 |
1 files changed, 53 insertions, 60 deletions
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index 03cf3fd14490..77a07a12e77f 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h | |||
@@ -58,6 +58,11 @@ | |||
58 | #define TX_QUEUE_OVERRIDE(mode) \ | 58 | #define TX_QUEUE_OVERRIDE(mode) \ |
59 | (((mode) == BOND_MODE_ACTIVEBACKUP) || \ | 59 | (((mode) == BOND_MODE_ACTIVEBACKUP) || \ |
60 | ((mode) == BOND_MODE_ROUNDROBIN)) | 60 | ((mode) == BOND_MODE_ROUNDROBIN)) |
61 | |||
62 | #define BOND_MODE_IS_LB(mode) \ | ||
63 | (((mode) == BOND_MODE_TLB) || \ | ||
64 | ((mode) == BOND_MODE_ALB)) | ||
65 | |||
61 | /* | 66 | /* |
62 | * Less bad way to call ioctl from within the kernel; this needs to be | 67 | * Less bad way to call ioctl from within the kernel; this needs to be |
63 | * done some other way to get the call out of interrupt context. | 68 | * done some other way to get the call out of interrupt context. |
@@ -72,63 +77,37 @@ | |||
72 | res; }) | 77 | res; }) |
73 | 78 | ||
74 | /* slave list primitives */ | 79 | /* slave list primitives */ |
75 | #define bond_to_slave(ptr) list_entry(ptr, struct slave, list) | 80 | #define bond_slave_list(bond) (&(bond)->dev->adj_list.lower) |
81 | |||
82 | #define bond_has_slaves(bond) !list_empty(bond_slave_list(bond)) | ||
76 | 83 | ||
77 | /* IMPORTANT: bond_first/last_slave can return NULL in case of an empty list */ | 84 | /* IMPORTANT: bond_first/last_slave can return NULL in case of an empty list */ |
78 | #define bond_first_slave(bond) \ | 85 | #define bond_first_slave(bond) \ |
79 | list_first_entry_or_null(&(bond)->slave_list, struct slave, list) | 86 | (bond_has_slaves(bond) ? \ |
87 | netdev_adjacent_get_private(bond_slave_list(bond)->next) : \ | ||
88 | NULL) | ||
80 | #define bond_last_slave(bond) \ | 89 | #define bond_last_slave(bond) \ |
81 | (list_empty(&(bond)->slave_list) ? NULL : \ | 90 | (bond_has_slaves(bond) ? \ |
82 | bond_to_slave((bond)->slave_list.prev)) | 91 | netdev_adjacent_get_private(bond_slave_list(bond)->prev) : \ |
92 | NULL) | ||
83 | 93 | ||
84 | #define bond_is_first_slave(bond, pos) ((pos)->list.prev == &(bond)->slave_list) | 94 | #define bond_is_first_slave(bond, pos) (pos == bond_first_slave(bond)) |
85 | #define bond_is_last_slave(bond, pos) ((pos)->list.next == &(bond)->slave_list) | 95 | #define bond_is_last_slave(bond, pos) (pos == bond_last_slave(bond)) |
86 | |||
87 | /* Since bond_first/last_slave can return NULL, these can return NULL too */ | ||
88 | #define bond_next_slave(bond, pos) \ | ||
89 | (bond_is_last_slave(bond, pos) ? bond_first_slave(bond) : \ | ||
90 | bond_to_slave((pos)->list.next)) | ||
91 | |||
92 | #define bond_prev_slave(bond, pos) \ | ||
93 | (bond_is_first_slave(bond, pos) ? bond_last_slave(bond) : \ | ||
94 | bond_to_slave((pos)->list.prev)) | ||
95 | |||
96 | /** | ||
97 | * bond_for_each_slave_from - iterate the slaves list from a starting point | ||
98 | * @bond: the bond holding this list. | ||
99 | * @pos: current slave. | ||
100 | * @cnt: counter for max number of moves | ||
101 | * @start: starting point. | ||
102 | * | ||
103 | * Caller must hold bond->lock | ||
104 | */ | ||
105 | #define bond_for_each_slave_from(bond, pos, cnt, start) \ | ||
106 | for (cnt = 0, pos = start; pos && cnt < (bond)->slave_cnt; \ | ||
107 | cnt++, pos = bond_next_slave(bond, pos)) | ||
108 | 96 | ||
109 | /** | 97 | /** |
110 | * bond_for_each_slave - iterate over all slaves | 98 | * bond_for_each_slave - iterate over all slaves |
111 | * @bond: the bond holding this list | 99 | * @bond: the bond holding this list |
112 | * @pos: current slave | 100 | * @pos: current slave |
101 | * @iter: list_head * iterator | ||
113 | * | 102 | * |
114 | * Caller must hold bond->lock | 103 | * Caller must hold bond->lock |
115 | */ | 104 | */ |
116 | #define bond_for_each_slave(bond, pos) \ | 105 | #define bond_for_each_slave(bond, pos, iter) \ |
117 | list_for_each_entry(pos, &(bond)->slave_list, list) | 106 | netdev_for_each_lower_private((bond)->dev, pos, iter) |
118 | 107 | ||
119 | /* Caller must have rcu_read_lock */ | 108 | /* Caller must have rcu_read_lock */ |
120 | #define bond_for_each_slave_rcu(bond, pos) \ | 109 | #define bond_for_each_slave_rcu(bond, pos, iter) \ |
121 | list_for_each_entry_rcu(pos, &(bond)->slave_list, list) | 110 | netdev_for_each_lower_private_rcu((bond)->dev, pos, iter) |
122 | |||
123 | /** | ||
124 | * bond_for_each_slave_reverse - iterate in reverse from a given position | ||
125 | * @bond: the bond holding this list | ||
126 | * @pos: slave to continue from | ||
127 | * | ||
128 | * Caller must hold bond->lock | ||
129 | */ | ||
130 | #define bond_for_each_slave_continue_reverse(bond, pos) \ | ||
131 | list_for_each_entry_continue_reverse(pos, &(bond)->slave_list, list) | ||
132 | 111 | ||
133 | #ifdef CONFIG_NET_POLL_CONTROLLER | 112 | #ifdef CONFIG_NET_POLL_CONTROLLER |
134 | extern atomic_t netpoll_block_tx; | 113 | extern atomic_t netpoll_block_tx; |
@@ -177,6 +156,7 @@ struct bond_params { | |||
177 | int all_slaves_active; | 156 | int all_slaves_active; |
178 | int resend_igmp; | 157 | int resend_igmp; |
179 | int lp_interval; | 158 | int lp_interval; |
159 | int packets_per_slave; | ||
180 | }; | 160 | }; |
181 | 161 | ||
182 | struct bond_parm_tbl { | 162 | struct bond_parm_tbl { |
@@ -188,7 +168,6 @@ struct bond_parm_tbl { | |||
188 | 168 | ||
189 | struct slave { | 169 | struct slave { |
190 | struct net_device *dev; /* first - useful for panic debug */ | 170 | struct net_device *dev; /* first - useful for panic debug */ |
191 | struct list_head list; | ||
192 | struct bonding *bond; /* our master */ | 171 | struct bonding *bond; /* our master */ |
193 | int delay; | 172 | int delay; |
194 | unsigned long jiffies; | 173 | unsigned long jiffies; |
@@ -228,7 +207,6 @@ struct slave { | |||
228 | */ | 207 | */ |
229 | struct bonding { | 208 | struct bonding { |
230 | struct net_device *dev; /* first - useful for panic debug */ | 209 | struct net_device *dev; /* first - useful for panic debug */ |
231 | struct list_head slave_list; | ||
232 | struct slave *curr_active_slave; | 210 | struct slave *curr_active_slave; |
233 | struct slave *current_arp_slave; | 211 | struct slave *current_arp_slave; |
234 | struct slave *primary_slave; | 212 | struct slave *primary_slave; |
@@ -245,8 +223,7 @@ struct bonding { | |||
245 | char proc_file_name[IFNAMSIZ]; | 223 | char proc_file_name[IFNAMSIZ]; |
246 | #endif /* CONFIG_PROC_FS */ | 224 | #endif /* CONFIG_PROC_FS */ |
247 | struct list_head bond_list; | 225 | struct list_head bond_list; |
248 | int (*xmit_hash_policy)(struct sk_buff *, int); | 226 | u32 rr_tx_counter; |
249 | u16 rr_tx_counter; | ||
250 | struct ad_bond_info ad_info; | 227 | struct ad_bond_info ad_info; |
251 | struct alb_bond_info alb_info; | 228 | struct alb_bond_info alb_info; |
252 | struct bond_params params; | 229 | struct bond_params params; |
@@ -276,13 +253,7 @@ struct bonding { | |||
276 | static inline struct slave *bond_get_slave_by_dev(struct bonding *bond, | 253 | static inline struct slave *bond_get_slave_by_dev(struct bonding *bond, |
277 | struct net_device *slave_dev) | 254 | struct net_device *slave_dev) |
278 | { | 255 | { |
279 | struct slave *slave = NULL; | 256 | return netdev_lower_dev_get_private(bond->dev, slave_dev); |
280 | |||
281 | bond_for_each_slave(bond, slave) | ||
282 | if (slave->dev == slave_dev) | ||
283 | return slave; | ||
284 | |||
285 | return NULL; | ||
286 | } | 257 | } |
287 | 258 | ||
288 | static inline struct bonding *bond_get_bond_by_slave(struct slave *slave) | 259 | static inline struct bonding *bond_get_bond_by_slave(struct slave *slave) |
@@ -294,8 +265,7 @@ static inline struct bonding *bond_get_bond_by_slave(struct slave *slave) | |||
294 | 265 | ||
295 | static inline bool bond_is_lb(const struct bonding *bond) | 266 | static inline bool bond_is_lb(const struct bonding *bond) |
296 | { | 267 | { |
297 | return (bond->params.mode == BOND_MODE_TLB || | 268 | return BOND_MODE_IS_LB(bond->params.mode); |
298 | bond->params.mode == BOND_MODE_ALB); | ||
299 | } | 269 | } |
300 | 270 | ||
301 | static inline void bond_set_active_slave(struct slave *slave) | 271 | static inline void bond_set_active_slave(struct slave *slave) |
@@ -432,21 +402,18 @@ static inline bool slave_can_tx(struct slave *slave) | |||
432 | struct bond_net; | 402 | struct bond_net; |
433 | 403 | ||
434 | int bond_arp_rcv(const struct sk_buff *skb, struct bonding *bond, struct slave *slave); | 404 | int bond_arp_rcv(const struct sk_buff *skb, struct bonding *bond, struct slave *slave); |
435 | struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr); | ||
436 | int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev); | 405 | int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev); |
437 | void bond_xmit_slave_id(struct bonding *bond, struct sk_buff *skb, int slave_id); | 406 | void bond_xmit_slave_id(struct bonding *bond, struct sk_buff *skb, int slave_id); |
438 | int bond_create(struct net *net, const char *name); | 407 | int bond_create(struct net *net, const char *name); |
439 | int bond_create_sysfs(struct bond_net *net); | 408 | int bond_create_sysfs(struct bond_net *net); |
440 | void bond_destroy_sysfs(struct bond_net *net); | 409 | void bond_destroy_sysfs(struct bond_net *net); |
441 | void bond_prepare_sysfs_group(struct bonding *bond); | 410 | void bond_prepare_sysfs_group(struct bonding *bond); |
442 | int bond_create_slave_symlinks(struct net_device *master, struct net_device *slave); | ||
443 | void bond_destroy_slave_symlinks(struct net_device *master, struct net_device *slave); | ||
444 | int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev); | 411 | int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev); |
445 | int bond_release(struct net_device *bond_dev, struct net_device *slave_dev); | 412 | int bond_release(struct net_device *bond_dev, struct net_device *slave_dev); |
446 | void bond_mii_monitor(struct work_struct *); | 413 | void bond_mii_monitor(struct work_struct *); |
447 | void bond_loadbalance_arp_mon(struct work_struct *); | 414 | void bond_loadbalance_arp_mon(struct work_struct *); |
448 | void bond_activebackup_arp_mon(struct work_struct *); | 415 | void bond_activebackup_arp_mon(struct work_struct *); |
449 | void bond_set_mode_ops(struct bonding *bond, int mode); | 416 | int bond_xmit_hash(struct bonding *bond, struct sk_buff *skb, int count); |
450 | int bond_parse_parm(const char *mode_arg, const struct bond_parm_tbl *tbl); | 417 | int bond_parse_parm(const char *mode_arg, const struct bond_parm_tbl *tbl); |
451 | void bond_select_active_slave(struct bonding *bond); | 418 | void bond_select_active_slave(struct bonding *bond); |
452 | void bond_change_active_slave(struct bonding *bond, struct slave *new_active); | 419 | void bond_change_active_slave(struct bonding *bond, struct slave *new_active); |
@@ -456,6 +423,14 @@ void bond_debug_register(struct bonding *bond); | |||
456 | void bond_debug_unregister(struct bonding *bond); | 423 | void bond_debug_unregister(struct bonding *bond); |
457 | void bond_debug_reregister(struct bonding *bond); | 424 | void bond_debug_reregister(struct bonding *bond); |
458 | const char *bond_mode_name(int mode); | 425 | const char *bond_mode_name(int mode); |
426 | void bond_setup(struct net_device *bond_dev); | ||
427 | unsigned int bond_get_num_tx_queues(void); | ||
428 | int bond_netlink_init(void); | ||
429 | void bond_netlink_fini(void); | ||
430 | int bond_option_mode_set(struct bonding *bond, int mode); | ||
431 | int bond_option_active_slave_set(struct bonding *bond, struct net_device *slave_dev); | ||
432 | struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond); | ||
433 | struct net_device *bond_option_active_slave_get(struct bonding *bond); | ||
459 | 434 | ||
460 | struct bond_net { | 435 | struct bond_net { |
461 | struct net * net; /* Associated network namespace */ | 436 | struct net * net; /* Associated network namespace */ |
@@ -492,9 +467,24 @@ static inline void bond_destroy_proc_dir(struct bond_net *bn) | |||
492 | static inline struct slave *bond_slave_has_mac(struct bonding *bond, | 467 | static inline struct slave *bond_slave_has_mac(struct bonding *bond, |
493 | const u8 *mac) | 468 | const u8 *mac) |
494 | { | 469 | { |
470 | struct list_head *iter; | ||
495 | struct slave *tmp; | 471 | struct slave *tmp; |
496 | 472 | ||
497 | bond_for_each_slave(bond, tmp) | 473 | bond_for_each_slave(bond, tmp, iter) |
474 | if (ether_addr_equal_64bits(mac, tmp->dev->dev_addr)) | ||
475 | return tmp; | ||
476 | |||
477 | return NULL; | ||
478 | } | ||
479 | |||
480 | /* Caller must hold rcu_read_lock() for read */ | ||
481 | static inline struct slave *bond_slave_has_mac_rcu(struct bonding *bond, | ||
482 | const u8 *mac) | ||
483 | { | ||
484 | struct list_head *iter; | ||
485 | struct slave *tmp; | ||
486 | |||
487 | bond_for_each_slave_rcu(bond, tmp, iter) | ||
498 | if (ether_addr_equal_64bits(mac, tmp->dev->dev_addr)) | 488 | if (ether_addr_equal_64bits(mac, tmp->dev->dev_addr)) |
499 | return tmp; | 489 | return tmp; |
500 | 490 | ||
@@ -528,4 +518,7 @@ extern const struct bond_parm_tbl fail_over_mac_tbl[]; | |||
528 | extern const struct bond_parm_tbl pri_reselect_tbl[]; | 518 | extern const struct bond_parm_tbl pri_reselect_tbl[]; |
529 | extern struct bond_parm_tbl ad_select_tbl[]; | 519 | extern struct bond_parm_tbl ad_select_tbl[]; |
530 | 520 | ||
521 | /* exported from bond_netlink.c */ | ||
522 | extern struct rtnl_link_ops bond_link_ops; | ||
523 | |||
531 | #endif /* _LINUX_BONDING_H */ | 524 | #endif /* _LINUX_BONDING_H */ |