^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright(c) 1999 - 2004 Intel Corporation. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #ifndef _NET_BOND_3AD_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #define _NET_BOND_3AD_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <asm/byteorder.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/skbuff.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/if_ether.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) /* General definitions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #define PKT_TYPE_LACPDU cpu_to_be16(ETH_P_SLOW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define AD_TIMER_INTERVAL 100 /*msec*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define MULTICAST_LACPDU_ADDR {0x01, 0x80, 0xC2, 0x00, 0x00, 0x02}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define AD_LACP_SLOW 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define AD_LACP_FAST 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) typedef struct mac_addr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) u8 mac_addr_value[ETH_ALEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) } __packed mac_addr_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) BOND_AD_STABLE = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) BOND_AD_BANDWIDTH = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) BOND_AD_COUNT = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) /* rx machine states(43.4.11 in the 802.3ad standard) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) typedef enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) AD_RX_DUMMY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) AD_RX_INITIALIZE, /* rx Machine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) AD_RX_PORT_DISABLED, /* rx Machine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) AD_RX_LACP_DISABLED, /* rx Machine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) AD_RX_EXPIRED, /* rx Machine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) AD_RX_DEFAULTED, /* rx Machine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) AD_RX_CURRENT /* rx Machine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) } rx_states_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) /* periodic machine states(43.4.12 in the 802.3ad standard) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) typedef enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) AD_PERIODIC_DUMMY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) AD_NO_PERIODIC, /* periodic machine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) AD_FAST_PERIODIC, /* periodic machine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) AD_SLOW_PERIODIC, /* periodic machine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) AD_PERIODIC_TX /* periodic machine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) } periodic_states_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /* mux machine states(43.4.13 in the 802.3ad standard) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) typedef enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) AD_MUX_DUMMY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) AD_MUX_DETACHED, /* mux machine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) AD_MUX_WAITING, /* mux machine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) AD_MUX_ATTACHED, /* mux machine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) AD_MUX_COLLECTING_DISTRIBUTING /* mux machine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) } mux_states_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) /* tx machine states(43.4.15 in the 802.3ad standard) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) typedef enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) AD_TX_DUMMY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) AD_TRANSMIT /* tx Machine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) } tx_states_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) /* churn machine states(43.4.17 in the 802.3ad standard) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) typedef enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) AD_CHURN_MONITOR, /* monitoring for churn */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) AD_CHURN, /* churn detected (error) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) AD_NO_CHURN /* no churn (no error) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) } churn_state_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) /* rx indication types */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) typedef enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) AD_TYPE_LACPDU = 1, /* type lacpdu */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) AD_TYPE_MARKER /* type marker */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) } pdu_type_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) /* rx marker indication types */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) typedef enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) AD_MARKER_INFORMATION_SUBTYPE = 1, /* marker imformation subtype */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) AD_MARKER_RESPONSE_SUBTYPE /* marker response subtype */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) } bond_marker_subtype_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) /* timers types(43.4.9 in the 802.3ad standard) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) typedef enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) AD_CURRENT_WHILE_TIMER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) AD_ACTOR_CHURN_TIMER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) AD_PERIODIC_TIMER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) AD_PARTNER_CHURN_TIMER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) AD_WAIT_WHILE_TIMER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) } ad_timers_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) #pragma pack(1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) /* Link Aggregation Control Protocol(LACP) data unit structure(43.4.2.2 in the 802.3ad standard) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) typedef struct lacpdu {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) u8 subtype; /* = LACP(= 0x01) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) u8 version_number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) u8 tlv_type_actor_info; /* = actor information(type/length/value) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) u8 actor_information_length; /* = 20 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) __be16 actor_system_priority;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) struct mac_addr actor_system;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) __be16 actor_key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) __be16 actor_port_priority;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) __be16 actor_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) u8 actor_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) u8 reserved_3_1[3]; /* = 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) u8 tlv_type_partner_info; /* = partner information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) u8 partner_information_length; /* = 20 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) __be16 partner_system_priority;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) struct mac_addr partner_system;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) __be16 partner_key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) __be16 partner_port_priority;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) __be16 partner_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) u8 partner_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) u8 reserved_3_2[3]; /* = 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) u8 tlv_type_collector_info; /* = collector information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) u8 collector_information_length;/* = 16 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) __be16 collector_max_delay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) u8 reserved_12[12];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) u8 tlv_type_terminator; /* = terminator */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) u8 terminator_length; /* = 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) u8 reserved_50[50]; /* = 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) } __packed lacpdu_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) typedef struct lacpdu_header {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) struct ethhdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) struct lacpdu lacpdu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) } __packed lacpdu_header_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) /* Marker Protocol Data Unit(PDU) structure(43.5.3.2 in the 802.3ad standard) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) typedef struct bond_marker {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) u8 subtype; /* = 0x02 (marker PDU) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) u8 version_number; /* = 0x01 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) u8 tlv_type; /* = 0x01 (marker information) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) /* = 0x02 (marker response information) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) u8 marker_length; /* = 0x16 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) u16 requester_port; /* The number assigned to the port by the requester */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) struct mac_addr requester_system; /* The requester's system id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) u32 requester_transaction_id; /* The transaction id allocated by the requester, */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) u16 pad; /* = 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) u8 tlv_type_terminator; /* = 0x00 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) u8 terminator_length; /* = 0x00 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) u8 reserved_90[90]; /* = 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) } __packed bond_marker_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) typedef struct bond_marker_header {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) struct ethhdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) struct bond_marker marker;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) } __packed bond_marker_header_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) #pragma pack()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) struct slave;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) struct bonding;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) struct ad_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) struct port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) #ifdef __ia64__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) #pragma pack(8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) struct bond_3ad_stats {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) atomic64_t lacpdu_rx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) atomic64_t lacpdu_tx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) atomic64_t lacpdu_unknown_rx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) atomic64_t lacpdu_illegal_rx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) atomic64_t marker_rx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) atomic64_t marker_tx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) atomic64_t marker_resp_rx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) atomic64_t marker_resp_tx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) atomic64_t marker_unknown_rx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) /* aggregator structure(43.4.5 in the 802.3ad standard) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) typedef struct aggregator {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) struct mac_addr aggregator_mac_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) u16 aggregator_identifier;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) bool is_individual;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) u16 actor_admin_aggregator_key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) u16 actor_oper_aggregator_key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) struct mac_addr partner_system;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) u16 partner_system_priority;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) u16 partner_oper_aggregator_key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) u16 receive_state; /* BOOLEAN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) u16 transmit_state; /* BOOLEAN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) struct port *lag_ports;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) /* ****** PRIVATE PARAMETERS ****** */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) struct slave *slave; /* pointer to the bond slave that this aggregator belongs to */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) u16 is_active; /* BOOLEAN. Indicates if this aggregator is active */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) u16 num_of_ports;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) } aggregator_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) struct port_params {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) struct mac_addr system;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) u16 system_priority;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) u16 key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) u16 port_number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) u16 port_priority;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) u16 port_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) /* port structure(43.4.6 in the 802.3ad standard) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) typedef struct port {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) u16 actor_port_number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) u16 actor_port_priority;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) struct mac_addr actor_system; /* This parameter is added here although it is not specified in the standard, just for simplification */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) u16 actor_system_priority; /* This parameter is added here although it is not specified in the standard, just for simplification */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) u16 actor_port_aggregator_identifier;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) bool ntt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) u16 actor_admin_port_key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) u16 actor_oper_port_key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) u8 actor_admin_port_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) u8 actor_oper_port_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) struct port_params partner_admin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) struct port_params partner_oper;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) bool is_enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) /* ****** PRIVATE PARAMETERS ****** */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) u16 sm_vars; /* all state machines variables for this port */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) rx_states_t sm_rx_state; /* state machine rx state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) u16 sm_rx_timer_counter; /* state machine rx timer counter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) periodic_states_t sm_periodic_state; /* state machine periodic state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) u16 sm_periodic_timer_counter; /* state machine periodic timer counter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) mux_states_t sm_mux_state; /* state machine mux state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) u16 sm_mux_timer_counter; /* state machine mux timer counter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) tx_states_t sm_tx_state; /* state machine tx state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) u16 sm_tx_timer_counter; /* state machine tx timer counter(allways on - enter to transmit state 3 time per second) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) u16 sm_churn_actor_timer_counter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) u16 sm_churn_partner_timer_counter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) u32 churn_actor_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) u32 churn_partner_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) churn_state_t sm_churn_actor_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) churn_state_t sm_churn_partner_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) struct slave *slave; /* pointer to the bond slave that this port belongs to */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) struct aggregator *aggregator; /* pointer to an aggregator that this port related to */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) struct port *next_port_in_aggregator; /* Next port on the linked list of the parent aggregator */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) u32 transaction_id; /* continuous number for identification of Marker PDU's; */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) struct lacpdu lacpdu; /* the lacpdu that will be sent for this port */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) } port_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) /* system structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) struct ad_system {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) u16 sys_priority;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) struct mac_addr sys_mac_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) #ifdef __ia64__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) #pragma pack()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) /* ========== AD Exported structures to the main bonding code ========== */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) #define BOND_AD_INFO(bond) ((bond)->ad_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) #define SLAVE_AD_INFO(slave) ((slave)->ad_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) struct ad_bond_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) struct ad_system system; /* 802.3ad system structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) struct bond_3ad_stats stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) atomic_t agg_select_timer; /* Timer to select aggregator after all adapter's hand shakes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) u16 aggregator_identifier;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) struct ad_slave_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) struct aggregator aggregator; /* 802.3ad aggregator structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) struct port port; /* 802.3ad port structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) struct bond_3ad_stats stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) u16 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) static inline const char *bond_3ad_churn_desc(churn_state_t state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) static const char *const churn_description[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) "monitoring",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) "churned",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) "none",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) "unknown"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) int max_size = ARRAY_SIZE(churn_description);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) if (state >= max_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) state = max_size - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) return churn_description[state];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) /* ========== AD Exported functions to the main bonding code ========== */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) void bond_3ad_bind_slave(struct slave *slave);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) void bond_3ad_unbind_slave(struct slave *slave);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) void bond_3ad_state_machine_handler(struct work_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) void bond_3ad_initiate_agg_selection(struct bonding *bond, int timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) void bond_3ad_adapter_speed_duplex_changed(struct slave *slave);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) void bond_3ad_handle_link_change(struct slave *slave, char link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) int bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) int __bond_3ad_get_active_agg_info(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) struct ad_info *ad_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) int bond_3ad_lacpdu_recv(const struct sk_buff *skb, struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) struct slave *slave);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) int bond_3ad_set_carrier(struct bonding *bond);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) void bond_3ad_update_lacp_rate(struct bonding *bond);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) void bond_3ad_update_ad_actor_settings(struct bonding *bond);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) int bond_3ad_stats_fill(struct sk_buff *skb, struct bond_3ad_stats *stats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) size_t bond_3ad_stats_size(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) #endif /* _NET_BOND_3AD_H */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)