Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2015-2020 Beijing WangXun Technology Co., Ltd.
3 : : * Copyright(c) 2010-2017 Intel Corporation
4 : : */
5 : :
6 : : #ifndef _TXGBE_ETHDEV_H_
7 : : #define _TXGBE_ETHDEV_H_
8 : :
9 : : #include <stdint.h>
10 : :
11 : : #include "base/txgbe.h"
12 : : #include "txgbe_ptypes.h"
13 : : #ifdef RTE_LIB_SECURITY
14 : : #include "txgbe_ipsec.h"
15 : : #endif
16 : : #include <rte_flow.h>
17 : : #include <rte_flow_driver.h>
18 : : #include <rte_time.h>
19 : : #include <rte_ethdev.h>
20 : : #include <rte_ethdev_core.h>
21 : : #include <rte_hash.h>
22 : : #include <rte_hash_crc.h>
23 : : #include <bus_pci_driver.h>
24 : : #include <rte_tm_driver.h>
25 : :
26 : : /* need update link, bit flag */
27 : : #define TXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
28 : : #define TXGBE_FLAG_MAILBOX (uint32_t)(1 << 1)
29 : : #define TXGBE_FLAG_PHY_INTERRUPT (uint32_t)(1 << 2)
30 : : #define TXGBE_FLAG_MACSEC (uint32_t)(1 << 3)
31 : : #define TXGBE_FLAG_NEED_LINK_CONFIG (uint32_t)(1 << 4)
32 : : #define TXGBE_FLAG_NEED_AN_CONFIG (uint32_t)(1 << 5)
33 : : #define TXGBE_FLAG_OVERHEAT (uint32_t)(1 << 6)
34 : : #define TXGBE_FLAG_TX_DESC_ERR (uint32_t)(1 << 7)
35 : :
36 : : /*
37 : : * Defines that were not part of txgbe_type.h as they are not used by the
38 : : * FreeBSD driver.
39 : : */
40 : : #define TXGBE_VFTA_SIZE 128
41 : : #define TXGBE_HKEY_MAX_INDEX 10
42 : : /*Default value of Max Rx Queue*/
43 : : #define TXGBE_MAX_RX_QUEUE_NUM 128
44 : : #define TXGBE_VMDQ_DCB_NB_QUEUES TXGBE_MAX_RX_QUEUE_NUM
45 : : #define TXGBE_NONE_MODE_TX_NB_QUEUES 64
46 : :
47 : : #ifndef NBBY
48 : : #define NBBY 8 /* number of bits in a byte */
49 : : #endif
50 : : #define TXGBE_HWSTRIP_BITMAP_SIZE \
51 : : (TXGBE_MAX_RX_QUEUE_NUM / (sizeof(uint32_t) * NBBY))
52 : :
53 : : #define TXGBE_QUEUE_ITR_INTERVAL_DEFAULT 500 /* 500us */
54 : :
55 : : #define TXGBE_MAX_QUEUE_NUM_PER_VF 8
56 : :
57 : : #define TXGBE_5TUPLE_MAX_PRI 7
58 : : #define TXGBE_5TUPLE_MIN_PRI 1
59 : :
60 : : #define TXGBE_MAX_MTU 9414
61 : : /* The overhead from MTU to max frame size. */
62 : : #define TXGBE_ETH_OVERHEAD (RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN)
63 : :
64 : : #define TXGBE_RSS_OFFLOAD_ALL ( \
65 : : RTE_ETH_RSS_IPV4 | \
66 : : RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
67 : : RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
68 : : RTE_ETH_RSS_NONFRAG_IPV4_SCTP | \
69 : : RTE_ETH_RSS_IPV6 | \
70 : : RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
71 : : RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
72 : : RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
73 : : RTE_ETH_RSS_IPV6_EX | \
74 : : RTE_ETH_RSS_IPV6_TCP_EX | \
75 : : RTE_ETH_RSS_IPV6_UDP_EX)
76 : :
77 : : #define TXGBE_MISC_VEC_ID RTE_INTR_VEC_ZERO_OFFSET
78 : : #define TXGBE_RX_VEC_START RTE_INTR_VEC_RXTX_OFFSET
79 : :
80 : : #define TXGBE_MAX_FDIR_FILTER_NUM (1024 * 32)
81 : : #define TXGBE_MAX_L2_TN_FILTER_NUM 128
82 : :
83 : : /*
84 : : * Information about the fdir mode.
85 : : */
86 : : struct txgbe_hw_fdir_mask {
87 : : uint16_t vlan_tci_mask;
88 : : uint32_t src_ipv4_mask;
89 : : uint32_t dst_ipv4_mask;
90 : : uint16_t src_ipv6_mask;
91 : : uint16_t dst_ipv6_mask;
92 : : uint16_t src_port_mask;
93 : : uint16_t dst_port_mask;
94 : : uint16_t flex_bytes_mask;
95 : : uint8_t pkt_type_mask; /* reversed mask for hw */
96 : : };
97 : :
98 : : struct txgbe_fdir_filter {
99 : : TAILQ_ENTRY(txgbe_fdir_filter) entries;
100 : : struct txgbe_atr_input input; /* key of fdir filter*/
101 : : uint32_t fdirflags; /* drop or forward */
102 : : uint32_t fdirhash; /* hash value for fdir */
103 : : uint8_t queue; /* assigned rx queue */
104 : : };
105 : :
106 : : /* list of fdir filters */
107 : : TAILQ_HEAD(txgbe_fdir_filter_list, txgbe_fdir_filter);
108 : :
109 : : struct txgbe_fdir_rule {
110 : : struct txgbe_hw_fdir_mask mask;
111 : : struct txgbe_atr_input input; /* key of fdir filter */
112 : : bool b_spec; /* If TRUE, input, fdirflags, queue have meaning. */
113 : : bool b_mask; /* If TRUE, mask has meaning. */
114 : : enum rte_fdir_mode mode; /* IP, MAC VLAN, Tunnel */
115 : : uint32_t fdirflags; /* drop or forward */
116 : : uint32_t soft_id; /* an unique value for this rule */
117 : : uint8_t queue; /* assigned rx queue */
118 : : uint8_t flex_bytes_offset;
119 : : bool flex_relative;
120 : : };
121 : :
122 : : struct txgbe_hw_fdir_info {
123 : : struct txgbe_hw_fdir_mask mask;
124 : : uint8_t flex_bytes_offset;
125 : : bool flex_relative;
126 : : uint16_t collision;
127 : : uint16_t free;
128 : : uint16_t maxhash;
129 : : uint8_t maxlen;
130 : : uint64_t add;
131 : : uint64_t remove;
132 : : uint64_t f_add;
133 : : uint64_t f_remove;
134 : : struct txgbe_fdir_filter_list fdir_list; /* filter list*/
135 : : /* store the pointers of the filters, index is the hash value. */
136 : : struct txgbe_fdir_filter **hash_map;
137 : : struct rte_hash *hash_handle; /* cuckoo hash handler */
138 : : bool mask_added; /* If already got mask from consistent filter */
139 : : };
140 : :
141 : : struct txgbe_rte_flow_rss_conf {
142 : : struct rte_flow_action_rss conf; /**< RSS parameters. */
143 : : uint8_t key[TXGBE_HKEY_MAX_INDEX * sizeof(uint32_t)]; /* Hash key. */
144 : : uint16_t queue[TXGBE_MAX_RX_QUEUE_NUM]; /**< Queues indices to use. */
145 : : };
146 : :
147 : : /* structure for interrupt relative data */
148 : : struct txgbe_interrupt {
149 : : uint32_t flags;
150 : : uint32_t mask_misc;
151 : : uint32_t mask_misc_orig; /* save mask during delayed handler */
152 : : uint64_t mask;
153 : : uint64_t mask_orig; /* save mask during delayed handler */
154 : : };
155 : :
156 : : #define TXGBE_NB_STAT_MAPPING 32
157 : : #define QSM_REG_NB_BITS_PER_QMAP_FIELD 8
158 : : #define NB_QMAP_FIELDS_PER_QSM_REG 4
159 : : #define QMAP_FIELD_RESERVED_BITS_MASK 0x0f
160 : : struct txgbe_stat_mappings {
161 : : uint32_t tqsm[TXGBE_NB_STAT_MAPPING];
162 : : uint32_t rqsm[TXGBE_NB_STAT_MAPPING];
163 : : };
164 : :
165 : : struct txgbe_vfta {
166 : : uint32_t vfta[TXGBE_VFTA_SIZE];
167 : : };
168 : :
169 : : struct txgbe_hwstrip {
170 : : uint32_t bitmap[TXGBE_HWSTRIP_BITMAP_SIZE];
171 : : };
172 : :
173 : : /*
174 : : * VF data which used by PF host only
175 : : */
176 : : #define TXGBE_MAX_VF_MC_ENTRIES 30
177 : :
178 : : struct txgbe_uta_info {
179 : : uint8_t uc_filter_type;
180 : : uint16_t uta_in_use;
181 : : uint32_t uta_shadow[TXGBE_MAX_UTA];
182 : : };
183 : :
184 : : struct txgbe_vf_info {
185 : : uint8_t vf_mac_addresses[RTE_ETHER_ADDR_LEN];
186 : : uint16_t vf_mc_hashes[TXGBE_MAX_VF_MC_ENTRIES];
187 : : uint16_t num_vf_mc_hashes;
188 : : bool clear_to_send;
189 : : uint16_t tx_rate[TXGBE_MAX_QUEUE_NUM_PER_VF];
190 : : uint16_t vlan_count;
191 : : uint8_t api_version;
192 : : uint16_t switch_domain_id;
193 : : uint16_t xcast_mode;
194 : : uint16_t mac_count;
195 : : };
196 : :
197 : : TAILQ_HEAD(txgbe_5tuple_filter_list, txgbe_5tuple_filter);
198 : :
199 : : struct txgbe_5tuple_filter_info {
200 : : uint32_t dst_ip;
201 : : uint32_t src_ip;
202 : : uint16_t dst_port;
203 : : uint16_t src_port;
204 : : enum txgbe_5tuple_protocol proto; /* l4 protocol. */
205 : : uint8_t priority; /* seven levels (001b-111b), 111b is highest,
206 : : * used when more than one filter matches.
207 : : */
208 : : uint8_t dst_ip_mask:1, /* if mask is 1b, do not compare dst ip. */
209 : : src_ip_mask:1, /* if mask is 1b, do not compare src ip. */
210 : : dst_port_mask:1, /* if mask is 1b, do not compare dst port. */
211 : : src_port_mask:1, /* if mask is 1b, do not compare src port. */
212 : : proto_mask:1; /* if mask is 1b, do not compare protocol. */
213 : : };
214 : :
215 : : /* 5tuple filter structure */
216 : : struct txgbe_5tuple_filter {
217 : : TAILQ_ENTRY(txgbe_5tuple_filter) entries;
218 : : uint16_t index; /* the index of 5tuple filter */
219 : : struct txgbe_5tuple_filter_info filter_info;
220 : : uint16_t queue; /* rx queue assigned to */
221 : : };
222 : :
223 : : #define TXGBE_5TUPLE_ARRAY_SIZE \
224 : : (RTE_ALIGN(TXGBE_MAX_FTQF_FILTERS, (sizeof(uint32_t) * NBBY)) / \
225 : : (sizeof(uint32_t) * NBBY))
226 : :
227 : : struct txgbe_ethertype_filter {
228 : : uint16_t ethertype;
229 : : uint32_t etqf;
230 : : uint32_t etqs;
231 : : /**
232 : : * If this filter is added by configuration,
233 : : * it should not be removed.
234 : : */
235 : : bool conf;
236 : : };
237 : :
238 : : /*
239 : : * Structure to store filters' info.
240 : : */
241 : : struct txgbe_filter_info {
242 : : uint8_t ethertype_mask; /* Bit mask for every used ethertype filter */
243 : : /* store used ethertype filters*/
244 : : struct txgbe_ethertype_filter ethertype_filters[TXGBE_ETF_ID_MAX];
245 : : /* Bit mask for every used 5tuple filter */
246 : : uint32_t fivetuple_mask[TXGBE_5TUPLE_ARRAY_SIZE];
247 : : struct txgbe_5tuple_filter_list fivetuple_list;
248 : : bool ntuple_is_full;
249 : : /* store the SYN filter info */
250 : : uint32_t syn_info;
251 : : /* store the rss filter info */
252 : : struct txgbe_rte_flow_rss_conf rss_info;
253 : : };
254 : :
255 : : struct txgbe_l2_tn_key {
256 : : enum rte_eth_tunnel_type l2_tn_type;
257 : : uint32_t tn_id;
258 : : };
259 : :
260 : : struct txgbe_l2_tn_filter {
261 : : TAILQ_ENTRY(txgbe_l2_tn_filter) entries;
262 : : struct txgbe_l2_tn_key key;
263 : : uint32_t pool;
264 : : };
265 : :
266 : : TAILQ_HEAD(txgbe_l2_tn_filter_list, txgbe_l2_tn_filter);
267 : :
268 : : struct txgbe_l2_tn_info {
269 : : struct txgbe_l2_tn_filter_list l2_tn_list;
270 : : struct txgbe_l2_tn_filter **hash_map;
271 : : struct rte_hash *hash_handle;
272 : : bool e_tag_en; /* e-tag enabled */
273 : : bool e_tag_fwd_en; /* e-tag based forwarding enabled */
274 : : uint16_t e_tag_ether_type; /* ether type for e-tag */
275 : : };
276 : :
277 : : struct rte_flow {
278 : : enum rte_filter_type filter_type;
279 : : void *rule;
280 : : };
281 : :
282 : : /* The configuration of bandwidth */
283 : : struct txgbe_bw_conf {
284 : : uint8_t tc_num; /* Number of TCs. */
285 : : };
286 : :
287 : : /* Struct to store Traffic Manager shaper profile. */
288 : : struct txgbe_tm_shaper_profile {
289 : : TAILQ_ENTRY(txgbe_tm_shaper_profile) node;
290 : : uint32_t shaper_profile_id;
291 : : uint32_t reference_count;
292 : : struct rte_tm_shaper_params profile;
293 : : };
294 : :
295 : : TAILQ_HEAD(txgbe_shaper_profile_list, txgbe_tm_shaper_profile);
296 : :
297 : : /* node type of Traffic Manager */
298 : : enum txgbe_tm_node_type {
299 : : TXGBE_TM_NODE_TYPE_PORT,
300 : : TXGBE_TM_NODE_TYPE_TC,
301 : : TXGBE_TM_NODE_TYPE_QUEUE,
302 : : TXGBE_TM_NODE_TYPE_MAX,
303 : : };
304 : :
305 : : /* Struct to store Traffic Manager node configuration. */
306 : : struct txgbe_tm_node {
307 : : TAILQ_ENTRY(txgbe_tm_node) node;
308 : : uint32_t id;
309 : : uint32_t priority;
310 : : uint32_t weight;
311 : : uint32_t reference_count;
312 : : uint16_t no;
313 : : struct txgbe_tm_node *parent;
314 : : struct txgbe_tm_shaper_profile *shaper_profile;
315 : : struct rte_tm_node_params params;
316 : : };
317 : :
318 : : TAILQ_HEAD(txgbe_tm_node_list, txgbe_tm_node);
319 : :
320 : : /* The configuration of Traffic Manager */
321 : : struct txgbe_tm_conf {
322 : : struct txgbe_shaper_profile_list shaper_profile_list;
323 : : struct txgbe_tm_node *root; /* root node - port */
324 : : struct txgbe_tm_node_list tc_list; /* node list for all the TCs */
325 : : struct txgbe_tm_node_list queue_list; /* node list for all the queues */
326 : : /**
327 : : * The number of added TC nodes.
328 : : * It should be no more than the TC number of this port.
329 : : */
330 : : uint32_t nb_tc_node;
331 : : /**
332 : : * The number of added queue nodes.
333 : : * It should be no more than the queue number of this port.
334 : : */
335 : : uint32_t nb_queue_node;
336 : : /**
337 : : * This flag is used to check if APP can change the TM node
338 : : * configuration.
339 : : * When it's true, means the configuration is applied to HW,
340 : : * APP should not change the configuration.
341 : : * As we don't support on-the-fly configuration, when starting
342 : : * the port, APP should call the hierarchy_commit API to set this
343 : : * flag to true. When stopping the port, this flag should be set
344 : : * to false.
345 : : */
346 : : bool committed;
347 : : };
348 : :
349 : : /*
350 : : * Structure to store private data for each driver instance (for each port).
351 : : */
352 : : struct txgbe_adapter {
353 : : struct txgbe_hw hw;
354 : : struct txgbe_hw_stats stats;
355 : : struct rte_eth_fdir_conf fdir_conf;
356 : : struct txgbe_hw_fdir_info fdir;
357 : : struct txgbe_interrupt intr;
358 : : struct txgbe_stat_mappings stat_mappings;
359 : : struct txgbe_vfta shadow_vfta;
360 : : struct txgbe_hwstrip hwstrip;
361 : : struct txgbe_dcb_config dcb_config;
362 : : struct txgbe_vf_info *vfdata;
363 : : struct txgbe_uta_info uta_info;
364 : : struct txgbe_filter_info filter;
365 : : struct txgbe_l2_tn_info l2_tn;
366 : : struct txgbe_bw_conf bw_conf;
367 : : #ifdef RTE_LIB_SECURITY
368 : : struct txgbe_ipsec ipsec;
369 : : #endif
370 : : bool rx_bulk_alloc_allowed;
371 : : bool rx_vec_allowed;
372 : : struct rte_timecounter systime_tc;
373 : : struct rte_timecounter rx_tstamp_tc;
374 : : struct rte_timecounter tx_tstamp_tc;
375 : : struct txgbe_tm_conf tm_conf;
376 : :
377 : : /* For RSS reta table update */
378 : : uint8_t rss_reta_updated;
379 : :
380 : : RTE_ATOMIC(uint32_t) link_thread_running;
381 : : rte_thread_t link_thread_tid;
382 : : };
383 : :
384 : : #define TXGBE_DEV_ADAPTER(dev) \
385 : : ((struct txgbe_adapter *)(dev)->data->dev_private)
386 : :
387 : : #define TXGBE_DEV_FDIR_CONF(dev) (&TXGBE_DEV_ADAPTER(dev)->fdir_conf)
388 : :
389 : : #define TXGBE_DEV_HW(dev) \
390 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->hw)
391 : :
392 : : #define TXGBE_DEV_STATS(dev) \
393 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->stats)
394 : :
395 : : #define TXGBE_DEV_INTR(dev) \
396 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->intr)
397 : :
398 : : #define TXGBE_DEV_FDIR(dev) \
399 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->fdir)
400 : :
401 : : #define TXGBE_DEV_STAT_MAPPINGS(dev) \
402 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->stat_mappings)
403 : :
404 : : #define TXGBE_DEV_VFTA(dev) \
405 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->shadow_vfta)
406 : :
407 : : #define TXGBE_DEV_HWSTRIP(dev) \
408 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->hwstrip)
409 : :
410 : : #define TXGBE_DEV_DCB_CONFIG(dev) \
411 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->dcb_config)
412 : :
413 : : #define TXGBE_DEV_VFDATA(dev) \
414 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->vfdata)
415 : :
416 : : #define TXGBE_DEV_MR_INFO(dev) \
417 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->mr_data)
418 : :
419 : : #define TXGBE_DEV_UTA_INFO(dev) \
420 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->uta_info)
421 : :
422 : : #define TXGBE_DEV_FILTER(dev) \
423 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->filter)
424 : :
425 : : #define TXGBE_DEV_L2_TN(dev) \
426 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->l2_tn)
427 : :
428 : : #define TXGBE_DEV_BW_CONF(dev) \
429 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->bw_conf)
430 : :
431 : : #define TXGBE_DEV_TM_CONF(dev) \
432 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->tm_conf)
433 : :
434 : : #define TXGBE_DEV_IPSEC(dev) \
435 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->ipsec)
436 : :
437 : : /*
438 : : * RX/TX function prototypes
439 : : */
440 : : void txgbe_dev_clear_queues(struct rte_eth_dev *dev);
441 : :
442 : : void txgbe_dev_free_queues(struct rte_eth_dev *dev);
443 : :
444 : : void txgbe_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
445 : :
446 : : void txgbe_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
447 : :
448 : : int txgbe_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
449 : : uint16_t nb_rx_desc, unsigned int socket_id,
450 : : const struct rte_eth_rxconf *rx_conf,
451 : : struct rte_mempool *mb_pool);
452 : :
453 : : int txgbe_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
454 : : uint16_t nb_tx_desc, unsigned int socket_id,
455 : : const struct rte_eth_txconf *tx_conf);
456 : :
457 : : int txgbe_dev_rx_queue_count(void *rx_queue);
458 : :
459 : : int txgbe_dev_rx_descriptor_status(void *rx_queue, uint16_t offset);
460 : : int txgbe_dev_tx_descriptor_status(void *tx_queue, uint16_t offset);
461 : :
462 : : int txgbe_dev_rx_init(struct rte_eth_dev *dev);
463 : :
464 : : void txgbe_dev_tx_init(struct rte_eth_dev *dev);
465 : :
466 : : int txgbe_dev_rxtx_start(struct rte_eth_dev *dev);
467 : :
468 : : void txgbe_dev_save_rx_queue(struct txgbe_hw *hw, uint16_t rx_queue_id);
469 : : void txgbe_dev_store_rx_queue(struct txgbe_hw *hw, uint16_t rx_queue_id);
470 : : void txgbe_dev_save_tx_queue(struct txgbe_hw *hw, uint16_t tx_queue_id);
471 : : void txgbe_dev_store_tx_queue(struct txgbe_hw *hw, uint16_t tx_queue_id);
472 : :
473 : : int txgbe_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
474 : :
475 : : int txgbe_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
476 : :
477 : : int txgbe_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
478 : :
479 : : int txgbe_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
480 : :
481 : : void txgbe_tx_queue_clear_error(void *param);
482 : :
483 : : void txgbe_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
484 : : struct rte_eth_rxq_info *qinfo);
485 : :
486 : : void txgbe_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
487 : : struct rte_eth_txq_info *qinfo);
488 : :
489 : : int txgbevf_dev_rx_init(struct rte_eth_dev *dev);
490 : :
491 : : void txgbevf_dev_tx_init(struct rte_eth_dev *dev);
492 : :
493 : : void txgbevf_dev_rxtx_start(struct rte_eth_dev *dev);
494 : :
495 : : uint16_t txgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
496 : : uint16_t nb_pkts);
497 : :
498 : : uint16_t txgbe_recv_pkts_bulk_alloc(void *rx_queue, struct rte_mbuf **rx_pkts,
499 : : uint16_t nb_pkts);
500 : :
501 : : uint16_t txgbe_recv_pkts_lro_single_alloc(void *rx_queue,
502 : : struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
503 : : uint16_t txgbe_recv_pkts_lro_bulk_alloc(void *rx_queue,
504 : : struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
505 : :
506 : : uint16_t txgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
507 : : uint16_t nb_pkts);
508 : :
509 : : uint16_t txgbe_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,
510 : : uint16_t nb_pkts);
511 : :
512 : : uint16_t txgbe_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
513 : : uint16_t nb_pkts);
514 : :
515 : : int txgbe_dev_rss_hash_update(struct rte_eth_dev *dev,
516 : : struct rte_eth_rss_conf *rss_conf);
517 : :
518 : : int txgbe_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
519 : : struct rte_eth_rss_conf *rss_conf);
520 : :
521 : : bool txgbe_rss_update(enum txgbe_mac_type mac_type);
522 : :
523 : : int txgbe_add_del_ntuple_filter(struct rte_eth_dev *dev,
524 : : struct rte_eth_ntuple_filter *filter,
525 : : bool add);
526 : : int txgbe_add_del_ethertype_filter(struct rte_eth_dev *dev,
527 : : struct rte_eth_ethertype_filter *filter,
528 : : bool add);
529 : : int txgbe_syn_filter_set(struct rte_eth_dev *dev,
530 : : struct rte_eth_syn_filter *filter,
531 : : bool add);
532 : : int txgbe_ntuple_filter_uninit(struct rte_eth_dev *eth_dev);
533 : :
534 : : int txgbevf_inject_5tuple_filter(struct rte_eth_dev *dev,
535 : : struct txgbe_5tuple_filter *filter);
536 : : void txgbevf_remove_5tuple_filter(struct rte_eth_dev *dev, u16 index);
537 : :
538 : : /**
539 : : * l2 tunnel configuration.
540 : : */
541 : : struct txgbe_l2_tunnel_conf {
542 : : enum rte_eth_tunnel_type l2_tunnel_type;
543 : : uint16_t ether_type; /* ether type in l2 header */
544 : : uint32_t tunnel_id; /* port tag id for e-tag */
545 : : uint16_t vf_id; /* VF id for tag insertion */
546 : : uint32_t pool; /* destination pool for tag based forwarding */
547 : : };
548 : :
549 : : int
550 : : txgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev,
551 : : struct txgbe_l2_tunnel_conf *l2_tunnel,
552 : : bool restore);
553 : : int
554 : : txgbe_dev_l2_tunnel_filter_del(struct rte_eth_dev *dev,
555 : : struct txgbe_l2_tunnel_conf *l2_tunnel);
556 : : void txgbe_filterlist_init(void);
557 : : void txgbe_filterlist_flush(void);
558 : : int txgbe_fdir_filter_init(struct rte_eth_dev *eth_dev);
559 : : int txgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev);
560 : :
561 : : void txgbe_set_ivar_map(struct txgbe_hw *hw, int8_t direction,
562 : : uint8_t queue, uint8_t msix_vector);
563 : :
564 : : /*
565 : : * Flow director function prototypes
566 : : */
567 : : int txgbe_fdir_configure(struct rte_eth_dev *dev);
568 : : int txgbe_fdir_set_input_mask(struct rte_eth_dev *dev);
569 : : uint16_t txgbe_fdir_get_flex_base(struct txgbe_fdir_rule *rule);
570 : : int txgbe_fdir_set_flexbytes_offset(struct rte_eth_dev *dev,
571 : : uint16_t offset, uint16_t flex_base);
572 : : int txgbe_fdir_filter_program(struct rte_eth_dev *dev,
573 : : struct txgbe_fdir_rule *rule,
574 : : bool del, bool update);
575 : : int txgbevf_fdir_filter_program(struct rte_eth_dev *dev,
576 : : struct txgbe_fdir_rule *rule,
577 : : bool del);
578 : : void txgbe_configure_pb(struct rte_eth_dev *dev);
579 : : void txgbe_configure_port(struct rte_eth_dev *dev);
580 : : void txgbe_configure_dcb(struct rte_eth_dev *dev);
581 : :
582 : : int
583 : : txgbe_dev_link_update_share(struct rte_eth_dev *dev,
584 : : int wait_to_complete);
585 : : int
586 : : txgbe_dev_wait_setup_link_complete(struct rte_eth_dev *dev,
587 : : uint32_t timeout_ms);
588 : : int txgbe_pf_host_init(struct rte_eth_dev *eth_dev);
589 : :
590 : : void txgbe_pf_host_uninit(struct rte_eth_dev *eth_dev);
591 : :
592 : : void txgbe_pf_mbx_process(struct rte_eth_dev *eth_dev);
593 : :
594 : : int txgbe_pf_host_configure(struct rte_eth_dev *eth_dev);
595 : :
596 : : uint32_t txgbe_convert_vm_rx_mask_to_val(uint16_t rx_mask, uint32_t orig_val);
597 : :
598 : : void txgbe_fdir_filter_restore(struct rte_eth_dev *dev);
599 : : int txgbe_clear_all_fdir_filter(struct rte_eth_dev *dev);
600 : :
601 : : extern const struct rte_flow_ops txgbe_flow_ops;
602 : :
603 : : void txgbe_clear_all_ethertype_filter(struct rte_eth_dev *dev);
604 : : void txgbe_clear_all_ntuple_filter(struct rte_eth_dev *dev);
605 : : void txgbe_clear_syn_filter(struct rte_eth_dev *dev);
606 : : int txgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev);
607 : :
608 : : int txgbe_set_vf_rate_limit(struct rte_eth_dev *dev, uint16_t vf,
609 : : uint16_t tx_rate, uint64_t q_msk);
610 : : int txgbe_tm_ops_get(struct rte_eth_dev *dev, void *ops);
611 : : void txgbe_tm_conf_init(struct rte_eth_dev *dev);
612 : : void txgbe_tm_conf_uninit(struct rte_eth_dev *dev);
613 : : int txgbe_set_queue_rate_limit(struct rte_eth_dev *dev, uint16_t queue_idx,
614 : : uint32_t tx_rate);
615 : : int txgbe_rss_conf_init(struct txgbe_rte_flow_rss_conf *out,
616 : : const struct rte_flow_action_rss *in);
617 : : int txgbe_action_rss_same(const struct rte_flow_action_rss *comp,
618 : : const struct rte_flow_action_rss *with);
619 : : int txgbe_config_rss_filter(struct rte_eth_dev *dev,
620 : : struct txgbe_rte_flow_rss_conf *conf, bool add);
621 : :
622 : : static inline int
623 : : txgbe_ethertype_filter_lookup(struct txgbe_filter_info *filter_info,
624 : : uint16_t ethertype)
625 : : {
626 : : int i;
627 : :
628 [ # # ]: 0 : for (i = 0; i < TXGBE_ETF_ID_MAX; i++) {
629 [ # # ]: 0 : if (filter_info->ethertype_filters[i].ethertype == ethertype &&
630 [ # # ]: 0 : (filter_info->ethertype_mask & (1 << i)))
631 : : return i;
632 : : }
633 : : return -1;
634 : : }
635 : :
636 : : static inline int
637 : 0 : txgbe_ethertype_filter_insert(struct txgbe_filter_info *filter_info,
638 : : struct txgbe_ethertype_filter *ethertype_filter)
639 : : {
640 : : int i;
641 : :
642 [ # # ]: 0 : for (i = 0; i < TXGBE_ETF_ID_MAX; i++) {
643 [ # # ]: 0 : if (filter_info->ethertype_mask & (1 << i))
644 : : continue;
645 : :
646 : 0 : filter_info->ethertype_mask |= 1 << i;
647 : 0 : filter_info->ethertype_filters[i].ethertype =
648 : 0 : ethertype_filter->ethertype;
649 : 0 : filter_info->ethertype_filters[i].etqf =
650 : 0 : ethertype_filter->etqf;
651 : 0 : filter_info->ethertype_filters[i].etqs =
652 : 0 : ethertype_filter->etqs;
653 : 0 : filter_info->ethertype_filters[i].conf =
654 : 0 : ethertype_filter->conf;
655 : 0 : break;
656 : : }
657 [ # # ]: 0 : return (i < TXGBE_ETF_ID_MAX ? i : -1);
658 : : }
659 : :
660 : : static inline int
661 : : txgbe_ethertype_filter_remove(struct txgbe_filter_info *filter_info,
662 : : uint8_t idx)
663 : : {
664 [ # # ]: 0 : if (idx >= TXGBE_ETF_ID_MAX)
665 : : return -1;
666 : 0 : filter_info->ethertype_mask &= ~(1 << idx);
667 : 0 : filter_info->ethertype_filters[idx].ethertype = 0;
668 : 0 : filter_info->ethertype_filters[idx].etqf = 0;
669 : 0 : filter_info->ethertype_filters[idx].etqs = 0;
670 : : filter_info->ethertype_filters[idx].etqs = FALSE;
671 : : return idx;
672 : : }
673 : :
674 : : #ifdef RTE_LIB_SECURITY
675 : : int txgbe_ipsec_ctx_create(struct rte_eth_dev *dev);
676 : : #endif
677 : :
678 : : /* High threshold controlling when to start sending XOFF frames. */
679 : : #define TXGBE_FC_XOFF_HITH 128 /*KB*/
680 : : /* Low threshold controlling when to start sending XON frames. */
681 : : #define TXGBE_FC_XON_LOTH 64 /*KB*/
682 : :
683 : : /* Timer value included in XOFF frames. */
684 : : #define TXGBE_FC_PAUSE_TIME 0x680
685 : :
686 : : #define TXGBE_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
687 : : #define TXGBE_LINK_UP_CHECK_TIMEOUT 1000 /* ms */
688 : : #define TXGBE_VMDQ_NUM_UC_MAC 4096 /* Maximum nb. of UC MAC addr. */
689 : :
690 : : /*
691 : : * Default values for RX/TX configuration
692 : : */
693 : : #define TXGBE_DEFAULT_RX_FREE_THRESH 32
694 : : #define TXGBE_DEFAULT_RX_PTHRESH 8
695 : : #define TXGBE_DEFAULT_RX_HTHRESH 8
696 : : #define TXGBE_DEFAULT_RX_WTHRESH 0
697 : :
698 : : #define TXGBE_DEFAULT_TX_FREE_THRESH 32
699 : : #define TXGBE_DEFAULT_TX_PTHRESH 32
700 : : #define TXGBE_DEFAULT_TX_HTHRESH 0
701 : : #define TXGBE_DEFAULT_TX_WTHRESH 0
702 : :
703 : : /* Additional timesync values. */
704 : : #define NSEC_PER_SEC 1000000000L
705 : : #define TXGBE_INCVAL_10GB 0xCCCCCC
706 : : #define TXGBE_INCVAL_1GB 0x800000
707 : : #define TXGBE_INCVAL_100 0xA00000
708 : : #define TXGBE_INCVAL_10 0xC7F380
709 : : #define TXGBE_INCVAL_FPGA 0x800000
710 : : #define TXGBE_INCVAL_SHIFT_10GB 20
711 : : #define TXGBE_INCVAL_SHIFT_1GB 18
712 : : #define TXGBE_INCVAL_SHIFT_100 15
713 : : #define TXGBE_INCVAL_SHIFT_10 12
714 : : #define TXGBE_INCVAL_SHIFT_FPGA 17
715 : :
716 : : #define TXGBE_CYCLECOUNTER_MASK 0xffffffffffffffffULL
717 : :
718 : : /* store statistics names and its offset in stats structure */
719 : : struct rte_txgbe_xstats_name_off {
720 : : char name[RTE_ETH_XSTATS_NAME_SIZE];
721 : : unsigned int offset;
722 : : };
723 : :
724 : : const uint32_t *txgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev,
725 : : size_t *no_of_elements);
726 : : int txgbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
727 : : struct rte_ether_addr *mc_addr_set,
728 : : uint32_t nb_mc_addr);
729 : : int txgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
730 : : struct rte_eth_rss_reta_entry64 *reta_conf,
731 : : uint16_t reta_size);
732 : : int txgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
733 : : struct rte_eth_rss_reta_entry64 *reta_conf,
734 : : uint16_t reta_size);
735 : : void txgbe_dev_setup_link_alarm_handler(void *param);
736 : : void txgbe_read_stats_registers(struct txgbe_hw *hw,
737 : : struct txgbe_hw_stats *hw_stats);
738 : :
739 : : void txgbe_vlan_hw_filter_enable(struct rte_eth_dev *dev);
740 : : void txgbe_vlan_hw_filter_disable(struct rte_eth_dev *dev);
741 : : void txgbe_vlan_hw_strip_config(struct rte_eth_dev *dev);
742 : : void txgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev,
743 : : uint16_t queue, bool on);
744 : : void txgbe_config_vlan_strip_on_all_queues(struct rte_eth_dev *dev,
745 : : int mask);
746 : :
747 : : #endif /* _TXGBE_ETHDEV_H_ */
|