15 #ifndef _LINUX_BONDING_H
16 #define _LINUX_BONDING_H
22 #include <linux/in6.h>
28 #define DRV_VERSION "3.7.1"
29 #define DRV_RELDATE "April 27, 2011"
30 #define DRV_NAME "bonding"
31 #define DRV_DESCRIPTION "Ethernet Channel Bonding Driver"
33 #define bond_version DRV_DESCRIPTION ": v" DRV_VERSION " (" DRV_RELDATE ")\n"
35 #define BOND_MAX_ARP_TARGETS 16
38 ((((dev)->flags & IFF_UP) == IFF_UP) && \
39 netif_running(dev) && \
40 netif_carrier_ok(dev))
45 #define SLAVE_IS_OK(slave) \
46 (((slave)->dev->flags & IFF_UP) && \
47 netif_running((slave)->dev) && \
48 ((slave)->link == BOND_LINK_UP) && \
49 bond_is_active_slave(slave))
52 #define USES_PRIMARY(mode) \
53 (((mode) == BOND_MODE_ACTIVEBACKUP) || \
54 ((mode) == BOND_MODE_TLB) || \
55 ((mode) == BOND_MODE_ALB))
57 #define TX_QUEUE_OVERRIDE(mode) \
58 (((mode) == BOND_MODE_ACTIVEBACKUP) || \
59 ((mode) == BOND_MODE_ROUNDROBIN))
65 #define IOCTL(dev, arg, cmd) ({ \
67 mm_segment_t fs = get_fs(); \
69 res = ioctl(dev, arg, cmd); \
82 #define bond_for_each_slave_from(bond, pos, cnt, start) \
83 for (cnt = 0, pos = start; \
84 cnt < (bond)->slave_cnt; \
85 cnt++, pos = (pos)->next)
97 #define bond_for_each_slave_from_to(bond, pos, cnt, start, stop) \
98 for (cnt = 0, pos = start; \
99 ((cnt < (bond)->slave_cnt) && (pos != (stop)->next)); \
100 cnt++, pos = (pos)->next)
110 #define bond_for_each_slave(bond, pos, cnt) \
111 bond_for_each_slave_from(bond, pos, cnt, (bond)->first_slave)
114 #ifdef CONFIG_NET_POLL_CONTROLLER
129 if (
unlikely(netpoll_tx_running(dev)))
134 #define block_netpoll_tx()
135 #define unblock_netpoll_tx()
136 #define is_netpoll_tx_blocked(dev) (0)
166 #define BOND_MAX_MODENAME_LEN 20
194 #ifdef CONFIG_NET_POLL_CONTROLLER
202 #define BOND_LINK_NOCHANGE -1
228 #ifdef CONFIG_PROC_FS
246 #ifdef CONFIG_DEBUG_FS
252 static inline bool bond_vlan_used(
struct bonding *bond)
257 #define bond_slave_get_rcu(dev) \
258 ((struct slave *) rcu_dereference(dev->rx_handler_data))
272 if (slave->
dev == slave_dev) {
282 if (!slave || !slave->
dev->master) {
286 return netdev_priv(slave->
dev->master);
289 static inline bool bond_is_lb(
const struct bonding *bond)
295 static inline void bond_set_active_slave(
struct slave *slave)
300 static inline void bond_set_backup_slave(
struct slave *slave)
305 static inline int bond_slave_state(
struct slave *slave)
310 static inline bool bond_is_active_slave(
struct slave *slave)
312 return !bond_slave_state(slave);
315 #define BOND_PRI_RESELECT_ALWAYS 0
316 #define BOND_PRI_RESELECT_BETTER 1
317 #define BOND_PRI_RESELECT_FAILURE 2
319 #define BOND_FOM_NONE 0
320 #define BOND_FOM_ACTIVE 1
321 #define BOND_FOM_FOLLOW 2
323 #define BOND_ARP_VALIDATE_NONE 0
324 #define BOND_ARP_VALIDATE_ACTIVE (1 << BOND_STATE_ACTIVE)
325 #define BOND_ARP_VALIDATE_BACKUP (1 << BOND_STATE_BACKUP)
326 #define BOND_ARP_VALIDATE_ALL (BOND_ARP_VALIDATE_ACTIVE | \
327 BOND_ARP_VALIDATE_BACKUP)
329 static inline int slave_do_arp_validate(
struct bonding *bond,
332 return bond->
params.arp_validate & (1 << bond_slave_state(slave));
335 static inline unsigned long slave_last_rx(
struct bonding *bond,
338 if (slave_do_arp_validate(bond, slave))
341 return slave->
dev->last_rx;
344 #ifdef CONFIG_NET_POLL_CONTROLLER
345 static inline void bond_netpoll_send_skb(
const struct slave *slave,
348 struct netpoll *np = slave->np;
351 netpoll_send_skb(np, skb);
354 static inline void bond_netpoll_send_skb(
const struct slave *slave,
360 static inline void bond_set_slave_inactive_flags(
struct slave *slave)
362 struct bonding *bond = netdev_priv(slave->
dev->master);
363 if (!bond_is_lb(bond))
364 bond_set_backup_slave(slave);
365 if (!bond->
params.all_slaves_active)
369 static inline void bond_set_slave_active_flags(
struct slave *slave)
371 bond_set_active_slave(slave);
375 static inline bool bond_is_slave_inactive(
struct slave *slave)
382 struct in_device *in_dev;
386 in_dev = __in_dev_get_rcu(dev);
424 #ifdef CONFIG_PROC_FS
430 #ifdef CONFIG_PROC_FS