199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause 299a2dd95SBruce Richardson * Copyright(c) 2017 Intel Corporation 399a2dd95SBruce Richardson */ 499a2dd95SBruce Richardson 599a2dd95SBruce Richardson #ifndef _RTE_BBDEV_H_ 699a2dd95SBruce Richardson #define _RTE_BBDEV_H_ 799a2dd95SBruce Richardson 899a2dd95SBruce Richardson /** 999a2dd95SBruce Richardson * @file rte_bbdev.h 1099a2dd95SBruce Richardson * 1199a2dd95SBruce Richardson * Wireless base band device abstraction APIs. 1299a2dd95SBruce Richardson * 1399a2dd95SBruce Richardson * @warning 1499a2dd95SBruce Richardson * @b EXPERIMENTAL: 1599a2dd95SBruce Richardson * All functions in this file may be changed or removed without prior notice. 1699a2dd95SBruce Richardson * 1799a2dd95SBruce Richardson * This API allows an application to discover, configure and use a device to 1899a2dd95SBruce Richardson * process operations. An asynchronous API (enqueue, followed by later dequeue) 1999a2dd95SBruce Richardson * is used for processing operations. 2099a2dd95SBruce Richardson * 2199a2dd95SBruce Richardson * The functions in this API are not thread-safe when called on the same 2299a2dd95SBruce Richardson * target object (a device, or a queue on a device), with the exception that 2399a2dd95SBruce Richardson * one thread can enqueue operations to a queue while another thread dequeues 2499a2dd95SBruce Richardson * from the same queue. 2599a2dd95SBruce Richardson */ 2699a2dd95SBruce Richardson 2799a2dd95SBruce Richardson #ifdef __cplusplus 2899a2dd95SBruce Richardson extern "C" { 2999a2dd95SBruce Richardson #endif 3099a2dd95SBruce Richardson 3199a2dd95SBruce Richardson #include <stdint.h> 3299a2dd95SBruce Richardson #include <stdbool.h> 3399a2dd95SBruce Richardson #include <string.h> 3499a2dd95SBruce Richardson 3599a2dd95SBruce Richardson #include <rte_compat.h> 3699a2dd95SBruce Richardson #include <rte_bus.h> 3799a2dd95SBruce Richardson #include <rte_cpuflags.h> 3899a2dd95SBruce Richardson #include <rte_memory.h> 3999a2dd95SBruce Richardson 4099a2dd95SBruce Richardson #include "rte_bbdev_op.h" 4199a2dd95SBruce Richardson 4299a2dd95SBruce Richardson #ifndef RTE_BBDEV_MAX_DEVS 4399a2dd95SBruce Richardson #define RTE_BBDEV_MAX_DEVS 128 /**< Max number of devices */ 4499a2dd95SBruce Richardson #endif 4599a2dd95SBruce Richardson 4699a2dd95SBruce Richardson /** Flags indicate current state of BBDEV device */ 4799a2dd95SBruce Richardson enum rte_bbdev_state { 4899a2dd95SBruce Richardson RTE_BBDEV_UNUSED, 4999a2dd95SBruce Richardson RTE_BBDEV_INITIALIZED 5099a2dd95SBruce Richardson }; 5199a2dd95SBruce Richardson 5299a2dd95SBruce Richardson /** 5399a2dd95SBruce Richardson * Get the total number of devices that have been successfully initialised. 5499a2dd95SBruce Richardson * 5599a2dd95SBruce Richardson * @return 5699a2dd95SBruce Richardson * The total number of usable devices. 5799a2dd95SBruce Richardson */ 5899a2dd95SBruce Richardson __rte_experimental 5999a2dd95SBruce Richardson uint16_t 6099a2dd95SBruce Richardson rte_bbdev_count(void); 6199a2dd95SBruce Richardson 6299a2dd95SBruce Richardson /** 6399a2dd95SBruce Richardson * Check if a device is valid. 6499a2dd95SBruce Richardson * 6599a2dd95SBruce Richardson * @param dev_id 6699a2dd95SBruce Richardson * The identifier of the device. 6799a2dd95SBruce Richardson * 6899a2dd95SBruce Richardson * @return 6999a2dd95SBruce Richardson * true if device ID is valid and device is attached, false otherwise. 7099a2dd95SBruce Richardson */ 7199a2dd95SBruce Richardson __rte_experimental 7299a2dd95SBruce Richardson bool 7399a2dd95SBruce Richardson rte_bbdev_is_valid(uint16_t dev_id); 7499a2dd95SBruce Richardson 7599a2dd95SBruce Richardson /** 7699a2dd95SBruce Richardson * Get the next enabled device. 7799a2dd95SBruce Richardson * 7899a2dd95SBruce Richardson * @param dev_id 7999a2dd95SBruce Richardson * The current device 8099a2dd95SBruce Richardson * 8199a2dd95SBruce Richardson * @return 8299a2dd95SBruce Richardson * - The next device, or 8399a2dd95SBruce Richardson * - RTE_BBDEV_MAX_DEVS if none found 8499a2dd95SBruce Richardson */ 8599a2dd95SBruce Richardson __rte_experimental 8699a2dd95SBruce Richardson uint16_t 8799a2dd95SBruce Richardson rte_bbdev_find_next(uint16_t dev_id); 8899a2dd95SBruce Richardson 8999a2dd95SBruce Richardson /** Iterate through all enabled devices */ 9099a2dd95SBruce Richardson #define RTE_BBDEV_FOREACH(i) for (i = rte_bbdev_find_next(-1); \ 9199a2dd95SBruce Richardson i < RTE_BBDEV_MAX_DEVS; \ 9299a2dd95SBruce Richardson i = rte_bbdev_find_next(i)) 9399a2dd95SBruce Richardson 9499a2dd95SBruce Richardson /** 9599a2dd95SBruce Richardson * Setup up device queues. 9699a2dd95SBruce Richardson * This function must be called on a device before setting up the queues and 9799a2dd95SBruce Richardson * starting the device. It can also be called when a device is in the stopped 9899a2dd95SBruce Richardson * state. If any device queues have been configured their configuration will be 9999a2dd95SBruce Richardson * cleared by a call to this function. 10099a2dd95SBruce Richardson * 10199a2dd95SBruce Richardson * @param dev_id 10299a2dd95SBruce Richardson * The identifier of the device. 10399a2dd95SBruce Richardson * @param num_queues 10499a2dd95SBruce Richardson * Number of queues to configure on device. 10599a2dd95SBruce Richardson * @param socket_id 10699a2dd95SBruce Richardson * ID of a socket which will be used to allocate memory. 10799a2dd95SBruce Richardson * 10899a2dd95SBruce Richardson * @return 10999a2dd95SBruce Richardson * - 0 on success 11099a2dd95SBruce Richardson * - -ENODEV if dev_id is invalid or the device is corrupted 11199a2dd95SBruce Richardson * - -EINVAL if num_queues is invalid, 0 or greater than maximum 11299a2dd95SBruce Richardson * - -EBUSY if the identified device has already started 11399a2dd95SBruce Richardson * - -ENOMEM if unable to allocate memory 11499a2dd95SBruce Richardson */ 11599a2dd95SBruce Richardson __rte_experimental 11699a2dd95SBruce Richardson int 11799a2dd95SBruce Richardson rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id); 11899a2dd95SBruce Richardson 11999a2dd95SBruce Richardson /** 12099a2dd95SBruce Richardson * Enable interrupts. 12199a2dd95SBruce Richardson * This function may be called before starting the device to enable the 12299a2dd95SBruce Richardson * interrupts if they are available. 12399a2dd95SBruce Richardson * 12499a2dd95SBruce Richardson * @param dev_id 12599a2dd95SBruce Richardson * The identifier of the device. 12699a2dd95SBruce Richardson * 12799a2dd95SBruce Richardson * @return 12899a2dd95SBruce Richardson * - 0 on success 12999a2dd95SBruce Richardson * - -ENODEV if dev_id is invalid or the device is corrupted 13099a2dd95SBruce Richardson * - -EBUSY if the identified device has already started 13199a2dd95SBruce Richardson * - -ENOTSUP if the interrupts are not supported by the device 13299a2dd95SBruce Richardson */ 13399a2dd95SBruce Richardson __rte_experimental 13499a2dd95SBruce Richardson int 13599a2dd95SBruce Richardson rte_bbdev_intr_enable(uint16_t dev_id); 13699a2dd95SBruce Richardson 13799a2dd95SBruce Richardson /** Device queue configuration structure */ 13899a2dd95SBruce Richardson struct rte_bbdev_queue_conf { 13999a2dd95SBruce Richardson int socket; /**< NUMA socket used for memory allocation */ 14099a2dd95SBruce Richardson uint32_t queue_size; /**< Size of queue */ 14199a2dd95SBruce Richardson uint8_t priority; /**< Queue priority */ 14299a2dd95SBruce Richardson bool deferred_start; /**< Do not start queue when device is started. */ 14399a2dd95SBruce Richardson enum rte_bbdev_op_type op_type; /**< Operation type */ 14499a2dd95SBruce Richardson }; 14599a2dd95SBruce Richardson 14699a2dd95SBruce Richardson /** 14799a2dd95SBruce Richardson * Configure a queue on a device. 14899a2dd95SBruce Richardson * This function can be called after device configuration, and before starting. 14999a2dd95SBruce Richardson * It can also be called when the device or the queue is in the stopped state. 15099a2dd95SBruce Richardson * 15199a2dd95SBruce Richardson * @param dev_id 15299a2dd95SBruce Richardson * The identifier of the device. 15399a2dd95SBruce Richardson * @param queue_id 15499a2dd95SBruce Richardson * The index of the queue. 15599a2dd95SBruce Richardson * @param conf 15699a2dd95SBruce Richardson * The queue configuration. If NULL, a default configuration will be used. 15799a2dd95SBruce Richardson * 15899a2dd95SBruce Richardson * @return 15999a2dd95SBruce Richardson * - 0 on success 16099a2dd95SBruce Richardson * - EINVAL if the identified queue size or priority are invalid 16199a2dd95SBruce Richardson * - EBUSY if the identified queue or its device have already started 16299a2dd95SBruce Richardson */ 16399a2dd95SBruce Richardson __rte_experimental 16499a2dd95SBruce Richardson int 16599a2dd95SBruce Richardson rte_bbdev_queue_configure(uint16_t dev_id, uint16_t queue_id, 16699a2dd95SBruce Richardson const struct rte_bbdev_queue_conf *conf); 16799a2dd95SBruce Richardson 16899a2dd95SBruce Richardson /** 16999a2dd95SBruce Richardson * Start a device. 17099a2dd95SBruce Richardson * This is the last step needed before enqueueing operations is possible. 17199a2dd95SBruce Richardson * 17299a2dd95SBruce Richardson * @param dev_id 17399a2dd95SBruce Richardson * The identifier of the device. 17499a2dd95SBruce Richardson * 17599a2dd95SBruce Richardson * @return 17699a2dd95SBruce Richardson * - 0 on success 17799a2dd95SBruce Richardson * - negative value on failure - as returned from PMD driver 17899a2dd95SBruce Richardson */ 17999a2dd95SBruce Richardson __rte_experimental 18099a2dd95SBruce Richardson int 18199a2dd95SBruce Richardson rte_bbdev_start(uint16_t dev_id); 18299a2dd95SBruce Richardson 18399a2dd95SBruce Richardson /** 18499a2dd95SBruce Richardson * Stop a device. 18599a2dd95SBruce Richardson * The device can be reconfigured, and restarted after being stopped. 18699a2dd95SBruce Richardson * 18799a2dd95SBruce Richardson * @param dev_id 18899a2dd95SBruce Richardson * The identifier of the device. 18999a2dd95SBruce Richardson * 19099a2dd95SBruce Richardson * @return 19199a2dd95SBruce Richardson * - 0 on success 19299a2dd95SBruce Richardson */ 19399a2dd95SBruce Richardson __rte_experimental 19499a2dd95SBruce Richardson int 19599a2dd95SBruce Richardson rte_bbdev_stop(uint16_t dev_id); 19699a2dd95SBruce Richardson 19799a2dd95SBruce Richardson /** 19899a2dd95SBruce Richardson * Close a device. 19999a2dd95SBruce Richardson * The device cannot be restarted without reconfiguration! 20099a2dd95SBruce Richardson * 20199a2dd95SBruce Richardson * @param dev_id 20299a2dd95SBruce Richardson * The identifier of the device. 20399a2dd95SBruce Richardson * 20499a2dd95SBruce Richardson * @return 20599a2dd95SBruce Richardson * - 0 on success 20699a2dd95SBruce Richardson */ 20799a2dd95SBruce Richardson __rte_experimental 20899a2dd95SBruce Richardson int 20999a2dd95SBruce Richardson rte_bbdev_close(uint16_t dev_id); 21099a2dd95SBruce Richardson 21199a2dd95SBruce Richardson /** 21299a2dd95SBruce Richardson * Start a specified queue on a device. 21399a2dd95SBruce Richardson * This is only needed if the queue has been stopped, or if the deferred_start 21499a2dd95SBruce Richardson * flag has been set when configuring the queue. 21599a2dd95SBruce Richardson * 21699a2dd95SBruce Richardson * @param dev_id 21799a2dd95SBruce Richardson * The identifier of the device. 21899a2dd95SBruce Richardson * @param queue_id 21999a2dd95SBruce Richardson * The index of the queue. 22099a2dd95SBruce Richardson * 22199a2dd95SBruce Richardson * @return 22299a2dd95SBruce Richardson * - 0 on success 22399a2dd95SBruce Richardson * - negative value on failure - as returned from PMD driver 22499a2dd95SBruce Richardson */ 22599a2dd95SBruce Richardson __rte_experimental 22699a2dd95SBruce Richardson int 22799a2dd95SBruce Richardson rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id); 22899a2dd95SBruce Richardson 22999a2dd95SBruce Richardson /** 23099a2dd95SBruce Richardson * Stop a specified queue on a device, to allow re configuration. 23199a2dd95SBruce Richardson * 23299a2dd95SBruce Richardson * @param dev_id 23399a2dd95SBruce Richardson * The identifier of the device. 23499a2dd95SBruce Richardson * @param queue_id 23599a2dd95SBruce Richardson * The index of the queue. 23699a2dd95SBruce Richardson * 23799a2dd95SBruce Richardson * @return 23899a2dd95SBruce Richardson * - 0 on success 23999a2dd95SBruce Richardson * - negative value on failure - as returned from PMD driver 24099a2dd95SBruce Richardson */ 24199a2dd95SBruce Richardson __rte_experimental 24299a2dd95SBruce Richardson int 24399a2dd95SBruce Richardson rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id); 24499a2dd95SBruce Richardson 24599a2dd95SBruce Richardson /** Device statistics. */ 24699a2dd95SBruce Richardson struct rte_bbdev_stats { 24799a2dd95SBruce Richardson uint64_t enqueued_count; /**< Count of all operations enqueued */ 24899a2dd95SBruce Richardson uint64_t dequeued_count; /**< Count of all operations dequeued */ 24999a2dd95SBruce Richardson /** Total error count on operations enqueued */ 25099a2dd95SBruce Richardson uint64_t enqueue_err_count; 25199a2dd95SBruce Richardson /** Total error count on operations dequeued */ 25299a2dd95SBruce Richardson uint64_t dequeue_err_count; 25399a2dd95SBruce Richardson /** CPU cycles consumed by the (HW/SW) accelerator device to offload 25499a2dd95SBruce Richardson * the enqueue request to its internal queues. 25599a2dd95SBruce Richardson * - For a HW device this is the cycles consumed in MMIO write 25699a2dd95SBruce Richardson * - For a SW (vdev) device, this is the processing time of the 25799a2dd95SBruce Richardson * bbdev operation 25899a2dd95SBruce Richardson */ 25999a2dd95SBruce Richardson uint64_t acc_offload_cycles; 26099a2dd95SBruce Richardson }; 26199a2dd95SBruce Richardson 26299a2dd95SBruce Richardson /** 26399a2dd95SBruce Richardson * Retrieve the general I/O statistics of a device. 26499a2dd95SBruce Richardson * 26599a2dd95SBruce Richardson * @param dev_id 26699a2dd95SBruce Richardson * The identifier of the device. 26799a2dd95SBruce Richardson * @param stats 26899a2dd95SBruce Richardson * Pointer to structure to where statistics will be copied. On error, this 26999a2dd95SBruce Richardson * location may or may not have been modified. 27099a2dd95SBruce Richardson * 27199a2dd95SBruce Richardson * @return 27299a2dd95SBruce Richardson * - 0 on success 27399a2dd95SBruce Richardson * - EINVAL if invalid parameter pointer is provided 27499a2dd95SBruce Richardson */ 27599a2dd95SBruce Richardson __rte_experimental 27699a2dd95SBruce Richardson int 27799a2dd95SBruce Richardson rte_bbdev_stats_get(uint16_t dev_id, struct rte_bbdev_stats *stats); 27899a2dd95SBruce Richardson 27999a2dd95SBruce Richardson /** 28099a2dd95SBruce Richardson * Reset the statistics of a device. 28199a2dd95SBruce Richardson * 28299a2dd95SBruce Richardson * @param dev_id 28399a2dd95SBruce Richardson * The identifier of the device. 28499a2dd95SBruce Richardson * @return 28599a2dd95SBruce Richardson * - 0 on success 28699a2dd95SBruce Richardson */ 28799a2dd95SBruce Richardson __rte_experimental 28899a2dd95SBruce Richardson int 28999a2dd95SBruce Richardson rte_bbdev_stats_reset(uint16_t dev_id); 29099a2dd95SBruce Richardson 29199a2dd95SBruce Richardson /** Device information supplied by the device's driver */ 29299a2dd95SBruce Richardson struct rte_bbdev_driver_info { 29399a2dd95SBruce Richardson /** Driver name */ 29499a2dd95SBruce Richardson const char *driver_name; 29599a2dd95SBruce Richardson 29699a2dd95SBruce Richardson /** Maximum number of queues supported by the device */ 29799a2dd95SBruce Richardson unsigned int max_num_queues; 29899a2dd95SBruce Richardson /** Queue size limit (queue size must also be power of 2) */ 29999a2dd95SBruce Richardson uint32_t queue_size_lim; 30099a2dd95SBruce Richardson /** Set if device off-loads operation to hardware */ 30199a2dd95SBruce Richardson bool hardware_accelerated; 30299a2dd95SBruce Richardson /** Max value supported by queue priority for DL */ 30399a2dd95SBruce Richardson uint8_t max_dl_queue_priority; 30499a2dd95SBruce Richardson /** Max value supported by queue priority for UL */ 30599a2dd95SBruce Richardson uint8_t max_ul_queue_priority; 30699a2dd95SBruce Richardson /** Set if device supports per-queue interrupts */ 30799a2dd95SBruce Richardson bool queue_intr_supported; 30899a2dd95SBruce Richardson /** Minimum alignment of buffers, in bytes */ 30999a2dd95SBruce Richardson uint16_t min_alignment; 31099a2dd95SBruce Richardson /** HARQ memory available in kB */ 31199a2dd95SBruce Richardson uint32_t harq_buffer_size; 312*ab4e1909SNicolas Chautru /** Byte endianness (RTE_BIG_ENDIAN/RTE_LITTLE_ENDIAN) supported 313*ab4e1909SNicolas Chautru * for input/output data 314*ab4e1909SNicolas Chautru */ 315*ab4e1909SNicolas Chautru uint8_t data_endianness; 31699a2dd95SBruce Richardson /** Default queue configuration used if none is supplied */ 31799a2dd95SBruce Richardson struct rte_bbdev_queue_conf default_queue_conf; 31899a2dd95SBruce Richardson /** Device operation capabilities */ 31999a2dd95SBruce Richardson const struct rte_bbdev_op_cap *capabilities; 32099a2dd95SBruce Richardson /** Device cpu_flag requirements */ 32199a2dd95SBruce Richardson const enum rte_cpu_flag_t *cpu_flag_reqs; 32299a2dd95SBruce Richardson }; 32399a2dd95SBruce Richardson 32499a2dd95SBruce Richardson /** Macro used at end of bbdev PMD list */ 32599a2dd95SBruce Richardson #define RTE_BBDEV_END_OF_CAPABILITIES_LIST() \ 32699a2dd95SBruce Richardson { RTE_BBDEV_OP_NONE } 32799a2dd95SBruce Richardson 32899a2dd95SBruce Richardson /** 32999a2dd95SBruce Richardson * Device information structure used by an application to discover a devices 33099a2dd95SBruce Richardson * capabilities and current configuration 33199a2dd95SBruce Richardson */ 33299a2dd95SBruce Richardson struct rte_bbdev_info { 33399a2dd95SBruce Richardson int socket_id; /**< NUMA socket that device is on */ 33499a2dd95SBruce Richardson const char *dev_name; /**< Unique device name */ 33599a2dd95SBruce Richardson const struct rte_device *device; /**< Device Information */ 33699a2dd95SBruce Richardson uint16_t num_queues; /**< Number of queues currently configured */ 33799a2dd95SBruce Richardson bool started; /**< Set if device is currently started */ 33899a2dd95SBruce Richardson struct rte_bbdev_driver_info drv; /**< Info from device driver */ 33999a2dd95SBruce Richardson }; 34099a2dd95SBruce Richardson 34199a2dd95SBruce Richardson /** 34299a2dd95SBruce Richardson * Retrieve information about a device. 34399a2dd95SBruce Richardson * 34499a2dd95SBruce Richardson * @param dev_id 34599a2dd95SBruce Richardson * The identifier of the device. 34699a2dd95SBruce Richardson * @param dev_info 34799a2dd95SBruce Richardson * Pointer to structure to where information will be copied. On error, this 34899a2dd95SBruce Richardson * location may or may not have been modified. 34999a2dd95SBruce Richardson * 35099a2dd95SBruce Richardson * @return 35199a2dd95SBruce Richardson * - 0 on success 35299a2dd95SBruce Richardson * - EINVAL if invalid parameter pointer is provided 35399a2dd95SBruce Richardson */ 35499a2dd95SBruce Richardson __rte_experimental 35599a2dd95SBruce Richardson int 35699a2dd95SBruce Richardson rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info); 35799a2dd95SBruce Richardson 35899a2dd95SBruce Richardson /** Queue information */ 35999a2dd95SBruce Richardson struct rte_bbdev_queue_info { 36099a2dd95SBruce Richardson /** Current device configuration */ 36199a2dd95SBruce Richardson struct rte_bbdev_queue_conf conf; 36299a2dd95SBruce Richardson /** Set if queue is currently started */ 36399a2dd95SBruce Richardson bool started; 36499a2dd95SBruce Richardson }; 36599a2dd95SBruce Richardson 36699a2dd95SBruce Richardson /** 36799a2dd95SBruce Richardson * Retrieve information about a specific queue on a device. 36899a2dd95SBruce Richardson * 36999a2dd95SBruce Richardson * @param dev_id 37099a2dd95SBruce Richardson * The identifier of the device. 37199a2dd95SBruce Richardson * @param queue_id 37299a2dd95SBruce Richardson * The index of the queue. 37399a2dd95SBruce Richardson * @param queue_info 37499a2dd95SBruce Richardson * Pointer to structure to where information will be copied. On error, this 37599a2dd95SBruce Richardson * location may or may not have been modified. 37699a2dd95SBruce Richardson * 37799a2dd95SBruce Richardson * @return 37899a2dd95SBruce Richardson * - 0 on success 37999a2dd95SBruce Richardson * - EINVAL if invalid parameter pointer is provided 38099a2dd95SBruce Richardson */ 38199a2dd95SBruce Richardson __rte_experimental 38299a2dd95SBruce Richardson int 38399a2dd95SBruce Richardson rte_bbdev_queue_info_get(uint16_t dev_id, uint16_t queue_id, 38499a2dd95SBruce Richardson struct rte_bbdev_queue_info *queue_info); 38599a2dd95SBruce Richardson 38699a2dd95SBruce Richardson /** @internal The data structure associated with each queue of a device. */ 38799a2dd95SBruce Richardson struct rte_bbdev_queue_data { 38899a2dd95SBruce Richardson void *queue_private; /**< Driver-specific per-queue data */ 38999a2dd95SBruce Richardson struct rte_bbdev_queue_conf conf; /**< Current configuration */ 39099a2dd95SBruce Richardson struct rte_bbdev_stats queue_stats; /**< Queue statistics */ 39199a2dd95SBruce Richardson bool started; /**< Queue state */ 39299a2dd95SBruce Richardson }; 39399a2dd95SBruce Richardson 39499a2dd95SBruce Richardson /** @internal Enqueue encode operations for processing on queue of a device. */ 39599a2dd95SBruce Richardson typedef uint16_t (*rte_bbdev_enqueue_enc_ops_t)( 39699a2dd95SBruce Richardson struct rte_bbdev_queue_data *q_data, 39799a2dd95SBruce Richardson struct rte_bbdev_enc_op **ops, 39899a2dd95SBruce Richardson uint16_t num); 39999a2dd95SBruce Richardson 40099a2dd95SBruce Richardson /** @internal Enqueue decode operations for processing on queue of a device. */ 40199a2dd95SBruce Richardson typedef uint16_t (*rte_bbdev_enqueue_dec_ops_t)( 40299a2dd95SBruce Richardson struct rte_bbdev_queue_data *q_data, 40399a2dd95SBruce Richardson struct rte_bbdev_dec_op **ops, 40499a2dd95SBruce Richardson uint16_t num); 40599a2dd95SBruce Richardson 40699a2dd95SBruce Richardson /** @internal Dequeue encode operations from a queue of a device. */ 40799a2dd95SBruce Richardson typedef uint16_t (*rte_bbdev_dequeue_enc_ops_t)( 40899a2dd95SBruce Richardson struct rte_bbdev_queue_data *q_data, 40999a2dd95SBruce Richardson struct rte_bbdev_enc_op **ops, uint16_t num); 41099a2dd95SBruce Richardson 41199a2dd95SBruce Richardson /** @internal Dequeue decode operations from a queue of a device. */ 41299a2dd95SBruce Richardson typedef uint16_t (*rte_bbdev_dequeue_dec_ops_t)( 41399a2dd95SBruce Richardson struct rte_bbdev_queue_data *q_data, 41499a2dd95SBruce Richardson struct rte_bbdev_dec_op **ops, uint16_t num); 41599a2dd95SBruce Richardson 41699a2dd95SBruce Richardson #define RTE_BBDEV_NAME_MAX_LEN 64 /**< Max length of device name */ 41799a2dd95SBruce Richardson 41899a2dd95SBruce Richardson /** 41999a2dd95SBruce Richardson * @internal The data associated with a device, with no function pointers. 42099a2dd95SBruce Richardson * This structure is safe to place in shared memory to be common among 42199a2dd95SBruce Richardson * different processes in a multi-process configuration. Drivers can access 42299a2dd95SBruce Richardson * these fields, but should never write to them! 42399a2dd95SBruce Richardson */ 42499a2dd95SBruce Richardson struct rte_bbdev_data { 42599a2dd95SBruce Richardson char name[RTE_BBDEV_NAME_MAX_LEN]; /**< Unique identifier name */ 42699a2dd95SBruce Richardson void *dev_private; /**< Driver-specific private data */ 42799a2dd95SBruce Richardson uint16_t num_queues; /**< Number of currently configured queues */ 42899a2dd95SBruce Richardson struct rte_bbdev_queue_data *queues; /**< Queue structures */ 42999a2dd95SBruce Richardson uint16_t dev_id; /**< Device ID */ 43099a2dd95SBruce Richardson int socket_id; /**< NUMA socket that device is on */ 43199a2dd95SBruce Richardson bool started; /**< Device run-time state */ 43299a2dd95SBruce Richardson uint16_t process_cnt; /** Counter of processes using the device */ 43399a2dd95SBruce Richardson }; 43499a2dd95SBruce Richardson 43599a2dd95SBruce Richardson /* Forward declarations */ 43699a2dd95SBruce Richardson struct rte_bbdev_ops; 43799a2dd95SBruce Richardson struct rte_bbdev_callback; 43899a2dd95SBruce Richardson struct rte_intr_handle; 43999a2dd95SBruce Richardson 44099a2dd95SBruce Richardson /** Structure to keep track of registered callbacks */ 441f1f6ebc0SWilliam Tu RTE_TAILQ_HEAD(rte_bbdev_cb_list, rte_bbdev_callback); 44299a2dd95SBruce Richardson 44399a2dd95SBruce Richardson /** 44499a2dd95SBruce Richardson * @internal The data structure associated with a device. Drivers can access 44599a2dd95SBruce Richardson * these fields, but should only write to the *_ops fields. 44699a2dd95SBruce Richardson */ 44799a2dd95SBruce Richardson struct __rte_cache_aligned rte_bbdev { 44899a2dd95SBruce Richardson /** Enqueue encode function */ 44999a2dd95SBruce Richardson rte_bbdev_enqueue_enc_ops_t enqueue_enc_ops; 45099a2dd95SBruce Richardson /** Enqueue decode function */ 45199a2dd95SBruce Richardson rte_bbdev_enqueue_dec_ops_t enqueue_dec_ops; 45299a2dd95SBruce Richardson /** Dequeue encode function */ 45399a2dd95SBruce Richardson rte_bbdev_dequeue_enc_ops_t dequeue_enc_ops; 45499a2dd95SBruce Richardson /** Dequeue decode function */ 45599a2dd95SBruce Richardson rte_bbdev_dequeue_dec_ops_t dequeue_dec_ops; 45699a2dd95SBruce Richardson /** Enqueue encode function */ 45799a2dd95SBruce Richardson rte_bbdev_enqueue_enc_ops_t enqueue_ldpc_enc_ops; 45899a2dd95SBruce Richardson /** Enqueue decode function */ 45999a2dd95SBruce Richardson rte_bbdev_enqueue_dec_ops_t enqueue_ldpc_dec_ops; 46099a2dd95SBruce Richardson /** Dequeue encode function */ 46199a2dd95SBruce Richardson rte_bbdev_dequeue_enc_ops_t dequeue_ldpc_enc_ops; 46299a2dd95SBruce Richardson /** Dequeue decode function */ 46399a2dd95SBruce Richardson rte_bbdev_dequeue_dec_ops_t dequeue_ldpc_dec_ops; 46499a2dd95SBruce Richardson const struct rte_bbdev_ops *dev_ops; /**< Functions exported by PMD */ 46599a2dd95SBruce Richardson struct rte_bbdev_data *data; /**< Pointer to device data */ 46699a2dd95SBruce Richardson enum rte_bbdev_state state; /**< If device is currently used or not */ 46799a2dd95SBruce Richardson struct rte_device *device; /**< Backing device */ 46899a2dd95SBruce Richardson /** User application callback for interrupts if present */ 46999a2dd95SBruce Richardson struct rte_bbdev_cb_list list_cbs; 47099a2dd95SBruce Richardson struct rte_intr_handle *intr_handle; /**< Device interrupt handle */ 47199a2dd95SBruce Richardson }; 47299a2dd95SBruce Richardson 47399a2dd95SBruce Richardson /** @internal array of all devices */ 47499a2dd95SBruce Richardson extern struct rte_bbdev rte_bbdev_devices[]; 47599a2dd95SBruce Richardson 47699a2dd95SBruce Richardson /** 47799a2dd95SBruce Richardson * Enqueue a burst of processed encode operations to a queue of the device. 47899a2dd95SBruce Richardson * This functions only enqueues as many operations as currently possible and 47999a2dd95SBruce Richardson * does not block until @p num_ops entries in the queue are available. 48099a2dd95SBruce Richardson * This function does not provide any error notification to avoid the 48199a2dd95SBruce Richardson * corresponding overhead. 48299a2dd95SBruce Richardson * 48399a2dd95SBruce Richardson * @param dev_id 48499a2dd95SBruce Richardson * The identifier of the device. 48599a2dd95SBruce Richardson * @param queue_id 48699a2dd95SBruce Richardson * The index of the queue. 48799a2dd95SBruce Richardson * @param ops 48899a2dd95SBruce Richardson * Pointer array containing operations to be enqueued Must have at least 48999a2dd95SBruce Richardson * @p num_ops entries 49099a2dd95SBruce Richardson * @param num_ops 49199a2dd95SBruce Richardson * The maximum number of operations to enqueue. 49299a2dd95SBruce Richardson * 49399a2dd95SBruce Richardson * @return 49499a2dd95SBruce Richardson * The number of operations actually enqueued (this is the number of processed 49599a2dd95SBruce Richardson * entries in the @p ops array). 49699a2dd95SBruce Richardson */ 49799a2dd95SBruce Richardson __rte_experimental 49899a2dd95SBruce Richardson static inline uint16_t 49999a2dd95SBruce Richardson rte_bbdev_enqueue_enc_ops(uint16_t dev_id, uint16_t queue_id, 50099a2dd95SBruce Richardson struct rte_bbdev_enc_op **ops, uint16_t num_ops) 50199a2dd95SBruce Richardson { 50299a2dd95SBruce Richardson struct rte_bbdev *dev = &rte_bbdev_devices[dev_id]; 50399a2dd95SBruce Richardson struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id]; 50499a2dd95SBruce Richardson return dev->enqueue_enc_ops(q_data, ops, num_ops); 50599a2dd95SBruce Richardson } 50699a2dd95SBruce Richardson 50799a2dd95SBruce Richardson /** 50899a2dd95SBruce Richardson * Enqueue a burst of processed decode operations to a queue of the device. 50999a2dd95SBruce Richardson * This functions only enqueues as many operations as currently possible and 51099a2dd95SBruce Richardson * does not block until @p num_ops entries in the queue are available. 51199a2dd95SBruce Richardson * This function does not provide any error notification to avoid the 51299a2dd95SBruce Richardson * corresponding overhead. 51399a2dd95SBruce Richardson * 51499a2dd95SBruce Richardson * @param dev_id 51599a2dd95SBruce Richardson * The identifier of the device. 51699a2dd95SBruce Richardson * @param queue_id 51799a2dd95SBruce Richardson * The index of the queue. 51899a2dd95SBruce Richardson * @param ops 51999a2dd95SBruce Richardson * Pointer array containing operations to be enqueued Must have at least 52099a2dd95SBruce Richardson * @p num_ops entries 52199a2dd95SBruce Richardson * @param num_ops 52299a2dd95SBruce Richardson * The maximum number of operations to enqueue. 52399a2dd95SBruce Richardson * 52499a2dd95SBruce Richardson * @return 52599a2dd95SBruce Richardson * The number of operations actually enqueued (this is the number of processed 52699a2dd95SBruce Richardson * entries in the @p ops array). 52799a2dd95SBruce Richardson */ 52899a2dd95SBruce Richardson __rte_experimental 52999a2dd95SBruce Richardson static inline uint16_t 53099a2dd95SBruce Richardson rte_bbdev_enqueue_dec_ops(uint16_t dev_id, uint16_t queue_id, 53199a2dd95SBruce Richardson struct rte_bbdev_dec_op **ops, uint16_t num_ops) 53299a2dd95SBruce Richardson { 53399a2dd95SBruce Richardson struct rte_bbdev *dev = &rte_bbdev_devices[dev_id]; 53499a2dd95SBruce Richardson struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id]; 53599a2dd95SBruce Richardson return dev->enqueue_dec_ops(q_data, ops, num_ops); 53699a2dd95SBruce Richardson } 53799a2dd95SBruce Richardson 53899a2dd95SBruce Richardson /** 53999a2dd95SBruce Richardson * Enqueue a burst of processed encode operations to a queue of the device. 54099a2dd95SBruce Richardson * This functions only enqueues as many operations as currently possible and 54199a2dd95SBruce Richardson * does not block until @p num_ops entries in the queue are available. 54299a2dd95SBruce Richardson * This function does not provide any error notification to avoid the 54399a2dd95SBruce Richardson * corresponding overhead. 54499a2dd95SBruce Richardson * 54599a2dd95SBruce Richardson * @param dev_id 54699a2dd95SBruce Richardson * The identifier of the device. 54799a2dd95SBruce Richardson * @param queue_id 54899a2dd95SBruce Richardson * The index of the queue. 54999a2dd95SBruce Richardson * @param ops 55099a2dd95SBruce Richardson * Pointer array containing operations to be enqueued Must have at least 55199a2dd95SBruce Richardson * @p num_ops entries 55299a2dd95SBruce Richardson * @param num_ops 55399a2dd95SBruce Richardson * The maximum number of operations to enqueue. 55499a2dd95SBruce Richardson * 55599a2dd95SBruce Richardson * @return 55699a2dd95SBruce Richardson * The number of operations actually enqueued (this is the number of processed 55799a2dd95SBruce Richardson * entries in the @p ops array). 55899a2dd95SBruce Richardson */ 55999a2dd95SBruce Richardson __rte_experimental 56099a2dd95SBruce Richardson static inline uint16_t 56199a2dd95SBruce Richardson rte_bbdev_enqueue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id, 56299a2dd95SBruce Richardson struct rte_bbdev_enc_op **ops, uint16_t num_ops) 56399a2dd95SBruce Richardson { 56499a2dd95SBruce Richardson struct rte_bbdev *dev = &rte_bbdev_devices[dev_id]; 56599a2dd95SBruce Richardson struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id]; 56699a2dd95SBruce Richardson return dev->enqueue_ldpc_enc_ops(q_data, ops, num_ops); 56799a2dd95SBruce Richardson } 56899a2dd95SBruce Richardson 56999a2dd95SBruce Richardson /** 57099a2dd95SBruce Richardson * Enqueue a burst of processed decode operations to a queue of the device. 57199a2dd95SBruce Richardson * This functions only enqueues as many operations as currently possible and 57299a2dd95SBruce Richardson * does not block until @p num_ops entries in the queue are available. 57399a2dd95SBruce Richardson * This function does not provide any error notification to avoid the 57499a2dd95SBruce Richardson * corresponding overhead. 57599a2dd95SBruce Richardson * 57699a2dd95SBruce Richardson * @param dev_id 57799a2dd95SBruce Richardson * The identifier of the device. 57899a2dd95SBruce Richardson * @param queue_id 57999a2dd95SBruce Richardson * The index of the queue. 58099a2dd95SBruce Richardson * @param ops 58199a2dd95SBruce Richardson * Pointer array containing operations to be enqueued Must have at least 58299a2dd95SBruce Richardson * @p num_ops entries 58399a2dd95SBruce Richardson * @param num_ops 58499a2dd95SBruce Richardson * The maximum number of operations to enqueue. 58599a2dd95SBruce Richardson * 58699a2dd95SBruce Richardson * @return 58799a2dd95SBruce Richardson * The number of operations actually enqueued (this is the number of processed 58899a2dd95SBruce Richardson * entries in the @p ops array). 58999a2dd95SBruce Richardson */ 59099a2dd95SBruce Richardson __rte_experimental 59199a2dd95SBruce Richardson static inline uint16_t 59299a2dd95SBruce Richardson rte_bbdev_enqueue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id, 59399a2dd95SBruce Richardson struct rte_bbdev_dec_op **ops, uint16_t num_ops) 59499a2dd95SBruce Richardson { 59599a2dd95SBruce Richardson struct rte_bbdev *dev = &rte_bbdev_devices[dev_id]; 59699a2dd95SBruce Richardson struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id]; 59799a2dd95SBruce Richardson return dev->enqueue_ldpc_dec_ops(q_data, ops, num_ops); 59899a2dd95SBruce Richardson } 59999a2dd95SBruce Richardson 60099a2dd95SBruce Richardson 60199a2dd95SBruce Richardson /** 60299a2dd95SBruce Richardson * Dequeue a burst of processed encode operations from a queue of the device. 60399a2dd95SBruce Richardson * This functions returns only the current contents of the queue, and does not 60499a2dd95SBruce Richardson * block until @ num_ops is available. 60599a2dd95SBruce Richardson * This function does not provide any error notification to avoid the 60699a2dd95SBruce Richardson * corresponding overhead. 60799a2dd95SBruce Richardson * 60899a2dd95SBruce Richardson * @param dev_id 60999a2dd95SBruce Richardson * The identifier of the device. 61099a2dd95SBruce Richardson * @param queue_id 61199a2dd95SBruce Richardson * The index of the queue. 61299a2dd95SBruce Richardson * @param ops 61399a2dd95SBruce Richardson * Pointer array where operations will be dequeued to. Must have at least 61499a2dd95SBruce Richardson * @p num_ops entries 61599a2dd95SBruce Richardson * ie. A pointer to a table of void * pointers (ops) that will be filled. 61699a2dd95SBruce Richardson * @param num_ops 61799a2dd95SBruce Richardson * The maximum number of operations to dequeue. 61899a2dd95SBruce Richardson * 61999a2dd95SBruce Richardson * @return 62099a2dd95SBruce Richardson * The number of operations actually dequeued (this is the number of entries 62199a2dd95SBruce Richardson * copied into the @p ops array). 62299a2dd95SBruce Richardson */ 62399a2dd95SBruce Richardson __rte_experimental 62499a2dd95SBruce Richardson static inline uint16_t 62599a2dd95SBruce Richardson rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id, 62699a2dd95SBruce Richardson struct rte_bbdev_enc_op **ops, uint16_t num_ops) 62799a2dd95SBruce Richardson { 62899a2dd95SBruce Richardson struct rte_bbdev *dev = &rte_bbdev_devices[dev_id]; 62999a2dd95SBruce Richardson struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id]; 63099a2dd95SBruce Richardson return dev->dequeue_enc_ops(q_data, ops, num_ops); 63199a2dd95SBruce Richardson } 63299a2dd95SBruce Richardson 63399a2dd95SBruce Richardson /** 63499a2dd95SBruce Richardson * Dequeue a burst of processed decode operations from a queue of the device. 63599a2dd95SBruce Richardson * This functions returns only the current contents of the queue, and does not 63699a2dd95SBruce Richardson * block until @ num_ops is available. 63799a2dd95SBruce Richardson * This function does not provide any error notification to avoid the 63899a2dd95SBruce Richardson * corresponding overhead. 63999a2dd95SBruce Richardson * 64099a2dd95SBruce Richardson * @param dev_id 64199a2dd95SBruce Richardson * The identifier of the device. 64299a2dd95SBruce Richardson * @param queue_id 64399a2dd95SBruce Richardson * The index of the queue. 64499a2dd95SBruce Richardson * @param ops 64599a2dd95SBruce Richardson * Pointer array where operations will be dequeued to. Must have at least 64699a2dd95SBruce Richardson * @p num_ops entries 64799a2dd95SBruce Richardson * ie. A pointer to a table of void * pointers (ops) that will be filled. 64899a2dd95SBruce Richardson * @param num_ops 64999a2dd95SBruce Richardson * The maximum number of operations to dequeue. 65099a2dd95SBruce Richardson * 65199a2dd95SBruce Richardson * @return 65299a2dd95SBruce Richardson * The number of operations actually dequeued (this is the number of entries 65399a2dd95SBruce Richardson * copied into the @p ops array). 65499a2dd95SBruce Richardson */ 65599a2dd95SBruce Richardson 65699a2dd95SBruce Richardson __rte_experimental 65799a2dd95SBruce Richardson static inline uint16_t 65899a2dd95SBruce Richardson rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id, 65999a2dd95SBruce Richardson struct rte_bbdev_dec_op **ops, uint16_t num_ops) 66099a2dd95SBruce Richardson { 66199a2dd95SBruce Richardson struct rte_bbdev *dev = &rte_bbdev_devices[dev_id]; 66299a2dd95SBruce Richardson struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id]; 66399a2dd95SBruce Richardson return dev->dequeue_dec_ops(q_data, ops, num_ops); 66499a2dd95SBruce Richardson } 66599a2dd95SBruce Richardson 66699a2dd95SBruce Richardson 66799a2dd95SBruce Richardson /** 66899a2dd95SBruce Richardson * Dequeue a burst of processed encode operations from a queue of the device. 66999a2dd95SBruce Richardson * This functions returns only the current contents of the queue, and does not 67099a2dd95SBruce Richardson * block until @ num_ops is available. 67199a2dd95SBruce Richardson * This function does not provide any error notification to avoid the 67299a2dd95SBruce Richardson * corresponding overhead. 67399a2dd95SBruce Richardson * 67499a2dd95SBruce Richardson * @param dev_id 67599a2dd95SBruce Richardson * The identifier of the device. 67699a2dd95SBruce Richardson * @param queue_id 67799a2dd95SBruce Richardson * The index of the queue. 67899a2dd95SBruce Richardson * @param ops 67999a2dd95SBruce Richardson * Pointer array where operations will be dequeued to. Must have at least 68099a2dd95SBruce Richardson * @p num_ops entries 68199a2dd95SBruce Richardson * @param num_ops 68299a2dd95SBruce Richardson * The maximum number of operations to dequeue. 68399a2dd95SBruce Richardson * 68499a2dd95SBruce Richardson * @return 68599a2dd95SBruce Richardson * The number of operations actually dequeued (this is the number of entries 68699a2dd95SBruce Richardson * copied into the @p ops array). 68799a2dd95SBruce Richardson */ 68899a2dd95SBruce Richardson __rte_experimental 68999a2dd95SBruce Richardson static inline uint16_t 69099a2dd95SBruce Richardson rte_bbdev_dequeue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id, 69199a2dd95SBruce Richardson struct rte_bbdev_enc_op **ops, uint16_t num_ops) 69299a2dd95SBruce Richardson { 69399a2dd95SBruce Richardson struct rte_bbdev *dev = &rte_bbdev_devices[dev_id]; 69499a2dd95SBruce Richardson struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id]; 69599a2dd95SBruce Richardson return dev->dequeue_ldpc_enc_ops(q_data, ops, num_ops); 69699a2dd95SBruce Richardson } 69799a2dd95SBruce Richardson 69899a2dd95SBruce Richardson /** 69999a2dd95SBruce Richardson * Dequeue a burst of processed decode operations from a queue of the device. 70099a2dd95SBruce Richardson * This functions returns only the current contents of the queue, and does not 70199a2dd95SBruce Richardson * block until @ num_ops is available. 70299a2dd95SBruce Richardson * This function does not provide any error notification to avoid the 70399a2dd95SBruce Richardson * corresponding overhead. 70499a2dd95SBruce Richardson * 70599a2dd95SBruce Richardson * @param dev_id 70699a2dd95SBruce Richardson * The identifier of the device. 70799a2dd95SBruce Richardson * @param queue_id 70899a2dd95SBruce Richardson * The index of the queue. 70999a2dd95SBruce Richardson * @param ops 71099a2dd95SBruce Richardson * Pointer array where operations will be dequeued to. Must have at least 71199a2dd95SBruce Richardson * @p num_ops entries 71299a2dd95SBruce Richardson * @param num_ops 71399a2dd95SBruce Richardson * The maximum number of operations to dequeue. 71499a2dd95SBruce Richardson * 71599a2dd95SBruce Richardson * @return 71699a2dd95SBruce Richardson * The number of operations actually dequeued (this is the number of entries 71799a2dd95SBruce Richardson * copied into the @p ops array). 71899a2dd95SBruce Richardson */ 71999a2dd95SBruce Richardson __rte_experimental 72099a2dd95SBruce Richardson static inline uint16_t 72199a2dd95SBruce Richardson rte_bbdev_dequeue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id, 72299a2dd95SBruce Richardson struct rte_bbdev_dec_op **ops, uint16_t num_ops) 72399a2dd95SBruce Richardson { 72499a2dd95SBruce Richardson struct rte_bbdev *dev = &rte_bbdev_devices[dev_id]; 72599a2dd95SBruce Richardson struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id]; 72699a2dd95SBruce Richardson return dev->dequeue_ldpc_dec_ops(q_data, ops, num_ops); 72799a2dd95SBruce Richardson } 72899a2dd95SBruce Richardson 72999a2dd95SBruce Richardson /** Definitions of device event types */ 73099a2dd95SBruce Richardson enum rte_bbdev_event_type { 73199a2dd95SBruce Richardson RTE_BBDEV_EVENT_UNKNOWN, /**< unknown event type */ 73299a2dd95SBruce Richardson RTE_BBDEV_EVENT_ERROR, /**< error interrupt event */ 73399a2dd95SBruce Richardson RTE_BBDEV_EVENT_DEQUEUE, /**< dequeue event */ 73499a2dd95SBruce Richardson RTE_BBDEV_EVENT_MAX /**< max value of this enum */ 73599a2dd95SBruce Richardson }; 73699a2dd95SBruce Richardson 73799a2dd95SBruce Richardson /** 73899a2dd95SBruce Richardson * Typedef for application callback function registered by application 73999a2dd95SBruce Richardson * software for notification of device events 74099a2dd95SBruce Richardson * 74199a2dd95SBruce Richardson * @param dev_id 74299a2dd95SBruce Richardson * Device identifier 74399a2dd95SBruce Richardson * @param event 74499a2dd95SBruce Richardson * Device event to register for notification of. 74599a2dd95SBruce Richardson * @param cb_arg 74699a2dd95SBruce Richardson * User specified parameter to be passed to user's callback function. 74799a2dd95SBruce Richardson * @param ret_param 74899a2dd95SBruce Richardson * To pass data back to user application. 74999a2dd95SBruce Richardson */ 75099a2dd95SBruce Richardson typedef void (*rte_bbdev_cb_fn)(uint16_t dev_id, 75199a2dd95SBruce Richardson enum rte_bbdev_event_type event, void *cb_arg, 75299a2dd95SBruce Richardson void *ret_param); 75399a2dd95SBruce Richardson 75499a2dd95SBruce Richardson /** 75599a2dd95SBruce Richardson * Register a callback function for specific device id. Multiple callbacks can 75699a2dd95SBruce Richardson * be added and will be called in the order they are added when an event is 75799a2dd95SBruce Richardson * triggered. Callbacks are called in a separate thread created by the DPDK EAL. 75899a2dd95SBruce Richardson * 75999a2dd95SBruce Richardson * @param dev_id 76099a2dd95SBruce Richardson * Device id. 76199a2dd95SBruce Richardson * @param event 76299a2dd95SBruce Richardson * The event that the callback will be registered for. 76399a2dd95SBruce Richardson * @param cb_fn 76499a2dd95SBruce Richardson * User supplied callback function to be called. 76599a2dd95SBruce Richardson * @param cb_arg 76699a2dd95SBruce Richardson * Pointer to parameter that will be passed to the callback. 76799a2dd95SBruce Richardson * 76899a2dd95SBruce Richardson * @return 76999a2dd95SBruce Richardson * Zero on success, negative value on failure. 77099a2dd95SBruce Richardson */ 77199a2dd95SBruce Richardson __rte_experimental 77299a2dd95SBruce Richardson int 77399a2dd95SBruce Richardson rte_bbdev_callback_register(uint16_t dev_id, enum rte_bbdev_event_type event, 77499a2dd95SBruce Richardson rte_bbdev_cb_fn cb_fn, void *cb_arg); 77599a2dd95SBruce Richardson 77699a2dd95SBruce Richardson /** 77799a2dd95SBruce Richardson * Unregister a callback function for specific device id. 77899a2dd95SBruce Richardson * 77999a2dd95SBruce Richardson * @param dev_id 78099a2dd95SBruce Richardson * The device identifier. 78199a2dd95SBruce Richardson * @param event 78299a2dd95SBruce Richardson * The event that the callback will be unregistered for. 78399a2dd95SBruce Richardson * @param cb_fn 78499a2dd95SBruce Richardson * User supplied callback function to be unregistered. 78599a2dd95SBruce Richardson * @param cb_arg 78699a2dd95SBruce Richardson * Pointer to the parameter supplied when registering the callback. 78799a2dd95SBruce Richardson * (void *)-1 means to remove all registered callbacks with the specified 78899a2dd95SBruce Richardson * function address. 78999a2dd95SBruce Richardson * 79099a2dd95SBruce Richardson * @return 79199a2dd95SBruce Richardson * - 0 on success 79299a2dd95SBruce Richardson * - EINVAL if invalid parameter pointer is provided 79399a2dd95SBruce Richardson * - EAGAIN if the provided callback pointer does not exist 79499a2dd95SBruce Richardson */ 79599a2dd95SBruce Richardson __rte_experimental 79699a2dd95SBruce Richardson int 79799a2dd95SBruce Richardson rte_bbdev_callback_unregister(uint16_t dev_id, enum rte_bbdev_event_type event, 79899a2dd95SBruce Richardson rte_bbdev_cb_fn cb_fn, void *cb_arg); 79999a2dd95SBruce Richardson 80099a2dd95SBruce Richardson /** 80199a2dd95SBruce Richardson * Enable a one-shot interrupt on the next operation enqueued to a particular 80299a2dd95SBruce Richardson * queue. The interrupt will be triggered when the operation is ready to be 80399a2dd95SBruce Richardson * dequeued. To handle the interrupt, an epoll file descriptor must be 80499a2dd95SBruce Richardson * registered using rte_bbdev_queue_intr_ctl(), and then an application 80599a2dd95SBruce Richardson * thread/lcore can wait for the interrupt using rte_epoll_wait(). 80699a2dd95SBruce Richardson * 80799a2dd95SBruce Richardson * @param dev_id 80899a2dd95SBruce Richardson * The device identifier. 80999a2dd95SBruce Richardson * @param queue_id 81099a2dd95SBruce Richardson * The index of the queue. 81199a2dd95SBruce Richardson * 81299a2dd95SBruce Richardson * @return 81399a2dd95SBruce Richardson * - 0 on success 81499a2dd95SBruce Richardson * - negative value on failure - as returned from PMD driver 81599a2dd95SBruce Richardson */ 81699a2dd95SBruce Richardson __rte_experimental 81799a2dd95SBruce Richardson int 81899a2dd95SBruce Richardson rte_bbdev_queue_intr_enable(uint16_t dev_id, uint16_t queue_id); 81999a2dd95SBruce Richardson 82099a2dd95SBruce Richardson /** 82199a2dd95SBruce Richardson * Disable a one-shot interrupt on the next operation enqueued to a particular 82299a2dd95SBruce Richardson * queue (if it has been enabled). 82399a2dd95SBruce Richardson * 82499a2dd95SBruce Richardson * @param dev_id 82599a2dd95SBruce Richardson * The device identifier. 82699a2dd95SBruce Richardson * @param queue_id 82799a2dd95SBruce Richardson * The index of the queue. 82899a2dd95SBruce Richardson * 82999a2dd95SBruce Richardson * @return 83099a2dd95SBruce Richardson * - 0 on success 83199a2dd95SBruce Richardson * - negative value on failure - as returned from PMD driver 83299a2dd95SBruce Richardson */ 83399a2dd95SBruce Richardson __rte_experimental 83499a2dd95SBruce Richardson int 83599a2dd95SBruce Richardson rte_bbdev_queue_intr_disable(uint16_t dev_id, uint16_t queue_id); 83699a2dd95SBruce Richardson 83799a2dd95SBruce Richardson /** 83899a2dd95SBruce Richardson * Control interface for per-queue interrupts. 83999a2dd95SBruce Richardson * 84099a2dd95SBruce Richardson * @param dev_id 84199a2dd95SBruce Richardson * The device identifier. 84299a2dd95SBruce Richardson * @param queue_id 84399a2dd95SBruce Richardson * The index of the queue. 84499a2dd95SBruce Richardson * @param epfd 84599a2dd95SBruce Richardson * Epoll file descriptor that will be associated with the interrupt source. 84699a2dd95SBruce Richardson * If the special value RTE_EPOLL_PER_THREAD is provided, a per thread epoll 84799a2dd95SBruce Richardson * file descriptor created by the EAL is used (RTE_EPOLL_PER_THREAD can also 84899a2dd95SBruce Richardson * be used when calling rte_epoll_wait()). 84999a2dd95SBruce Richardson * @param op 85099a2dd95SBruce Richardson * The operation be performed for the vector.RTE_INTR_EVENT_ADD or 85199a2dd95SBruce Richardson * RTE_INTR_EVENT_DEL. 85299a2dd95SBruce Richardson * @param data 85399a2dd95SBruce Richardson * User context, that will be returned in the epdata.data field of the 85499a2dd95SBruce Richardson * rte_epoll_event structure filled in by rte_epoll_wait(). 85599a2dd95SBruce Richardson * 85699a2dd95SBruce Richardson * @return 85799a2dd95SBruce Richardson * - 0 on success 85899a2dd95SBruce Richardson * - ENOTSUP if interrupts are not supported by the identified device 85999a2dd95SBruce Richardson * - negative value on failure - as returned from PMD driver 86099a2dd95SBruce Richardson */ 86199a2dd95SBruce Richardson __rte_experimental 86299a2dd95SBruce Richardson int 86399a2dd95SBruce Richardson rte_bbdev_queue_intr_ctl(uint16_t dev_id, uint16_t queue_id, int epfd, int op, 86499a2dd95SBruce Richardson void *data); 86599a2dd95SBruce Richardson 86699a2dd95SBruce Richardson #ifdef __cplusplus 86799a2dd95SBruce Richardson } 86899a2dd95SBruce Richardson #endif 86999a2dd95SBruce Richardson 87099a2dd95SBruce Richardson #endif /* _RTE_BBDEV_H_ */ 871