ethdev: add hairpin queue operations
[dpdk.git] / lib / librte_ethdev / rte_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 /**
9  * @file
10  *
11  * RTE Ethernet Device PMD API
12  *
13  * These APIs for the use from Ethernet drivers, user applications shouldn't
14  * use them.
15  *
16  */
17
18 #include <rte_ethdev.h>
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 /**< @internal Declaration of the hairpin peer queue information structure. */
25 struct rte_hairpin_peer_info;
26
27 /*
28  * Definitions of all functions exported by an Ethernet driver through the
29  * generic structure of type *eth_dev_ops* supplied in the *rte_eth_dev*
30  * structure associated with an Ethernet device.
31  */
32
33 typedef int  (*eth_dev_configure_t)(struct rte_eth_dev *dev);
34 /**< @internal Ethernet device configuration. */
35
36 typedef int  (*eth_dev_start_t)(struct rte_eth_dev *dev);
37 /**< @internal Function used to start a configured Ethernet device. */
38
39 typedef void (*eth_dev_stop_t)(struct rte_eth_dev *dev);
40 /**< @internal Function used to stop a configured Ethernet device. */
41
42 typedef int  (*eth_dev_set_link_up_t)(struct rte_eth_dev *dev);
43 /**< @internal Function used to link up a configured Ethernet device. */
44
45 typedef int  (*eth_dev_set_link_down_t)(struct rte_eth_dev *dev);
46 /**< @internal Function used to link down a configured Ethernet device. */
47
48 typedef int (*eth_dev_close_t)(struct rte_eth_dev *dev);
49 /**< @internal Function used to close a configured Ethernet device. */
50
51 typedef int (*eth_dev_reset_t)(struct rte_eth_dev *dev);
52 /** <@internal Function used to reset a configured Ethernet device. */
53
54 typedef int (*eth_is_removed_t)(struct rte_eth_dev *dev);
55 /**< @internal Function used to detect an Ethernet device removal. */
56
57 /**
58  * @internal
59  * Function used to enable the Rx promiscuous mode of an Ethernet device.
60  *
61  * @param dev
62  *   ethdev handle of port.
63  *
64  * @return
65  *   Negative errno value on error, 0 on success.
66  *
67  * @retval 0
68  *   Success, promiscuous mode is enabled.
69  * @retval -ENOTSUP
70  *   Promiscuous mode is not supported.
71  * @retval -ENODEV
72  *   Device is gone.
73  * @retval -E_RTE_SECONDARY
74  *   Function was called from a secondary process instance and not supported.
75  * @retval -ETIMEDOUT
76  *   Attempt to enable promiscuos mode failed because of timeout.
77  * @retval -EAGAIN
78  *   Failed to enable promiscuous mode.
79  */
80 typedef int (*eth_promiscuous_enable_t)(struct rte_eth_dev *dev);
81
82 /**
83  * @internal
84  * Function used to disable the Rx promiscuous mode of an Ethernet device.
85  *
86  * @param dev
87  *   ethdev handle of port.
88  *
89  * @return
90  *   Negative errno value on error, 0 on success.
91  *
92  * @retval 0
93  *   Success, promiscuous mode is disabled.
94  * @retval -ENOTSUP
95  *   Promiscuous mode disabling is not supported.
96  * @retval -ENODEV
97  *   Device is gone.
98  * @retval -E_RTE_SECONDARY
99  *   Function was called from a secondary process instance and not supported.
100  * @retval -ETIMEDOUT
101  *   Attempt to disable promiscuos mode failed because of timeout.
102  * @retval -EAGAIN
103  *   Failed to disable promiscuous mode.
104  */
105 typedef int (*eth_promiscuous_disable_t)(struct rte_eth_dev *dev);
106
107 /**
108  * @internal
109  * Enable the receipt of all multicast packets by an Ethernet device.
110  *
111  * @param dev
112  *   ethdev handle of port.
113  *
114  * @return
115  *   Negative errno value on error, 0 on success.
116  *
117  * @retval 0
118  *   Success, all-multicast mode is enabled.
119  * @retval -ENOTSUP
120  *   All-multicast mode is not supported.
121  * @retval -ENODEV
122  *   Device is gone.
123  * @retval -E_RTE_SECONDARY
124  *   Function was called from a secondary process instance and not supported.
125  * @retval -ETIMEDOUT
126  *   Attempt to enable all-multicast mode failed because of timeout.
127  * @retval -EAGAIN
128  *   Failed to enable all-multicast mode.
129  */
130 typedef int (*eth_allmulticast_enable_t)(struct rte_eth_dev *dev);
131
132 /**
133  * @internal
134  * Disable the receipt of all multicast packets by an Ethernet device.
135  *
136  * @param dev
137  *   ethdev handle of port.
138  *
139  * @return
140  *   Negative errno value on error, 0 on success.
141  *
142  * @retval 0
143  *   Success, all-multicast mode is disabled.
144  * @retval -ENOTSUP
145  *   All-multicast mode disabling is not supported.
146  * @retval -ENODEV
147  *   Device is gone.
148  * @retval -E_RTE_SECONDARY
149  *   Function was called from a secondary process instance and not supported.
150  * @retval -ETIMEDOUT
151  *   Attempt to disable all-multicast mode failed because of timeout.
152  * @retval -EAGAIN
153  *   Failed to disable all-multicast mode.
154  */
155 typedef int (*eth_allmulticast_disable_t)(struct rte_eth_dev *dev);
156
157 typedef int (*eth_link_update_t)(struct rte_eth_dev *dev,
158                                 int wait_to_complete);
159 /**< @internal Get link speed, duplex mode and state (up/down) of an Ethernet device. */
160
161 typedef int (*eth_stats_get_t)(struct rte_eth_dev *dev,
162                                 struct rte_eth_stats *igb_stats);
163 /**< @internal Get global I/O statistics of an Ethernet device. */
164
165 /**
166  * @internal
167  * Reset global I/O statistics of an Ethernet device to 0.
168  *
169  * @param dev
170  *   ethdev handle of port.
171  *
172  * @return
173  *   Negative errno value on error, 0 on success.
174  *
175  * @retval 0
176  *   Success, statistics has been reset.
177  * @retval -ENOTSUP
178  *   Resetting statistics is not supported.
179  * @retval -EINVAL
180  *   Resetting statistics is not valid.
181  * @retval -ENOMEM
182  *   Not enough memory to get the stats.
183  */
184 typedef int (*eth_stats_reset_t)(struct rte_eth_dev *dev);
185
186 typedef int (*eth_xstats_get_t)(struct rte_eth_dev *dev,
187         struct rte_eth_xstat *stats, unsigned int n);
188 /**< @internal Get extended stats of an Ethernet device. */
189
190 typedef int (*eth_xstats_get_by_id_t)(struct rte_eth_dev *dev,
191                                       const uint64_t *ids,
192                                       uint64_t *values,
193                                       unsigned int n);
194 /**< @internal Get extended stats of an Ethernet device. */
195
196 /**
197  * @internal
198  * Reset extended stats of an Ethernet device.
199  *
200  * @param dev
201  *   ethdev handle of port.
202  *
203  * @return
204  *   Negative errno value on error, 0 on success.
205  *
206  * @retval 0
207  *   Success, statistics has been reset.
208  * @retval -ENOTSUP
209  *   Resetting statistics is not supported.
210  * @retval -EINVAL
211  *   Resetting statistics is not valid.
212  * @retval -ENOMEM
213  *   Not enough memory to get the stats.
214  */
215 typedef int (*eth_xstats_reset_t)(struct rte_eth_dev *dev);
216
217 typedef int (*eth_xstats_get_names_t)(struct rte_eth_dev *dev,
218         struct rte_eth_xstat_name *xstats_names, unsigned int size);
219 /**< @internal Get names of extended stats of an Ethernet device. */
220
221 typedef int (*eth_xstats_get_names_by_id_t)(struct rte_eth_dev *dev,
222         struct rte_eth_xstat_name *xstats_names, const uint64_t *ids,
223         unsigned int size);
224 /**< @internal Get names of extended stats of an Ethernet device. */
225
226 typedef int (*eth_queue_stats_mapping_set_t)(struct rte_eth_dev *dev,
227                                              uint16_t queue_id,
228                                              uint8_t stat_idx,
229                                              uint8_t is_rx);
230 /**< @internal Set a queue statistics mapping for a tx/rx queue of an Ethernet device. */
231
232 typedef int (*eth_dev_infos_get_t)(struct rte_eth_dev *dev,
233                                    struct rte_eth_dev_info *dev_info);
234 /**< @internal Get specific information of an Ethernet device. */
235
236 typedef const uint32_t *(*eth_dev_supported_ptypes_get_t)(struct rte_eth_dev *dev);
237 /**< @internal Get supported ptypes of an Ethernet device. */
238
239 /**
240  * @internal
241  * Inform Ethernet device about reduced range of packet types to handle.
242  *
243  * @param dev
244  *   The Ethernet device identifier.
245  * @param ptype_mask
246  *   The ptype family that application is interested in should be bitwise OR of
247  *   RTE_PTYPE_*_MASK or 0.
248  * @return
249  *   - (0) if Success.
250  */
251 typedef int (*eth_dev_ptypes_set_t)(struct rte_eth_dev *dev,
252                                      uint32_t ptype_mask);
253
254 typedef int (*eth_queue_start_t)(struct rte_eth_dev *dev,
255                                     uint16_t queue_id);
256 /**< @internal Start rx and tx of a queue of an Ethernet device. */
257
258 typedef int (*eth_queue_stop_t)(struct rte_eth_dev *dev,
259                                     uint16_t queue_id);
260 /**< @internal Stop rx and tx of a queue of an Ethernet device. */
261
262 typedef int (*eth_rx_queue_setup_t)(struct rte_eth_dev *dev,
263                                     uint16_t rx_queue_id,
264                                     uint16_t nb_rx_desc,
265                                     unsigned int socket_id,
266                                     const struct rte_eth_rxconf *rx_conf,
267                                     struct rte_mempool *mb_pool);
268 /**< @internal Set up a receive queue of an Ethernet device. */
269
270 typedef int (*eth_tx_queue_setup_t)(struct rte_eth_dev *dev,
271                                     uint16_t tx_queue_id,
272                                     uint16_t nb_tx_desc,
273                                     unsigned int socket_id,
274                                     const struct rte_eth_txconf *tx_conf);
275 /**< @internal Setup a transmit queue of an Ethernet device. */
276
277 typedef int (*eth_rx_enable_intr_t)(struct rte_eth_dev *dev,
278                                     uint16_t rx_queue_id);
279 /**< @internal Enable interrupt of a receive queue of an Ethernet device. */
280
281 typedef int (*eth_rx_disable_intr_t)(struct rte_eth_dev *dev,
282                                     uint16_t rx_queue_id);
283 /**< @internal Disable interrupt of a receive queue of an Ethernet device. */
284
285 typedef void (*eth_queue_release_t)(void *queue);
286 /**< @internal Release memory resources allocated by given RX/TX queue. */
287
288 typedef int (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
289                                      char *fw_version, size_t fw_size);
290 /**< @internal Get firmware information of an Ethernet device. */
291
292 typedef int (*eth_tx_done_cleanup_t)(void *txq, uint32_t free_cnt);
293 /**< @internal Force mbufs to be from TX ring. */
294
295 typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
296         uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
297
298 typedef void (*eth_txq_info_get_t)(struct rte_eth_dev *dev,
299         uint16_t tx_queue_id, struct rte_eth_txq_info *qinfo);
300
301 typedef int (*eth_burst_mode_get_t)(struct rte_eth_dev *dev,
302         uint16_t queue_id, struct rte_eth_burst_mode *mode);
303
304 typedef int (*mtu_set_t)(struct rte_eth_dev *dev, uint16_t mtu);
305 /**< @internal Set MTU. */
306
307 typedef int (*vlan_filter_set_t)(struct rte_eth_dev *dev,
308                                   uint16_t vlan_id,
309                                   int on);
310 /**< @internal filtering of a VLAN Tag Identifier by an Ethernet device. */
311
312 typedef int (*vlan_tpid_set_t)(struct rte_eth_dev *dev,
313                                enum rte_vlan_type type, uint16_t tpid);
314 /**< @internal set the outer/inner VLAN-TPID by an Ethernet device. */
315
316 typedef int (*vlan_offload_set_t)(struct rte_eth_dev *dev, int mask);
317 /**< @internal set VLAN offload function by an Ethernet device. */
318
319 typedef int (*vlan_pvid_set_t)(struct rte_eth_dev *dev,
320                                uint16_t vlan_id,
321                                int on);
322 /**< @internal set port based TX VLAN insertion by an Ethernet device. */
323
324 typedef void (*vlan_strip_queue_set_t)(struct rte_eth_dev *dev,
325                                   uint16_t rx_queue_id,
326                                   int on);
327 /**< @internal VLAN stripping enable/disable by an queue of Ethernet device. */
328
329 typedef int (*flow_ctrl_get_t)(struct rte_eth_dev *dev,
330                                struct rte_eth_fc_conf *fc_conf);
331 /**< @internal Get current flow control parameter on an Ethernet device */
332
333 typedef int (*flow_ctrl_set_t)(struct rte_eth_dev *dev,
334                                struct rte_eth_fc_conf *fc_conf);
335 /**< @internal Setup flow control parameter on an Ethernet device */
336
337 typedef int (*priority_flow_ctrl_set_t)(struct rte_eth_dev *dev,
338                                 struct rte_eth_pfc_conf *pfc_conf);
339 /**< @internal Setup priority flow control parameter on an Ethernet device */
340
341 typedef int (*reta_update_t)(struct rte_eth_dev *dev,
342                              struct rte_eth_rss_reta_entry64 *reta_conf,
343                              uint16_t reta_size);
344 /**< @internal Update RSS redirection table on an Ethernet device */
345
346 typedef int (*reta_query_t)(struct rte_eth_dev *dev,
347                             struct rte_eth_rss_reta_entry64 *reta_conf,
348                             uint16_t reta_size);
349 /**< @internal Query RSS redirection table on an Ethernet device */
350
351 typedef int (*rss_hash_update_t)(struct rte_eth_dev *dev,
352                                  struct rte_eth_rss_conf *rss_conf);
353 /**< @internal Update RSS hash configuration of an Ethernet device */
354
355 typedef int (*rss_hash_conf_get_t)(struct rte_eth_dev *dev,
356                                    struct rte_eth_rss_conf *rss_conf);
357 /**< @internal Get current RSS hash configuration of an Ethernet device */
358
359 typedef int (*eth_dev_led_on_t)(struct rte_eth_dev *dev);
360 /**< @internal Turn on SW controllable LED on an Ethernet device */
361
362 typedef int (*eth_dev_led_off_t)(struct rte_eth_dev *dev);
363 /**< @internal Turn off SW controllable LED on an Ethernet device */
364
365 typedef void (*eth_mac_addr_remove_t)(struct rte_eth_dev *dev, uint32_t index);
366 /**< @internal Remove MAC address from receive address register */
367
368 typedef int (*eth_mac_addr_add_t)(struct rte_eth_dev *dev,
369                                   struct rte_ether_addr *mac_addr,
370                                   uint32_t index,
371                                   uint32_t vmdq);
372 /**< @internal Set a MAC address into Receive Address Register */
373
374 typedef int (*eth_mac_addr_set_t)(struct rte_eth_dev *dev,
375                                   struct rte_ether_addr *mac_addr);
376 /**< @internal Set a MAC address into Receive Address Register */
377
378 typedef int (*eth_uc_hash_table_set_t)(struct rte_eth_dev *dev,
379                                   struct rte_ether_addr *mac_addr,
380                                   uint8_t on);
381 /**< @internal Set a Unicast Hash bitmap */
382
383 typedef int (*eth_uc_all_hash_table_set_t)(struct rte_eth_dev *dev,
384                                   uint8_t on);
385 /**< @internal Set all Unicast Hash bitmap */
386
387 typedef int (*eth_set_queue_rate_limit_t)(struct rte_eth_dev *dev,
388                                 uint16_t queue_idx,
389                                 uint16_t tx_rate);
390 /**< @internal Set queue TX rate */
391
392 typedef int (*eth_mirror_rule_set_t)(struct rte_eth_dev *dev,
393                                   struct rte_eth_mirror_conf *mirror_conf,
394                                   uint8_t rule_id,
395                                   uint8_t on);
396 /**< @internal Add a traffic mirroring rule on an Ethernet device */
397
398 typedef int (*eth_mirror_rule_reset_t)(struct rte_eth_dev *dev,
399                                   uint8_t rule_id);
400 /**< @internal Remove a traffic mirroring rule on an Ethernet device */
401
402 typedef int (*eth_udp_tunnel_port_add_t)(struct rte_eth_dev *dev,
403                                          struct rte_eth_udp_tunnel *tunnel_udp);
404 /**< @internal Add tunneling UDP port */
405
406 typedef int (*eth_udp_tunnel_port_del_t)(struct rte_eth_dev *dev,
407                                          struct rte_eth_udp_tunnel *tunnel_udp);
408 /**< @internal Delete tunneling UDP port */
409
410 typedef int (*eth_set_mc_addr_list_t)(struct rte_eth_dev *dev,
411                                       struct rte_ether_addr *mc_addr_set,
412                                       uint32_t nb_mc_addr);
413 /**< @internal set the list of multicast addresses on an Ethernet device */
414
415 typedef int (*eth_timesync_enable_t)(struct rte_eth_dev *dev);
416 /**< @internal Function used to enable IEEE1588/802.1AS timestamping. */
417
418 typedef int (*eth_timesync_disable_t)(struct rte_eth_dev *dev);
419 /**< @internal Function used to disable IEEE1588/802.1AS timestamping. */
420
421 typedef int (*eth_timesync_read_rx_timestamp_t)(struct rte_eth_dev *dev,
422                                                 struct timespec *timestamp,
423                                                 uint32_t flags);
424 /**< @internal Function used to read an RX IEEE1588/802.1AS timestamp. */
425
426 typedef int (*eth_timesync_read_tx_timestamp_t)(struct rte_eth_dev *dev,
427                                                 struct timespec *timestamp);
428 /**< @internal Function used to read a TX IEEE1588/802.1AS timestamp. */
429
430 typedef int (*eth_timesync_adjust_time)(struct rte_eth_dev *dev, int64_t);
431 /**< @internal Function used to adjust the device clock */
432
433 typedef int (*eth_timesync_read_time)(struct rte_eth_dev *dev,
434                                       struct timespec *timestamp);
435 /**< @internal Function used to get time from the device clock. */
436
437 typedef int (*eth_timesync_write_time)(struct rte_eth_dev *dev,
438                                        const struct timespec *timestamp);
439 /**< @internal Function used to get time from the device clock */
440
441 typedef int (*eth_read_clock)(struct rte_eth_dev *dev,
442                                       uint64_t *timestamp);
443 /**< @internal Function used to get the current value of the device clock. */
444
445 typedef int (*eth_get_reg_t)(struct rte_eth_dev *dev,
446                                 struct rte_dev_reg_info *info);
447 /**< @internal Retrieve registers  */
448
449 typedef int (*eth_get_eeprom_length_t)(struct rte_eth_dev *dev);
450 /**< @internal Retrieve eeprom size  */
451
452 typedef int (*eth_get_eeprom_t)(struct rte_eth_dev *dev,
453                                 struct rte_dev_eeprom_info *info);
454 /**< @internal Retrieve eeprom data  */
455
456 typedef int (*eth_set_eeprom_t)(struct rte_eth_dev *dev,
457                                 struct rte_dev_eeprom_info *info);
458 /**< @internal Program eeprom data  */
459
460 typedef int (*eth_get_module_info_t)(struct rte_eth_dev *dev,
461                                      struct rte_eth_dev_module_info *modinfo);
462 /**< @internal Retrieve type and size of plugin module eeprom */
463
464 typedef int (*eth_get_module_eeprom_t)(struct rte_eth_dev *dev,
465                                        struct rte_dev_eeprom_info *info);
466 /**< @internal Retrieve plugin module eeprom data */
467
468 typedef int (*eth_l2_tunnel_eth_type_conf_t)
469         (struct rte_eth_dev *dev, struct rte_eth_l2_tunnel_conf *l2_tunnel);
470 /**< @internal config l2 tunnel ether type */
471
472 typedef int (*eth_l2_tunnel_offload_set_t)
473         (struct rte_eth_dev *dev,
474          struct rte_eth_l2_tunnel_conf *l2_tunnel,
475          uint32_t mask,
476          uint8_t en);
477 /**< @internal enable/disable the l2 tunnel offload functions */
478
479
480 typedef int (*eth_filter_ctrl_t)(struct rte_eth_dev *dev,
481                                  enum rte_filter_type filter_type,
482                                  enum rte_filter_op filter_op,
483                                  void *arg);
484 /**< @internal Take operations to assigned filter type on an Ethernet device */
485
486 typedef int (*eth_tm_ops_get_t)(struct rte_eth_dev *dev, void *ops);
487 /**< @internal Get Traffic Management (TM) operations on an Ethernet device */
488
489 typedef int (*eth_mtr_ops_get_t)(struct rte_eth_dev *dev, void *ops);
490 /**< @internal Get Traffic Metering and Policing (MTR) operations */
491
492 typedef int (*eth_get_dcb_info)(struct rte_eth_dev *dev,
493                                  struct rte_eth_dcb_info *dcb_info);
494 /**< @internal Get dcb information on an Ethernet device */
495
496 typedef int (*eth_pool_ops_supported_t)(struct rte_eth_dev *dev,
497                                                 const char *pool);
498 /**< @internal Test if a port supports specific mempool ops */
499
500 /**
501  * @internal
502  * Get the hairpin capabilities.
503  *
504  * @param dev
505  *   ethdev handle of port.
506  * @param cap
507  *   returns the hairpin capabilities from the device.
508  *
509  * @return
510  *   Negative errno value on error, 0 on success.
511  *
512  * @retval 0
513  *   Success, hairpin is supported.
514  * @retval -ENOTSUP
515  *   Hairpin is not supported.
516  */
517 typedef int (*eth_hairpin_cap_get_t)(struct rte_eth_dev *dev,
518                                      struct rte_eth_hairpin_cap *cap);
519
520 /**
521  * @internal
522  * Setup RX hairpin queue.
523  *
524  * @param dev
525  *   ethdev handle of port.
526  * @param rx_queue_id
527  *   the selected RX queue index.
528  * @param nb_rx_desc
529  *   the requested number of descriptors for this queue. 0 - use PMD default.
530  * @param conf
531  *   the RX hairpin configuration structure.
532  *
533  * @return
534  *   Negative errno value on error, 0 on success.
535  *
536  * @retval 0
537  *   Success, hairpin is supported.
538  * @retval -ENOTSUP
539  *   Hairpin is not supported.
540  * @retval -EINVAL
541  *   One of the parameters is invalid.
542  * @retval -ENOMEM
543  *   Unable to allocate resources.
544  */
545 typedef int (*eth_rx_hairpin_queue_setup_t)
546         (struct rte_eth_dev *dev, uint16_t rx_queue_id,
547          uint16_t nb_rx_desc,
548          const struct rte_eth_hairpin_conf *conf);
549
550 /**
551  * @internal
552  * Setup TX hairpin queue.
553  *
554  * @param dev
555  *   ethdev handle of port.
556  * @param tx_queue_id
557  *   the selected TX queue index.
558  * @param nb_tx_desc
559  *   the requested number of descriptors for this queue. 0 - use PMD default.
560  * @param conf
561  *   the TX hairpin configuration structure.
562  *
563  * @return
564  *   Negative errno value on error, 0 on success.
565  *
566  * @retval 0
567  *   Success, hairpin is supported.
568  * @retval -ENOTSUP
569  *   Hairpin is not supported.
570  * @retval -EINVAL
571  *   One of the parameters is invalid.
572  * @retval -ENOMEM
573  *   Unable to allocate resources.
574  */
575 typedef int (*eth_tx_hairpin_queue_setup_t)
576         (struct rte_eth_dev *dev, uint16_t tx_queue_id,
577          uint16_t nb_tx_desc,
578          const struct rte_eth_hairpin_conf *hairpin_conf);
579
580 /**
581  * @internal
582  * Get Forward Error Correction(FEC) capability.
583  *
584  * @param dev
585  *   ethdev handle of port.
586  * @param speed_fec_capa
587  *   speed_fec_capa is out only with per-speed capabilities.
588  * @param num
589  *   a number of elements in an speed_fec_capa array.
590  *
591  * @return
592  *   Negative errno value on error, positive value on success.
593  *
594  * @retval positive value
595  *   A non-negative value lower or equal to num: success. The return value
596  *   is the number of entries filled in the fec capa array.
597  *   A non-negative value higher than num: error, the given fec capa array
598  *   is too small. The return value corresponds to the num that should
599  *   be given to succeed. The entries in the fec capa array are not valid
600  *   and shall not be used by the caller.
601  * @retval -ENOTSUP
602  *   Operation is not supported.
603  * @retval -EIO
604  *   Device is removed.
605  * @retval -EINVAL
606  *   *num* or *speed_fec_capa* invalid.
607  */
608 typedef int (*eth_fec_get_capability_t)(struct rte_eth_dev *dev,
609                 struct rte_eth_fec_capa *speed_fec_capa, unsigned int num);
610
611 /**
612  * @internal
613  * Get Forward Error Correction(FEC) mode.
614  *
615  * @param dev
616  *   ethdev handle of port.
617  * @param fec_capa
618  *   a bitmask of enabled FEC modes. If AUTO bit is set, other
619  *   bits specify FEC modes which may be negotiated. If AUTO
620  *   bit is clear, specify FEC modes to be used (only one valid
621  *   mode per speed may be set).
622  *
623  * @return
624  *   Negative errno value on error, 0 on success.
625  *
626  * @retval 0
627  *   Success, get FEC success.
628  * @retval -ENOTSUP
629  *   Operation is not supported.
630  * @retval -EIO
631  *   Device is removed.
632  */
633 typedef int (*eth_fec_get_t)(struct rte_eth_dev *dev,
634                              uint32_t *fec_capa);
635
636 /**
637  * @internal
638  * Set Forward Error Correction(FEC) mode.
639  *
640  * @param dev
641  *   ethdev handle of port.
642  * @param fec_capa
643  *   bitmask of allowed FEC modes. It must be only one
644  *   if AUTO is disabled. If AUTO is enabled, other
645  *   bits specify FEC modes which may be negotiated.
646  *
647  * @return
648  *   Negative errno value on error, 0 on success.
649  *
650  * @retval 0
651  *   Success, set FEC success.
652  * @retval -ENOTSUP
653  *   Operation is not supported.
654  * @retval -EINVAL
655  *   Unsupported FEC mode requested.
656  * @retval -EIO
657  *   Device is removed.
658  */
659 typedef int (*eth_fec_set_t)(struct rte_eth_dev *dev, uint32_t fec_capa);
660
661 /**
662  * @internal
663  * Get all hairpin Tx/Rx peer ports of the current device, if any.
664  *
665  * @param dev
666  *   ethdev handle of port.
667  * @param peer_ports
668  *   array to save the ports list.
669  * @param len
670  *   array length.
671  * @param direction
672  *   value to decide the current to peer direction
673  *   positive - used as Tx to get all peer Rx ports.
674  *   zero - used as Rx to get all peer Tx ports.
675  *
676  * @return
677  *   Negative errno value on error, 0 or positive on success.
678  *
679  * @retval 0
680  *   Success, no peer ports.
681  * @retval >0
682  *   Actual number of the peer ports.
683  * @retval -ENOTSUP
684  *   Get peer ports API is not supported.
685  * @retval -EINVAL
686  *   One of the parameters is invalid.
687  */
688 typedef int (*hairpin_get_peer_ports_t)(struct rte_eth_dev *dev,
689                                         uint16_t *peer_ports, size_t len,
690                                         uint32_t direction);
691
692 /**
693  * @internal
694  * Bind all hairpin Tx queues of one port to the Rx queues of the peer port.
695  *
696  * @param dev
697  *   ethdev handle of port.
698  * @param rx_port
699  *   the peer Rx port.
700  *
701  * @return
702  *   Negative errno value on error, 0 on success.
703  *
704  * @retval 0
705  *   Success, bind successfully.
706  * @retval -ENOTSUP
707  *   Bind API is not supported.
708  * @retval -EINVAL
709  *   One of the parameters is invalid.
710  * @retval -EBUSY
711  *   Device is not started.
712  */
713 typedef int (*eth_hairpin_bind_t)(struct rte_eth_dev *dev,
714                                 uint16_t rx_port);
715
716 /**
717  * @internal
718  * Unbind all hairpin Tx queues of one port from the Rx queues of the peer port.
719  *
720  * @param dev
721  *   ethdev handle of port.
722  * @param rx_port
723  *   the peer Rx port.
724  *
725  * @return
726  *   Negative errno value on error, 0 on success.
727  *
728  * @retval 0
729  *   Success, unbind successfully.
730  * @retval -ENOTSUP
731  *   Bind API is not supported.
732  * @retval -EINVAL
733  *   One of the parameters is invalid.
734  * @retval -EBUSY
735  *   Device is already stopped.
736  */
737 typedef int (*eth_hairpin_unbind_t)(struct rte_eth_dev *dev,
738                                   uint16_t rx_port);
739
740 typedef int (*eth_hairpin_queue_peer_update_t)
741         (struct rte_eth_dev *dev, uint16_t peer_queue,
742          struct rte_hairpin_peer_info *current_info,
743          struct rte_hairpin_peer_info *peer_info, uint32_t direction);
744 /**< @internal Update and fetch peer queue information. */
745
746 typedef int (*eth_hairpin_queue_peer_bind_t)
747         (struct rte_eth_dev *dev, uint16_t cur_queue,
748          struct rte_hairpin_peer_info *peer_info, uint32_t direction);
749 /**< @internal Bind peer queue to the current queue with fetched information. */
750
751 typedef int (*eth_hairpin_queue_peer_unbind_t)
752         (struct rte_eth_dev *dev, uint16_t cur_queue, uint32_t direction);
753 /**< @internal Unbind peer queue from the current queue. */
754
755 /**
756  * @internal A structure containing the functions exported by an Ethernet driver.
757  */
758 struct eth_dev_ops {
759         eth_dev_configure_t        dev_configure; /**< Configure device. */
760         eth_dev_start_t            dev_start;     /**< Start device. */
761         eth_dev_stop_t             dev_stop;      /**< Stop device. */
762         eth_dev_set_link_up_t      dev_set_link_up;   /**< Device link up. */
763         eth_dev_set_link_down_t    dev_set_link_down; /**< Device link down. */
764         eth_dev_close_t            dev_close;     /**< Close device. */
765         eth_dev_reset_t            dev_reset;     /**< Reset device. */
766         eth_link_update_t          link_update;   /**< Get device link state. */
767         eth_is_removed_t           is_removed;
768         /**< Check if the device was physically removed. */
769
770         eth_promiscuous_enable_t   promiscuous_enable; /**< Promiscuous ON. */
771         eth_promiscuous_disable_t  promiscuous_disable;/**< Promiscuous OFF. */
772         eth_allmulticast_enable_t  allmulticast_enable;/**< RX multicast ON. */
773         eth_allmulticast_disable_t allmulticast_disable;/**< RX multicast OFF. */
774         eth_mac_addr_remove_t      mac_addr_remove; /**< Remove MAC address. */
775         eth_mac_addr_add_t         mac_addr_add;  /**< Add a MAC address. */
776         eth_mac_addr_set_t         mac_addr_set;  /**< Set a MAC address. */
777         eth_set_mc_addr_list_t     set_mc_addr_list; /**< set list of mcast addrs. */
778         mtu_set_t                  mtu_set;       /**< Set MTU. */
779
780         eth_stats_get_t            stats_get;     /**< Get generic device statistics. */
781         eth_stats_reset_t          stats_reset;   /**< Reset generic device statistics. */
782         eth_xstats_get_t           xstats_get;    /**< Get extended device statistics. */
783         eth_xstats_reset_t         xstats_reset;  /**< Reset extended device statistics. */
784         eth_xstats_get_names_t     xstats_get_names;
785         /**< Get names of extended statistics. */
786         eth_queue_stats_mapping_set_t queue_stats_mapping_set;
787         /**< Configure per queue stat counter mapping. */
788
789         eth_dev_infos_get_t        dev_infos_get; /**< Get device info. */
790         eth_rxq_info_get_t         rxq_info_get; /**< retrieve RX queue information. */
791         eth_txq_info_get_t         txq_info_get; /**< retrieve TX queue information. */
792         eth_burst_mode_get_t       rx_burst_mode_get; /**< Get RX burst mode */
793         eth_burst_mode_get_t       tx_burst_mode_get; /**< Get TX burst mode */
794         eth_fw_version_get_t       fw_version_get; /**< Get firmware version. */
795         eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
796         /**< Get packet types supported and identified by device. */
797         eth_dev_ptypes_set_t dev_ptypes_set;
798         /**< Inform Ethernet device about reduced range of packet types to handle. */
799
800         vlan_filter_set_t          vlan_filter_set; /**< Filter VLAN Setup. */
801         vlan_tpid_set_t            vlan_tpid_set; /**< Outer/Inner VLAN TPID Setup. */
802         vlan_strip_queue_set_t     vlan_strip_queue_set; /**< VLAN Stripping on queue. */
803         vlan_offload_set_t         vlan_offload_set; /**< Set VLAN Offload. */
804         vlan_pvid_set_t            vlan_pvid_set; /**< Set port based TX VLAN insertion. */
805
806         eth_queue_start_t          rx_queue_start;/**< Start RX for a queue. */
807         eth_queue_stop_t           rx_queue_stop; /**< Stop RX for a queue. */
808         eth_queue_start_t          tx_queue_start;/**< Start TX for a queue. */
809         eth_queue_stop_t           tx_queue_stop; /**< Stop TX for a queue. */
810         eth_rx_queue_setup_t       rx_queue_setup;/**< Set up device RX queue. */
811         eth_queue_release_t        rx_queue_release; /**< Release RX queue. */
812
813         eth_rx_enable_intr_t       rx_queue_intr_enable;  /**< Enable Rx queue interrupt. */
814         eth_rx_disable_intr_t      rx_queue_intr_disable; /**< Disable Rx queue interrupt. */
815         eth_tx_queue_setup_t       tx_queue_setup;/**< Set up device TX queue. */
816         eth_queue_release_t        tx_queue_release; /**< Release TX queue. */
817         eth_tx_done_cleanup_t      tx_done_cleanup;/**< Free tx ring mbufs */
818
819         eth_dev_led_on_t           dev_led_on;    /**< Turn on LED. */
820         eth_dev_led_off_t          dev_led_off;   /**< Turn off LED. */
821
822         flow_ctrl_get_t            flow_ctrl_get; /**< Get flow control. */
823         flow_ctrl_set_t            flow_ctrl_set; /**< Setup flow control. */
824         priority_flow_ctrl_set_t   priority_flow_ctrl_set; /**< Setup priority flow control. */
825
826         eth_uc_hash_table_set_t    uc_hash_table_set; /**< Set Unicast Table Array. */
827         eth_uc_all_hash_table_set_t uc_all_hash_table_set; /**< Set Unicast hash bitmap. */
828
829         eth_mirror_rule_set_t      mirror_rule_set; /**< Add a traffic mirror rule. */
830         eth_mirror_rule_reset_t    mirror_rule_reset; /**< reset a traffic mirror rule. */
831
832         eth_udp_tunnel_port_add_t  udp_tunnel_port_add; /** Add UDP tunnel port. */
833         eth_udp_tunnel_port_del_t  udp_tunnel_port_del; /** Del UDP tunnel port. */
834         eth_l2_tunnel_eth_type_conf_t l2_tunnel_eth_type_conf;
835         /** Config ether type of l2 tunnel. */
836         eth_l2_tunnel_offload_set_t   l2_tunnel_offload_set;
837         /** Enable/disable l2 tunnel offload functions. */
838
839         eth_set_queue_rate_limit_t set_queue_rate_limit; /**< Set queue rate limit. */
840
841         rss_hash_update_t          rss_hash_update; /** Configure RSS hash protocols. */
842         rss_hash_conf_get_t        rss_hash_conf_get; /** Get current RSS hash configuration. */
843         reta_update_t              reta_update;   /** Update redirection table. */
844         reta_query_t               reta_query;    /** Query redirection table. */
845
846         eth_get_reg_t              get_reg;           /**< Get registers. */
847         eth_get_eeprom_length_t    get_eeprom_length; /**< Get eeprom length. */
848         eth_get_eeprom_t           get_eeprom;        /**< Get eeprom data. */
849         eth_set_eeprom_t           set_eeprom;        /**< Set eeprom. */
850
851         eth_get_module_info_t      get_module_info;
852         /** Get plugin module eeprom attribute. */
853         eth_get_module_eeprom_t    get_module_eeprom;
854         /** Get plugin module eeprom data. */
855
856         eth_filter_ctrl_t          filter_ctrl; /**< common filter control. */
857
858         eth_get_dcb_info           get_dcb_info; /** Get DCB information. */
859
860         eth_timesync_enable_t      timesync_enable;
861         /** Turn IEEE1588/802.1AS timestamping on. */
862         eth_timesync_disable_t     timesync_disable;
863         /** Turn IEEE1588/802.1AS timestamping off. */
864         eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp;
865         /** Read the IEEE1588/802.1AS RX timestamp. */
866         eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp;
867         /** Read the IEEE1588/802.1AS TX timestamp. */
868         eth_timesync_adjust_time   timesync_adjust_time; /** Adjust the device clock. */
869         eth_timesync_read_time     timesync_read_time; /** Get the device clock time. */
870         eth_timesync_write_time    timesync_write_time; /** Set the device clock time. */
871
872         eth_read_clock             read_clock;
873
874         eth_xstats_get_by_id_t     xstats_get_by_id;
875         /**< Get extended device statistic values by ID. */
876         eth_xstats_get_names_by_id_t xstats_get_names_by_id;
877         /**< Get name of extended device statistics by ID. */
878
879         eth_tm_ops_get_t tm_ops_get;
880         /**< Get Traffic Management (TM) operations. */
881
882         eth_mtr_ops_get_t mtr_ops_get;
883         /**< Get Traffic Metering and Policing (MTR) operations. */
884
885         eth_pool_ops_supported_t pool_ops_supported;
886         /**< Test if a port supports specific mempool ops */
887
888         eth_hairpin_cap_get_t hairpin_cap_get;
889         /**< Returns the hairpin capabilities. */
890         eth_rx_hairpin_queue_setup_t rx_hairpin_queue_setup;
891         /**< Set up device RX hairpin queue. */
892         eth_tx_hairpin_queue_setup_t tx_hairpin_queue_setup;
893         /**< Set up device TX hairpin queue. */
894
895         eth_fec_get_capability_t fec_get_capability;
896         /**< Get Forward Error Correction(FEC) capability. */
897         eth_fec_get_t fec_get;
898         /**< Get Forward Error Correction(FEC) mode. */
899         eth_fec_set_t fec_set;
900         /**< Set Forward Error Correction(FEC) mode. */
901         hairpin_get_peer_ports_t hairpin_get_peer_ports;
902         /**< Get hairpin peer ports list. */
903         eth_hairpin_bind_t hairpin_bind;
904         /**< Bind all hairpin Tx queues of device to the peer port Rx queues. */
905         eth_hairpin_unbind_t hairpin_unbind;
906         /**< Unbind all hairpin Tx queues from the peer port Rx queues. */
907         eth_hairpin_queue_peer_update_t hairpin_queue_peer_update;
908         /**< Pass the current queue info and get the peer queue info. */
909         eth_hairpin_queue_peer_bind_t hairpin_queue_peer_bind;
910         /**< Set up the connection between the pair of hairpin queues. */
911         eth_hairpin_queue_peer_unbind_t hairpin_queue_peer_unbind;
912         /**< Disconnect the hairpin queues of a pair from each other. */
913 };
914
915 /**
916  * RX/TX queue states
917  */
918 #define RTE_ETH_QUEUE_STATE_STOPPED 0
919 #define RTE_ETH_QUEUE_STATE_STARTED 1
920 #define RTE_ETH_QUEUE_STATE_HAIRPIN 2
921
922 /**
923  * @internal
924  * Check if the selected Rx queue is hairpin queue.
925  *
926  * @param dev
927  *  Pointer to the selected device.
928  * @param queue_id
929  *  The selected queue.
930  *
931  * @return
932  *   - (1) if the queue is hairpin queue, 0 otherwise.
933  */
934 __rte_internal
935 int rte_eth_dev_is_rx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id);
936
937 /**
938  * @internal
939  * Check if the selected Tx queue is hairpin queue.
940  *
941  * @param dev
942  *  Pointer to the selected device.
943  * @param queue_id
944  *  The selected queue.
945  *
946  * @return
947  *   - (1) if the queue is hairpin queue, 0 otherwise.
948  */
949 __rte_internal
950 int rte_eth_dev_is_tx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id);
951
952 /**
953  * @internal
954  * Returns a ethdev slot specified by the unique identifier name.
955  *
956  * @param       name
957  *  The pointer to the Unique identifier name for each Ethernet device
958  * @return
959  *   - The pointer to the ethdev slot, on success. NULL on error
960  */
961 __rte_internal
962 struct rte_eth_dev *rte_eth_dev_allocated(const char *name);
963
964 /**
965  * @internal
966  * Allocates a new ethdev slot for an ethernet device and returns the pointer
967  * to that slot for the driver to use.
968  *
969  * @param       name    Unique identifier name for each Ethernet device
970  * @return
971  *   - Slot in the rte_dev_devices array for a new device;
972  */
973 __rte_internal
974 struct rte_eth_dev *rte_eth_dev_allocate(const char *name);
975
976 /**
977  * @internal
978  * Attach to the ethdev already initialized by the primary
979  * process.
980  *
981  * @param       name    Ethernet device's name.
982  * @return
983  *   - Success: Slot in the rte_dev_devices array for attached
984  *        device.
985  *   - Error: Null pointer.
986  */
987 __rte_internal
988 struct rte_eth_dev *rte_eth_dev_attach_secondary(const char *name);
989
990 /**
991  * @internal
992  * Notify RTE_ETH_EVENT_DESTROY and release the specified ethdev port.
993  *
994  * The following PMD-managed data fields will be freed:
995  *   - dev_private
996  *   - mac_addrs
997  *   - hash_mac_addrs
998  * If one of these fields should not be freed,
999  * it must be reset to NULL by the PMD, typically in dev_close method.
1000  *
1001  * @param eth_dev
1002  * Device to be detached.
1003  * @return
1004  *   - 0 on success, negative on error
1005  */
1006 __rte_internal
1007 int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev);
1008
1009 /**
1010  * @internal
1011  * Release device queues and clear its configuration to force the user
1012  * application to reconfigure it. It is for internal use only.
1013  *
1014  * @param dev
1015  *  Pointer to struct rte_eth_dev.
1016  *
1017  * @return
1018  *  void
1019  */
1020 __rte_internal
1021 void rte_eth_dev_internal_reset(struct rte_eth_dev *dev);
1022
1023 /**
1024  * @internal Executes all the user application registered callbacks for
1025  * the specific device. It is for DPDK internal user only. User
1026  * application should not call it directly.
1027  *
1028  * @param dev
1029  *  Pointer to struct rte_eth_dev.
1030  * @param event
1031  *  Eth device interrupt event type.
1032  * @param ret_param
1033  *  To pass data back to user application.
1034  *  This allows the user application to decide if a particular function
1035  *  is permitted or not.
1036  *
1037  * @return
1038  *  int
1039  */
1040 __rte_internal
1041 int rte_eth_dev_callback_process(struct rte_eth_dev *dev,
1042                 enum rte_eth_event_type event, void *ret_param);
1043
1044 /**
1045  * @internal
1046  * This is the last step of device probing.
1047  * It must be called after a port is allocated and initialized successfully.
1048  *
1049  * The notification RTE_ETH_EVENT_NEW is sent to other entities
1050  * (libraries and applications).
1051  * The state is set as RTE_ETH_DEV_ATTACHED.
1052  *
1053  * @param dev
1054  *  New ethdev port.
1055  */
1056 __rte_internal
1057 void rte_eth_dev_probing_finish(struct rte_eth_dev *dev);
1058
1059 /**
1060  * Create memzone for HW rings.
1061  * malloc can't be used as the physical address is needed.
1062  * If the memzone is already created, then this function returns a ptr
1063  * to the old one.
1064  *
1065  * @param eth_dev
1066  *   The *eth_dev* pointer is the address of the *rte_eth_dev* structure
1067  * @param name
1068  *   The name of the memory zone
1069  * @param queue_id
1070  *   The index of the queue to add to name
1071  * @param size
1072  *   The sizeof of the memory area
1073  * @param align
1074  *   Alignment for resulting memzone. Must be a power of 2.
1075  * @param socket_id
1076  *   The *socket_id* argument is the socket identifier in case of NUMA.
1077  */
1078 __rte_internal
1079 const struct rte_memzone *
1080 rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name,
1081                          uint16_t queue_id, size_t size,
1082                          unsigned align, int socket_id);
1083
1084 /**
1085  * Free previously allocated memzone for HW rings.
1086  *
1087  * @param eth_dev
1088  *   The *eth_dev* pointer is the address of the *rte_eth_dev* structure
1089  * @param name
1090  *   The name of the memory zone
1091  * @param queue_id
1092  *   The index of the queue to add to name
1093  * @return
1094  *   Negative errno value on error, 0 on success.
1095  */
1096 __rte_internal
1097 int
1098 rte_eth_dma_zone_free(const struct rte_eth_dev *eth_dev, const char *name,
1099                  uint16_t queue_id);
1100
1101 /**
1102  * @internal
1103  * Atomically set the link status for the specific device.
1104  * It is for use by DPDK device driver use only.
1105  * User applications should not call it
1106  *
1107  * @param dev
1108  *  Pointer to struct rte_eth_dev.
1109  * @param link
1110  *  New link status value.
1111  * @return
1112  *  Same convention as eth_link_update operation.
1113  *  0   if link up status has changed
1114  *  -1  if link up status was unchanged
1115  */
1116 static inline int
1117 rte_eth_linkstatus_set(struct rte_eth_dev *dev,
1118                        const struct rte_eth_link *new_link)
1119 {
1120         uint64_t *dev_link = (uint64_t *)&(dev->data->dev_link);
1121         union {
1122                 uint64_t val64;
1123                 struct rte_eth_link link;
1124         } orig;
1125
1126         RTE_BUILD_BUG_ON(sizeof(*new_link) != sizeof(uint64_t));
1127
1128         orig.val64 = __atomic_exchange_n(dev_link, *(const uint64_t *)new_link,
1129                                         __ATOMIC_SEQ_CST);
1130
1131         return (orig.link.link_status == new_link->link_status) ? -1 : 0;
1132 }
1133
1134 /**
1135  * @internal
1136  * Atomically get the link speed and status.
1137  *
1138  * @param dev
1139  *  Pointer to struct rte_eth_dev.
1140  * @param link
1141  *  link status value.
1142  */
1143 static inline void
1144 rte_eth_linkstatus_get(const struct rte_eth_dev *dev,
1145                        struct rte_eth_link *link)
1146 {
1147         uint64_t *src = (uint64_t *)&(dev->data->dev_link);
1148         uint64_t *dst = (uint64_t *)link;
1149
1150         RTE_BUILD_BUG_ON(sizeof(*link) != sizeof(uint64_t));
1151
1152         *dst = __atomic_load_n(src, __ATOMIC_SEQ_CST);
1153 }
1154
1155 /**
1156  * Allocate an unique switch domain identifier.
1157  *
1158  * A pool of switch domain identifiers which can be allocated on request. This
1159  * will enabled devices which support the concept of switch domains to request
1160  * a switch domain id which is guaranteed to be unique from other devices
1161  * running in the same process.
1162  *
1163  * @param domain_id
1164  *  switch domain identifier parameter to pass back to application
1165  *
1166  * @return
1167  *   Negative errno value on error, 0 on success.
1168  */
1169 __rte_internal
1170 int
1171 rte_eth_switch_domain_alloc(uint16_t *domain_id);
1172
1173 /**
1174  * Free switch domain.
1175  *
1176  * Return a switch domain identifier to the pool of free identifiers after it is
1177  * no longer in use by device.
1178  *
1179  * @param domain_id
1180  *  switch domain identifier to free
1181  *
1182  * @return
1183  *   Negative errno value on error, 0 on success.
1184  */
1185 __rte_internal
1186 int
1187 rte_eth_switch_domain_free(uint16_t domain_id);
1188
1189 /** Generic Ethernet device arguments  */
1190 struct rte_eth_devargs {
1191         uint16_t ports[RTE_MAX_ETHPORTS];
1192         /** port/s number to enable on a multi-port single function */
1193         uint16_t nb_ports;
1194         /** number of ports in ports field */
1195         uint16_t representor_ports[RTE_MAX_ETHPORTS];
1196         /** representor port/s identifier to enable on device */
1197         uint16_t nb_representor_ports;
1198         /** number of ports in representor port field */
1199 };
1200
1201 /**
1202  * PMD helper function to parse ethdev arguments
1203  *
1204  * @param devargs
1205  *  device arguments
1206  * @param eth_devargs
1207  *  parsed ethdev specific arguments.
1208  *
1209  * @return
1210  *   Negative errno value on error, 0 on success.
1211  */
1212 __rte_internal
1213 int
1214 rte_eth_devargs_parse(const char *devargs, struct rte_eth_devargs *eth_devargs);
1215
1216
1217 typedef int (*ethdev_init_t)(struct rte_eth_dev *ethdev, void *init_params);
1218 typedef int (*ethdev_bus_specific_init)(struct rte_eth_dev *ethdev,
1219         void *bus_specific_init_params);
1220
1221 /**
1222  * PMD helper function for the creation of a new ethdev ports.
1223  *
1224  * @param device
1225  *  rte_device handle.
1226  * @param name
1227  *  port name.
1228  * @param priv_data_size
1229  *  size of private data required for port.
1230  * @param bus_specific_init
1231  *  port bus specific initialisation callback function
1232  * @param bus_init_params
1233  *  port bus specific initialisation parameters
1234  * @param ethdev_init
1235  *  device specific port initialization callback function
1236  * @param init_params
1237  *  port initialisation parameters
1238  *
1239  * @return
1240  *   Negative errno value on error, 0 on success.
1241  */
1242 __rte_internal
1243 int
1244 rte_eth_dev_create(struct rte_device *device, const char *name,
1245         size_t priv_data_size,
1246         ethdev_bus_specific_init bus_specific_init, void *bus_init_params,
1247         ethdev_init_t ethdev_init, void *init_params);
1248
1249
1250 typedef int (*ethdev_uninit_t)(struct rte_eth_dev *ethdev);
1251
1252 /**
1253  * PMD helper function for cleaning up the resources of a ethdev port on it's
1254  * destruction.
1255  *
1256  * @param ethdev
1257  *   ethdev handle of port.
1258  * @param ethdev_uninit
1259  *   device specific port un-initialise callback function
1260  *
1261  * @return
1262  *   Negative errno value on error, 0 on success.
1263  */
1264 __rte_internal
1265 int
1266 rte_eth_dev_destroy(struct rte_eth_dev *ethdev, ethdev_uninit_t ethdev_uninit);
1267
1268 /**
1269  * @internal
1270  * Pass the current hairpin queue HW and/or SW information to the peer queue
1271  * and fetch back the information of the peer queue.
1272  *
1273  * @param peer_port
1274  *  Peer port identifier of the Ethernet device.
1275  * @param peer_queue
1276  *  Peer queue index of the port.
1277  * @param cur_info
1278  *  Pointer to the current information structure.
1279  * @param peer_info
1280  *  Pointer to the peer information, output.
1281  * @param direction
1282  *  Direction to pass the information.
1283  *  positive - pass Tx queue information and get peer Rx queue information
1284  *  zero - pass Rx queue information and get peer Tx queue information
1285  *
1286  * @return
1287  *  Negative errno value on error, 0 on success.
1288  */
1289 __rte_internal
1290 int
1291 rte_eth_hairpin_queue_peer_update(uint16_t peer_port, uint16_t peer_queue,
1292                                   struct rte_hairpin_peer_info *cur_info,
1293                                   struct rte_hairpin_peer_info *peer_info,
1294                                   uint32_t direction);
1295
1296 /**
1297  * @internal
1298  * Configure current hairpin queue with the peer information fetched to create
1299  * the connection (bind) with peer queue in the specified direction.
1300  * This function might need to be called twice to fully create the connections.
1301  *
1302  * @param cur_port
1303  *  Current port identifier of the Ethernet device.
1304  * @param cur_queue
1305  *  Current queue index of the port.
1306  * @param peer_info
1307  *  Pointer to the peer information, input.
1308  * @param direction
1309  *  Direction to create the connection.
1310  *  positive - bind current Tx queue to peer Rx queue
1311  *  zero - bind current Rx queue to peer Tx queue
1312  *
1313  * @return
1314  *  Negative errno value on error, 0 on success.
1315  */
1316 __rte_internal
1317 int
1318 rte_eth_hairpin_queue_peer_bind(uint16_t cur_port, uint16_t cur_queue,
1319                                 struct rte_hairpin_peer_info *peer_info,
1320                                 uint32_t direction);
1321
1322 /**
1323  * @internal
1324  * Reset the current queue state and configuration to disconnect (unbind) it
1325  * from the peer queue.
1326  * This function might need to be called twice to disconnect each other.
1327  *
1328  * @param cur_port
1329  *  Current port identifier of the Ethernet device.
1330  * @param cur_queue
1331  *  Current queue index of the port.
1332  * @param direction
1333  *  Direction to destroy the connection.
1334  *  positive - unbind current Tx queue from peer Rx queue
1335  *  zero - unbind current Rx queue from peer Tx queue
1336  *
1337  * @return
1338  *  Negative errno value on error, 0 on success.
1339  */
1340 __rte_internal
1341 int
1342 rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t cur_queue,
1343                                   uint32_t direction);
1344
1345 #ifdef __cplusplus
1346 }
1347 #endif
1348
1349 #endif /* _RTE_ETHDEV_DRIVER_H_ */