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