LCOV - code coverage report
Current view: top level - lib/bbdev - rte_bbdev.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 72 0.0 %
Date: 2025-04-03 19:37:06 Functions: 0 12 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2017 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef _RTE_BBDEV_H_
       6                 :            : #define _RTE_BBDEV_H_
       7                 :            : 
       8                 :            : /**
       9                 :            :  * @file rte_bbdev.h
      10                 :            :  *
      11                 :            :  * Wireless base band device abstraction APIs.
      12                 :            :  *
      13                 :            :  * This API allows an application to discover, configure and use a device to
      14                 :            :  * process operations. An asynchronous API (enqueue, followed by later dequeue)
      15                 :            :  * is used for processing operations.
      16                 :            :  *
      17                 :            :  * The functions in this API are not thread-safe when called on the same
      18                 :            :  * target object (a device, or a queue on a device), with the exception that
      19                 :            :  * one thread can enqueue operations to a queue while another thread dequeues
      20                 :            :  * from the same queue.
      21                 :            :  */
      22                 :            : 
      23                 :            : #include <stdint.h>
      24                 :            : #include <stdbool.h>
      25                 :            : 
      26                 :            : #include <rte_compat.h>
      27                 :            : #include <rte_cpuflags.h>
      28                 :            : 
      29                 :            : #include "rte_bbdev_op.h"
      30                 :            : 
      31                 :            : #ifdef __cplusplus
      32                 :            : extern "C" {
      33                 :            : #endif
      34                 :            : 
      35                 :            : #include "rte_bbdev_trace_fp.h"
      36                 :            : 
      37                 :            : #ifndef RTE_BBDEV_MAX_DEVS
      38                 :            : #define RTE_BBDEV_MAX_DEVS 128  /**< Max number of devices */
      39                 :            : #endif
      40                 :            : 
      41                 :            : /*
      42                 :            :  * Maximum size to be used to manage the enum rte_bbdev_enqueue_status
      43                 :            :  * including padding for future enum insertion.
      44                 :            :  * The enum values must be explicitly kept smaller or equal to this padded maximum size.
      45                 :            :  */
      46                 :            : #define RTE_BBDEV_ENQ_STATUS_SIZE_MAX 6
      47                 :            : 
      48                 :            : /** Flags indicate current state of BBDEV device */
      49                 :            : enum rte_bbdev_state {
      50                 :            :         RTE_BBDEV_UNUSED,
      51                 :            :         RTE_BBDEV_INITIALIZED
      52                 :            : };
      53                 :            : 
      54                 :            : /**
      55                 :            :  * Get the total number of devices that have been successfully initialised.
      56                 :            :  *
      57                 :            :  * @return
      58                 :            :  *   The total number of usable devices.
      59                 :            :  */
      60                 :            : uint16_t
      61                 :            : rte_bbdev_count(void);
      62                 :            : 
      63                 :            : /**
      64                 :            :  * Check if a device is valid.
      65                 :            :  *
      66                 :            :  * @param dev_id
      67                 :            :  *   The identifier of the device.
      68                 :            :  *
      69                 :            :  * @return
      70                 :            :  *   true if device ID is valid and device is attached, false otherwise.
      71                 :            :  */
      72                 :            : bool
      73                 :            : rte_bbdev_is_valid(uint16_t dev_id);
      74                 :            : 
      75                 :            : /**
      76                 :            :  * Get the next enabled device.
      77                 :            :  *
      78                 :            :  * @param dev_id
      79                 :            :  *   The current device
      80                 :            :  *
      81                 :            :  * @return
      82                 :            :  *   - The next device, or
      83                 :            :  *   - RTE_BBDEV_MAX_DEVS if none found
      84                 :            :  */
      85                 :            : uint16_t
      86                 :            : rte_bbdev_find_next(uint16_t dev_id);
      87                 :            : 
      88                 :            : /** Iterate through all enabled devices */
      89                 :            : #define RTE_BBDEV_FOREACH(i) for (i = rte_bbdev_find_next(-1); \
      90                 :            :                 i < RTE_BBDEV_MAX_DEVS; \
      91                 :            :                 i = rte_bbdev_find_next(i))
      92                 :            : 
      93                 :            : /**
      94                 :            :  * Setup up device queues.
      95                 :            :  * This function must be called on a device before setting up the queues and
      96                 :            :  * starting the device. It can also be called when a device is in the stopped
      97                 :            :  * state. If any device queues have been configured their configuration will be
      98                 :            :  * cleared by a call to this function.
      99                 :            :  *
     100                 :            :  * @param dev_id
     101                 :            :  *   The identifier of the device.
     102                 :            :  * @param num_queues
     103                 :            :  *   Number of queues to configure on device.
     104                 :            :  * @param socket_id
     105                 :            :  *   ID of a socket which will be used to allocate memory.
     106                 :            :  *
     107                 :            :  * @return
     108                 :            :  *   - 0 on success
     109                 :            :  *   - -ENODEV if dev_id is invalid or the device is corrupted
     110                 :            :  *   - -EINVAL if num_queues is invalid, 0 or greater than maximum
     111                 :            :  *   - -EBUSY if the identified device has already started
     112                 :            :  *   - -ENOMEM if unable to allocate memory
     113                 :            :  */
     114                 :            : int
     115                 :            : rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id);
     116                 :            : 
     117                 :            : /**
     118                 :            :  * Enable interrupts.
     119                 :            :  * This function may be called before starting the device to enable the
     120                 :            :  * interrupts if they are available.
     121                 :            :  *
     122                 :            :  * @param dev_id
     123                 :            :  *   The identifier of the device.
     124                 :            :  *
     125                 :            :  * @return
     126                 :            :  *   - 0 on success
     127                 :            :  *   - -ENODEV if dev_id is invalid or the device is corrupted
     128                 :            :  *   - -EBUSY if the identified device has already started
     129                 :            :  *   - -ENOTSUP if the interrupts are not supported by the device
     130                 :            :  */
     131                 :            : int
     132                 :            : rte_bbdev_intr_enable(uint16_t dev_id);
     133                 :            : 
     134                 :            : /** Device queue configuration structure */
     135                 :            : struct rte_bbdev_queue_conf {
     136                 :            :         int socket;  /**< NUMA socket used for memory allocation */
     137                 :            :         uint32_t queue_size;  /**< Size of queue */
     138                 :            :         uint8_t priority;  /**< Queue priority */
     139                 :            :         bool deferred_start; /**< Do not start queue when device is started. */
     140                 :            :         enum rte_bbdev_op_type op_type; /**< Operation type */
     141                 :            : };
     142                 :            : 
     143                 :            : /**
     144                 :            :  * Configure a queue on a device.
     145                 :            :  * This function can be called after device configuration, and before starting.
     146                 :            :  * It can also be called when the device or the queue is in the stopped state.
     147                 :            :  *
     148                 :            :  * @param dev_id
     149                 :            :  *   The identifier of the device.
     150                 :            :  * @param queue_id
     151                 :            :  *   The index of the queue.
     152                 :            :  * @param conf
     153                 :            :  *   The queue configuration. If NULL, a default configuration will be used.
     154                 :            :  *
     155                 :            :  * @return
     156                 :            :  *   - 0 on success
     157                 :            :  *   - EINVAL if the identified queue size or priority are invalid
     158                 :            :  *   - EBUSY if the identified queue or its device have already started
     159                 :            :  */
     160                 :            : int
     161                 :            : rte_bbdev_queue_configure(uint16_t dev_id, uint16_t queue_id,
     162                 :            :                 const struct rte_bbdev_queue_conf *conf);
     163                 :            : 
     164                 :            : /**
     165                 :            :  * Start a device.
     166                 :            :  * This is the last step needed before enqueueing operations is possible.
     167                 :            :  *
     168                 :            :  * @param dev_id
     169                 :            :  *   The identifier of the device.
     170                 :            :  *
     171                 :            :  * @return
     172                 :            :  *   - 0 on success
     173                 :            :  *   - negative value on failure - as returned from PMD
     174                 :            :  */
     175                 :            : int
     176                 :            : rte_bbdev_start(uint16_t dev_id);
     177                 :            : 
     178                 :            : /**
     179                 :            :  * Stop a device.
     180                 :            :  * The device can be reconfigured, and restarted after being stopped.
     181                 :            :  *
     182                 :            :  * @param dev_id
     183                 :            :  *   The identifier of the device.
     184                 :            :  *
     185                 :            :  * @return
     186                 :            :  *   - 0 on success
     187                 :            :  */
     188                 :            : int
     189                 :            : rte_bbdev_stop(uint16_t dev_id);
     190                 :            : 
     191                 :            : /**
     192                 :            :  * Close a device.
     193                 :            :  * The device cannot be restarted without reconfiguration!
     194                 :            :  *
     195                 :            :  * @param dev_id
     196                 :            :  *   The identifier of the device.
     197                 :            :  *
     198                 :            :  * @return
     199                 :            :  *   - 0 on success
     200                 :            :  */
     201                 :            : int
     202                 :            : rte_bbdev_close(uint16_t dev_id);
     203                 :            : 
     204                 :            : /**
     205                 :            :  * Start a specified queue on a device.
     206                 :            :  * This is only needed if the queue has been stopped, or if the deferred_start
     207                 :            :  * flag has been set when configuring the queue.
     208                 :            :  *
     209                 :            :  * @param dev_id
     210                 :            :  *   The identifier of the device.
     211                 :            :  * @param queue_id
     212                 :            :  *   The index of the queue.
     213                 :            :  *
     214                 :            :  * @return
     215                 :            :  *   - 0 on success
     216                 :            :  *   - negative value on failure - as returned from PMD
     217                 :            :  */
     218                 :            : int
     219                 :            : rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id);
     220                 :            : 
     221                 :            : /**
     222                 :            :  * Stop a specified queue on a device, to allow re configuration.
     223                 :            :  *
     224                 :            :  * @param dev_id
     225                 :            :  *   The identifier of the device.
     226                 :            :  * @param queue_id
     227                 :            :  *   The index of the queue.
     228                 :            :  *
     229                 :            :  * @return
     230                 :            :  *   - 0 on success
     231                 :            :  *   - negative value on failure - as returned from PMD
     232                 :            :  */
     233                 :            : int
     234                 :            : rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id);
     235                 :            : 
     236                 :            : /**
     237                 :            :  * Flags to indicate the reason why a previous enqueue may not have
     238                 :            :  * consumed all requested operations.
     239                 :            :  * In case of multiple reasons the latter supersedes a previous one.
     240                 :            :  * The related macro RTE_BBDEV_ENQ_STATUS_SIZE_MAX can be used
     241                 :            :  * as an absolute maximum for notably sizing array
     242                 :            :  * while allowing for future enumeration insertion.
     243                 :            :  */
     244                 :            : enum rte_bbdev_enqueue_status {
     245                 :            :         RTE_BBDEV_ENQ_STATUS_NONE,             /**< Nothing to report. */
     246                 :            :         RTE_BBDEV_ENQ_STATUS_QUEUE_FULL,       /**< Not enough room in queue. */
     247                 :            :         RTE_BBDEV_ENQ_STATUS_RING_FULL,        /**< Not enough room in ring. */
     248                 :            :         RTE_BBDEV_ENQ_STATUS_INVALID_OP,       /**< Operation was rejected as invalid. */
     249                 :            :         /* Note: RTE_BBDEV_ENQ_STATUS_SIZE_MAX must be larger or equal to maximum enum value. */
     250                 :            : };
     251                 :            : 
     252                 :            : /**
     253                 :            :  * Flags to indicate the status of the device.
     254                 :            :  */
     255                 :            : enum rte_bbdev_device_status {
     256                 :            :         RTE_BBDEV_DEV_NOSTATUS,        /**< Nothing being reported. */
     257                 :            :         RTE_BBDEV_DEV_NOT_SUPPORTED,   /**< Device status is not supported on the PMD. */
     258                 :            :         RTE_BBDEV_DEV_RESET,           /**< Device in reset and un-configured state. */
     259                 :            :         RTE_BBDEV_DEV_CONFIGURED,      /**< Device is configured and ready to use. */
     260                 :            :         RTE_BBDEV_DEV_ACTIVE,          /**< Device is configured and VF is being used. */
     261                 :            :         RTE_BBDEV_DEV_FATAL_ERR,       /**< Device has hit a fatal uncorrectable error. */
     262                 :            :         RTE_BBDEV_DEV_RESTART_REQ,     /**< Device requires application to restart. */
     263                 :            :         RTE_BBDEV_DEV_RECONFIG_REQ,    /**< Device requires application to reconfigure queues. */
     264                 :            :         RTE_BBDEV_DEV_CORRECT_ERR,     /**< Warning of a correctable error event happened. */
     265                 :            : };
     266                 :            : 
     267                 :            : /** Device statistics. */
     268                 :            : struct rte_bbdev_stats {
     269                 :            :         uint64_t enqueued_count;  /**< Count of all operations enqueued */
     270                 :            :         uint64_t dequeued_count;  /**< Count of all operations dequeued */
     271                 :            :         /** Total error count on operations enqueued */
     272                 :            :         uint64_t enqueue_err_count;
     273                 :            :         /** Total error count on operations dequeued */
     274                 :            :         uint64_t dequeue_err_count;
     275                 :            :         /** Total warning count on operations enqueued. */
     276                 :            :         uint64_t enqueue_warn_count;
     277                 :            :         /** Total warning count on operations dequeued. */
     278                 :            :         uint64_t dequeue_warn_count;
     279                 :            :         /** Total enqueue status count based on *rte_bbdev_enqueue_status* enum. */
     280                 :            :         uint64_t enqueue_status_count[RTE_BBDEV_ENQ_STATUS_SIZE_MAX];
     281                 :            :         /** CPU cycles consumed by the (HW/SW) accelerator device to offload
     282                 :            :          *  the enqueue request to its internal queues.
     283                 :            :          *  - For a HW device this is the cycles consumed in MMIO write
     284                 :            :          *  - For a SW (vdev) device, this is the processing time of the
     285                 :            :          *     bbdev operation
     286                 :            :          */
     287                 :            :         uint64_t acc_offload_cycles;
     288                 :            :         /** Available number of enqueue batch on that queue. */
     289                 :            :         uint16_t enqueue_depth_avail;
     290                 :            : };
     291                 :            : 
     292                 :            : /**
     293                 :            :  * Retrieve the general I/O statistics of a device.
     294                 :            :  *
     295                 :            :  * @param dev_id
     296                 :            :  *   The identifier of the device.
     297                 :            :  * @param stats
     298                 :            :  *   Pointer to structure to where statistics will be copied. On error, this
     299                 :            :  *   location may or may not have been modified.
     300                 :            :  *
     301                 :            :  * @return
     302                 :            :  *   - 0 on success
     303                 :            :  *   - EINVAL if invalid parameter pointer is provided
     304                 :            :  */
     305                 :            : int
     306                 :            : rte_bbdev_stats_get(uint16_t dev_id, struct rte_bbdev_stats *stats);
     307                 :            : 
     308                 :            : /**
     309                 :            :  * Reset the statistics of a device.
     310                 :            :  *
     311                 :            :  * @param dev_id
     312                 :            :  *   The identifier of the device.
     313                 :            :  * @return
     314                 :            :  *   - 0 on success
     315                 :            :  */
     316                 :            : int
     317                 :            : rte_bbdev_stats_reset(uint16_t dev_id);
     318                 :            : 
     319                 :            : /** Device information supplied by the device's driver */
     320                 :            : 
     321                 :            : /* Structure rte_bbdev_driver_info 8< */
     322                 :            : struct rte_bbdev_driver_info {
     323                 :            :         /** Driver name */
     324                 :            :         const char *driver_name;
     325                 :            : 
     326                 :            :         /** Maximum number of queues supported by the device */
     327                 :            :         unsigned int max_num_queues;
     328                 :            :         /** Maximum number of queues supported per operation type */
     329                 :            :         unsigned int num_queues[RTE_BBDEV_OP_TYPE_SIZE_MAX];
     330                 :            :         /** Priority level supported per operation type */
     331                 :            :         unsigned int queue_priority[RTE_BBDEV_OP_TYPE_SIZE_MAX];
     332                 :            :         /** Queue size limit (queue size must also be power of 2) */
     333                 :            :         uint32_t queue_size_lim;
     334                 :            :         /** Set if device off-loads operation to hardware  */
     335                 :            :         bool hardware_accelerated;
     336                 :            :         /** Max value supported by queue priority for DL */
     337                 :            :         uint8_t max_dl_queue_priority;
     338                 :            :         /** Max value supported by queue priority for UL */
     339                 :            :         uint8_t max_ul_queue_priority;
     340                 :            :         /** Set if device supports per-queue interrupts */
     341                 :            :         bool queue_intr_supported;
     342                 :            :         /** Device Status */
     343                 :            :         enum rte_bbdev_device_status device_status;
     344                 :            :         /** HARQ memory available in kB */
     345                 :            :         uint32_t harq_buffer_size;
     346                 :            :         /** Minimum alignment of buffers, in bytes */
     347                 :            :         uint16_t min_alignment;
     348                 :            :         /** Byte endianness (RTE_BIG_ENDIAN/RTE_LITTLE_ENDIAN) supported
     349                 :            :          *  for input/output data
     350                 :            :          */
     351                 :            :         uint8_t data_endianness;
     352                 :            :         /** Default queue configuration used if none is supplied  */
     353                 :            :         struct rte_bbdev_queue_conf default_queue_conf;
     354                 :            :         /** Device operation capabilities */
     355                 :            :         const struct rte_bbdev_op_cap *capabilities;
     356                 :            :         /** Device cpu_flag requirements */
     357                 :            :         const enum rte_cpu_flag_t *cpu_flag_reqs;
     358                 :            :         /** FFT windowing width for 2048 FFT - size defined in capability. */
     359                 :            :         uint16_t *fft_window_width;
     360                 :            : };
     361                 :            : /* >8 End of structure rte_bbdev_driver_info. */
     362                 :            : 
     363                 :            : /** Macro used at end of bbdev PMD list */
     364                 :            : #define RTE_BBDEV_END_OF_CAPABILITIES_LIST() \
     365                 :            :         { RTE_BBDEV_OP_NONE }
     366                 :            : 
     367                 :            : /**
     368                 :            :  * Device information structure used by an application to discover a devices
     369                 :            :  * capabilities and current configuration
     370                 :            :  */
     371                 :            : 
     372                 :            : /* Structure rte_bbdev_info 8< */
     373                 :            : struct rte_bbdev_info {
     374                 :            :         int socket_id;  /**< NUMA socket that device is on */
     375                 :            :         const char *dev_name;  /**< Unique device name */
     376                 :            :         const struct rte_device *device; /**< Device Information */
     377                 :            :         uint16_t num_queues;  /**< Number of queues currently configured */
     378                 :            :         bool started;  /**< Set if device is currently started */
     379                 :            :         struct rte_bbdev_driver_info drv;  /**< Info from device driver */
     380                 :            : };
     381                 :            : /* >8 End of structure rte_bbdev_info. */
     382                 :            : 
     383                 :            : /**
     384                 :            :  * Retrieve information about a device.
     385                 :            :  *
     386                 :            :  * @param dev_id
     387                 :            :  *   The identifier of the device.
     388                 :            :  * @param dev_info
     389                 :            :  *   Pointer to structure to where information will be copied. On error, this
     390                 :            :  *   location may or may not have been modified.
     391                 :            :  *
     392                 :            :  * @return
     393                 :            :  *   - 0 on success
     394                 :            :  *   - EINVAL if invalid parameter pointer is provided
     395                 :            :  */
     396                 :            : int
     397                 :            : rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info);
     398                 :            : 
     399                 :            : /** Queue information */
     400                 :            : struct rte_bbdev_queue_info {
     401                 :            :         /** Current device configuration */
     402                 :            :         struct rte_bbdev_queue_conf conf;
     403                 :            :         /** Set if queue is currently started */
     404                 :            :         bool started;
     405                 :            : };
     406                 :            : 
     407                 :            : /**
     408                 :            :  * Retrieve information about a specific queue on a device.
     409                 :            :  *
     410                 :            :  * @param dev_id
     411                 :            :  *   The identifier of the device.
     412                 :            :  * @param queue_id
     413                 :            :  *   The index of the queue.
     414                 :            :  * @param queue_info
     415                 :            :  *   Pointer to structure to where information will be copied. On error, this
     416                 :            :  *   location may or may not have been modified.
     417                 :            :  *
     418                 :            :  * @return
     419                 :            :  *   - 0 on success
     420                 :            :  *   - EINVAL if invalid parameter pointer is provided
     421                 :            :  */
     422                 :            : int
     423                 :            : rte_bbdev_queue_info_get(uint16_t dev_id, uint16_t queue_id,
     424                 :            :                 struct rte_bbdev_queue_info *queue_info);
     425                 :            : 
     426                 :            : /** @internal The data structure associated with each queue of a device. */
     427                 :            : struct rte_bbdev_queue_data {
     428                 :            :         void *queue_private;  /**< Driver-specific per-queue data */
     429                 :            :         struct rte_bbdev_queue_conf conf;  /**< Current configuration */
     430                 :            :         struct rte_bbdev_stats queue_stats;  /**< Queue statistics */
     431                 :            :         enum rte_bbdev_enqueue_status enqueue_status; /**< Enqueue status when op is rejected */
     432                 :            :         bool started;  /**< Queue state */
     433                 :            : };
     434                 :            : 
     435                 :            : /** @internal Enqueue encode operations for processing on queue of a device. */
     436                 :            : typedef uint16_t (*rte_bbdev_enqueue_enc_ops_t)(
     437                 :            :                 struct rte_bbdev_queue_data *q_data,
     438                 :            :                 struct rte_bbdev_enc_op **ops,
     439                 :            :                 uint16_t num);
     440                 :            : 
     441                 :            : /** @internal Enqueue decode operations for processing on queue of a device. */
     442                 :            : typedef uint16_t (*rte_bbdev_enqueue_dec_ops_t)(
     443                 :            :                 struct rte_bbdev_queue_data *q_data,
     444                 :            :                 struct rte_bbdev_dec_op **ops,
     445                 :            :                 uint16_t num);
     446                 :            : 
     447                 :            : /** @internal Enqueue FFT operations for processing on queue of a device. */
     448                 :            : typedef uint16_t (*rte_bbdev_enqueue_fft_ops_t)(
     449                 :            :                 struct rte_bbdev_queue_data *q_data,
     450                 :            :                 struct rte_bbdev_fft_op **ops,
     451                 :            :                 uint16_t num);
     452                 :            : 
     453                 :            : /** @internal Enqueue MLD-TS operations for processing on queue of a device. */
     454                 :            : typedef uint16_t (*rte_bbdev_enqueue_mldts_ops_t)(
     455                 :            :                 struct rte_bbdev_queue_data *q_data,
     456                 :            :                 struct rte_bbdev_mldts_op **ops,
     457                 :            :                 uint16_t num);
     458                 :            : 
     459                 :            : /** @internal Dequeue encode operations from a queue of a device. */
     460                 :            : typedef uint16_t (*rte_bbdev_dequeue_enc_ops_t)(
     461                 :            :                 struct rte_bbdev_queue_data *q_data,
     462                 :            :                 struct rte_bbdev_enc_op **ops, uint16_t num);
     463                 :            : 
     464                 :            : /** @internal Dequeue decode operations from a queue of a device. */
     465                 :            : typedef uint16_t (*rte_bbdev_dequeue_dec_ops_t)(
     466                 :            :                 struct rte_bbdev_queue_data *q_data,
     467                 :            :                 struct rte_bbdev_dec_op **ops, uint16_t num);
     468                 :            : 
     469                 :            : /** @internal Dequeue FFT operations from a queue of a device. */
     470                 :            : typedef uint16_t (*rte_bbdev_dequeue_fft_ops_t)(
     471                 :            :                 struct rte_bbdev_queue_data *q_data,
     472                 :            :                 struct rte_bbdev_fft_op **ops, uint16_t num);
     473                 :            : 
     474                 :            : /** @internal Dequeue MLDTS operations from a queue of a device. */
     475                 :            : typedef uint16_t (*rte_bbdev_dequeue_mldts_ops_t)(
     476                 :            :                 struct rte_bbdev_queue_data *q_data,
     477                 :            :                 struct rte_bbdev_mldts_op **ops, uint16_t num);
     478                 :            : 
     479                 :            : #define RTE_BBDEV_NAME_MAX_LEN  64  /**< Max length of device name */
     480                 :            : 
     481                 :            : /**
     482                 :            :  * @internal The data associated with a device, with no function pointers.
     483                 :            :  * This structure is safe to place in shared memory to be common among
     484                 :            :  * different processes in a multi-process configuration. Drivers can access
     485                 :            :  * these fields, but should never write to them!
     486                 :            :  */
     487                 :            : struct rte_bbdev_data {
     488                 :            :         char name[RTE_BBDEV_NAME_MAX_LEN]; /**< Unique identifier name */
     489                 :            :         void *dev_private;  /**< Driver-specific private data */
     490                 :            :         uint16_t num_queues;  /**< Number of currently configured queues */
     491                 :            :         struct rte_bbdev_queue_data *queues;  /**< Queue structures */
     492                 :            :         uint16_t dev_id;  /**< Device ID */
     493                 :            :         int socket_id;  /**< NUMA socket that device is on */
     494                 :            :         bool started;  /**< Device run-time state */
     495                 :            :         RTE_ATOMIC(uint16_t) process_cnt;  /** Counter of processes using the device */
     496                 :            : };
     497                 :            : 
     498                 :            : /* Forward declarations */
     499                 :            : struct rte_bbdev_ops;
     500                 :            : struct rte_bbdev_callback;
     501                 :            : struct rte_intr_handle;
     502                 :            : 
     503                 :            : /** Structure to keep track of registered callbacks */
     504                 :            : RTE_TAILQ_HEAD(rte_bbdev_cb_list, rte_bbdev_callback);
     505                 :            : 
     506                 :            : /**
     507                 :            :  * @internal The data structure associated with a device. Drivers can access
     508                 :            :  * these fields, but should only write to the *_ops fields.
     509                 :            :  */
     510                 :            : struct __rte_cache_aligned rte_bbdev {
     511                 :            :         /** Enqueue encode function */
     512                 :            :         rte_bbdev_enqueue_enc_ops_t enqueue_enc_ops;
     513                 :            :         /** Enqueue decode function */
     514                 :            :         rte_bbdev_enqueue_dec_ops_t enqueue_dec_ops;
     515                 :            :         /** Dequeue encode function */
     516                 :            :         rte_bbdev_dequeue_enc_ops_t dequeue_enc_ops;
     517                 :            :         /** Dequeue decode function */
     518                 :            :         rte_bbdev_dequeue_dec_ops_t dequeue_dec_ops;
     519                 :            :         /** Enqueue encode function */
     520                 :            :         rte_bbdev_enqueue_enc_ops_t enqueue_ldpc_enc_ops;
     521                 :            :         /** Enqueue decode function */
     522                 :            :         rte_bbdev_enqueue_dec_ops_t enqueue_ldpc_dec_ops;
     523                 :            :         /** Dequeue encode function */
     524                 :            :         rte_bbdev_dequeue_enc_ops_t dequeue_ldpc_enc_ops;
     525                 :            :         /** Dequeue decode function */
     526                 :            :         rte_bbdev_dequeue_dec_ops_t dequeue_ldpc_dec_ops;
     527                 :            :         /** Enqueue FFT function */
     528                 :            :         rte_bbdev_enqueue_fft_ops_t enqueue_fft_ops;
     529                 :            :         /** Dequeue FFT function */
     530                 :            :         rte_bbdev_dequeue_fft_ops_t dequeue_fft_ops;
     531                 :            :         const struct rte_bbdev_ops *dev_ops;  /**< Functions exported by PMD */
     532                 :            :         struct rte_bbdev_data *data;  /**< Pointer to device data */
     533                 :            :         enum rte_bbdev_state state;  /**< If device is currently used or not */
     534                 :            :         struct rte_device *device; /**< Backing device */
     535                 :            :         /** User application callback for interrupts if present */
     536                 :            :         struct rte_bbdev_cb_list list_cbs;
     537                 :            :         struct rte_intr_handle *intr_handle; /**< Device interrupt handle */
     538                 :            :         /** Enqueue MLD-TS function */
     539                 :            :         rte_bbdev_enqueue_mldts_ops_t enqueue_mldts_ops;
     540                 :            :         /** Dequeue MLD-TS function */
     541                 :            :         rte_bbdev_dequeue_mldts_ops_t dequeue_mldts_ops;
     542                 :            : };
     543                 :            : 
     544                 :            : /** @internal array of all devices */
     545                 :            : extern struct rte_bbdev rte_bbdev_devices[];
     546                 :            : 
     547                 :            : /**
     548                 :            :  * Enqueue a burst of processed encode operations to a queue of the device.
     549                 :            :  * This functions only enqueues as many operations as currently possible and
     550                 :            :  * does not block until @p num_ops entries in the queue are available.
     551                 :            :  * This function does not provide any error notification to avoid the
     552                 :            :  * corresponding overhead.
     553                 :            :  *
     554                 :            :  * @param dev_id
     555                 :            :  *   The identifier of the device.
     556                 :            :  * @param queue_id
     557                 :            :  *   The index of the queue.
     558                 :            :  * @param ops
     559                 :            :  *   Pointer array containing operations to be enqueued Must have at least
     560                 :            :  *   @p num_ops entries
     561                 :            :  * @param num_ops
     562                 :            :  *   The maximum number of operations to enqueue.
     563                 :            :  *
     564                 :            :  * @return
     565                 :            :  *   The number of operations actually enqueued (this is the number of processed
     566                 :            :  *   entries in the @p ops array).
     567                 :            :  */
     568                 :            : static inline uint16_t
     569                 :          0 : rte_bbdev_enqueue_enc_ops(uint16_t dev_id, uint16_t queue_id,
     570                 :            :                 struct rte_bbdev_enc_op **ops, uint16_t num_ops)
     571                 :            : {
     572                 :          0 :         struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
     573                 :          0 :         struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
     574                 :          0 :         rte_bbdev_trace_enqueue(dev_id, queue_id, (void **)ops, num_ops,
     575                 :            :                         rte_bbdev_op_type_str(RTE_BBDEV_OP_TURBO_DEC));
     576                 :          0 :         return dev->enqueue_enc_ops(q_data, ops, num_ops);
     577                 :            : }
     578                 :            : 
     579                 :            : /**
     580                 :            :  * Enqueue a burst of processed decode operations to a queue of the device.
     581                 :            :  * This functions only enqueues as many operations as currently possible and
     582                 :            :  * does not block until @p num_ops entries in the queue are available.
     583                 :            :  * This function does not provide any error notification to avoid the
     584                 :            :  * corresponding overhead.
     585                 :            :  *
     586                 :            :  * @param dev_id
     587                 :            :  *   The identifier of the device.
     588                 :            :  * @param queue_id
     589                 :            :  *   The index of the queue.
     590                 :            :  * @param ops
     591                 :            :  *   Pointer array containing operations to be enqueued Must have at least
     592                 :            :  *   @p num_ops entries
     593                 :            :  * @param num_ops
     594                 :            :  *   The maximum number of operations to enqueue.
     595                 :            :  *
     596                 :            :  * @return
     597                 :            :  *   The number of operations actually enqueued (this is the number of processed
     598                 :            :  *   entries in the @p ops array).
     599                 :            :  */
     600                 :            : static inline uint16_t
     601                 :          0 : rte_bbdev_enqueue_dec_ops(uint16_t dev_id, uint16_t queue_id,
     602                 :            :                 struct rte_bbdev_dec_op **ops, uint16_t num_ops)
     603                 :            : {
     604                 :          0 :         struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
     605                 :          0 :         struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
     606                 :          0 :         rte_bbdev_trace_enqueue(dev_id, queue_id, (void **)ops, num_ops,
     607                 :            :                         rte_bbdev_op_type_str(RTE_BBDEV_OP_TURBO_ENC));
     608                 :          0 :         return dev->enqueue_dec_ops(q_data, ops, num_ops);
     609                 :            : }
     610                 :            : 
     611                 :            : /**
     612                 :            :  * Enqueue a burst of processed encode operations to a queue of the device.
     613                 :            :  * This functions only enqueues as many operations as currently possible and
     614                 :            :  * does not block until @p num_ops entries in the queue are available.
     615                 :            :  * This function does not provide any error notification to avoid the
     616                 :            :  * corresponding overhead.
     617                 :            :  *
     618                 :            :  * @param dev_id
     619                 :            :  *   The identifier of the device.
     620                 :            :  * @param queue_id
     621                 :            :  *   The index of the queue.
     622                 :            :  * @param ops
     623                 :            :  *   Pointer array containing operations to be enqueued Must have at least
     624                 :            :  *   @p num_ops entries
     625                 :            :  * @param num_ops
     626                 :            :  *   The maximum number of operations to enqueue.
     627                 :            :  *
     628                 :            :  * @return
     629                 :            :  *   The number of operations actually enqueued (this is the number of processed
     630                 :            :  *   entries in the @p ops array).
     631                 :            :  */
     632                 :            : static inline uint16_t
     633                 :          0 : rte_bbdev_enqueue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,
     634                 :            :                 struct rte_bbdev_enc_op **ops, uint16_t num_ops)
     635                 :            : {
     636                 :          0 :         struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
     637                 :          0 :         struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
     638                 :          0 :         rte_bbdev_trace_enqueue(dev_id, queue_id, (void **)ops, num_ops,
     639                 :            :                         rte_bbdev_op_type_str(RTE_BBDEV_OP_LDPC_ENC));
     640                 :          0 :         return dev->enqueue_ldpc_enc_ops(q_data, ops, num_ops);
     641                 :            : }
     642                 :            : 
     643                 :            : /**
     644                 :            :  * Enqueue a burst of processed decode operations to a queue of the device.
     645                 :            :  * This functions only enqueues as many operations as currently possible and
     646                 :            :  * does not block until @p num_ops entries in the queue are available.
     647                 :            :  * This function does not provide any error notification to avoid the
     648                 :            :  * corresponding overhead.
     649                 :            :  *
     650                 :            :  * @param dev_id
     651                 :            :  *   The identifier of the device.
     652                 :            :  * @param queue_id
     653                 :            :  *   The index of the queue.
     654                 :            :  * @param ops
     655                 :            :  *   Pointer array containing operations to be enqueued Must have at least
     656                 :            :  *   @p num_ops entries
     657                 :            :  * @param num_ops
     658                 :            :  *   The maximum number of operations to enqueue.
     659                 :            :  *
     660                 :            :  * @return
     661                 :            :  *   The number of operations actually enqueued (this is the number of processed
     662                 :            :  *   entries in the @p ops array).
     663                 :            :  */
     664                 :            : static inline uint16_t
     665                 :          0 : rte_bbdev_enqueue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id,
     666                 :            :                 struct rte_bbdev_dec_op **ops, uint16_t num_ops)
     667                 :            : {
     668                 :          0 :         struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
     669                 :          0 :         struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
     670                 :          0 :         rte_bbdev_trace_enqueue(dev_id, queue_id, (void **)ops, num_ops,
     671                 :            :                         rte_bbdev_op_type_str(RTE_BBDEV_OP_LDPC_DEC));
     672                 :          0 :         return dev->enqueue_ldpc_dec_ops(q_data, ops, num_ops);
     673                 :            : }
     674                 :            : 
     675                 :            : /**
     676                 :            :  * Enqueue a burst of FFT operations to a queue of the device.
     677                 :            :  * This functions only enqueues as many operations as currently possible and
     678                 :            :  * does not block until @p num_ops entries in the queue are available.
     679                 :            :  * This function does not provide any error notification to avoid the
     680                 :            :  * corresponding overhead.
     681                 :            :  *
     682                 :            :  * @param dev_id
     683                 :            :  *   The identifier of the device.
     684                 :            :  * @param queue_id
     685                 :            :  *   The index of the queue.
     686                 :            :  * @param ops
     687                 :            :  *   Pointer array containing operations to be enqueued.
     688                 :            :  *   Must have at least @p num_ops entries.
     689                 :            :  * @param num_ops
     690                 :            :  *   The maximum number of operations to enqueue.
     691                 :            :  *
     692                 :            :  * @return
     693                 :            :  *   The number of operations actually enqueued.
     694                 :            :  *   (This is the number of processed entries in the @p ops array.)
     695                 :            :  */
     696                 :            : static inline uint16_t
     697                 :          0 : rte_bbdev_enqueue_fft_ops(uint16_t dev_id, uint16_t queue_id,
     698                 :            :                 struct rte_bbdev_fft_op **ops, uint16_t num_ops)
     699                 :            : {
     700                 :          0 :         struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
     701                 :          0 :         struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
     702                 :          0 :         rte_bbdev_trace_enqueue(dev_id, queue_id, (void **)ops, num_ops,
     703                 :            :                         rte_bbdev_op_type_str(RTE_BBDEV_OP_FFT));
     704                 :          0 :         return dev->enqueue_fft_ops(q_data, ops, num_ops);
     705                 :            : }
     706                 :            : 
     707                 :            : /**
     708                 :            :  * Enqueue a burst of MLDTS operations to a queue of the device.
     709                 :            :  * This functions only enqueues as many operations as currently possible and
     710                 :            :  * does not block until @p num_ops entries in the queue are available.
     711                 :            :  * This function does not provide any error notification to avoid the
     712                 :            :  * corresponding overhead.
     713                 :            :  *
     714                 :            :  * @param dev_id
     715                 :            :  *   The identifier of the device.
     716                 :            :  * @param queue_id
     717                 :            :  *   The index of the queue.
     718                 :            :  * @param ops
     719                 :            :  *   Pointer array containing operations to be enqueued Must have at least
     720                 :            :  *   @p num_ops entries
     721                 :            :  * @param num_ops
     722                 :            :  *   The maximum number of operations to enqueue.
     723                 :            :  *
     724                 :            :  * @return
     725                 :            :  *   The number of operations actually enqueued (this is the number of processed
     726                 :            :  *   entries in the @p ops array).
     727                 :            :  */
     728                 :            : static inline uint16_t
     729                 :          0 : rte_bbdev_enqueue_mldts_ops(uint16_t dev_id, uint16_t queue_id,
     730                 :            :                 struct rte_bbdev_mldts_op **ops, uint16_t num_ops)
     731                 :            : {
     732                 :          0 :         struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
     733                 :          0 :         struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
     734                 :          0 :         rte_bbdev_trace_enqueue(dev_id, queue_id, (void **)ops, num_ops,
     735                 :            :                         rte_bbdev_op_type_str(RTE_BBDEV_OP_MLDTS));
     736                 :          0 :         return dev->enqueue_mldts_ops(q_data, ops, num_ops);
     737                 :            : }
     738                 :            : 
     739                 :            : /**
     740                 :            :  * Dequeue a burst of processed encode operations from a queue of the device.
     741                 :            :  * This functions returns only the current contents of the queue,
     742                 :            :  * and does not block until @ num_ops is available.
     743                 :            :  * This function does not provide any error notification to avoid the
     744                 :            :  * corresponding overhead.
     745                 :            :  *
     746                 :            :  * @param dev_id
     747                 :            :  *   The identifier of the device.
     748                 :            :  * @param queue_id
     749                 :            :  *   The index of the queue.
     750                 :            :  * @param ops
     751                 :            :  *   Pointer array where operations will be dequeued to.
     752                 :            :  *   Must have at least @p num_ops entries, i.e.
     753                 :            :  *   a pointer to a table of void * pointers (ops) that will be filled.
     754                 :            :  * @param num_ops
     755                 :            :  *   The maximum number of operations to dequeue.
     756                 :            :  *
     757                 :            :  * @return
     758                 :            :  *   The number of operations actually dequeued.
     759                 :            :  *   (This is the number of entries copied into the @p ops array.)
     760                 :            :  */
     761                 :            : static inline uint16_t
     762                 :          0 : rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id,
     763                 :            :                 struct rte_bbdev_enc_op **ops, uint16_t num_ops)
     764                 :            : {
     765                 :          0 :         struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
     766                 :          0 :         struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
     767                 :          0 :         uint16_t num_ops_dequeued = dev->dequeue_enc_ops(q_data, ops, num_ops);
     768                 :          0 :         if (num_ops_dequeued > 0)
     769                 :          0 :                 rte_bbdev_trace_dequeue(dev_id, queue_id, (void **)ops, num_ops,
     770                 :            :                                 num_ops_dequeued, rte_bbdev_op_type_str(RTE_BBDEV_OP_TURBO_ENC));
     771                 :          0 :         return num_ops_dequeued;
     772                 :            : }
     773                 :            : 
     774                 :            : /**
     775                 :            :  * Dequeue a burst of processed decode operations from a queue of the device.
     776                 :            :  * This functions returns only the current contents of the queue, and does not
     777                 :            :  * block until @ num_ops is available.
     778                 :            :  * This function does not provide any error notification to avoid the
     779                 :            :  * corresponding overhead.
     780                 :            :  *
     781                 :            :  * @param dev_id
     782                 :            :  *   The identifier of the device.
     783                 :            :  * @param queue_id
     784                 :            :  *   The index of the queue.
     785                 :            :  * @param ops
     786                 :            :  *   Pointer array where operations will be dequeued to. Must have at least
     787                 :            :  *   @p num_ops entries
     788                 :            :  *   ie. A pointer to a table of void * pointers (ops) that will be filled.
     789                 :            :  * @param num_ops
     790                 :            :  *   The maximum number of operations to dequeue.
     791                 :            :  *
     792                 :            :  * @return
     793                 :            :  *   The number of operations actually dequeued (this is the number of entries
     794                 :            :  *   copied into the @p ops array).
     795                 :            :  */
     796                 :            : 
     797                 :            : static inline uint16_t
     798                 :          0 : rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id,
     799                 :            :                 struct rte_bbdev_dec_op **ops, uint16_t num_ops)
     800                 :            : {
     801                 :          0 :         struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
     802                 :          0 :         struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
     803                 :          0 :         uint16_t num_ops_dequeued = dev->dequeue_dec_ops(q_data, ops, num_ops);
     804                 :          0 :         if (num_ops_dequeued > 0)
     805                 :          0 :                 rte_bbdev_trace_dequeue(dev_id, queue_id, (void **)ops, num_ops,
     806                 :            :                                 num_ops_dequeued, rte_bbdev_op_type_str(RTE_BBDEV_OP_TURBO_DEC));
     807                 :          0 :         return num_ops_dequeued;
     808                 :            : }
     809                 :            : 
     810                 :            : 
     811                 :            : /**
     812                 :            :  * Dequeue a burst of processed encode operations from a queue of the device.
     813                 :            :  * This functions returns only the current contents of the queue, and does not
     814                 :            :  * block until @ num_ops is available.
     815                 :            :  * This function does not provide any error notification to avoid the
     816                 :            :  * corresponding overhead.
     817                 :            :  *
     818                 :            :  * @param dev_id
     819                 :            :  *   The identifier of the device.
     820                 :            :  * @param queue_id
     821                 :            :  *   The index of the queue.
     822                 :            :  * @param ops
     823                 :            :  *   Pointer array where operations will be dequeued to. Must have at least
     824                 :            :  *   @p num_ops entries
     825                 :            :  * @param num_ops
     826                 :            :  *   The maximum number of operations to dequeue.
     827                 :            :  *
     828                 :            :  * @return
     829                 :            :  *   The number of operations actually dequeued (this is the number of entries
     830                 :            :  *   copied into the @p ops array).
     831                 :            :  */
     832                 :            : static inline uint16_t
     833                 :          0 : rte_bbdev_dequeue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,
     834                 :            :                 struct rte_bbdev_enc_op **ops, uint16_t num_ops)
     835                 :            : {
     836                 :          0 :         struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
     837                 :          0 :         struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
     838                 :          0 :         uint16_t num_ops_dequeued = dev->dequeue_ldpc_enc_ops(q_data, ops, num_ops);
     839                 :          0 :         if (num_ops_dequeued > 0)
     840                 :          0 :                 rte_bbdev_trace_dequeue(dev_id, queue_id, (void **)ops, num_ops,
     841                 :            :                                 num_ops_dequeued, rte_bbdev_op_type_str(RTE_BBDEV_OP_LDPC_ENC));
     842                 :          0 :         return num_ops_dequeued;
     843                 :            : }
     844                 :            : 
     845                 :            : /**
     846                 :            :  * Dequeue a burst of processed decode operations from a queue of the device.
     847                 :            :  * This functions returns only the current contents of the queue, and does not
     848                 :            :  * block until @ num_ops is available.
     849                 :            :  * This function does not provide any error notification to avoid the
     850                 :            :  * corresponding overhead.
     851                 :            :  *
     852                 :            :  * @param dev_id
     853                 :            :  *   The identifier of the device.
     854                 :            :  * @param queue_id
     855                 :            :  *   The index of the queue.
     856                 :            :  * @param ops
     857                 :            :  *   Pointer array where operations will be dequeued to. Must have at least
     858                 :            :  *   @p num_ops entries
     859                 :            :  * @param num_ops
     860                 :            :  *   The maximum number of operations to dequeue.
     861                 :            :  *
     862                 :            :  * @return
     863                 :            :  *   The number of operations actually dequeued (this is the number of entries
     864                 :            :  *   copied into the @p ops array).
     865                 :            :  */
     866                 :            : static inline uint16_t
     867                 :          0 : rte_bbdev_dequeue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id,
     868                 :            :                 struct rte_bbdev_dec_op **ops, uint16_t num_ops)
     869                 :            : {
     870                 :          0 :         struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
     871                 :          0 :         struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
     872                 :          0 :         uint16_t num_ops_dequeued = dev->dequeue_ldpc_dec_ops(q_data, ops, num_ops);
     873                 :          0 :         if (num_ops_dequeued > 0)
     874                 :          0 :                 rte_bbdev_trace_dequeue(dev_id, queue_id, (void **)ops, num_ops,
     875                 :            :                                 num_ops_dequeued, rte_bbdev_op_type_str(RTE_BBDEV_OP_LDPC_DEC));
     876                 :          0 :         return num_ops_dequeued;
     877                 :            : }
     878                 :            : 
     879                 :            : /**
     880                 :            :  * Dequeue a burst of FFT operations from a queue of the device.
     881                 :            :  * This functions returns only the current contents of the queue, and does not
     882                 :            :  * block until @ num_ops is available.
     883                 :            :  * This function does not provide any error notification to avoid the
     884                 :            :  * corresponding overhead.
     885                 :            :  *
     886                 :            :  * @param dev_id
     887                 :            :  *   The identifier of the device.
     888                 :            :  * @param queue_id
     889                 :            :  *   The index of the queue.
     890                 :            :  * @param ops
     891                 :            :  *   Pointer array where operations will be dequeued to. Must have at least
     892                 :            :  *   @p num_ops entries
     893                 :            :  * @param num_ops
     894                 :            :  *   The maximum number of operations to dequeue.
     895                 :            :  *
     896                 :            :  * @return
     897                 :            :  *   The number of operations actually dequeued (this is the number of entries
     898                 :            :  *   copied into the @p ops array).
     899                 :            :  */
     900                 :            : static inline uint16_t
     901                 :          0 : rte_bbdev_dequeue_fft_ops(uint16_t dev_id, uint16_t queue_id,
     902                 :            :                 struct rte_bbdev_fft_op **ops, uint16_t num_ops)
     903                 :            : {
     904                 :          0 :         struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
     905                 :          0 :         struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
     906                 :          0 :         uint16_t num_ops_dequeued = dev->dequeue_fft_ops(q_data, ops, num_ops);
     907                 :          0 :         if (num_ops_dequeued > 0)
     908                 :          0 :                 rte_bbdev_trace_dequeue(dev_id, queue_id, (void **)ops, num_ops,
     909                 :            :                                 num_ops_dequeued, rte_bbdev_op_type_str(RTE_BBDEV_OP_FFT));
     910                 :          0 :         return num_ops_dequeued;
     911                 :            : }
     912                 :            : 
     913                 :            : /**
     914                 :            :  * Dequeue a burst of MLDTS operations from a queue of the device.
     915                 :            :  * This functions returns only the current contents of the queue, and does not
     916                 :            :  * block until @p num_ops is available.
     917                 :            :  * This function does not provide any error notification to avoid the
     918                 :            :  * corresponding overhead.
     919                 :            :  *
     920                 :            :  * @param dev_id
     921                 :            :  *   The identifier of the device.
     922                 :            :  * @param queue_id
     923                 :            :  *   The index of the queue.
     924                 :            :  * @param ops
     925                 :            :  *   Pointer array where operations will be dequeued to. Must have at least
     926                 :            :  *   @p num_ops entries
     927                 :            :  * @param num_ops
     928                 :            :  *   The maximum number of operations to dequeue.
     929                 :            :  *
     930                 :            :  * @return
     931                 :            :  *   The number of operations actually dequeued (this is the number of entries
     932                 :            :  *   copied into the @p ops array).
     933                 :            :  */
     934                 :            : static inline uint16_t
     935                 :          0 : rte_bbdev_dequeue_mldts_ops(uint16_t dev_id, uint16_t queue_id,
     936                 :            :                 struct rte_bbdev_mldts_op **ops, uint16_t num_ops)
     937                 :            : {
     938                 :          0 :         struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
     939                 :          0 :         struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
     940                 :          0 :         uint16_t num_ops_dequeued = dev->dequeue_mldts_ops(q_data, ops, num_ops);
     941                 :          0 :         if (num_ops_dequeued > 0)
     942                 :          0 :                 rte_bbdev_trace_dequeue(dev_id, queue_id, (void **)ops, num_ops,
     943                 :            :                                 num_ops_dequeued, rte_bbdev_op_type_str(RTE_BBDEV_OP_MLDTS));
     944                 :          0 :         return num_ops_dequeued;
     945                 :            : }
     946                 :            : 
     947                 :            : /** Definitions of device event types */
     948                 :            : enum rte_bbdev_event_type {
     949                 :            :         RTE_BBDEV_EVENT_UNKNOWN,  /**< unknown event type */
     950                 :            :         RTE_BBDEV_EVENT_ERROR,  /**< error interrupt event */
     951                 :            :         RTE_BBDEV_EVENT_DEQUEUE,  /**< dequeue event */
     952                 :            :         RTE_BBDEV_EVENT_MAX  /**< max value of this enum */
     953                 :            : };
     954                 :            : 
     955                 :            : /**
     956                 :            :  * Typedef for application callback function registered by application
     957                 :            :  * software for notification of device events
     958                 :            :  *
     959                 :            :  * @param dev_id
     960                 :            :  *   Device identifier
     961                 :            :  * @param event
     962                 :            :  *   Device event to register for notification of.
     963                 :            :  * @param cb_arg
     964                 :            :  *   User specified parameter to be passed to user's callback function.
     965                 :            :  * @param ret_param
     966                 :            :  *   To pass data back to user application.
     967                 :            :  */
     968                 :            : typedef void (*rte_bbdev_cb_fn)(uint16_t dev_id,
     969                 :            :                 enum rte_bbdev_event_type event, void *cb_arg,
     970                 :            :                 void *ret_param);
     971                 :            : 
     972                 :            : /**
     973                 :            :  * Register a callback function for specific device id. Multiple callbacks can
     974                 :            :  * be added and will be called in the order they are added when an event is
     975                 :            :  * triggered. Callbacks are called in a separate thread created by the DPDK EAL.
     976                 :            :  *
     977                 :            :  * @param dev_id
     978                 :            :  *   Device id.
     979                 :            :  * @param event
     980                 :            :  *   The event that the callback will be registered for.
     981                 :            :  * @param cb_fn
     982                 :            :  *   User supplied callback function to be called.
     983                 :            :  * @param cb_arg
     984                 :            :  *   Pointer to parameter that will be passed to the callback.
     985                 :            :  *
     986                 :            :  * @return
     987                 :            :  *   Zero on success, negative value on failure.
     988                 :            :  */
     989                 :            : int
     990                 :            : rte_bbdev_callback_register(uint16_t dev_id, enum rte_bbdev_event_type event,
     991                 :            :                 rte_bbdev_cb_fn cb_fn, void *cb_arg);
     992                 :            : 
     993                 :            : /**
     994                 :            :  * Unregister a callback function for specific device id.
     995                 :            :  *
     996                 :            :  * @param dev_id
     997                 :            :  *   The device identifier.
     998                 :            :  * @param event
     999                 :            :  *   The event that the callback will be unregistered for.
    1000                 :            :  * @param cb_fn
    1001                 :            :  *   User supplied callback function to be unregistered.
    1002                 :            :  * @param cb_arg
    1003                 :            :  *   Pointer to the parameter supplied when registering the callback.
    1004                 :            :  *   (void *)-1 means to remove all registered callbacks with the specified
    1005                 :            :  *   function address.
    1006                 :            :  *
    1007                 :            :  * @return
    1008                 :            :  *   - 0 on success
    1009                 :            :  *   - EINVAL if invalid parameter pointer is provided
    1010                 :            :  *   - EAGAIN if the provided callback pointer does not exist
    1011                 :            :  */
    1012                 :            : int
    1013                 :            : rte_bbdev_callback_unregister(uint16_t dev_id, enum rte_bbdev_event_type event,
    1014                 :            :                 rte_bbdev_cb_fn cb_fn, void *cb_arg);
    1015                 :            : 
    1016                 :            : /**
    1017                 :            :  * Enable a one-shot interrupt on the next operation enqueued to a particular
    1018                 :            :  * queue. The interrupt will be triggered when the operation is ready to be
    1019                 :            :  * dequeued. To handle the interrupt, an epoll file descriptor must be
    1020                 :            :  * registered using rte_bbdev_queue_intr_ctl(), and then an application
    1021                 :            :  * thread/lcore can wait for the interrupt using rte_epoll_wait().
    1022                 :            :  *
    1023                 :            :  * @param dev_id
    1024                 :            :  *   The device identifier.
    1025                 :            :  * @param queue_id
    1026                 :            :  *   The index of the queue.
    1027                 :            :  *
    1028                 :            :  * @return
    1029                 :            :  *   - 0 on success
    1030                 :            :  *   - negative value on failure - as returned from PMD
    1031                 :            :  */
    1032                 :            : int
    1033                 :            : rte_bbdev_queue_intr_enable(uint16_t dev_id, uint16_t queue_id);
    1034                 :            : 
    1035                 :            : /**
    1036                 :            :  * Disable a one-shot interrupt on the next operation enqueued to a particular
    1037                 :            :  * queue (if it has been enabled).
    1038                 :            :  *
    1039                 :            :  * @param dev_id
    1040                 :            :  *   The device identifier.
    1041                 :            :  * @param queue_id
    1042                 :            :  *   The index of the queue.
    1043                 :            :  *
    1044                 :            :  * @return
    1045                 :            :  *   - 0 on success
    1046                 :            :  *   - negative value on failure - as returned from PMD
    1047                 :            :  */
    1048                 :            : int
    1049                 :            : rte_bbdev_queue_intr_disable(uint16_t dev_id, uint16_t queue_id);
    1050                 :            : 
    1051                 :            : /**
    1052                 :            :  * Control interface for per-queue interrupts.
    1053                 :            :  *
    1054                 :            :  * @param dev_id
    1055                 :            :  *   The device identifier.
    1056                 :            :  * @param queue_id
    1057                 :            :  *   The index of the queue.
    1058                 :            :  * @param epfd
    1059                 :            :  *   Epoll file descriptor that will be associated with the interrupt source.
    1060                 :            :  *   If the special value RTE_EPOLL_PER_THREAD is provided, a per thread epoll
    1061                 :            :  *   file descriptor created by the EAL is used (RTE_EPOLL_PER_THREAD can also
    1062                 :            :  *   be used when calling rte_epoll_wait()).
    1063                 :            :  * @param op
    1064                 :            :  *   The operation be performed for the vector.RTE_INTR_EVENT_ADD or
    1065                 :            :  *   RTE_INTR_EVENT_DEL.
    1066                 :            :  * @param data
    1067                 :            :  *   User context, that will be returned in the epdata.data field of the
    1068                 :            :  *   rte_epoll_event structure filled in by rte_epoll_wait().
    1069                 :            :  *
    1070                 :            :  * @return
    1071                 :            :  *   - 0 on success
    1072                 :            :  *   - ENOTSUP if interrupts are not supported by the identified device
    1073                 :            :  *   - negative value on failure - as returned from PMD
    1074                 :            :  */
    1075                 :            : int
    1076                 :            : rte_bbdev_queue_intr_ctl(uint16_t dev_id, uint16_t queue_id, int epfd, int op,
    1077                 :            :                 void *data);
    1078                 :            : 
    1079                 :            : /**
    1080                 :            :  * Convert device status from enum to string.
    1081                 :            :  *
    1082                 :            :  * @param status
    1083                 :            :  *   Device status as enum.
    1084                 :            :  *
    1085                 :            :  * @returns
    1086                 :            :  *   Device status as string or NULL if invalid.
    1087                 :            :  */
    1088                 :            : const char*
    1089                 :            : rte_bbdev_device_status_str(enum rte_bbdev_device_status status);
    1090                 :            : 
    1091                 :            : /**
    1092                 :            :  * Convert queue status from enum to string.
    1093                 :            :  *
    1094                 :            :  * @param status
    1095                 :            :  *   Queue status as enum.
    1096                 :            :  *
    1097                 :            :  * @returns
    1098                 :            :  *   Queue status as string or NULL if op_type is invalid.
    1099                 :            :  */
    1100                 :            : const char*
    1101                 :            : rte_bbdev_enqueue_status_str(enum rte_bbdev_enqueue_status status);
    1102                 :            : 
    1103                 :            : /**
    1104                 :            :  * Dump operations info from device to a file.
    1105                 :            :  * This API is used for debugging provided input operations, not a dataplane API.
    1106                 :            :  *
    1107                 :            :  *  @param dev_id
    1108                 :            :  *    The device identifier.
    1109                 :            :  *
    1110                 :            :  *  @param queue_index
    1111                 :            :  *    Index of queue.
    1112                 :            :  *
    1113                 :            :  *  @param file
    1114                 :            :  *    A pointer to a file for output.
    1115                 :            :  *
    1116                 :            :  * @returns
    1117                 :            :  *   - 0 on success
    1118                 :            :  *   - ENOTSUP if interrupts are not supported by the identified device
    1119                 :            :  *   - negative value on failure - as returned from PMD
    1120                 :            :  *
    1121                 :            :  */
    1122                 :            : __rte_experimental
    1123                 :            : int
    1124                 :            : rte_bbdev_queue_ops_dump(uint16_t dev_id, uint16_t queue_index, FILE *file);
    1125                 :            : 
    1126                 :            : 
    1127                 :            : /**
    1128                 :            :  * String of parameters related to the parameters of an operation of a given type.
    1129                 :            :  *
    1130                 :            :  *  @param op
    1131                 :            :  *    Pointer to an operation.
    1132                 :            :  *
    1133                 :            :  *  @param op_type
    1134                 :            :  *    Operation type enum.
    1135                 :            :  *
    1136                 :            :  *  @param str
    1137                 :            :  *    String being describing the operations.
    1138                 :            :  *
    1139                 :            :  *  @param len
    1140                 :            :  *    Size of the string buffer.
    1141                 :            :  *
    1142                 :            :  * @returns
    1143                 :            :  *   String describing the provided operation.
    1144                 :            :  *
    1145                 :            :  */
    1146                 :            : __rte_experimental
    1147                 :            : char *
    1148                 :            : rte_bbdev_ops_param_string(void *op, enum rte_bbdev_op_type op_type, char *str, uint32_t len);
    1149                 :            : 
    1150                 :            : #ifdef __cplusplus
    1151                 :            : }
    1152                 :            : #endif
    1153                 :            : 
    1154                 :            : #endif /* _RTE_BBDEV_H_ */

Generated by: LCOV version 1.14