1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2016 Cavium, Inc 3 */ 4 5 #ifndef _RTE_EVENTDEV_PMD_H_ 6 #define _RTE_EVENTDEV_PMD_H_ 7 8 /** @file 9 * RTE Event PMD APIs 10 * 11 * @note 12 * These API are from event PMD only and user applications should not call 13 * them directly. 14 */ 15 16 #include <string.h> 17 18 #include <rte_common.h> 19 #include <rte_compat.h> 20 #include <rte_config.h> 21 #include <rte_dev.h> 22 #include <rte_log.h> 23 #include <rte_malloc.h> 24 #include <rte_mbuf.h> 25 #include <rte_mbuf_dyn.h> 26 27 #include "event_timer_adapter_pmd.h" 28 #include "rte_eventdev.h" 29 30 /* Logging Macros */ 31 #define RTE_EDEV_LOG_ERR(...) \ 32 RTE_LOG(ERR, EVENTDEV, \ 33 RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \ 34 __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,))) 35 36 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG 37 #define RTE_EDEV_LOG_DEBUG(...) \ 38 RTE_LOG(DEBUG, EVENTDEV, \ 39 RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \ 40 __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,))) 41 #else 42 #define RTE_EDEV_LOG_DEBUG(...) (void)0 43 #endif 44 45 /* Macros to check for valid device */ 46 #define RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, retval) do { \ 47 if (!rte_event_pmd_is_valid_dev((dev_id))) { \ 48 RTE_EDEV_LOG_ERR("Invalid dev_id=%d\n", dev_id); \ 49 return retval; \ 50 } \ 51 } while (0) 52 53 #define RTE_EVENTDEV_VALID_DEVID_OR_ERRNO_RET(dev_id, errno, retval) do { \ 54 if (!rte_event_pmd_is_valid_dev((dev_id))) { \ 55 RTE_EDEV_LOG_ERR("Invalid dev_id=%d\n", dev_id); \ 56 rte_errno = errno; \ 57 return retval; \ 58 } \ 59 } while (0) 60 61 #define RTE_EVENTDEV_VALID_DEVID_OR_RET(dev_id) do { \ 62 if (!rte_event_pmd_is_valid_dev((dev_id))) { \ 63 RTE_EDEV_LOG_ERR("Invalid dev_id=%d\n", dev_id); \ 64 return; \ 65 } \ 66 } while (0) 67 68 #define RTE_EVENT_ETH_RX_ADAPTER_SW_CAP \ 69 ((RTE_EVENT_ETH_RX_ADAPTER_CAP_OVERRIDE_FLOW_ID) | \ 70 (RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ) | \ 71 (RTE_EVENT_ETH_RX_ADAPTER_CAP_EVENT_VECTOR)) 72 73 #define RTE_EVENT_CRYPTO_ADAPTER_SW_CAP \ 74 RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA 75 76 /**< Ethernet Rx adapter cap to return If the packet transfers from 77 * the ethdev to eventdev use a SW service function 78 */ 79 80 #define RTE_EVENTDEV_DETACHED (0) 81 #define RTE_EVENTDEV_ATTACHED (1) 82 83 #define RTE_EVENTDEV_NAME_MAX_LEN (64) 84 /**< @internal Max length of name of event PMD */ 85 86 struct rte_eth_dev; 87 88 /** Global structure used for maintaining state of allocated event devices */ 89 struct rte_eventdev_global { 90 uint8_t nb_devs; /**< Number of devices found */ 91 }; 92 93 /** 94 * @internal 95 * The data part, with no function pointers, associated with each device. 96 * 97 * This structure is safe to place in shared memory to be common among 98 * different processes in a multi-process configuration. 99 */ 100 struct rte_eventdev_data { 101 int socket_id; 102 /**< Socket ID where memory is allocated */ 103 uint8_t dev_id; 104 /**< Device ID for this instance */ 105 uint8_t nb_queues; 106 /**< Number of event queues. */ 107 uint8_t nb_ports; 108 /**< Number of event ports. */ 109 void *ports[RTE_EVENT_MAX_PORTS_PER_DEV]; 110 /**< Array of pointers to ports. */ 111 struct rte_event_port_conf ports_cfg[RTE_EVENT_MAX_PORTS_PER_DEV]; 112 /**< Array of port configuration structures. */ 113 struct rte_event_queue_conf queues_cfg[RTE_EVENT_MAX_QUEUES_PER_DEV]; 114 /**< Array of queue configuration structures. */ 115 uint16_t links_map[RTE_EVENT_MAX_PORTS_PER_DEV * 116 RTE_EVENT_MAX_QUEUES_PER_DEV]; 117 /**< Memory to store queues to port connections. */ 118 void *dev_private; 119 /**< PMD-specific private data */ 120 uint32_t event_dev_cap; 121 /**< Event device capabilities(RTE_EVENT_DEV_CAP_)*/ 122 struct rte_event_dev_config dev_conf; 123 /**< Configuration applied to device. */ 124 uint8_t service_inited; 125 /* Service initialization state */ 126 uint32_t service_id; 127 /* Service ID*/ 128 void *dev_stop_flush_arg; 129 /**< User-provided argument for event flush function */ 130 131 RTE_STD_C11 132 uint8_t dev_started : 1; 133 /**< Device state: STARTED(1)/STOPPED(0) */ 134 135 char name[RTE_EVENTDEV_NAME_MAX_LEN]; 136 /**< Unique identifier name */ 137 138 uint64_t reserved_64s[4]; /**< Reserved for future fields */ 139 void *reserved_ptrs[4]; /**< Reserved for future fields */ 140 } __rte_cache_aligned; 141 142 /** @internal The data structure associated with each event device. */ 143 struct rte_eventdev { 144 struct rte_eventdev_data *data; 145 /**< Pointer to device data */ 146 struct eventdev_ops *dev_ops; 147 /**< Functions exported by PMD */ 148 struct rte_device *dev; 149 /**< Device info. supplied by probing */ 150 151 RTE_STD_C11 152 uint8_t attached : 1; 153 /**< Flag indicating the device is attached */ 154 155 event_enqueue_t enqueue; 156 /**< Pointer to PMD enqueue function. */ 157 event_enqueue_burst_t enqueue_burst; 158 /**< Pointer to PMD enqueue burst function. */ 159 event_enqueue_burst_t enqueue_new_burst; 160 /**< Pointer to PMD enqueue burst function(op new variant) */ 161 event_enqueue_burst_t enqueue_forward_burst; 162 /**< Pointer to PMD enqueue burst function(op forward variant) */ 163 event_dequeue_t dequeue; 164 /**< Pointer to PMD dequeue function. */ 165 event_dequeue_burst_t dequeue_burst; 166 /**< Pointer to PMD dequeue burst function. */ 167 event_tx_adapter_enqueue_t txa_enqueue_same_dest; 168 /**< Pointer to PMD eth Tx adapter burst enqueue function with 169 * events destined to same Eth port & Tx queue. 170 */ 171 event_tx_adapter_enqueue_t txa_enqueue; 172 /**< Pointer to PMD eth Tx adapter enqueue function. */ 173 event_crypto_adapter_enqueue_t ca_enqueue; 174 175 uint64_t reserved_64s[4]; /**< Reserved for future fields */ 176 void *reserved_ptrs[3]; /**< Reserved for future fields */ 177 } __rte_cache_aligned; 178 179 extern struct rte_eventdev *rte_eventdevs; 180 /** @internal The pool of rte_eventdev structures. */ 181 182 /** 183 * Get the rte_eventdev structure device pointer for the named device. 184 * 185 * @param name 186 * device name to select the device structure. 187 * 188 * @return 189 * - The rte_eventdev structure pointer for the given device ID. 190 */ 191 __rte_internal 192 static inline struct rte_eventdev * 193 rte_event_pmd_get_named_dev(const char *name) 194 { 195 struct rte_eventdev *dev; 196 unsigned int i; 197 198 if (name == NULL) 199 return NULL; 200 201 for (i = 0; i < RTE_EVENT_MAX_DEVS; i++) { 202 dev = &rte_eventdevs[i]; 203 if ((dev->attached == RTE_EVENTDEV_ATTACHED) && 204 (strcmp(dev->data->name, name) == 0)) 205 return dev; 206 } 207 208 return NULL; 209 } 210 211 /** 212 * Validate if the event device index is valid attached event device. 213 * 214 * @param dev_id 215 * Event device index. 216 * 217 * @return 218 * - If the device index is valid (1) or not (0). 219 */ 220 __rte_internal 221 static inline unsigned 222 rte_event_pmd_is_valid_dev(uint8_t dev_id) 223 { 224 struct rte_eventdev *dev; 225 226 if (dev_id >= RTE_EVENT_MAX_DEVS) 227 return 0; 228 229 dev = &rte_eventdevs[dev_id]; 230 if (dev->attached != RTE_EVENTDEV_ATTACHED) 231 return 0; 232 else 233 return 1; 234 } 235 236 /** 237 * Definitions of all functions exported by a driver through the 238 * the generic structure of type *event_dev_ops* supplied in the 239 * *rte_eventdev* structure associated with a device. 240 */ 241 242 /** 243 * Get device information of a device. 244 * 245 * @param dev 246 * Event device pointer 247 * @param dev_info 248 * Event device information structure 249 */ 250 typedef void (*eventdev_info_get_t)(struct rte_eventdev *dev, 251 struct rte_event_dev_info *dev_info); 252 253 /** 254 * Configure a device. 255 * 256 * @param dev 257 * Event device pointer 258 * 259 * @return 260 * Returns 0 on success 261 */ 262 typedef int (*eventdev_configure_t)(const struct rte_eventdev *dev); 263 264 /** 265 * Start a configured device. 266 * 267 * @param dev 268 * Event device pointer 269 * 270 * @return 271 * Returns 0 on success 272 */ 273 typedef int (*eventdev_start_t)(struct rte_eventdev *dev); 274 275 /** 276 * Stop a configured device. 277 * 278 * @param dev 279 * Event device pointer 280 */ 281 typedef void (*eventdev_stop_t)(struct rte_eventdev *dev); 282 283 /** 284 * Close a configured device. 285 * 286 * @param dev 287 * Event device pointer 288 * 289 * @return 290 * - 0 on success 291 * - (-EAGAIN) if can't close as device is busy 292 */ 293 typedef int (*eventdev_close_t)(struct rte_eventdev *dev); 294 295 /** 296 * Retrieve the default event queue configuration. 297 * 298 * @param dev 299 * Event device pointer 300 * @param queue_id 301 * Event queue index 302 * @param[out] queue_conf 303 * Event queue configuration structure 304 * 305 */ 306 typedef void (*eventdev_queue_default_conf_get_t)(struct rte_eventdev *dev, 307 uint8_t queue_id, struct rte_event_queue_conf *queue_conf); 308 309 /** 310 * Setup an event queue. 311 * 312 * @param dev 313 * Event device pointer 314 * @param queue_id 315 * Event queue index 316 * @param queue_conf 317 * Event queue configuration structure 318 * 319 * @return 320 * Returns 0 on success. 321 */ 322 typedef int (*eventdev_queue_setup_t)(struct rte_eventdev *dev, 323 uint8_t queue_id, 324 const struct rte_event_queue_conf *queue_conf); 325 326 /** 327 * Release resources allocated by given event queue. 328 * 329 * @param dev 330 * Event device pointer 331 * @param queue_id 332 * Event queue index 333 * 334 */ 335 typedef void (*eventdev_queue_release_t)(struct rte_eventdev *dev, 336 uint8_t queue_id); 337 338 /** 339 * Retrieve the default event port configuration. 340 * 341 * @param dev 342 * Event device pointer 343 * @param port_id 344 * Event port index 345 * @param[out] port_conf 346 * Event port configuration structure 347 * 348 */ 349 typedef void (*eventdev_port_default_conf_get_t)(struct rte_eventdev *dev, 350 uint8_t port_id, struct rte_event_port_conf *port_conf); 351 352 /** 353 * Setup an event port. 354 * 355 * @param dev 356 * Event device pointer 357 * @param port_id 358 * Event port index 359 * @param port_conf 360 * Event port configuration structure 361 * 362 * @return 363 * Returns 0 on success. 364 */ 365 typedef int (*eventdev_port_setup_t)(struct rte_eventdev *dev, 366 uint8_t port_id, 367 const struct rte_event_port_conf *port_conf); 368 369 /** 370 * Release memory resources allocated by given event port. 371 * 372 * @param port 373 * Event port pointer 374 * 375 */ 376 typedef void (*eventdev_port_release_t)(void *port); 377 378 /** 379 * Link multiple source event queues to destination event port. 380 * 381 * @param dev 382 * Event device pointer 383 * @param port 384 * Event port pointer 385 * @param queues 386 * Points to an array of *nb_links* event queues to be linked 387 * to the event port. 388 * @param priorities 389 * Points to an array of *nb_links* service priorities associated with each 390 * event queue link to event port. 391 * @param nb_links 392 * The number of links to establish 393 * 394 * @return 395 * Returns 0 on success. 396 * 397 */ 398 typedef int (*eventdev_port_link_t)(struct rte_eventdev *dev, void *port, 399 const uint8_t queues[], const uint8_t priorities[], 400 uint16_t nb_links); 401 402 /** 403 * Unlink multiple source event queues from destination event port. 404 * 405 * @param dev 406 * Event device pointer 407 * @param port 408 * Event port pointer 409 * @param queues 410 * An array of *nb_unlinks* event queues to be unlinked from the event port. 411 * @param nb_unlinks 412 * The number of unlinks to establish 413 * 414 * @return 415 * Returns 0 on success. 416 * 417 */ 418 typedef int (*eventdev_port_unlink_t)(struct rte_eventdev *dev, void *port, 419 uint8_t queues[], uint16_t nb_unlinks); 420 421 /** 422 * Unlinks in progress. Returns number of unlinks that the PMD is currently 423 * performing, but have not yet been completed. 424 * 425 * @param dev 426 * Event device pointer 427 * 428 * @param port 429 * Event port pointer 430 * 431 * @return 432 * Returns the number of in-progress unlinks. Zero is returned if none are 433 * in progress. 434 */ 435 typedef int (*eventdev_port_unlinks_in_progress_t)(struct rte_eventdev *dev, 436 void *port); 437 438 /** 439 * Converts nanoseconds to *timeout_ticks* value for rte_event_dequeue() 440 * 441 * @param dev 442 * Event device pointer 443 * @param ns 444 * Wait time in nanosecond 445 * @param[out] timeout_ticks 446 * Value for the *timeout_ticks* parameter in rte_event_dequeue() function 447 * 448 * @return 449 * Returns 0 on success. 450 * 451 */ 452 typedef int (*eventdev_dequeue_timeout_ticks_t)(struct rte_eventdev *dev, 453 uint64_t ns, uint64_t *timeout_ticks); 454 455 /** 456 * Dump internal information 457 * 458 * @param dev 459 * Event device pointer 460 * @param f 461 * A pointer to a file for output 462 * 463 */ 464 typedef void (*eventdev_dump_t)(struct rte_eventdev *dev, FILE *f); 465 466 /** 467 * Retrieve a set of statistics from device 468 * 469 * @param dev 470 * Event device pointer 471 * @param mode 472 * Level (device, port or queue) 473 * @param queue_port_id 474 * Queue or port number depending on mode 475 * @param ids 476 * The stat ids to retrieve 477 * @param values 478 * The returned stat values 479 * @param n 480 * The number of id values and entries in the values array 481 * @return 482 * The number of stat values successfully filled into the values array 483 */ 484 typedef int (*eventdev_xstats_get_t)(const struct rte_eventdev *dev, 485 enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id, 486 const unsigned int ids[], uint64_t values[], unsigned int n); 487 488 /** 489 * Resets the statistic values in xstats for the device, based on mode. 490 */ 491 typedef int (*eventdev_xstats_reset_t)(struct rte_eventdev *dev, 492 enum rte_event_dev_xstats_mode mode, 493 int16_t queue_port_id, 494 const uint32_t ids[], 495 uint32_t nb_ids); 496 497 /** 498 * Get names of extended stats of an event device 499 * 500 * @param dev 501 * Event device pointer 502 * @param mode 503 * Level (device, port or queue) 504 * @param queue_port_id 505 * Queue or port number depending on mode 506 * @param xstats_names 507 * Array of name values to be filled in 508 * @param ids 509 * The stat ids to retrieve 510 * @param size 511 * Number of values in the xstats_names array 512 * @return 513 * When size >= the number of stats, return the number of stat values filled 514 * into the array. 515 * When size < the number of available stats, return the number of stats 516 * values, and do not fill in any data into xstats_names. 517 */ 518 typedef int (*eventdev_xstats_get_names_t)(const struct rte_eventdev *dev, 519 enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id, 520 struct rte_event_dev_xstats_name *xstats_names, 521 unsigned int *ids, unsigned int size); 522 523 /** 524 * Get value of one stats and optionally return its id 525 * 526 * @param dev 527 * Event device pointer 528 * @param name 529 * The name of the stat to retrieve 530 * @param id 531 * Pointer to an unsigned int where we store the stat-id for future reference. 532 * This pointer may be null if the id is not required. 533 * @return 534 * The value of the stat, or (uint64_t)-1 if the stat is not found. 535 * If the stat is not found, the id value will be returned as (unsigned)-1, 536 * if id pointer is non-NULL 537 */ 538 typedef uint64_t (*eventdev_xstats_get_by_name)(const struct rte_eventdev *dev, 539 const char *name, unsigned int *id); 540 541 542 /** 543 * Retrieve the event device's ethdev Rx adapter capabilities for the 544 * specified ethernet port 545 * 546 * @param dev 547 * Event device pointer 548 * 549 * @param eth_dev 550 * Ethernet device pointer 551 * 552 * @param[out] caps 553 * A pointer to memory filled with Rx event adapter capabilities. 554 * 555 * @return 556 * - 0: Success, driver provides Rx event adapter capabilities for the 557 * ethernet device. 558 * - <0: Error code returned by the driver function. 559 * 560 */ 561 typedef int (*eventdev_eth_rx_adapter_caps_get_t) 562 (const struct rte_eventdev *dev, 563 const struct rte_eth_dev *eth_dev, 564 uint32_t *caps); 565 566 struct rte_event_eth_rx_adapter_queue_conf; 567 568 /** 569 * Retrieve the event device's timer adapter capabilities, as well as the ops 570 * structure that an event timer adapter should call through to enter the 571 * driver 572 * 573 * @param dev 574 * Event device pointer 575 * 576 * @param flags 577 * Flags that can be used to determine how to select an event timer 578 * adapter ops structure 579 * 580 * @param[out] caps 581 * A pointer to memory filled with Rx event adapter capabilities. 582 * 583 * @param[out] ops 584 * A pointer to the ops pointer to set with the address of the desired ops 585 * structure 586 * 587 * @return 588 * - 0: Success, driver provides Rx event adapter capabilities for the 589 * ethernet device. 590 * - <0: Error code returned by the driver function. 591 * 592 */ 593 typedef int (*eventdev_timer_adapter_caps_get_t)( 594 const struct rte_eventdev *dev, uint64_t flags, uint32_t *caps, 595 const struct event_timer_adapter_ops **ops); 596 597 /** 598 * Add ethernet Rx queues to event device. This callback is invoked if 599 * the caps returned from rte_eventdev_eth_rx_adapter_caps_get(, eth_port_id) 600 * has RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT set. 601 * 602 * @param dev 603 * Event device pointer 604 * 605 * @param eth_dev 606 * Ethernet device pointer 607 * 608 * @param rx_queue_id 609 * Ethernet device receive queue index 610 * 611 * @param queue_conf 612 * Additional configuration structure 613 614 * @return 615 * - 0: Success, ethernet receive queue added successfully. 616 * - <0: Error code returned by the driver function. 617 * 618 */ 619 typedef int (*eventdev_eth_rx_adapter_queue_add_t)( 620 const struct rte_eventdev *dev, 621 const struct rte_eth_dev *eth_dev, 622 int32_t rx_queue_id, 623 const struct rte_event_eth_rx_adapter_queue_conf *queue_conf); 624 625 /** 626 * Delete ethernet Rx queues from event device. This callback is invoked if 627 * the caps returned from eventdev_eth_rx_adapter_caps_get(, eth_port_id) 628 * has RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT set. 629 * 630 * @param dev 631 * Event device pointer 632 * 633 * @param eth_dev 634 * Ethernet device pointer 635 * 636 * @param rx_queue_id 637 * Ethernet device receive queue index 638 * 639 * @return 640 * - 0: Success, ethernet receive queue deleted successfully. 641 * - <0: Error code returned by the driver function. 642 * 643 */ 644 typedef int (*eventdev_eth_rx_adapter_queue_del_t) 645 (const struct rte_eventdev *dev, 646 const struct rte_eth_dev *eth_dev, 647 int32_t rx_queue_id); 648 649 /** 650 * Retrieve Rx adapter queue config information for the specified 651 * rx queue ID. 652 * 653 * @param dev 654 * Event device pointer 655 * 656 * @param eth_dev 657 * Ethernet device pointer 658 * 659 * @param rx_queue_id 660 * Ethernet device receive queue index. 661 * 662 * @param[out] queue_conf 663 * Pointer to rte_event_eth_rx_adapter_queue_conf structure 664 * 665 * @return 666 * - 0: Success 667 * - <0: Error code on failure. 668 */ 669 typedef int (*eventdev_eth_rx_adapter_queue_conf_get_t) 670 (const struct rte_eventdev *dev, 671 const struct rte_eth_dev *eth_dev, 672 uint16_t rx_queue_id, 673 struct rte_event_eth_rx_adapter_queue_conf *queue_conf); 674 675 /** 676 * Start ethernet Rx adapter. This callback is invoked if 677 * the caps returned from eventdev_eth_rx_adapter_caps_get(.., eth_port_id) 678 * has RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT set and Rx queues 679 * from eth_port_id have been added to the event device. 680 * 681 * @param dev 682 * Event device pointer 683 * 684 * @param eth_dev 685 * Ethernet device pointer 686 * 687 * @return 688 * - 0: Success, ethernet Rx adapter started successfully. 689 * - <0: Error code returned by the driver function. 690 */ 691 typedef int (*eventdev_eth_rx_adapter_start_t) 692 (const struct rte_eventdev *dev, 693 const struct rte_eth_dev *eth_dev); 694 695 /** 696 * Stop ethernet Rx adapter. This callback is invoked if 697 * the caps returned from eventdev_eth_rx_adapter_caps_get(..,eth_port_id) 698 * has RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT set and Rx queues 699 * from eth_port_id have been added to the event device. 700 * 701 * @param dev 702 * Event device pointer 703 * 704 * @param eth_dev 705 * Ethernet device pointer 706 * 707 * @return 708 * - 0: Success, ethernet Rx adapter stopped successfully. 709 * - <0: Error code returned by the driver function. 710 */ 711 typedef int (*eventdev_eth_rx_adapter_stop_t) 712 (const struct rte_eventdev *dev, 713 const struct rte_eth_dev *eth_dev); 714 715 struct rte_event_eth_rx_adapter_stats; 716 717 /** 718 * Retrieve ethernet Rx adapter statistics. 719 * 720 * @param dev 721 * Event device pointer 722 * 723 * @param eth_dev 724 * Ethernet device pointer 725 * 726 * @param[out] stats 727 * Pointer to stats structure 728 * 729 * @return 730 * Return 0 on success. 731 */ 732 733 typedef int (*eventdev_eth_rx_adapter_stats_get) 734 (const struct rte_eventdev *dev, 735 const struct rte_eth_dev *eth_dev, 736 struct rte_event_eth_rx_adapter_stats *stats); 737 /** 738 * Reset ethernet Rx adapter statistics. 739 * 740 * @param dev 741 * Event device pointer 742 * 743 * @param eth_dev 744 * Ethernet device pointer 745 * 746 * @return 747 * Return 0 on success. 748 */ 749 typedef int (*eventdev_eth_rx_adapter_stats_reset) 750 (const struct rte_eventdev *dev, 751 const struct rte_eth_dev *eth_dev); 752 753 struct rte_event_eth_rx_adapter_queue_stats; 754 755 /** 756 * Retrieve ethernet Rx adapter queue statistics. 757 * 758 * @param dev 759 * Event device pointer 760 * 761 * @param eth_dev 762 * Ethernet device pointer 763 * 764 * @param rx_queue_id 765 * Ethernet device receive queue index. 766 * 767 * @param[out] q_stats 768 * Pointer to queue stats structure 769 * 770 * @return 771 * Return 0 on success. 772 */ 773 typedef int (*eventdev_eth_rx_adapter_q_stats_get) 774 (const struct rte_eventdev *dev, 775 const struct rte_eth_dev *eth_dev, 776 uint16_t rx_queue_id, 777 struct rte_event_eth_rx_adapter_queue_stats *q_stats); 778 779 /** 780 * Reset ethernet Rx adapter queue statistics. 781 * 782 * @param dev 783 * Event device pointer 784 * 785 * @param eth_dev 786 * Ethernet device pointer 787 * 788 * @param rx_queue_id 789 * Ethernet device receive queue index. 790 * 791 * @return 792 * Return 0 on success. 793 */ 794 typedef int (*eventdev_eth_rx_adapter_q_stats_reset) 795 (const struct rte_eventdev *dev, 796 const struct rte_eth_dev *eth_dev, 797 uint16_t rx_queue_id); 798 799 /** 800 * Start eventdev selftest. 801 * 802 * @return 803 * Return 0 on success. 804 */ 805 typedef int (*eventdev_selftest)(void); 806 807 struct rte_event_eth_rx_adapter_vector_limits; 808 /** 809 * Get event vector limits for a given event, ethernet device pair. 810 * 811 * @param dev 812 * Event device pointer 813 * 814 * @param eth_dev 815 * Ethernet device pointer 816 * 817 * @param[out] limits 818 * Pointer to the limits structure to be filled. 819 * 820 * @return 821 * - 0: Success. 822 * - <0: Error code returned by the driver function. 823 */ 824 typedef int (*eventdev_eth_rx_adapter_vector_limits_get_t)( 825 const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev, 826 struct rte_event_eth_rx_adapter_vector_limits *limits); 827 828 typedef uint32_t rte_event_pmd_selftest_seqn_t; 829 extern int rte_event_pmd_selftest_seqn_dynfield_offset; 830 831 /** 832 * Read test sequence number from mbuf. 833 * 834 * @param mbuf Structure to read from. 835 * @return pointer to test sequence number. 836 */ 837 __rte_internal 838 static inline rte_event_pmd_selftest_seqn_t * 839 rte_event_pmd_selftest_seqn(struct rte_mbuf *mbuf) 840 { 841 return RTE_MBUF_DYNFIELD(mbuf, 842 rte_event_pmd_selftest_seqn_dynfield_offset, 843 rte_event_pmd_selftest_seqn_t *); 844 } 845 846 struct rte_cryptodev; 847 848 /** 849 * This API may change without prior notice 850 * 851 * Retrieve the event device's crypto adapter capabilities for the 852 * specified cryptodev 853 * 854 * @param dev 855 * Event device pointer 856 * 857 * @param cdev 858 * cryptodev pointer 859 * 860 * @param[out] caps 861 * A pointer to memory filled with event adapter capabilities. 862 * It is expected to be pre-allocated & initialized by caller. 863 * 864 * @return 865 * - 0: Success, driver provides event adapter capabilities for the 866 * cryptodev. 867 * - <0: Error code returned by the driver function. 868 * 869 */ 870 typedef int (*eventdev_crypto_adapter_caps_get_t) 871 (const struct rte_eventdev *dev, 872 const struct rte_cryptodev *cdev, 873 uint32_t *caps); 874 875 /** 876 * This API may change without prior notice 877 * 878 * Add crypto queue pair to event device. This callback is invoked if 879 * the caps returned from rte_event_crypto_adapter_caps_get(, cdev_id) 880 * has RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_* set. 881 * 882 * @param dev 883 * Event device pointer 884 * 885 * @param cdev 886 * cryptodev pointer 887 * 888 * @param queue_pair_id 889 * cryptodev queue pair identifier. 890 * 891 * @param event 892 * Event information required for binding cryptodev queue pair to event queue. 893 * This structure will have a valid value for only those HW PMDs supporting 894 * @see RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND capability. 895 * 896 * @return 897 * - 0: Success, cryptodev queue pair added successfully. 898 * - <0: Error code returned by the driver function. 899 * 900 */ 901 typedef int (*eventdev_crypto_adapter_queue_pair_add_t) 902 (const struct rte_eventdev *dev, 903 const struct rte_cryptodev *cdev, 904 int32_t queue_pair_id, 905 const struct rte_event *event); 906 907 908 /** 909 * This API may change without prior notice 910 * 911 * Delete crypto queue pair to event device. This callback is invoked if 912 * the caps returned from rte_event_crypto_adapter_caps_get(, cdev_id) 913 * has RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_* set. 914 * 915 * @param dev 916 * Event device pointer 917 * 918 * @param cdev 919 * cryptodev pointer 920 * 921 * @param queue_pair_id 922 * cryptodev queue pair identifier. 923 * 924 * @return 925 * - 0: Success, cryptodev queue pair deleted successfully. 926 * - <0: Error code returned by the driver function. 927 * 928 */ 929 typedef int (*eventdev_crypto_adapter_queue_pair_del_t) 930 (const struct rte_eventdev *dev, 931 const struct rte_cryptodev *cdev, 932 int32_t queue_pair_id); 933 934 /** 935 * Start crypto adapter. This callback is invoked if 936 * the caps returned from rte_event_crypto_adapter_caps_get(.., cdev_id) 937 * has RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_* set and queue pairs 938 * from cdev_id have been added to the event device. 939 * 940 * @param dev 941 * Event device pointer 942 * 943 * @param cdev 944 * Crypto device pointer 945 * 946 * @return 947 * - 0: Success, crypto adapter started successfully. 948 * - <0: Error code returned by the driver function. 949 */ 950 typedef int (*eventdev_crypto_adapter_start_t) 951 (const struct rte_eventdev *dev, 952 const struct rte_cryptodev *cdev); 953 954 /** 955 * Stop crypto adapter. This callback is invoked if 956 * the caps returned from rte_event_crypto_adapter_caps_get(.., cdev_id) 957 * has RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_* set and queue pairs 958 * from cdev_id have been added to the event device. 959 * 960 * @param dev 961 * Event device pointer 962 * 963 * @param cdev 964 * Crypto device pointer 965 * 966 * @return 967 * - 0: Success, crypto adapter stopped successfully. 968 * - <0: Error code returned by the driver function. 969 */ 970 typedef int (*eventdev_crypto_adapter_stop_t) 971 (const struct rte_eventdev *dev, 972 const struct rte_cryptodev *cdev); 973 974 struct rte_event_crypto_adapter_stats; 975 976 /** 977 * Retrieve crypto adapter statistics. 978 * 979 * @param dev 980 * Event device pointer 981 * 982 * @param cdev 983 * Crypto device pointer 984 * 985 * @param[out] stats 986 * Pointer to stats structure 987 * 988 * @return 989 * Return 0 on success. 990 */ 991 992 typedef int (*eventdev_crypto_adapter_stats_get) 993 (const struct rte_eventdev *dev, 994 const struct rte_cryptodev *cdev, 995 struct rte_event_crypto_adapter_stats *stats); 996 997 /** 998 * Reset crypto adapter statistics. 999 * 1000 * @param dev 1001 * Event device pointer 1002 * 1003 * @param cdev 1004 * Crypto device pointer 1005 * 1006 * @return 1007 * Return 0 on success. 1008 */ 1009 1010 typedef int (*eventdev_crypto_adapter_stats_reset) 1011 (const struct rte_eventdev *dev, 1012 const struct rte_cryptodev *cdev); 1013 1014 /** 1015 * Retrieve the event device's eth Tx adapter capabilities. 1016 * 1017 * @param dev 1018 * Event device pointer 1019 * 1020 * @param eth_dev 1021 * Ethernet device pointer 1022 * 1023 * @param[out] caps 1024 * A pointer to memory filled with eth Tx adapter capabilities. 1025 * 1026 * @return 1027 * - 0: Success, driver provides eth Tx adapter capabilities 1028 * - <0: Error code returned by the driver function. 1029 * 1030 */ 1031 typedef int (*eventdev_eth_tx_adapter_caps_get_t) 1032 (const struct rte_eventdev *dev, 1033 const struct rte_eth_dev *eth_dev, 1034 uint32_t *caps); 1035 1036 /** 1037 * Create adapter callback. 1038 * 1039 * @param id 1040 * Adapter identifier 1041 * 1042 * @param dev 1043 * Event device pointer 1044 * 1045 * @return 1046 * - 0: Success. 1047 * - <0: Error code on failure. 1048 */ 1049 typedef int (*eventdev_eth_tx_adapter_create_t)(uint8_t id, 1050 const struct rte_eventdev *dev); 1051 1052 /** 1053 * Free adapter callback. 1054 * 1055 * @param id 1056 * Adapter identifier 1057 * 1058 * @param dev 1059 * Event device pointer 1060 * 1061 * @return 1062 * - 0: Success. 1063 * - <0: Error code on failure. 1064 */ 1065 typedef int (*eventdev_eth_tx_adapter_free_t)(uint8_t id, 1066 const struct rte_eventdev *dev); 1067 1068 /** 1069 * Add a Tx queue to the adapter. 1070 * A queue value of -1 is used to indicate all 1071 * queues within the device. 1072 * 1073 * @param id 1074 * Adapter identifier 1075 * 1076 * @param dev 1077 * Event device pointer 1078 * 1079 * @param eth_dev 1080 * Ethernet device pointer 1081 * 1082 * @param tx_queue_id 1083 * Transmit queue index 1084 * 1085 * @return 1086 * - 0: Success. 1087 * - <0: Error code on failure. 1088 */ 1089 typedef int (*eventdev_eth_tx_adapter_queue_add_t)( 1090 uint8_t id, 1091 const struct rte_eventdev *dev, 1092 const struct rte_eth_dev *eth_dev, 1093 int32_t tx_queue_id); 1094 1095 /** 1096 * Delete a Tx queue from the adapter. 1097 * A queue value of -1 is used to indicate all 1098 * queues within the device, that have been added to this 1099 * adapter. 1100 * 1101 * @param id 1102 * Adapter identifier 1103 * 1104 * @param dev 1105 * Event device pointer 1106 * 1107 * @param eth_dev 1108 * Ethernet device pointer 1109 * 1110 * @param tx_queue_id 1111 * Transmit queue index 1112 * 1113 * @return 1114 * - 0: Success, Queues deleted successfully. 1115 * - <0: Error code on failure. 1116 */ 1117 typedef int (*eventdev_eth_tx_adapter_queue_del_t)( 1118 uint8_t id, 1119 const struct rte_eventdev *dev, 1120 const struct rte_eth_dev *eth_dev, 1121 int32_t tx_queue_id); 1122 1123 /** 1124 * Start the adapter. 1125 * 1126 * @param id 1127 * Adapter identifier 1128 * 1129 * @param dev 1130 * Event device pointer 1131 * 1132 * @return 1133 * - 0: Success, Adapter started correctly. 1134 * - <0: Error code on failure. 1135 */ 1136 typedef int (*eventdev_eth_tx_adapter_start_t)(uint8_t id, 1137 const struct rte_eventdev *dev); 1138 1139 /** 1140 * Stop the adapter. 1141 * 1142 * @param id 1143 * Adapter identifier 1144 * 1145 * @param dev 1146 * Event device pointer 1147 * 1148 * @return 1149 * - 0: Success. 1150 * - <0: Error code on failure. 1151 */ 1152 typedef int (*eventdev_eth_tx_adapter_stop_t)(uint8_t id, 1153 const struct rte_eventdev *dev); 1154 1155 struct rte_event_eth_tx_adapter_stats; 1156 1157 /** 1158 * Retrieve statistics for an adapter 1159 * 1160 * @param id 1161 * Adapter identifier 1162 * 1163 * @param dev 1164 * Event device pointer 1165 * 1166 * @param [out] stats 1167 * A pointer to structure used to retrieve statistics for an adapter 1168 * 1169 * @return 1170 * - 0: Success, statistics retrieved successfully. 1171 * - <0: Error code on failure. 1172 */ 1173 typedef int (*eventdev_eth_tx_adapter_stats_get_t)( 1174 uint8_t id, 1175 const struct rte_eventdev *dev, 1176 struct rte_event_eth_tx_adapter_stats *stats); 1177 1178 /** 1179 * Reset statistics for an adapter 1180 * 1181 * @param id 1182 * Adapter identifier 1183 * 1184 * @param dev 1185 * Event device pointer 1186 * 1187 * @return 1188 * - 0: Success, statistics retrieved successfully. 1189 * - <0: Error code on failure. 1190 */ 1191 typedef int (*eventdev_eth_tx_adapter_stats_reset_t)(uint8_t id, 1192 const struct rte_eventdev *dev); 1193 1194 /** Event device operations function pointer table */ 1195 struct eventdev_ops { 1196 eventdev_info_get_t dev_infos_get; /**< Get device info. */ 1197 eventdev_configure_t dev_configure; /**< Configure device. */ 1198 eventdev_start_t dev_start; /**< Start device. */ 1199 eventdev_stop_t dev_stop; /**< Stop device. */ 1200 eventdev_close_t dev_close; /**< Close device. */ 1201 1202 eventdev_queue_default_conf_get_t queue_def_conf; 1203 /**< Get default queue configuration. */ 1204 eventdev_queue_setup_t queue_setup; 1205 /**< Set up an event queue. */ 1206 eventdev_queue_release_t queue_release; 1207 /**< Release an event queue. */ 1208 1209 eventdev_port_default_conf_get_t port_def_conf; 1210 /**< Get default port configuration. */ 1211 eventdev_port_setup_t port_setup; 1212 /**< Set up an event port. */ 1213 eventdev_port_release_t port_release; 1214 /**< Release an event port. */ 1215 1216 eventdev_port_link_t port_link; 1217 /**< Link event queues to an event port. */ 1218 eventdev_port_unlink_t port_unlink; 1219 /**< Unlink event queues from an event port. */ 1220 eventdev_port_unlinks_in_progress_t port_unlinks_in_progress; 1221 /**< Unlinks in progress on an event port. */ 1222 eventdev_dequeue_timeout_ticks_t timeout_ticks; 1223 /**< Converts ns to *timeout_ticks* value for rte_event_dequeue() */ 1224 eventdev_dump_t dump; 1225 /* Dump internal information */ 1226 1227 eventdev_xstats_get_t xstats_get; 1228 /**< Get extended device statistics. */ 1229 eventdev_xstats_get_names_t xstats_get_names; 1230 /**< Get names of extended stats. */ 1231 eventdev_xstats_get_by_name xstats_get_by_name; 1232 /**< Get one value by name. */ 1233 eventdev_xstats_reset_t xstats_reset; 1234 /**< Reset the statistics values in xstats. */ 1235 1236 eventdev_eth_rx_adapter_caps_get_t eth_rx_adapter_caps_get; 1237 /**< Get ethernet Rx adapter capabilities */ 1238 eventdev_eth_rx_adapter_queue_add_t eth_rx_adapter_queue_add; 1239 /**< Add Rx queues to ethernet Rx adapter */ 1240 eventdev_eth_rx_adapter_queue_del_t eth_rx_adapter_queue_del; 1241 /**< Delete Rx queues from ethernet Rx adapter */ 1242 eventdev_eth_rx_adapter_queue_conf_get_t eth_rx_adapter_queue_conf_get; 1243 /**< Get Rx adapter queue info */ 1244 eventdev_eth_rx_adapter_start_t eth_rx_adapter_start; 1245 /**< Start ethernet Rx adapter */ 1246 eventdev_eth_rx_adapter_stop_t eth_rx_adapter_stop; 1247 /**< Stop ethernet Rx adapter */ 1248 eventdev_eth_rx_adapter_stats_get eth_rx_adapter_stats_get; 1249 /**< Get ethernet Rx stats */ 1250 eventdev_eth_rx_adapter_stats_reset eth_rx_adapter_stats_reset; 1251 /**< Reset ethernet Rx stats */ 1252 eventdev_eth_rx_adapter_vector_limits_get_t 1253 eth_rx_adapter_vector_limits_get; 1254 /**< Get event vector limits for the Rx adapter */ 1255 1256 eventdev_timer_adapter_caps_get_t timer_adapter_caps_get; 1257 /**< Get timer adapter capabilities */ 1258 1259 eventdev_crypto_adapter_caps_get_t crypto_adapter_caps_get; 1260 /**< Get crypto adapter capabilities */ 1261 eventdev_crypto_adapter_queue_pair_add_t crypto_adapter_queue_pair_add; 1262 /**< Add queue pair to crypto adapter */ 1263 eventdev_crypto_adapter_queue_pair_del_t crypto_adapter_queue_pair_del; 1264 /**< Delete queue pair from crypto adapter */ 1265 eventdev_crypto_adapter_start_t crypto_adapter_start; 1266 /**< Start crypto adapter */ 1267 eventdev_crypto_adapter_stop_t crypto_adapter_stop; 1268 /**< Stop crypto adapter */ 1269 eventdev_crypto_adapter_stats_get crypto_adapter_stats_get; 1270 /**< Get crypto stats */ 1271 eventdev_crypto_adapter_stats_reset crypto_adapter_stats_reset; 1272 /**< Reset crypto stats */ 1273 1274 eventdev_eth_rx_adapter_q_stats_get eth_rx_adapter_queue_stats_get; 1275 /**< Get ethernet Rx queue stats */ 1276 eventdev_eth_rx_adapter_q_stats_reset eth_rx_adapter_queue_stats_reset; 1277 /**< Reset ethernet Rx queue stats */ 1278 1279 eventdev_eth_tx_adapter_caps_get_t eth_tx_adapter_caps_get; 1280 /**< Get ethernet Tx adapter capabilities */ 1281 1282 eventdev_eth_tx_adapter_create_t eth_tx_adapter_create; 1283 /**< Create adapter callback */ 1284 eventdev_eth_tx_adapter_free_t eth_tx_adapter_free; 1285 /**< Free adapter callback */ 1286 eventdev_eth_tx_adapter_queue_add_t eth_tx_adapter_queue_add; 1287 /**< Add Tx queues to the eth Tx adapter */ 1288 eventdev_eth_tx_adapter_queue_del_t eth_tx_adapter_queue_del; 1289 /**< Delete Tx queues from the eth Tx adapter */ 1290 eventdev_eth_tx_adapter_start_t eth_tx_adapter_start; 1291 /**< Start eth Tx adapter */ 1292 eventdev_eth_tx_adapter_stop_t eth_tx_adapter_stop; 1293 /**< Stop eth Tx adapter */ 1294 eventdev_eth_tx_adapter_stats_get_t eth_tx_adapter_stats_get; 1295 /**< Get eth Tx adapter statistics */ 1296 eventdev_eth_tx_adapter_stats_reset_t eth_tx_adapter_stats_reset; 1297 /**< Reset eth Tx adapter statistics */ 1298 1299 eventdev_selftest dev_selftest; 1300 /**< Start eventdev Selftest */ 1301 1302 eventdev_stop_flush_t dev_stop_flush; 1303 /**< User-provided event flush function */ 1304 }; 1305 1306 /** 1307 * Allocates a new eventdev slot for an event device and returns the pointer 1308 * to that slot for the driver to use. 1309 * 1310 * @param name 1311 * Unique identifier name for each device 1312 * @param socket_id 1313 * Socket to allocate resources on. 1314 * @return 1315 * - Slot in the rte_dev_devices array for a new device; 1316 */ 1317 __rte_internal 1318 struct rte_eventdev * 1319 rte_event_pmd_allocate(const char *name, int socket_id); 1320 1321 /** 1322 * Release the specified eventdev device. 1323 * 1324 * @param eventdev 1325 * The *eventdev* pointer is the address of the *rte_eventdev* structure. 1326 * @return 1327 * - 0 on success, negative on error 1328 */ 1329 __rte_internal 1330 int 1331 rte_event_pmd_release(struct rte_eventdev *eventdev); 1332 1333 /** 1334 * 1335 * @internal 1336 * This is the last step of device probing. 1337 * It must be called after a port is allocated and initialized successfully. 1338 * 1339 * @param eventdev 1340 * New event device. 1341 */ 1342 __rte_internal 1343 void 1344 event_dev_probing_finish(struct rte_eventdev *eventdev); 1345 1346 /** 1347 * Reset eventdevice fastpath APIs to dummy values. 1348 * 1349 * @param fp_ops 1350 * The *fp_ops* pointer to reset. 1351 */ 1352 __rte_internal 1353 void 1354 event_dev_fp_ops_reset(struct rte_event_fp_ops *fp_op); 1355 1356 /** 1357 * Set eventdevice fastpath APIs to event device values. 1358 * 1359 * @param fp_ops 1360 * The *fp_ops* pointer to set. 1361 */ 1362 __rte_internal 1363 void 1364 event_dev_fp_ops_set(struct rte_event_fp_ops *fp_ops, 1365 const struct rte_eventdev *dev); 1366 1367 #ifdef __cplusplus 1368 } 1369 #endif 1370 1371 #endif /* _RTE_EVENTDEV_PMD_H_ */ 1372