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 : : /* store the SYN filter info */
249 : : uint32_t syn_info;
250 : : /* store the rss filter info */
251 : : struct txgbe_rte_flow_rss_conf rss_info;
252 : : };
253 : :
254 : : struct txgbe_l2_tn_key {
255 : : enum rte_eth_tunnel_type l2_tn_type;
256 : : uint32_t tn_id;
257 : : };
258 : :
259 : : struct txgbe_l2_tn_filter {
260 : : TAILQ_ENTRY(txgbe_l2_tn_filter) entries;
261 : : struct txgbe_l2_tn_key key;
262 : : uint32_t pool;
263 : : };
264 : :
265 : : TAILQ_HEAD(txgbe_l2_tn_filter_list, txgbe_l2_tn_filter);
266 : :
267 : : struct txgbe_l2_tn_info {
268 : : struct txgbe_l2_tn_filter_list l2_tn_list;
269 : : struct txgbe_l2_tn_filter **hash_map;
270 : : struct rte_hash *hash_handle;
271 : : bool e_tag_en; /* e-tag enabled */
272 : : bool e_tag_fwd_en; /* e-tag based forwarding enabled */
273 : : uint16_t e_tag_ether_type; /* ether type for e-tag */
274 : : };
275 : :
276 : : struct rte_flow {
277 : : enum rte_filter_type filter_type;
278 : : void *rule;
279 : : };
280 : :
281 : : /* The configuration of bandwidth */
282 : : struct txgbe_bw_conf {
283 : : uint8_t tc_num; /* Number of TCs. */
284 : : };
285 : :
286 : : /* Struct to store Traffic Manager shaper profile. */
287 : : struct txgbe_tm_shaper_profile {
288 : : TAILQ_ENTRY(txgbe_tm_shaper_profile) node;
289 : : uint32_t shaper_profile_id;
290 : : uint32_t reference_count;
291 : : struct rte_tm_shaper_params profile;
292 : : };
293 : :
294 : : TAILQ_HEAD(txgbe_shaper_profile_list, txgbe_tm_shaper_profile);
295 : :
296 : : /* node type of Traffic Manager */
297 : : enum txgbe_tm_node_type {
298 : : TXGBE_TM_NODE_TYPE_PORT,
299 : : TXGBE_TM_NODE_TYPE_TC,
300 : : TXGBE_TM_NODE_TYPE_QUEUE,
301 : : TXGBE_TM_NODE_TYPE_MAX,
302 : : };
303 : :
304 : : /* Struct to store Traffic Manager node configuration. */
305 : : struct txgbe_tm_node {
306 : : TAILQ_ENTRY(txgbe_tm_node) node;
307 : : uint32_t id;
308 : : uint32_t priority;
309 : : uint32_t weight;
310 : : uint32_t reference_count;
311 : : uint16_t no;
312 : : struct txgbe_tm_node *parent;
313 : : struct txgbe_tm_shaper_profile *shaper_profile;
314 : : struct rte_tm_node_params params;
315 : : };
316 : :
317 : : TAILQ_HEAD(txgbe_tm_node_list, txgbe_tm_node);
318 : :
319 : : /* The configuration of Traffic Manager */
320 : : struct txgbe_tm_conf {
321 : : struct txgbe_shaper_profile_list shaper_profile_list;
322 : : struct txgbe_tm_node *root; /* root node - port */
323 : : struct txgbe_tm_node_list tc_list; /* node list for all the TCs */
324 : : struct txgbe_tm_node_list queue_list; /* node list for all the queues */
325 : : /**
326 : : * The number of added TC nodes.
327 : : * It should be no more than the TC number of this port.
328 : : */
329 : : uint32_t nb_tc_node;
330 : : /**
331 : : * The number of added queue nodes.
332 : : * It should be no more than the queue number of this port.
333 : : */
334 : : uint32_t nb_queue_node;
335 : : /**
336 : : * This flag is used to check if APP can change the TM node
337 : : * configuration.
338 : : * When it's true, means the configuration is applied to HW,
339 : : * APP should not change the configuration.
340 : : * As we don't support on-the-fly configuration, when starting
341 : : * the port, APP should call the hierarchy_commit API to set this
342 : : * flag to true. When stopping the port, this flag should be set
343 : : * to false.
344 : : */
345 : : bool committed;
346 : : };
347 : :
348 : : /*
349 : : * Structure to store private data for each driver instance (for each port).
350 : : */
351 : : struct txgbe_adapter {
352 : : struct txgbe_hw hw;
353 : : struct txgbe_hw_stats stats;
354 : : struct rte_eth_fdir_conf fdir_conf;
355 : : struct txgbe_hw_fdir_info fdir;
356 : : struct txgbe_interrupt intr;
357 : : struct txgbe_stat_mappings stat_mappings;
358 : : struct txgbe_vfta shadow_vfta;
359 : : struct txgbe_hwstrip hwstrip;
360 : : struct txgbe_dcb_config dcb_config;
361 : : struct txgbe_vf_info *vfdata;
362 : : struct txgbe_uta_info uta_info;
363 : : struct txgbe_filter_info filter;
364 : : struct txgbe_l2_tn_info l2_tn;
365 : : struct txgbe_bw_conf bw_conf;
366 : : #ifdef RTE_LIB_SECURITY
367 : : struct txgbe_ipsec ipsec;
368 : : #endif
369 : : bool rx_bulk_alloc_allowed;
370 : : bool rx_vec_allowed;
371 : : struct rte_timecounter systime_tc;
372 : : struct rte_timecounter rx_tstamp_tc;
373 : : struct rte_timecounter tx_tstamp_tc;
374 : : struct txgbe_tm_conf tm_conf;
375 : :
376 : : /* For RSS reta table update */
377 : : uint8_t rss_reta_updated;
378 : :
379 : : RTE_ATOMIC(uint32_t) link_thread_running;
380 : : rte_thread_t link_thread_tid;
381 : : };
382 : :
383 : : #define TXGBE_DEV_ADAPTER(dev) \
384 : : ((struct txgbe_adapter *)(dev)->data->dev_private)
385 : :
386 : : #define TXGBE_DEV_FDIR_CONF(dev) (&TXGBE_DEV_ADAPTER(dev)->fdir_conf)
387 : :
388 : : #define TXGBE_DEV_HW(dev) \
389 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->hw)
390 : :
391 : : #define TXGBE_DEV_STATS(dev) \
392 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->stats)
393 : :
394 : : #define TXGBE_DEV_INTR(dev) \
395 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->intr)
396 : :
397 : : #define TXGBE_DEV_FDIR(dev) \
398 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->fdir)
399 : :
400 : : #define TXGBE_DEV_STAT_MAPPINGS(dev) \
401 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->stat_mappings)
402 : :
403 : : #define TXGBE_DEV_VFTA(dev) \
404 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->shadow_vfta)
405 : :
406 : : #define TXGBE_DEV_HWSTRIP(dev) \
407 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->hwstrip)
408 : :
409 : : #define TXGBE_DEV_DCB_CONFIG(dev) \
410 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->dcb_config)
411 : :
412 : : #define TXGBE_DEV_VFDATA(dev) \
413 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->vfdata)
414 : :
415 : : #define TXGBE_DEV_MR_INFO(dev) \
416 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->mr_data)
417 : :
418 : : #define TXGBE_DEV_UTA_INFO(dev) \
419 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->uta_info)
420 : :
421 : : #define TXGBE_DEV_FILTER(dev) \
422 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->filter)
423 : :
424 : : #define TXGBE_DEV_L2_TN(dev) \
425 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->l2_tn)
426 : :
427 : : #define TXGBE_DEV_BW_CONF(dev) \
428 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->bw_conf)
429 : :
430 : : #define TXGBE_DEV_TM_CONF(dev) \
431 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->tm_conf)
432 : :
433 : : #define TXGBE_DEV_IPSEC(dev) \
434 : : (&((struct txgbe_adapter *)(dev)->data->dev_private)->ipsec)
435 : :
436 : : /*
437 : : * RX/TX function prototypes
438 : : */
439 : : void txgbe_dev_clear_queues(struct rte_eth_dev *dev);
440 : :
441 : : void txgbe_dev_free_queues(struct rte_eth_dev *dev);
442 : :
443 : : void txgbe_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
444 : :
445 : : void txgbe_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
446 : :
447 : : int txgbe_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
448 : : uint16_t nb_rx_desc, unsigned int socket_id,
449 : : const struct rte_eth_rxconf *rx_conf,
450 : : struct rte_mempool *mb_pool);
451 : :
452 : : int txgbe_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
453 : : uint16_t nb_tx_desc, unsigned int socket_id,
454 : : const struct rte_eth_txconf *tx_conf);
455 : :
456 : : uint32_t txgbe_dev_rx_queue_count(void *rx_queue);
457 : :
458 : : int txgbe_dev_rx_descriptor_status(void *rx_queue, uint16_t offset);
459 : : int txgbe_dev_tx_descriptor_status(void *tx_queue, uint16_t offset);
460 : :
461 : : int txgbe_dev_rx_init(struct rte_eth_dev *dev);
462 : :
463 : : void txgbe_dev_tx_init(struct rte_eth_dev *dev);
464 : :
465 : : int txgbe_dev_rxtx_start(struct rte_eth_dev *dev);
466 : :
467 : : void txgbe_dev_save_rx_queue(struct txgbe_hw *hw, uint16_t rx_queue_id);
468 : : void txgbe_dev_store_rx_queue(struct txgbe_hw *hw, uint16_t rx_queue_id);
469 : : void txgbe_dev_save_tx_queue(struct txgbe_hw *hw, uint16_t tx_queue_id);
470 : : void txgbe_dev_store_tx_queue(struct txgbe_hw *hw, uint16_t tx_queue_id);
471 : :
472 : : int txgbe_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
473 : :
474 : : int txgbe_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
475 : :
476 : : int txgbe_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
477 : :
478 : : int txgbe_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
479 : :
480 : : void txgbe_tx_queue_clear_error(void *param);
481 : :
482 : : void txgbe_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
483 : : struct rte_eth_rxq_info *qinfo);
484 : :
485 : : void txgbe_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
486 : : struct rte_eth_txq_info *qinfo);
487 : :
488 : : int txgbevf_dev_rx_init(struct rte_eth_dev *dev);
489 : :
490 : : void txgbevf_dev_tx_init(struct rte_eth_dev *dev);
491 : :
492 : : void txgbevf_dev_rxtx_start(struct rte_eth_dev *dev);
493 : :
494 : : uint16_t txgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
495 : : uint16_t nb_pkts);
496 : :
497 : : uint16_t txgbe_recv_pkts_bulk_alloc(void *rx_queue, struct rte_mbuf **rx_pkts,
498 : : uint16_t nb_pkts);
499 : :
500 : : uint16_t txgbe_recv_pkts_lro_single_alloc(void *rx_queue,
501 : : struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
502 : : uint16_t txgbe_recv_pkts_lro_bulk_alloc(void *rx_queue,
503 : : struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
504 : :
505 : : uint16_t txgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
506 : : uint16_t nb_pkts);
507 : :
508 : : uint16_t txgbe_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,
509 : : uint16_t nb_pkts);
510 : :
511 : : uint16_t txgbe_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
512 : : uint16_t nb_pkts);
513 : :
514 : : int txgbe_dev_rss_hash_update(struct rte_eth_dev *dev,
515 : : struct rte_eth_rss_conf *rss_conf);
516 : :
517 : : int txgbe_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
518 : : struct rte_eth_rss_conf *rss_conf);
519 : :
520 : : bool txgbe_rss_update_sp(enum txgbe_mac_type mac_type);
521 : :
522 : : int txgbe_add_del_ntuple_filter(struct rte_eth_dev *dev,
523 : : struct rte_eth_ntuple_filter *filter,
524 : : bool add);
525 : : int txgbe_add_del_ethertype_filter(struct rte_eth_dev *dev,
526 : : struct rte_eth_ethertype_filter *filter,
527 : : bool add);
528 : : int txgbe_syn_filter_set(struct rte_eth_dev *dev,
529 : : struct rte_eth_syn_filter *filter,
530 : : bool add);
531 : : int txgbe_ntuple_filter_uninit(struct rte_eth_dev *eth_dev);
532 : :
533 : : int txgbevf_inject_5tuple_filter(struct rte_eth_dev *dev,
534 : : struct txgbe_5tuple_filter *filter);
535 : : void txgbevf_remove_5tuple_filter(struct rte_eth_dev *dev, u16 index);
536 : :
537 : : /**
538 : : * l2 tunnel configuration.
539 : : */
540 : : struct txgbe_l2_tunnel_conf {
541 : : enum rte_eth_tunnel_type l2_tunnel_type;
542 : : uint16_t ether_type; /* ether type in l2 header */
543 : : uint32_t tunnel_id; /* port tag id for e-tag */
544 : : uint16_t vf_id; /* VF id for tag insertion */
545 : : uint32_t pool; /* destination pool for tag based forwarding */
546 : : };
547 : :
548 : : int
549 : : txgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev,
550 : : struct txgbe_l2_tunnel_conf *l2_tunnel,
551 : : bool restore);
552 : : int
553 : : txgbe_dev_l2_tunnel_filter_del(struct rte_eth_dev *dev,
554 : : struct txgbe_l2_tunnel_conf *l2_tunnel);
555 : : void txgbe_filterlist_init(void);
556 : : void txgbe_filterlist_flush(void);
557 : :
558 : : void txgbe_set_ivar_map(struct txgbe_hw *hw, int8_t direction,
559 : : uint8_t queue, uint8_t msix_vector);
560 : :
561 : : /*
562 : : * Flow director function prototypes
563 : : */
564 : : int txgbe_fdir_configure(struct rte_eth_dev *dev);
565 : : int txgbe_fdir_set_input_mask(struct rte_eth_dev *dev);
566 : : uint16_t txgbe_fdir_get_flex_base(struct txgbe_fdir_rule *rule);
567 : : int txgbe_fdir_set_flexbytes_offset(struct rte_eth_dev *dev,
568 : : uint16_t offset, uint16_t flex_base);
569 : : int txgbe_fdir_filter_program(struct rte_eth_dev *dev,
570 : : struct txgbe_fdir_rule *rule,
571 : : bool del, bool update);
572 : :
573 : : void txgbe_configure_pb(struct rte_eth_dev *dev);
574 : : void txgbe_configure_port(struct rte_eth_dev *dev);
575 : : void txgbe_configure_dcb(struct rte_eth_dev *dev);
576 : :
577 : : int
578 : : txgbe_dev_link_update_share(struct rte_eth_dev *dev,
579 : : int wait_to_complete);
580 : : int
581 : : txgbe_dev_wait_setup_link_complete(struct rte_eth_dev *dev,
582 : : uint32_t timeout_ms);
583 : : int txgbe_pf_host_init(struct rte_eth_dev *eth_dev);
584 : :
585 : : void txgbe_pf_host_uninit(struct rte_eth_dev *eth_dev);
586 : :
587 : : void txgbe_pf_mbx_process(struct rte_eth_dev *eth_dev);
588 : :
589 : : int txgbe_pf_host_configure(struct rte_eth_dev *eth_dev);
590 : :
591 : : uint32_t txgbe_convert_vm_rx_mask_to_val(uint16_t rx_mask, uint32_t orig_val);
592 : :
593 : : void txgbe_fdir_filter_restore(struct rte_eth_dev *dev);
594 : : int txgbe_clear_all_fdir_filter(struct rte_eth_dev *dev);
595 : :
596 : : extern const struct rte_flow_ops txgbe_flow_ops;
597 : :
598 : : void txgbe_clear_all_ethertype_filter(struct rte_eth_dev *dev);
599 : : void txgbe_clear_all_ntuple_filter(struct rte_eth_dev *dev);
600 : : void txgbe_clear_syn_filter(struct rte_eth_dev *dev);
601 : : int txgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev);
602 : :
603 : : int txgbe_set_vf_rate_limit(struct rte_eth_dev *dev, uint16_t vf,
604 : : uint16_t tx_rate, uint64_t q_msk);
605 : : int txgbe_tm_ops_get(struct rte_eth_dev *dev, void *ops);
606 : : void txgbe_tm_conf_init(struct rte_eth_dev *dev);
607 : : void txgbe_tm_conf_uninit(struct rte_eth_dev *dev);
608 : : int txgbe_set_queue_rate_limit(struct rte_eth_dev *dev, uint16_t queue_idx,
609 : : uint32_t tx_rate);
610 : : int txgbe_rss_conf_init(struct txgbe_rte_flow_rss_conf *out,
611 : : const struct rte_flow_action_rss *in);
612 : : int txgbe_action_rss_same(const struct rte_flow_action_rss *comp,
613 : : const struct rte_flow_action_rss *with);
614 : : int txgbe_config_rss_filter(struct rte_eth_dev *dev,
615 : : struct txgbe_rte_flow_rss_conf *conf, bool add);
616 : :
617 : : static inline int
618 : : txgbe_ethertype_filter_lookup(struct txgbe_filter_info *filter_info,
619 : : uint16_t ethertype)
620 : : {
621 : : int i;
622 : :
623 [ # # ]: 0 : for (i = 0; i < TXGBE_ETF_ID_MAX; i++) {
624 [ # # ]: 0 : if (filter_info->ethertype_filters[i].ethertype == ethertype &&
625 [ # # ]: 0 : (filter_info->ethertype_mask & (1 << i)))
626 : : return i;
627 : : }
628 : : return -1;
629 : : }
630 : :
631 : : static inline int
632 : 0 : txgbe_ethertype_filter_insert(struct txgbe_filter_info *filter_info,
633 : : struct txgbe_ethertype_filter *ethertype_filter)
634 : : {
635 : : int i;
636 : :
637 [ # # ]: 0 : for (i = 0; i < TXGBE_ETF_ID_MAX; i++) {
638 [ # # ]: 0 : if (filter_info->ethertype_mask & (1 << i))
639 : : continue;
640 : :
641 : 0 : filter_info->ethertype_mask |= 1 << i;
642 : 0 : filter_info->ethertype_filters[i].ethertype =
643 : 0 : ethertype_filter->ethertype;
644 : 0 : filter_info->ethertype_filters[i].etqf =
645 : 0 : ethertype_filter->etqf;
646 : 0 : filter_info->ethertype_filters[i].etqs =
647 : 0 : ethertype_filter->etqs;
648 : 0 : filter_info->ethertype_filters[i].conf =
649 : 0 : ethertype_filter->conf;
650 : 0 : break;
651 : : }
652 [ # # ]: 0 : return (i < TXGBE_ETF_ID_MAX ? i : -1);
653 : : }
654 : :
655 : : static inline int
656 : : txgbe_ethertype_filter_remove(struct txgbe_filter_info *filter_info,
657 : : uint8_t idx)
658 : : {
659 [ # # ]: 0 : if (idx >= TXGBE_ETF_ID_MAX)
660 : : return -1;
661 : 0 : filter_info->ethertype_mask &= ~(1 << idx);
662 : 0 : filter_info->ethertype_filters[idx].ethertype = 0;
663 : 0 : filter_info->ethertype_filters[idx].etqf = 0;
664 : 0 : filter_info->ethertype_filters[idx].etqs = 0;
665 : : filter_info->ethertype_filters[idx].etqs = FALSE;
666 : : return idx;
667 : : }
668 : :
669 : : #ifdef RTE_LIB_SECURITY
670 : : int txgbe_ipsec_ctx_create(struct rte_eth_dev *dev);
671 : : #endif
672 : :
673 : : /* High threshold controlling when to start sending XOFF frames. */
674 : : #define TXGBE_FC_XOFF_HITH 128 /*KB*/
675 : : /* Low threshold controlling when to start sending XON frames. */
676 : : #define TXGBE_FC_XON_LOTH 64 /*KB*/
677 : :
678 : : /* Timer value included in XOFF frames. */
679 : : #define TXGBE_FC_PAUSE_TIME 0x680
680 : :
681 : : #define TXGBE_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
682 : : #define TXGBE_LINK_UP_CHECK_TIMEOUT 1000 /* ms */
683 : : #define TXGBE_VMDQ_NUM_UC_MAC 4096 /* Maximum nb. of UC MAC addr. */
684 : :
685 : : /*
686 : : * Default values for RX/TX configuration
687 : : */
688 : : #define TXGBE_DEFAULT_RX_FREE_THRESH 32
689 : : #define TXGBE_DEFAULT_RX_PTHRESH 8
690 : : #define TXGBE_DEFAULT_RX_HTHRESH 8
691 : : #define TXGBE_DEFAULT_RX_WTHRESH 0
692 : :
693 : : #define TXGBE_DEFAULT_TX_FREE_THRESH 32
694 : : #define TXGBE_DEFAULT_TX_PTHRESH 32
695 : : #define TXGBE_DEFAULT_TX_HTHRESH 0
696 : : #define TXGBE_DEFAULT_TX_WTHRESH 0
697 : :
698 : : /* Additional timesync values. */
699 : : #define NSEC_PER_SEC 1000000000L
700 : : #define TXGBE_INCVAL_10GB 0xCCCCCC
701 : : #define TXGBE_INCVAL_1GB 0x800000
702 : : #define TXGBE_INCVAL_100 0xA00000
703 : : #define TXGBE_INCVAL_10 0xC7F380
704 : : #define TXGBE_INCVAL_FPGA 0x800000
705 : : #define TXGBE_INCVAL_SHIFT_10GB 20
706 : : #define TXGBE_INCVAL_SHIFT_1GB 18
707 : : #define TXGBE_INCVAL_SHIFT_100 15
708 : : #define TXGBE_INCVAL_SHIFT_10 12
709 : : #define TXGBE_INCVAL_SHIFT_FPGA 17
710 : :
711 : : #define TXGBE_CYCLECOUNTER_MASK 0xffffffffffffffffULL
712 : :
713 : : /* store statistics names and its offset in stats structure */
714 : : struct rte_txgbe_xstats_name_off {
715 : : char name[RTE_ETH_XSTATS_NAME_SIZE];
716 : : unsigned int offset;
717 : : };
718 : :
719 : : const uint32_t *txgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev,
720 : : size_t *no_of_elements);
721 : : int txgbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
722 : : struct rte_ether_addr *mc_addr_set,
723 : : uint32_t nb_mc_addr);
724 : : int txgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
725 : : struct rte_eth_rss_reta_entry64 *reta_conf,
726 : : uint16_t reta_size);
727 : : int txgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
728 : : struct rte_eth_rss_reta_entry64 *reta_conf,
729 : : uint16_t reta_size);
730 : : void txgbe_dev_setup_link_alarm_handler(void *param);
731 : : void txgbe_read_stats_registers(struct txgbe_hw *hw,
732 : : struct txgbe_hw_stats *hw_stats);
733 : :
734 : : void txgbe_vlan_hw_filter_enable(struct rte_eth_dev *dev);
735 : : void txgbe_vlan_hw_filter_disable(struct rte_eth_dev *dev);
736 : : void txgbe_vlan_hw_strip_config(struct rte_eth_dev *dev);
737 : : void txgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev,
738 : : uint16_t queue, bool on);
739 : : void txgbe_config_vlan_strip_on_all_queues(struct rte_eth_dev *dev,
740 : : int mask);
741 : :
742 : : #endif /* _TXGBE_ETHDEV_H_ */
|