1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2016 Cavium, Inc. 3 * Copyright(c) 2016-2018 Intel Corporation. 4 * Copyright 2016 NXP 5 * All rights reserved. 6 */ 7 8 #ifndef _RTE_EVENTDEV_H_ 9 #define _RTE_EVENTDEV_H_ 10 11 /** 12 * @file 13 * 14 * RTE Event Device API 15 * 16 * In a polling model, lcores poll ethdev ports and associated rx queues 17 * directly to look for packet. In an event driven model, by contrast, lcores 18 * call the scheduler that selects packets for them based on programmer 19 * specified criteria. Eventdev library adds support for event driven 20 * programming model, which offer applications automatic multicore scaling, 21 * dynamic load balancing, pipelining, packet ingress order maintenance and 22 * synchronization services to simplify application packet processing. 23 * 24 * The Event Device API is composed of two parts: 25 * 26 * - The application-oriented Event API that includes functions to setup 27 * an event device (configure it, setup its queues, ports and start it), to 28 * establish the link between queues to port and to receive events, and so on. 29 * 30 * - The driver-oriented Event API that exports a function allowing 31 * an event poll Mode Driver (PMD) to simultaneously register itself as 32 * an event device driver. 33 * 34 * Event device components: 35 * 36 * +-----------------+ 37 * | +-------------+ | 38 * +-------+ | | flow 0 | | 39 * |Packet | | +-------------+ | 40 * |event | | +-------------+ | 41 * | | | | flow 1 | |port_link(port0, queue0) 42 * +-------+ | +-------------+ | | +--------+ 43 * +-------+ | +-------------+ o-----v-----o |dequeue +------+ 44 * |Crypto | | | flow n | | | event +------->|Core 0| 45 * |work | | +-------------+ o----+ | port 0 | | | 46 * |done ev| | event queue 0 | | +--------+ +------+ 47 * +-------+ +-----------------+ | 48 * +-------+ | 49 * |Timer | +-----------------+ | +--------+ 50 * |expiry | | +-------------+ | +------o |dequeue +------+ 51 * |event | | | flow 0 | o-----------o event +------->|Core 1| 52 * +-------+ | +-------------+ | +----o port 1 | | | 53 * Event enqueue | +-------------+ | | +--------+ +------+ 54 * o-------------> | | flow 1 | | | 55 * enqueue( | +-------------+ | | 56 * queue_id, | | | +--------+ +------+ 57 * flow_id, | +-------------+ | | | |dequeue |Core 2| 58 * sched_type, | | flow n | o-----------o event +------->| | 59 * event_type, | +-------------+ | | | port 2 | +------+ 60 * subev_type, | event queue 1 | | +--------+ 61 * event) +-----------------+ | +--------+ 62 * | | |dequeue +------+ 63 * +-------+ +-----------------+ | | event +------->|Core n| 64 * |Core | | +-------------+ o-----------o port n | | | 65 * |(SW) | | | flow 0 | | | +--------+ +--+---+ 66 * |event | | +-------------+ | | | 67 * +-------+ | +-------------+ | | | 68 * ^ | | flow 1 | | | | 69 * | | +-------------+ o------+ | 70 * | | +-------------+ | | 71 * | | | flow n | | | 72 * | | +-------------+ | | 73 * | | event queue n | | 74 * | +-----------------+ | 75 * | | 76 * +-----------------------------------------------------------+ 77 * 78 * Event device: A hardware or software-based event scheduler. 79 * 80 * Event: A unit of scheduling that encapsulates a packet or other datatype 81 * like SW generated event from the CPU, Crypto work completion notification, 82 * Timer expiry event notification etc as well as metadata. 83 * The metadata includes flow ID, scheduling type, event priority, event_type, 84 * sub_event_type etc. 85 * 86 * Event queue: A queue containing events that are scheduled by the event dev. 87 * An event queue contains events of different flows associated with scheduling 88 * types, such as atomic, ordered, or parallel. 89 * 90 * Event port: An application's interface into the event dev for enqueue and 91 * dequeue operations. Each event port can be linked with one or more 92 * event queues for dequeue operations. 93 * 94 * By default, all the functions of the Event Device API exported by a PMD 95 * are lock-free functions which assume to not be invoked in parallel on 96 * different logical cores to work on the same target object. For instance, 97 * the dequeue function of a PMD cannot be invoked in parallel on two logical 98 * cores to operates on same event port. Of course, this function 99 * can be invoked in parallel by different logical cores on different ports. 100 * It is the responsibility of the upper level application to enforce this rule. 101 * 102 * In all functions of the Event API, the Event device is 103 * designated by an integer >= 0 named the device identifier *dev_id* 104 * 105 * At the Event driver level, Event devices are represented by a generic 106 * data structure of type *rte_event_dev*. 107 * 108 * Event devices are dynamically registered during the PCI/SoC device probing 109 * phase performed at EAL initialization time. 110 * When an Event device is being probed, a *rte_event_dev* structure and 111 * a new device identifier are allocated for that device. Then, the 112 * event_dev_init() function supplied by the Event driver matching the probed 113 * device is invoked to properly initialize the device. 114 * 115 * The role of the device init function consists of resetting the hardware or 116 * software event driver implementations. 117 * 118 * If the device init operation is successful, the correspondence between 119 * the device identifier assigned to the new device and its associated 120 * *rte_event_dev* structure is effectively registered. 121 * Otherwise, both the *rte_event_dev* structure and the device identifier are 122 * freed. 123 * 124 * The functions exported by the application Event API to setup a device 125 * designated by its device identifier must be invoked in the following order: 126 * - rte_event_dev_configure() 127 * - rte_event_queue_setup() 128 * - rte_event_port_setup() 129 * - rte_event_port_link() 130 * - rte_event_dev_start() 131 * 132 * Then, the application can invoke, in any order, the functions 133 * exported by the Event API to schedule events, dequeue events, enqueue events, 134 * change event queue(s) to event port [un]link establishment and so on. 135 * 136 * Application may use rte_event_[queue/port]_default_conf_get() to get the 137 * default configuration to set up an event queue or event port by 138 * overriding few default values. 139 * 140 * If the application wants to change the configuration (i.e. call 141 * rte_event_dev_configure(), rte_event_queue_setup(), or 142 * rte_event_port_setup()), it must call rte_event_dev_stop() first to stop the 143 * device and then do the reconfiguration before calling rte_event_dev_start() 144 * again. The schedule, enqueue and dequeue functions should not be invoked 145 * when the device is stopped. 146 * 147 * Finally, an application can close an Event device by invoking the 148 * rte_event_dev_close() function. 149 * 150 * Each function of the application Event API invokes a specific function 151 * of the PMD that controls the target device designated by its device 152 * identifier. 153 * 154 * For this purpose, all device-specific functions of an Event driver are 155 * supplied through a set of pointers contained in a generic structure of type 156 * *event_dev_ops*. 157 * The address of the *event_dev_ops* structure is stored in the *rte_event_dev* 158 * structure by the device init function of the Event driver, which is 159 * invoked during the PCI/SoC device probing phase, as explained earlier. 160 * 161 * In other words, each function of the Event API simply retrieves the 162 * *rte_event_dev* structure associated with the device identifier and 163 * performs an indirect invocation of the corresponding driver function 164 * supplied in the *event_dev_ops* structure of the *rte_event_dev* structure. 165 * 166 * For performance reasons, the address of the fast-path functions of the 167 * Event driver is not contained in the *event_dev_ops* structure. 168 * Instead, they are directly stored at the beginning of the *rte_event_dev* 169 * structure to avoid an extra indirect memory access during their invocation. 170 * 171 * RTE event device drivers do not use interrupts for enqueue or dequeue 172 * operation. Instead, Event drivers export Poll-Mode enqueue and dequeue 173 * functions to applications. 174 * 175 * The events are injected to event device through *enqueue* operation by 176 * event producers in the system. The typical event producers are ethdev 177 * subsystem for generating packet events, CPU(SW) for generating events based 178 * on different stages of application processing, cryptodev for generating 179 * crypto work completion notification etc 180 * 181 * The *dequeue* operation gets one or more events from the event ports. 182 * The application process the events and send to downstream event queue through 183 * rte_event_enqueue_burst() if it is an intermediate stage of event processing, 184 * on the final stage, the application may use Tx adapter API for maintaining 185 * the ingress order and then send the packet/event on the wire. 186 * 187 * The point at which events are scheduled to ports depends on the device. 188 * For hardware devices, scheduling occurs asynchronously without any software 189 * intervention. Software schedulers can either be distributed 190 * (each worker thread schedules events to its own port) or centralized 191 * (a dedicated thread schedules to all ports). Distributed software schedulers 192 * perform the scheduling in rte_event_dequeue_burst(), whereas centralized 193 * scheduler logic need a dedicated service core for scheduling. 194 * The RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED capability flag is not set 195 * indicates the device is centralized and thus needs a dedicated scheduling 196 * thread that repeatedly calls software specific scheduling function. 197 * 198 * An event driven worker thread has following typical workflow on fastpath: 199 * \code{.c} 200 * while (1) { 201 * rte_event_dequeue_burst(...); 202 * (event processing) 203 * rte_event_enqueue_burst(...); 204 * } 205 * \endcode 206 * 207 */ 208 209 #ifdef __cplusplus 210 extern "C" { 211 #endif 212 213 #include <rte_common.h> 214 #include <rte_errno.h> 215 #include <rte_mbuf_pool_ops.h> 216 #include <rte_mempool.h> 217 218 #include "rte_eventdev_trace_fp.h" 219 220 struct rte_mbuf; /* we just use mbuf pointers; no need to include rte_mbuf.h */ 221 struct rte_event; 222 223 /* Event device capability bitmap flags */ 224 #define RTE_EVENT_DEV_CAP_QUEUE_QOS (1ULL << 0) 225 /**< Event scheduling prioritization is based on the priority associated with 226 * each event queue. 227 * 228 * @see rte_event_queue_setup(), rte_event_queue_attr_set() 229 */ 230 #define RTE_EVENT_DEV_CAP_EVENT_QOS (1ULL << 1) 231 /**< Event scheduling prioritization is based on the priority associated with 232 * each event. Priority of each event is supplied in *rte_event* structure 233 * on each enqueue operation. 234 * 235 * @see rte_event_enqueue_burst() 236 */ 237 #define RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED (1ULL << 2) 238 /**< Event device operates in distributed scheduling mode. 239 * In distributed scheduling mode, event scheduling happens in HW or 240 * rte_event_dequeue_burst() or the combination of these two. 241 * If the flag is not set then eventdev is centralized and thus needs a 242 * dedicated service core that acts as a scheduling thread . 243 * 244 * @see rte_event_dequeue_burst() 245 */ 246 #define RTE_EVENT_DEV_CAP_QUEUE_ALL_TYPES (1ULL << 3) 247 /**< Event device is capable of enqueuing events of any type to any queue. 248 * If this capability is not set, the queue only supports events of the 249 * *RTE_SCHED_TYPE_* type that it was created with. 250 * 251 * @see RTE_SCHED_TYPE_* values 252 */ 253 #define RTE_EVENT_DEV_CAP_BURST_MODE (1ULL << 4) 254 /**< Event device is capable of operating in burst mode for enqueue(forward, 255 * release) and dequeue operation. If this capability is not set, application 256 * still uses the rte_event_dequeue_burst() and rte_event_enqueue_burst() but 257 * PMD accepts only one event at a time. 258 * 259 * @see rte_event_dequeue_burst() rte_event_enqueue_burst() 260 */ 261 #define RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE (1ULL << 5) 262 /**< Event device ports support disabling the implicit release feature, in 263 * which the port will release all unreleased events in its dequeue operation. 264 * If this capability is set and the port is configured with implicit release 265 * disabled, the application is responsible for explicitly releasing events 266 * using either the RTE_EVENT_OP_FORWARD or the RTE_EVENT_OP_RELEASE event 267 * enqueue operations. 268 * 269 * @see rte_event_dequeue_burst() rte_event_enqueue_burst() 270 */ 271 272 #define RTE_EVENT_DEV_CAP_NONSEQ_MODE (1ULL << 6) 273 /**< Event device is capable of operating in none sequential mode. The path 274 * of the event is not necessary to be sequential. Application can change 275 * the path of event at runtime. If the flag is not set, then event each event 276 * will follow a path from queue 0 to queue 1 to queue 2 etc. If the flag is 277 * set, events may be sent to queues in any order. If the flag is not set, the 278 * eventdev will return an error when the application enqueues an event for a 279 * qid which is not the next in the sequence. 280 */ 281 282 #define RTE_EVENT_DEV_CAP_RUNTIME_PORT_LINK (1ULL << 7) 283 /**< Event device is capable of configuring the queue/port link at runtime. 284 * If the flag is not set, the eventdev queue/port link is only can be 285 * configured during initialization. 286 */ 287 288 #define RTE_EVENT_DEV_CAP_MULTIPLE_QUEUE_PORT (1ULL << 8) 289 /**< Event device is capable of setting up the link between multiple queue 290 * with single port. If the flag is not set, the eventdev can only map a 291 * single queue to each port or map a single queue to many port. 292 */ 293 294 #define RTE_EVENT_DEV_CAP_CARRY_FLOW_ID (1ULL << 9) 295 /**< Event device preserves the flow ID from the enqueued 296 * event to the dequeued event if the flag is set. Otherwise, 297 * the content of this field is implementation dependent. 298 */ 299 300 #define RTE_EVENT_DEV_CAP_MAINTENANCE_FREE (1ULL << 10) 301 /**< Event device *does not* require calls to rte_event_maintain(). 302 * An event device that does not set this flag requires calls to 303 * rte_event_maintain() during periods when neither 304 * rte_event_dequeue_burst() nor rte_event_enqueue_burst() are called 305 * on a port. This will allow the event device to perform internal 306 * processing, such as flushing buffered events, return credits to a 307 * global pool, or process signaling related to load balancing. 308 */ 309 310 #define RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR (1ULL << 11) 311 /**< Event device is capable of changing the queue attributes at runtime i.e 312 * after rte_event_queue_setup() or rte_event_start() call sequence. If this 313 * flag is not set, eventdev queue attributes can only be configured during 314 * rte_event_queue_setup(). 315 */ 316 317 /* Event device priority levels */ 318 #define RTE_EVENT_DEV_PRIORITY_HIGHEST 0 319 /**< Highest priority expressed across eventdev subsystem 320 * @see rte_event_queue_setup(), rte_event_enqueue_burst() 321 * @see rte_event_port_link() 322 */ 323 #define RTE_EVENT_DEV_PRIORITY_NORMAL 128 324 /**< Normal priority expressed across eventdev subsystem 325 * @see rte_event_queue_setup(), rte_event_enqueue_burst() 326 * @see rte_event_port_link() 327 */ 328 #define RTE_EVENT_DEV_PRIORITY_LOWEST 255 329 /**< Lowest priority expressed across eventdev subsystem 330 * @see rte_event_queue_setup(), rte_event_enqueue_burst() 331 * @see rte_event_port_link() 332 */ 333 334 /** 335 * Get the total number of event devices that have been successfully 336 * initialised. 337 * 338 * @return 339 * The total number of usable event devices. 340 */ 341 uint8_t 342 rte_event_dev_count(void); 343 344 /** 345 * Get the device identifier for the named event device. 346 * 347 * @param name 348 * Event device name to select the event device identifier. 349 * 350 * @return 351 * Returns event device identifier on success. 352 * - <0: Failure to find named event device. 353 */ 354 int 355 rte_event_dev_get_dev_id(const char *name); 356 357 /** 358 * Return the NUMA socket to which a device is connected. 359 * 360 * @param dev_id 361 * The identifier of the device. 362 * @return 363 * The NUMA socket id to which the device is connected or 364 * a default of zero if the socket could not be determined. 365 * -(-EINVAL) dev_id value is out of range. 366 */ 367 int 368 rte_event_dev_socket_id(uint8_t dev_id); 369 370 /** 371 * Event device information 372 */ 373 struct rte_event_dev_info { 374 const char *driver_name; /**< Event driver name */ 375 struct rte_device *dev; /**< Device information */ 376 uint32_t min_dequeue_timeout_ns; 377 /**< Minimum supported global dequeue timeout(ns) by this device */ 378 uint32_t max_dequeue_timeout_ns; 379 /**< Maximum supported global dequeue timeout(ns) by this device */ 380 uint32_t dequeue_timeout_ns; 381 /**< Configured global dequeue timeout(ns) for this device */ 382 uint8_t max_event_queues; 383 /**< Maximum event_queues supported by this device */ 384 uint32_t max_event_queue_flows; 385 /**< Maximum supported flows in an event queue by this device*/ 386 uint8_t max_event_queue_priority_levels; 387 /**< Maximum number of event queue priority levels by this device. 388 * Valid when the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability 389 */ 390 uint8_t max_event_priority_levels; 391 /**< Maximum number of event priority levels by this device. 392 * Valid when the device has RTE_EVENT_DEV_CAP_EVENT_QOS capability 393 */ 394 uint8_t max_event_ports; 395 /**< Maximum number of event ports supported by this device */ 396 uint8_t max_event_port_dequeue_depth; 397 /**< Maximum number of events can be dequeued at a time from an 398 * event port by this device. 399 * A device that does not support bulk dequeue will set this as 1. 400 */ 401 uint32_t max_event_port_enqueue_depth; 402 /**< Maximum number of events can be enqueued at a time from an 403 * event port by this device. 404 * A device that does not support bulk enqueue will set this as 1. 405 */ 406 uint8_t max_event_port_links; 407 /**< Maximum number of queues that can be linked to a single event 408 * port by this device. 409 */ 410 int32_t max_num_events; 411 /**< A *closed system* event dev has a limit on the number of events it 412 * can manage at a time. An *open system* event dev does not have a 413 * limit and will specify this as -1. 414 */ 415 uint32_t event_dev_cap; 416 /**< Event device capabilities(RTE_EVENT_DEV_CAP_)*/ 417 uint8_t max_single_link_event_port_queue_pairs; 418 /**< Maximum number of event ports and queues that are optimized for 419 * (and only capable of) single-link configurations supported by this 420 * device. These ports and queues are not accounted for in 421 * max_event_ports or max_event_queues. 422 */ 423 }; 424 425 /** 426 * Retrieve the contextual information of an event device. 427 * 428 * @param dev_id 429 * The identifier of the device. 430 * 431 * @param[out] dev_info 432 * A pointer to a structure of type *rte_event_dev_info* to be filled with the 433 * contextual information of the device. 434 * 435 * @return 436 * - 0: Success, driver updates the contextual information of the event device 437 * - <0: Error code returned by the driver info get function. 438 * 439 */ 440 int 441 rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info); 442 443 /** 444 * The count of ports. 445 */ 446 #define RTE_EVENT_DEV_ATTR_PORT_COUNT 0 447 /** 448 * The count of queues. 449 */ 450 #define RTE_EVENT_DEV_ATTR_QUEUE_COUNT 1 451 /** 452 * The status of the device, zero for stopped, non-zero for started. 453 */ 454 #define RTE_EVENT_DEV_ATTR_STARTED 2 455 456 /** 457 * Get an attribute from a device. 458 * 459 * @param dev_id Eventdev id 460 * @param attr_id The attribute ID to retrieve 461 * @param[out] attr_value A pointer that will be filled in with the attribute 462 * value if successful. 463 * 464 * @return 465 * - 0: Successfully retrieved attribute value 466 * - -EINVAL: Invalid device or *attr_id* provided, or *attr_value* is NULL 467 */ 468 int 469 rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id, 470 uint32_t *attr_value); 471 472 473 /* Event device configuration bitmap flags */ 474 #define RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT (1ULL << 0) 475 /**< Override the global *dequeue_timeout_ns* and use per dequeue timeout in ns. 476 * @see rte_event_dequeue_timeout_ticks(), rte_event_dequeue_burst() 477 */ 478 479 /** Event device configuration structure */ 480 struct rte_event_dev_config { 481 uint32_t dequeue_timeout_ns; 482 /**< rte_event_dequeue_burst() timeout on this device. 483 * This value should be in the range of *min_dequeue_timeout_ns* and 484 * *max_dequeue_timeout_ns* which previously provided in 485 * rte_event_dev_info_get() 486 * The value 0 is allowed, in which case, default dequeue timeout used. 487 * @see RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT 488 */ 489 int32_t nb_events_limit; 490 /**< In a *closed system* this field is the limit on maximum number of 491 * events that can be inflight in the eventdev at a given time. The 492 * limit is required to ensure that the finite space in a closed system 493 * is not overwhelmed. The value cannot exceed the *max_num_events* 494 * as provided by rte_event_dev_info_get(). 495 * This value should be set to -1 for *open system*. 496 */ 497 uint8_t nb_event_queues; 498 /**< Number of event queues to configure on this device. 499 * This value cannot exceed the *max_event_queues* which previously 500 * provided in rte_event_dev_info_get() 501 */ 502 uint8_t nb_event_ports; 503 /**< Number of event ports to configure on this device. 504 * This value cannot exceed the *max_event_ports* which previously 505 * provided in rte_event_dev_info_get() 506 */ 507 uint32_t nb_event_queue_flows; 508 /**< Number of flows for any event queue on this device. 509 * This value cannot exceed the *max_event_queue_flows* which previously 510 * provided in rte_event_dev_info_get() 511 */ 512 uint32_t nb_event_port_dequeue_depth; 513 /**< Maximum number of events can be dequeued at a time from an 514 * event port by this device. 515 * This value cannot exceed the *max_event_port_dequeue_depth* 516 * which previously provided in rte_event_dev_info_get(). 517 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable. 518 * @see rte_event_port_setup() 519 */ 520 uint32_t nb_event_port_enqueue_depth; 521 /**< Maximum number of events can be enqueued at a time from an 522 * event port by this device. 523 * This value cannot exceed the *max_event_port_enqueue_depth* 524 * which previously provided in rte_event_dev_info_get(). 525 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable. 526 * @see rte_event_port_setup() 527 */ 528 uint32_t event_dev_cfg; 529 /**< Event device config flags(RTE_EVENT_DEV_CFG_)*/ 530 uint8_t nb_single_link_event_port_queues; 531 /**< Number of event ports and queues that will be singly-linked to 532 * each other. These are a subset of the overall event ports and 533 * queues; this value cannot exceed *nb_event_ports* or 534 * *nb_event_queues*. If the device has ports and queues that are 535 * optimized for single-link usage, this field is a hint for how many 536 * to allocate; otherwise, regular event ports and queues can be used. 537 */ 538 }; 539 540 /** 541 * Configure an event device. 542 * 543 * This function must be invoked first before any other function in the 544 * API. This function can also be re-invoked when a device is in the 545 * stopped state. 546 * 547 * The caller may use rte_event_dev_info_get() to get the capability of each 548 * resources available for this event device. 549 * 550 * @param dev_id 551 * The identifier of the device to configure. 552 * @param dev_conf 553 * The event device configuration structure. 554 * 555 * @return 556 * - 0: Success, device configured. 557 * - <0: Error code returned by the driver configuration function. 558 */ 559 int 560 rte_event_dev_configure(uint8_t dev_id, 561 const struct rte_event_dev_config *dev_conf); 562 563 /* Event queue specific APIs */ 564 565 /* Event queue configuration bitmap flags */ 566 #define RTE_EVENT_QUEUE_CFG_ALL_TYPES (1ULL << 0) 567 /**< Allow ATOMIC,ORDERED,PARALLEL schedule type enqueue 568 * 569 * @see RTE_SCHED_TYPE_ORDERED, RTE_SCHED_TYPE_ATOMIC, RTE_SCHED_TYPE_PARALLEL 570 * @see rte_event_enqueue_burst() 571 */ 572 #define RTE_EVENT_QUEUE_CFG_SINGLE_LINK (1ULL << 1) 573 /**< This event queue links only to a single event port. 574 * 575 * @see rte_event_port_setup(), rte_event_port_link() 576 */ 577 578 /** Event queue configuration structure */ 579 struct rte_event_queue_conf { 580 uint32_t nb_atomic_flows; 581 /**< The maximum number of active flows this queue can track at any 582 * given time. If the queue is configured for atomic scheduling (by 583 * applying the RTE_EVENT_QUEUE_CFG_ALL_TYPES flag to event_queue_cfg 584 * or RTE_SCHED_TYPE_ATOMIC flag to schedule_type), then the 585 * value must be in the range of [1, nb_event_queue_flows], which was 586 * previously provided in rte_event_dev_configure(). 587 */ 588 uint32_t nb_atomic_order_sequences; 589 /**< The maximum number of outstanding events waiting to be 590 * reordered by this queue. In other words, the number of entries in 591 * this queue’s reorder buffer.When the number of events in the 592 * reorder buffer reaches to *nb_atomic_order_sequences* then the 593 * scheduler cannot schedule the events from this queue and invalid 594 * event will be returned from dequeue until one or more entries are 595 * freed up/released. 596 * If the queue is configured for ordered scheduling (by applying the 597 * RTE_EVENT_QUEUE_CFG_ALL_TYPES flag to event_queue_cfg or 598 * RTE_SCHED_TYPE_ORDERED flag to schedule_type), then the value must 599 * be in the range of [1, nb_event_queue_flows], which was 600 * previously supplied to rte_event_dev_configure(). 601 */ 602 uint32_t event_queue_cfg; 603 /**< Queue cfg flags(EVENT_QUEUE_CFG_) */ 604 uint8_t schedule_type; 605 /**< Queue schedule type(RTE_SCHED_TYPE_*). 606 * Valid when RTE_EVENT_QUEUE_CFG_ALL_TYPES bit is not set in 607 * event_queue_cfg. 608 */ 609 uint8_t priority; 610 /**< Priority for this event queue relative to other event queues. 611 * The requested priority should in the range of 612 * [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST]. 613 * The implementation shall normalize the requested priority to 614 * event device supported priority value. 615 * Valid when the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability 616 */ 617 }; 618 619 /** 620 * Retrieve the default configuration information of an event queue designated 621 * by its *queue_id* from the event driver for an event device. 622 * 623 * This function intended to be used in conjunction with rte_event_queue_setup() 624 * where caller needs to set up the queue by overriding few default values. 625 * 626 * @param dev_id 627 * The identifier of the device. 628 * @param queue_id 629 * The index of the event queue to get the configuration information. 630 * The value must be in the range [0, nb_event_queues - 1] 631 * previously supplied to rte_event_dev_configure(). 632 * @param[out] queue_conf 633 * The pointer to the default event queue configuration data. 634 * @return 635 * - 0: Success, driver updates the default event queue configuration data. 636 * - <0: Error code returned by the driver info get function. 637 * 638 * @see rte_event_queue_setup() 639 * 640 */ 641 int 642 rte_event_queue_default_conf_get(uint8_t dev_id, uint8_t queue_id, 643 struct rte_event_queue_conf *queue_conf); 644 645 /** 646 * Allocate and set up an event queue for an event device. 647 * 648 * @param dev_id 649 * The identifier of the device. 650 * @param queue_id 651 * The index of the event queue to setup. The value must be in the range 652 * [0, nb_event_queues - 1] previously supplied to rte_event_dev_configure(). 653 * @param queue_conf 654 * The pointer to the configuration data to be used for the event queue. 655 * NULL value is allowed, in which case default configuration used. 656 * 657 * @see rte_event_queue_default_conf_get() 658 * 659 * @return 660 * - 0: Success, event queue correctly set up. 661 * - <0: event queue configuration failed 662 */ 663 int 664 rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id, 665 const struct rte_event_queue_conf *queue_conf); 666 667 /** 668 * The priority of the queue. 669 */ 670 #define RTE_EVENT_QUEUE_ATTR_PRIORITY 0 671 /** 672 * The number of atomic flows configured for the queue. 673 */ 674 #define RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_FLOWS 1 675 /** 676 * The number of atomic order sequences configured for the queue. 677 */ 678 #define RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_ORDER_SEQUENCES 2 679 /** 680 * The cfg flags for the queue. 681 */ 682 #define RTE_EVENT_QUEUE_ATTR_EVENT_QUEUE_CFG 3 683 /** 684 * The schedule type of the queue. 685 */ 686 #define RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE 4 687 688 /** 689 * Get an attribute from a queue. 690 * 691 * @param dev_id 692 * Eventdev id 693 * @param queue_id 694 * Eventdev queue id 695 * @param attr_id 696 * The attribute ID to retrieve 697 * @param[out] attr_value 698 * A pointer that will be filled in with the attribute value if successful 699 * 700 * @return 701 * - 0: Successfully returned value 702 * - -EINVAL: invalid device, queue or attr_id provided, or attr_value was 703 * NULL 704 * - -EOVERFLOW: returned when attr_id is set to 705 * RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE and event_queue_cfg is set to 706 * RTE_EVENT_QUEUE_CFG_ALL_TYPES 707 */ 708 int 709 rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id, 710 uint32_t *attr_value); 711 712 /** 713 * Set an event queue attribute. 714 * 715 * @param dev_id 716 * Eventdev id 717 * @param queue_id 718 * Eventdev queue id 719 * @param attr_id 720 * The attribute ID to set 721 * @param attr_value 722 * The attribute value to set 723 * 724 * @return 725 * - 0: Successfully set attribute. 726 * - -EINVAL: invalid device, queue or attr_id. 727 * - -ENOTSUP: device does not support setting the event attribute. 728 * - <0: failed to set event queue attribute 729 */ 730 __rte_experimental 731 int 732 rte_event_queue_attr_set(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id, 733 uint64_t attr_value); 734 735 /* Event port specific APIs */ 736 737 /* Event port configuration bitmap flags */ 738 #define RTE_EVENT_PORT_CFG_DISABLE_IMPL_REL (1ULL << 0) 739 /**< Configure the port not to release outstanding events in 740 * rte_event_dev_dequeue_burst(). If set, all events received through 741 * the port must be explicitly released with RTE_EVENT_OP_RELEASE or 742 * RTE_EVENT_OP_FORWARD. Must be unset if the device is not 743 * RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE capable. 744 */ 745 #define RTE_EVENT_PORT_CFG_SINGLE_LINK (1ULL << 1) 746 /**< This event port links only to a single event queue. 747 * 748 * @see rte_event_port_setup(), rte_event_port_link() 749 */ 750 #define RTE_EVENT_PORT_CFG_HINT_PRODUCER (1ULL << 2) 751 /**< Hint that this event port will primarily enqueue events to the system. 752 * A PMD can optimize its internal workings by assuming that this port is 753 * primarily going to enqueue NEW events. 754 * 755 * Note that this flag is only a hint, so PMDs must operate under the 756 * assumption that any port can enqueue an event with any type of op. 757 * 758 * @see rte_event_port_setup() 759 */ 760 #define RTE_EVENT_PORT_CFG_HINT_CONSUMER (1ULL << 3) 761 /**< Hint that this event port will primarily dequeue events from the system. 762 * A PMD can optimize its internal workings by assuming that this port is 763 * primarily going to consume events, and not enqueue FORWARD or RELEASE 764 * events. 765 * 766 * Note that this flag is only a hint, so PMDs must operate under the 767 * assumption that any port can enqueue an event with any type of op. 768 * 769 * @see rte_event_port_setup() 770 */ 771 #define RTE_EVENT_PORT_CFG_HINT_WORKER (1ULL << 4) 772 /**< Hint that this event port will primarily pass existing events through. 773 * A PMD can optimize its internal workings by assuming that this port is 774 * primarily going to FORWARD events, and not enqueue NEW or RELEASE events 775 * often. 776 * 777 * Note that this flag is only a hint, so PMDs must operate under the 778 * assumption that any port can enqueue an event with any type of op. 779 * 780 * @see rte_event_port_setup() 781 */ 782 783 /** Event port configuration structure */ 784 struct rte_event_port_conf { 785 int32_t new_event_threshold; 786 /**< A backpressure threshold for new event enqueues on this port. 787 * Use for *closed system* event dev where event capacity is limited, 788 * and cannot exceed the capacity of the event dev. 789 * Configuring ports with different thresholds can make higher priority 790 * traffic less likely to be backpressured. 791 * For example, a port used to inject NIC Rx packets into the event dev 792 * can have a lower threshold so as not to overwhelm the device, 793 * while ports used for worker pools can have a higher threshold. 794 * This value cannot exceed the *nb_events_limit* 795 * which was previously supplied to rte_event_dev_configure(). 796 * This should be set to '-1' for *open system*. 797 */ 798 uint16_t dequeue_depth; 799 /**< Configure number of bulk dequeues for this event port. 800 * This value cannot exceed the *nb_event_port_dequeue_depth* 801 * which previously supplied to rte_event_dev_configure(). 802 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable. 803 */ 804 uint16_t enqueue_depth; 805 /**< Configure number of bulk enqueues for this event port. 806 * This value cannot exceed the *nb_event_port_enqueue_depth* 807 * which previously supplied to rte_event_dev_configure(). 808 * Ignored when device is not RTE_EVENT_DEV_CAP_BURST_MODE capable. 809 */ 810 uint32_t event_port_cfg; /**< Port cfg flags(EVENT_PORT_CFG_) */ 811 }; 812 813 /** 814 * Retrieve the default configuration information of an event port designated 815 * by its *port_id* from the event driver for an event device. 816 * 817 * This function intended to be used in conjunction with rte_event_port_setup() 818 * where caller needs to set up the port by overriding few default values. 819 * 820 * @param dev_id 821 * The identifier of the device. 822 * @param port_id 823 * The index of the event port to get the configuration information. 824 * The value must be in the range [0, nb_event_ports - 1] 825 * previously supplied to rte_event_dev_configure(). 826 * @param[out] port_conf 827 * The pointer to the default event port configuration data 828 * @return 829 * - 0: Success, driver updates the default event port configuration data. 830 * - <0: Error code returned by the driver info get function. 831 * 832 * @see rte_event_port_setup() 833 * 834 */ 835 int 836 rte_event_port_default_conf_get(uint8_t dev_id, uint8_t port_id, 837 struct rte_event_port_conf *port_conf); 838 839 /** 840 * Allocate and set up an event port for an event device. 841 * 842 * @param dev_id 843 * The identifier of the device. 844 * @param port_id 845 * The index of the event port to setup. The value must be in the range 846 * [0, nb_event_ports - 1] previously supplied to rte_event_dev_configure(). 847 * @param port_conf 848 * The pointer to the configuration data to be used for the queue. 849 * NULL value is allowed, in which case default configuration used. 850 * 851 * @see rte_event_port_default_conf_get() 852 * 853 * @return 854 * - 0: Success, event port correctly set up. 855 * - <0: Port configuration failed 856 * - (-EDQUOT) Quota exceeded(Application tried to link the queue configured 857 * with RTE_EVENT_QUEUE_CFG_SINGLE_LINK to more than one event ports) 858 */ 859 int 860 rte_event_port_setup(uint8_t dev_id, uint8_t port_id, 861 const struct rte_event_port_conf *port_conf); 862 863 typedef void (*rte_eventdev_port_flush_t)(uint8_t dev_id, 864 struct rte_event event, void *arg); 865 /**< Callback function prototype that can be passed during 866 * rte_event_port_release(), invoked once per a released event. 867 */ 868 869 /** 870 * Quiesce any core specific resources consumed by the event port. 871 * 872 * Event ports are generally coupled with lcores, and a given Hardware 873 * implementation might require the PMD to store port specific data in the 874 * lcore. 875 * When the application decides to migrate the event port to another lcore 876 * or teardown the current lcore it may to call `rte_event_port_quiesce` 877 * to make sure that all the data associated with the event port are released 878 * from the lcore, this might also include any prefetched events. 879 * While releasing the event port from the lcore, this function calls the 880 * user-provided flush callback once per event. 881 * 882 * @note Invocation of this API does not affect the existing port configuration. 883 * 884 * @param dev_id 885 * The identifier of the device. 886 * @param port_id 887 * The index of the event port to setup. The value must be in the range 888 * [0, nb_event_ports - 1] previously supplied to rte_event_dev_configure(). 889 * @param release_cb 890 * Callback function invoked once per flushed event. 891 * @param args 892 * Argument supplied to callback. 893 */ 894 __rte_experimental 895 void 896 rte_event_port_quiesce(uint8_t dev_id, uint8_t port_id, 897 rte_eventdev_port_flush_t release_cb, void *args); 898 899 /** 900 * The queue depth of the port on the enqueue side 901 */ 902 #define RTE_EVENT_PORT_ATTR_ENQ_DEPTH 0 903 /** 904 * The queue depth of the port on the dequeue side 905 */ 906 #define RTE_EVENT_PORT_ATTR_DEQ_DEPTH 1 907 /** 908 * The new event threshold of the port 909 */ 910 #define RTE_EVENT_PORT_ATTR_NEW_EVENT_THRESHOLD 2 911 /** 912 * The implicit release disable attribute of the port 913 */ 914 #define RTE_EVENT_PORT_ATTR_IMPLICIT_RELEASE_DISABLE 3 915 916 /** 917 * Get an attribute from a port. 918 * 919 * @param dev_id 920 * Eventdev id 921 * @param port_id 922 * Eventdev port id 923 * @param attr_id 924 * The attribute ID to retrieve 925 * @param[out] attr_value 926 * A pointer that will be filled in with the attribute value if successful 927 * 928 * @return 929 * - 0: Successfully returned value 930 * - (-EINVAL) Invalid device, port or attr_id, or attr_value was NULL 931 */ 932 int 933 rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, 934 uint32_t *attr_value); 935 936 /** 937 * Start an event device. 938 * 939 * The device start step is the last one and consists of setting the event 940 * queues to start accepting the events and schedules to event ports. 941 * 942 * On success, all basic functions exported by the API (event enqueue, 943 * event dequeue and so on) can be invoked. 944 * 945 * @param dev_id 946 * Event device identifier 947 * @return 948 * - 0: Success, device started. 949 * - -ESTALE : Not all ports of the device are configured 950 * - -ENOLINK: Not all queues are linked, which could lead to deadlock. 951 */ 952 int 953 rte_event_dev_start(uint8_t dev_id); 954 955 /** 956 * Stop an event device. 957 * 958 * This function causes all queued events to be drained, including those 959 * residing in event ports. While draining events out of the device, this 960 * function calls the user-provided flush callback (if one was registered) once 961 * per event. 962 * 963 * The device can be restarted with a call to rte_event_dev_start(). Threads 964 * that continue to enqueue/dequeue while the device is stopped, or being 965 * stopped, will result in undefined behavior. This includes event adapters, 966 * which must be stopped prior to stopping the eventdev. 967 * 968 * @param dev_id 969 * Event device identifier. 970 * 971 * @see rte_event_dev_stop_flush_callback_register() 972 */ 973 void 974 rte_event_dev_stop(uint8_t dev_id); 975 976 typedef void (*eventdev_stop_flush_t)(uint8_t dev_id, struct rte_event event, 977 void *arg); 978 /**< Callback function called during rte_event_dev_stop(), invoked once per 979 * flushed event. 980 */ 981 982 /** 983 * Registers a callback function to be invoked during rte_event_dev_stop() for 984 * each flushed event. This function can be used to properly dispose of queued 985 * events, for example events containing memory pointers. 986 * 987 * The callback function is only registered for the calling process. The 988 * callback function must be registered in every process that can call 989 * rte_event_dev_stop(). 990 * 991 * To unregister a callback, call this function with a NULL callback pointer. 992 * 993 * @param dev_id 994 * The identifier of the device. 995 * @param callback 996 * Callback function invoked once per flushed event. 997 * @param userdata 998 * Argument supplied to callback. 999 * 1000 * @return 1001 * - 0 on success. 1002 * - -EINVAL if *dev_id* is invalid 1003 * 1004 * @see rte_event_dev_stop() 1005 */ 1006 int 1007 rte_event_dev_stop_flush_callback_register(uint8_t dev_id, 1008 eventdev_stop_flush_t callback, void *userdata); 1009 1010 /** 1011 * Close an event device. The device cannot be restarted! 1012 * 1013 * @param dev_id 1014 * Event device identifier 1015 * 1016 * @return 1017 * - 0 on successfully closing device 1018 * - <0 on failure to close device 1019 * - (-EAGAIN) if device is busy 1020 */ 1021 int 1022 rte_event_dev_close(uint8_t dev_id); 1023 1024 /** 1025 * Event vector structure. 1026 */ 1027 struct rte_event_vector { 1028 uint16_t nb_elem; 1029 /**< Number of elements in this event vector. */ 1030 uint16_t rsvd : 15; 1031 /**< Reserved for future use */ 1032 uint16_t attr_valid : 1; 1033 /**< Indicates that the below union attributes have valid information. 1034 */ 1035 union { 1036 /* Used by Rx/Tx adapter. 1037 * Indicates that all the elements in this vector belong to the 1038 * same port and queue pair when originating from Rx adapter, 1039 * valid only when event type is ETHDEV_VECTOR or 1040 * ETH_RX_ADAPTER_VECTOR. 1041 * Can also be used to indicate the Tx adapter the destination 1042 * port and queue of the mbufs in the vector 1043 */ 1044 struct { 1045 uint16_t port; 1046 /* Ethernet device port id. */ 1047 uint16_t queue; 1048 /* Ethernet device queue id. */ 1049 }; 1050 }; 1051 /**< Union to hold common attributes of the vector array. */ 1052 uint64_t impl_opaque; 1053 1054 /* empty structures do not have zero size in C++ leading to compilation errors 1055 * with clang about structure having different sizes in C and C++. 1056 * Since these are all zero-sized arrays, we can omit the "union" wrapper for 1057 * C++ builds, removing the warning. 1058 */ 1059 #ifndef __cplusplus 1060 /**< Implementation specific opaque value. 1061 * An implementation may use this field to hold implementation specific 1062 * value to share between dequeue and enqueue operation. 1063 * The application should not modify this field. 1064 */ 1065 union { 1066 #endif 1067 struct rte_mbuf *mbufs[0]; 1068 void *ptrs[0]; 1069 uint64_t *u64s[0]; 1070 #ifndef __cplusplus 1071 } __rte_aligned(16); 1072 #endif 1073 /**< Start of the vector array union. Depending upon the event type the 1074 * vector array can be an array of mbufs or pointers or opaque u64 1075 * values. 1076 */ 1077 } __rte_aligned(16); 1078 1079 /* Scheduler type definitions */ 1080 #define RTE_SCHED_TYPE_ORDERED 0 1081 /**< Ordered scheduling 1082 * 1083 * Events from an ordered flow of an event queue can be scheduled to multiple 1084 * ports for concurrent processing while maintaining the original event order. 1085 * This scheme enables the user to achieve high single flow throughput by 1086 * avoiding SW synchronization for ordering between ports which bound to cores. 1087 * 1088 * The source flow ordering from an event queue is maintained when events are 1089 * enqueued to their destination queue within the same ordered flow context. 1090 * An event port holds the context until application call 1091 * rte_event_dequeue_burst() from the same port, which implicitly releases 1092 * the context. 1093 * User may allow the scheduler to release the context earlier than that 1094 * by invoking rte_event_enqueue_burst() with RTE_EVENT_OP_RELEASE operation. 1095 * 1096 * Events from the source queue appear in their original order when dequeued 1097 * from a destination queue. 1098 * Event ordering is based on the received event(s), but also other 1099 * (newly allocated or stored) events are ordered when enqueued within the same 1100 * ordered context. Events not enqueued (e.g. released or stored) within the 1101 * context are considered missing from reordering and are skipped at this time 1102 * (but can be ordered again within another context). 1103 * 1104 * @see rte_event_queue_setup(), rte_event_dequeue_burst(), RTE_EVENT_OP_RELEASE 1105 */ 1106 1107 #define RTE_SCHED_TYPE_ATOMIC 1 1108 /**< Atomic scheduling 1109 * 1110 * Events from an atomic flow of an event queue can be scheduled only to a 1111 * single port at a time. The port is guaranteed to have exclusive (atomic) 1112 * access to the associated flow context, which enables the user to avoid SW 1113 * synchronization. Atomic flows also help to maintain event ordering 1114 * since only one port at a time can process events from a flow of an 1115 * event queue. 1116 * 1117 * The atomic queue synchronization context is dedicated to the port until 1118 * application call rte_event_dequeue_burst() from the same port, 1119 * which implicitly releases the context. User may allow the scheduler to 1120 * release the context earlier than that by invoking rte_event_enqueue_burst() 1121 * with RTE_EVENT_OP_RELEASE operation. 1122 * 1123 * @see rte_event_queue_setup(), rte_event_dequeue_burst(), RTE_EVENT_OP_RELEASE 1124 */ 1125 1126 #define RTE_SCHED_TYPE_PARALLEL 2 1127 /**< Parallel scheduling 1128 * 1129 * The scheduler performs priority scheduling, load balancing, etc. functions 1130 * but does not provide additional event synchronization or ordering. 1131 * It is free to schedule events from a single parallel flow of an event queue 1132 * to multiple events ports for concurrent processing. 1133 * The application is responsible for flow context synchronization and 1134 * event ordering (SW synchronization). 1135 * 1136 * @see rte_event_queue_setup(), rte_event_dequeue_burst() 1137 */ 1138 1139 /* Event types to classify the event source */ 1140 #define RTE_EVENT_TYPE_ETHDEV 0x0 1141 /**< The event generated from ethdev subsystem */ 1142 #define RTE_EVENT_TYPE_CRYPTODEV 0x1 1143 /**< The event generated from crypodev subsystem */ 1144 #define RTE_EVENT_TYPE_TIMER 0x2 1145 /**< The event generated from event timer adapter */ 1146 #define RTE_EVENT_TYPE_CPU 0x3 1147 /**< The event generated from cpu for pipelining. 1148 * Application may use *sub_event_type* to further classify the event 1149 */ 1150 #define RTE_EVENT_TYPE_ETH_RX_ADAPTER 0x4 1151 /**< The event generated from event eth Rx adapter */ 1152 #define RTE_EVENT_TYPE_VECTOR 0x8 1153 /**< Indicates that event is a vector. 1154 * All vector event types should be a logical OR of EVENT_TYPE_VECTOR. 1155 * This simplifies the pipeline design as one can split processing the events 1156 * between vector events and normal event across event types. 1157 * Example: 1158 * if (ev.event_type & RTE_EVENT_TYPE_VECTOR) { 1159 * // Classify and handle vector event. 1160 * } else { 1161 * // Classify and handle event. 1162 * } 1163 */ 1164 #define RTE_EVENT_TYPE_ETHDEV_VECTOR \ 1165 (RTE_EVENT_TYPE_VECTOR | RTE_EVENT_TYPE_ETHDEV) 1166 /**< The event vector generated from ethdev subsystem */ 1167 #define RTE_EVENT_TYPE_CPU_VECTOR (RTE_EVENT_TYPE_VECTOR | RTE_EVENT_TYPE_CPU) 1168 /**< The event vector generated from cpu for pipelining. */ 1169 #define RTE_EVENT_TYPE_ETH_RX_ADAPTER_VECTOR \ 1170 (RTE_EVENT_TYPE_VECTOR | RTE_EVENT_TYPE_ETH_RX_ADAPTER) 1171 /**< The event vector generated from eth Rx adapter. */ 1172 1173 #define RTE_EVENT_TYPE_MAX 0x10 1174 /**< Maximum number of event types */ 1175 1176 /* Event enqueue operations */ 1177 #define RTE_EVENT_OP_NEW 0 1178 /**< The event producers use this operation to inject a new event to the 1179 * event device. 1180 */ 1181 #define RTE_EVENT_OP_FORWARD 1 1182 /**< The CPU use this operation to forward the event to different event queue or 1183 * change to new application specific flow or schedule type to enable 1184 * pipelining. 1185 * 1186 * This operation must only be enqueued to the same port that the 1187 * event to be forwarded was dequeued from. 1188 */ 1189 #define RTE_EVENT_OP_RELEASE 2 1190 /**< Release the flow context associated with the schedule type. 1191 * 1192 * If current flow's scheduler type method is *RTE_SCHED_TYPE_ATOMIC* 1193 * then this function hints the scheduler that the user has completed critical 1194 * section processing in the current atomic context. 1195 * The scheduler is now allowed to schedule events from the same flow from 1196 * an event queue to another port. However, the context may be still held 1197 * until the next rte_event_dequeue_burst() call, this call allows but does not 1198 * force the scheduler to release the context early. 1199 * 1200 * Early atomic context release may increase parallelism and thus system 1201 * performance, but the user needs to design carefully the split into critical 1202 * vs non-critical sections. 1203 * 1204 * If current flow's scheduler type method is *RTE_SCHED_TYPE_ORDERED* 1205 * then this function hints the scheduler that the user has done all that need 1206 * to maintain event order in the current ordered context. 1207 * The scheduler is allowed to release the ordered context of this port and 1208 * avoid reordering any following enqueues. 1209 * 1210 * Early ordered context release may increase parallelism and thus system 1211 * performance. 1212 * 1213 * If current flow's scheduler type method is *RTE_SCHED_TYPE_PARALLEL* 1214 * or no scheduling context is held then this function may be an NOOP, 1215 * depending on the implementation. 1216 * 1217 * This operation must only be enqueued to the same port that the 1218 * event to be released was dequeued from. 1219 * 1220 */ 1221 1222 /** 1223 * The generic *rte_event* structure to hold the event attributes 1224 * for dequeue and enqueue operation 1225 */ 1226 RTE_STD_C11 1227 struct rte_event { 1228 /** WORD0 */ 1229 union { 1230 uint64_t event; 1231 /** Event attributes for dequeue or enqueue operation */ 1232 struct { 1233 uint32_t flow_id:20; 1234 /**< Targeted flow identifier for the enqueue and 1235 * dequeue operation. 1236 * The value must be in the range of 1237 * [0, nb_event_queue_flows - 1] which 1238 * previously supplied to rte_event_dev_configure(). 1239 */ 1240 uint32_t sub_event_type:8; 1241 /**< Sub-event types based on the event source. 1242 * @see RTE_EVENT_TYPE_CPU 1243 */ 1244 uint32_t event_type:4; 1245 /**< Event type to classify the event source. 1246 * @see RTE_EVENT_TYPE_ETHDEV, (RTE_EVENT_TYPE_*) 1247 */ 1248 uint8_t op:2; 1249 /**< The type of event enqueue operation - new/forward/ 1250 * etc.This field is not preserved across an instance 1251 * and is undefined on dequeue. 1252 * @see RTE_EVENT_OP_NEW, (RTE_EVENT_OP_*) 1253 */ 1254 uint8_t rsvd:4; 1255 /**< Reserved for future use */ 1256 uint8_t sched_type:2; 1257 /**< Scheduler synchronization type (RTE_SCHED_TYPE_*) 1258 * associated with flow id on a given event queue 1259 * for the enqueue and dequeue operation. 1260 */ 1261 uint8_t queue_id; 1262 /**< Targeted event queue identifier for the enqueue or 1263 * dequeue operation. 1264 * The value must be in the range of 1265 * [0, nb_event_queues - 1] which previously supplied to 1266 * rte_event_dev_configure(). 1267 */ 1268 uint8_t priority; 1269 /**< Event priority relative to other events in the 1270 * event queue. The requested priority should in the 1271 * range of [RTE_EVENT_DEV_PRIORITY_HIGHEST, 1272 * RTE_EVENT_DEV_PRIORITY_LOWEST]. 1273 * The implementation shall normalize the requested 1274 * priority to supported priority value. 1275 * Valid when the device has 1276 * RTE_EVENT_DEV_CAP_EVENT_QOS capability. 1277 */ 1278 uint8_t impl_opaque; 1279 /**< Implementation specific opaque value. 1280 * An implementation may use this field to hold 1281 * implementation specific value to share between 1282 * dequeue and enqueue operation. 1283 * The application should not modify this field. 1284 */ 1285 }; 1286 }; 1287 /** WORD1 */ 1288 union { 1289 uint64_t u64; 1290 /**< Opaque 64-bit value */ 1291 void *event_ptr; 1292 /**< Opaque event pointer */ 1293 struct rte_mbuf *mbuf; 1294 /**< mbuf pointer if dequeued event is associated with mbuf */ 1295 struct rte_event_vector *vec; 1296 /**< Event vector pointer. */ 1297 }; 1298 }; 1299 1300 /* Ethdev Rx adapter capability bitmap flags */ 1301 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT 0x1 1302 /**< This flag is sent when the packet transfer mechanism is in HW. 1303 * Ethdev can send packets to the event device using internal event port. 1304 */ 1305 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ 0x2 1306 /**< Adapter supports multiple event queues per ethdev. Every ethdev 1307 * Rx queue can be connected to a unique event queue. 1308 */ 1309 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_OVERRIDE_FLOW_ID 0x4 1310 /**< The application can override the adapter generated flow ID in the 1311 * event. This flow ID can be specified when adding an ethdev Rx queue 1312 * to the adapter using the ev.flow_id member. 1313 * @see struct rte_event_eth_rx_adapter_queue_conf::ev 1314 * @see struct rte_event_eth_rx_adapter_queue_conf::rx_queue_flags 1315 */ 1316 #define RTE_EVENT_ETH_RX_ADAPTER_CAP_EVENT_VECTOR 0x8 1317 /**< Adapter supports event vectorization per ethdev. */ 1318 1319 /** 1320 * Retrieve the event device's ethdev Rx adapter capabilities for the 1321 * specified ethernet port 1322 * 1323 * @param dev_id 1324 * The identifier of the device. 1325 * 1326 * @param eth_port_id 1327 * The identifier of the ethernet device. 1328 * 1329 * @param[out] caps 1330 * A pointer to memory filled with Rx event adapter capabilities. 1331 * 1332 * @return 1333 * - 0: Success, driver provides Rx event adapter capabilities for the 1334 * ethernet device. 1335 * - <0: Error code returned by the driver function. 1336 * 1337 */ 1338 int 1339 rte_event_eth_rx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id, 1340 uint32_t *caps); 1341 1342 #define RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT (1ULL << 0) 1343 /**< This flag is set when the timer mechanism is in HW. */ 1344 1345 #define RTE_EVENT_TIMER_ADAPTER_CAP_PERIODIC (1ULL << 1) 1346 /**< This flag is set if periodic mode is supported. */ 1347 1348 /** 1349 * Retrieve the event device's timer adapter capabilities. 1350 * 1351 * @param dev_id 1352 * The identifier of the device. 1353 * 1354 * @param[out] caps 1355 * A pointer to memory to be filled with event timer adapter capabilities. 1356 * 1357 * @return 1358 * - 0: Success, driver provided event timer adapter capabilities. 1359 * - <0: Error code returned by the driver function. 1360 */ 1361 int 1362 rte_event_timer_adapter_caps_get(uint8_t dev_id, uint32_t *caps); 1363 1364 /* Crypto adapter capability bitmap flag */ 1365 #define RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW 0x1 1366 /**< Flag indicates HW is capable of generating events in 1367 * RTE_EVENT_OP_NEW enqueue operation. Cryptodev will send 1368 * packets to the event device as new events using an internal 1369 * event port. 1370 */ 1371 1372 #define RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD 0x2 1373 /**< Flag indicates HW is capable of generating events in 1374 * RTE_EVENT_OP_FORWARD enqueue operation. Cryptodev will send 1375 * packets to the event device as forwarded event using an 1376 * internal event port. 1377 */ 1378 1379 #define RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND 0x4 1380 /**< Flag indicates HW is capable of mapping crypto queue pair to 1381 * event queue. 1382 */ 1383 1384 #define RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA 0x8 1385 /**< Flag indicates HW/SW supports a mechanism to store and retrieve 1386 * the private data information along with the crypto session. 1387 */ 1388 1389 /** 1390 * Retrieve the event device's crypto adapter capabilities for the 1391 * specified cryptodev device 1392 * 1393 * @param dev_id 1394 * The identifier of the device. 1395 * 1396 * @param cdev_id 1397 * The identifier of the cryptodev device. 1398 * 1399 * @param[out] caps 1400 * A pointer to memory filled with event adapter capabilities. 1401 * It is expected to be pre-allocated & initialized by caller. 1402 * 1403 * @return 1404 * - 0: Success, driver provides event adapter capabilities for the 1405 * cryptodev device. 1406 * - <0: Error code returned by the driver function. 1407 * 1408 */ 1409 int 1410 rte_event_crypto_adapter_caps_get(uint8_t dev_id, uint8_t cdev_id, 1411 uint32_t *caps); 1412 1413 /* Ethdev Tx adapter capability bitmap flags */ 1414 #define RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT 0x1 1415 /**< This flag is sent when the PMD supports a packet transmit callback 1416 */ 1417 #define RTE_EVENT_ETH_TX_ADAPTER_CAP_EVENT_VECTOR 0x2 1418 /**< Indicates that the Tx adapter is capable of handling event vector of 1419 * mbufs. 1420 */ 1421 1422 /** 1423 * Retrieve the event device's eth Tx adapter capabilities 1424 * 1425 * @param dev_id 1426 * The identifier of the device. 1427 * 1428 * @param eth_port_id 1429 * The identifier of the ethernet device. 1430 * 1431 * @param[out] caps 1432 * A pointer to memory filled with eth Tx adapter capabilities. 1433 * 1434 * @return 1435 * - 0: Success, driver provides eth Tx adapter capabilities. 1436 * - <0: Error code returned by the driver function. 1437 * 1438 */ 1439 int 1440 rte_event_eth_tx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id, 1441 uint32_t *caps); 1442 1443 /** 1444 * Converts nanoseconds to *timeout_ticks* value for rte_event_dequeue_burst() 1445 * 1446 * If the device is configured with RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT flag 1447 * then application can use this function to convert timeout value in 1448 * nanoseconds to implementations specific timeout value supplied in 1449 * rte_event_dequeue_burst() 1450 * 1451 * @param dev_id 1452 * The identifier of the device. 1453 * @param ns 1454 * Wait time in nanosecond 1455 * @param[out] timeout_ticks 1456 * Value for the *timeout_ticks* parameter in rte_event_dequeue_burst() 1457 * 1458 * @return 1459 * - 0 on success. 1460 * - -ENOTSUP if the device doesn't support timeouts 1461 * - -EINVAL if *dev_id* is invalid or *timeout_ticks* is NULL 1462 * - other values < 0 on failure. 1463 * 1464 * @see rte_event_dequeue_burst(), RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT 1465 * @see rte_event_dev_configure() 1466 * 1467 */ 1468 int 1469 rte_event_dequeue_timeout_ticks(uint8_t dev_id, uint64_t ns, 1470 uint64_t *timeout_ticks); 1471 1472 /** 1473 * Link multiple source event queues supplied in *queues* to the destination 1474 * event port designated by its *port_id* with associated service priority 1475 * supplied in *priorities* on the event device designated by its *dev_id*. 1476 * 1477 * The link establishment shall enable the event port *port_id* from 1478 * receiving events from the specified event queue(s) supplied in *queues* 1479 * 1480 * An event queue may link to one or more event ports. 1481 * The number of links can be established from an event queue to event port is 1482 * implementation defined. 1483 * 1484 * Event queue(s) to event port link establishment can be changed at runtime 1485 * without re-configuring the device to support scaling and to reduce the 1486 * latency of critical work by establishing the link with more event ports 1487 * at runtime. 1488 * 1489 * @param dev_id 1490 * The identifier of the device. 1491 * 1492 * @param port_id 1493 * Event port identifier to select the destination port to link. 1494 * 1495 * @param queues 1496 * Points to an array of *nb_links* event queues to be linked 1497 * to the event port. 1498 * NULL value is allowed, in which case this function links all the configured 1499 * event queues *nb_event_queues* which previously supplied to 1500 * rte_event_dev_configure() to the event port *port_id* 1501 * 1502 * @param priorities 1503 * Points to an array of *nb_links* service priorities associated with each 1504 * event queue link to event port. 1505 * The priority defines the event port's servicing priority for 1506 * event queue, which may be ignored by an implementation. 1507 * The requested priority should in the range of 1508 * [RTE_EVENT_DEV_PRIORITY_HIGHEST, RTE_EVENT_DEV_PRIORITY_LOWEST]. 1509 * The implementation shall normalize the requested priority to 1510 * implementation supported priority value. 1511 * NULL value is allowed, in which case this function links the event queues 1512 * with RTE_EVENT_DEV_PRIORITY_NORMAL servicing priority 1513 * 1514 * @param nb_links 1515 * The number of links to establish. This parameter is ignored if queues is 1516 * NULL. 1517 * 1518 * @return 1519 * The number of links actually established. The return value can be less than 1520 * the value of the *nb_links* parameter when the implementation has the 1521 * limitation on specific queue to port link establishment or if invalid 1522 * parameters are specified in *queues* 1523 * If the return value is less than *nb_links*, the remaining links at the end 1524 * of link[] are not established, and the caller has to take care of them. 1525 * If return value is less than *nb_links* then implementation shall update the 1526 * rte_errno accordingly, Possible rte_errno values are 1527 * (EDQUOT) Quota exceeded(Application tried to link the queue configured with 1528 * RTE_EVENT_QUEUE_CFG_SINGLE_LINK to more than one event ports) 1529 * (EINVAL) Invalid parameter 1530 * 1531 */ 1532 int 1533 rte_event_port_link(uint8_t dev_id, uint8_t port_id, 1534 const uint8_t queues[], const uint8_t priorities[], 1535 uint16_t nb_links); 1536 1537 /** 1538 * Unlink multiple source event queues supplied in *queues* from the destination 1539 * event port designated by its *port_id* on the event device designated 1540 * by its *dev_id*. 1541 * 1542 * The unlink call issues an async request to disable the event port *port_id* 1543 * from receiving events from the specified event queue *queue_id*. 1544 * Event queue(s) to event port unlink establishment can be changed at runtime 1545 * without re-configuring the device. 1546 * 1547 * @see rte_event_port_unlinks_in_progress() to poll for completed unlinks. 1548 * 1549 * @param dev_id 1550 * The identifier of the device. 1551 * 1552 * @param port_id 1553 * Event port identifier to select the destination port to unlink. 1554 * 1555 * @param queues 1556 * Points to an array of *nb_unlinks* event queues to be unlinked 1557 * from the event port. 1558 * NULL value is allowed, in which case this function unlinks all the 1559 * event queue(s) from the event port *port_id*. 1560 * 1561 * @param nb_unlinks 1562 * The number of unlinks to establish. This parameter is ignored if queues is 1563 * NULL. 1564 * 1565 * @return 1566 * The number of unlinks successfully requested. The return value can be less 1567 * than the value of the *nb_unlinks* parameter when the implementation has the 1568 * limitation on specific queue to port unlink establishment or 1569 * if invalid parameters are specified. 1570 * If the return value is less than *nb_unlinks*, the remaining queues at the 1571 * end of queues[] are not unlinked, and the caller has to take care of them. 1572 * If return value is less than *nb_unlinks* then implementation shall update 1573 * the rte_errno accordingly, Possible rte_errno values are 1574 * (EINVAL) Invalid parameter 1575 */ 1576 int 1577 rte_event_port_unlink(uint8_t dev_id, uint8_t port_id, 1578 uint8_t queues[], uint16_t nb_unlinks); 1579 1580 /** 1581 * Returns the number of unlinks in progress. 1582 * 1583 * This function provides the application with a method to detect when an 1584 * unlink has been completed by the implementation. 1585 * 1586 * @see rte_event_port_unlink() to issue unlink requests. 1587 * 1588 * @param dev_id 1589 * The identifier of the device. 1590 * 1591 * @param port_id 1592 * Event port identifier to select port to check for unlinks in progress. 1593 * 1594 * @return 1595 * The number of unlinks that are in progress. A return of zero indicates that 1596 * there are no outstanding unlink requests. A positive return value indicates 1597 * the number of unlinks that are in progress, but are not yet complete. 1598 * A negative return value indicates an error, -EINVAL indicates an invalid 1599 * parameter passed for *dev_id* or *port_id*. 1600 */ 1601 int 1602 rte_event_port_unlinks_in_progress(uint8_t dev_id, uint8_t port_id); 1603 1604 /** 1605 * Retrieve the list of source event queues and its associated service priority 1606 * linked to the destination event port designated by its *port_id* 1607 * on the event device designated by its *dev_id*. 1608 * 1609 * @param dev_id 1610 * The identifier of the device. 1611 * 1612 * @param port_id 1613 * Event port identifier. 1614 * 1615 * @param[out] queues 1616 * Points to an array of *queues* for output. 1617 * The caller has to allocate *RTE_EVENT_MAX_QUEUES_PER_DEV* bytes to 1618 * store the event queue(s) linked with event port *port_id* 1619 * 1620 * @param[out] priorities 1621 * Points to an array of *priorities* for output. 1622 * The caller has to allocate *RTE_EVENT_MAX_QUEUES_PER_DEV* bytes to 1623 * store the service priority associated with each event queue linked 1624 * 1625 * @return 1626 * The number of links established on the event port designated by its 1627 * *port_id*. 1628 * - <0 on failure. 1629 * 1630 */ 1631 int 1632 rte_event_port_links_get(uint8_t dev_id, uint8_t port_id, 1633 uint8_t queues[], uint8_t priorities[]); 1634 1635 /** 1636 * Retrieve the service ID of the event dev. If the adapter doesn't use 1637 * a rte_service function, this function returns -ESRCH. 1638 * 1639 * @param dev_id 1640 * The identifier of the device. 1641 * 1642 * @param [out] service_id 1643 * A pointer to a uint32_t, to be filled in with the service id. 1644 * 1645 * @return 1646 * - 0: Success 1647 * - <0: Error code on failure, if the event dev doesn't use a rte_service 1648 * function, this function returns -ESRCH. 1649 */ 1650 int 1651 rte_event_dev_service_id_get(uint8_t dev_id, uint32_t *service_id); 1652 1653 /** 1654 * Dump internal information about *dev_id* to the FILE* provided in *f*. 1655 * 1656 * @param dev_id 1657 * The identifier of the device. 1658 * 1659 * @param f 1660 * A pointer to a file for output 1661 * 1662 * @return 1663 * - 0: on success 1664 * - <0: on failure. 1665 */ 1666 int 1667 rte_event_dev_dump(uint8_t dev_id, FILE *f); 1668 1669 /** Maximum name length for extended statistics counters */ 1670 #define RTE_EVENT_DEV_XSTATS_NAME_SIZE 64 1671 1672 /** 1673 * Selects the component of the eventdev to retrieve statistics from. 1674 */ 1675 enum rte_event_dev_xstats_mode { 1676 RTE_EVENT_DEV_XSTATS_DEVICE, 1677 RTE_EVENT_DEV_XSTATS_PORT, 1678 RTE_EVENT_DEV_XSTATS_QUEUE, 1679 }; 1680 1681 /** 1682 * A name-key lookup element for extended statistics. 1683 * 1684 * This structure is used to map between names and ID numbers 1685 * for extended ethdev statistics. 1686 */ 1687 struct rte_event_dev_xstats_name { 1688 char name[RTE_EVENT_DEV_XSTATS_NAME_SIZE]; 1689 }; 1690 1691 /** 1692 * Retrieve names of extended statistics of an event device. 1693 * 1694 * @param dev_id 1695 * The identifier of the event device. 1696 * @param mode 1697 * The mode of statistics to retrieve. Choices include the device statistics, 1698 * port statistics or queue statistics. 1699 * @param queue_port_id 1700 * Used to specify the port or queue number in queue or port mode, and is 1701 * ignored in device mode. 1702 * @param[out] xstats_names 1703 * Block of memory to insert names into. Must be at least size in capacity. 1704 * If set to NULL, function returns required capacity. 1705 * @param[out] ids 1706 * Block of memory to insert ids into. Must be at least size in capacity. 1707 * If set to NULL, function returns required capacity. The id values returned 1708 * can be passed to *rte_event_dev_xstats_get* to select statistics. 1709 * @param size 1710 * Capacity of xstats_names (number of names). 1711 * @return 1712 * - positive value lower or equal to size: success. The return value 1713 * is the number of entries filled in the stats table. 1714 * - positive value higher than size: error, the given statistics table 1715 * is too small. The return value corresponds to the size that should 1716 * be given to succeed. The entries in the table are not valid and 1717 * shall not be used by the caller. 1718 * - negative value on error: 1719 * -ENODEV for invalid *dev_id* 1720 * -EINVAL for invalid mode, queue port or id parameters 1721 * -ENOTSUP if the device doesn't support this function. 1722 */ 1723 int 1724 rte_event_dev_xstats_names_get(uint8_t dev_id, 1725 enum rte_event_dev_xstats_mode mode, 1726 uint8_t queue_port_id, 1727 struct rte_event_dev_xstats_name *xstats_names, 1728 unsigned int *ids, 1729 unsigned int size); 1730 1731 /** 1732 * Retrieve extended statistics of an event device. 1733 * 1734 * @param dev_id 1735 * The identifier of the device. 1736 * @param mode 1737 * The mode of statistics to retrieve. Choices include the device statistics, 1738 * port statistics or queue statistics. 1739 * @param queue_port_id 1740 * Used to specify the port or queue number in queue or port mode, and is 1741 * ignored in device mode. 1742 * @param ids 1743 * The id numbers of the stats to get. The ids can be got from the stat 1744 * position in the stat list from rte_event_dev_get_xstats_names(), or 1745 * by using rte_event_dev_xstats_by_name_get(). 1746 * @param[out] values 1747 * The values for each stats request by ID. 1748 * @param n 1749 * The number of stats requested 1750 * @return 1751 * - positive value: number of stat entries filled into the values array 1752 * - negative value on error: 1753 * -ENODEV for invalid *dev_id* 1754 * -EINVAL for invalid mode, queue port or id parameters 1755 * -ENOTSUP if the device doesn't support this function. 1756 */ 1757 int 1758 rte_event_dev_xstats_get(uint8_t dev_id, 1759 enum rte_event_dev_xstats_mode mode, 1760 uint8_t queue_port_id, 1761 const unsigned int ids[], 1762 uint64_t values[], unsigned int n); 1763 1764 /** 1765 * Retrieve the value of a single stat by requesting it by name. 1766 * 1767 * @param dev_id 1768 * The identifier of the device 1769 * @param name 1770 * The stat name to retrieve 1771 * @param[out] id 1772 * If non-NULL, the numerical id of the stat will be returned, so that further 1773 * requests for the stat can be got using rte_event_dev_xstats_get, which will 1774 * be faster as it doesn't need to scan a list of names for the stat. 1775 * If the stat cannot be found, the id returned will be (unsigned)-1. 1776 * @return 1777 * - positive value or zero: the stat value 1778 * - negative value: -EINVAL if stat not found, -ENOTSUP if not supported. 1779 */ 1780 uint64_t 1781 rte_event_dev_xstats_by_name_get(uint8_t dev_id, const char *name, 1782 unsigned int *id); 1783 1784 /** 1785 * Reset the values of the xstats of the selected component in the device. 1786 * 1787 * @param dev_id 1788 * The identifier of the device 1789 * @param mode 1790 * The mode of the statistics to reset. Choose from device, queue or port. 1791 * @param queue_port_id 1792 * The queue or port to reset. 0 and positive values select ports and queues, 1793 * while -1 indicates all ports or queues. 1794 * @param ids 1795 * Selects specific statistics to be reset. When NULL, all statistics selected 1796 * by *mode* will be reset. If non-NULL, must point to array of at least 1797 * *nb_ids* size. 1798 * @param nb_ids 1799 * The number of ids available from the *ids* array. Ignored when ids is NULL. 1800 * @return 1801 * - zero: successfully reset the statistics to zero 1802 * - negative value: -EINVAL invalid parameters, -ENOTSUP if not supported. 1803 */ 1804 int 1805 rte_event_dev_xstats_reset(uint8_t dev_id, 1806 enum rte_event_dev_xstats_mode mode, 1807 int16_t queue_port_id, 1808 const uint32_t ids[], 1809 uint32_t nb_ids); 1810 1811 /** 1812 * Trigger the eventdev self test. 1813 * 1814 * @param dev_id 1815 * The identifier of the device 1816 * @return 1817 * - 0: Selftest successful 1818 * - -ENOTSUP if the device doesn't support selftest 1819 * - other values < 0 on failure. 1820 */ 1821 int rte_event_dev_selftest(uint8_t dev_id); 1822 1823 /** 1824 * Get the memory required per event vector based on the number of elements per 1825 * vector. 1826 * This should be used to create the mempool that holds the event vectors. 1827 * 1828 * @param name 1829 * The name of the vector pool. 1830 * @param n 1831 * The number of elements in the mbuf pool. 1832 * @param cache_size 1833 * Size of the per-core object cache. See rte_mempool_create() for 1834 * details. 1835 * @param nb_elem 1836 * The number of elements that a single event vector should be able to hold. 1837 * @param socket_id 1838 * The socket identifier where the memory should be allocated. The 1839 * value can be *SOCKET_ID_ANY* if there is no NUMA constraint for the 1840 * reserved zone 1841 * 1842 * @return 1843 * The pointer to the newly allocated mempool, on success. NULL on error 1844 * with rte_errno set appropriately. Possible rte_errno values include: 1845 * - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure 1846 * - E_RTE_SECONDARY - function was called from a secondary process instance 1847 * - EINVAL - cache size provided is too large, or priv_size is not aligned. 1848 * - ENOSPC - the maximum number of memzones has already been allocated 1849 * - EEXIST - a memzone with the same name already exists 1850 * - ENOMEM - no appropriate memory area found in which to create memzone 1851 * - ENAMETOOLONG - mempool name requested is too long. 1852 */ 1853 struct rte_mempool * 1854 rte_event_vector_pool_create(const char *name, unsigned int n, 1855 unsigned int cache_size, uint16_t nb_elem, 1856 int socket_id); 1857 1858 #include <rte_eventdev_core.h> 1859 1860 static __rte_always_inline uint16_t 1861 __rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id, 1862 const struct rte_event ev[], uint16_t nb_events, 1863 const event_enqueue_burst_t fn) 1864 { 1865 const struct rte_event_fp_ops *fp_ops; 1866 void *port; 1867 1868 fp_ops = &rte_event_fp_ops[dev_id]; 1869 port = fp_ops->data[port_id]; 1870 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG 1871 if (dev_id >= RTE_EVENT_MAX_DEVS || 1872 port_id >= RTE_EVENT_MAX_PORTS_PER_DEV) { 1873 rte_errno = EINVAL; 1874 return 0; 1875 } 1876 1877 if (port == NULL) { 1878 rte_errno = EINVAL; 1879 return 0; 1880 } 1881 #endif 1882 rte_eventdev_trace_enq_burst(dev_id, port_id, ev, nb_events, (void *)fn); 1883 /* 1884 * Allow zero cost non burst mode routine invocation if application 1885 * requests nb_events as const one 1886 */ 1887 if (nb_events == 1) 1888 return (fp_ops->enqueue)(port, ev); 1889 else 1890 return fn(port, ev, nb_events); 1891 } 1892 1893 /** 1894 * Enqueue a burst of events objects or an event object supplied in *rte_event* 1895 * structure on an event device designated by its *dev_id* through the event 1896 * port specified by *port_id*. Each event object specifies the event queue on 1897 * which it will be enqueued. 1898 * 1899 * The *nb_events* parameter is the number of event objects to enqueue which are 1900 * supplied in the *ev* array of *rte_event* structure. 1901 * 1902 * Event operations RTE_EVENT_OP_FORWARD and RTE_EVENT_OP_RELEASE must only be 1903 * enqueued to the same port that their associated events were dequeued from. 1904 * 1905 * The rte_event_enqueue_burst() function returns the number of 1906 * events objects it actually enqueued. A return value equal to *nb_events* 1907 * means that all event objects have been enqueued. 1908 * 1909 * @param dev_id 1910 * The identifier of the device. 1911 * @param port_id 1912 * The identifier of the event port. 1913 * @param ev 1914 * Points to an array of *nb_events* objects of type *rte_event* structure 1915 * which contain the event object enqueue operations to be processed. 1916 * @param nb_events 1917 * The number of event objects to enqueue, typically number of 1918 * rte_event_port_attr_get(...RTE_EVENT_PORT_ATTR_ENQ_DEPTH...) 1919 * available for this port. 1920 * 1921 * @return 1922 * The number of event objects actually enqueued on the event device. The 1923 * return value can be less than the value of the *nb_events* parameter when 1924 * the event devices queue is full or if invalid parameters are specified in a 1925 * *rte_event*. If the return value is less than *nb_events*, the remaining 1926 * events at the end of ev[] are not consumed and the caller has to take care 1927 * of them, and rte_errno is set accordingly. Possible errno values include: 1928 * - EINVAL The port ID is invalid, device ID is invalid, an event's queue 1929 * ID is invalid, or an event's sched type doesn't match the 1930 * capabilities of the destination queue. 1931 * - ENOSPC The event port was backpressured and unable to enqueue 1932 * one or more events. This error code is only applicable to 1933 * closed systems. 1934 * @see rte_event_port_attr_get(), RTE_EVENT_PORT_ATTR_ENQ_DEPTH 1935 */ 1936 static inline uint16_t 1937 rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id, 1938 const struct rte_event ev[], uint16_t nb_events) 1939 { 1940 const struct rte_event_fp_ops *fp_ops; 1941 1942 fp_ops = &rte_event_fp_ops[dev_id]; 1943 return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events, 1944 fp_ops->enqueue_burst); 1945 } 1946 1947 /** 1948 * Enqueue a burst of events objects of operation type *RTE_EVENT_OP_NEW* on 1949 * an event device designated by its *dev_id* through the event port specified 1950 * by *port_id*. 1951 * 1952 * Provides the same functionality as rte_event_enqueue_burst(), expect that 1953 * application can use this API when the all objects in the burst contains 1954 * the enqueue operation of the type *RTE_EVENT_OP_NEW*. This specialized 1955 * function can provide the additional hint to the PMD and optimize if possible. 1956 * 1957 * The rte_event_enqueue_new_burst() result is undefined if the enqueue burst 1958 * has event object of operation type != RTE_EVENT_OP_NEW. 1959 * 1960 * @param dev_id 1961 * The identifier of the device. 1962 * @param port_id 1963 * The identifier of the event port. 1964 * @param ev 1965 * Points to an array of *nb_events* objects of type *rte_event* structure 1966 * which contain the event object enqueue operations to be processed. 1967 * @param nb_events 1968 * The number of event objects to enqueue, typically number of 1969 * rte_event_port_attr_get(...RTE_EVENT_PORT_ATTR_ENQ_DEPTH...) 1970 * available for this port. 1971 * 1972 * @return 1973 * The number of event objects actually enqueued on the event device. The 1974 * return value can be less than the value of the *nb_events* parameter when 1975 * the event devices queue is full or if invalid parameters are specified in a 1976 * *rte_event*. If the return value is less than *nb_events*, the remaining 1977 * events at the end of ev[] are not consumed and the caller has to take care 1978 * of them, and rte_errno is set accordingly. Possible errno values include: 1979 * - EINVAL The port ID is invalid, device ID is invalid, an event's queue 1980 * ID is invalid, or an event's sched type doesn't match the 1981 * capabilities of the destination queue. 1982 * - ENOSPC The event port was backpressured and unable to enqueue 1983 * one or more events. This error code is only applicable to 1984 * closed systems. 1985 * @see rte_event_port_attr_get(), RTE_EVENT_PORT_ATTR_ENQ_DEPTH 1986 * @see rte_event_enqueue_burst() 1987 */ 1988 static inline uint16_t 1989 rte_event_enqueue_new_burst(uint8_t dev_id, uint8_t port_id, 1990 const struct rte_event ev[], uint16_t nb_events) 1991 { 1992 const struct rte_event_fp_ops *fp_ops; 1993 1994 fp_ops = &rte_event_fp_ops[dev_id]; 1995 return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events, 1996 fp_ops->enqueue_new_burst); 1997 } 1998 1999 /** 2000 * Enqueue a burst of events objects of operation type *RTE_EVENT_OP_FORWARD* 2001 * on an event device designated by its *dev_id* through the event port 2002 * specified by *port_id*. 2003 * 2004 * Provides the same functionality as rte_event_enqueue_burst(), expect that 2005 * application can use this API when the all objects in the burst contains 2006 * the enqueue operation of the type *RTE_EVENT_OP_FORWARD*. This specialized 2007 * function can provide the additional hint to the PMD and optimize if possible. 2008 * 2009 * The rte_event_enqueue_new_burst() result is undefined if the enqueue burst 2010 * has event object of operation type != RTE_EVENT_OP_FORWARD. 2011 * 2012 * @param dev_id 2013 * The identifier of the device. 2014 * @param port_id 2015 * The identifier of the event port. 2016 * @param ev 2017 * Points to an array of *nb_events* objects of type *rte_event* structure 2018 * which contain the event object enqueue operations to be processed. 2019 * @param nb_events 2020 * The number of event objects to enqueue, typically number of 2021 * rte_event_port_attr_get(...RTE_EVENT_PORT_ATTR_ENQ_DEPTH...) 2022 * available for this port. 2023 * 2024 * @return 2025 * The number of event objects actually enqueued on the event device. The 2026 * return value can be less than the value of the *nb_events* parameter when 2027 * the event devices queue is full or if invalid parameters are specified in a 2028 * *rte_event*. If the return value is less than *nb_events*, the remaining 2029 * events at the end of ev[] are not consumed and the caller has to take care 2030 * of them, and rte_errno is set accordingly. Possible errno values include: 2031 * - EINVAL The port ID is invalid, device ID is invalid, an event's queue 2032 * ID is invalid, or an event's sched type doesn't match the 2033 * capabilities of the destination queue. 2034 * - ENOSPC The event port was backpressured and unable to enqueue 2035 * one or more events. This error code is only applicable to 2036 * closed systems. 2037 * @see rte_event_port_attr_get(), RTE_EVENT_PORT_ATTR_ENQ_DEPTH 2038 * @see rte_event_enqueue_burst() 2039 */ 2040 static inline uint16_t 2041 rte_event_enqueue_forward_burst(uint8_t dev_id, uint8_t port_id, 2042 const struct rte_event ev[], uint16_t nb_events) 2043 { 2044 const struct rte_event_fp_ops *fp_ops; 2045 2046 fp_ops = &rte_event_fp_ops[dev_id]; 2047 return __rte_event_enqueue_burst(dev_id, port_id, ev, nb_events, 2048 fp_ops->enqueue_forward_burst); 2049 } 2050 2051 /** 2052 * Dequeue a burst of events objects or an event object from the event port 2053 * designated by its *event_port_id*, on an event device designated 2054 * by its *dev_id*. 2055 * 2056 * rte_event_dequeue_burst() does not dictate the specifics of scheduling 2057 * algorithm as each eventdev driver may have different criteria to schedule 2058 * an event. However, in general, from an application perspective scheduler may 2059 * use the following scheme to dispatch an event to the port. 2060 * 2061 * 1) Selection of event queue based on 2062 * a) The list of event queues are linked to the event port. 2063 * b) If the device has RTE_EVENT_DEV_CAP_QUEUE_QOS capability then event 2064 * queue selection from list is based on event queue priority relative to 2065 * other event queue supplied as *priority* in rte_event_queue_setup() 2066 * c) If the device has RTE_EVENT_DEV_CAP_EVENT_QOS capability then event 2067 * queue selection from the list is based on event priority supplied as 2068 * *priority* in rte_event_enqueue_burst() 2069 * 2) Selection of event 2070 * a) The number of flows available in selected event queue. 2071 * b) Schedule type method associated with the event 2072 * 2073 * The *nb_events* parameter is the maximum number of event objects to dequeue 2074 * which are returned in the *ev* array of *rte_event* structure. 2075 * 2076 * The rte_event_dequeue_burst() function returns the number of events objects 2077 * it actually dequeued. A return value equal to *nb_events* means that all 2078 * event objects have been dequeued. 2079 * 2080 * The number of events dequeued is the number of scheduler contexts held by 2081 * this port. These contexts are automatically released in the next 2082 * rte_event_dequeue_burst() invocation if the port supports implicit 2083 * releases, or invoking rte_event_enqueue_burst() with RTE_EVENT_OP_RELEASE 2084 * operation can be used to release the contexts early. 2085 * 2086 * Event operations RTE_EVENT_OP_FORWARD and RTE_EVENT_OP_RELEASE must only be 2087 * enqueued to the same port that their associated events were dequeued from. 2088 * 2089 * @param dev_id 2090 * The identifier of the device. 2091 * @param port_id 2092 * The identifier of the event port. 2093 * @param[out] ev 2094 * Points to an array of *nb_events* objects of type *rte_event* structure 2095 * for output to be populated with the dequeued event objects. 2096 * @param nb_events 2097 * The maximum number of event objects to dequeue, typically number of 2098 * rte_event_port_dequeue_depth() available for this port. 2099 * 2100 * @param timeout_ticks 2101 * - 0 no-wait, returns immediately if there is no event. 2102 * - >0 wait for the event, if the device is configured with 2103 * RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT then this function will wait until 2104 * at least one event is available or *timeout_ticks* time. 2105 * if the device is not configured with RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT 2106 * then this function will wait until the event available or 2107 * *dequeue_timeout_ns* ns which was previously supplied to 2108 * rte_event_dev_configure() 2109 * 2110 * @return 2111 * The number of event objects actually dequeued from the port. The return 2112 * value can be less than the value of the *nb_events* parameter when the 2113 * event port's queue is not full. 2114 * 2115 * @see rte_event_port_dequeue_depth() 2116 */ 2117 static inline uint16_t 2118 rte_event_dequeue_burst(uint8_t dev_id, uint8_t port_id, struct rte_event ev[], 2119 uint16_t nb_events, uint64_t timeout_ticks) 2120 { 2121 const struct rte_event_fp_ops *fp_ops; 2122 void *port; 2123 2124 fp_ops = &rte_event_fp_ops[dev_id]; 2125 port = fp_ops->data[port_id]; 2126 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG 2127 if (dev_id >= RTE_EVENT_MAX_DEVS || 2128 port_id >= RTE_EVENT_MAX_PORTS_PER_DEV) { 2129 rte_errno = EINVAL; 2130 return 0; 2131 } 2132 2133 if (port == NULL) { 2134 rte_errno = EINVAL; 2135 return 0; 2136 } 2137 #endif 2138 rte_eventdev_trace_deq_burst(dev_id, port_id, ev, nb_events); 2139 /* 2140 * Allow zero cost non burst mode routine invocation if application 2141 * requests nb_events as const one 2142 */ 2143 if (nb_events == 1) 2144 return (fp_ops->dequeue)(port, ev, timeout_ticks); 2145 else 2146 return (fp_ops->dequeue_burst)(port, ev, nb_events, 2147 timeout_ticks); 2148 } 2149 2150 #define RTE_EVENT_DEV_MAINT_OP_FLUSH (1 << 0) 2151 /**< Force an immediately flush of any buffered events in the port, 2152 * potentially at the cost of additional overhead. 2153 * 2154 * @see rte_event_maintain() 2155 */ 2156 2157 /** 2158 * Maintain an event device. 2159 * 2160 * This function is only relevant for event devices which do not have 2161 * the @ref RTE_EVENT_DEV_CAP_MAINTENANCE_FREE flag set. Such devices 2162 * require an application thread using a particular port to 2163 * periodically call rte_event_maintain() on that port during periods 2164 * which it is neither attempting to enqueue events to nor dequeue 2165 * events from the port. rte_event_maintain() is a low-overhead 2166 * function and should be called at a high rate (e.g., in the 2167 * application's poll loop). 2168 * 2169 * No port may be left unmaintained. 2170 * 2171 * At the application thread's convenience, rte_event_maintain() may 2172 * (but is not required to) be called even during periods when enqueue 2173 * or dequeue functions are being called, at the cost of a slight 2174 * increase in overhead. 2175 * 2176 * rte_event_maintain() may be called on event devices which have set 2177 * @ref RTE_EVENT_DEV_CAP_MAINTENANCE_FREE, in which case it is a 2178 * no-operation. 2179 * 2180 * @param dev_id 2181 * The identifier of the device. 2182 * @param port_id 2183 * The identifier of the event port. 2184 * @param op 2185 * 0, or @ref RTE_EVENT_DEV_MAINT_OP_FLUSH. 2186 * @return 2187 * - 0 on success. 2188 * - -EINVAL if *dev_id*, *port_id*, or *op* is invalid. 2189 * 2190 * @see RTE_EVENT_DEV_CAP_MAINTENANCE_FREE 2191 */ 2192 __rte_experimental 2193 static inline int 2194 rte_event_maintain(uint8_t dev_id, uint8_t port_id, int op) 2195 { 2196 const struct rte_event_fp_ops *fp_ops; 2197 void *port; 2198 2199 fp_ops = &rte_event_fp_ops[dev_id]; 2200 port = fp_ops->data[port_id]; 2201 #ifdef RTE_LIBRTE_EVENTDEV_DEBUG 2202 if (dev_id >= RTE_EVENT_MAX_DEVS || 2203 port_id >= RTE_EVENT_MAX_PORTS_PER_DEV) 2204 return -EINVAL; 2205 2206 if (port == NULL) 2207 return -EINVAL; 2208 2209 if (op & (~RTE_EVENT_DEV_MAINT_OP_FLUSH)) 2210 return -EINVAL; 2211 #endif 2212 rte_eventdev_trace_maintain(dev_id, port_id, op); 2213 2214 if (fp_ops->maintain != NULL) 2215 fp_ops->maintain(port, op); 2216 2217 return 0; 2218 } 2219 2220 #ifdef __cplusplus 2221 } 2222 #endif 2223 2224 #endif /* _RTE_EVENTDEV_H_ */ 2225