if_bonding.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. #ifndef _LINUX_IF_BONDING_H
  44. #define _LINUX_IF_BONDING_H
  45. #include <linux/if.h>
  46. #include <linux/types.h>
  47. #include <linux/if_ether.h>
  48. /* userland - kernel ABI version (2003/05/08) */
  49. #define BOND_ABI_VERSION 2
  50. /*
  51. * We can remove these ioctl definitions in 2.5. People should use the
  52. * SIOC*** versions of them instead
  53. */
  54. #define BOND_ENSLAVE_OLD (SIOCDEVPRIVATE)
  55. #define BOND_RELEASE_OLD (SIOCDEVPRIVATE + 1)
  56. #define BOND_SETHWADDR_OLD (SIOCDEVPRIVATE + 2)
  57. #define BOND_SLAVE_INFO_QUERY_OLD (SIOCDEVPRIVATE + 11)
  58. #define BOND_INFO_QUERY_OLD (SIOCDEVPRIVATE + 12)
  59. #define BOND_CHANGE_ACTIVE_OLD (SIOCDEVPRIVATE + 13)
  60. #define BOND_CHECK_MII_STATUS (SIOCGMIIPHY)
  61. #define BOND_MODE_ROUNDROBIN 0
  62. #define BOND_MODE_ACTIVEBACKUP 1
  63. #define BOND_MODE_XOR 2
  64. #define BOND_MODE_BROADCAST 3
  65. #define BOND_MODE_8023AD 4
  66. #define BOND_MODE_TLB 5
  67. #define BOND_MODE_ALB 6 /* TLB + RLB (receive load balancing) */
  68. /* each slave's link has 4 states */
  69. #define BOND_LINK_UP 0 /* link is up and running */
  70. #define BOND_LINK_FAIL 1 /* link has just gone down */
  71. #define BOND_LINK_DOWN 2 /* link has been down for too long time */
  72. #define BOND_LINK_BACK 3 /* link is going back */
  73. /* each slave has several states */
  74. #define BOND_STATE_ACTIVE 0 /* link is active */
  75. #define BOND_STATE_BACKUP 1 /* link is backup */
  76. #define BOND_DEFAULT_MAX_BONDS 1 /* Default maximum number of devices to support */
  77. #define BOND_DEFAULT_TX_QUEUES 16 /* Default number of tx queues per device */
  78. #define BOND_DEFAULT_RESEND_IGMP 1 /* Default number of IGMP membership reports */
  79. /* hashing types */
  80. #define BOND_XMIT_POLICY_LAYER2 0 /* layer 2 (MAC only), default */
  81. #define BOND_XMIT_POLICY_LAYER34 1 /* layer 3+4 (IP ^ (TCP || UDP)) */
  82. #define BOND_XMIT_POLICY_LAYER23 2 /* layer 2+3 (IP ^ MAC) */
  83. #define BOND_XMIT_POLICY_ENCAP23 3 /* encapsulated layer 2+3 */
  84. #define BOND_XMIT_POLICY_ENCAP34 4 /* encapsulated layer 3+4 */
  85. /* 802.3ad port state definitions (43.4.2.2 in the 802.3ad standard) */
  86. #define LACP_STATE_LACP_ACTIVITY 0x1
  87. #define LACP_STATE_LACP_TIMEOUT 0x2
  88. #define LACP_STATE_AGGREGATION 0x4
  89. #define LACP_STATE_SYNCHRONIZATION 0x8
  90. #define LACP_STATE_COLLECTING 0x10
  91. #define LACP_STATE_DISTRIBUTING 0x20
  92. #define LACP_STATE_DEFAULTED 0x40
  93. #define LACP_STATE_EXPIRED 0x80
  94. typedef struct ifbond {
  95. __s32 bond_mode;
  96. __s32 num_slaves;
  97. __s32 miimon;
  98. } ifbond;
  99. typedef struct ifslave {
  100. __s32 slave_id; /* Used as an IN param to the BOND_SLAVE_INFO_QUERY ioctl */
  101. char slave_name[IFNAMSIZ];
  102. __s8 link;
  103. __s8 state;
  104. __u32 link_failure_count;
  105. } ifslave;
  106. struct ad_info {
  107. __u16 aggregator_id;
  108. __u16 ports;
  109. __u16 actor_key;
  110. __u16 partner_key;
  111. __u8 partner_system[ETH_ALEN];
  112. };
  113. /* Embedded inside LINK_XSTATS_TYPE_BOND */
  114. enum {
  115. BOND_XSTATS_UNSPEC,
  116. BOND_XSTATS_3AD,
  117. __BOND_XSTATS_MAX
  118. };
  119. #define BOND_XSTATS_MAX (__BOND_XSTATS_MAX - 1)
  120. /* Embedded inside BOND_XSTATS_3AD */
  121. enum {
  122. BOND_3AD_STAT_LACPDU_RX,
  123. BOND_3AD_STAT_LACPDU_TX,
  124. BOND_3AD_STAT_LACPDU_UNKNOWN_RX,
  125. BOND_3AD_STAT_LACPDU_ILLEGAL_RX,
  126. BOND_3AD_STAT_MARKER_RX,
  127. BOND_3AD_STAT_MARKER_TX,
  128. BOND_3AD_STAT_MARKER_RESP_RX,
  129. BOND_3AD_STAT_MARKER_RESP_TX,
  130. BOND_3AD_STAT_MARKER_UNKNOWN_RX,
  131. BOND_3AD_STAT_PAD,
  132. __BOND_3AD_STAT_MAX
  133. };
  134. #define BOND_3AD_STAT_MAX (__BOND_3AD_STAT_MAX - 1)
  135. #endif /* _LINUX_IF_BONDING_H */
  136. /*
  137. * Local variables:
  138. * version-control: t
  139. * kept-new-versions: 5
  140. * c-indent-level: 8
  141. * c-basic-offset: 8
  142. * tab-width: 8
  143. * End:
  144. */