1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2017 Intel Corporation. 3 * All rights reserved. 4 */ 5 6 #ifndef _RTE_EVENT_ETH_RX_ADAPTER_ 7 #define _RTE_EVENT_ETH_RX_ADAPTER_ 8 9 /** 10 * @file 11 * 12 * RTE Event Ethernet Rx Adapter 13 * 14 * An eventdev-based packet processing application enqueues/dequeues mbufs 15 * to/from the event device. Packet flow from the ethernet device to the event 16 * device can be accomplished using either HW or SW mechanisms depending on the 17 * platform and the particular combination of ethernet and event devices. The 18 * event ethernet Rx adapter provides common APIs to configure the packet flow 19 * from the ethernet devices to event devices across both these transfer 20 * mechanisms. 21 * 22 * The adapter uses a EAL service core function for SW based packet transfer 23 * and uses the eventdev PMD functions to configure HW based packet transfer 24 * between the ethernet device and the event device. 25 * 26 * The ethernet Rx event adapter's functions are: 27 * - rte_event_eth_rx_adapter_create_ext() 28 * - rte_event_eth_rx_adapter_create() 29 * - rte_event_eth_rx_adapter_create_with_params() 30 * - rte_event_eth_rx_adapter_create_ext_with_params() 31 * - rte_event_eth_rx_adapter_free() 32 * - rte_event_eth_rx_adapter_queue_add() 33 * - rte_event_eth_rx_adapter_queue_del() 34 * - rte_event_eth_rx_adapter_start() 35 * - rte_event_eth_rx_adapter_stop() 36 * - rte_event_eth_rx_adapter_stats_get() 37 * - rte_event_eth_rx_adapter_stats_reset() 38 * - rte_event_eth_rx_adapter_queue_conf_get() 39 * - rte_event_eth_rx_adapter_queue_stats_get() 40 * - rte_event_eth_rx_adapter_queue_stats_reset() 41 * - rte_event_eth_rx_adapter_event_port_get() 42 * - rte_event_eth_rx_adapter_instance_get() 43 * - rte_event_eth_rx_adapter_runtime_params_get() 44 * - rte_event_eth_rx_adapter_runtime_params_init() 45 * - rte_event_eth_rx_adapter_runtime_params_set() 46 * 47 * The application creates an ethernet to event adapter using 48 * rte_event_eth_rx_adapter_create_ext() or rte_event_eth_rx_adapter_create() 49 * or rte_event_eth_rx_adapter_create_with_params() or 50 * rte_event_eth_rx_adapter_create_ext_with_params() functions. 51 * 52 * The adapter needs to know which ethernet rx queues to poll for mbufs as well 53 * as event device parameters such as the event queue identifier, event 54 * priority and scheduling type that the adapter should use when constructing 55 * events. The rte_event_eth_rx_adapter_queue_add() function is provided for 56 * this purpose. 57 * The servicing weight parameter in the rte_event_eth_rx_adapter_queue_conf 58 * is applicable when the Rx adapter uses a service core function and is 59 * intended to provide application control of the frequency of polling ethernet 60 * device receive queues, for example, the application may want to poll higher 61 * priority queues with a higher frequency but at the same time not starve 62 * lower priority queues completely. If this parameter is zero and the receive 63 * interrupt is enabled when configuring the device, the receive queue is 64 * interrupt driven; else, the queue is assigned a servicing weight of one. 65 * 66 * The application can start/stop the adapter using the 67 * rte_event_eth_rx_adapter_start() and the rte_event_eth_rx_adapter_stop() 68 * functions. If the adapter uses a rte_service function, then the application 69 * is also required to assign a core to the service function and control the 70 * service core using the rte_service APIs. The 71 * rte_event_eth_rx_adapter_service_id_get() function can be used to retrieve 72 * the service function ID of the adapter in this case. 73 * 74 * For SW based packet transfers, i.e., when the 75 * RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT is not set in the adapter's 76 * capabilities flags for a particular ethernet device, the service function 77 * temporarily enqueues events to an event buffer before batch enqueuing these 78 * to the event device. If the buffer fills up, the service function stops 79 * dequeuing packets from the ethernet device. The application may want to 80 * monitor the buffer fill level and instruct the service function to 81 * selectively buffer events. The application may also use some other 82 * criteria to decide which packets should enter the event device even when 83 * the event buffer fill level is low or may want to enqueue packets to an 84 * internal event port. The rte_event_eth_rx_adapter_cb_register() function 85 * allows the application to register a callback that selects which packets are 86 * enqueued to the event device by the SW adapter. The callback interface is 87 * event based so the callback can also modify the event data if it needs to. 88 */ 89 90 #include <stdint.h> 91 92 #include <rte_compat.h> 93 #include <rte_service.h> 94 95 #include "rte_eventdev.h" 96 97 #ifdef __cplusplus 98 extern "C" { 99 #endif 100 101 #define RTE_EVENT_ETH_RX_ADAPTER_MAX_INSTANCE 32 102 103 /* struct rte_event_eth_rx_adapter_queue_conf flags definitions */ 104 #define RTE_EVENT_ETH_RX_ADAPTER_QUEUE_FLOW_ID_VALID 0x1 105 /**< This flag indicates the flow identifier is valid 106 * @see rte_event_eth_rx_adapter_queue_conf::rx_queue_flags 107 */ 108 #define RTE_EVENT_ETH_RX_ADAPTER_QUEUE_EVENT_VECTOR 0x2 109 /**< This flag indicates that mbufs arriving on the queue need to be vectorized 110 * @see rte_event_eth_rx_adapter_queue_conf::rx_queue_flags 111 */ 112 113 /** 114 * Adapter configuration structure that the adapter configuration callback 115 * function is expected to fill out 116 * @see rte_event_eth_rx_adapter_conf_cb 117 */ 118 struct rte_event_eth_rx_adapter_conf { 119 uint8_t event_port_id; 120 /**< Event port identifier, the adapter enqueues mbuf events to this 121 * port. 122 */ 123 uint32_t max_nb_rx; 124 /**< The adapter can return early if it has processed at least 125 * max_nb_rx mbufs. This isn't treated as a requirement; batching may 126 * cause the adapter to process more than max_nb_rx mbufs. 127 */ 128 }; 129 130 /** 131 * Function type used for adapter configuration callback. The callback is 132 * used to fill in members of the struct rte_event_eth_rx_adapter_conf, this 133 * callback is invoked when creating a SW service for packet transfer from 134 * ethdev queues to the event device. The SW service is created within the 135 * rte_event_eth_rx_adapter_queue_add() function if SW based packet transfers 136 * from ethdev queues to the event device are required. 137 * 138 * @param id 139 * Adapter identifier. 140 * 141 * @param dev_id 142 * Event device identifier. 143 * 144 * @param [out] conf 145 * Structure that needs to be populated by this callback. 146 * 147 * @param arg 148 * Argument to the callback. This is the same as the conf_arg passed to the 149 * rte_event_eth_rx_adapter_create_ext(). 150 */ 151 typedef int (*rte_event_eth_rx_adapter_conf_cb) (uint8_t id, uint8_t dev_id, 152 struct rte_event_eth_rx_adapter_conf *conf, 153 void *arg); 154 155 /** 156 * Rx queue configuration structure 157 */ 158 struct rte_event_eth_rx_adapter_queue_conf { 159 uint32_t rx_queue_flags; 160 /**< Flags for handling received packets 161 * @see RTE_EVENT_ETH_RX_ADAPTER_QUEUE_FLOW_ID_VALID 162 */ 163 uint16_t servicing_weight; 164 /**< Relative polling frequency of ethernet receive queue when the 165 * adapter uses a service core function for ethernet to event device 166 * transfers. If it is set to zero, the Rx queue is interrupt driven 167 * (unless rx queue interrupts are not enabled for the ethernet 168 * device). 169 */ 170 struct rte_event ev; 171 /**< 172 * The values from the following event fields will be used when 173 * queuing mbuf events: 174 * - event_queue_id: Targeted event queue ID for received packets. 175 * - event_priority: Event priority of packets from this Rx queue in 176 * the event queue relative to other events. 177 * - sched_type: Scheduling type for packets from this Rx queue. 178 * - flow_id: If the RTE_ETH_RX_EVENT_ADAPTER_QUEUE_FLOW_ID_VALID bit 179 * is set in rx_queue_flags, this flow_id is used for all 180 * packets received from this queue. Otherwise the flow ID 181 * is set to the RSS hash of the src and dst IPv4/6 182 * addresses. 183 * 184 * The event adapter sets ev.event_type to RTE_EVENT_TYPE_ETHDEV in the 185 * enqueued event. 186 */ 187 uint16_t vector_sz; 188 /**< 189 * Indicates the maximum number for mbufs to combine and form a vector. 190 * Should be within 191 * @see rte_event_eth_rx_adapter_vector_limits::min_vector_sz 192 * @see rte_event_eth_rx_adapter_vector_limits::max_vector_sz 193 * Valid when RTE_EVENT_ETH_RX_ADAPTER_QUEUE_EVENT_VECTOR flag is set in 194 * @see rte_event_eth_rx_adapter_queue_conf::rx_queue_flags 195 */ 196 uint64_t vector_timeout_ns; 197 /**< 198 * Indicates the maximum number of nanoseconds to wait for receiving 199 * mbufs. Should be within vectorization limits of the 200 * adapter 201 * @see rte_event_eth_rx_adapter_vector_limits::min_vector_ns 202 * @see rte_event_eth_rx_adapter_vector_limits::max_vector_ns 203 * Valid when RTE_EVENT_ETH_RX_ADAPTER_QUEUE_EVENT_VECTOR flag is set in 204 * @see rte_event_eth_rx_adapter_queue_conf::rx_queue_flags 205 */ 206 struct rte_mempool *vector_mp; 207 /**< 208 * Indicates the mempool that should be used for allocating 209 * rte_event_vector container. 210 * Should be created by using `rte_event_vector_pool_create`. 211 * Valid when RTE_EVENT_ETH_RX_ADAPTER_QUEUE_EVENT_VECTOR flag is set in 212 * @see rte_event_eth_rx_adapter_queue_conf::rx_queue_flags. 213 */ 214 uint16_t event_buf_size; 215 /**< event buffer size for this queue */ 216 }; 217 218 /** 219 * A structure used to retrieve statistics for an 220 * eth rx adapter queue. 221 */ 222 struct rte_event_eth_rx_adapter_queue_stats { 223 uint64_t rx_event_buf_count; 224 /**< Rx event buffered count */ 225 uint64_t rx_event_buf_size; 226 /**< Rx event buffer size */ 227 uint64_t rx_poll_count; 228 /**< Receive queue poll count */ 229 uint64_t rx_packets; 230 /**< Received packet count */ 231 uint64_t rx_dropped; 232 /**< Received packet dropped count */ 233 }; 234 235 /** 236 * A structure used to retrieve statistics for an eth rx adapter instance. 237 */ 238 struct rte_event_eth_rx_adapter_stats { 239 uint64_t rx_poll_count; 240 /**< Receive queue poll count */ 241 uint64_t rx_packets; 242 /**< Received packet count */ 243 uint64_t rx_enq_count; 244 /**< Eventdev enqueue count */ 245 uint64_t rx_enq_retry; 246 /**< Eventdev enqueue retry count */ 247 uint64_t rx_dropped; 248 /**< Received packet dropped count */ 249 uint64_t rx_enq_start_ts; 250 /**< Rx enqueue start timestamp */ 251 uint64_t rx_enq_block_cycles; 252 /**< Cycles for which the service is blocked by the event device, 253 * i.e, the service fails to enqueue to the event device. 254 */ 255 uint64_t rx_enq_end_ts; 256 /**< Latest timestamp at which the service is unblocked 257 * by the event device. The start, end timestamps and 258 * block cycles can be used to compute the percentage of 259 * cycles the service is blocked by the event device. 260 */ 261 uint64_t rx_intr_packets; 262 /**< Received packet count for interrupt mode Rx queues */ 263 uint64_t rx_event_buf_count; 264 /**< Rx event buffered count */ 265 uint64_t rx_event_buf_size; 266 /**< Rx event buffer size */ 267 }; 268 269 /** 270 * A structure used to retrieve eth rx adapter vector limits. 271 */ 272 struct rte_event_eth_rx_adapter_vector_limits { 273 uint16_t min_sz; 274 /**< Minimum vector limit configurable. 275 * @see rte_event_eth_rx_adapter_event_vector_config::vector_sz 276 */ 277 uint16_t max_sz; 278 /**< Maximum vector limit configurable. 279 * @see rte_event_eth_rx_adapter_event_vector_config::vector_sz 280 */ 281 uint8_t log2_sz; 282 /**< True if the size configured should be in log2. 283 * @see rte_event_eth_rx_adapter_event_vector_config::vector_sz 284 */ 285 uint64_t min_timeout_ns; 286 /**< Minimum vector timeout configurable. 287 * @see rte_event_eth_rx_adapter_event_vector_config::vector_timeout_ns 288 */ 289 uint64_t max_timeout_ns; 290 /**< Maximum vector timeout configurable. 291 * @see rte_event_eth_rx_adapter_event_vector_config::vector_timeout_ns 292 */ 293 }; 294 295 /** 296 * A structure to hold adapter config params 297 */ 298 struct rte_event_eth_rx_adapter_params { 299 uint16_t event_buf_size; 300 /**< size of event buffer for the adapter. 301 * This value is rounded up for better buffer utilization 302 * and performance. 303 */ 304 bool use_queue_event_buf; 305 /**< flag to indicate that event buffer is separate for each queue */ 306 }; 307 308 /** 309 * Adapter runtime configuration parameters 310 */ 311 struct rte_event_eth_rx_adapter_runtime_params { 312 uint32_t max_nb_rx; 313 /**< The adapter can return early if it has processed at least 314 * max_nb_rx mbufs. This isn't treated as a requirement; batching may 315 * cause the adapter to process more than max_nb_rx mbufs. 316 * 317 * rte_event_eth_rx_adapter_create() or 318 * rte_event_eth_adapter_create_with_params() configures the 319 * adapter with default value of max_nb_rx. 320 * rte_event_eth_rx_adapter_create_ext() configures the adapter with 321 * user provided value of max_nb_rx through 322 * rte_event_eth_rx_adapter_conf::max_nb_rx parameter. 323 * rte_event_eth_rx_adapter_runtime_params_set() allows to re-configure 324 * max_nb_rx during runtime (after adding at least one queue) 325 * 326 * This is valid for the devices without 327 * RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT capability. 328 */ 329 uint32_t rsvd[15]; 330 /**< Reserved fields for future use */ 331 }; 332 333 /** 334 * 335 * Callback function invoked by the SW adapter before it continues 336 * to process events. The callback is passed the size of the enqueue 337 * buffer in the SW adapter and the occupancy of the buffer. The 338 * callback can use these values to decide which events are 339 * enqueued to the event device by the SW adapter. The callback may 340 * also enqueue events internally using its own event port. The SW 341 * adapter populates the event information based on the Rx queue 342 * configuration in the adapter. The callback can modify the this event 343 * information for the events to be enqueued by the SW adapter. 344 * 345 * The callback return value is the number of events from the 346 * beginning of the event array that are to be enqueued by 347 * the SW adapter. It is the callback's responsibility to arrange 348 * these events at the beginning of the array, if these events are 349 * not contiguous in the original array. The *nb_dropped* parameter is 350 * a pointer to the number of events dropped by the callback, this 351 * number is used by the adapter to indicate the number of dropped packets 352 * as part of its statistics. 353 * 354 * @param eth_dev_id 355 * Port identifier of the Ethernet device. 356 * @param queue_id 357 * Receive queue index. 358 * @param enqueue_buf_size 359 * Total enqueue buffer size. 360 * @param enqueue_buf_count 361 * Event count in enqueue buffer. 362 * @param[in, out] ev 363 * Event array. 364 * @param nb_event 365 * Event array length. 366 * @param cb_arg 367 * Callback argument. 368 * @param[out] nb_dropped 369 * Packets dropped by callback. 370 * @return 371 * - The number of events to be enqueued by the SW adapter. 372 */ 373 typedef uint16_t (*rte_event_eth_rx_adapter_cb_fn)(uint16_t eth_dev_id, 374 uint16_t queue_id, 375 uint32_t enqueue_buf_size, 376 uint32_t enqueue_buf_count, 377 struct rte_event *ev, 378 uint16_t nb_event, 379 void *cb_arg, 380 uint16_t *nb_dropped); 381 382 /** 383 * Create a new ethernet Rx event adapter with the specified identifier. 384 * 385 * @param id 386 * The identifier of the ethernet Rx event adapter. 387 * 388 * @param dev_id 389 * The identifier of the device to configure. 390 * 391 * @param conf_cb 392 * Callback function that fills in members of a 393 * struct rte_event_eth_rx_adapter_conf struct passed into 394 * it. 395 * 396 * @param conf_arg 397 * Argument that is passed to the conf_cb function. 398 * 399 * @return 400 * - 0: Success 401 * - <0: Error code on failure 402 */ 403 int rte_event_eth_rx_adapter_create_ext(uint8_t id, uint8_t dev_id, 404 rte_event_eth_rx_adapter_conf_cb conf_cb, 405 void *conf_arg); 406 407 /** 408 * Create a new ethernet Rx event adapter with the specified identifier. 409 * This function uses an internal configuration function that creates an event 410 * port. This default function reconfigures the event device with an 411 * additional event port and setup the event port using the port_config 412 * parameter passed into this function. In case the application needs more 413 * control in configuration of the service, it should use the 414 * rte_event_eth_rx_adapter_create_ext() version. 415 * 416 * When this API is used for creating adapter instance, 417 * ``rte_event_dev_config::nb_event_ports`` is automatically incremented, 418 * and event device is reconfigured with additional event port during service 419 * initialization. This event device reconfigure logic also increments the 420 * ``rte_event_dev_config::nb_single_link_event_port_queues`` 421 * parameter if the adapter event port config is of type 422 * ``RTE_EVENT_PORT_CFG_SINGLE_LINK``. 423 * 424 * Application no longer needs to account for 425 * ``rte_event_dev_config::nb_event_ports`` and 426 * ``rte_event_dev_config::nb_single_link_event_port_queues`` 427 * parameters required for eth Rx adapter in the event device configuration 428 * when the adapter is created with this API. 429 * 430 * @param id 431 * The identifier of the ethernet Rx event adapter. 432 * 433 * @param dev_id 434 * The identifier of the device to configure. 435 * 436 * @param port_config 437 * Argument of type *rte_event_port_conf* that is passed to the conf_cb 438 * function. 439 * 440 * @return 441 * - 0: Success 442 * - <0: Error code on failure 443 */ 444 int rte_event_eth_rx_adapter_create(uint8_t id, uint8_t dev_id, 445 struct rte_event_port_conf *port_config); 446 447 /** 448 * This is a variant of rte_event_eth_rx_adapter_create() with additional 449 * adapter params specified in ``struct rte_event_eth_rx_adapter_params``. 450 * 451 * @param id 452 * The identifier of the ethernet Rx event adapter. 453 * 454 * @param dev_id 455 * The identifier of the event device to configure. 456 * 457 * @param port_config 458 * Argument of type *rte_event_port_conf* that is passed to the conf_cb 459 * function. 460 * 461 * @param rxa_params 462 * Pointer to struct rte_event_eth_rx_adapter_params. 463 * In case of NULL, default values are used. 464 * 465 * @return 466 * - 0: Success 467 * - <0: Error code on failure 468 */ 469 int rte_event_eth_rx_adapter_create_with_params(uint8_t id, uint8_t dev_id, 470 struct rte_event_port_conf *port_config, 471 struct rte_event_eth_rx_adapter_params *rxa_params); 472 473 /** 474 * This is a variant of rte_event_eth_rx_adapter_create_ext() with additional 475 * adapter params specified in ``struct rte_event_eth_rx_adapter_params``. 476 * 477 * @param id 478 * The identifier of the ethernet Rx event adapter. 479 * 480 * @param dev_id 481 * The identifier of the event device to configure. 482 * 483 * @param conf_cb 484 * Callback function that fills in members of a 485 * struct rte_event_eth_rx_adapter_conf struct passed into 486 * it. 487 * 488 * @param conf_arg 489 * Argument that is passed to the conf_cb function. 490 * 491 * @param rxa_params 492 * Pointer to struct rte_event_eth_rx_adapter_params. 493 * In case of NULL, default values are used. 494 * 495 * @return 496 * - 0: Success 497 * - <0: Error code on failure 498 */ 499 __rte_experimental 500 int 501 rte_event_eth_rx_adapter_create_ext_with_params(uint8_t id, uint8_t dev_id, 502 rte_event_eth_rx_adapter_conf_cb conf_cb, 503 void *conf_arg, 504 struct rte_event_eth_rx_adapter_params *rxa_params); 505 506 /** 507 * Free an event adapter 508 * 509 * @param id 510 * Adapter identifier. 511 * 512 * @return 513 * - 0: Success 514 * - <0: Error code on failure, If the adapter still has Rx queues 515 * added to it, the function returns -EBUSY. 516 */ 517 int rte_event_eth_rx_adapter_free(uint8_t id); 518 519 /** 520 * Add receive queue to an event adapter. After a queue has been 521 * added to the event adapter, the result of the application calling 522 * rte_eth_rx_burst(eth_dev_id, rx_queue_id, ..) is undefined. 523 * 524 * @param id 525 * Adapter identifier. 526 * 527 * @param eth_dev_id 528 * Port identifier of Ethernet device. 529 * 530 * @param rx_queue_id 531 * Ethernet device receive queue index. 532 * If rx_queue_id is -1, then all Rx queues configured for 533 * the device are added. If the ethdev Rx queues can only be 534 * connected to a single event queue then rx_queue_id is 535 * required to be -1. 536 * @see RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ 537 * 538 * @param conf 539 * Additional configuration structure of type *rte_event_eth_rx_adapter_queue_conf* 540 * 541 * @return 542 * - 0: Success, Receive queue added correctly. 543 * - <0: Error code on failure. 544 * - (-EIO) device reconfiguration and restart error. The adapter reconfigures 545 * the event device with an additional port if it is required to use a service 546 * function for packet transfer from the ethernet device to the event device. 547 * If the device had been started before this call, this error code indicates 548 * an error in restart following an error in reconfiguration, i.e., a 549 * combination of the two error codes. 550 */ 551 int rte_event_eth_rx_adapter_queue_add(uint8_t id, 552 uint16_t eth_dev_id, 553 int32_t rx_queue_id, 554 const struct rte_event_eth_rx_adapter_queue_conf *conf); 555 556 /** 557 * Delete receive queue from an event adapter. 558 * 559 * @param id 560 * Adapter identifier. 561 * 562 * @param eth_dev_id 563 * Port identifier of Ethernet device. 564 * 565 * @param rx_queue_id 566 * Ethernet device receive queue index. 567 * If rx_queue_id is -1, then all Rx queues configured for 568 * the device are deleted. If the ethdev Rx queues can only be 569 * connected to a single event queue then rx_queue_id is 570 * required to be -1. 571 * @see RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ 572 * 573 * @return 574 * - 0: Success, Receive queue deleted correctly. 575 * - <0: Error code on failure. 576 */ 577 int rte_event_eth_rx_adapter_queue_del(uint8_t id, uint16_t eth_dev_id, 578 int32_t rx_queue_id); 579 580 /** 581 * Start ethernet Rx event adapter 582 * 583 * @param id 584 * Adapter identifier. 585 * 586 * @return 587 * - 0: Success, Adapter started correctly. 588 * - <0: Error code on failure. 589 * 590 * @note 591 * The eventdev to which the event_eth_rx_adapter is connected needs to 592 * be started before calling rte_event_eth_rx_adapter_start(). 593 */ 594 int rte_event_eth_rx_adapter_start(uint8_t id); 595 596 /** 597 * Stop ethernet Rx event adapter 598 * 599 * @param id 600 * Adapter identifier. 601 * 602 * @return 603 * - 0: Success, Adapter started correctly. 604 * - <0: Error code on failure. 605 */ 606 int rte_event_eth_rx_adapter_stop(uint8_t id); 607 608 /** 609 * Retrieve statistics for an adapter 610 * 611 * @param id 612 * Adapter identifier. 613 * 614 * @param [out] stats 615 * A pointer to structure used to retrieve statistics for an adapter. 616 * 617 * @return 618 * - 0: Success, retrieved successfully. 619 * - <0: Error code on failure. 620 */ 621 int rte_event_eth_rx_adapter_stats_get(uint8_t id, 622 struct rte_event_eth_rx_adapter_stats *stats); 623 624 /** 625 * Reset statistics for an adapter. 626 * 627 * @param id 628 * Adapter identifier. 629 * 630 * @return 631 * - 0: Success, statistics reset successfully. 632 * - <0: Error code on failure. 633 */ 634 int rte_event_eth_rx_adapter_stats_reset(uint8_t id); 635 636 /** 637 * Retrieve the service ID of an adapter. If the adapter doesn't use 638 * a rte_service function, this function returns -ESRCH. 639 * 640 * @param id 641 * Adapter identifier. 642 * 643 * @param [out] service_id 644 * A pointer to a uint32_t, to be filled in with the service id. 645 * 646 * @return 647 * - 0: Success 648 * - <0: Error code on failure, if the adapter doesn't use a rte_service 649 * function, this function returns -ESRCH. 650 */ 651 int rte_event_eth_rx_adapter_service_id_get(uint8_t id, uint32_t *service_id); 652 653 /** 654 * Register callback to process Rx packets, this is supported for 655 * SW based packet transfers. 656 * @see rte_event_eth_rx_cb_fn 657 * 658 * @param id 659 * Adapter identifier. 660 * @param eth_dev_id 661 * Port identifier of Ethernet device. 662 * @param cb_fn 663 * Callback function. 664 * @param cb_arg 665 * Callback arg. 666 * @return 667 * - 0: Success 668 * - <0: Error code on failure. 669 */ 670 int rte_event_eth_rx_adapter_cb_register(uint8_t id, uint16_t eth_dev_id, 671 rte_event_eth_rx_adapter_cb_fn cb_fn, 672 void *cb_arg); 673 674 /** 675 * Retrieve vector limits for a given event dev and eth dev pair. 676 * @see rte_event_eth_rx_adapter_vector_limits 677 * 678 * @param dev_id 679 * Event device identifier. 680 * @param eth_port_id 681 * Port identifier of the ethernet device. 682 * @param [out] limits 683 * A pointer to rte_event_eth_rx_adapter_vector_limits structure that has to 684 * be filled. 685 * 686 * @return 687 * - 0: Success. 688 * - <0: Error code on failure. 689 */ 690 int rte_event_eth_rx_adapter_vector_limits_get( 691 uint8_t dev_id, uint16_t eth_port_id, 692 struct rte_event_eth_rx_adapter_vector_limits *limits); 693 694 /** 695 * Retrieve Rx queue config information. 696 * 697 * @param id 698 * Adapter identifier. 699 700 * @param eth_dev_id 701 * Port identifier of Ethernet device. 702 703 * @param rx_queue_id 704 * Ethernet device receive queue index. 705 706 * @param[out] queue_conf 707 * Pointer to struct rte_event_eth_rx_adapter_queue_conf 708 709 * @return 710 * - 0: Success, Receive queue added correctly. 711 * - <0: Error code on failure. 712 */ 713 int rte_event_eth_rx_adapter_queue_conf_get(uint8_t id, 714 uint16_t eth_dev_id, 715 uint16_t rx_queue_id, 716 struct rte_event_eth_rx_adapter_queue_conf *queue_conf); 717 718 /** 719 * Retrieve Rx queue statistics. 720 * 721 * @param id 722 * Adapter identifier. 723 * 724 * @param eth_dev_id 725 * Port identifier of Ethernet device. 726 * 727 * @param rx_queue_id 728 * Ethernet device receive queue index. 729 * 730 * @param[out] stats 731 * Pointer to struct rte_event_eth_rx_adapter_queue_stats 732 * 733 * @return 734 * - 0: Success, queue buffer stats retrieved. 735 * - <0: Error code on failure. 736 */ 737 int 738 rte_event_eth_rx_adapter_queue_stats_get(uint8_t id, 739 uint16_t eth_dev_id, 740 uint16_t rx_queue_id, 741 struct rte_event_eth_rx_adapter_queue_stats *stats); 742 743 /** 744 * Reset Rx queue statistics. 745 * 746 * @param id 747 * Adapter identifier. 748 * 749 * @param eth_dev_id 750 * Port identifier of Ethernet device. 751 * 752 * @param rx_queue_id 753 * Ethernet device receive queue index. 754 * 755 * @return 756 * - 0: Success, queue buffer stats retrieved. 757 * - <0: Error code on failure. 758 */ 759 int 760 rte_event_eth_rx_adapter_queue_stats_reset(uint8_t id, 761 uint16_t eth_dev_id, 762 uint16_t rx_queue_id); 763 764 /** 765 * Retrieve the event port ID of an adapter. If the adapter doesn't use 766 * a rte_service function, this function returns -ESRCH. 767 * 768 * @param id 769 * Adapter identifier. 770 * 771 * @param [out] event_port_id 772 * A pointer to a uint8_t, to be filled in with the port id. 773 * 774 * @return 775 * - 0: Success 776 * - <0: Error code on failure, if the adapter doesn't use a rte_service 777 * function, this function returns -ESRCH. 778 */ 779 int 780 rte_event_eth_rx_adapter_event_port_get(uint8_t id, uint8_t *event_port_id); 781 782 /** 783 * Get RX adapter instance ID for a RX queue 784 * 785 * @param eth_dev_id 786 * Port identifier of Ethernet device. 787 * 788 * @param rx_queue_id 789 * Ethernet device receive queue index. 790 * 791 * @param[out] rxa_inst_id 792 * Pointer to store RX adapter instance identifier. 793 * Contains valid Rx adapter instance id when return value is 0 794 * 795 * @return 796 * - 0: Success 797 * - <0: Error code on failure 798 */ 799 int 800 rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id, 801 uint16_t rx_queue_id, 802 uint8_t *rxa_inst_id); 803 804 /** 805 * Initialize the adapter runtime configuration parameters with default values 806 * 807 * @param params 808 * A pointer to structure of type struct rte_event_eth_rx_adapter_runtime_params 809 * 810 * @return 811 * - 0: Success 812 * - <0: Error code on failure 813 */ 814 __rte_experimental 815 int 816 rte_event_eth_rx_adapter_runtime_params_init( 817 struct rte_event_eth_rx_adapter_runtime_params *params); 818 819 /** 820 * Set the adapter runtime configuration parameters 821 * 822 * @param id 823 * Adapter identifier 824 * 825 * @param params 826 * A pointer to structure of type struct rte_event_eth_rx_adapter_runtime_params 827 * with configuration parameter values. The reserved fields of the structure 828 * must be initialized to zero and the valid fields need to be set appropriately. 829 * This structure can be initialized using 830 * rte_event_eth_rx_adapter_runtime_params_init() to default values or 831 * application may reset this structure and update the required fields. 832 * 833 * @return 834 * - 0: Success 835 * - <0: Error code on failure 836 */ 837 __rte_experimental 838 int 839 rte_event_eth_rx_adapter_runtime_params_set(uint8_t id, 840 struct rte_event_eth_rx_adapter_runtime_params *params); 841 842 /** 843 * Get the adapter runtime configuration parameters 844 * 845 * @param id 846 * Adapter identifier 847 * 848 * @param[out] params 849 * A pointer to structure of type struct rte_event_eth_rx_adapter_runtime_params 850 * containing valid adapter parameters when return value is 0. 851 * 852 * @return 853 * - 0: Success 854 * - <0: Error code on failure 855 */ 856 __rte_experimental 857 int 858 rte_event_eth_rx_adapter_runtime_params_get(uint8_t id, 859 struct rte_event_eth_rx_adapter_runtime_params *params); 860 861 #ifdef __cplusplus 862 } 863 #endif 864 #endif /* _RTE_EVENT_ETH_RX_ADAPTER_ */ 865