]> git.proxmox.com Git - ceph.git/blame - ceph/src/seastar/dpdk/drivers/net/bonding/rte_eth_bond_8023ad.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / seastar / dpdk / drivers / net / bonding / rte_eth_bond_8023ad.h
CommitLineData
9f95a23c
TL
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
7c673cae
FG
3 */
4
5#ifndef RTE_ETH_BOND_8023AD_H_
6#define RTE_ETH_BOND_8023AD_H_
7
8#include <rte_ether.h>
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14/**
15 * Actor/partner states
16 */
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
26
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
31
32#define SLOW_SUBTYPE_LACP 0x01
33#define SLOW_SUBTYPE_MARKER 0x02
34
35#define MARKER_TLV_TYPE_INFO 0x01
36#define MARKER_TLV_TYPE_RESP 0x02
37
9f95a23c 38typedef void (*rte_eth_bond_8023ad_ext_slowrx_fn)(uint16_t slave_id,
7c673cae
FG
39 struct rte_mbuf *lacp_pkt);
40
41enum rte_bond_8023ad_selection {
42 UNSELECTED,
43 STANDBY,
44 SELECTED
45};
46
9f95a23c
TL
47enum rte_bond_8023ad_agg_selection {
48 AGG_BANDWIDTH,
49 AGG_COUNT,
50 AGG_STABLE
51};
52
7c673cae
FG
53/** Generic slow protocol structure */
54struct slow_protocol {
55 uint8_t subtype;
56 uint8_t reserved_119[119];
57} __attribute__((__packed__));
58
59/** Generic slow protocol frame type structure */
60struct slow_protocol_frame {
61 struct ether_hdr eth_hdr;
62 struct slow_protocol slow_protocol;
63} __attribute__((__packed__));
64
65struct port_params {
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 */
70 uint16_t key;
71 /**< Speed information (implementation dependednt) and duplex. */
72 uint16_t port_priority;
73 /**< Priority of this (unused in current implementation) */
74 uint16_t port_number;
75 /**< Port number. It corresponds to slave port id. */
76} __attribute__((__packed__));
77
78struct lacpdu_actor_partner_params {
79 uint8_t tlv_type_info;
80 uint8_t info_length;
81 struct port_params port_params;
82 uint8_t state;
83 uint8_t reserved_3[3];
84} __attribute__((__packed__));
85
86/** LACPDU structure (5.4.2 in 802.1AX documentation). */
87struct lacpdu {
88 uint8_t subtype;
89 uint8_t version_number;
90
91 struct lacpdu_actor_partner_params actor;
92 struct lacpdu_actor_partner_params partner;
93
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];
98
99 uint8_t tlv_type_terminator;
100 uint8_t terminator_length;
101 uint8_t reserved_50[50];
102} __attribute__((__packed__));
103
104/** LACPDU frame: Contains ethernet header and LACPDU. */
105struct lacpdu_header {
106 struct ether_hdr eth_hdr;
107 struct lacpdu lacpdu;
108} __attribute__((__packed__));
109
110struct marker {
111 uint8_t subtype;
112 uint8_t version_number;
113
114 uint8_t tlv_type_marker;
115 uint8_t info_length;
116 uint16_t requester_port;
117 struct ether_addr requester_system;
118 uint32_t requester_transaction_id;
119 uint8_t reserved_2[2];
120
121 uint8_t tlv_type_terminator;
122 uint8_t terminator_length;
123 uint8_t reserved_90[90];
124} __attribute__((__packed__));
125
126struct marker_header {
127 struct ether_hdr eth_hdr;
128 struct marker marker;
129} __attribute__((__packed__));
130
131struct 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;
9f95a23c 141 enum rte_bond_8023ad_agg_selection agg_selection;
7c673cae
FG
142};
143
144struct rte_eth_bond_8023ad_slave_info {
145 enum rte_bond_8023ad_selection selected;
146 uint8_t actor_state;
147 struct port_params actor;
148 uint8_t partner_state;
149 struct port_params partner;
9f95a23c 150 uint16_t agg_port_id;
7c673cae
FG
151};
152
153/**
154 * @internal
155 *
156 * Function returns current configuration of 802.3AX mode.
157 *
158 * @param port_id Bonding device id
159 * @param conf Pointer to timeout structure.
160 *
161 * @return
162 * 0 - if ok
163 * -EINVAL if conf is NULL
164 */
165int
9f95a23c 166rte_eth_bond_8023ad_conf_get(uint16_t port_id,
7c673cae
FG
167 struct rte_eth_bond_8023ad_conf *conf);
168
169/**
170 * @internal
171 *
172 * Function set new configuration of 802.3AX mode.
173 *
174 * @param port_id Bonding device id
175 * @param conf Configuration, if NULL set default configuration.
176 * @return
177 * 0 - if ok
178 * -EINVAL if configuration is invalid.
179 */
180int
9f95a23c 181rte_eth_bond_8023ad_setup(uint16_t port_id,
7c673cae
FG
182 struct rte_eth_bond_8023ad_conf *conf);
183
184/**
185 * @internal
186 *
187 * Function returns current state of given slave device.
188 *
189 * @param slave_id Port id of valid slave.
190 * @param conf buffer for configuration
191 * @return
192 * 0 - if ok
193 * -EINVAL if conf is NULL or slave id is invalid (not a slave of given
194 * bonded device or is not inactive).
195 */
196int
9f95a23c 197rte_eth_bond_8023ad_slave_info(uint16_t port_id, uint16_t slave_id,
7c673cae
FG
198 struct rte_eth_bond_8023ad_slave_info *conf);
199
200#ifdef __cplusplus
201}
202#endif
203
204/**
205 * Configure a slave port to start collecting.
206 *
207 * @param port_id Bonding device id
208 * @param slave_id Port id of valid slave.
209 * @param enabled Non-zero when collection enabled.
210 * @return
211 * 0 - if ok
212 * -EINVAL if slave is not valid.
213 */
214int
9f95a23c
TL
215rte_eth_bond_8023ad_ext_collect(uint16_t port_id, uint16_t slave_id,
216 int enabled);
7c673cae
FG
217
218/**
219 * Get COLLECTING flag from slave port actor state.
220 *
221 * @param port_id Bonding device id
222 * @param slave_id Port id of valid slave.
223 * @return
224 * 0 - if not set
225 * 1 - if set
226 * -EINVAL if slave is not valid.
227 */
228int
9f95a23c 229rte_eth_bond_8023ad_ext_collect_get(uint16_t port_id, uint16_t slave_id);
7c673cae
FG
230
231/**
232 * Configure a slave port to start distributing.
233 *
234 * @param port_id Bonding device id
235 * @param slave_id Port id of valid slave.
236 * @param enabled Non-zero when distribution enabled.
237 * @return
238 * 0 - if ok
239 * -EINVAL if slave is not valid.
240 */
241int
9f95a23c
TL
242rte_eth_bond_8023ad_ext_distrib(uint16_t port_id, uint16_t slave_id,
243 int enabled);
7c673cae
FG
244
245/**
246 * Get DISTRIBUTING flag from slave port actor state.
247 *
248 * @param port_id Bonding device id
249 * @param slave_id Port id of valid slave.
250 * @return
251 * 0 - if not set
252 * 1 - if set
253 * -EINVAL if slave is not valid.
254 */
255int
9f95a23c 256rte_eth_bond_8023ad_ext_distrib_get(uint16_t port_id, uint16_t slave_id);
7c673cae
FG
257
258/**
259 * LACPDU transmit path for external 802.3ad state machine. Caller retains
260 * ownership of the packet on failure.
261 *
262 * @param port_id Bonding device id
263 * @param slave_id Port ID of valid slave device.
264 * @param lacp_pkt mbuf containing LACPDU.
265 *
266 * @return
267 * 0 on success, negative value otherwise.
268 */
269int
9f95a23c 270rte_eth_bond_8023ad_ext_slowtx(uint16_t port_id, uint16_t slave_id,
7c673cae
FG
271 struct rte_mbuf *lacp_pkt);
272
9f95a23c
TL
273/**
274 * Enable dedicated hw queues for 802.3ad control plane traffic on on slaves
275 *
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.
283 *
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.
287 *
288 * Bonding port must be stopped to change this configuration.
289 *
290 * @param port_id Bonding device id
291 *
292 * @return
293 * 0 on success, negative value otherwise.
294 */
295int
296rte_eth_bond_8023ad_dedicated_queues_enable(uint16_t port_id);
297
298/**
299 * Disable slow queue on slaves
300 *
301 * This function disables hardware slow packet filter.
302 *
303 * Bonding port must be stopped to change this configuration.
304 *
305 * @see rte_eth_bond_8023ad_slow_pkt_hw_filter_enable
306 *
307 * @param port_id Bonding device id
308 * @return
309 * 0 on success, negative value otherwise.
310 *
311 */
312int
313rte_eth_bond_8023ad_dedicated_queues_disable(uint16_t port_id);
314
315/*
316 * Get aggregator mode for 8023ad
317 * @param port_id Bonding device id
318 *
319 * @return
320 * agregator mode on success, negative value otherwise
321 */
322int
323rte_eth_bond_8023ad_agg_selection_get(uint16_t port_id);
324
325/**
326 * Set aggregator mode for 8023ad
327 * @param port_id Bonding device id
328 * @return
329 * 0 on success, negative value otherwise
330 */
331int
332rte_eth_bond_8023ad_agg_selection_set(uint16_t port_id,
333 enum rte_bond_8023ad_agg_selection agg_selection);
7c673cae 334#endif /* RTE_ETH_BOND_8023AD_H_ */