vdpa/mlx5: add task ring for multi-thread management
[dpdk.git] / lib / ethdev / ethdev_driver.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Intel Corporation
3  */
4
5 #ifndef _RTE_ETHDEV_DRIVER_H_
6 #define _RTE_ETHDEV_DRIVER_H_
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 /**
13  * @file
14  *
15  * RTE Ethernet Device PMD API
16  *
17  * These APIs for the use from Ethernet drivers, user applications shouldn't
18  * use them.
19  *
20  */
21
22 #include <rte_ethdev.h>
23
24 /**
25  * @internal
26  * Structure used to hold information about the callbacks to be called for a
27  * queue on Rx and Tx.
28  */
29 struct rte_eth_rxtx_callback {
30         struct rte_eth_rxtx_callback *next;
31         union{
32                 rte_rx_callback_fn rx;
33                 rte_tx_callback_fn tx;
34         } fn;
35         void *param;
36 };
37
38 /**
39  * @internal
40  * The generic data structure associated with each Ethernet device.
41  *
42  * Pointers to burst-oriented packet receive and transmit functions are
43  * located at the beginning of the structure, along with the pointer to
44  * where all the data elements for the particular device are stored in shared
45  * memory. This split allows the function pointer and driver data to be per-
46  * process, while the actual configuration data for the device is shared.
47  */
48 struct rte_eth_dev {
49         eth_rx_burst_t rx_pkt_burst; /**< Pointer to PMD receive function */
50         eth_tx_burst_t tx_pkt_burst; /**< Pointer to PMD transmit function */
51
52         /** Pointer to PMD transmit prepare function */
53         eth_tx_prep_t tx_pkt_prepare;
54         /** Get the number of used Rx descriptors */
55         eth_rx_queue_count_t rx_queue_count;
56         /** Check the status of a Rx descriptor */
57         eth_rx_descriptor_status_t rx_descriptor_status;
58         /** Check the status of a Tx descriptor */
59         eth_tx_descriptor_status_t tx_descriptor_status;
60
61         /**
62          * Device data that is shared between primary and secondary processes
63          */
64         struct rte_eth_dev_data *data;
65         void *process_private; /**< Pointer to per-process device data */
66         const struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */
67         struct rte_device *device; /**< Backing device */
68         struct rte_intr_handle *intr_handle; /**< Device interrupt handle */
69
70         /** User application callbacks for NIC interrupts */
71         struct rte_eth_dev_cb_list link_intr_cbs;
72         /**
73          * User-supplied functions called from rx_burst to post-process
74          * received packets before passing them to the user
75          */
76         struct rte_eth_rxtx_callback *post_rx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
77         /**
78          * User-supplied functions called from tx_burst to pre-process
79          * received packets before passing them to the driver for transmission
80          */
81         struct rte_eth_rxtx_callback *pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
82
83         enum rte_eth_dev_state state; /**< Flag indicating the port state */
84         void *security_ctx; /**< Context for security ops */
85 } __rte_cache_aligned;
86
87 struct rte_eth_dev_sriov;
88 struct rte_eth_dev_owner;
89
90 /**
91  * @internal
92  * The data part, with no function pointers, associated with each Ethernet
93  * device. This structure is safe to place in shared memory to be common
94  * among different processes in a multi-process configuration.
95  */
96 struct rte_eth_dev_data {
97         char name[RTE_ETH_NAME_MAX_LEN]; /**< Unique identifier name */
98
99         void **rx_queues; /**< Array of pointers to Rx queues */
100         void **tx_queues; /**< Array of pointers to Tx queues */
101         uint16_t nb_rx_queues; /**< Number of Rx queues */
102         uint16_t nb_tx_queues; /**< Number of Tx queues */
103
104         struct rte_eth_dev_sriov sriov;    /**< SRIOV data */
105
106         /** PMD-specific private data. @see rte_eth_dev_release_port() */
107         void *dev_private;
108
109         struct rte_eth_link dev_link;   /**< Link-level information & status */
110         struct rte_eth_conf dev_conf;   /**< Configuration applied to device */
111         uint16_t mtu;                   /**< Maximum Transmission Unit */
112
113         /** Common Rx buffer size handled by all queues */
114         uint32_t min_rx_buf_size;
115
116         uint64_t rx_mbuf_alloc_failed; /**< Rx ring mbuf allocation failures */
117
118         /** Device Ethernet link address. @see rte_eth_dev_release_port() */
119         struct rte_ether_addr *mac_addrs;
120         /** Bitmap associating MAC addresses to pools */
121         uint64_t mac_pool_sel[RTE_ETH_NUM_RECEIVE_MAC_ADDR];
122         /**
123          * Device Ethernet MAC addresses of hash filtering.
124          * @see rte_eth_dev_release_port()
125          */
126         struct rte_ether_addr *hash_mac_addrs;
127
128         uint16_t port_id;           /**< Device [external] port identifier */
129
130         __extension__
131         uint8_t /** Rx promiscuous mode ON(1) / OFF(0) */
132                 promiscuous   : 1,
133                 /** Rx of scattered packets is ON(1) / OFF(0) */
134                 scattered_rx : 1,
135                 /** Rx all multicast mode ON(1) / OFF(0) */
136                 all_multicast : 1,
137                 /** Device state: STARTED(1) / STOPPED(0) */
138                 dev_started : 1,
139                 /** Rx LRO is ON(1) / OFF(0) */
140                 lro         : 1,
141                 /**
142                  * Indicates whether the device is configured:
143                  * CONFIGURED(1) / NOT CONFIGURED(0)
144                  */
145                 dev_configured : 1,
146                 /**
147                  * Indicates whether the flow engine is configured:
148                  * CONFIGURED(1) / NOT CONFIGURED(0)
149                  */
150                 flow_configured : 1;
151
152         /** Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0) */
153         uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
154         /** Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0) */
155         uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
156
157         uint32_t dev_flags;             /**< Capabilities */
158         int numa_node;                  /**< NUMA node connection */
159
160         /** VLAN filter configuration */
161         struct rte_vlan_filter_conf vlan_filter_conf;
162
163         struct rte_eth_dev_owner owner; /**< The port owner */
164
165         /**
166          * Switch-specific identifier.
167          * Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags.
168          */
169         uint16_t representor_id;
170         /**
171          * Port ID of the backing device.
172          * This device will be used to query representor info and calculate
173          * representor IDs. Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags.
174          */
175         uint16_t backer_port_id;
176
177         pthread_mutex_t flow_ops_mutex; /**< rte_flow ops mutex */
178 } __rte_cache_aligned;
179
180 /**
181  * @internal
182  * The pool of *rte_eth_dev* structures. The size of the pool
183  * is configured at compile-time in the <rte_ethdev.c> file.
184  */
185 extern struct rte_eth_dev rte_eth_devices[];
186
187 /** @internal Declaration of the hairpin peer queue information structure. */
188 struct rte_hairpin_peer_info;
189
190 /*
191  * Definitions of all functions exported by an Ethernet driver through the
192  * generic structure of type *eth_dev_ops* supplied in the *rte_eth_dev*
193  * structure associated with an Ethernet device.
194  */
195
196 /** @internal Ethernet device configuration. */
197 typedef int  (*eth_dev_configure_t)(struct rte_eth_dev *dev);
198
199 /** @internal Function used to start a configured Ethernet device. */
200 typedef int  (*eth_dev_start_t)(struct rte_eth_dev *dev);
201
202 /** @internal Function used to stop a configured Ethernet device. */
203 typedef int (*eth_dev_stop_t)(struct rte_eth_dev *dev);
204
205 /** @internal Function used to link up a configured Ethernet device. */
206 typedef int  (*eth_dev_set_link_up_t)(struct rte_eth_dev *dev);
207
208 /** @internal Function used to link down a configured Ethernet device. */
209 typedef int  (*eth_dev_set_link_down_t)(struct rte_eth_dev *dev);
210
211 /** @internal Function used to close a configured Ethernet device. */
212 typedef int (*eth_dev_close_t)(struct rte_eth_dev *dev);
213
214 /** @internal Function used to reset a configured Ethernet device. */
215 typedef int (*eth_dev_reset_t)(struct rte_eth_dev *dev);
216
217 /** @internal Function used to detect an Ethernet device removal. */
218 typedef int (*eth_is_removed_t)(struct rte_eth_dev *dev);
219
220 /**
221  * @internal
222  * Function used to enable the Rx promiscuous mode of an Ethernet device.
223  *
224  * @param dev
225  *   ethdev handle of port.
226  *
227  * @return
228  *   Negative errno value on error, 0 on success.
229  *
230  * @retval 0
231  *   Success, promiscuous mode is enabled.
232  * @retval -ENOTSUP
233  *   Promiscuous mode is not supported.
234  * @retval -ENODEV
235  *   Device is gone.
236  * @retval -E_RTE_SECONDARY
237  *   Function was called from a secondary process instance and not supported.
238  * @retval -ETIMEDOUT
239  *   Attempt to enable promiscuous mode failed because of timeout.
240  * @retval -EAGAIN
241  *   Failed to enable promiscuous mode.
242  */
243 typedef int (*eth_promiscuous_enable_t)(struct rte_eth_dev *dev);
244
245 /**
246  * @internal
247  * Function used to disable the Rx promiscuous mode of an Ethernet device.
248  *
249  * @param dev
250  *   ethdev handle of port.
251  *
252  * @return
253  *   Negative errno value on error, 0 on success.
254  *
255  * @retval 0
256  *   Success, promiscuous mode is disabled.
257  * @retval -ENOTSUP
258  *   Promiscuous mode disabling is not supported.
259  * @retval -ENODEV
260  *   Device is gone.
261  * @retval -E_RTE_SECONDARY
262  *   Function was called from a secondary process instance and not supported.
263  * @retval -ETIMEDOUT
264  *   Attempt to disable promiscuous mode failed because of timeout.
265  * @retval -EAGAIN
266  *   Failed to disable promiscuous mode.
267  */
268 typedef int (*eth_promiscuous_disable_t)(struct rte_eth_dev *dev);
269
270 /**
271  * @internal
272  * Enable the receipt of all multicast packets by an Ethernet device.
273  *
274  * @param dev
275  *   ethdev handle of port.
276  *
277  * @return
278  *   Negative errno value on error, 0 on success.
279  *
280  * @retval 0
281  *   Success, all-multicast mode is enabled.
282  * @retval -ENOTSUP
283  *   All-multicast mode is not supported.
284  * @retval -ENODEV
285  *   Device is gone.
286  * @retval -E_RTE_SECONDARY
287  *   Function was called from a secondary process instance and not supported.
288  * @retval -ETIMEDOUT
289  *   Attempt to enable all-multicast mode failed because of timeout.
290  * @retval -EAGAIN
291  *   Failed to enable all-multicast mode.
292  */
293 typedef int (*eth_allmulticast_enable_t)(struct rte_eth_dev *dev);
294
295 /**
296  * @internal
297  * Disable the receipt of all multicast packets by an Ethernet device.
298  *
299  * @param dev
300  *   ethdev handle of port.
301  *
302  * @return
303  *   Negative errno value on error, 0 on success.
304  *
305  * @retval 0
306  *   Success, all-multicast mode is disabled.
307  * @retval -ENOTSUP
308  *   All-multicast mode disabling is not supported.
309  * @retval -ENODEV
310  *   Device is gone.
311  * @retval -E_RTE_SECONDARY
312  *   Function was called from a secondary process instance and not supported.
313  * @retval -ETIMEDOUT
314  *   Attempt to disable all-multicast mode failed because of timeout.
315  * @retval -EAGAIN
316  *   Failed to disable all-multicast mode.
317  */
318 typedef int (*eth_allmulticast_disable_t)(struct rte_eth_dev *dev);
319
320 /**
321  * @internal
322  * Get link speed, duplex mode and state (up/down) of an Ethernet device.
323  */
324 typedef int (*eth_link_update_t)(struct rte_eth_dev *dev,
325                                 int wait_to_complete);
326
327 /** @internal Get global I/O statistics of an Ethernet device. */
328 typedef int (*eth_stats_get_t)(struct rte_eth_dev *dev,
329                                 struct rte_eth_stats *igb_stats);
330
331 /**
332  * @internal
333  * Reset global I/O statistics of an Ethernet device to 0.
334  *
335  * @param dev
336  *   ethdev handle of port.
337  *
338  * @return
339  *   Negative errno value on error, 0 on success.
340  *
341  * @retval 0
342  *   Success, statistics has been reset.
343  * @retval -ENOTSUP
344  *   Resetting statistics is not supported.
345  * @retval -EINVAL
346  *   Resetting statistics is not valid.
347  * @retval -ENOMEM
348  *   Not enough memory to get the stats.
349  */
350 typedef int (*eth_stats_reset_t)(struct rte_eth_dev *dev);
351
352 /** @internal Get extended stats of an Ethernet device. */
353 typedef int (*eth_xstats_get_t)(struct rte_eth_dev *dev,
354         struct rte_eth_xstat *stats, unsigned int n);
355
356 /**
357  * @internal
358  * Get extended stats of an Ethernet device.
359  *
360  * @param dev
361  *   ethdev handle of port.
362  * @param ids
363  *   IDs array to retrieve specific statistics. Must not be NULL.
364  * @param values
365  *   A pointer to a table to be filled with device statistics values.
366  *   Must not be NULL.
367  * @param n
368  *   Element count in @p ids and @p values.
369  *
370  * @return
371  *   - A number of filled in stats.
372  *   - A negative value on error.
373  */
374 typedef int (*eth_xstats_get_by_id_t)(struct rte_eth_dev *dev,
375                                       const uint64_t *ids,
376                                       uint64_t *values,
377                                       unsigned int n);
378
379 /**
380  * @internal
381  * Reset extended stats of an Ethernet device.
382  *
383  * @param dev
384  *   ethdev handle of port.
385  *
386  * @return
387  *   Negative errno value on error, 0 on success.
388  *
389  * @retval 0
390  *   Success, statistics has been reset.
391  * @retval -ENOTSUP
392  *   Resetting statistics is not supported.
393  * @retval -EINVAL
394  *   Resetting statistics is not valid.
395  * @retval -ENOMEM
396  *   Not enough memory to get the stats.
397  */
398 typedef int (*eth_xstats_reset_t)(struct rte_eth_dev *dev);
399
400 /** @internal Get names of extended stats of an Ethernet device. */
401 typedef int (*eth_xstats_get_names_t)(struct rte_eth_dev *dev,
402         struct rte_eth_xstat_name *xstats_names, unsigned int size);
403
404 /**
405  * @internal
406  * Get names of extended stats of an Ethernet device.
407  *
408  * @param dev
409  *   ethdev handle of port.
410  * @param ids
411  *   IDs array to retrieve specific statistics. Must not be NULL.
412  * @param xstats_names
413  *   An rte_eth_xstat_name array of at least @p size elements to be filled.
414  *   Must not be NULL.
415  * @param size
416  *   Element count in @p ids and @p xstats_names.
417  *
418  * @return
419  *   - A number of filled in stats.
420  *   - A negative value on error.
421  */
422 typedef int (*eth_xstats_get_names_by_id_t)(struct rte_eth_dev *dev,
423         const uint64_t *ids, struct rte_eth_xstat_name *xstats_names,
424         unsigned int size);
425
426 /**
427  * @internal
428  * Set a queue statistics mapping for a Tx/Rx queue of an Ethernet device.
429  */
430 typedef int (*eth_queue_stats_mapping_set_t)(struct rte_eth_dev *dev,
431                                              uint16_t queue_id,
432                                              uint8_t stat_idx,
433                                              uint8_t is_rx);
434
435 /** @internal Get specific information of an Ethernet device. */
436 typedef int (*eth_dev_infos_get_t)(struct rte_eth_dev *dev,
437                                    struct rte_eth_dev_info *dev_info);
438
439 /** @internal Get supported ptypes of an Ethernet device. */
440 typedef const uint32_t *(*eth_dev_supported_ptypes_get_t)(struct rte_eth_dev *dev);
441
442 /**
443  * @internal
444  * Inform Ethernet device about reduced range of packet types to handle.
445  *
446  * @param dev
447  *   The Ethernet device identifier.
448  * @param ptype_mask
449  *   The ptype family that application is interested in should be bitwise OR of
450  *   RTE_PTYPE_*_MASK or 0.
451  * @return
452  *   - (0) if Success.
453  */
454 typedef int (*eth_dev_ptypes_set_t)(struct rte_eth_dev *dev,
455                                      uint32_t ptype_mask);
456
457 /** @internal Start Rx and Tx of a queue of an Ethernet device. */
458 typedef int (*eth_queue_start_t)(struct rte_eth_dev *dev,
459                                     uint16_t queue_id);
460
461 /** @internal Stop Rx and Tx of a queue of an Ethernet device. */
462 typedef int (*eth_queue_stop_t)(struct rte_eth_dev *dev,
463                                     uint16_t queue_id);
464
465 /** @internal Set up a receive queue of an Ethernet device. */
466 typedef int (*eth_rx_queue_setup_t)(struct rte_eth_dev *dev,
467                                     uint16_t rx_queue_id,
468                                     uint16_t nb_rx_desc,
469                                     unsigned int socket_id,
470                                     const struct rte_eth_rxconf *rx_conf,
471                                     struct rte_mempool *mb_pool);
472
473 /** @internal Setup a transmit queue of an Ethernet device. */
474 typedef int (*eth_tx_queue_setup_t)(struct rte_eth_dev *dev,
475                                     uint16_t tx_queue_id,
476                                     uint16_t nb_tx_desc,
477                                     unsigned int socket_id,
478                                     const struct rte_eth_txconf *tx_conf);
479
480 /** @internal Enable interrupt of a receive queue of an Ethernet device. */
481 typedef int (*eth_rx_enable_intr_t)(struct rte_eth_dev *dev,
482                                     uint16_t rx_queue_id);
483
484 /** @internal Disable interrupt of a receive queue of an Ethernet device. */
485 typedef int (*eth_rx_disable_intr_t)(struct rte_eth_dev *dev,
486                                     uint16_t rx_queue_id);
487
488 /** @internal Release memory resources allocated by given Rx/Tx queue. */
489 typedef void (*eth_queue_release_t)(struct rte_eth_dev *dev,
490                                     uint16_t queue_id);
491
492 /** @internal Get firmware information of an Ethernet device. */
493 typedef int (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
494                                      char *fw_version, size_t fw_size);
495
496 /** @internal Force mbufs to be from Tx ring. */
497 typedef int (*eth_tx_done_cleanup_t)(void *txq, uint32_t free_cnt);
498
499 typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
500         uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
501
502 typedef void (*eth_txq_info_get_t)(struct rte_eth_dev *dev,
503         uint16_t tx_queue_id, struct rte_eth_txq_info *qinfo);
504
505 typedef int (*eth_burst_mode_get_t)(struct rte_eth_dev *dev,
506         uint16_t queue_id, struct rte_eth_burst_mode *mode);
507
508 /** @internal Set MTU. */
509 typedef int (*mtu_set_t)(struct rte_eth_dev *dev, uint16_t mtu);
510
511 /** @internal Filtering of a VLAN Tag Identifier by an Ethernet device. */
512 typedef int (*vlan_filter_set_t)(struct rte_eth_dev *dev,
513                                   uint16_t vlan_id,
514                                   int on);
515
516 /** @internal Set the outer/inner VLAN-TPID by an Ethernet device. */
517 typedef int (*vlan_tpid_set_t)(struct rte_eth_dev *dev,
518                                enum rte_vlan_type type, uint16_t tpid);
519
520 /** @internal Set VLAN offload function by an Ethernet device. */
521 typedef int (*vlan_offload_set_t)(struct rte_eth_dev *dev, int mask);
522
523 /** @internal Set port based Tx VLAN insertion by an Ethernet device. */
524 typedef int (*vlan_pvid_set_t)(struct rte_eth_dev *dev,
525                                uint16_t vlan_id,
526                                int on);
527
528 /** @internal VLAN stripping enable/disable by an queue of Ethernet device. */
529 typedef void (*vlan_strip_queue_set_t)(struct rte_eth_dev *dev,
530                                   uint16_t rx_queue_id,
531                                   int on);
532
533 /** @internal Get current flow control parameter on an Ethernet device. */
534 typedef int (*flow_ctrl_get_t)(struct rte_eth_dev *dev,
535                                struct rte_eth_fc_conf *fc_conf);
536
537 /** @internal Setup flow control parameter on an Ethernet device. */
538 typedef int (*flow_ctrl_set_t)(struct rte_eth_dev *dev,
539                                struct rte_eth_fc_conf *fc_conf);
540
541 /** @internal Setup priority flow control parameter on an Ethernet device. */
542 typedef int (*priority_flow_ctrl_set_t)(struct rte_eth_dev *dev,
543                                 struct rte_eth_pfc_conf *pfc_conf);
544
545 /** @internal Get info for queue based PFC on an Ethernet device. */
546 typedef int (*priority_flow_ctrl_queue_info_get_t)(struct rte_eth_dev *dev,
547                         struct rte_eth_pfc_queue_info *pfc_queue_info);
548 /** @internal Configure queue based PFC parameter on an Ethernet device. */
549 typedef int (*priority_flow_ctrl_queue_config_t)(struct rte_eth_dev *dev,
550                         struct rte_eth_pfc_queue_conf *pfc_queue_conf);
551
552 /** @internal Update RSS redirection table on an Ethernet device. */
553 typedef int (*reta_update_t)(struct rte_eth_dev *dev,
554                              struct rte_eth_rss_reta_entry64 *reta_conf,
555                              uint16_t reta_size);
556
557 /** @internal Query RSS redirection table on an Ethernet device. */
558 typedef int (*reta_query_t)(struct rte_eth_dev *dev,
559                             struct rte_eth_rss_reta_entry64 *reta_conf,
560                             uint16_t reta_size);
561
562 /** @internal Update RSS hash configuration of an Ethernet device. */
563 typedef int (*rss_hash_update_t)(struct rte_eth_dev *dev,
564                                  struct rte_eth_rss_conf *rss_conf);
565
566 /** @internal Get current RSS hash configuration of an Ethernet device. */
567 typedef int (*rss_hash_conf_get_t)(struct rte_eth_dev *dev,
568                                    struct rte_eth_rss_conf *rss_conf);
569
570 /** @internal Turn on SW controllable LED on an Ethernet device. */
571 typedef int (*eth_dev_led_on_t)(struct rte_eth_dev *dev);
572
573 /** @internal Turn off SW controllable LED on an Ethernet device. */
574 typedef int (*eth_dev_led_off_t)(struct rte_eth_dev *dev);
575
576 /** @internal Remove MAC address from receive address register. */
577 typedef void (*eth_mac_addr_remove_t)(struct rte_eth_dev *dev, uint32_t index);
578
579 /** @internal Set a MAC address into Receive Address Register. */
580 typedef int (*eth_mac_addr_add_t)(struct rte_eth_dev *dev,
581                                   struct rte_ether_addr *mac_addr,
582                                   uint32_t index,
583                                   uint32_t vmdq);
584
585 /** @internal Set a MAC address into Receive Address Register. */
586 typedef int (*eth_mac_addr_set_t)(struct rte_eth_dev *dev,
587                                   struct rte_ether_addr *mac_addr);
588
589 /** @internal Set a Unicast Hash bitmap. */
590 typedef int (*eth_uc_hash_table_set_t)(struct rte_eth_dev *dev,
591                                   struct rte_ether_addr *mac_addr,
592                                   uint8_t on);
593
594 /** @internal Set all Unicast Hash bitmap. */
595 typedef int (*eth_uc_all_hash_table_set_t)(struct rte_eth_dev *dev,
596                                   uint8_t on);
597
598 /** @internal Set queue Tx rate. */
599 typedef int (*eth_set_queue_rate_limit_t)(struct rte_eth_dev *dev,
600                                 uint16_t queue_idx,
601                                 uint16_t tx_rate);
602
603 /** @internal Add tunneling UDP port. */
604 typedef int (*eth_udp_tunnel_port_add_t)(struct rte_eth_dev *dev,
605                                          struct rte_eth_udp_tunnel *tunnel_udp);
606
607 /** @internal Delete tunneling UDP port. */
608 typedef int (*eth_udp_tunnel_port_del_t)(struct rte_eth_dev *dev,
609                                          struct rte_eth_udp_tunnel *tunnel_udp);
610
611 /** @internal set the list of multicast addresses on an Ethernet device. */
612 typedef int (*eth_set_mc_addr_list_t)(struct rte_eth_dev *dev,
613                                       struct rte_ether_addr *mc_addr_set,
614                                       uint32_t nb_mc_addr);
615
616 /** @internal Function used to enable IEEE1588/802.1AS timestamping. */
617 typedef int (*eth_timesync_enable_t)(struct rte_eth_dev *dev);
618
619 /** @internal Function used to disable IEEE1588/802.1AS timestamping. */
620 typedef int (*eth_timesync_disable_t)(struct rte_eth_dev *dev);
621
622 /** @internal Function used to read an Rx IEEE1588/802.1AS timestamp. */
623 typedef int (*eth_timesync_read_rx_timestamp_t)(struct rte_eth_dev *dev,
624                                                 struct timespec *timestamp,
625                                                 uint32_t flags);
626
627 /** @internal Function used to read a Tx IEEE1588/802.1AS timestamp. */
628 typedef int (*eth_timesync_read_tx_timestamp_t)(struct rte_eth_dev *dev,
629                                                 struct timespec *timestamp);
630
631 /** @internal Function used to adjust the device clock. */
632 typedef int (*eth_timesync_adjust_time)(struct rte_eth_dev *dev, int64_t);
633
634 /** @internal Function used to get time from the device clock. */
635 typedef int (*eth_timesync_read_time)(struct rte_eth_dev *dev,
636                                       struct timespec *timestamp);
637
638 /** @internal Function used to get time from the device clock. */
639 typedef int (*eth_timesync_write_time)(struct rte_eth_dev *dev,
640                                        const struct timespec *timestamp);
641
642 /** @internal Function used to get the current value of the device clock. */
643 typedef int (*eth_read_clock)(struct rte_eth_dev *dev,
644                                       uint64_t *timestamp);
645
646 /** @internal Retrieve registers. */
647 typedef int (*eth_get_reg_t)(struct rte_eth_dev *dev,
648                                 struct rte_dev_reg_info *info);
649
650 /** @internal Retrieve EEPROM size. */
651 typedef int (*eth_get_eeprom_length_t)(struct rte_eth_dev *dev);
652
653 /** @internal Retrieve EEPROM data. */
654 typedef int (*eth_get_eeprom_t)(struct rte_eth_dev *dev,
655                                 struct rte_dev_eeprom_info *info);
656
657 /** @internal Program EEPROM data. */
658 typedef int (*eth_set_eeprom_t)(struct rte_eth_dev *dev,
659                                 struct rte_dev_eeprom_info *info);
660
661 /** @internal Retrieve type and size of plugin module EEPROM. */
662 typedef int (*eth_get_module_info_t)(struct rte_eth_dev *dev,
663                                      struct rte_eth_dev_module_info *modinfo);
664
665 /** @internal Retrieve plugin module EEPROM data. */
666 typedef int (*eth_get_module_eeprom_t)(struct rte_eth_dev *dev,
667                                        struct rte_dev_eeprom_info *info);
668
669 struct rte_flow_ops;
670 /**
671  * @internal
672  * Get flow operations.
673  *
674  * If the flow API is not supported for the specified device,
675  * the driver can return NULL.
676  */
677 typedef int (*eth_flow_ops_get_t)(struct rte_eth_dev *dev,
678                                   const struct rte_flow_ops **ops);
679
680 /** @internal Get Traffic Management (TM) operations on an Ethernet device. */
681 typedef int (*eth_tm_ops_get_t)(struct rte_eth_dev *dev, void *ops);
682
683 /** @internal Get Traffic Metering and Policing (MTR) operations. */
684 typedef int (*eth_mtr_ops_get_t)(struct rte_eth_dev *dev, void *ops);
685
686 /** @internal Get DCB information on an Ethernet device. */
687 typedef int (*eth_get_dcb_info)(struct rte_eth_dev *dev,
688                                  struct rte_eth_dcb_info *dcb_info);
689
690 /** @internal Test if a port supports specific mempool ops. */
691 typedef int (*eth_pool_ops_supported_t)(struct rte_eth_dev *dev,
692                                                 const char *pool);
693
694 /**
695  * @internal
696  * Get the hairpin capabilities.
697  *
698  * @param dev
699  *   ethdev handle of port.
700  * @param cap
701  *   returns the hairpin capabilities from the device.
702  *
703  * @return
704  *   Negative errno value on error, 0 on success.
705  *
706  * @retval 0
707  *   Success, hairpin is supported.
708  * @retval -ENOTSUP
709  *   Hairpin is not supported.
710  */
711 typedef int (*eth_hairpin_cap_get_t)(struct rte_eth_dev *dev,
712                                      struct rte_eth_hairpin_cap *cap);
713
714 /**
715  * @internal
716  * Setup Rx hairpin queue.
717  *
718  * @param dev
719  *   ethdev handle of port.
720  * @param rx_queue_id
721  *   the selected Rx queue index.
722  * @param nb_rx_desc
723  *   the requested number of descriptors for this queue. 0 - use PMD default.
724  * @param conf
725  *   the Rx hairpin configuration structure.
726  *
727  * @return
728  *   Negative errno value on error, 0 on success.
729  *
730  * @retval 0
731  *   Success, hairpin is supported.
732  * @retval -ENOTSUP
733  *   Hairpin is not supported.
734  * @retval -EINVAL
735  *   One of the parameters is invalid.
736  * @retval -ENOMEM
737  *   Unable to allocate resources.
738  */
739 typedef int (*eth_rx_hairpin_queue_setup_t)
740         (struct rte_eth_dev *dev, uint16_t rx_queue_id,
741          uint16_t nb_rx_desc,
742          const struct rte_eth_hairpin_conf *conf);
743
744 /**
745  * @internal
746  * Setup Tx hairpin queue.
747  *
748  * @param dev
749  *   ethdev handle of port.
750  * @param tx_queue_id
751  *   the selected Tx queue index.
752  * @param nb_tx_desc
753  *   the requested number of descriptors for this queue. 0 - use PMD default.
754  * @param conf
755  *   the Tx hairpin configuration structure.
756  *
757  * @return
758  *   Negative errno value on error, 0 on success.
759  *
760  * @retval 0
761  *   Success, hairpin is supported.
762  * @retval -ENOTSUP
763  *   Hairpin is not supported.
764  * @retval -EINVAL
765  *   One of the parameters is invalid.
766  * @retval -ENOMEM
767  *   Unable to allocate resources.
768  */
769 typedef int (*eth_tx_hairpin_queue_setup_t)
770         (struct rte_eth_dev *dev, uint16_t tx_queue_id,
771          uint16_t nb_tx_desc,
772          const struct rte_eth_hairpin_conf *hairpin_conf);
773
774 /**
775  * @internal
776  * Get Forward Error Correction(FEC) capability.
777  *
778  * @param dev
779  *   ethdev handle of port.
780  * @param speed_fec_capa
781  *   speed_fec_capa is out only with per-speed capabilities.
782  * @param num
783  *   a number of elements in an speed_fec_capa array.
784  *
785  * @return
786  *   Negative errno value on error, positive value on success.
787  *
788  * @retval positive value
789  *   A non-negative value lower or equal to num: success. The return value
790  *   is the number of entries filled in the fec capa array.
791  *   A non-negative value higher than num: error, the given fec capa array
792  *   is too small. The return value corresponds to the num that should
793  *   be given to succeed. The entries in the fec capa array are not valid
794  *   and shall not be used by the caller.
795  * @retval -ENOTSUP
796  *   Operation is not supported.
797  * @retval -EIO
798  *   Device is removed.
799  * @retval -EINVAL
800  *   *num* or *speed_fec_capa* invalid.
801  */
802 typedef int (*eth_fec_get_capability_t)(struct rte_eth_dev *dev,
803                 struct rte_eth_fec_capa *speed_fec_capa, unsigned int num);
804
805 /**
806  * @internal
807  * Get Forward Error Correction(FEC) mode.
808  *
809  * @param dev
810  *   ethdev handle of port.
811  * @param fec_capa
812  *   a bitmask of enabled FEC modes. If AUTO bit is set, other
813  *   bits specify FEC modes which may be negotiated. If AUTO
814  *   bit is clear, specify FEC modes to be used (only one valid
815  *   mode per speed may be set).
816  *
817  * @return
818  *   Negative errno value on error, 0 on success.
819  *
820  * @retval 0
821  *   Success, get FEC success.
822  * @retval -ENOTSUP
823  *   Operation is not supported.
824  * @retval -EIO
825  *   Device is removed.
826  */
827 typedef int (*eth_fec_get_t)(struct rte_eth_dev *dev,
828                              uint32_t *fec_capa);
829
830 /**
831  * @internal
832  * Set Forward Error Correction(FEC) mode.
833  *
834  * @param dev
835  *   ethdev handle of port.
836  * @param fec_capa
837  *   bitmask of allowed FEC modes. It must be only one
838  *   if AUTO is disabled. If AUTO is enabled, other
839  *   bits specify FEC modes which may be negotiated.
840  *
841  * @return
842  *   Negative errno value on error, 0 on success.
843  *
844  * @retval 0
845  *   Success, set FEC success.
846  * @retval -ENOTSUP
847  *   Operation is not supported.
848  * @retval -EINVAL
849  *   Unsupported FEC mode requested.
850  * @retval -EIO
851  *   Device is removed.
852  */
853 typedef int (*eth_fec_set_t)(struct rte_eth_dev *dev, uint32_t fec_capa);
854
855 /**
856  * @internal
857  * Get all hairpin Tx/Rx peer ports of the current device, if any.
858  *
859  * @param dev
860  *   ethdev handle of port.
861  * @param peer_ports
862  *   array to save the ports list.
863  * @param len
864  *   array length.
865  * @param direction
866  *   value to decide the current to peer direction
867  *   positive - used as Tx to get all peer Rx ports.
868  *   zero - used as Rx to get all peer Tx ports.
869  *
870  * @return
871  *   Negative errno value on error, 0 or positive on success.
872  *
873  * @retval 0
874  *   Success, no peer ports.
875  * @retval >0
876  *   Actual number of the peer ports.
877  * @retval -ENOTSUP
878  *   Get peer ports API is not supported.
879  * @retval -EINVAL
880  *   One of the parameters is invalid.
881  */
882 typedef int (*hairpin_get_peer_ports_t)(struct rte_eth_dev *dev,
883                                         uint16_t *peer_ports, size_t len,
884                                         uint32_t direction);
885
886 /**
887  * @internal
888  * Bind all hairpin Tx queues of one port to the Rx queues of the peer port.
889  *
890  * @param dev
891  *   ethdev handle of port.
892  * @param rx_port
893  *   the peer Rx port.
894  *
895  * @return
896  *   Negative errno value on error, 0 on success.
897  *
898  * @retval 0
899  *   Success, bind successfully.
900  * @retval -ENOTSUP
901  *   Bind API is not supported.
902  * @retval -EINVAL
903  *   One of the parameters is invalid.
904  * @retval -EBUSY
905  *   Device is not started.
906  */
907 typedef int (*eth_hairpin_bind_t)(struct rte_eth_dev *dev,
908                                 uint16_t rx_port);
909
910 /**
911  * @internal
912  * Unbind all hairpin Tx queues of one port from the Rx queues of the peer port.
913  *
914  * @param dev
915  *   ethdev handle of port.
916  * @param rx_port
917  *   the peer Rx port.
918  *
919  * @return
920  *   Negative errno value on error, 0 on success.
921  *
922  * @retval 0
923  *   Success, unbind successfully.
924  * @retval -ENOTSUP
925  *   Bind API is not supported.
926  * @retval -EINVAL
927  *   One of the parameters is invalid.
928  * @retval -EBUSY
929  *   Device is already stopped.
930  */
931 typedef int (*eth_hairpin_unbind_t)(struct rte_eth_dev *dev,
932                                   uint16_t rx_port);
933
934 /** @internal Update and fetch peer queue information. */
935 typedef int (*eth_hairpin_queue_peer_update_t)
936         (struct rte_eth_dev *dev, uint16_t peer_queue,
937          struct rte_hairpin_peer_info *current_info,
938          struct rte_hairpin_peer_info *peer_info, uint32_t direction);
939
940 /** @internal Bind peer queue to the current queue with fetched information. */
941 typedef int (*eth_hairpin_queue_peer_bind_t)
942         (struct rte_eth_dev *dev, uint16_t cur_queue,
943          struct rte_hairpin_peer_info *peer_info, uint32_t direction);
944
945 /** @internal Unbind peer queue from the current queue. */
946 typedef int (*eth_hairpin_queue_peer_unbind_t)
947         (struct rte_eth_dev *dev, uint16_t cur_queue, uint32_t direction);
948
949 /**
950  * @internal
951  * Get address of memory location whose contents will change whenever there is
952  * new data to be received on an Rx queue.
953  *
954  * @param rxq
955  *   Ethdev queue pointer.
956  * @param pmc
957  *   The pointer to power-optimized monitoring condition structure.
958  * @return
959  *   Negative errno value on error, 0 on success.
960  *
961  * @retval 0
962  *   Success
963  * @retval -EINVAL
964  *   Invalid parameters
965  */
966 typedef int (*eth_get_monitor_addr_t)(void *rxq,
967                 struct rte_power_monitor_cond *pmc);
968
969 /**
970  * @internal
971  * Get representor info to be able to calculate the unique representor ID.
972  *
973  * Caller should pass NULL as pointer of info to get number of entries,
974  * allocate info buffer according to returned entry number, then call
975  * again with buffer to get real info.
976  *
977  * To calculate the representor ID, caller should iterate each entry,
978  * match controller index, pf index, vf or sf start index and range,
979  * then calculate representor ID from offset to vf/sf start index.
980  * @see rte_eth_representor_id_get.
981  *
982  * @param dev
983  *   Ethdev handle of port.
984  * @param [out] info
985  *   Pointer to memory to save device representor info.
986  * @return
987  *   Negative errno value on error, number of info entries otherwise.
988  */
989
990 typedef int (*eth_representor_info_get_t)(struct rte_eth_dev *dev,
991         struct rte_eth_representor_info *info);
992
993 /**
994  * @internal
995  * Negotiate the NIC's ability to deliver specific kinds of metadata to the PMD.
996  *
997  * @param dev
998  *   Port (ethdev) handle
999  *
1000  * @param[inout] features
1001  *   Feature selection buffer
1002  *
1003  * @return
1004  *   Negative errno value on error, zero otherwise
1005  */
1006 typedef int (*eth_rx_metadata_negotiate_t)(struct rte_eth_dev *dev,
1007                                        uint64_t *features);
1008
1009 /**
1010  * @internal
1011  * Get IP reassembly offload capability of a PMD.
1012  *
1013  * @param dev
1014  *   Port (ethdev) handle
1015  *
1016  * @param[out] conf
1017  *   IP reassembly capability supported by the PMD
1018  *
1019  * @return
1020  *   Negative errno value on error, zero otherwise
1021  */
1022 typedef int (*eth_ip_reassembly_capability_get_t)(struct rte_eth_dev *dev,
1023                 struct rte_eth_ip_reassembly_params *capa);
1024
1025 /**
1026  * @internal
1027  * Get IP reassembly offload configuration parameters set in PMD.
1028  *
1029  * @param dev
1030  *   Port (ethdev) handle
1031  *
1032  * @param[out] conf
1033  *   Configuration parameters for IP reassembly.
1034  *
1035  * @return
1036  *   Negative errno value on error, zero otherwise
1037  */
1038 typedef int (*eth_ip_reassembly_conf_get_t)(struct rte_eth_dev *dev,
1039                 struct rte_eth_ip_reassembly_params *conf);
1040
1041 /**
1042  * @internal
1043  * Set configuration parameters for enabling IP reassembly offload in hardware.
1044  *
1045  * @param dev
1046  *   Port (ethdev) handle
1047  *
1048  * @param[in] conf
1049  *   Configuration parameters for IP reassembly.
1050  *
1051  * @return
1052  *   Negative errno value on error, zero otherwise
1053  */
1054 typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev,
1055                 const struct rte_eth_ip_reassembly_params *conf);
1056
1057 /**
1058  * @internal
1059  * Dump private info from device to a file.
1060  *
1061  * @param dev
1062  *   Port (ethdev) handle.
1063  * @param file
1064  *   A pointer to a file for output.
1065  *
1066  * @return
1067  *   Negative value on error, 0 on success.
1068  *
1069  * @retval 0
1070  *   Success
1071  * @retval -EINVAL
1072  *   Invalid file
1073  */
1074 typedef int (*eth_dev_priv_dump_t)(struct rte_eth_dev *dev, FILE *file);
1075
1076 /**
1077  * @internal Set Rx queue available descriptors threshold.
1078  * @see rte_eth_rx_avail_thresh_set()
1079  *
1080  * Driver should round down number of descriptors on conversion from
1081  * percentage.
1082  */
1083 typedef int (*eth_rx_queue_avail_thresh_set_t)(struct rte_eth_dev *dev,
1084                                       uint16_t rx_queue_id,
1085                                       uint8_t avail_thresh);
1086
1087 /**
1088  * @internal Query Rx queue available descriptors threshold event.
1089  * @see rte_eth_rx_avail_thresh_query()
1090  */
1091
1092 typedef int (*eth_rx_queue_avail_thresh_query_t)(struct rte_eth_dev *dev,
1093                                         uint16_t *rx_queue_id,
1094                                         uint8_t *avail_thresh);
1095
1096 /**
1097  * @internal A structure containing the functions exported by an Ethernet driver.
1098  */
1099 struct eth_dev_ops {
1100         eth_dev_configure_t        dev_configure; /**< Configure device */
1101         eth_dev_start_t            dev_start;     /**< Start device */
1102         eth_dev_stop_t             dev_stop;      /**< Stop device */
1103         eth_dev_set_link_up_t      dev_set_link_up;   /**< Device link up */
1104         eth_dev_set_link_down_t    dev_set_link_down; /**< Device link down */
1105         eth_dev_close_t            dev_close;     /**< Close device */
1106         eth_dev_reset_t            dev_reset;     /**< Reset device */
1107         eth_link_update_t          link_update;   /**< Get device link state */
1108         /** Check if the device was physically removed */
1109         eth_is_removed_t           is_removed;
1110
1111         eth_promiscuous_enable_t   promiscuous_enable; /**< Promiscuous ON */
1112         eth_promiscuous_disable_t  promiscuous_disable;/**< Promiscuous OFF */
1113         eth_allmulticast_enable_t  allmulticast_enable;/**< Rx multicast ON */
1114         eth_allmulticast_disable_t allmulticast_disable;/**< Rx multicast OFF */
1115         eth_mac_addr_remove_t      mac_addr_remove; /**< Remove MAC address */
1116         eth_mac_addr_add_t         mac_addr_add;  /**< Add a MAC address */
1117         eth_mac_addr_set_t         mac_addr_set;  /**< Set a MAC address */
1118         /** Set list of multicast addresses */
1119         eth_set_mc_addr_list_t     set_mc_addr_list;
1120         mtu_set_t                  mtu_set;       /**< Set MTU */
1121
1122         /** Get generic device statistics */
1123         eth_stats_get_t            stats_get;
1124         /** Reset generic device statistics */
1125         eth_stats_reset_t          stats_reset;
1126         /** Get extended device statistics */
1127         eth_xstats_get_t           xstats_get;
1128         /** Reset extended device statistics */
1129         eth_xstats_reset_t         xstats_reset;
1130         /** Get names of extended statistics */
1131         eth_xstats_get_names_t     xstats_get_names;
1132         /** Configure per queue stat counter mapping */
1133         eth_queue_stats_mapping_set_t queue_stats_mapping_set;
1134
1135         eth_dev_infos_get_t        dev_infos_get; /**< Get device info */
1136         /** Retrieve Rx queue information */
1137         eth_rxq_info_get_t         rxq_info_get;
1138         /** Retrieve Tx queue information */
1139         eth_txq_info_get_t         txq_info_get;
1140         eth_burst_mode_get_t       rx_burst_mode_get; /**< Get Rx burst mode */
1141         eth_burst_mode_get_t       tx_burst_mode_get; /**< Get Tx burst mode */
1142         eth_fw_version_get_t       fw_version_get; /**< Get firmware version */
1143
1144         /** Get packet types supported and identified by device */
1145         eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
1146         /**
1147          * Inform Ethernet device about reduced range of packet types to
1148          * handle
1149          */
1150         eth_dev_ptypes_set_t dev_ptypes_set;
1151
1152         /** Filter VLAN Setup */
1153         vlan_filter_set_t          vlan_filter_set;
1154         /** Outer/Inner VLAN TPID Setup */
1155         vlan_tpid_set_t            vlan_tpid_set;
1156         /** VLAN Stripping on queue */
1157         vlan_strip_queue_set_t     vlan_strip_queue_set;
1158         /** Set VLAN Offload */
1159         vlan_offload_set_t         vlan_offload_set;
1160         /** Set port based Tx VLAN insertion */
1161         vlan_pvid_set_t            vlan_pvid_set;
1162
1163         eth_queue_start_t          rx_queue_start;/**< Start Rx for a queue */
1164         eth_queue_stop_t           rx_queue_stop; /**< Stop Rx for a queue */
1165         eth_queue_start_t          tx_queue_start;/**< Start Tx for a queue */
1166         eth_queue_stop_t           tx_queue_stop; /**< Stop Tx for a queue */
1167         eth_rx_queue_setup_t       rx_queue_setup;/**< Set up device Rx queue */
1168         eth_queue_release_t        rx_queue_release; /**< Release Rx queue */
1169
1170         /** Enable Rx queue interrupt */
1171         eth_rx_enable_intr_t       rx_queue_intr_enable;
1172         /** Disable Rx queue interrupt */
1173         eth_rx_disable_intr_t      rx_queue_intr_disable;
1174
1175         eth_tx_queue_setup_t       tx_queue_setup;/**< Set up device Tx queue */
1176         eth_queue_release_t        tx_queue_release; /**< Release Tx queue */
1177         eth_tx_done_cleanup_t      tx_done_cleanup;/**< Free Tx ring mbufs */
1178
1179         eth_dev_led_on_t           dev_led_on;    /**< Turn on LED */
1180         eth_dev_led_off_t          dev_led_off;   /**< Turn off LED */
1181
1182         flow_ctrl_get_t            flow_ctrl_get; /**< Get flow control */
1183         flow_ctrl_set_t            flow_ctrl_set; /**< Setup flow control */
1184         /** Setup priority flow control */
1185         priority_flow_ctrl_set_t   priority_flow_ctrl_set;
1186         /** Priority flow control queue info get */
1187         priority_flow_ctrl_queue_info_get_t priority_flow_ctrl_queue_info_get;
1188         /** Priority flow control queue configure */
1189         priority_flow_ctrl_queue_config_t priority_flow_ctrl_queue_config;
1190
1191         /** Set Unicast Table Array */
1192         eth_uc_hash_table_set_t    uc_hash_table_set;
1193         /** Set Unicast hash bitmap */
1194         eth_uc_all_hash_table_set_t uc_all_hash_table_set;
1195
1196         /** Add UDP tunnel port */
1197         eth_udp_tunnel_port_add_t  udp_tunnel_port_add;
1198         /** Delete UDP tunnel port */
1199         eth_udp_tunnel_port_del_t  udp_tunnel_port_del;
1200
1201         /** Set queue rate limit */
1202         eth_set_queue_rate_limit_t set_queue_rate_limit;
1203
1204         /** Configure RSS hash protocols and hashing key */
1205         rss_hash_update_t          rss_hash_update;
1206         /** Get current RSS hash configuration */
1207         rss_hash_conf_get_t        rss_hash_conf_get;
1208         /** Update redirection table */
1209         reta_update_t              reta_update;
1210         /** Query redirection table */
1211         reta_query_t               reta_query;
1212
1213         eth_get_reg_t              get_reg;           /**< Get registers */
1214         eth_get_eeprom_length_t    get_eeprom_length; /**< Get EEPROM length */
1215         eth_get_eeprom_t           get_eeprom;        /**< Get EEPROM data */
1216         eth_set_eeprom_t           set_eeprom;        /**< Set EEPROM */
1217
1218         /** Get plugin module EEPROM attribute */
1219         eth_get_module_info_t      get_module_info;
1220         /** Get plugin module EEPROM data */
1221         eth_get_module_eeprom_t    get_module_eeprom;
1222
1223         eth_flow_ops_get_t         flow_ops_get; /**< Get flow operations */
1224
1225         eth_get_dcb_info           get_dcb_info; /**< Get DCB information */
1226
1227         /** Turn IEEE1588/802.1AS timestamping on */
1228         eth_timesync_enable_t      timesync_enable;
1229         /** Turn IEEE1588/802.1AS timestamping off */
1230         eth_timesync_disable_t     timesync_disable;
1231         /** Read the IEEE1588/802.1AS Rx timestamp */
1232         eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp;
1233         /** Read the IEEE1588/802.1AS Tx timestamp */
1234         eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp;
1235         /** Adjust the device clock */
1236         eth_timesync_adjust_time   timesync_adjust_time;
1237         /** Get the device clock time */
1238         eth_timesync_read_time     timesync_read_time;
1239         /** Set the device clock time */
1240         eth_timesync_write_time    timesync_write_time;
1241
1242         eth_read_clock             read_clock;
1243
1244         /** Get extended device statistic values by ID */
1245         eth_xstats_get_by_id_t     xstats_get_by_id;
1246         /** Get name of extended device statistics by ID */
1247         eth_xstats_get_names_by_id_t xstats_get_names_by_id;
1248
1249         /** Get Traffic Management (TM) operations */
1250         eth_tm_ops_get_t tm_ops_get;
1251
1252         /** Get Traffic Metering and Policing (MTR) operations */
1253         eth_mtr_ops_get_t mtr_ops_get;
1254
1255         /** Test if a port supports specific mempool ops */
1256         eth_pool_ops_supported_t pool_ops_supported;
1257
1258         /** Returns the hairpin capabilities */
1259         eth_hairpin_cap_get_t hairpin_cap_get;
1260         /** Set up device Rx hairpin queue */
1261         eth_rx_hairpin_queue_setup_t rx_hairpin_queue_setup;
1262         /** Set up device Tx hairpin queue */
1263         eth_tx_hairpin_queue_setup_t tx_hairpin_queue_setup;
1264
1265         /** Get Forward Error Correction(FEC) capability */
1266         eth_fec_get_capability_t fec_get_capability;
1267         /** Get Forward Error Correction(FEC) mode */
1268         eth_fec_get_t fec_get;
1269         /** Set Forward Error Correction(FEC) mode */
1270         eth_fec_set_t fec_set;
1271
1272         /** Get hairpin peer ports list */
1273         hairpin_get_peer_ports_t hairpin_get_peer_ports;
1274         /** Bind all hairpin Tx queues of device to the peer port Rx queues */
1275         eth_hairpin_bind_t hairpin_bind;
1276         /** Unbind all hairpin Tx queues from the peer port Rx queues */
1277         eth_hairpin_unbind_t hairpin_unbind;
1278         /** Pass the current queue info and get the peer queue info */
1279         eth_hairpin_queue_peer_update_t hairpin_queue_peer_update;
1280         /** Set up the connection between the pair of hairpin queues */
1281         eth_hairpin_queue_peer_bind_t hairpin_queue_peer_bind;
1282         /** Disconnect the hairpin queues of a pair from each other */
1283         eth_hairpin_queue_peer_unbind_t hairpin_queue_peer_unbind;
1284
1285         /** Get power monitoring condition for Rx queue */
1286         eth_get_monitor_addr_t get_monitor_addr;
1287
1288         /** Get representor info */
1289         eth_representor_info_get_t representor_info_get;
1290
1291         /**
1292          * Negotiate the NIC's ability to deliver specific
1293          * kinds of metadata to the PMD
1294          */
1295         eth_rx_metadata_negotiate_t rx_metadata_negotiate;
1296
1297         /** Get IP reassembly capability */
1298         eth_ip_reassembly_capability_get_t ip_reassembly_capability_get;
1299         /** Get IP reassembly configuration */
1300         eth_ip_reassembly_conf_get_t ip_reassembly_conf_get;
1301         /** Set IP reassembly configuration */
1302         eth_ip_reassembly_conf_set_t ip_reassembly_conf_set;
1303
1304         /** Dump private info from device */
1305         eth_dev_priv_dump_t eth_dev_priv_dump;
1306
1307         /** Set Rx queue available descriptors threshold */
1308         eth_rx_queue_avail_thresh_set_t rx_queue_avail_thresh_set;
1309         /** Query Rx queue available descriptors threshold event */
1310         eth_rx_queue_avail_thresh_query_t rx_queue_avail_thresh_query;
1311 };
1312
1313 /**
1314  * @internal
1315  * Check if the selected Rx queue is hairpin queue.
1316  *
1317  * @param dev
1318  *  Pointer to the selected device.
1319  * @param queue_id
1320  *  The selected queue.
1321  *
1322  * @return
1323  *   - (1) if the queue is hairpin queue, 0 otherwise.
1324  */
1325 __rte_internal
1326 int rte_eth_dev_is_rx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id);
1327
1328 /**
1329  * @internal
1330  * Check if the selected Tx queue is hairpin queue.
1331  *
1332  * @param dev
1333  *  Pointer to the selected device.
1334  * @param queue_id
1335  *  The selected queue.
1336  *
1337  * @return
1338  *   - (1) if the queue is hairpin queue, 0 otherwise.
1339  */
1340 __rte_internal
1341 int rte_eth_dev_is_tx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id);
1342
1343 /**
1344  * @internal
1345  * Returns a ethdev slot specified by the unique identifier name.
1346  *
1347  * @param       name
1348  *  The pointer to the Unique identifier name for each Ethernet device
1349  * @return
1350  *   - The pointer to the ethdev slot, on success. NULL on error
1351  */
1352 __rte_internal
1353 struct rte_eth_dev *rte_eth_dev_allocated(const char *name);
1354
1355 /**
1356  * @internal
1357  * Allocates a new ethdev slot for an Ethernet device and returns the pointer
1358  * to that slot for the driver to use.
1359  *
1360  * @param       name    Unique identifier name for each Ethernet device
1361  * @return
1362  *   - Slot in the rte_dev_devices array for a new device;
1363  */
1364 __rte_internal
1365 struct rte_eth_dev *rte_eth_dev_allocate(const char *name);
1366
1367 /**
1368  * @internal
1369  * Attach to the ethdev already initialized by the primary
1370  * process.
1371  *
1372  * @param       name    Ethernet device's name.
1373  * @return
1374  *   - Success: Slot in the rte_dev_devices array for attached
1375  *        device.
1376  *   - Error: Null pointer.
1377  */
1378 __rte_internal
1379 struct rte_eth_dev *rte_eth_dev_attach_secondary(const char *name);
1380
1381 /**
1382  * @internal
1383  * Notify RTE_ETH_EVENT_DESTROY and release the specified ethdev port.
1384  *
1385  * The following PMD-managed data fields will be freed:
1386  *   - dev_private
1387  *   - mac_addrs
1388  *   - hash_mac_addrs
1389  * If one of these fields should not be freed,
1390  * it must be reset to NULL by the PMD, typically in dev_close method.
1391  *
1392  * @param eth_dev
1393  * Device to be detached.
1394  * @return
1395  *   - 0 on success, negative on error
1396  */
1397 __rte_internal
1398 int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev);
1399
1400 /**
1401  * @internal
1402  * Release device queues and clear its configuration to force the user
1403  * application to reconfigure it. It is for internal use only.
1404  *
1405  * @param dev
1406  *  Pointer to struct rte_eth_dev.
1407  *
1408  * @return
1409  *  void
1410  */
1411 __rte_internal
1412 void rte_eth_dev_internal_reset(struct rte_eth_dev *dev);
1413
1414 /**
1415  * @internal Executes all the user application registered callbacks for
1416  * the specific device. It is for DPDK internal user only. User
1417  * application should not call it directly.
1418  *
1419  * @param dev
1420  *  Pointer to struct rte_eth_dev.
1421  * @param event
1422  *  Eth device interrupt event type.
1423  * @param ret_param
1424  *  To pass data back to user application.
1425  *  This allows the user application to decide if a particular function
1426  *  is permitted or not.
1427  *
1428  * @return
1429  *  int
1430  */
1431 __rte_internal
1432 int rte_eth_dev_callback_process(struct rte_eth_dev *dev,
1433                 enum rte_eth_event_type event, void *ret_param);
1434
1435 /**
1436  * @internal
1437  * This is the last step of device probing.
1438  * It must be called after a port is allocated and initialized successfully.
1439  *
1440  * The notification RTE_ETH_EVENT_NEW is sent to other entities
1441  * (libraries and applications).
1442  * The state is set as RTE_ETH_DEV_ATTACHED.
1443  *
1444  * @param dev
1445  *  New ethdev port.
1446  */
1447 __rte_internal
1448 void rte_eth_dev_probing_finish(struct rte_eth_dev *dev);
1449
1450 /**
1451  * Create memzone for HW rings.
1452  * malloc can't be used as the physical address is needed.
1453  * If the memzone is already created, then this function returns a ptr
1454  * to the old one.
1455  *
1456  * @param eth_dev
1457  *   The *eth_dev* pointer is the address of the *rte_eth_dev* structure
1458  * @param name
1459  *   The name of the memory zone
1460  * @param queue_id
1461  *   The index of the queue to add to name
1462  * @param size
1463  *   The sizeof of the memory area
1464  * @param align
1465  *   Alignment for resulting memzone. Must be a power of 2.
1466  * @param socket_id
1467  *   The *socket_id* argument is the socket identifier in case of NUMA.
1468  */
1469 __rte_internal
1470 const struct rte_memzone *
1471 rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name,
1472                          uint16_t queue_id, size_t size,
1473                          unsigned align, int socket_id);
1474
1475 /**
1476  * Free previously allocated memzone for HW rings.
1477  *
1478  * @param eth_dev
1479  *   The *eth_dev* pointer is the address of the *rte_eth_dev* structure
1480  * @param name
1481  *   The name of the memory zone
1482  * @param queue_id
1483  *   The index of the queue to add to name
1484  * @return
1485  *   Negative errno value on error, 0 on success.
1486  */
1487 __rte_internal
1488 int
1489 rte_eth_dma_zone_free(const struct rte_eth_dev *eth_dev, const char *name,
1490                  uint16_t queue_id);
1491
1492 /**
1493  * @internal
1494  * Atomically set the link status for the specific device.
1495  * It is for use by DPDK device driver use only.
1496  * User applications should not call it
1497  *
1498  * @param dev
1499  *  Pointer to struct rte_eth_dev.
1500  * @param link
1501  *  New link status value.
1502  * @return
1503  *  Same convention as eth_link_update operation.
1504  *  0   if link up status has changed
1505  *  -1  if link up status was unchanged
1506  */
1507 static inline int
1508 rte_eth_linkstatus_set(struct rte_eth_dev *dev,
1509                        const struct rte_eth_link *new_link)
1510 {
1511         uint64_t *dev_link = (uint64_t *)&(dev->data->dev_link);
1512         union {
1513                 uint64_t val64;
1514                 struct rte_eth_link link;
1515         } orig;
1516
1517         RTE_BUILD_BUG_ON(sizeof(*new_link) != sizeof(uint64_t));
1518
1519         orig.val64 = __atomic_exchange_n(dev_link, *(const uint64_t *)new_link,
1520                                         __ATOMIC_SEQ_CST);
1521
1522         return (orig.link.link_status == new_link->link_status) ? -1 : 0;
1523 }
1524
1525 /**
1526  * @internal
1527  * Atomically get the link speed and status.
1528  *
1529  * @param dev
1530  *  Pointer to struct rte_eth_dev.
1531  * @param link
1532  *  link status value.
1533  */
1534 static inline void
1535 rte_eth_linkstatus_get(const struct rte_eth_dev *dev,
1536                        struct rte_eth_link *link)
1537 {
1538         uint64_t *src = (uint64_t *)&(dev->data->dev_link);
1539         uint64_t *dst = (uint64_t *)link;
1540
1541         RTE_BUILD_BUG_ON(sizeof(*link) != sizeof(uint64_t));
1542
1543         *dst = __atomic_load_n(src, __ATOMIC_SEQ_CST);
1544 }
1545
1546 /**
1547  * @internal
1548  * Dummy DPDK callback for Rx/Tx packet burst.
1549  *
1550  * @param queue
1551  *  Pointer to Rx/Tx queue
1552  * @param pkts
1553  *  Packet array
1554  * @param nb_pkts
1555  *  Number of packets in packet array
1556  */
1557 __rte_internal
1558 uint16_t
1559 rte_eth_pkt_burst_dummy(void *queue __rte_unused,
1560                 struct rte_mbuf **pkts __rte_unused,
1561                 uint16_t nb_pkts __rte_unused);
1562
1563 /**
1564  * Allocate an unique switch domain identifier.
1565  *
1566  * A pool of switch domain identifiers which can be allocated on request. This
1567  * will enabled devices which support the concept of switch domains to request
1568  * a switch domain ID which is guaranteed to be unique from other devices
1569  * running in the same process.
1570  *
1571  * @param domain_id
1572  *  switch domain identifier parameter to pass back to application
1573  *
1574  * @return
1575  *   Negative errno value on error, 0 on success.
1576  */
1577 __rte_internal
1578 int
1579 rte_eth_switch_domain_alloc(uint16_t *domain_id);
1580
1581 /**
1582  * Free switch domain.
1583  *
1584  * Return a switch domain identifier to the pool of free identifiers after it is
1585  * no longer in use by device.
1586  *
1587  * @param domain_id
1588  *  switch domain identifier to free
1589  *
1590  * @return
1591  *   Negative errno value on error, 0 on success.
1592  */
1593 __rte_internal
1594 int
1595 rte_eth_switch_domain_free(uint16_t domain_id);
1596
1597 /**
1598  * Generic Ethernet device arguments
1599  *
1600  * One type of representor each structure.
1601  */
1602 struct rte_eth_devargs {
1603         uint16_t mh_controllers[RTE_MAX_MULTI_HOST_CTRLS];
1604         /** controller/s number in case of multi-host */
1605         uint16_t nb_mh_controllers;
1606         /** number of controllers in multi-host controllers field */
1607         uint16_t ports[RTE_MAX_ETHPORTS];
1608         /** port/s number to enable on a multi-port single function */
1609         uint16_t nb_ports;
1610         /** number of ports in ports field */
1611         uint16_t representor_ports[RTE_MAX_ETHPORTS];
1612         /** representor port/s identifier to enable on device */
1613         uint16_t nb_representor_ports;
1614         /** number of ports in representor port field */
1615         enum rte_eth_representor_type type; /* type of representor */
1616 };
1617
1618 /**
1619  * PMD helper function to get representor ID from location detail.
1620  *
1621  * Get representor ID from controller, pf and (sf or vf).
1622  * The mapping is retrieved from rte_eth_representor_info_get().
1623  *
1624  * For backward compatibility, if no representor info, direct
1625  * map legacy VF (no controller and pf).
1626  *
1627  * @param port_id
1628  *  Port ID of the backing device.
1629  * @param type
1630  *  Representor type.
1631  * @param controller
1632  *  Controller ID, -1 if unspecified.
1633  * @param pf
1634  *  PF port ID, -1 if unspecified.
1635  * @param representor_port
1636  *  VF or SF representor port number, -1 if unspecified.
1637  * @param repr_id
1638  *  Pointer to output representor ID.
1639  *
1640  * @return
1641  *  Negative errno value on error, 0 on success.
1642  */
1643 __rte_internal
1644 int
1645 rte_eth_representor_id_get(uint16_t port_id,
1646                            enum rte_eth_representor_type type,
1647                            int controller, int pf, int representor_port,
1648                            uint16_t *repr_id);
1649
1650 /**
1651  * PMD helper function to parse ethdev arguments
1652  *
1653  * @param devargs
1654  *  device arguments
1655  * @param eth_devargs
1656  *  parsed ethdev specific arguments.
1657  *
1658  * @return
1659  *   Negative errno value on error, 0 on success.
1660  */
1661 __rte_internal
1662 int
1663 rte_eth_devargs_parse(const char *devargs, struct rte_eth_devargs *eth_devargs);
1664
1665
1666 typedef int (*ethdev_init_t)(struct rte_eth_dev *ethdev, void *init_params);
1667 typedef int (*ethdev_bus_specific_init)(struct rte_eth_dev *ethdev,
1668         void *bus_specific_init_params);
1669
1670 /**
1671  * PMD helper function for the creation of a new ethdev ports.
1672  *
1673  * @param device
1674  *  rte_device handle.
1675  * @param name
1676  *  port name.
1677  * @param priv_data_size
1678  *  size of private data required for port.
1679  * @param bus_specific_init
1680  *  port bus specific initialisation callback function
1681  * @param bus_init_params
1682  *  port bus specific initialisation parameters
1683  * @param ethdev_init
1684  *  device specific port initialization callback function
1685  * @param init_params
1686  *  port initialisation parameters
1687  *
1688  * @return
1689  *   Negative errno value on error, 0 on success.
1690  */
1691 __rte_internal
1692 int
1693 rte_eth_dev_create(struct rte_device *device, const char *name,
1694         size_t priv_data_size,
1695         ethdev_bus_specific_init bus_specific_init, void *bus_init_params,
1696         ethdev_init_t ethdev_init, void *init_params);
1697
1698
1699 typedef int (*ethdev_uninit_t)(struct rte_eth_dev *ethdev);
1700
1701 /**
1702  * PMD helper function for cleaning up the resources of a ethdev port on it's
1703  * destruction.
1704  *
1705  * @param ethdev
1706  *   ethdev handle of port.
1707  * @param ethdev_uninit
1708  *   device specific port un-initialise callback function
1709  *
1710  * @return
1711  *   Negative errno value on error, 0 on success.
1712  */
1713 __rte_internal
1714 int
1715 rte_eth_dev_destroy(struct rte_eth_dev *ethdev, ethdev_uninit_t ethdev_uninit);
1716
1717 /**
1718  * @internal
1719  * Pass the current hairpin queue HW and/or SW information to the peer queue
1720  * and fetch back the information of the peer queue.
1721  *
1722  * @param peer_port
1723  *  Peer port identifier of the Ethernet device.
1724  * @param peer_queue
1725  *  Peer queue index of the port.
1726  * @param cur_info
1727  *  Pointer to the current information structure.
1728  * @param peer_info
1729  *  Pointer to the peer information, output.
1730  * @param direction
1731  *  Direction to pass the information.
1732  *  positive - pass Tx queue information and get peer Rx queue information
1733  *  zero - pass Rx queue information and get peer Tx queue information
1734  *
1735  * @return
1736  *  Negative errno value on error, 0 on success.
1737  */
1738 __rte_internal
1739 int
1740 rte_eth_hairpin_queue_peer_update(uint16_t peer_port, uint16_t peer_queue,
1741                                   struct rte_hairpin_peer_info *cur_info,
1742                                   struct rte_hairpin_peer_info *peer_info,
1743                                   uint32_t direction);
1744
1745 /**
1746  * @internal
1747  * Configure current hairpin queue with the peer information fetched to create
1748  * the connection (bind) with peer queue in the specified direction.
1749  * This function might need to be called twice to fully create the connections.
1750  *
1751  * @param cur_port
1752  *  Current port identifier of the Ethernet device.
1753  * @param cur_queue
1754  *  Current queue index of the port.
1755  * @param peer_info
1756  *  Pointer to the peer information, input.
1757  * @param direction
1758  *  Direction to create the connection.
1759  *  positive - bind current Tx queue to peer Rx queue
1760  *  zero - bind current Rx queue to peer Tx queue
1761  *
1762  * @return
1763  *  Negative errno value on error, 0 on success.
1764  */
1765 __rte_internal
1766 int
1767 rte_eth_hairpin_queue_peer_bind(uint16_t cur_port, uint16_t cur_queue,
1768                                 struct rte_hairpin_peer_info *peer_info,
1769                                 uint32_t direction);
1770
1771 /**
1772  * @internal
1773  * Get rte_eth_dev from device name. The device name should be specified
1774  * as below:
1775  * - PCIe address (Domain:Bus:Device.Function), for example 0000:2:00.0
1776  * - SoC device name, for example fsl-gmac0
1777  * - vdev dpdk name, for example net_[pcap0|null0|tap0]
1778  *
1779  * @param name
1780  *   PCI address or name of the device
1781  * @return
1782  *   - rte_eth_dev if successful
1783  *   - NULL on failure
1784  */
1785 __rte_internal
1786 struct rte_eth_dev*
1787 rte_eth_dev_get_by_name(const char *name);
1788
1789 /**
1790  * @internal
1791  * Reset the current queue state and configuration to disconnect (unbind) it
1792  * from the peer queue.
1793  * This function might need to be called twice to disconnect each other.
1794  *
1795  * @param cur_port
1796  *  Current port identifier of the Ethernet device.
1797  * @param cur_queue
1798  *  Current queue index of the port.
1799  * @param direction
1800  *  Direction to destroy the connection.
1801  *  positive - unbind current Tx queue from peer Rx queue
1802  *  zero - unbind current Rx queue from peer Tx queue
1803  *
1804  * @return
1805  *  Negative errno value on error, 0 on success.
1806  */
1807 __rte_internal
1808 int
1809 rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t cur_queue,
1810                                   uint32_t direction);
1811
1812 /**
1813  * @internal
1814  * Register mbuf dynamic field and flag for IP reassembly incomplete case.
1815  */
1816 __rte_internal
1817 int
1818 rte_eth_ip_reassembly_dynfield_register(int *field_offset, int *flag);
1819
1820
1821 /*
1822  * Legacy ethdev API used internally by drivers.
1823  */
1824
1825 enum rte_filter_type {
1826         RTE_ETH_FILTER_NONE = 0,
1827         RTE_ETH_FILTER_ETHERTYPE,
1828         RTE_ETH_FILTER_FLEXIBLE,
1829         RTE_ETH_FILTER_SYN,
1830         RTE_ETH_FILTER_NTUPLE,
1831         RTE_ETH_FILTER_TUNNEL,
1832         RTE_ETH_FILTER_FDIR,
1833         RTE_ETH_FILTER_HASH,
1834         RTE_ETH_FILTER_L2_TUNNEL,
1835 };
1836
1837 /**
1838  * Define all structures for Ethertype Filter type.
1839  */
1840
1841 #define RTE_ETHTYPE_FLAGS_MAC    0x0001 /**< If set, compare mac */
1842 #define RTE_ETHTYPE_FLAGS_DROP   0x0002 /**< If set, drop packet when match */
1843
1844 /**
1845  * A structure used to define the ethertype filter entry
1846  * to support RTE_ETH_FILTER_ETHERTYPE data representation.
1847  */
1848 struct rte_eth_ethertype_filter {
1849         struct rte_ether_addr mac_addr;   /**< Mac address to match */
1850         uint16_t ether_type;          /**< Ether type to match */
1851         uint16_t flags;               /**< Flags from RTE_ETHTYPE_FLAGS_* */
1852         uint16_t queue;               /**< Queue assigned to when match */
1853 };
1854
1855 /**
1856  * A structure used to define the TCP syn filter entry
1857  * to support RTE_ETH_FILTER_SYN data representation.
1858  */
1859 struct rte_eth_syn_filter {
1860         /** 1 - higher priority than other filters, 0 - lower priority */
1861         uint8_t hig_pri;
1862         uint16_t queue;      /**< Queue assigned to when match */
1863 };
1864
1865 /**
1866  * filter type of tunneling packet
1867  */
1868 #define RTE_ETH_TUNNEL_FILTER_OMAC  0x01 /**< filter by outer MAC addr */
1869 #define RTE_ETH_TUNNEL_FILTER_OIP   0x02 /**< filter by outer IP Addr */
1870 #define RTE_ETH_TUNNEL_FILTER_TENID 0x04 /**< filter by tenant ID */
1871 #define RTE_ETH_TUNNEL_FILTER_IMAC  0x08 /**< filter by inner MAC addr */
1872 #define RTE_ETH_TUNNEL_FILTER_IVLAN 0x10 /**< filter by inner VLAN ID */
1873 #define RTE_ETH_TUNNEL_FILTER_IIP   0x20 /**< filter by inner IP addr */
1874
1875 #define RTE_ETH_TUNNEL_FILTER_IMAC_IVLAN (RTE_ETH_TUNNEL_FILTER_IMAC | \
1876                                           RTE_ETH_TUNNEL_FILTER_IVLAN)
1877 #define RTE_ETH_TUNNEL_FILTER_IMAC_IVLAN_TENID (RTE_ETH_TUNNEL_FILTER_IMAC | \
1878                                                 RTE_ETH_TUNNEL_FILTER_IVLAN | \
1879                                                 RTE_ETH_TUNNEL_FILTER_TENID)
1880 #define RTE_ETH_TUNNEL_FILTER_IMAC_TENID (RTE_ETH_TUNNEL_FILTER_IMAC | \
1881                                           RTE_ETH_TUNNEL_FILTER_TENID)
1882 #define RTE_ETH_TUNNEL_FILTER_OMAC_TENID_IMAC (RTE_ETH_TUNNEL_FILTER_OMAC | \
1883                                                RTE_ETH_TUNNEL_FILTER_TENID | \
1884                                                RTE_ETH_TUNNEL_FILTER_IMAC)
1885
1886 /**
1887  *  Select IPv4 or IPv6 for tunnel filters.
1888  */
1889 enum rte_tunnel_iptype {
1890         RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4 */
1891         RTE_TUNNEL_IPTYPE_IPV6,     /**< IPv6 */
1892 };
1893
1894 /**
1895  * Tunneling Packet filter configuration.
1896  */
1897 struct rte_eth_tunnel_filter_conf {
1898         struct rte_ether_addr outer_mac;    /**< Outer MAC address to match */
1899         struct rte_ether_addr inner_mac;    /**< Inner MAC address to match */
1900         uint16_t inner_vlan;                /**< Inner VLAN to match */
1901         enum rte_tunnel_iptype ip_type;     /**< IP address type */
1902         /**
1903          * Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP
1904          * is set in filter_type, or inner destination IP address to match
1905          * if ETH_TUNNEL_FILTER_IIP is set in filter_type.
1906          */
1907         union {
1908                 uint32_t ipv4_addr;         /**< IPv4 address in big endian */
1909                 uint32_t ipv6_addr[4];      /**< IPv6 address in big endian */
1910         } ip_addr;
1911         /** Flags from ETH_TUNNEL_FILTER_XX - see above */
1912         uint16_t filter_type;
1913         enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type */
1914         uint32_t tenant_id;     /**< Tenant ID to match: VNI, GRE key... */
1915         uint16_t queue_id;      /**< Queue assigned to if match */
1916 };
1917
1918 #ifdef __cplusplus
1919 }
1920 #endif
1921
1922 #endif /* _RTE_ETHDEV_DRIVER_H_ */