aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding/bonding.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/bonding/bonding.h')
-rw-r--r--drivers/net/bonding/bonding.h113
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
134extern atomic_t netpoll_block_tx; 113extern 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
182struct bond_parm_tbl { 162struct bond_parm_tbl {
@@ -188,7 +168,6 @@ struct bond_parm_tbl {
188 168
189struct slave { 169struct 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 */
229struct bonding { 208struct 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 {
276static inline struct slave *bond_get_slave_by_dev(struct bonding *bond, 253static 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
288static inline struct bonding *bond_get_bond_by_slave(struct slave *slave) 259static 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
295static inline bool bond_is_lb(const struct bonding *bond) 266static 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
301static inline void bond_set_active_slave(struct slave *slave) 271static inline void bond_set_active_slave(struct slave *slave)
@@ -432,21 +402,18 @@ static inline bool slave_can_tx(struct slave *slave)
432struct bond_net; 402struct bond_net;
433 403
434int bond_arp_rcv(const struct sk_buff *skb, struct bonding *bond, struct slave *slave); 404int bond_arp_rcv(const struct sk_buff *skb, struct bonding *bond, struct slave *slave);
435struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr);
436int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev); 405int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev);
437void bond_xmit_slave_id(struct bonding *bond, struct sk_buff *skb, int slave_id); 406void bond_xmit_slave_id(struct bonding *bond, struct sk_buff *skb, int slave_id);
438int bond_create(struct net *net, const char *name); 407int bond_create(struct net *net, const char *name);
439int bond_create_sysfs(struct bond_net *net); 408int bond_create_sysfs(struct bond_net *net);
440void bond_destroy_sysfs(struct bond_net *net); 409void bond_destroy_sysfs(struct bond_net *net);
441void bond_prepare_sysfs_group(struct bonding *bond); 410void bond_prepare_sysfs_group(struct bonding *bond);
442int bond_create_slave_symlinks(struct net_device *master, struct net_device *slave);
443void bond_destroy_slave_symlinks(struct net_device *master, struct net_device *slave);
444int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev); 411int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev);
445int bond_release(struct net_device *bond_dev, struct net_device *slave_dev); 412int bond_release(struct net_device *bond_dev, struct net_device *slave_dev);
446void bond_mii_monitor(struct work_struct *); 413void bond_mii_monitor(struct work_struct *);
447void bond_loadbalance_arp_mon(struct work_struct *); 414void bond_loadbalance_arp_mon(struct work_struct *);
448void bond_activebackup_arp_mon(struct work_struct *); 415void bond_activebackup_arp_mon(struct work_struct *);
449void bond_set_mode_ops(struct bonding *bond, int mode); 416int bond_xmit_hash(struct bonding *bond, struct sk_buff *skb, int count);
450int bond_parse_parm(const char *mode_arg, const struct bond_parm_tbl *tbl); 417int bond_parse_parm(const char *mode_arg, const struct bond_parm_tbl *tbl);
451void bond_select_active_slave(struct bonding *bond); 418void bond_select_active_slave(struct bonding *bond);
452void bond_change_active_slave(struct bonding *bond, struct slave *new_active); 419void bond_change_active_slave(struct bonding *bond, struct slave *new_active);
@@ -456,6 +423,14 @@ void bond_debug_register(struct bonding *bond);
456void bond_debug_unregister(struct bonding *bond); 423void bond_debug_unregister(struct bonding *bond);
457void bond_debug_reregister(struct bonding *bond); 424void bond_debug_reregister(struct bonding *bond);
458const char *bond_mode_name(int mode); 425const char *bond_mode_name(int mode);
426void bond_setup(struct net_device *bond_dev);
427unsigned int bond_get_num_tx_queues(void);
428int bond_netlink_init(void);
429void bond_netlink_fini(void);
430int bond_option_mode_set(struct bonding *bond, int mode);
431int bond_option_active_slave_set(struct bonding *bond, struct net_device *slave_dev);
432struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond);
433struct net_device *bond_option_active_slave_get(struct bonding *bond);
459 434
460struct bond_net { 435struct 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)
492static inline struct slave *bond_slave_has_mac(struct bonding *bond, 467static 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 */
481static 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[];
528extern const struct bond_parm_tbl pri_reselect_tbl[]; 518extern const struct bond_parm_tbl pri_reselect_tbl[];
529extern struct bond_parm_tbl ad_select_tbl[]; 519extern struct bond_parm_tbl ad_select_tbl[];
530 520
521/* exported from bond_netlink.c */
522extern struct rtnl_link_ops bond_link_ops;
523
531#endif /* _LINUX_BONDING_H */ 524#endif /* _LINUX_BONDING_H */