Linux-libre 5.4.48-gnu
[librecmc/linux-libre.git] / include / uapi / linux / if_bonding.h
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
98 typedef struct ifbond {
99         __s32 bond_mode;
100         __s32 num_slaves;
101         __s32 miimon;
102 } ifbond;
103
104 typedef struct ifslave {
105         __s32 slave_id; /* Used as an IN param to the BOND_SLAVE_INFO_QUERY ioctl */
106         char slave_name[IFNAMSIZ];
107         __s8 link;
108         __s8 state;
109         __u32  link_failure_count;
110 } ifslave;
111
112 struct ad_info {
113         __u16 aggregator_id;
114         __u16 ports;
115         __u16 actor_key;
116         __u16 partner_key;
117         __u8 partner_system[ETH_ALEN];
118 };
119
120 /* Embedded inside LINK_XSTATS_TYPE_BOND */
121 enum {
122         BOND_XSTATS_UNSPEC,
123         BOND_XSTATS_3AD,
124         __BOND_XSTATS_MAX
125 };
126 #define BOND_XSTATS_MAX (__BOND_XSTATS_MAX - 1)
127
128 /* Embedded inside BOND_XSTATS_3AD */
129 enum {
130         BOND_3AD_STAT_LACPDU_RX,
131         BOND_3AD_STAT_LACPDU_TX,
132         BOND_3AD_STAT_LACPDU_UNKNOWN_RX,
133         BOND_3AD_STAT_LACPDU_ILLEGAL_RX,
134         BOND_3AD_STAT_MARKER_RX,
135         BOND_3AD_STAT_MARKER_TX,
136         BOND_3AD_STAT_MARKER_RESP_RX,
137         BOND_3AD_STAT_MARKER_RESP_TX,
138         BOND_3AD_STAT_MARKER_UNKNOWN_RX,
139         BOND_3AD_STAT_PAD,
140         __BOND_3AD_STAT_MAX
141 };
142 #define BOND_3AD_STAT_MAX (__BOND_3AD_STAT_MAX - 1)
143
144 #endif /* _LINUX_IF_BONDING_H */
145
146 /*
147  * Local variables:
148  *  version-control: t
149  *  kept-new-versions: 5
150  *  c-indent-level: 8
151  *  c-basic-offset: 8
152  *  tab-width: 8
153  * End:
154  */
155