1/*
2 * Bond several ethernet interfaces into a Cisco, running 'Etherchannel'.
3 *
4 *
5 * Portions are (c) Copyright 1995 Simon "Guru Aleph-Null" Janes
6 * NCM: Network and Communications Management, Inc.
7 *
8 * BUT, I'm the one who modified it for ethernet, so:
9 * (c) Copyright 1999, Thomas Davis, tadavis@lbl.gov
10 *
11 *	This software may be used and distributed according to the terms
12 *	of the GNU Public License, incorporated herein by reference.
13 *
14 */
15
16#ifndef _LINUX_IF_BONDING_H
17#define _LINUX_IF_BONDING_H
18
19#ifdef __KERNEL__
20#include <linux/timer.h>
21#include <linux/if.h>
22#include <linux/proc_fs.h>
23#endif /* __KERNEL__ */
24
25#include <linux/types.h>
26
27/*
28 * We can remove these ioctl definitions in 2.5.  People should use the
29 * SIOC*** versions of them instead
30 */
31#define BOND_ENSLAVE_OLD		(SIOCDEVPRIVATE)
32#define BOND_RELEASE_OLD		(SIOCDEVPRIVATE + 1)
33#define BOND_SETHWADDR_OLD		(SIOCDEVPRIVATE + 2)
34#define BOND_SLAVE_INFO_QUERY_OLD	(SIOCDEVPRIVATE + 11)
35#define BOND_INFO_QUERY_OLD		(SIOCDEVPRIVATE + 12)
36#define BOND_CHANGE_ACTIVE_OLD		(SIOCDEVPRIVATE + 13)
37
38#define BOND_CHECK_MII_STATUS	(SIOCGMIIPHY)
39
40#define BOND_MODE_ROUNDROBIN    0
41#define BOND_MODE_ACTIVEBACKUP  1
42#define BOND_MODE_XOR           2
43
44/* each slave's link has 4 states */
45#define BOND_LINK_UP    0           /* link is up and running */
46#define BOND_LINK_FAIL  1           /* link has just gone down */
47#define BOND_LINK_DOWN  2           /* link has been down for too long time */
48#define BOND_LINK_BACK  3           /* link is going back */
49
50/* each slave has several states */
51#define BOND_STATE_ACTIVE       0   /* link is active */
52#define BOND_STATE_BACKUP       1   /* link is backup */
53
54#define BOND_DEFAULT_MAX_BONDS  1   /* Default maximum number of devices to support */
55
56typedef struct ifbond {
57	__s32 bond_mode;
58	__s32 num_slaves;
59	__s32 miimon;
60} ifbond;
61
62typedef struct ifslave
63{
64	__s32 slave_id; /* Used as an IN param to the BOND_SLAVE_INFO_QUERY ioctl */
65	char slave_name[IFNAMSIZ];
66	char link;
67	char state;
68	__u32  link_failure_count;
69} ifslave;
70
71#ifdef __KERNEL__
72typedef struct slave {
73	struct slave *next;
74	struct slave *prev;
75	struct net_device *dev;
76	short  delay;
77	char   link;    /* one of BOND_LINK_XXXX */
78	char   state;   /* one of BOND_STATE_XXXX */
79	unsigned short original_flags;
80	u32 link_failure_count;
81} slave_t;
82
83/*
84 * Here are the locking policies for the two bonding locks:
85 *
86 * 1) Get bond->lock when reading/writing slave list.
87 * 2) Get bond->ptrlock when reading/writing bond->current_slave.
88 *    (It is unnecessary when the write-lock is put with bond->lock.)
89 * 3) When we lock with bond->ptrlock, we must lock with bond->lock
90 *    beforehand.
91 */
92typedef struct bonding {
93	slave_t *next;
94	slave_t *prev;
95	slave_t *current_slave;
96	__s32 slave_cnt;
97	rwlock_t lock;
98	rwlock_t ptrlock;
99	struct timer_list mii_timer;
100	struct timer_list arp_timer;
101	struct net_device_stats *stats;
102#ifdef CONFIG_PROC_FS
103	struct proc_dir_entry *bond_proc_dir;
104	struct proc_dir_entry *bond_proc_info_file;
105#endif /* CONFIG_PROC_FS */
106	struct bonding *next_bond;
107	struct net_device *device;
108	struct dev_mc_list *mc_list;
109	unsigned short flags;
110} bonding_t;
111#endif /* __KERNEL__ */
112
113#endif /* _LINUX_BOND_H */
114
115/*
116 * Local variables:
117 *  version-control: t
118 *  kept-new-versions: 5
119 *  c-indent-level: 8
120 *  c-basic-offset: 8
121 *  tab-width: 8
122 * End:
123 */
124