1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
5 #ifndef RTE_ETH_BOND_8023AD_H_
6 #define RTE_ETH_BOND_8023AD_H_
15 * Actor/partner states
17 #define STATE_LACP_ACTIVE 0x01
18 #define STATE_LACP_SHORT_TIMEOUT 0x02
19 #define STATE_AGGREGATION 0x04
20 #define STATE_SYNCHRONIZATION 0x08
21 #define STATE_COLLECTING 0x10
22 #define STATE_DISTRIBUTING 0x20
23 /** Partners parameters are defaulted */
24 #define STATE_DEFAULTED 0x40
25 #define STATE_EXPIRED 0x80
27 #define TLV_TYPE_ACTOR_INFORMATION 0x01
28 #define TLV_TYPE_PARTNER_INFORMATION 0x02
29 #define TLV_TYPE_COLLECTOR_INFORMATION 0x03
30 #define TLV_TYPE_TERMINATOR_INFORMATION 0x00
32 #define SLOW_SUBTYPE_LACP 0x01
33 #define SLOW_SUBTYPE_MARKER 0x02
35 #define MARKER_TLV_TYPE_INFO 0x01
36 #define MARKER_TLV_TYPE_RESP 0x02
38 typedef void (*rte_eth_bond_8023ad_ext_slowrx_fn)(uint16_t slave_id,
39 struct rte_mbuf *lacp_pkt);
41 enum rte_bond_8023ad_selection {
47 enum rte_bond_8023ad_agg_selection {
53 /** Generic slow protocol structure */
54 struct slow_protocol {
56 uint8_t reserved_119[119];
57 } __attribute__((__packed__));
59 /** Generic slow protocol frame type structure */
60 struct slow_protocol_frame {
61 struct ether_hdr eth_hdr;
62 struct slow_protocol slow_protocol;
63 } __attribute__((__packed__));
66 uint16_t system_priority;
67 /**< System priority (unused in current implementation) */
68 struct ether_addr system;
69 /**< System ID - Slave MAC address, same as bonding MAC address */
71 /**< Speed information (implementation dependednt) and duplex. */
72 uint16_t port_priority;
73 /**< Priority of this (unused in current implementation) */
75 /**< Port number. It corresponds to slave port id. */
76 } __attribute__((__packed__));
78 struct lacpdu_actor_partner_params {
79 uint8_t tlv_type_info;
81 struct port_params port_params;
83 uint8_t reserved_3[3];
84 } __attribute__((__packed__));
86 /** LACPDU structure (5.4.2 in 802.1AX documentation). */
89 uint8_t version_number;
91 struct lacpdu_actor_partner_params actor;
92 struct lacpdu_actor_partner_params partner;
94 uint8_t tlv_type_collector_info;
95 uint8_t collector_info_length;
96 uint16_t collector_max_delay;
97 uint8_t reserved_12[12];
99 uint8_t tlv_type_terminator;
100 uint8_t terminator_length;
101 uint8_t reserved_50[50];
102 } __attribute__((__packed__));
104 /** LACPDU frame: Contains ethernet header and LACPDU. */
105 struct lacpdu_header {
106 struct ether_hdr eth_hdr;
107 struct lacpdu lacpdu;
108 } __attribute__((__packed__));
112 uint8_t version_number;
114 uint8_t tlv_type_marker;
116 uint16_t requester_port;
117 struct ether_addr requester_system;
118 uint32_t requester_transaction_id;
119 uint8_t reserved_2[2];
121 uint8_t tlv_type_terminator;
122 uint8_t terminator_length;
123 uint8_t reserved_90[90];
124 } __attribute__((__packed__));
126 struct marker_header {
127 struct ether_hdr eth_hdr;
128 struct marker marker;
129 } __attribute__((__packed__));
131 struct rte_eth_bond_8023ad_conf {
132 uint32_t fast_periodic_ms;
133 uint32_t slow_periodic_ms;
134 uint32_t short_timeout_ms;
135 uint32_t long_timeout_ms;
136 uint32_t aggregate_wait_timeout_ms;
137 uint32_t tx_period_ms;
138 uint32_t rx_marker_period_ms;
139 uint32_t update_timeout_ms;
140 rte_eth_bond_8023ad_ext_slowrx_fn slowrx_cb;
141 enum rte_bond_8023ad_agg_selection agg_selection;
144 struct rte_eth_bond_8023ad_slave_info {
145 enum rte_bond_8023ad_selection selected;
147 struct port_params actor;
148 uint8_t partner_state;
149 struct port_params partner;
150 uint16_t agg_port_id;
156 * Function returns current configuration of 802.3AX mode.
158 * @param port_id Bonding device id
159 * @param conf Pointer to timeout structure.
163 * -EINVAL if conf is NULL
166 rte_eth_bond_8023ad_conf_get(uint16_t port_id,
167 struct rte_eth_bond_8023ad_conf *conf);
172 * Function set new configuration of 802.3AX mode.
174 * @param port_id Bonding device id
175 * @param conf Configuration, if NULL set default configuration.
178 * -EINVAL if configuration is invalid.
181 rte_eth_bond_8023ad_setup(uint16_t port_id,
182 struct rte_eth_bond_8023ad_conf *conf);
187 * Function returns current state of given slave device.
189 * @param slave_id Port id of valid slave.
190 * @param conf buffer for configuration
193 * -EINVAL if conf is NULL or slave id is invalid (not a slave of given
194 * bonded device or is not inactive).
197 rte_eth_bond_8023ad_slave_info(uint16_t port_id, uint16_t slave_id,
198 struct rte_eth_bond_8023ad_slave_info *conf);
205 * Configure a slave port to start collecting.
207 * @param port_id Bonding device id
208 * @param slave_id Port id of valid slave.
209 * @param enabled Non-zero when collection enabled.
212 * -EINVAL if slave is not valid.
215 rte_eth_bond_8023ad_ext_collect(uint16_t port_id, uint16_t slave_id,
219 * Get COLLECTING flag from slave port actor state.
221 * @param port_id Bonding device id
222 * @param slave_id Port id of valid slave.
226 * -EINVAL if slave is not valid.
229 rte_eth_bond_8023ad_ext_collect_get(uint16_t port_id, uint16_t slave_id);
232 * Configure a slave port to start distributing.
234 * @param port_id Bonding device id
235 * @param slave_id Port id of valid slave.
236 * @param enabled Non-zero when distribution enabled.
239 * -EINVAL if slave is not valid.
242 rte_eth_bond_8023ad_ext_distrib(uint16_t port_id, uint16_t slave_id,
246 * Get DISTRIBUTING flag from slave port actor state.
248 * @param port_id Bonding device id
249 * @param slave_id Port id of valid slave.
253 * -EINVAL if slave is not valid.
256 rte_eth_bond_8023ad_ext_distrib_get(uint16_t port_id, uint16_t slave_id);
259 * LACPDU transmit path for external 802.3ad state machine. Caller retains
260 * ownership of the packet on failure.
262 * @param port_id Bonding device id
263 * @param slave_id Port ID of valid slave device.
264 * @param lacp_pkt mbuf containing LACPDU.
267 * 0 on success, negative value otherwise.
270 rte_eth_bond_8023ad_ext_slowtx(uint16_t port_id, uint16_t slave_id,
271 struct rte_mbuf *lacp_pkt);
274 * Enable dedicated hw queues for 802.3ad control plane traffic on on slaves
276 * This function creates an additional tx and rx queue on each slave for
277 * dedicated 802.3ad control plane traffic . A flow filtering rule is
278 * programmed on each slave to redirect all LACP slow packets to that rx queue
279 * for processing in the LACP state machine, this removes the need to filter
280 * these packets in the bonded devices data path. The additional tx queue is
281 * used to enable the LACP state machine to enqueue LACP packets directly to
282 * slave hw independently of the bonded devices data path.
284 * To use this feature all slaves must support the programming of the flow
285 * filter rule required for rx and have enough queues that one rx and tx queue
286 * can be reserved for the LACP state machines control packets.
288 * Bonding port must be stopped to change this configuration.
290 * @param port_id Bonding device id
293 * 0 on success, negative value otherwise.
296 rte_eth_bond_8023ad_dedicated_queues_enable(uint16_t port_id);
299 * Disable slow queue on slaves
301 * This function disables hardware slow packet filter.
303 * Bonding port must be stopped to change this configuration.
305 * @see rte_eth_bond_8023ad_slow_pkt_hw_filter_enable
307 * @param port_id Bonding device id
309 * 0 on success, negative value otherwise.
313 rte_eth_bond_8023ad_dedicated_queues_disable(uint16_t port_id);
316 * Get aggregator mode for 8023ad
317 * @param port_id Bonding device id
320 * agregator mode on success, negative value otherwise
323 rte_eth_bond_8023ad_agg_selection_get(uint16_t port_id);
326 * Set aggregator mode for 8023ad
327 * @param port_id Bonding device id
329 * 0 on success, negative value otherwise
332 rte_eth_bond_8023ad_agg_selection_set(uint16_t port_id,
333 enum rte_bond_8023ad_agg_selection agg_selection);
334 #endif /* RTE_ETH_BOND_8023AD_H_ */