DPDK  24.07.0
rte_bbdev.h
Go to the documentation of this file.
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 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #include <stdint.h>
28 #include <stdbool.h>
29 
30 #include <rte_compat.h>
31 #include <rte_cpuflags.h>
32 
33 #include "rte_bbdev_op.h"
34 
35 #ifndef RTE_BBDEV_MAX_DEVS
36 #define RTE_BBDEV_MAX_DEVS 128
37 #endif
38 
39 /*
40  * Maximum size to be used to manage the enum rte_bbdev_enqueue_status
41  * including padding for future enum insertion.
42  * The enum values must be explicitly kept smaller or equal to this padded maximum size.
43  */
44 #define RTE_BBDEV_ENQ_STATUS_SIZE_MAX 6
45 
48  RTE_BBDEV_UNUSED,
49  RTE_BBDEV_INITIALIZED
50 };
51 
58 uint16_t
59 rte_bbdev_count(void);
60 
70 bool
71 rte_bbdev_is_valid(uint16_t dev_id);
72 
83 uint16_t
84 rte_bbdev_find_next(uint16_t dev_id);
85 
87 #define RTE_BBDEV_FOREACH(i) for (i = rte_bbdev_find_next(-1); \
88  i < RTE_BBDEV_MAX_DEVS; \
89  i = rte_bbdev_find_next(i))
90 
112 int
113 rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id);
114 
129 int
130 rte_bbdev_intr_enable(uint16_t dev_id);
131 
134  int socket;
135  uint32_t queue_size;
136  uint8_t priority;
139 };
140 
158 int
159 rte_bbdev_queue_configure(uint16_t dev_id, uint16_t queue_id,
160  const struct rte_bbdev_queue_conf *conf);
161 
173 int
174 rte_bbdev_start(uint16_t dev_id);
175 
186 int
187 rte_bbdev_stop(uint16_t dev_id);
188 
199 int
200 rte_bbdev_close(uint16_t dev_id);
201 
216 int
217 rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id);
218 
231 int
232 rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id);
233 
247  /* Note: RTE_BBDEV_ENQ_STATUS_SIZE_MAX must be larger or equal to maximum enum value. */
248 };
249 
263 };
264 
267  uint64_t enqueued_count;
268  uint64_t dequeued_count;
278  uint64_t enqueue_status_count[RTE_BBDEV_ENQ_STATUS_SIZE_MAX];
286 };
287 
301 int
302 rte_bbdev_stats_get(uint16_t dev_id, struct rte_bbdev_stats *stats);
303 
312 int
313 rte_bbdev_stats_reset(uint16_t dev_id);
314 
317 /* Structure rte_bbdev_driver_info 8< */
320  const char *driver_name;
321 
323  unsigned int max_num_queues;
325  unsigned int num_queues[RTE_BBDEV_OP_TYPE_SIZE_MAX];
327  unsigned int queue_priority[RTE_BBDEV_OP_TYPE_SIZE_MAX];
329  uint32_t queue_size_lim;
339  enum rte_bbdev_device_status device_status;
343  uint16_t min_alignment;
349  struct rte_bbdev_queue_conf default_queue_conf;
353  const enum rte_cpu_flag_t *cpu_flag_reqs;
355  uint16_t *fft_window_width;
356 };
357 /* >8 End of structure rte_bbdev_driver_info. */
358 
360 #define RTE_BBDEV_END_OF_CAPABILITIES_LIST() \
361  { RTE_BBDEV_OP_NONE }
362 
368 /* Structure rte_bbdev_info 8< */
370  int socket_id;
371  const char *dev_name;
372  const struct rte_device *device;
373  uint16_t num_queues;
374  bool started;
376 };
377 /* >8 End of structure rte_bbdev_info. */
378 
392 int
393 rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info);
394 
398  struct rte_bbdev_queue_conf conf;
400  bool started;
401 };
402 
418 int
419 rte_bbdev_queue_info_get(uint16_t dev_id, uint16_t queue_id,
420  struct rte_bbdev_queue_info *queue_info);
421 
423 struct rte_bbdev_queue_data {
424  void *queue_private;
425  struct rte_bbdev_queue_conf conf;
426  struct rte_bbdev_stats queue_stats;
427  enum rte_bbdev_enqueue_status enqueue_status;
428  bool started;
429 };
430 
432 typedef uint16_t (*rte_bbdev_enqueue_enc_ops_t)(
433  struct rte_bbdev_queue_data *q_data,
434  struct rte_bbdev_enc_op **ops,
435  uint16_t num);
436 
438 typedef uint16_t (*rte_bbdev_enqueue_dec_ops_t)(
439  struct rte_bbdev_queue_data *q_data,
440  struct rte_bbdev_dec_op **ops,
441  uint16_t num);
442 
444 typedef uint16_t (*rte_bbdev_enqueue_fft_ops_t)(
445  struct rte_bbdev_queue_data *q_data,
446  struct rte_bbdev_fft_op **ops,
447  uint16_t num);
448 
450 typedef uint16_t (*rte_bbdev_enqueue_mldts_ops_t)(
451  struct rte_bbdev_queue_data *q_data,
452  struct rte_bbdev_mldts_op **ops,
453  uint16_t num);
454 
456 typedef uint16_t (*rte_bbdev_dequeue_enc_ops_t)(
457  struct rte_bbdev_queue_data *q_data,
458  struct rte_bbdev_enc_op **ops, uint16_t num);
459 
461 typedef uint16_t (*rte_bbdev_dequeue_dec_ops_t)(
462  struct rte_bbdev_queue_data *q_data,
463  struct rte_bbdev_dec_op **ops, uint16_t num);
464 
466 typedef uint16_t (*rte_bbdev_dequeue_fft_ops_t)(
467  struct rte_bbdev_queue_data *q_data,
468  struct rte_bbdev_fft_op **ops, uint16_t num);
469 
471 typedef uint16_t (*rte_bbdev_dequeue_mldts_ops_t)(
472  struct rte_bbdev_queue_data *q_data,
473  struct rte_bbdev_mldts_op **ops, uint16_t num);
474 
475 #define RTE_BBDEV_NAME_MAX_LEN 64
483 struct rte_bbdev_data {
484  char name[RTE_BBDEV_NAME_MAX_LEN];
485  void *dev_private;
486  uint16_t num_queues;
487  struct rte_bbdev_queue_data *queues;
488  uint16_t dev_id;
489  int socket_id;
490  bool started;
491  RTE_ATOMIC(uint16_t) process_cnt;
492 };
493 
494 /* Forward declarations */
495 struct rte_bbdev_ops;
496 struct rte_bbdev_callback;
497 struct rte_intr_handle;
498 
500 RTE_TAILQ_HEAD(rte_bbdev_cb_list, rte_bbdev_callback);
501 
506 struct __rte_cache_aligned rte_bbdev {
508  rte_bbdev_enqueue_enc_ops_t enqueue_enc_ops;
510  rte_bbdev_enqueue_dec_ops_t enqueue_dec_ops;
512  rte_bbdev_dequeue_enc_ops_t dequeue_enc_ops;
514  rte_bbdev_dequeue_dec_ops_t dequeue_dec_ops;
516  rte_bbdev_enqueue_enc_ops_t enqueue_ldpc_enc_ops;
518  rte_bbdev_enqueue_dec_ops_t enqueue_ldpc_dec_ops;
520  rte_bbdev_dequeue_enc_ops_t dequeue_ldpc_enc_ops;
522  rte_bbdev_dequeue_dec_ops_t dequeue_ldpc_dec_ops;
524  rte_bbdev_enqueue_fft_ops_t enqueue_fft_ops;
526  rte_bbdev_dequeue_fft_ops_t dequeue_fft_ops;
527  const struct rte_bbdev_ops *dev_ops;
528  struct rte_bbdev_data *data;
529  enum rte_bbdev_state state;
530  struct rte_device *device;
532  struct rte_bbdev_cb_list list_cbs;
533  struct rte_intr_handle *intr_handle;
535  rte_bbdev_enqueue_mldts_ops_t enqueue_mldts_ops;
537  rte_bbdev_dequeue_mldts_ops_t dequeue_mldts_ops;
538 };
539 
541 extern struct rte_bbdev rte_bbdev_devices[];
542 
564 static inline uint16_t
565 rte_bbdev_enqueue_enc_ops(uint16_t dev_id, uint16_t queue_id,
566  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
567 {
568  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
569  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
570  return dev->enqueue_enc_ops(q_data, ops, num_ops);
571 }
572 
594 static inline uint16_t
595 rte_bbdev_enqueue_dec_ops(uint16_t dev_id, uint16_t queue_id,
596  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
597 {
598  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
599  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
600  return dev->enqueue_dec_ops(q_data, ops, num_ops);
601 }
602 
624 static inline uint16_t
625 rte_bbdev_enqueue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,
626  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
627 {
628  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
629  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
630  return dev->enqueue_ldpc_enc_ops(q_data, ops, num_ops);
631 }
632 
654 static inline uint16_t
655 rte_bbdev_enqueue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id,
656  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
657 {
658  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
659  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
660  return dev->enqueue_ldpc_dec_ops(q_data, ops, num_ops);
661 }
662 
684 static inline uint16_t
685 rte_bbdev_enqueue_fft_ops(uint16_t dev_id, uint16_t queue_id,
686  struct rte_bbdev_fft_op **ops, uint16_t num_ops)
687 {
688  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
689  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
690  return dev->enqueue_fft_ops(q_data, ops, num_ops);
691 }
692 
714 static inline uint16_t
715 rte_bbdev_enqueue_mldts_ops(uint16_t dev_id, uint16_t queue_id,
716  struct rte_bbdev_mldts_op **ops, uint16_t num_ops)
717 {
718  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
719  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
720  return dev->enqueue_mldts_ops(q_data, ops, num_ops);
721 }
722 
745 static inline uint16_t
746 rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id,
747  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
748 {
749  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
750  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
751  return dev->dequeue_enc_ops(q_data, ops, num_ops);
752 }
753 
777 static inline uint16_t
778 rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id,
779  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
780 {
781  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
782  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
783  return dev->dequeue_dec_ops(q_data, ops, num_ops);
784 }
785 
786 
808 static inline uint16_t
809 rte_bbdev_dequeue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,
810  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
811 {
812  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
813  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
814  return dev->dequeue_ldpc_enc_ops(q_data, ops, num_ops);
815 }
816 
838 static inline uint16_t
839 rte_bbdev_dequeue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id,
840  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
841 {
842  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
843  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
844  return dev->dequeue_ldpc_dec_ops(q_data, ops, num_ops);
845 }
846 
868 static inline uint16_t
869 rte_bbdev_dequeue_fft_ops(uint16_t dev_id, uint16_t queue_id,
870  struct rte_bbdev_fft_op **ops, uint16_t num_ops)
871 {
872  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
873  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
874  return dev->dequeue_fft_ops(q_data, ops, num_ops);
875 }
876 
898 __rte_experimental
899 static inline uint16_t
900 rte_bbdev_dequeue_mldts_ops(uint16_t dev_id, uint16_t queue_id,
901  struct rte_bbdev_mldts_op **ops, uint16_t num_ops)
902 {
903  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
904  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
905  return dev->dequeue_mldts_ops(q_data, ops, num_ops);
906 }
907 
914 };
915 
929 typedef void (*rte_bbdev_cb_fn)(uint16_t dev_id,
930  enum rte_bbdev_event_type event, void *cb_arg,
931  void *ret_param);
932 
950 int
951 rte_bbdev_callback_register(uint16_t dev_id, enum rte_bbdev_event_type event,
952  rte_bbdev_cb_fn cb_fn, void *cb_arg);
953 
973 int
974 rte_bbdev_callback_unregister(uint16_t dev_id, enum rte_bbdev_event_type event,
975  rte_bbdev_cb_fn cb_fn, void *cb_arg);
976 
993 int
994 rte_bbdev_queue_intr_enable(uint16_t dev_id, uint16_t queue_id);
995 
1009 int
1010 rte_bbdev_queue_intr_disable(uint16_t dev_id, uint16_t queue_id);
1011 
1036 int
1037 rte_bbdev_queue_intr_ctl(uint16_t dev_id, uint16_t queue_id, int epfd, int op,
1038  void *data);
1039 
1049 const char*
1051 
1061 const char*
1063 
1064 #ifdef __cplusplus
1065 }
1066 #endif
1067 
1068 #endif /* _RTE_BBDEV_H_ */
uint64_t acc_offload_cycles
Definition: rte_bbdev.h:285
uint16_t num_queues
Definition: rte_bbdev.h:373
int rte_bbdev_queue_configure(uint16_t dev_id, uint16_t queue_id, const struct rte_bbdev_queue_conf *conf)
int rte_bbdev_intr_enable(uint16_t dev_id)
uint64_t enqueued_count
Definition: rte_bbdev.h:267
int rte_bbdev_queue_intr_ctl(uint16_t dev_id, uint16_t queue_id, int epfd, int op, void *data)
int rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id)
static uint16_t rte_bbdev_enqueue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id, struct rte_bbdev_enc_op **ops, uint16_t num_ops)
Definition: rte_bbdev.h:625
RTE_TAILQ_HEAD(rte_bbdev_cb_list, rte_bbdev_callback)
uint64_t dequeue_err_count
Definition: rte_bbdev.h:272
const char * driver_name
Definition: rte_bbdev.h:320
rte_bbdev_op_type
Definition: rte_bbdev_op.h:926
static uint16_t rte_bbdev_dequeue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id, struct rte_bbdev_enc_op **ops, uint16_t num_ops)
Definition: rte_bbdev.h:809
uint32_t harq_buffer_size
Definition: rte_bbdev.h:341
uint8_t max_dl_queue_priority
Definition: rte_bbdev.h:333
static uint16_t rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id, struct rte_bbdev_dec_op **ops, uint16_t num_ops)
Definition: rte_bbdev.h:778
static uint16_t rte_bbdev_dequeue_fft_ops(uint16_t dev_id, uint16_t queue_id, struct rte_bbdev_fft_op **ops, uint16_t num_ops)
Definition: rte_bbdev.h:869
static __rte_experimental uint16_t rte_bbdev_dequeue_mldts_ops(uint16_t dev_id, uint16_t queue_id, struct rte_bbdev_mldts_op **ops, uint16_t num_ops)
Definition: rte_bbdev.h:900
int rte_bbdev_queue_info_get(uint16_t dev_id, uint16_t queue_id, struct rte_bbdev_queue_info *queue_info)
#define __rte_cache_aligned
Definition: rte_common.h:568
uint16_t rte_bbdev_find_next(uint16_t dev_id)
uint16_t min_alignment
Definition: rte_bbdev.h:343
int rte_bbdev_stats_get(uint16_t dev_id, struct rte_bbdev_stats *stats)
int rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info)
unsigned int max_num_queues
Definition: rte_bbdev.h:323
enum rte_bbdev_op_type op_type
Definition: rte_bbdev.h:138
int rte_bbdev_queue_intr_enable(uint16_t dev_id, uint16_t queue_id)
int rte_bbdev_start(uint16_t dev_id)
uint16_t rte_bbdev_count(void)
const char * rte_bbdev_enqueue_status_str(enum rte_bbdev_enqueue_status status)
static uint16_t rte_bbdev_enqueue_dec_ops(uint16_t dev_id, uint16_t queue_id, struct rte_bbdev_dec_op **ops, uint16_t num_ops)
Definition: rte_bbdev.h:595
bool rte_bbdev_is_valid(uint16_t dev_id)
static uint16_t rte_bbdev_enqueue_fft_ops(uint16_t dev_id, uint16_t queue_id, struct rte_bbdev_fft_op **ops, uint16_t num_ops)
Definition: rte_bbdev.h:685
uint64_t enqueue_warn_count
Definition: rte_bbdev.h:274
#define RTE_BBDEV_NAME_MAX_LEN
Definition: rte_bbdev.h:475
rte_bbdev_enqueue_status
Definition: rte_bbdev.h:242
int rte_bbdev_queue_intr_disable(uint16_t dev_id, uint16_t queue_id)
static uint16_t rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id, struct rte_bbdev_enc_op **ops, uint16_t num_ops)
Definition: rte_bbdev.h:746
uint64_t dequeue_warn_count
Definition: rte_bbdev.h:276
uint32_t queue_size_lim
Definition: rte_bbdev.h:329
rte_bbdev_state
Definition: rte_bbdev.h:47
int rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id)
static uint16_t rte_bbdev_dequeue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id, struct rte_bbdev_dec_op **ops, uint16_t num_ops)
Definition: rte_bbdev.h:839
int rte_bbdev_callback_unregister(uint16_t dev_id, enum rte_bbdev_event_type event, rte_bbdev_cb_fn cb_fn, void *cb_arg)
static uint16_t rte_bbdev_enqueue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id, struct rte_bbdev_dec_op **ops, uint16_t num_ops)
Definition: rte_bbdev.h:655
uint16_t * fft_window_width
Definition: rte_bbdev.h:355
const char * dev_name
Definition: rte_bbdev.h:371
int rte_bbdev_stats_reset(uint16_t dev_id)
rte_bbdev_event_type
Definition: rte_bbdev.h:909
const struct rte_device * device
Definition: rte_bbdev.h:372
static uint16_t rte_bbdev_enqueue_enc_ops(uint16_t dev_id, uint16_t queue_id, struct rte_bbdev_enc_op **ops, uint16_t num_ops)
Definition: rte_bbdev.h:565
rte_bbdev_device_status
Definition: rte_bbdev.h:253
const struct rte_bbdev_op_cap * capabilities
Definition: rte_bbdev.h:351
int rte_bbdev_stop(uint16_t dev_id)
int rte_bbdev_close(uint16_t dev_id)
static uint16_t rte_bbdev_enqueue_mldts_ops(uint16_t dev_id, uint16_t queue_id, struct rte_bbdev_mldts_op **ops, uint16_t num_ops)
Definition: rte_bbdev.h:715
int rte_bbdev_callback_register(uint16_t dev_id, enum rte_bbdev_event_type event, rte_bbdev_cb_fn cb_fn, void *cb_arg)
uint8_t max_ul_queue_priority
Definition: rte_bbdev.h:335
enum rte_cpu_flag_t * cpu_flag_reqs
Definition: rte_bbdev.h:353
uint64_t enqueue_err_count
Definition: rte_bbdev.h:270
uint64_t dequeued_count
Definition: rte_bbdev.h:268
const char * rte_bbdev_device_status_str(enum rte_bbdev_device_status status)
void(* rte_bbdev_cb_fn)(uint16_t dev_id, enum rte_bbdev_event_type event, void *cb_arg, void *ret_param)
Definition: rte_bbdev.h:929
int rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id)