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