DPDK  19.02.0
rte_eth_bond_8023ad_private.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4 
5 #ifndef RTE_ETH_BOND_8023AD_PRIVATE_H_
6 #define RTE_ETH_BOND_8023AD_PRIVATE_H_
7 
8 #include <stdint.h>
9 
10 #include <rte_ether.h>
11 #include <rte_byteorder.h>
12 #include <rte_atomic.h>
13 #include <rte_flow.h>
14 
15 #include "rte_eth_bond_8023ad.h"
16 
17 #define BOND_MODE_8023AX_UPDATE_TIMEOUT_MS 100
18 
19 #define BOND_MODE_8023AX_SLAVE_RX_PKTS 3
20 
21 #define BOND_MODE_8023AX_SLAVE_TX_PKTS 1
22 
25 #define BOND_8023AD_FAST_PERIODIC_MS 900
26 #define BOND_8023AD_SLOW_PERIODIC_MS 29000
27 #define BOND_8023AD_SHORT_TIMEOUT_MS 3000
28 #define BOND_8023AD_LONG_TIMEOUT_MS 90000
29 #define BOND_8023AD_CHURN_DETECTION_TIMEOUT_MS 60000
30 #define BOND_8023AD_AGGREGATE_WAIT_TIMEOUT_MS 2000
31 #define BOND_8023AD_TX_MACHINE_PERIOD_MS 500
32 #define BOND_8023AD_RX_MARKER_PERIOD_MS 2000
33 
39 #define BOND_8023AD_WARNINGS_PERIOD_MS 1000
40 
41 
42 
46 #define SM_FLAGS_BEGIN 0x0001
47 #define SM_FLAGS_LACP_ENABLED 0x0002
48 #define SM_FLAGS_ACTOR_CHURN 0x0004
49 #define SM_FLAGS_PARTNER_CHURN 0x0008
50 #define SM_FLAGS_MOVED 0x0100
51 #define SM_FLAGS_PARTNER_SHORT_TIMEOUT 0x0200
52 #define SM_FLAGS_NTT 0x0400
53 
54 #define BOND_LINK_FULL_DUPLEX_KEY 0x01
55 #define BOND_LINK_SPEED_KEY_10M 0x02
56 #define BOND_LINK_SPEED_KEY_100M 0x04
57 #define BOND_LINK_SPEED_KEY_1000M 0x08
58 #define BOND_LINK_SPEED_KEY_10G 0x10
59 #define BOND_LINK_SPEED_KEY_20G 0x11
60 #define BOND_LINK_SPEED_KEY_40G 0x12
61 
62 #define WRN_RX_MARKER_TO_FAST 0x01
63 #define WRN_UNKNOWN_SLOW_TYPE 0x02
64 #define WRN_UNKNOWN_MARKER_TYPE 0x04
65 #define WRN_NOT_LACP_CAPABLE 0x08
66 #define WRN_RX_QUEUE_FULL 0x10
67 #define WRN_TX_QUEUE_FULL 0x20
68 
69 #define CHECK_FLAGS(_variable, _f) ((_variable) & (_f))
70 #define SET_FLAGS(_variable, _f) ((_variable) |= (_f))
71 #define CLEAR_FLAGS(_variable, _f) ((_variable) &= ~(_f))
72 
73 #define SM_FLAG(_p, _f) (!!CHECK_FLAGS((_p)->sm_flags, SM_FLAGS_ ## _f))
74 #define SM_FLAG_SET(_p, _f) SET_FLAGS((_p)->sm_flags, SM_FLAGS_ ## _f)
75 #define SM_FLAG_CLR(_p, _f) CLEAR_FLAGS((_p)->sm_flags, SM_FLAGS_ ## _f)
76 
77 #define ACTOR_STATE(_p, _f) (!!CHECK_FLAGS((_p)->actor_state, STATE_ ## _f))
78 #define ACTOR_STATE_SET(_p, _f) SET_FLAGS((_p)->actor_state, STATE_ ## _f)
79 #define ACTOR_STATE_CLR(_p, _f) CLEAR_FLAGS((_p)->actor_state, STATE_ ## _f)
80 
81 #define PARTNER_STATE(_p, _f) (!!CHECK_FLAGS((_p)->partner_state, STATE_ ## _f))
82 #define PARTNER_STATE_SET(_p, _f) SET_FLAGS((_p)->partner_state, STATE_ ## _f)
83 #define PARTNER_STATE_CLR(_p, _f) CLEAR_FLAGS((_p)->partner_state, STATE_ ## _f)
84 
86 struct port {
91  uint8_t actor_state;
92 
94  struct port_params actor;
95 
102  uint8_t partner_state;
103 
105  struct port_params partner;
106 
107  /* Additional port parameters not listed in documentation */
109  uint16_t sm_flags;
110  enum rte_bond_8023ad_selection selected;
111 
112  uint64_t current_while_timer;
113  uint64_t periodic_timer;
114  uint64_t wait_while_timer;
115  uint64_t tx_machine_timer;
116  uint64_t tx_marker_timer;
117  /* Agregator parameters */
120 
123 
125  struct rte_ring *rx_ring;
126 
128  struct rte_ring *tx_ring;
129 
133  volatile uint64_t rx_marker_timer;
134 
135  uint64_t warning_timer;
136  volatile uint16_t warnings_to_show;
137 
140 };
141 
142 struct mode8023ad_private {
143  uint64_t fast_periodic_timeout;
144  uint64_t slow_periodic_timeout;
145  uint64_t short_timeout;
146  uint64_t long_timeout;
147  uint64_t aggregate_wait_timeout;
148  uint64_t tx_period_timeout;
149  uint64_t rx_marker_timeout;
150  uint64_t update_timeout_us;
151  rte_eth_bond_8023ad_ext_slowrx_fn slowrx_cb;
152  uint8_t external_sm;
153 
154  struct rte_eth_link slave_link;
155  /***< slave link properties */
156 
161  struct {
162  uint8_t enabled;
163 
164  struct rte_flow *flow[RTE_MAX_ETHPORTS];
165 
166  uint16_t rx_qid;
167  uint16_t tx_qid;
168  } dedicated_queues;
169  enum rte_bond_8023ad_agg_selection agg_selection;
170 };
171 
177 extern struct port bond_mode_8023ad_ports[];
178 
179 /* Forward declaration */
180 struct bond_dev_private;
181 
182 
193 void
194 bond_mode_8023ad_setup(struct rte_eth_dev *dev,
195  struct rte_eth_bond_8023ad_conf *conf);
196 
206 int
207 bond_mode_8023ad_enable(struct rte_eth_dev *dev);
208 
218 int bond_mode_8023ad_disable(struct rte_eth_dev *dev);
219 
229 int
230 bond_mode_8023ad_start(struct rte_eth_dev *dev);
231 
240 void
241 bond_mode_8023ad_stop(struct rte_eth_dev *dev);
242 
251 void
252 bond_mode_8023ad_handle_slow_pkt(struct bond_dev_private *internals,
253  uint16_t slave_id, struct rte_mbuf *pkt);
254 
266 void
267 bond_mode_8023ad_activate_slave(struct rte_eth_dev *dev, uint16_t port_id);
268 
280 int
281 bond_mode_8023ad_deactivate_slave(struct rte_eth_dev *dev, uint16_t slave_pos);
282 
287 void
288 bond_mode_8023ad_mac_address_update(struct rte_eth_dev *bond_dev);
289 
290 int
291 bond_ethdev_8023ad_flow_verify(struct rte_eth_dev *bond_dev,
292  uint16_t slave_port);
293 
294 int
295 bond_ethdev_8023ad_flow_set(struct rte_eth_dev *bond_dev, uint16_t slave_port);
296 
297 int
298 bond_8023ad_slow_pkt_hw_filter_supported(uint16_t port_id);
299 
300 #endif /* RTE_ETH_BOND_8023AD_H_ */