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