Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2018-2021 Beijing WangXun Technology Co., Ltd.
3 : : * Copyright(c) 2010-2017 Intel Corporation
4 : : */
5 : :
6 : : #ifndef _NGBE_ETHDEV_H_
7 : : #define _NGBE_ETHDEV_H_
8 : :
9 : : #include "ngbe_ptypes.h"
10 : : #include <rte_time.h>
11 : : #include <rte_ethdev.h>
12 : : #include <rte_ethdev_core.h>
13 : :
14 : : /* need update link, bit flag */
15 : : #define NGBE_FLAG_NEED_LINK_UPDATE ((uint32_t)(1 << 0))
16 : : #define NGBE_FLAG_MAILBOX ((uint32_t)(1 << 1))
17 : : #define NGBE_FLAG_PHY_INTERRUPT ((uint32_t)(1 << 2))
18 : : #define NGBE_FLAG_MACSEC ((uint32_t)(1 << 3))
19 : : #define NGBE_FLAG_NEED_LINK_CONFIG ((uint32_t)(1 << 4))
20 : : #define NGBE_FLAG_OVERHEAT ((uint32_t)(1 << 5))
21 : :
22 : : #define NGBE_VFTA_SIZE 128
23 : : #define NGBE_HKEY_MAX_INDEX 10
24 : : /*Default value of Max Rx Queue*/
25 : : #define NGBE_MAX_RX_QUEUE_NUM 8
26 : :
27 : : #ifndef NBBY
28 : : #define NBBY 8 /* number of bits in a byte */
29 : : #endif
30 : : #define NGBE_HWSTRIP_BITMAP_SIZE \
31 : : (NGBE_MAX_RX_QUEUE_NUM / (sizeof(uint32_t) * NBBY))
32 : :
33 : : #define NGBE_QUEUE_ITR_INTERVAL_DEFAULT 500 /* 500us */
34 : :
35 : : #define NGBE_MAX_MTU 9414
36 : : /* The overhead from MTU to max frame size. */
37 : : #define NGBE_ETH_OVERHEAD (RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN)
38 : :
39 : : #define NGBE_RSS_OFFLOAD_ALL ( \
40 : : RTE_ETH_RSS_IPV4 | \
41 : : RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
42 : : RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
43 : : RTE_ETH_RSS_NONFRAG_IPV4_SCTP | \
44 : : RTE_ETH_RSS_IPV6 | \
45 : : RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
46 : : RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
47 : : RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
48 : : RTE_ETH_RSS_IPV6_EX | \
49 : : RTE_ETH_RSS_IPV6_TCP_EX | \
50 : : RTE_ETH_RSS_IPV6_UDP_EX)
51 : :
52 : : #define NGBE_MISC_VEC_ID RTE_INTR_VEC_ZERO_OFFSET
53 : : #define NGBE_RX_VEC_START RTE_INTR_VEC_RXTX_OFFSET
54 : :
55 : : /* structure for interrupt relative data */
56 : : struct ngbe_interrupt {
57 : : uint32_t flags;
58 : : uint32_t mask_misc;
59 : : uint32_t mask_misc_orig; /* save mask during delayed handler */
60 : : uint64_t mask;
61 : : uint64_t mask_orig; /* save mask during delayed handler */
62 : : };
63 : :
64 : : struct ngbe_vfta {
65 : : uint32_t vfta[NGBE_VFTA_SIZE];
66 : : };
67 : :
68 : : struct ngbe_hwstrip {
69 : : uint32_t bitmap[NGBE_HWSTRIP_BITMAP_SIZE];
70 : : };
71 : :
72 : : /**
73 : : * Response sent back to ngbe driver from user app after callback
74 : : */
75 : : enum ngbe_mb_event_rsp {
76 : : NGBE_MB_EVENT_NOOP_ACK, /**< skip mbox request and ACK */
77 : : NGBE_MB_EVENT_NOOP_NACK, /**< skip mbox request and NACK */
78 : : NGBE_MB_EVENT_PROCEED, /**< proceed with mbox request */
79 : : NGBE_MB_EVENT_MAX /**< max value of this enum */
80 : : };
81 : :
82 : : /**
83 : : * Data sent to the user application when the callback is executed.
84 : : */
85 : : struct ngbe_mb_event_param {
86 : : uint16_t vfid; /**< Virtual Function number */
87 : : uint16_t msg_type; /**< VF to PF message type, defined in ngbe_mbx.h */
88 : : uint16_t retval; /**< return value */
89 : : void *msg; /**< pointer to message */
90 : : };
91 : :
92 : : /*
93 : : * VF data which used by PF host only
94 : : */
95 : : #define NGBE_MAX_VF_MC_ENTRIES 30
96 : :
97 : : struct ngbe_uta_info {
98 : : uint8_t uc_filter_type;
99 : : uint16_t uta_in_use;
100 : : uint32_t uta_shadow[NGBE_MAX_UTA];
101 : : };
102 : :
103 : : struct ngbe_vf_info {
104 : : uint8_t vf_mac_addresses[RTE_ETHER_ADDR_LEN];
105 : : uint16_t vf_mc_hashes[NGBE_MAX_VF_MC_ENTRIES];
106 : : uint16_t num_vf_mc_hashes;
107 : : bool clear_to_send;
108 : : uint16_t vlan_count;
109 : : uint8_t api_version;
110 : : uint16_t switch_domain_id;
111 : : uint16_t xcast_mode;
112 : : uint16_t mac_count;
113 : : };
114 : :
115 : : /*
116 : : * Structure to store private data for each driver instance (for each port).
117 : : */
118 : : struct ngbe_adapter {
119 : : struct ngbe_hw hw;
120 : : struct ngbe_hw_stats stats;
121 : : struct ngbe_interrupt intr;
122 : : struct ngbe_vfta shadow_vfta;
123 : : struct ngbe_hwstrip hwstrip;
124 : : struct ngbe_vf_info *vfdata;
125 : : struct ngbe_uta_info uta_info;
126 : : bool rx_bulk_alloc_allowed;
127 : : bool rx_vec_allowed;
128 : : struct rte_timecounter systime_tc;
129 : : struct rte_timecounter rx_tstamp_tc;
130 : : struct rte_timecounter tx_tstamp_tc;
131 : :
132 : : /* For RSS reta table update */
133 : : uint8_t rss_reta_updated;
134 : : };
135 : :
136 : : static inline struct ngbe_adapter *
137 : : ngbe_dev_adapter(struct rte_eth_dev *dev)
138 : : {
139 [ # # # # : 0 : struct ngbe_adapter *ad = dev->data->dev_private;
# # # # #
# # # # #
# # # # ]
140 : :
141 : : return ad;
142 : : }
143 : :
144 : : static inline struct ngbe_hw *
145 : : ngbe_dev_hw(struct rte_eth_dev *dev)
146 : : {
147 : : struct ngbe_adapter *ad = ngbe_dev_adapter(dev);
148 [ # # # # : 0 : struct ngbe_hw *hw = &ad->hw;
# # # # #
# # # # #
# # # # ]
149 : :
150 : : return hw;
151 : : }
152 : :
153 : : #define NGBE_DEV_STATS(dev) \
154 : : (&((struct ngbe_adapter *)(dev)->data->dev_private)->stats)
155 : :
156 : : static inline struct ngbe_interrupt *
157 : : ngbe_dev_intr(struct rte_eth_dev *dev)
158 : : {
159 : : struct ngbe_adapter *ad = ngbe_dev_adapter(dev);
160 : : struct ngbe_interrupt *intr = &ad->intr;
161 : :
162 : : return intr;
163 : : }
164 : :
165 : : #define NGBE_DEV_VFTA(dev) \
166 : : (&((struct ngbe_adapter *)(dev)->data->dev_private)->shadow_vfta)
167 : :
168 : : #define NGBE_DEV_HWSTRIP(dev) \
169 : : (&((struct ngbe_adapter *)(dev)->data->dev_private)->hwstrip)
170 : :
171 : : #define NGBE_DEV_VFDATA(dev) \
172 : : (&((struct ngbe_adapter *)(dev)->data->dev_private)->vfdata)
173 : :
174 : : #define NGBE_DEV_UTA_INFO(dev) \
175 : : (&((struct ngbe_adapter *)(dev)->data->dev_private)->uta_info)
176 : :
177 : : /*
178 : : * Rx/Tx function prototypes
179 : : */
180 : : void ngbe_dev_clear_queues(struct rte_eth_dev *dev);
181 : :
182 : : void ngbe_dev_free_queues(struct rte_eth_dev *dev);
183 : :
184 : : void ngbe_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
185 : :
186 : : void ngbe_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
187 : :
188 : : int ngbe_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
189 : : uint16_t nb_rx_desc, unsigned int socket_id,
190 : : const struct rte_eth_rxconf *rx_conf,
191 : : struct rte_mempool *mb_pool);
192 : :
193 : : int ngbe_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
194 : : uint16_t nb_tx_desc, unsigned int socket_id,
195 : : const struct rte_eth_txconf *tx_conf);
196 : :
197 : : int ngbe_dev_rx_queue_count(void *rx_queue);
198 : :
199 : : int ngbe_dev_rx_descriptor_status(void *rx_queue, uint16_t offset);
200 : : int ngbe_dev_tx_descriptor_status(void *tx_queue, uint16_t offset);
201 : :
202 : : int ngbe_dev_rx_init(struct rte_eth_dev *dev);
203 : :
204 : : void ngbe_dev_tx_init(struct rte_eth_dev *dev);
205 : :
206 : : int ngbe_dev_rxtx_start(struct rte_eth_dev *dev);
207 : :
208 : : void ngbe_dev_save_rx_queue(struct ngbe_hw *hw, uint16_t rx_queue_id);
209 : : void ngbe_dev_store_rx_queue(struct ngbe_hw *hw, uint16_t rx_queue_id);
210 : : void ngbe_dev_save_tx_queue(struct ngbe_hw *hw, uint16_t tx_queue_id);
211 : : void ngbe_dev_store_tx_queue(struct ngbe_hw *hw, uint16_t tx_queue_id);
212 : :
213 : : int ngbe_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
214 : :
215 : : int ngbe_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
216 : :
217 : : int ngbe_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
218 : :
219 : : int ngbe_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
220 : :
221 : : void ngbe_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
222 : : struct rte_eth_rxq_info *qinfo);
223 : :
224 : : void ngbe_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
225 : : struct rte_eth_txq_info *qinfo);
226 : :
227 : : int
228 : : ngbe_rx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
229 : : struct rte_eth_burst_mode *mode);
230 : : int
231 : : ngbe_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
232 : : struct rte_eth_burst_mode *mode);
233 : :
234 : : int ngbevf_dev_rx_init(struct rte_eth_dev *dev);
235 : :
236 : : void ngbevf_dev_tx_init(struct rte_eth_dev *dev);
237 : :
238 : : void ngbevf_dev_rxtx_start(struct rte_eth_dev *dev);
239 : :
240 : : uint16_t ngbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
241 : : uint16_t nb_pkts);
242 : :
243 : : uint16_t ngbe_recv_pkts_bulk_alloc(void *rx_queue, struct rte_mbuf **rx_pkts,
244 : : uint16_t nb_pkts);
245 : :
246 : : uint16_t ngbe_recv_pkts_sc_single_alloc(void *rx_queue,
247 : : struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
248 : : uint16_t ngbe_recv_pkts_sc_bulk_alloc(void *rx_queue,
249 : : struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
250 : :
251 : : uint16_t ngbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
252 : : uint16_t nb_pkts);
253 : :
254 : : uint16_t ngbe_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,
255 : : uint16_t nb_pkts);
256 : :
257 : : uint16_t ngbe_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
258 : : uint16_t nb_pkts);
259 : :
260 : : int ngbe_dev_rss_hash_update(struct rte_eth_dev *dev,
261 : : struct rte_eth_rss_conf *rss_conf);
262 : :
263 : : int ngbe_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
264 : : struct rte_eth_rss_conf *rss_conf);
265 : :
266 : : void ngbe_set_ivar_map(struct ngbe_hw *hw, int8_t direction,
267 : : uint8_t queue, uint8_t msix_vector);
268 : :
269 : : void ngbe_configure_port(struct rte_eth_dev *dev);
270 : :
271 : : int
272 : : ngbe_dev_link_update_share(struct rte_eth_dev *dev,
273 : : int wait_to_complete);
274 : :
275 : : /*
276 : : * misc function prototypes
277 : : */
278 : : void ngbe_vlan_hw_filter_enable(struct rte_eth_dev *dev);
279 : :
280 : : void ngbe_vlan_hw_filter_disable(struct rte_eth_dev *dev);
281 : :
282 : : void ngbe_vlan_hw_strip_config(struct rte_eth_dev *dev);
283 : :
284 : : int ngbe_pf_host_init(struct rte_eth_dev *eth_dev);
285 : :
286 : : void ngbe_pf_host_uninit(struct rte_eth_dev *eth_dev);
287 : :
288 : : void ngbe_pf_mbx_process(struct rte_eth_dev *eth_dev);
289 : :
290 : : int ngbe_pf_host_configure(struct rte_eth_dev *eth_dev);
291 : :
292 : : /* High threshold controlling when to start sending XOFF frames. */
293 : : #define NGBE_FC_XOFF_HITH 128 /*KB*/
294 : : /* Low threshold controlling when to start sending XON frames. */
295 : : #define NGBE_FC_XON_LOTH 64 /*KB*/
296 : :
297 : : /* Timer value included in XOFF frames. */
298 : : #define NGBE_FC_PAUSE_TIME 0x680
299 : :
300 : : #define NGBE_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
301 : : #define NGBE_LINK_UP_CHECK_TIMEOUT 1000 /* ms */
302 : : #define NGBE_VMDQ_NUM_UC_MAC 4096 /* Maximum nb. of UC MAC addr. */
303 : :
304 : : /*
305 : : * Default values for Rx/Tx configuration
306 : : */
307 : : #define NGBE_DEFAULT_RX_FREE_THRESH 32
308 : : #define NGBE_DEFAULT_RX_PTHRESH 8
309 : : #define NGBE_DEFAULT_RX_HTHRESH 8
310 : : #define NGBE_DEFAULT_RX_WTHRESH 0
311 : :
312 : : #define NGBE_DEFAULT_TX_FREE_THRESH 32
313 : : #define NGBE_DEFAULT_TX_PTHRESH 32
314 : : #define NGBE_DEFAULT_TX_HTHRESH 0
315 : : #define NGBE_DEFAULT_TX_WTHRESH 0
316 : :
317 : : /* Additional timesync values. */
318 : : #define NGBE_INCVAL_1GB 0x2000000 /* all speed is same in Emerald */
319 : : #define NGBE_INCVAL_SHIFT_1GB 22 /* all speed is same in Emerald */
320 : :
321 : : #define NGBE_CYCLECOUNTER_MASK 0xffffffffffffffffULL
322 : :
323 : : /* store statistics names and its offset in stats structure */
324 : : struct rte_ngbe_xstats_name_off {
325 : : char name[RTE_ETH_XSTATS_NAME_SIZE];
326 : : unsigned int offset;
327 : : };
328 : :
329 : : const uint32_t *ngbe_dev_supported_ptypes_get(struct rte_eth_dev *dev,
330 : : size_t *no_of_elements);
331 : : int ngbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
332 : : struct rte_ether_addr *mc_addr_set,
333 : : uint32_t nb_mc_addr);
334 : : int ngbe_dev_rss_reta_update(struct rte_eth_dev *dev,
335 : : struct rte_eth_rss_reta_entry64 *reta_conf,
336 : : uint16_t reta_size);
337 : : int ngbe_dev_rss_reta_query(struct rte_eth_dev *dev,
338 : : struct rte_eth_rss_reta_entry64 *reta_conf,
339 : : uint16_t reta_size);
340 : : void ngbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev,
341 : : uint16_t queue, bool on);
342 : : void ngbe_config_vlan_strip_on_all_queues(struct rte_eth_dev *dev,
343 : : int mask);
344 : : void ngbe_read_stats_registers(struct ngbe_hw *hw,
345 : : struct ngbe_hw_stats *hw_stats);
346 : :
347 : : #endif /* _NGBE_ETHDEV_H_ */
|