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