mempool: introduce helpers for populate and required size
[dpdk.git] / lib / librte_ethdev / rte_ethdev_core.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Intel Corporation
3  */
4
5 #ifndef _RTE_ETHDEV_CORE_H_
6 #define _RTE_ETHDEV_CORE_H_
7
8 /**
9  * @file
10  *
11  * RTE Ethernet Device internal header.
12  *
13  * This header contains internal data types. But they are still part of the
14  * public API because they are used by inline functions in the published API.
15  *
16  * Applications should not use these directly.
17  *
18  */
19
20 struct rte_eth_dev_callback;
21 /** @internal Structure to keep track of registered callbacks */
22 TAILQ_HEAD(rte_eth_dev_cb_list, rte_eth_dev_callback);
23
24 /*
25  * Definitions of all functions exported by an Ethernet driver through the
26  * the generic structure of type *eth_dev_ops* supplied in the *rte_eth_dev*
27  * structure associated with an Ethernet device.
28  */
29 struct rte_eth_dev;
30
31 typedef int  (*eth_dev_configure_t)(struct rte_eth_dev *dev);
32 /**< @internal Ethernet device configuration. */
33
34 typedef int  (*eth_dev_start_t)(struct rte_eth_dev *dev);
35 /**< @internal Function used to start a configured Ethernet device. */
36
37 typedef void (*eth_dev_stop_t)(struct rte_eth_dev *dev);
38 /**< @internal Function used to stop a configured Ethernet device. */
39
40 typedef int  (*eth_dev_set_link_up_t)(struct rte_eth_dev *dev);
41 /**< @internal Function used to link up a configured Ethernet device. */
42
43 typedef int  (*eth_dev_set_link_down_t)(struct rte_eth_dev *dev);
44 /**< @internal Function used to link down a configured Ethernet device. */
45
46 typedef void (*eth_dev_close_t)(struct rte_eth_dev *dev);
47 /**< @internal Function used to close a configured Ethernet device. */
48
49 typedef int (*eth_dev_reset_t)(struct rte_eth_dev *dev);
50 /** <@internal Function used to reset a configured Ethernet device. */
51
52 typedef int (*eth_is_removed_t)(struct rte_eth_dev *dev);
53 /**< @internal Function used to detect an Ethernet device removal. */
54
55 /**
56  * @internal
57  * Function used to enable the Rx promiscuous mode of an Ethernet device.
58  *
59  * @param dev
60  *   ethdev handle of port.
61  *
62  * @return
63  *   Negative errno value on error, 0 on success.
64  *
65  * @retval 0
66  *   Success, promiscuous mode is enabled.
67  * @retval -ENOTSUP
68  *   Promiscuous mode is not supported.
69  * @retval -ENODEV
70  *   Device is gone.
71  * @retval -E_RTE_SECONDARY
72  *   Function was called from a secondary process instance and not supported.
73  * @retval -ETIMEDOUT
74  *   Attempt to enable promiscuos mode failed because of timeout.
75  * @retval -EAGAIN
76  *   Failed to enable promiscuous mode.
77  */
78 typedef int (*eth_promiscuous_enable_t)(struct rte_eth_dev *dev);
79
80 /**
81  * @internal
82  * Function used to disable the Rx promiscuous mode of an Ethernet device.
83  *
84  * @param dev
85  *   ethdev handle of port.
86  *
87  * @return
88  *   Negative errno value on error, 0 on success.
89  *
90  * @retval 0
91  *   Success, promiscuous mode is disabled.
92  * @retval -ENOTSUP
93  *   Promiscuous mode disabling is not supported.
94  * @retval -ENODEV
95  *   Device is gone.
96  * @retval -E_RTE_SECONDARY
97  *   Function was called from a secondary process instance and not supported.
98  * @retval -ETIMEDOUT
99  *   Attempt to disable promiscuos mode failed because of timeout.
100  * @retval -EAGAIN
101  *   Failed to disable promiscuous mode.
102  */
103 typedef int (*eth_promiscuous_disable_t)(struct rte_eth_dev *dev);
104
105 /**
106  * @internal
107  * Enable the receipt of all multicast packets by an Ethernet device.
108  *
109  * @param dev
110  *   ethdev handle of port.
111  *
112  * @return
113  *   Negative errno value on error, 0 on success.
114  *
115  * @retval 0
116  *   Success, all-multicast mode is enabled.
117  * @retval -ENOTSUP
118  *   All-multicast mode is not supported.
119  * @retval -ENODEV
120  *   Device is gone.
121  * @retval -E_RTE_SECONDARY
122  *   Function was called from a secondary process instance and not supported.
123  * @retval -ETIMEDOUT
124  *   Attempt to enable all-multicast mode failed because of timeout.
125  * @retval -EAGAIN
126  *   Failed to enable all-multicast mode.
127  */
128 typedef int (*eth_allmulticast_enable_t)(struct rte_eth_dev *dev);
129
130 /**
131  * @internal
132  * Disable the receipt of all multicast packets by an Ethernet device.
133  *
134  * @param dev
135  *   ethdev handle of port.
136  *
137  * @return
138  *   Negative errno value on error, 0 on success.
139  *
140  * @retval 0
141  *   Success, all-multicast mode is disabled.
142  * @retval -ENOTSUP
143  *   All-multicast mode disabling is not supported.
144  * @retval -ENODEV
145  *   Device is gone.
146  * @retval -E_RTE_SECONDARY
147  *   Function was called from a secondary process instance and not supported.
148  * @retval -ETIMEDOUT
149  *   Attempt to disable all-multicast mode failed because of timeout.
150  * @retval -EAGAIN
151  *   Failed to disable all-multicast mode.
152  */
153 typedef int (*eth_allmulticast_disable_t)(struct rte_eth_dev *dev);
154
155 typedef int (*eth_link_update_t)(struct rte_eth_dev *dev,
156                                 int wait_to_complete);
157 /**< @internal Get link speed, duplex mode and state (up/down) of an Ethernet device. */
158
159 typedef int (*eth_stats_get_t)(struct rte_eth_dev *dev,
160                                 struct rte_eth_stats *igb_stats);
161 /**< @internal Get global I/O statistics of an Ethernet device. */
162
163 /**
164  * @internal
165  * Reset global I/O statistics of an Ethernet device to 0.
166  *
167  * @param dev
168  *   ethdev handle of port.
169  *
170  * @return
171  *   Negative errno value on error, 0 on success.
172  *
173  * @retval 0
174  *   Success, statistics has been reset.
175  * @retval -ENOTSUP
176  *   Resetting statistics is not supported.
177  * @retval -EINVAL
178  *   Resetting statistics is not valid.
179  * @retval -ENOMEM
180  *   Not enough memory to get the stats.
181  */
182 typedef int (*eth_stats_reset_t)(struct rte_eth_dev *dev);
183
184 typedef int (*eth_xstats_get_t)(struct rte_eth_dev *dev,
185         struct rte_eth_xstat *stats, unsigned n);
186 /**< @internal Get extended stats of an Ethernet device. */
187
188 typedef int (*eth_xstats_get_by_id_t)(struct rte_eth_dev *dev,
189                                       const uint64_t *ids,
190                                       uint64_t *values,
191                                       unsigned int n);
192 /**< @internal Get extended stats of an Ethernet device. */
193
194 /**
195  * @internal
196  * Reset extended stats of an Ethernet device.
197  *
198  * @param dev
199  *   ethdev handle of port.
200  *
201  * @return
202  *   Negative errno value on error, 0 on success.
203  *
204  * @retval 0
205  *   Success, statistics has been reset.
206  * @retval -ENOTSUP
207  *   Resetting statistics is not supported.
208  * @retval -EINVAL
209  *   Resetting statistics is not valid.
210  * @retval -ENOMEM
211  *   Not enough memory to get the stats.
212  */
213 typedef int (*eth_xstats_reset_t)(struct rte_eth_dev *dev);
214
215 typedef int (*eth_xstats_get_names_t)(struct rte_eth_dev *dev,
216         struct rte_eth_xstat_name *xstats_names, unsigned size);
217 /**< @internal Get names of extended stats of an Ethernet device. */
218
219 typedef int (*eth_xstats_get_names_by_id_t)(struct rte_eth_dev *dev,
220         struct rte_eth_xstat_name *xstats_names, const uint64_t *ids,
221         unsigned int size);
222 /**< @internal Get names of extended stats of an Ethernet device. */
223
224 typedef int (*eth_queue_stats_mapping_set_t)(struct rte_eth_dev *dev,
225                                              uint16_t queue_id,
226                                              uint8_t stat_idx,
227                                              uint8_t is_rx);
228 /**< @internal Set a queue statistics mapping for a tx/rx queue of an Ethernet device. */
229
230 typedef int (*eth_dev_infos_get_t)(struct rte_eth_dev *dev,
231                                    struct rte_eth_dev_info *dev_info);
232 /**< @internal Get specific information of an Ethernet device. */
233
234 typedef const uint32_t *(*eth_dev_supported_ptypes_get_t)(struct rte_eth_dev *dev);
235 /**< @internal Get supported ptypes of an Ethernet device. */
236
237 typedef int (*eth_queue_start_t)(struct rte_eth_dev *dev,
238                                     uint16_t queue_id);
239 /**< @internal Start rx and tx of a queue of an Ethernet device. */
240
241 typedef int (*eth_queue_stop_t)(struct rte_eth_dev *dev,
242                                     uint16_t queue_id);
243 /**< @internal Stop rx and tx of a queue of an Ethernet device. */
244
245 typedef int (*eth_rx_queue_setup_t)(struct rte_eth_dev *dev,
246                                     uint16_t rx_queue_id,
247                                     uint16_t nb_rx_desc,
248                                     unsigned int socket_id,
249                                     const struct rte_eth_rxconf *rx_conf,
250                                     struct rte_mempool *mb_pool);
251 /**< @internal Set up a receive queue of an Ethernet device. */
252
253 typedef int (*eth_tx_queue_setup_t)(struct rte_eth_dev *dev,
254                                     uint16_t tx_queue_id,
255                                     uint16_t nb_tx_desc,
256                                     unsigned int socket_id,
257                                     const struct rte_eth_txconf *tx_conf);
258 /**< @internal Setup a transmit queue of an Ethernet device. */
259
260 typedef int (*eth_rx_enable_intr_t)(struct rte_eth_dev *dev,
261                                     uint16_t rx_queue_id);
262 /**< @internal Enable interrupt of a receive queue of an Ethernet device. */
263
264 typedef int (*eth_rx_disable_intr_t)(struct rte_eth_dev *dev,
265                                     uint16_t rx_queue_id);
266 /**< @internal Disable interrupt of a receive queue of an Ethernet device. */
267
268 typedef void (*eth_queue_release_t)(void *queue);
269 /**< @internal Release memory resources allocated by given RX/TX queue. */
270
271 typedef uint32_t (*eth_rx_queue_count_t)(struct rte_eth_dev *dev,
272                                          uint16_t rx_queue_id);
273 /**< @internal Get number of used descriptors on a receive queue. */
274
275 typedef int (*eth_rx_descriptor_done_t)(void *rxq, uint16_t offset);
276 /**< @internal Check DD bit of specific RX descriptor */
277
278 typedef int (*eth_rx_descriptor_status_t)(void *rxq, uint16_t offset);
279 /**< @internal Check the status of a Rx descriptor */
280
281 typedef int (*eth_tx_descriptor_status_t)(void *txq, uint16_t offset);
282 /**< @internal Check the status of a Tx descriptor */
283
284 typedef int (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
285                                      char *fw_version, size_t fw_size);
286 /**< @internal Get firmware information of an Ethernet device. */
287
288 typedef int (*eth_tx_done_cleanup_t)(void *txq, uint32_t free_cnt);
289 /**< @internal Force mbufs to be from TX ring. */
290
291 typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
292         uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
293
294 typedef void (*eth_txq_info_get_t)(struct rte_eth_dev *dev,
295         uint16_t tx_queue_id, struct rte_eth_txq_info *qinfo);
296
297 typedef int (*eth_burst_mode_get_t)(struct rte_eth_dev *dev,
298         uint16_t queue_id, struct rte_eth_burst_mode *mode);
299
300 typedef int (*mtu_set_t)(struct rte_eth_dev *dev, uint16_t mtu);
301 /**< @internal Set MTU. */
302
303 typedef int (*vlan_filter_set_t)(struct rte_eth_dev *dev,
304                                   uint16_t vlan_id,
305                                   int on);
306 /**< @internal filtering of a VLAN Tag Identifier by an Ethernet device. */
307
308 typedef int (*vlan_tpid_set_t)(struct rte_eth_dev *dev,
309                                enum rte_vlan_type type, uint16_t tpid);
310 /**< @internal set the outer/inner VLAN-TPID by an Ethernet device. */
311
312 typedef int (*vlan_offload_set_t)(struct rte_eth_dev *dev, int mask);
313 /**< @internal set VLAN offload function by an Ethernet device. */
314
315 typedef int (*vlan_pvid_set_t)(struct rte_eth_dev *dev,
316                                uint16_t vlan_id,
317                                int on);
318 /**< @internal set port based TX VLAN insertion by an Ethernet device. */
319
320 typedef void (*vlan_strip_queue_set_t)(struct rte_eth_dev *dev,
321                                   uint16_t rx_queue_id,
322                                   int on);
323 /**< @internal VLAN stripping enable/disable by an queue of Ethernet device. */
324
325 typedef uint16_t (*eth_rx_burst_t)(void *rxq,
326                                    struct rte_mbuf **rx_pkts,
327                                    uint16_t nb_pkts);
328 /**< @internal Retrieve input packets from a receive queue of an Ethernet device. */
329
330 typedef uint16_t (*eth_tx_burst_t)(void *txq,
331                                    struct rte_mbuf **tx_pkts,
332                                    uint16_t nb_pkts);
333 /**< @internal Send output packets on a transmit queue of an Ethernet device. */
334
335 typedef uint16_t (*eth_tx_prep_t)(void *txq,
336                                    struct rte_mbuf **tx_pkts,
337                                    uint16_t nb_pkts);
338 /**< @internal Prepare output packets on a transmit queue of an Ethernet device. */
339
340 typedef int (*flow_ctrl_get_t)(struct rte_eth_dev *dev,
341                                struct rte_eth_fc_conf *fc_conf);
342 /**< @internal Get current flow control parameter on an Ethernet device */
343
344 typedef int (*flow_ctrl_set_t)(struct rte_eth_dev *dev,
345                                struct rte_eth_fc_conf *fc_conf);
346 /**< @internal Setup flow control parameter on an Ethernet device */
347
348 typedef int (*priority_flow_ctrl_set_t)(struct rte_eth_dev *dev,
349                                 struct rte_eth_pfc_conf *pfc_conf);
350 /**< @internal Setup priority flow control parameter on an Ethernet device */
351
352 typedef int (*reta_update_t)(struct rte_eth_dev *dev,
353                              struct rte_eth_rss_reta_entry64 *reta_conf,
354                              uint16_t reta_size);
355 /**< @internal Update RSS redirection table on an Ethernet device */
356
357 typedef int (*reta_query_t)(struct rte_eth_dev *dev,
358                             struct rte_eth_rss_reta_entry64 *reta_conf,
359                             uint16_t reta_size);
360 /**< @internal Query RSS redirection table on an Ethernet device */
361
362 typedef int (*rss_hash_update_t)(struct rte_eth_dev *dev,
363                                  struct rte_eth_rss_conf *rss_conf);
364 /**< @internal Update RSS hash configuration of an Ethernet device */
365
366 typedef int (*rss_hash_conf_get_t)(struct rte_eth_dev *dev,
367                                    struct rte_eth_rss_conf *rss_conf);
368 /**< @internal Get current RSS hash configuration of an Ethernet device */
369
370 typedef int (*eth_dev_led_on_t)(struct rte_eth_dev *dev);
371 /**< @internal Turn on SW controllable LED on an Ethernet device */
372
373 typedef int (*eth_dev_led_off_t)(struct rte_eth_dev *dev);
374 /**< @internal Turn off SW controllable LED on an Ethernet device */
375
376 typedef void (*eth_mac_addr_remove_t)(struct rte_eth_dev *dev, uint32_t index);
377 /**< @internal Remove MAC address from receive address register */
378
379 typedef int (*eth_mac_addr_add_t)(struct rte_eth_dev *dev,
380                                   struct rte_ether_addr *mac_addr,
381                                   uint32_t index,
382                                   uint32_t vmdq);
383 /**< @internal Set a MAC address into Receive Address Address Register */
384
385 typedef int (*eth_mac_addr_set_t)(struct rte_eth_dev *dev,
386                                   struct rte_ether_addr *mac_addr);
387 /**< @internal Set a MAC address into Receive Address Address Register */
388
389 typedef int (*eth_uc_hash_table_set_t)(struct rte_eth_dev *dev,
390                                   struct rte_ether_addr *mac_addr,
391                                   uint8_t on);
392 /**< @internal Set a Unicast Hash bitmap */
393
394 typedef int (*eth_uc_all_hash_table_set_t)(struct rte_eth_dev *dev,
395                                   uint8_t on);
396 /**< @internal Set all Unicast Hash bitmap */
397
398 typedef int (*eth_set_queue_rate_limit_t)(struct rte_eth_dev *dev,
399                                 uint16_t queue_idx,
400                                 uint16_t tx_rate);
401 /**< @internal Set queue TX rate */
402
403 typedef int (*eth_mirror_rule_set_t)(struct rte_eth_dev *dev,
404                                   struct rte_eth_mirror_conf *mirror_conf,
405                                   uint8_t rule_id,
406                                   uint8_t on);
407 /**< @internal Add a traffic mirroring rule on an Ethernet device */
408
409 typedef int (*eth_mirror_rule_reset_t)(struct rte_eth_dev *dev,
410                                   uint8_t rule_id);
411 /**< @internal Remove a traffic mirroring rule on an Ethernet device */
412
413 typedef int (*eth_udp_tunnel_port_add_t)(struct rte_eth_dev *dev,
414                                          struct rte_eth_udp_tunnel *tunnel_udp);
415 /**< @internal Add tunneling UDP port */
416
417 typedef int (*eth_udp_tunnel_port_del_t)(struct rte_eth_dev *dev,
418                                          struct rte_eth_udp_tunnel *tunnel_udp);
419 /**< @internal Delete tunneling UDP port */
420
421 typedef int (*eth_set_mc_addr_list_t)(struct rte_eth_dev *dev,
422                                       struct rte_ether_addr *mc_addr_set,
423                                       uint32_t nb_mc_addr);
424 /**< @internal set the list of multicast addresses on an Ethernet device */
425
426 typedef int (*eth_timesync_enable_t)(struct rte_eth_dev *dev);
427 /**< @internal Function used to enable IEEE1588/802.1AS timestamping. */
428
429 typedef int (*eth_timesync_disable_t)(struct rte_eth_dev *dev);
430 /**< @internal Function used to disable IEEE1588/802.1AS timestamping. */
431
432 typedef int (*eth_timesync_read_rx_timestamp_t)(struct rte_eth_dev *dev,
433                                                 struct timespec *timestamp,
434                                                 uint32_t flags);
435 /**< @internal Function used to read an RX IEEE1588/802.1AS timestamp. */
436
437 typedef int (*eth_timesync_read_tx_timestamp_t)(struct rte_eth_dev *dev,
438                                                 struct timespec *timestamp);
439 /**< @internal Function used to read a TX IEEE1588/802.1AS timestamp. */
440
441 typedef int (*eth_timesync_adjust_time)(struct rte_eth_dev *dev, int64_t);
442 /**< @internal Function used to adjust the device clock */
443
444 typedef int (*eth_timesync_read_time)(struct rte_eth_dev *dev,
445                                       struct timespec *timestamp);
446 /**< @internal Function used to get time from the device clock. */
447
448 typedef int (*eth_timesync_write_time)(struct rte_eth_dev *dev,
449                                        const struct timespec *timestamp);
450 /**< @internal Function used to get time from the device clock */
451
452 typedef int (*eth_read_clock)(struct rte_eth_dev *dev,
453                                       uint64_t *timestamp);
454 /**< @internal Function used to get the current value of the device clock. */
455
456 typedef int (*eth_get_reg_t)(struct rte_eth_dev *dev,
457                                 struct rte_dev_reg_info *info);
458 /**< @internal Retrieve registers  */
459
460 typedef int (*eth_get_eeprom_length_t)(struct rte_eth_dev *dev);
461 /**< @internal Retrieve eeprom size  */
462
463 typedef int (*eth_get_eeprom_t)(struct rte_eth_dev *dev,
464                                 struct rte_dev_eeprom_info *info);
465 /**< @internal Retrieve eeprom data  */
466
467 typedef int (*eth_set_eeprom_t)(struct rte_eth_dev *dev,
468                                 struct rte_dev_eeprom_info *info);
469 /**< @internal Program eeprom data  */
470
471 typedef int (*eth_get_module_info_t)(struct rte_eth_dev *dev,
472                                      struct rte_eth_dev_module_info *modinfo);
473 /**< @internal Retrieve type and size of plugin module eeprom */
474
475 typedef int (*eth_get_module_eeprom_t)(struct rte_eth_dev *dev,
476                                        struct rte_dev_eeprom_info *info);
477 /**< @internal Retrieve plugin module eeprom data */
478
479 typedef int (*eth_l2_tunnel_eth_type_conf_t)
480         (struct rte_eth_dev *dev, struct rte_eth_l2_tunnel_conf *l2_tunnel);
481 /**< @internal config l2 tunnel ether type */
482
483 typedef int (*eth_l2_tunnel_offload_set_t)
484         (struct rte_eth_dev *dev,
485          struct rte_eth_l2_tunnel_conf *l2_tunnel,
486          uint32_t mask,
487          uint8_t en);
488 /**< @internal enable/disable the l2 tunnel offload functions */
489
490
491 typedef int (*eth_filter_ctrl_t)(struct rte_eth_dev *dev,
492                                  enum rte_filter_type filter_type,
493                                  enum rte_filter_op filter_op,
494                                  void *arg);
495 /**< @internal Take operations to assigned filter type on an Ethernet device */
496
497 typedef int (*eth_tm_ops_get_t)(struct rte_eth_dev *dev, void *ops);
498 /**< @internal Get Traffic Management (TM) operations on an Ethernet device */
499
500 typedef int (*eth_mtr_ops_get_t)(struct rte_eth_dev *dev, void *ops);
501 /**< @internal Get Traffic Metering and Policing (MTR) operations */
502
503 typedef int (*eth_get_dcb_info)(struct rte_eth_dev *dev,
504                                  struct rte_eth_dcb_info *dcb_info);
505 /**< @internal Get dcb information on an Ethernet device */
506
507 typedef int (*eth_pool_ops_supported_t)(struct rte_eth_dev *dev,
508                                                 const char *pool);
509 /**< @internal Test if a port supports specific mempool ops */
510
511 /**
512  * @internal A structure containing the functions exported by an Ethernet driver.
513  */
514 struct eth_dev_ops {
515         eth_dev_configure_t        dev_configure; /**< Configure device. */
516         eth_dev_start_t            dev_start;     /**< Start device. */
517         eth_dev_stop_t             dev_stop;      /**< Stop device. */
518         eth_dev_set_link_up_t      dev_set_link_up;   /**< Device link up. */
519         eth_dev_set_link_down_t    dev_set_link_down; /**< Device link down. */
520         eth_dev_close_t            dev_close;     /**< Close device. */
521         eth_dev_reset_t            dev_reset;     /**< Reset device. */
522         eth_link_update_t          link_update;   /**< Get device link state. */
523         eth_is_removed_t           is_removed;
524         /**< Check if the device was physically removed. */
525
526         eth_promiscuous_enable_t   promiscuous_enable; /**< Promiscuous ON. */
527         eth_promiscuous_disable_t  promiscuous_disable;/**< Promiscuous OFF. */
528         eth_allmulticast_enable_t  allmulticast_enable;/**< RX multicast ON. */
529         eth_allmulticast_disable_t allmulticast_disable;/**< RX multicast OFF. */
530         eth_mac_addr_remove_t      mac_addr_remove; /**< Remove MAC address. */
531         eth_mac_addr_add_t         mac_addr_add;  /**< Add a MAC address. */
532         eth_mac_addr_set_t         mac_addr_set;  /**< Set a MAC address. */
533         eth_set_mc_addr_list_t     set_mc_addr_list; /**< set list of mcast addrs. */
534         mtu_set_t                  mtu_set;       /**< Set MTU. */
535
536         eth_stats_get_t            stats_get;     /**< Get generic device statistics. */
537         eth_stats_reset_t          stats_reset;   /**< Reset generic device statistics. */
538         eth_xstats_get_t           xstats_get;    /**< Get extended device statistics. */
539         eth_xstats_reset_t         xstats_reset;  /**< Reset extended device statistics. */
540         eth_xstats_get_names_t     xstats_get_names;
541         /**< Get names of extended statistics. */
542         eth_queue_stats_mapping_set_t queue_stats_mapping_set;
543         /**< Configure per queue stat counter mapping. */
544
545         eth_dev_infos_get_t        dev_infos_get; /**< Get device info. */
546         eth_rxq_info_get_t         rxq_info_get; /**< retrieve RX queue information. */
547         eth_txq_info_get_t         txq_info_get; /**< retrieve TX queue information. */
548         eth_burst_mode_get_t       rx_burst_mode_get; /**< Get RX burst mode */
549         eth_burst_mode_get_t       tx_burst_mode_get; /**< Get TX burst mode */
550         eth_fw_version_get_t       fw_version_get; /**< Get firmware version. */
551         eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
552         /**< Get packet types supported and identified by device. */
553
554         vlan_filter_set_t          vlan_filter_set; /**< Filter VLAN Setup. */
555         vlan_tpid_set_t            vlan_tpid_set; /**< Outer/Inner VLAN TPID Setup. */
556         vlan_strip_queue_set_t     vlan_strip_queue_set; /**< VLAN Stripping on queue. */
557         vlan_offload_set_t         vlan_offload_set; /**< Set VLAN Offload. */
558         vlan_pvid_set_t            vlan_pvid_set; /**< Set port based TX VLAN insertion. */
559
560         eth_queue_start_t          rx_queue_start;/**< Start RX for a queue. */
561         eth_queue_stop_t           rx_queue_stop; /**< Stop RX for a queue. */
562         eth_queue_start_t          tx_queue_start;/**< Start TX for a queue. */
563         eth_queue_stop_t           tx_queue_stop; /**< Stop TX for a queue. */
564         eth_rx_queue_setup_t       rx_queue_setup;/**< Set up device RX queue. */
565         eth_queue_release_t        rx_queue_release; /**< Release RX queue. */
566         eth_rx_queue_count_t       rx_queue_count;
567         /**< Get the number of used RX descriptors. */
568         eth_rx_descriptor_done_t   rx_descriptor_done; /**< Check rxd DD bit. */
569         eth_rx_descriptor_status_t rx_descriptor_status;
570         /**< Check the status of a Rx descriptor. */
571         eth_tx_descriptor_status_t tx_descriptor_status;
572         /**< Check the status of a Tx descriptor. */
573         eth_rx_enable_intr_t       rx_queue_intr_enable;  /**< Enable Rx queue interrupt. */
574         eth_rx_disable_intr_t      rx_queue_intr_disable; /**< Disable Rx queue interrupt. */
575         eth_tx_queue_setup_t       tx_queue_setup;/**< Set up device TX queue. */
576         eth_queue_release_t        tx_queue_release; /**< Release TX queue. */
577         eth_tx_done_cleanup_t      tx_done_cleanup;/**< Free tx ring mbufs */
578
579         eth_dev_led_on_t           dev_led_on;    /**< Turn on LED. */
580         eth_dev_led_off_t          dev_led_off;   /**< Turn off LED. */
581
582         flow_ctrl_get_t            flow_ctrl_get; /**< Get flow control. */
583         flow_ctrl_set_t            flow_ctrl_set; /**< Setup flow control. */
584         priority_flow_ctrl_set_t   priority_flow_ctrl_set; /**< Setup priority flow control. */
585
586         eth_uc_hash_table_set_t    uc_hash_table_set; /**< Set Unicast Table Array. */
587         eth_uc_all_hash_table_set_t uc_all_hash_table_set; /**< Set Unicast hash bitmap. */
588
589         eth_mirror_rule_set_t      mirror_rule_set; /**< Add a traffic mirror rule. */
590         eth_mirror_rule_reset_t    mirror_rule_reset; /**< reset a traffic mirror rule. */
591
592         eth_udp_tunnel_port_add_t  udp_tunnel_port_add; /** Add UDP tunnel port. */
593         eth_udp_tunnel_port_del_t  udp_tunnel_port_del; /** Del UDP tunnel port. */
594         eth_l2_tunnel_eth_type_conf_t l2_tunnel_eth_type_conf;
595         /** Config ether type of l2 tunnel. */
596         eth_l2_tunnel_offload_set_t   l2_tunnel_offload_set;
597         /** Enable/disable l2 tunnel offload functions. */
598
599         eth_set_queue_rate_limit_t set_queue_rate_limit; /**< Set queue rate limit. */
600
601         rss_hash_update_t          rss_hash_update; /** Configure RSS hash protocols. */
602         rss_hash_conf_get_t        rss_hash_conf_get; /** Get current RSS hash configuration. */
603         reta_update_t              reta_update;   /** Update redirection table. */
604         reta_query_t               reta_query;    /** Query redirection table. */
605
606         eth_get_reg_t              get_reg;           /**< Get registers. */
607         eth_get_eeprom_length_t    get_eeprom_length; /**< Get eeprom length. */
608         eth_get_eeprom_t           get_eeprom;        /**< Get eeprom data. */
609         eth_set_eeprom_t           set_eeprom;        /**< Set eeprom. */
610
611         eth_get_module_info_t      get_module_info;
612         /** Get plugin module eeprom attribute. */
613         eth_get_module_eeprom_t    get_module_eeprom;
614         /** Get plugin module eeprom data. */
615
616         eth_filter_ctrl_t          filter_ctrl; /**< common filter control. */
617
618         eth_get_dcb_info           get_dcb_info; /** Get DCB information. */
619
620         eth_timesync_enable_t      timesync_enable;
621         /** Turn IEEE1588/802.1AS timestamping on. */
622         eth_timesync_disable_t     timesync_disable;
623         /** Turn IEEE1588/802.1AS timestamping off. */
624         eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp;
625         /** Read the IEEE1588/802.1AS RX timestamp. */
626         eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp;
627         /** Read the IEEE1588/802.1AS TX timestamp. */
628         eth_timesync_adjust_time   timesync_adjust_time; /** Adjust the device clock. */
629         eth_timesync_read_time     timesync_read_time; /** Get the device clock time. */
630         eth_timesync_write_time    timesync_write_time; /** Set the device clock time. */
631
632         eth_read_clock             read_clock;
633
634         eth_xstats_get_by_id_t     xstats_get_by_id;
635         /**< Get extended device statistic values by ID. */
636         eth_xstats_get_names_by_id_t xstats_get_names_by_id;
637         /**< Get name of extended device statistics by ID. */
638
639         eth_tm_ops_get_t tm_ops_get;
640         /**< Get Traffic Management (TM) operations. */
641
642         eth_mtr_ops_get_t mtr_ops_get;
643         /**< Get Traffic Metering and Policing (MTR) operations. */
644
645         eth_pool_ops_supported_t pool_ops_supported;
646         /**< Test if a port supports specific mempool ops */
647 };
648
649 /**
650  * @internal
651  * Structure used to hold information about the callbacks to be called for a
652  * queue on RX and TX.
653  */
654 struct rte_eth_rxtx_callback {
655         struct rte_eth_rxtx_callback *next;
656         union{
657                 rte_rx_callback_fn rx;
658                 rte_tx_callback_fn tx;
659         } fn;
660         void *param;
661 };
662
663 /**
664  * @internal
665  * The generic data structure associated with each ethernet device.
666  *
667  * Pointers to burst-oriented packet receive and transmit functions are
668  * located at the beginning of the structure, along with the pointer to
669  * where all the data elements for the particular device are stored in shared
670  * memory. This split allows the function pointer and driver data to be per-
671  * process, while the actual configuration data for the device is shared.
672  */
673 struct rte_eth_dev {
674         eth_rx_burst_t rx_pkt_burst; /**< Pointer to PMD receive function. */
675         eth_tx_burst_t tx_pkt_burst; /**< Pointer to PMD transmit function. */
676         eth_tx_prep_t tx_pkt_prepare; /**< Pointer to PMD transmit prepare function. */
677         /**
678          * Next two fields are per-device data but *data is shared between
679          * primary and secondary processes and *process_private is per-process
680          * private. The second one is managed by PMDs if necessary.
681          */
682         struct rte_eth_dev_data *data;  /**< Pointer to device data. */
683         void *process_private; /**< Pointer to per-process device data. */
684         const struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */
685         struct rte_device *device; /**< Backing device */
686         struct rte_intr_handle *intr_handle; /**< Device interrupt handle */
687         /** User application callbacks for NIC interrupts */
688         struct rte_eth_dev_cb_list link_intr_cbs;
689         /**
690          * User-supplied functions called from rx_burst to post-process
691          * received packets before passing them to the user
692          */
693         struct rte_eth_rxtx_callback *post_rx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
694         /**
695          * User-supplied functions called from tx_burst to pre-process
696          * received packets before passing them to the driver for transmission.
697          */
698         struct rte_eth_rxtx_callback *pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
699         enum rte_eth_dev_state state; /**< Flag indicating the port state */
700         void *security_ctx; /**< Context for security ops */
701 } __rte_cache_aligned;
702
703 struct rte_eth_dev_sriov;
704 struct rte_eth_dev_owner;
705
706 /**
707  * @internal
708  * The data part, with no function pointers, associated with each ethernet device.
709  *
710  * This structure is safe to place in shared memory to be common among different
711  * processes in a multi-process configuration.
712  */
713 struct rte_eth_dev_data {
714         char name[RTE_ETH_NAME_MAX_LEN]; /**< Unique identifier name */
715
716         void **rx_queues; /**< Array of pointers to RX queues. */
717         void **tx_queues; /**< Array of pointers to TX queues. */
718         uint16_t nb_rx_queues; /**< Number of RX queues. */
719         uint16_t nb_tx_queues; /**< Number of TX queues. */
720
721         struct rte_eth_dev_sriov sriov;    /**< SRIOV data */
722
723         void *dev_private;
724                         /**< PMD-specific private data.
725                          *   @see rte_eth_dev_release_port()
726                          */
727
728         struct rte_eth_link dev_link;   /**< Link-level information & status. */
729         struct rte_eth_conf dev_conf;   /**< Configuration applied to device. */
730         uint16_t mtu;                   /**< Maximum Transmission Unit. */
731         uint32_t min_rx_buf_size;
732                         /**< Common RX buffer size handled by all queues. */
733
734         uint64_t rx_mbuf_alloc_failed; /**< RX ring mbuf allocation failures. */
735         struct rte_ether_addr *mac_addrs;
736                         /**< Device Ethernet link address.
737                          *   @see rte_eth_dev_release_port()
738                          */
739         uint64_t mac_pool_sel[ETH_NUM_RECEIVE_MAC_ADDR];
740                         /**< Bitmap associating MAC addresses to pools. */
741         struct rte_ether_addr *hash_mac_addrs;
742                         /**< Device Ethernet MAC addresses of hash filtering.
743                          *   @see rte_eth_dev_release_port()
744                          */
745         uint16_t port_id;           /**< Device [external] port identifier. */
746
747         __extension__
748         uint8_t promiscuous   : 1, /**< RX promiscuous mode ON(1) / OFF(0). */
749                 scattered_rx : 1,  /**< RX of scattered packets is ON(1) / OFF(0) */
750                 all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
751                 dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
752                 lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
753         uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
754                         /**< Queues state: STARTED(1) / STOPPED(0). */
755         uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
756                         /**< Queues state: STARTED(1) / STOPPED(0). */
757         uint32_t dev_flags;             /**< Capabilities. */
758         enum rte_kernel_driver kdrv;    /**< Kernel driver passthrough. */
759         int numa_node;                  /**< NUMA node connection. */
760         struct rte_vlan_filter_conf vlan_filter_conf;
761                         /**< VLAN filter configuration. */
762         struct rte_eth_dev_owner owner; /**< The port owner. */
763         uint16_t representor_id;
764                         /**< Switch-specific identifier.
765                          *   Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags.
766                          */
767 } __rte_cache_aligned;
768
769 /**
770  * @internal
771  * The pool of *rte_eth_dev* structures. The size of the pool
772  * is configured at compile-time in the <rte_ethdev.c> file.
773  */
774 extern struct rte_eth_dev rte_eth_devices[];
775
776 #endif /* _RTE_ETHDEV_CORE_H_ */