1 /* SPDX-License-Identifier: GPL-1.0+ WITH Linux-syscall-note */
2 /*
3  * Bond several ethernet interfaces into a Cisco, running 'Etherchannel'.
4  *
5  *
6  * Portions are (c) Copyright 1995 Simon "Guru Aleph-Null" Janes
7  * NCM: Network and Communications Management, Inc.
8  *
9  * BUT, I'm the one who modified it for ethernet, so:
10  * (c) Copyright 1999, Thomas Davis, tadavis@lbl.gov
11  *
12  *	This software may be used and distributed according to the terms
13  *	of the GNU Public License, incorporated herein by reference.
14  *
15  * 2003/03/18 - Amir Noam <amir.noam at intel dot com>
16  *	- Added support for getting slave's speed and duplex via ethtool.
17  *	  Needed for 802.3ad and other future modes.
18  *
19  * 2003/03/18 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
20  *		Shmulik Hen <shmulik.hen at intel dot com>
21  *	- Enable support of modes that need to use the unique mac address of
22  *	  each slave.
23  *
24  * 2003/03/18 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
25  *		Amir Noam <amir.noam at intel dot com>
26  *	- Moved driver's private data types to bonding.h
27  *
28  * 2003/03/18 - Amir Noam <amir.noam at intel dot com>,
29  *		Tsippy Mendelson <tsippy.mendelson at intel dot com> and
30  *		Shmulik Hen <shmulik.hen at intel dot com>
31  *	- Added support for IEEE 802.3ad Dynamic link aggregation mode.
32  *
33  * 2003/05/01 - Amir Noam <amir.noam at intel dot com>
34  *	- Added ABI version control to restore compatibility between
35  *	  new/old ifenslave and new/old bonding.
36  *
37  * 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com>
38  *	- Code cleanup and style changes
39  *
40  * 2005/05/05 - Jason Gabler <jygabler at lbl dot gov>
41  *      - added definitions for various XOR hashing policies
42  */
43 
44 #ifndef _LINUX_IF_BONDING_H
45 #define _LINUX_IF_BONDING_H
46 
47 #include <linux/if.h>
48 #include <linux/types.h>
49 #include <linux/if_ether.h>
50 
51 /* userland - kernel ABI version (2003/05/08) */
52 #define BOND_ABI_VERSION 2
53 
54 /*
55  * We can remove these ioctl definitions in 2.5.  People should use the
56  * SIOC*** versions of them instead
57  */
58 #define BOND_ENSLAVE_OLD		(SIOCDEVPRIVATE)
59 #define BOND_RELEASE_OLD		(SIOCDEVPRIVATE + 1)
60 #define BOND_SETHWADDR_OLD		(SIOCDEVPRIVATE + 2)
61 #define BOND_SLAVE_INFO_QUERY_OLD	(SIOCDEVPRIVATE + 11)
62 #define BOND_INFO_QUERY_OLD		(SIOCDEVPRIVATE + 12)
63 #define BOND_CHANGE_ACTIVE_OLD		(SIOCDEVPRIVATE + 13)
64 
65 #define BOND_CHECK_MII_STATUS	(SIOCGMIIPHY)
66 
67 #define BOND_MODE_ROUNDROBIN	0
68 #define BOND_MODE_ACTIVEBACKUP	1
69 #define BOND_MODE_XOR		2
70 #define BOND_MODE_BROADCAST	3
71 #define BOND_MODE_8023AD        4
72 #define BOND_MODE_TLB           5
73 #define BOND_MODE_ALB		6 /* TLB + RLB (receive load balancing) */
74 
75 /* each slave's link has 4 states */
76 #define BOND_LINK_UP    0           /* link is up and running */
77 #define BOND_LINK_FAIL  1           /* link has just gone down */
78 #define BOND_LINK_DOWN  2           /* link has been down for too long time */
79 #define BOND_LINK_BACK  3           /* link is going back */
80 
81 /* each slave has several states */
82 #define BOND_STATE_ACTIVE       0   /* link is active */
83 #define BOND_STATE_BACKUP       1   /* link is backup */
84 
85 #define BOND_DEFAULT_MAX_BONDS  1   /* Default maximum number of devices to support */
86 
87 #define BOND_DEFAULT_TX_QUEUES 16   /* Default number of tx queues per device */
88 
89 #define BOND_DEFAULT_RESEND_IGMP	1 /* Default number of IGMP membership reports */
90 
91 /* hashing types */
92 #define BOND_XMIT_POLICY_LAYER2		0 /* layer 2 (MAC only), default */
93 #define BOND_XMIT_POLICY_LAYER34	1 /* layer 3+4 (IP ^ (TCP || UDP)) */
94 #define BOND_XMIT_POLICY_LAYER23	2 /* layer 2+3 (IP ^ MAC) */
95 #define BOND_XMIT_POLICY_ENCAP23	3 /* encapsulated layer 2+3 */
96 #define BOND_XMIT_POLICY_ENCAP34	4 /* encapsulated layer 3+4 */
97 #define BOND_XMIT_POLICY_VLAN_SRCMAC	5 /* vlan + source MAC */
98 
99 /* 802.3ad port state definitions (43.4.2.2 in the 802.3ad standard) */
100 #define LACP_STATE_LACP_ACTIVITY   0x1
101 #define LACP_STATE_LACP_TIMEOUT    0x2
102 #define LACP_STATE_AGGREGATION     0x4
103 #define LACP_STATE_SYNCHRONIZATION 0x8
104 #define LACP_STATE_COLLECTING      0x10
105 #define LACP_STATE_DISTRIBUTING    0x20
106 #define LACP_STATE_DEFAULTED       0x40
107 #define LACP_STATE_EXPIRED         0x80
108 
109 typedef struct ifbond {
110 	__s32 bond_mode;
111 	__s32 num_slaves;
112 	__s32 miimon;
113 } ifbond;
114 
115 typedef struct ifslave {
116 	__s32 slave_id; /* Used as an IN param to the BOND_SLAVE_INFO_QUERY ioctl */
117 	char slave_name[IFNAMSIZ];
118 	__s8 link;
119 	__s8 state;
120 	__u32  link_failure_count;
121 } ifslave;
122 
123 struct ad_info {
124 	__u16 aggregator_id;
125 	__u16 ports;
126 	__u16 actor_key;
127 	__u16 partner_key;
128 	__u8 partner_system[ETH_ALEN];
129 };
130 
131 /* Embedded inside LINK_XSTATS_TYPE_BOND */
132 enum {
133 	BOND_XSTATS_UNSPEC,
134 	BOND_XSTATS_3AD,
135 	__BOND_XSTATS_MAX
136 };
137 #define BOND_XSTATS_MAX (__BOND_XSTATS_MAX - 1)
138 
139 /* Embedded inside BOND_XSTATS_3AD */
140 enum {
141 	BOND_3AD_STAT_LACPDU_RX,
142 	BOND_3AD_STAT_LACPDU_TX,
143 	BOND_3AD_STAT_LACPDU_UNKNOWN_RX,
144 	BOND_3AD_STAT_LACPDU_ILLEGAL_RX,
145 	BOND_3AD_STAT_MARKER_RX,
146 	BOND_3AD_STAT_MARKER_TX,
147 	BOND_3AD_STAT_MARKER_RESP_RX,
148 	BOND_3AD_STAT_MARKER_RESP_TX,
149 	BOND_3AD_STAT_MARKER_UNKNOWN_RX,
150 	BOND_3AD_STAT_PAD,
151 	__BOND_3AD_STAT_MAX
152 };
153 #define BOND_3AD_STAT_MAX (__BOND_3AD_STAT_MAX - 1)
154 
155 #endif /* _LINUX_IF_BONDING_H */
156