2017-11-01 14:09:13 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-1.0+ WITH Linux-syscall-note */
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Bond several ethernet interfaces into a Cisco, running 'Etherchannel'.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Portions are (c) Copyright 1995 Simon "Guru Aleph-Null" Janes
|
|
|
|
* NCM: Network and Communications Management, Inc.
|
|
|
|
*
|
|
|
|
* BUT, I'm the one who modified it for ethernet, so:
|
|
|
|
* (c) Copyright 1999, Thomas Davis, tadavis@lbl.gov
|
|
|
|
*
|
|
|
|
* This software may be used and distributed according to the terms
|
|
|
|
* of the GNU Public License, incorporated herein by reference.
|
|
|
|
*
|
|
|
|
* 2003/03/18 - Amir Noam <amir.noam at intel dot com>
|
|
|
|
* - Added support for getting slave's speed and duplex via ethtool.
|
|
|
|
* Needed for 802.3ad and other future modes.
|
|
|
|
*
|
|
|
|
* 2003/03/18 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
|
|
|
|
* Shmulik Hen <shmulik.hen at intel dot com>
|
|
|
|
* - Enable support of modes that need to use the unique mac address of
|
|
|
|
* each slave.
|
|
|
|
*
|
|
|
|
* 2003/03/18 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
|
|
|
|
* Amir Noam <amir.noam at intel dot com>
|
|
|
|
* - Moved driver's private data types to bonding.h
|
|
|
|
*
|
|
|
|
* 2003/03/18 - Amir Noam <amir.noam at intel dot com>,
|
|
|
|
* Tsippy Mendelson <tsippy.mendelson at intel dot com> and
|
|
|
|
* Shmulik Hen <shmulik.hen at intel dot com>
|
|
|
|
* - Added support for IEEE 802.3ad Dynamic link aggregation mode.
|
|
|
|
*
|
|
|
|
* 2003/05/01 - Amir Noam <amir.noam at intel dot com>
|
|
|
|
* - Added ABI version control to restore compatibility between
|
|
|
|
* new/old ifenslave and new/old bonding.
|
|
|
|
*
|
|
|
|
* 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com>
|
|
|
|
* - Code cleanup and style changes
|
2005-06-26 21:54:11 +00:00
|
|
|
*
|
|
|
|
* 2005/05/05 - Jason Gabler <jygabler at lbl dot gov>
|
|
|
|
* - added definitions for various XOR hashing policies
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LINUX_IF_BONDING_H
|
|
|
|
#define _LINUX_IF_BONDING_H
|
|
|
|
|
|
|
|
#include <linux/if.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/if_ether.h>
|
|
|
|
|
|
|
|
/* userland - kernel ABI version (2003/05/08) */
|
|
|
|
#define BOND_ABI_VERSION 2
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We can remove these ioctl definitions in 2.5. People should use the
|
|
|
|
* SIOC*** versions of them instead
|
|
|
|
*/
|
|
|
|
#define BOND_ENSLAVE_OLD (SIOCDEVPRIVATE)
|
|
|
|
#define BOND_RELEASE_OLD (SIOCDEVPRIVATE + 1)
|
|
|
|
#define BOND_SETHWADDR_OLD (SIOCDEVPRIVATE + 2)
|
|
|
|
#define BOND_SLAVE_INFO_QUERY_OLD (SIOCDEVPRIVATE + 11)
|
|
|
|
#define BOND_INFO_QUERY_OLD (SIOCDEVPRIVATE + 12)
|
|
|
|
#define BOND_CHANGE_ACTIVE_OLD (SIOCDEVPRIVATE + 13)
|
|
|
|
|
|
|
|
#define BOND_CHECK_MII_STATUS (SIOCGMIIPHY)
|
|
|
|
|
|
|
|
#define BOND_MODE_ROUNDROBIN 0
|
|
|
|
#define BOND_MODE_ACTIVEBACKUP 1
|
|
|
|
#define BOND_MODE_XOR 2
|
|
|
|
#define BOND_MODE_BROADCAST 3
|
|
|
|
#define BOND_MODE_8023AD 4
|
|
|
|
#define BOND_MODE_TLB 5
|
|
|
|
#define BOND_MODE_ALB 6 /* TLB + RLB (receive load balancing) */
|
|
|
|
|
|
|
|
/* each slave's link has 4 states */
|
|
|
|
#define BOND_LINK_UP 0 /* link is up and running */
|
|
|
|
#define BOND_LINK_FAIL 1 /* link has just gone down */
|
|
|
|
#define BOND_LINK_DOWN 2 /* link has been down for too long time */
|
|
|
|
#define BOND_LINK_BACK 3 /* link is going back */
|
|
|
|
|
|
|
|
/* each slave has several states */
|
|
|
|
#define BOND_STATE_ACTIVE 0 /* link is active */
|
|
|
|
#define BOND_STATE_BACKUP 1 /* link is backup */
|
|
|
|
|
|
|
|
#define BOND_DEFAULT_MAX_BONDS 1 /* Default maximum number of devices to support */
|
|
|
|
|
2010-06-02 08:40:18 +00:00
|
|
|
#define BOND_DEFAULT_TX_QUEUES 16 /* Default number of tx queues per device */
|
2010-10-05 14:23:59 +00:00
|
|
|
|
|
|
|
#define BOND_DEFAULT_RESEND_IGMP 1 /* Default number of IGMP membership reports */
|
|
|
|
|
2005-06-26 21:54:11 +00:00
|
|
|
/* hashing types */
|
|
|
|
#define BOND_XMIT_POLICY_LAYER2 0 /* layer 2 (MAC only), default */
|
2007-12-07 07:40:34 +00:00
|
|
|
#define BOND_XMIT_POLICY_LAYER34 1 /* layer 3+4 (IP ^ (TCP || UDP)) */
|
|
|
|
#define BOND_XMIT_POLICY_LAYER23 2 /* layer 2+3 (IP ^ MAC) */
|
2013-10-02 11:39:25 +00:00
|
|
|
#define BOND_XMIT_POLICY_ENCAP23 3 /* encapsulated layer 2+3 */
|
|
|
|
#define BOND_XMIT_POLICY_ENCAP34 4 /* encapsulated layer 3+4 */
|
bonding: add a vlan+srcmac tx hashing option
This comes from an end-user request, where they're running multiple VMs on
hosts with bonded interfaces connected to some interest switch topologies,
where 802.3ad isn't an option. They're currently running a proprietary
solution that effectively achieves load-balancing of VMs and bandwidth
utilization improvements with a similar form of transmission algorithm.
Basically, each VM has it's own vlan, so it always sends its traffic out
the same interface, unless that interface fails. Traffic gets split
between the interfaces, maintaining a consistent path, with failover still
available if an interface goes down.
Unlike bond_eth_hash(), this hash function is using the full source MAC
address instead of just the last byte, as there are so few components to
the hash, and in the no-vlan case, we would be returning just the last
byte of the source MAC as the hash value. It's entirely possible to have
two NICs in a bond with the same last byte of their MAC, but not the same
MAC, so this adjustment should guarantee distinct hashes in all cases.
This has been rudimetarily tested to provide similar results to the
proprietary solution it is aiming to replace. A patch for iproute2 is also
posted, to properly support the new mode there as well.
Cc: Jay Vosburgh <j.vosburgh@gmail.com>
Cc: Veaceslav Falico <vfalico@gmail.com>
Cc: Andy Gospodarek <andy@greyhouse.net>
Cc: Thomas Davis <tadavis@lbl.gov>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Link: https://lore.kernel.org/r/20210119010927.1191922-1-jarod@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2021-01-19 01:09:27 +00:00
|
|
|
#define BOND_XMIT_POLICY_VLAN_SRCMAC 5 /* vlan + source MAC */
|
2005-06-26 21:54:11 +00:00
|
|
|
|
bonding: move 802.3ad port state flags to uapi
The bond slave actor/partner operating state is exported as
bitfield to userspace, which lacks a way to interpret it, e.g.,
iproute2 only prints the state as a number:
ad_actor_oper_port_state 15
For userspace to interpret the bitfield, the bitfield definitions
should be part of the uapi. The bitfield itself is defined in the
802.3ad standard.
This commit moves the 802.3ad bitfield definitions to uapi.
Related iproute2 patches, soon to be posted upstream, use the new uapi
headers to pretty-print bond slave state, e.g., with ip -d link show
ad_actor_oper_port_state_str <active,short_timeout,aggregating,in_sync>
Signed-off-by: Andy Roulin <aroulin@cumulusnetworks.com>
Acked-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Acked-by: Jay Vosburgh <jay.vosburgh@canonical.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
2019-12-11 22:30:58 +00:00
|
|
|
/* 802.3ad port state definitions (43.4.2.2 in the 802.3ad standard) */
|
2019-12-26 13:41:57 +00:00
|
|
|
#define LACP_STATE_LACP_ACTIVITY 0x1
|
|
|
|
#define LACP_STATE_LACP_TIMEOUT 0x2
|
|
|
|
#define LACP_STATE_AGGREGATION 0x4
|
|
|
|
#define LACP_STATE_SYNCHRONIZATION 0x8
|
|
|
|
#define LACP_STATE_COLLECTING 0x10
|
|
|
|
#define LACP_STATE_DISTRIBUTING 0x20
|
|
|
|
#define LACP_STATE_DEFAULTED 0x40
|
|
|
|
#define LACP_STATE_EXPIRED 0x80
|
bonding: move 802.3ad port state flags to uapi
The bond slave actor/partner operating state is exported as
bitfield to userspace, which lacks a way to interpret it, e.g.,
iproute2 only prints the state as a number:
ad_actor_oper_port_state 15
For userspace to interpret the bitfield, the bitfield definitions
should be part of the uapi. The bitfield itself is defined in the
802.3ad standard.
This commit moves the 802.3ad bitfield definitions to uapi.
Related iproute2 patches, soon to be posted upstream, use the new uapi
headers to pretty-print bond slave state, e.g., with ip -d link show
ad_actor_oper_port_state_str <active,short_timeout,aggregating,in_sync>
Signed-off-by: Andy Roulin <aroulin@cumulusnetworks.com>
Acked-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Acked-by: Jay Vosburgh <jay.vosburgh@canonical.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
2019-12-11 22:30:58 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
typedef struct ifbond {
|
|
|
|
__s32 bond_mode;
|
|
|
|
__s32 num_slaves;
|
|
|
|
__s32 miimon;
|
|
|
|
} ifbond;
|
|
|
|
|
2009-11-04 17:50:58 +00:00
|
|
|
typedef struct ifslave {
|
2005-04-16 22:20:36 +00:00
|
|
|
__s32 slave_id; /* Used as an IN param to the BOND_SLAVE_INFO_QUERY ioctl */
|
|
|
|
char slave_name[IFNAMSIZ];
|
|
|
|
__s8 link;
|
|
|
|
__s8 state;
|
|
|
|
__u32 link_failure_count;
|
|
|
|
} ifslave;
|
|
|
|
|
|
|
|
struct ad_info {
|
|
|
|
__u16 aggregator_id;
|
|
|
|
__u16 ports;
|
|
|
|
__u16 actor_key;
|
|
|
|
__u16 partner_key;
|
|
|
|
__u8 partner_system[ETH_ALEN];
|
|
|
|
};
|
|
|
|
|
2019-01-18 12:30:23 +00:00
|
|
|
/* Embedded inside LINK_XSTATS_TYPE_BOND */
|
|
|
|
enum {
|
|
|
|
BOND_XSTATS_UNSPEC,
|
|
|
|
BOND_XSTATS_3AD,
|
|
|
|
__BOND_XSTATS_MAX
|
|
|
|
};
|
|
|
|
#define BOND_XSTATS_MAX (__BOND_XSTATS_MAX - 1)
|
|
|
|
|
|
|
|
/* Embedded inside BOND_XSTATS_3AD */
|
|
|
|
enum {
|
|
|
|
BOND_3AD_STAT_LACPDU_RX,
|
|
|
|
BOND_3AD_STAT_LACPDU_TX,
|
|
|
|
BOND_3AD_STAT_LACPDU_UNKNOWN_RX,
|
|
|
|
BOND_3AD_STAT_LACPDU_ILLEGAL_RX,
|
|
|
|
BOND_3AD_STAT_MARKER_RX,
|
|
|
|
BOND_3AD_STAT_MARKER_TX,
|
|
|
|
BOND_3AD_STAT_MARKER_RESP_RX,
|
|
|
|
BOND_3AD_STAT_MARKER_RESP_TX,
|
|
|
|
BOND_3AD_STAT_MARKER_UNKNOWN_RX,
|
|
|
|
BOND_3AD_STAT_PAD,
|
|
|
|
__BOND_3AD_STAT_MAX
|
|
|
|
};
|
|
|
|
#define BOND_3AD_STAT_MAX (__BOND_3AD_STAT_MAX - 1)
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif /* _LINUX_IF_BONDING_H */
|