DPDK  18.11.11
rte_eth_bond_8023ad.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
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
11 extern "C" {
12 #endif
13 
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 
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 
38 typedef void (*rte_eth_bond_8023ad_ext_slowrx_fn)(uint16_t slave_id,
39  struct rte_mbuf *lacp_pkt);
40 
41 enum rte_bond_8023ad_selection {
42  UNSELECTED,
43  STANDBY,
44  SELECTED
45 };
46 
47 enum rte_bond_8023ad_agg_selection {
48  AGG_BANDWIDTH,
49  AGG_COUNT,
50  AGG_STABLE
51 };
52 
54 struct slow_protocol {
55  uint8_t subtype;
56  uint8_t reserved_119[119];
57 } __attribute__((__packed__));
58 
61  struct ether_hdr eth_hdr;
62  struct slow_protocol slow_protocol;
63 } __attribute__((__packed__));
64 
65 struct port_params {
66  uint16_t system_priority;
68  struct ether_addr system;
70  uint16_t key;
72  uint16_t port_priority;
74  uint16_t port_number;
76 } __attribute__((__packed__));
77 
78 struct 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 
87 struct 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 
106  struct ether_hdr eth_hdr;
107  struct lacpdu lacpdu;
108 } __attribute__((__packed__));
109 
110 struct 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 
126 struct marker_header {
127  struct ether_hdr eth_hdr;
128  struct marker marker;
129 } __attribute__((__packed__));
130 
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;
142 };
143 
144 struct 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;
150  uint16_t agg_port_id;
151 };
152 
165 int
166 rte_eth_bond_8023ad_conf_get(uint16_t port_id,
167  struct rte_eth_bond_8023ad_conf *conf);
168 
180 int
181 rte_eth_bond_8023ad_setup(uint16_t port_id,
182  struct rte_eth_bond_8023ad_conf *conf);
183 
196 int
197 rte_eth_bond_8023ad_slave_info(uint16_t port_id, uint16_t slave_id,
198  struct rte_eth_bond_8023ad_slave_info *conf);
199 
200 #ifdef __cplusplus
201 }
202 #endif
203 
214 int
215 rte_eth_bond_8023ad_ext_collect(uint16_t port_id, uint16_t slave_id,
216  int enabled);
217 
228 int
229 rte_eth_bond_8023ad_ext_collect_get(uint16_t port_id, uint16_t slave_id);
230 
241 int
242 rte_eth_bond_8023ad_ext_distrib(uint16_t port_id, uint16_t slave_id,
243  int enabled);
244 
255 int
256 rte_eth_bond_8023ad_ext_distrib_get(uint16_t port_id, uint16_t slave_id);
257 
269 int
270 rte_eth_bond_8023ad_ext_slowtx(uint16_t port_id, uint16_t slave_id,
271  struct rte_mbuf *lacp_pkt);
272 
295 int
296 rte_eth_bond_8023ad_dedicated_queues_enable(uint16_t port_id);
297 
312 int
313 rte_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  */
322 int
323 rte_eth_bond_8023ad_agg_selection_get(uint16_t port_id);
324 
331 int
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_ */