xref: /dpdk/lib/bbdev/rte_bbdev_pmd.h (revision b53d106d)
199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
299a2dd95SBruce Richardson  * Copyright(c) 2017 Intel Corporation
399a2dd95SBruce Richardson  */
499a2dd95SBruce Richardson 
599a2dd95SBruce Richardson #ifndef _RTE_BBDEV_PMD_H_
699a2dd95SBruce Richardson #define _RTE_BBDEV_PMD_H_
799a2dd95SBruce Richardson 
899a2dd95SBruce Richardson /**
999a2dd95SBruce Richardson  * @file rte_bbdev_pmd.h
1099a2dd95SBruce Richardson  *
1199a2dd95SBruce Richardson  * Wireless base band driver-facing APIs.
1299a2dd95SBruce Richardson  *
1399a2dd95SBruce Richardson  * This API provides the mechanism for device drivers to register with the
1499a2dd95SBruce Richardson  * bbdev interface. User applications should not use this API.
1599a2dd95SBruce Richardson  */
1699a2dd95SBruce Richardson 
1799a2dd95SBruce Richardson #ifdef __cplusplus
1899a2dd95SBruce Richardson extern "C" {
1999a2dd95SBruce Richardson #endif
2099a2dd95SBruce Richardson 
2199a2dd95SBruce Richardson #include <stdint.h>
2299a2dd95SBruce Richardson #include <rte_log.h>
2399a2dd95SBruce Richardson 
2499a2dd95SBruce Richardson #include "rte_bbdev.h"
2599a2dd95SBruce Richardson 
2699a2dd95SBruce Richardson /** Suggested value for SW based devices */
2799a2dd95SBruce Richardson #define RTE_BBDEV_DEFAULT_MAX_NB_QUEUES RTE_MAX_LCORE
2899a2dd95SBruce Richardson 
2999a2dd95SBruce Richardson /** Suggested value for SW based devices */
3099a2dd95SBruce Richardson #define RTE_BBDEV_QUEUE_SIZE_LIMIT 16384
3199a2dd95SBruce Richardson 
3299a2dd95SBruce Richardson /**
3399a2dd95SBruce Richardson  * @internal
3499a2dd95SBruce Richardson  * Allocates a new slot for a bbdev and returns the pointer to that slot
3599a2dd95SBruce Richardson  * for the driver to use.
3699a2dd95SBruce Richardson  *
3799a2dd95SBruce Richardson  * @param name
3899a2dd95SBruce Richardson  *   Unique identifier name for each bbdev device
3999a2dd95SBruce Richardson  *
4099a2dd95SBruce Richardson  * @return
4199a2dd95SBruce Richardson  *   - Slot in the rte_bbdev array for a new device;
4299a2dd95SBruce Richardson  */
4399a2dd95SBruce Richardson struct rte_bbdev *
4499a2dd95SBruce Richardson rte_bbdev_allocate(const char *name);
4599a2dd95SBruce Richardson 
4699a2dd95SBruce Richardson /**
4799a2dd95SBruce Richardson  * @internal
4899a2dd95SBruce Richardson  * Release the specified bbdev.
4999a2dd95SBruce Richardson  *
5099a2dd95SBruce Richardson  * @param bbdev
5199a2dd95SBruce Richardson  *   The *bbdev* pointer is the address of the *rte_bbdev* structure.
5299a2dd95SBruce Richardson  * @return
5399a2dd95SBruce Richardson  *   - 0 on success, negative on error
5499a2dd95SBruce Richardson  */
5599a2dd95SBruce Richardson int
5699a2dd95SBruce Richardson rte_bbdev_release(struct rte_bbdev *bbdev);
5799a2dd95SBruce Richardson 
5899a2dd95SBruce Richardson /**
5999a2dd95SBruce Richardson  * Get the device structure for a named device.
6099a2dd95SBruce Richardson  *
6199a2dd95SBruce Richardson  * @param name
6299a2dd95SBruce Richardson  *   Name of the device
6399a2dd95SBruce Richardson  *
6499a2dd95SBruce Richardson  * @return
6599a2dd95SBruce Richardson  *   - The device structure pointer, or
6699a2dd95SBruce Richardson  *   - NULL otherwise
6799a2dd95SBruce Richardson  *
6899a2dd95SBruce Richardson  */
6999a2dd95SBruce Richardson struct rte_bbdev *
7099a2dd95SBruce Richardson rte_bbdev_get_named_dev(const char *name);
7199a2dd95SBruce Richardson 
7299a2dd95SBruce Richardson /**
73*b53d106dSSean Morrissey  * Definitions of all functions exported by a driver through the generic
7499a2dd95SBruce Richardson  * structure of type *rte_bbdev_ops* supplied in the *rte_bbdev* structure
7599a2dd95SBruce Richardson  * associated with a device.
7699a2dd95SBruce Richardson  */
7799a2dd95SBruce Richardson 
7899a2dd95SBruce Richardson /** @internal Function used to configure device memory. */
7999a2dd95SBruce Richardson typedef int (*rte_bbdev_setup_queues_t)(struct rte_bbdev *dev,
8099a2dd95SBruce Richardson 		uint16_t num_queues, int socket_id);
8199a2dd95SBruce Richardson 
8299a2dd95SBruce Richardson /** @internal Function used to configure interrupts for a device. */
8399a2dd95SBruce Richardson typedef int (*rte_bbdev_intr_enable_t)(struct rte_bbdev *dev);
8499a2dd95SBruce Richardson 
8599a2dd95SBruce Richardson /** @internal Function to allocate and configure a device queue. */
8699a2dd95SBruce Richardson typedef int (*rte_bbdev_queue_setup_t)(struct rte_bbdev *dev,
8799a2dd95SBruce Richardson 		uint16_t queue_id, const struct rte_bbdev_queue_conf *conf);
8899a2dd95SBruce Richardson 
8999a2dd95SBruce Richardson /*
9099a2dd95SBruce Richardson  * @internal
9199a2dd95SBruce Richardson  * Function to release memory resources allocated for a device queue.
9299a2dd95SBruce Richardson  */
9399a2dd95SBruce Richardson typedef int (*rte_bbdev_queue_release_t)(struct rte_bbdev *dev,
9499a2dd95SBruce Richardson 		uint16_t queue_id);
9599a2dd95SBruce Richardson 
9699a2dd95SBruce Richardson /** @internal Function to start a configured device. */
9799a2dd95SBruce Richardson typedef int (*rte_bbdev_start_t)(struct rte_bbdev *dev);
9899a2dd95SBruce Richardson 
9999a2dd95SBruce Richardson /** @internal Function to stop a device. */
10099a2dd95SBruce Richardson typedef void (*rte_bbdev_stop_t)(struct rte_bbdev *dev);
10199a2dd95SBruce Richardson 
10299a2dd95SBruce Richardson /** @internal Function to close a device. */
10399a2dd95SBruce Richardson typedef int (*rte_bbdev_close_t)(struct rte_bbdev *dev);
10499a2dd95SBruce Richardson 
10599a2dd95SBruce Richardson /** @internal Function to start a device queue. */
10699a2dd95SBruce Richardson typedef int (*rte_bbdev_queue_start_t)(struct rte_bbdev *dev,
10799a2dd95SBruce Richardson 		uint16_t queue_id);
10899a2dd95SBruce Richardson 
10999a2dd95SBruce Richardson /** @internal Function to stop a device queue. */
11099a2dd95SBruce Richardson typedef int (*rte_bbdev_queue_stop_t)(struct rte_bbdev *dev, uint16_t queue_id);
11199a2dd95SBruce Richardson 
11299a2dd95SBruce Richardson /** @internal Function to read stats from a device. */
11399a2dd95SBruce Richardson typedef void (*rte_bbdev_stats_get_t)(struct rte_bbdev *dev,
11499a2dd95SBruce Richardson 		struct rte_bbdev_stats *stats);
11599a2dd95SBruce Richardson 
11699a2dd95SBruce Richardson /** @internal Function to reset stats on a device. */
11799a2dd95SBruce Richardson typedef void (*rte_bbdev_stats_reset_t)(struct rte_bbdev *dev);
11899a2dd95SBruce Richardson 
11999a2dd95SBruce Richardson /** @internal Function to retrieve specific information of a device. */
12099a2dd95SBruce Richardson typedef void (*rte_bbdev_info_get_t)(struct rte_bbdev *dev,
12199a2dd95SBruce Richardson 		struct rte_bbdev_driver_info *dev_info);
12299a2dd95SBruce Richardson 
12399a2dd95SBruce Richardson /*
12499a2dd95SBruce Richardson  * @internal
12599a2dd95SBruce Richardson  * Function to enable interrupt for next op on a queue of a device.
12699a2dd95SBruce Richardson  */
12799a2dd95SBruce Richardson typedef int (*rte_bbdev_queue_intr_enable_t)(struct rte_bbdev *dev,
12899a2dd95SBruce Richardson 				    uint16_t queue_id);
12999a2dd95SBruce Richardson 
13099a2dd95SBruce Richardson /*
13199a2dd95SBruce Richardson  * @internal
13299a2dd95SBruce Richardson  * Function to disable interrupt for next op on a queue of a device.
13399a2dd95SBruce Richardson  */
13499a2dd95SBruce Richardson typedef int (*rte_bbdev_queue_intr_disable_t)(struct rte_bbdev *dev,
13599a2dd95SBruce Richardson 				    uint16_t queue_id);
13699a2dd95SBruce Richardson 
13799a2dd95SBruce Richardson /**
13899a2dd95SBruce Richardson  * Operations implemented by drivers. Fields marked as "Required" must be
13999a2dd95SBruce Richardson  * provided by a driver for a device to have basic functionality. "Optional"
14099a2dd95SBruce Richardson  * fields are for non-vital operations
14199a2dd95SBruce Richardson  */
14299a2dd95SBruce Richardson struct rte_bbdev_ops {
14399a2dd95SBruce Richardson 	/** Allocate and configure device memory. Optional. */
14499a2dd95SBruce Richardson 	rte_bbdev_setup_queues_t setup_queues;
14599a2dd95SBruce Richardson 	/** Configure interrupts. Optional. */
14699a2dd95SBruce Richardson 	rte_bbdev_intr_enable_t intr_enable;
14799a2dd95SBruce Richardson 	/** Start device. Optional. */
14899a2dd95SBruce Richardson 	rte_bbdev_start_t start;
14999a2dd95SBruce Richardson 	/** Stop device. Optional. */
15099a2dd95SBruce Richardson 	rte_bbdev_stop_t stop;
15199a2dd95SBruce Richardson 	/** Close device. Optional. */
15299a2dd95SBruce Richardson 	rte_bbdev_close_t close;
15399a2dd95SBruce Richardson 
15499a2dd95SBruce Richardson 	/** Get device info. Required. */
15599a2dd95SBruce Richardson 	rte_bbdev_info_get_t info_get;
15699a2dd95SBruce Richardson 	/** Get device statistics. Optional. */
15799a2dd95SBruce Richardson 	rte_bbdev_stats_get_t stats_get;
15899a2dd95SBruce Richardson 	/** Reset device statistics. Optional. */
15999a2dd95SBruce Richardson 	rte_bbdev_stats_reset_t stats_reset;
16099a2dd95SBruce Richardson 
16199a2dd95SBruce Richardson 	/** Set up a device queue. Required. */
16299a2dd95SBruce Richardson 	rte_bbdev_queue_setup_t queue_setup;
16399a2dd95SBruce Richardson 	/** Release a queue. Required. */
16499a2dd95SBruce Richardson 	rte_bbdev_queue_release_t queue_release;
16599a2dd95SBruce Richardson 	/** Start a queue. Optional. */
16699a2dd95SBruce Richardson 	rte_bbdev_queue_start_t queue_start;
16799a2dd95SBruce Richardson 	/** Stop a queue pair. Optional. */
16899a2dd95SBruce Richardson 	rte_bbdev_queue_stop_t queue_stop;
16999a2dd95SBruce Richardson 
17099a2dd95SBruce Richardson 	/** Enable queue interrupt. Optional */
17199a2dd95SBruce Richardson 	rte_bbdev_queue_intr_enable_t queue_intr_enable;
17299a2dd95SBruce Richardson 	/** Disable queue interrupt. Optional */
17399a2dd95SBruce Richardson 	rte_bbdev_queue_intr_disable_t queue_intr_disable;
17499a2dd95SBruce Richardson };
17599a2dd95SBruce Richardson 
17699a2dd95SBruce Richardson /**
17799a2dd95SBruce Richardson  * Executes all the user application registered callbacks for the specific
17899a2dd95SBruce Richardson  * device and event type.
17999a2dd95SBruce Richardson  *
18099a2dd95SBruce Richardson  * @param dev
18199a2dd95SBruce Richardson  *   Pointer to the device structure.
18299a2dd95SBruce Richardson  * @param event
18399a2dd95SBruce Richardson  *   Event type.
18499a2dd95SBruce Richardson  * @param ret_param
18599a2dd95SBruce Richardson  *   To pass data back to user application.
18699a2dd95SBruce Richardson  */
18799a2dd95SBruce Richardson void
18899a2dd95SBruce Richardson rte_bbdev_pmd_callback_process(struct rte_bbdev *dev,
18999a2dd95SBruce Richardson 	enum rte_bbdev_event_type event, void *ret_param);
19099a2dd95SBruce Richardson 
19199a2dd95SBruce Richardson #ifdef __cplusplus
19299a2dd95SBruce Richardson }
19399a2dd95SBruce Richardson #endif
19499a2dd95SBruce Richardson 
19599a2dd95SBruce Richardson #endif /* _RTE_BBDEV_PMD_H_ */
196