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