examples/fips_validation: fix buffer overflow
[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 /**
238  * @internal
239  * Inform Ethernet device about reduced range of packet types to handle.
240  *
241  * @param dev
242  *   The Ethernet device identifier.
243  * @param ptype_mask
244  *   The ptype family that application is interested in should be bitwise OR of
245  *   RTE_PTYPE_*_MASK or 0.
246  * @return
247  *   - (0) if Success.
248  */
249 typedef int (*eth_dev_ptypes_set_t)(struct rte_eth_dev *dev,
250                                      uint32_t ptype_mask);
251
252 typedef int (*eth_queue_start_t)(struct rte_eth_dev *dev,
253                                     uint16_t queue_id);
254 /**< @internal Start rx and tx of a queue of an Ethernet device. */
255
256 typedef int (*eth_queue_stop_t)(struct rte_eth_dev *dev,
257                                     uint16_t queue_id);
258 /**< @internal Stop rx and tx of a queue of an Ethernet device. */
259
260 typedef int (*eth_rx_queue_setup_t)(struct rte_eth_dev *dev,
261                                     uint16_t rx_queue_id,
262                                     uint16_t nb_rx_desc,
263                                     unsigned int socket_id,
264                                     const struct rte_eth_rxconf *rx_conf,
265                                     struct rte_mempool *mb_pool);
266 /**< @internal Set up a receive queue of an Ethernet device. */
267
268 typedef int (*eth_tx_queue_setup_t)(struct rte_eth_dev *dev,
269                                     uint16_t tx_queue_id,
270                                     uint16_t nb_tx_desc,
271                                     unsigned int socket_id,
272                                     const struct rte_eth_txconf *tx_conf);
273 /**< @internal Setup a transmit queue of an Ethernet device. */
274
275 typedef int (*eth_rx_enable_intr_t)(struct rte_eth_dev *dev,
276                                     uint16_t rx_queue_id);
277 /**< @internal Enable interrupt of a receive queue of an Ethernet device. */
278
279 typedef int (*eth_rx_disable_intr_t)(struct rte_eth_dev *dev,
280                                     uint16_t rx_queue_id);
281 /**< @internal Disable interrupt of a receive queue of an Ethernet device. */
282
283 typedef void (*eth_queue_release_t)(void *queue);
284 /**< @internal Release memory resources allocated by given RX/TX queue. */
285
286 typedef uint32_t (*eth_rx_queue_count_t)(struct rte_eth_dev *dev,
287                                          uint16_t rx_queue_id);
288 /**< @internal Get number of used descriptors on a receive queue. */
289
290 typedef int (*eth_rx_descriptor_done_t)(void *rxq, uint16_t offset);
291 /**< @internal Check DD bit of specific RX descriptor */
292
293 typedef int (*eth_rx_descriptor_status_t)(void *rxq, uint16_t offset);
294 /**< @internal Check the status of a Rx descriptor */
295
296 typedef int (*eth_tx_descriptor_status_t)(void *txq, uint16_t offset);
297 /**< @internal Check the status of a Tx descriptor */
298
299 typedef int (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
300                                      char *fw_version, size_t fw_size);
301 /**< @internal Get firmware information of an Ethernet device. */
302
303 typedef int (*eth_tx_done_cleanup_t)(void *txq, uint32_t free_cnt);
304 /**< @internal Force mbufs to be from TX ring. */
305
306 typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
307         uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
308
309 typedef void (*eth_txq_info_get_t)(struct rte_eth_dev *dev,
310         uint16_t tx_queue_id, struct rte_eth_txq_info *qinfo);
311
312 typedef int (*eth_burst_mode_get_t)(struct rte_eth_dev *dev,
313         uint16_t queue_id, struct rte_eth_burst_mode *mode);
314
315 typedef int (*mtu_set_t)(struct rte_eth_dev *dev, uint16_t mtu);
316 /**< @internal Set MTU. */
317
318 typedef int (*vlan_filter_set_t)(struct rte_eth_dev *dev,
319                                   uint16_t vlan_id,
320                                   int on);
321 /**< @internal filtering of a VLAN Tag Identifier by an Ethernet device. */
322
323 typedef int (*vlan_tpid_set_t)(struct rte_eth_dev *dev,
324                                enum rte_vlan_type type, uint16_t tpid);
325 /**< @internal set the outer/inner VLAN-TPID by an Ethernet device. */
326
327 typedef int (*vlan_offload_set_t)(struct rte_eth_dev *dev, int mask);
328 /**< @internal set VLAN offload function by an Ethernet device. */
329
330 typedef int (*vlan_pvid_set_t)(struct rte_eth_dev *dev,
331                                uint16_t vlan_id,
332                                int on);
333 /**< @internal set port based TX VLAN insertion by an Ethernet device. */
334
335 typedef void (*vlan_strip_queue_set_t)(struct rte_eth_dev *dev,
336                                   uint16_t rx_queue_id,
337                                   int on);
338 /**< @internal VLAN stripping enable/disable by an queue of Ethernet device. */
339
340 typedef uint16_t (*eth_rx_burst_t)(void *rxq,
341                                    struct rte_mbuf **rx_pkts,
342                                    uint16_t nb_pkts);
343 /**< @internal Retrieve input packets from a receive queue of an Ethernet device. */
344
345 typedef uint16_t (*eth_tx_burst_t)(void *txq,
346                                    struct rte_mbuf **tx_pkts,
347                                    uint16_t nb_pkts);
348 /**< @internal Send output packets on a transmit queue of an Ethernet device. */
349
350 typedef uint16_t (*eth_tx_prep_t)(void *txq,
351                                    struct rte_mbuf **tx_pkts,
352                                    uint16_t nb_pkts);
353 /**< @internal Prepare output packets on a transmit queue of an Ethernet device. */
354
355 typedef int (*flow_ctrl_get_t)(struct rte_eth_dev *dev,
356                                struct rte_eth_fc_conf *fc_conf);
357 /**< @internal Get current flow control parameter on an Ethernet device */
358
359 typedef int (*flow_ctrl_set_t)(struct rte_eth_dev *dev,
360                                struct rte_eth_fc_conf *fc_conf);
361 /**< @internal Setup flow control parameter on an Ethernet device */
362
363 typedef int (*priority_flow_ctrl_set_t)(struct rte_eth_dev *dev,
364                                 struct rte_eth_pfc_conf *pfc_conf);
365 /**< @internal Setup priority flow control parameter on an Ethernet device */
366
367 typedef int (*reta_update_t)(struct rte_eth_dev *dev,
368                              struct rte_eth_rss_reta_entry64 *reta_conf,
369                              uint16_t reta_size);
370 /**< @internal Update RSS redirection table on an Ethernet device */
371
372 typedef int (*reta_query_t)(struct rte_eth_dev *dev,
373                             struct rte_eth_rss_reta_entry64 *reta_conf,
374                             uint16_t reta_size);
375 /**< @internal Query RSS redirection table on an Ethernet device */
376
377 typedef int (*rss_hash_update_t)(struct rte_eth_dev *dev,
378                                  struct rte_eth_rss_conf *rss_conf);
379 /**< @internal Update RSS hash configuration of an Ethernet device */
380
381 typedef int (*rss_hash_conf_get_t)(struct rte_eth_dev *dev,
382                                    struct rte_eth_rss_conf *rss_conf);
383 /**< @internal Get current RSS hash configuration of an Ethernet device */
384
385 typedef int (*eth_dev_led_on_t)(struct rte_eth_dev *dev);
386 /**< @internal Turn on SW controllable LED on an Ethernet device */
387
388 typedef int (*eth_dev_led_off_t)(struct rte_eth_dev *dev);
389 /**< @internal Turn off SW controllable LED on an Ethernet device */
390
391 typedef void (*eth_mac_addr_remove_t)(struct rte_eth_dev *dev, uint32_t index);
392 /**< @internal Remove MAC address from receive address register */
393
394 typedef int (*eth_mac_addr_add_t)(struct rte_eth_dev *dev,
395                                   struct rte_ether_addr *mac_addr,
396                                   uint32_t index,
397                                   uint32_t vmdq);
398 /**< @internal Set a MAC address into Receive Address Address Register */
399
400 typedef int (*eth_mac_addr_set_t)(struct rte_eth_dev *dev,
401                                   struct rte_ether_addr *mac_addr);
402 /**< @internal Set a MAC address into Receive Address Address Register */
403
404 typedef int (*eth_uc_hash_table_set_t)(struct rte_eth_dev *dev,
405                                   struct rte_ether_addr *mac_addr,
406                                   uint8_t on);
407 /**< @internal Set a Unicast Hash bitmap */
408
409 typedef int (*eth_uc_all_hash_table_set_t)(struct rte_eth_dev *dev,
410                                   uint8_t on);
411 /**< @internal Set all Unicast Hash bitmap */
412
413 typedef int (*eth_set_queue_rate_limit_t)(struct rte_eth_dev *dev,
414                                 uint16_t queue_idx,
415                                 uint16_t tx_rate);
416 /**< @internal Set queue TX rate */
417
418 typedef int (*eth_mirror_rule_set_t)(struct rte_eth_dev *dev,
419                                   struct rte_eth_mirror_conf *mirror_conf,
420                                   uint8_t rule_id,
421                                   uint8_t on);
422 /**< @internal Add a traffic mirroring rule on an Ethernet device */
423
424 typedef int (*eth_mirror_rule_reset_t)(struct rte_eth_dev *dev,
425                                   uint8_t rule_id);
426 /**< @internal Remove a traffic mirroring rule on an Ethernet device */
427
428 typedef int (*eth_udp_tunnel_port_add_t)(struct rte_eth_dev *dev,
429                                          struct rte_eth_udp_tunnel *tunnel_udp);
430 /**< @internal Add tunneling UDP port */
431
432 typedef int (*eth_udp_tunnel_port_del_t)(struct rte_eth_dev *dev,
433                                          struct rte_eth_udp_tunnel *tunnel_udp);
434 /**< @internal Delete tunneling UDP port */
435
436 typedef int (*eth_set_mc_addr_list_t)(struct rte_eth_dev *dev,
437                                       struct rte_ether_addr *mc_addr_set,
438                                       uint32_t nb_mc_addr);
439 /**< @internal set the list of multicast addresses on an Ethernet device */
440
441 typedef int (*eth_timesync_enable_t)(struct rte_eth_dev *dev);
442 /**< @internal Function used to enable IEEE1588/802.1AS timestamping. */
443
444 typedef int (*eth_timesync_disable_t)(struct rte_eth_dev *dev);
445 /**< @internal Function used to disable IEEE1588/802.1AS timestamping. */
446
447 typedef int (*eth_timesync_read_rx_timestamp_t)(struct rte_eth_dev *dev,
448                                                 struct timespec *timestamp,
449                                                 uint32_t flags);
450 /**< @internal Function used to read an RX IEEE1588/802.1AS timestamp. */
451
452 typedef int (*eth_timesync_read_tx_timestamp_t)(struct rte_eth_dev *dev,
453                                                 struct timespec *timestamp);
454 /**< @internal Function used to read a TX IEEE1588/802.1AS timestamp. */
455
456 typedef int (*eth_timesync_adjust_time)(struct rte_eth_dev *dev, int64_t);
457 /**< @internal Function used to adjust the device clock */
458
459 typedef int (*eth_timesync_read_time)(struct rte_eth_dev *dev,
460                                       struct timespec *timestamp);
461 /**< @internal Function used to get time from the device clock. */
462
463 typedef int (*eth_timesync_write_time)(struct rte_eth_dev *dev,
464                                        const struct timespec *timestamp);
465 /**< @internal Function used to get time from the device clock */
466
467 typedef int (*eth_read_clock)(struct rte_eth_dev *dev,
468                                       uint64_t *timestamp);
469 /**< @internal Function used to get the current value of the device clock. */
470
471 typedef int (*eth_get_reg_t)(struct rte_eth_dev *dev,
472                                 struct rte_dev_reg_info *info);
473 /**< @internal Retrieve registers  */
474
475 typedef int (*eth_get_eeprom_length_t)(struct rte_eth_dev *dev);
476 /**< @internal Retrieve eeprom size  */
477
478 typedef int (*eth_get_eeprom_t)(struct rte_eth_dev *dev,
479                                 struct rte_dev_eeprom_info *info);
480 /**< @internal Retrieve eeprom data  */
481
482 typedef int (*eth_set_eeprom_t)(struct rte_eth_dev *dev,
483                                 struct rte_dev_eeprom_info *info);
484 /**< @internal Program eeprom data  */
485
486 typedef int (*eth_get_module_info_t)(struct rte_eth_dev *dev,
487                                      struct rte_eth_dev_module_info *modinfo);
488 /**< @internal Retrieve type and size of plugin module eeprom */
489
490 typedef int (*eth_get_module_eeprom_t)(struct rte_eth_dev *dev,
491                                        struct rte_dev_eeprom_info *info);
492 /**< @internal Retrieve plugin module eeprom data */
493
494 typedef int (*eth_l2_tunnel_eth_type_conf_t)
495         (struct rte_eth_dev *dev, struct rte_eth_l2_tunnel_conf *l2_tunnel);
496 /**< @internal config l2 tunnel ether type */
497
498 typedef int (*eth_l2_tunnel_offload_set_t)
499         (struct rte_eth_dev *dev,
500          struct rte_eth_l2_tunnel_conf *l2_tunnel,
501          uint32_t mask,
502          uint8_t en);
503 /**< @internal enable/disable the l2 tunnel offload functions */
504
505
506 typedef int (*eth_filter_ctrl_t)(struct rte_eth_dev *dev,
507                                  enum rte_filter_type filter_type,
508                                  enum rte_filter_op filter_op,
509                                  void *arg);
510 /**< @internal Take operations to assigned filter type on an Ethernet device */
511
512 typedef int (*eth_tm_ops_get_t)(struct rte_eth_dev *dev, void *ops);
513 /**< @internal Get Traffic Management (TM) operations on an Ethernet device */
514
515 typedef int (*eth_mtr_ops_get_t)(struct rte_eth_dev *dev, void *ops);
516 /**< @internal Get Traffic Metering and Policing (MTR) operations */
517
518 typedef int (*eth_get_dcb_info)(struct rte_eth_dev *dev,
519                                  struct rte_eth_dcb_info *dcb_info);
520 /**< @internal Get dcb information on an Ethernet device */
521
522 typedef int (*eth_pool_ops_supported_t)(struct rte_eth_dev *dev,
523                                                 const char *pool);
524 /**< @internal Test if a port supports specific mempool ops */
525
526 /**
527  * @internal
528  * Get the hairpin capabilities.
529  *
530  * @param dev
531  *   ethdev handle of port.
532  * @param cap
533  *   returns the hairpin capabilities from the device.
534  *
535  * @return
536  *   Negative errno value on error, 0 on success.
537  *
538  * @retval 0
539  *   Success, hairpin is supported.
540  * @retval -ENOTSUP
541  *   Hairpin is not supported.
542  */
543 typedef int (*eth_hairpin_cap_get_t)(struct rte_eth_dev *dev,
544                                      struct rte_eth_hairpin_cap *cap);
545
546 /**
547  * @internal
548  * Setup RX hairpin queue.
549  *
550  * @param dev
551  *   ethdev handle of port.
552  * @param rx_queue_id
553  *   the selected RX queue index.
554  * @param nb_rx_desc
555  *   the requested number of descriptors for this queue. 0 - use PMD default.
556  * @param conf
557  *   the RX hairpin configuration structure.
558  *
559  * @return
560  *   Negative errno value on error, 0 on success.
561  *
562  * @retval 0
563  *   Success, hairpin is supported.
564  * @retval -ENOTSUP
565  *   Hairpin is not supported.
566  * @retval -EINVAL
567  *   One of the parameters is invalid.
568  * @retval -ENOMEM
569  *   Unable to allocate resources.
570  */
571 typedef int (*eth_rx_hairpin_queue_setup_t)
572         (struct rte_eth_dev *dev, uint16_t rx_queue_id,
573          uint16_t nb_rx_desc,
574          const struct rte_eth_hairpin_conf *conf);
575
576 /**
577  * @internal
578  * Setup TX hairpin queue.
579  *
580  * @param dev
581  *   ethdev handle of port.
582  * @param tx_queue_id
583  *   the selected TX queue index.
584  * @param nb_tx_desc
585  *   the requested number of descriptors for this queue. 0 - use PMD default.
586  * @param conf
587  *   the TX hairpin configuration structure.
588  *
589  * @return
590  *   Negative errno value on error, 0 on success.
591  *
592  * @retval 0
593  *   Success, hairpin is supported.
594  * @retval -ENOTSUP
595  *   Hairpin is not supported.
596  * @retval -EINVAL
597  *   One of the parameters is invalid.
598  * @retval -ENOMEM
599  *   Unable to allocate resources.
600  */
601 typedef int (*eth_tx_hairpin_queue_setup_t)
602         (struct rte_eth_dev *dev, uint16_t tx_queue_id,
603          uint16_t nb_tx_desc,
604          const struct rte_eth_hairpin_conf *hairpin_conf);
605
606 /**
607  * @internal A structure containing the functions exported by an Ethernet driver.
608  */
609 struct eth_dev_ops {
610         eth_dev_configure_t        dev_configure; /**< Configure device. */
611         eth_dev_start_t            dev_start;     /**< Start device. */
612         eth_dev_stop_t             dev_stop;      /**< Stop device. */
613         eth_dev_set_link_up_t      dev_set_link_up;   /**< Device link up. */
614         eth_dev_set_link_down_t    dev_set_link_down; /**< Device link down. */
615         eth_dev_close_t            dev_close;     /**< Close device. */
616         eth_dev_reset_t            dev_reset;     /**< Reset device. */
617         eth_link_update_t          link_update;   /**< Get device link state. */
618         eth_is_removed_t           is_removed;
619         /**< Check if the device was physically removed. */
620
621         eth_promiscuous_enable_t   promiscuous_enable; /**< Promiscuous ON. */
622         eth_promiscuous_disable_t  promiscuous_disable;/**< Promiscuous OFF. */
623         eth_allmulticast_enable_t  allmulticast_enable;/**< RX multicast ON. */
624         eth_allmulticast_disable_t allmulticast_disable;/**< RX multicast OFF. */
625         eth_mac_addr_remove_t      mac_addr_remove; /**< Remove MAC address. */
626         eth_mac_addr_add_t         mac_addr_add;  /**< Add a MAC address. */
627         eth_mac_addr_set_t         mac_addr_set;  /**< Set a MAC address. */
628         eth_set_mc_addr_list_t     set_mc_addr_list; /**< set list of mcast addrs. */
629         mtu_set_t                  mtu_set;       /**< Set MTU. */
630
631         eth_stats_get_t            stats_get;     /**< Get generic device statistics. */
632         eth_stats_reset_t          stats_reset;   /**< Reset generic device statistics. */
633         eth_xstats_get_t           xstats_get;    /**< Get extended device statistics. */
634         eth_xstats_reset_t         xstats_reset;  /**< Reset extended device statistics. */
635         eth_xstats_get_names_t     xstats_get_names;
636         /**< Get names of extended statistics. */
637         eth_queue_stats_mapping_set_t queue_stats_mapping_set;
638         /**< Configure per queue stat counter mapping. */
639
640         eth_dev_infos_get_t        dev_infos_get; /**< Get device info. */
641         eth_rxq_info_get_t         rxq_info_get; /**< retrieve RX queue information. */
642         eth_txq_info_get_t         txq_info_get; /**< retrieve TX queue information. */
643         eth_burst_mode_get_t       rx_burst_mode_get; /**< Get RX burst mode */
644         eth_burst_mode_get_t       tx_burst_mode_get; /**< Get TX burst mode */
645         eth_fw_version_get_t       fw_version_get; /**< Get firmware version. */
646         eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
647         /**< Get packet types supported and identified by device. */
648         eth_dev_ptypes_set_t dev_ptypes_set;
649         /**< Inform Ethernet device about reduced range of packet types to handle. */
650
651         vlan_filter_set_t          vlan_filter_set; /**< Filter VLAN Setup. */
652         vlan_tpid_set_t            vlan_tpid_set; /**< Outer/Inner VLAN TPID Setup. */
653         vlan_strip_queue_set_t     vlan_strip_queue_set; /**< VLAN Stripping on queue. */
654         vlan_offload_set_t         vlan_offload_set; /**< Set VLAN Offload. */
655         vlan_pvid_set_t            vlan_pvid_set; /**< Set port based TX VLAN insertion. */
656
657         eth_queue_start_t          rx_queue_start;/**< Start RX for a queue. */
658         eth_queue_stop_t           rx_queue_stop; /**< Stop RX for a queue. */
659         eth_queue_start_t          tx_queue_start;/**< Start TX for a queue. */
660         eth_queue_stop_t           tx_queue_stop; /**< Stop TX for a queue. */
661         eth_rx_queue_setup_t       rx_queue_setup;/**< Set up device RX queue. */
662         eth_queue_release_t        rx_queue_release; /**< Release RX queue. */
663         eth_rx_queue_count_t       rx_queue_count;
664         /**< Get the number of used RX descriptors. */
665         eth_rx_descriptor_done_t   rx_descriptor_done; /**< Check rxd DD bit. */
666         eth_rx_descriptor_status_t rx_descriptor_status;
667         /**< Check the status of a Rx descriptor. */
668         eth_tx_descriptor_status_t tx_descriptor_status;
669         /**< Check the status of a Tx descriptor. */
670         /*
671          * Static inline functions use functions ABOVE this comment.
672          * New dev_ops functions should be added BELOW to avoid breaking ABI.
673          */
674         eth_rx_enable_intr_t       rx_queue_intr_enable;  /**< Enable Rx queue interrupt. */
675         eth_rx_disable_intr_t      rx_queue_intr_disable; /**< Disable Rx queue interrupt. */
676         eth_tx_queue_setup_t       tx_queue_setup;/**< Set up device TX queue. */
677         eth_queue_release_t        tx_queue_release; /**< Release TX queue. */
678         eth_tx_done_cleanup_t      tx_done_cleanup;/**< Free tx ring mbufs */
679
680         eth_dev_led_on_t           dev_led_on;    /**< Turn on LED. */
681         eth_dev_led_off_t          dev_led_off;   /**< Turn off LED. */
682
683         flow_ctrl_get_t            flow_ctrl_get; /**< Get flow control. */
684         flow_ctrl_set_t            flow_ctrl_set; /**< Setup flow control. */
685         priority_flow_ctrl_set_t   priority_flow_ctrl_set; /**< Setup priority flow control. */
686
687         eth_uc_hash_table_set_t    uc_hash_table_set; /**< Set Unicast Table Array. */
688         eth_uc_all_hash_table_set_t uc_all_hash_table_set; /**< Set Unicast hash bitmap. */
689
690         eth_mirror_rule_set_t      mirror_rule_set; /**< Add a traffic mirror rule. */
691         eth_mirror_rule_reset_t    mirror_rule_reset; /**< reset a traffic mirror rule. */
692
693         eth_udp_tunnel_port_add_t  udp_tunnel_port_add; /** Add UDP tunnel port. */
694         eth_udp_tunnel_port_del_t  udp_tunnel_port_del; /** Del UDP tunnel port. */
695         eth_l2_tunnel_eth_type_conf_t l2_tunnel_eth_type_conf;
696         /** Config ether type of l2 tunnel. */
697         eth_l2_tunnel_offload_set_t   l2_tunnel_offload_set;
698         /** Enable/disable l2 tunnel offload functions. */
699
700         eth_set_queue_rate_limit_t set_queue_rate_limit; /**< Set queue rate limit. */
701
702         rss_hash_update_t          rss_hash_update; /** Configure RSS hash protocols. */
703         rss_hash_conf_get_t        rss_hash_conf_get; /** Get current RSS hash configuration. */
704         reta_update_t              reta_update;   /** Update redirection table. */
705         reta_query_t               reta_query;    /** Query redirection table. */
706
707         eth_get_reg_t              get_reg;           /**< Get registers. */
708         eth_get_eeprom_length_t    get_eeprom_length; /**< Get eeprom length. */
709         eth_get_eeprom_t           get_eeprom;        /**< Get eeprom data. */
710         eth_set_eeprom_t           set_eeprom;        /**< Set eeprom. */
711
712         eth_get_module_info_t      get_module_info;
713         /** Get plugin module eeprom attribute. */
714         eth_get_module_eeprom_t    get_module_eeprom;
715         /** Get plugin module eeprom data. */
716
717         eth_filter_ctrl_t          filter_ctrl; /**< common filter control. */
718
719         eth_get_dcb_info           get_dcb_info; /** Get DCB information. */
720
721         eth_timesync_enable_t      timesync_enable;
722         /** Turn IEEE1588/802.1AS timestamping on. */
723         eth_timesync_disable_t     timesync_disable;
724         /** Turn IEEE1588/802.1AS timestamping off. */
725         eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp;
726         /** Read the IEEE1588/802.1AS RX timestamp. */
727         eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp;
728         /** Read the IEEE1588/802.1AS TX timestamp. */
729         eth_timesync_adjust_time   timesync_adjust_time; /** Adjust the device clock. */
730         eth_timesync_read_time     timesync_read_time; /** Get the device clock time. */
731         eth_timesync_write_time    timesync_write_time; /** Set the device clock time. */
732
733         eth_read_clock             read_clock;
734
735         eth_xstats_get_by_id_t     xstats_get_by_id;
736         /**< Get extended device statistic values by ID. */
737         eth_xstats_get_names_by_id_t xstats_get_names_by_id;
738         /**< Get name of extended device statistics by ID. */
739
740         eth_tm_ops_get_t tm_ops_get;
741         /**< Get Traffic Management (TM) operations. */
742
743         eth_mtr_ops_get_t mtr_ops_get;
744         /**< Get Traffic Metering and Policing (MTR) operations. */
745
746         eth_pool_ops_supported_t pool_ops_supported;
747         /**< Test if a port supports specific mempool ops */
748
749         eth_hairpin_cap_get_t hairpin_cap_get;
750         /**< Returns the hairpin capabilities. */
751         eth_rx_hairpin_queue_setup_t rx_hairpin_queue_setup;
752         /**< Set up device RX hairpin queue. */
753         eth_tx_hairpin_queue_setup_t tx_hairpin_queue_setup;
754         /**< Set up device TX hairpin queue. */
755 };
756
757 /**
758  * @internal
759  * Structure used to hold information about the callbacks to be called for a
760  * queue on RX and TX.
761  */
762 struct rte_eth_rxtx_callback {
763         struct rte_eth_rxtx_callback *next;
764         union{
765                 rte_rx_callback_fn rx;
766                 rte_tx_callback_fn tx;
767         } fn;
768         void *param;
769 };
770
771 /**
772  * @internal
773  * The generic data structure associated with each ethernet device.
774  *
775  * Pointers to burst-oriented packet receive and transmit functions are
776  * located at the beginning of the structure, along with the pointer to
777  * where all the data elements for the particular device are stored in shared
778  * memory. This split allows the function pointer and driver data to be per-
779  * process, while the actual configuration data for the device is shared.
780  */
781 struct rte_eth_dev {
782         eth_rx_burst_t rx_pkt_burst; /**< Pointer to PMD receive function. */
783         eth_tx_burst_t tx_pkt_burst; /**< Pointer to PMD transmit function. */
784         eth_tx_prep_t tx_pkt_prepare; /**< Pointer to PMD transmit prepare function. */
785         /**
786          * Next two fields are per-device data but *data is shared between
787          * primary and secondary processes and *process_private is per-process
788          * private. The second one is managed by PMDs if necessary.
789          */
790         struct rte_eth_dev_data *data;  /**< Pointer to device data. */
791         void *process_private; /**< Pointer to per-process device data. */
792         const struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */
793         struct rte_device *device; /**< Backing device */
794         struct rte_intr_handle *intr_handle; /**< Device interrupt handle */
795         /** User application callbacks for NIC interrupts */
796         struct rte_eth_dev_cb_list link_intr_cbs;
797         /**
798          * User-supplied functions called from rx_burst to post-process
799          * received packets before passing them to the user
800          */
801         struct rte_eth_rxtx_callback *post_rx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
802         /**
803          * User-supplied functions called from tx_burst to pre-process
804          * received packets before passing them to the driver for transmission.
805          */
806         struct rte_eth_rxtx_callback *pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
807         enum rte_eth_dev_state state; /**< Flag indicating the port state */
808         void *security_ctx; /**< Context for security ops */
809
810         uint64_t reserved_64s[4]; /**< Reserved for future fields */
811         void *reserved_ptrs[4];   /**< Reserved for future fields */
812 } __rte_cache_aligned;
813
814 struct rte_eth_dev_sriov;
815 struct rte_eth_dev_owner;
816
817 /**
818  * @internal
819  * The data part, with no function pointers, associated with each ethernet device.
820  *
821  * This structure is safe to place in shared memory to be common among different
822  * processes in a multi-process configuration.
823  */
824 struct rte_eth_dev_data {
825         char name[RTE_ETH_NAME_MAX_LEN]; /**< Unique identifier name */
826
827         void **rx_queues; /**< Array of pointers to RX queues. */
828         void **tx_queues; /**< Array of pointers to TX queues. */
829         uint16_t nb_rx_queues; /**< Number of RX queues. */
830         uint16_t nb_tx_queues; /**< Number of TX queues. */
831
832         struct rte_eth_dev_sriov sriov;    /**< SRIOV data */
833
834         void *dev_private;
835                         /**< PMD-specific private data.
836                          *   @see rte_eth_dev_release_port()
837                          */
838
839         struct rte_eth_link dev_link;   /**< Link-level information & status. */
840         struct rte_eth_conf dev_conf;   /**< Configuration applied to device. */
841         uint16_t mtu;                   /**< Maximum Transmission Unit. */
842         uint32_t min_rx_buf_size;
843                         /**< Common RX buffer size handled by all queues. */
844
845         uint64_t rx_mbuf_alloc_failed; /**< RX ring mbuf allocation failures. */
846         struct rte_ether_addr *mac_addrs;
847                         /**< Device Ethernet link address.
848                          *   @see rte_eth_dev_release_port()
849                          */
850         uint64_t mac_pool_sel[ETH_NUM_RECEIVE_MAC_ADDR];
851                         /**< Bitmap associating MAC addresses to pools. */
852         struct rte_ether_addr *hash_mac_addrs;
853                         /**< Device Ethernet MAC addresses of hash filtering.
854                          *   @see rte_eth_dev_release_port()
855                          */
856         uint16_t port_id;           /**< Device [external] port identifier. */
857
858         __extension__
859         uint8_t promiscuous   : 1, /**< RX promiscuous mode ON(1) / OFF(0). */
860                 scattered_rx : 1,  /**< RX of scattered packets is ON(1) / OFF(0) */
861                 all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
862                 dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
863                 lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
864         uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
865                 /**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
866         uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
867                 /**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
868         uint32_t dev_flags;             /**< Capabilities. */
869         enum rte_kernel_driver kdrv;    /**< Kernel driver passthrough. */
870         int numa_node;                  /**< NUMA node connection. */
871         struct rte_vlan_filter_conf vlan_filter_conf;
872                         /**< VLAN filter configuration. */
873         struct rte_eth_dev_owner owner; /**< The port owner. */
874         uint16_t representor_id;
875                         /**< Switch-specific identifier.
876                          *   Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags.
877                          */
878
879         uint64_t reserved_64s[4]; /**< Reserved for future fields */
880         void *reserved_ptrs[4];   /**< Reserved for future fields */
881 } __rte_cache_aligned;
882
883 /**
884  * @internal
885  * The pool of *rte_eth_dev* structures. The size of the pool
886  * is configured at compile-time in the <rte_ethdev.c> file.
887  */
888 extern struct rte_eth_dev rte_eth_devices[];
889
890 #endif /* _RTE_ETHDEV_CORE_H_ */