DPDK  24.11.0-rc3
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 #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 #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];
288 };
289 
303 int
304 rte_bbdev_stats_get(uint16_t dev_id, struct rte_bbdev_stats *stats);
305 
314 int
315 rte_bbdev_stats_reset(uint16_t dev_id);
316 
319 /* Structure rte_bbdev_driver_info 8< */
322  const char *driver_name;
323 
325  unsigned int max_num_queues;
327  unsigned int num_queues[RTE_BBDEV_OP_TYPE_SIZE_MAX];
329  unsigned int queue_priority[RTE_BBDEV_OP_TYPE_SIZE_MAX];
331  uint32_t queue_size_lim;
341  enum rte_bbdev_device_status device_status;
345  uint16_t min_alignment;
351  struct rte_bbdev_queue_conf default_queue_conf;
355  const enum rte_cpu_flag_t *cpu_flag_reqs;
357  uint16_t *fft_window_width;
358 };
359 /* >8 End of structure rte_bbdev_driver_info. */
360 
362 #define RTE_BBDEV_END_OF_CAPABILITIES_LIST() \
363  { RTE_BBDEV_OP_NONE }
364 
370 /* Structure rte_bbdev_info 8< */
372  int socket_id;
373  const char *dev_name;
374  const struct rte_device *device;
375  uint16_t num_queues;
376  bool started;
378 };
379 /* >8 End of structure rte_bbdev_info. */
380 
394 int
395 rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info);
396 
400  struct rte_bbdev_queue_conf conf;
402  bool started;
403 };
404 
420 int
421 rte_bbdev_queue_info_get(uint16_t dev_id, uint16_t queue_id,
422  struct rte_bbdev_queue_info *queue_info);
423 
425 struct rte_bbdev_queue_data {
426  void *queue_private;
427  struct rte_bbdev_queue_conf conf;
428  struct rte_bbdev_stats queue_stats;
429  enum rte_bbdev_enqueue_status enqueue_status;
430  bool started;
431 };
432 
434 typedef uint16_t (*rte_bbdev_enqueue_enc_ops_t)(
435  struct rte_bbdev_queue_data *q_data,
436  struct rte_bbdev_enc_op **ops,
437  uint16_t num);
438 
440 typedef uint16_t (*rte_bbdev_enqueue_dec_ops_t)(
441  struct rte_bbdev_queue_data *q_data,
442  struct rte_bbdev_dec_op **ops,
443  uint16_t num);
444 
446 typedef uint16_t (*rte_bbdev_enqueue_fft_ops_t)(
447  struct rte_bbdev_queue_data *q_data,
448  struct rte_bbdev_fft_op **ops,
449  uint16_t num);
450 
452 typedef uint16_t (*rte_bbdev_enqueue_mldts_ops_t)(
453  struct rte_bbdev_queue_data *q_data,
454  struct rte_bbdev_mldts_op **ops,
455  uint16_t num);
456 
458 typedef uint16_t (*rte_bbdev_dequeue_enc_ops_t)(
459  struct rte_bbdev_queue_data *q_data,
460  struct rte_bbdev_enc_op **ops, uint16_t num);
461 
463 typedef uint16_t (*rte_bbdev_dequeue_dec_ops_t)(
464  struct rte_bbdev_queue_data *q_data,
465  struct rte_bbdev_dec_op **ops, uint16_t num);
466 
468 typedef uint16_t (*rte_bbdev_dequeue_fft_ops_t)(
469  struct rte_bbdev_queue_data *q_data,
470  struct rte_bbdev_fft_op **ops, uint16_t num);
471 
473 typedef uint16_t (*rte_bbdev_dequeue_mldts_ops_t)(
474  struct rte_bbdev_queue_data *q_data,
475  struct rte_bbdev_mldts_op **ops, uint16_t num);
476 
477 #define RTE_BBDEV_NAME_MAX_LEN 64
485 struct rte_bbdev_data {
486  char name[RTE_BBDEV_NAME_MAX_LEN];
487  void *dev_private;
488  uint16_t num_queues;
489  struct rte_bbdev_queue_data *queues;
490  uint16_t dev_id;
491  int socket_id;
492  bool started;
493  RTE_ATOMIC(uint16_t) process_cnt;
494 };
495 
496 /* Forward declarations */
497 struct rte_bbdev_ops;
498 struct rte_bbdev_callback;
499 struct rte_intr_handle;
500 
502 RTE_TAILQ_HEAD(rte_bbdev_cb_list, rte_bbdev_callback);
503 
508 struct __rte_cache_aligned rte_bbdev {
510  rte_bbdev_enqueue_enc_ops_t enqueue_enc_ops;
512  rte_bbdev_enqueue_dec_ops_t enqueue_dec_ops;
514  rte_bbdev_dequeue_enc_ops_t dequeue_enc_ops;
516  rte_bbdev_dequeue_dec_ops_t dequeue_dec_ops;
518  rte_bbdev_enqueue_enc_ops_t enqueue_ldpc_enc_ops;
520  rte_bbdev_enqueue_dec_ops_t enqueue_ldpc_dec_ops;
522  rte_bbdev_dequeue_enc_ops_t dequeue_ldpc_enc_ops;
524  rte_bbdev_dequeue_dec_ops_t dequeue_ldpc_dec_ops;
526  rte_bbdev_enqueue_fft_ops_t enqueue_fft_ops;
528  rte_bbdev_dequeue_fft_ops_t dequeue_fft_ops;
529  const struct rte_bbdev_ops *dev_ops;
530  struct rte_bbdev_data *data;
531  enum rte_bbdev_state state;
532  struct rte_device *device;
534  struct rte_bbdev_cb_list list_cbs;
535  struct rte_intr_handle *intr_handle;
537  rte_bbdev_enqueue_mldts_ops_t enqueue_mldts_ops;
539  rte_bbdev_dequeue_mldts_ops_t dequeue_mldts_ops;
540 };
541 
543 extern struct rte_bbdev rte_bbdev_devices[];
544 
566 static inline uint16_t
567 rte_bbdev_enqueue_enc_ops(uint16_t dev_id, uint16_t queue_id,
568  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
569 {
570  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
571  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
572  return dev->enqueue_enc_ops(q_data, ops, num_ops);
573 }
574 
596 static inline uint16_t
597 rte_bbdev_enqueue_dec_ops(uint16_t dev_id, uint16_t queue_id,
598  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
599 {
600  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
601  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
602  return dev->enqueue_dec_ops(q_data, ops, num_ops);
603 }
604 
626 static inline uint16_t
627 rte_bbdev_enqueue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,
628  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
629 {
630  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
631  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
632  return dev->enqueue_ldpc_enc_ops(q_data, ops, num_ops);
633 }
634 
656 static inline uint16_t
657 rte_bbdev_enqueue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id,
658  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
659 {
660  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
661  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
662  return dev->enqueue_ldpc_dec_ops(q_data, ops, num_ops);
663 }
664 
686 static inline uint16_t
687 rte_bbdev_enqueue_fft_ops(uint16_t dev_id, uint16_t queue_id,
688  struct rte_bbdev_fft_op **ops, uint16_t num_ops)
689 {
690  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
691  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
692  return dev->enqueue_fft_ops(q_data, ops, num_ops);
693 }
694 
716 static inline uint16_t
717 rte_bbdev_enqueue_mldts_ops(uint16_t dev_id, uint16_t queue_id,
718  struct rte_bbdev_mldts_op **ops, uint16_t num_ops)
719 {
720  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
721  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
722  return dev->enqueue_mldts_ops(q_data, ops, num_ops);
723 }
724 
747 static inline uint16_t
748 rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id,
749  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
750 {
751  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
752  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
753  return dev->dequeue_enc_ops(q_data, ops, num_ops);
754 }
755 
779 static inline uint16_t
780 rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id,
781  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
782 {
783  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
784  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
785  return dev->dequeue_dec_ops(q_data, ops, num_ops);
786 }
787 
788 
810 static inline uint16_t
811 rte_bbdev_dequeue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,
812  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
813 {
814  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
815  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
816  return dev->dequeue_ldpc_enc_ops(q_data, ops, num_ops);
817 }
818 
840 static inline uint16_t
841 rte_bbdev_dequeue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id,
842  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
843 {
844  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
845  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
846  return dev->dequeue_ldpc_dec_ops(q_data, ops, num_ops);
847 }
848 
870 static inline uint16_t
871 rte_bbdev_dequeue_fft_ops(uint16_t dev_id, uint16_t queue_id,
872  struct rte_bbdev_fft_op **ops, uint16_t num_ops)
873 {
874  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
875  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
876  return dev->dequeue_fft_ops(q_data, ops, num_ops);
877 }
878 
900 static inline uint16_t
901 rte_bbdev_dequeue_mldts_ops(uint16_t dev_id, uint16_t queue_id,
902  struct rte_bbdev_mldts_op **ops, uint16_t num_ops)
903 {
904  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
905  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
906  return dev->dequeue_mldts_ops(q_data, ops, num_ops);
907 }
908 
915 };
916 
930 typedef void (*rte_bbdev_cb_fn)(uint16_t dev_id,
931  enum rte_bbdev_event_type event, void *cb_arg,
932  void *ret_param);
933 
951 int
952 rte_bbdev_callback_register(uint16_t dev_id, enum rte_bbdev_event_type event,
953  rte_bbdev_cb_fn cb_fn, void *cb_arg);
954 
974 int
975 rte_bbdev_callback_unregister(uint16_t dev_id, enum rte_bbdev_event_type event,
976  rte_bbdev_cb_fn cb_fn, void *cb_arg);
977 
994 int
995 rte_bbdev_queue_intr_enable(uint16_t dev_id, uint16_t queue_id);
996 
1010 int
1011 rte_bbdev_queue_intr_disable(uint16_t dev_id, uint16_t queue_id);
1012 
1037 int
1038 rte_bbdev_queue_intr_ctl(uint16_t dev_id, uint16_t queue_id, int epfd, int op,
1039  void *data);
1040 
1050 const char*
1052 
1062 const char*
1064 
1084 __rte_experimental
1085 int
1086 rte_bbdev_queue_ops_dump(uint16_t dev_id, uint16_t queue_index, FILE *file);
1087 
1088 
1108 __rte_experimental
1109 char *
1110 rte_bbdev_ops_param_string(void *op, enum rte_bbdev_op_type op_type, char *str, uint32_t len);
1111 
1112 #ifdef __cplusplus
1113 }
1114 #endif
1115 
1116 #endif /* _RTE_BBDEV_H_ */
__rte_experimental int rte_bbdev_queue_ops_dump(uint16_t dev_id, uint16_t queue_index, FILE *file)
uint64_t acc_offload_cycles
Definition: rte_bbdev.h:285
uint16_t num_queues
Definition: rte_bbdev.h:375
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:627
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:322
rte_bbdev_op_type
Definition: rte_bbdev_op.h:930
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:811
uint32_t harq_buffer_size
Definition: rte_bbdev.h:343
uint8_t max_dl_queue_priority
Definition: rte_bbdev.h:335
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:780
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:871
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:627
uint16_t rte_bbdev_find_next(uint16_t dev_id)
uint16_t min_alignment
Definition: rte_bbdev.h:345
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:325
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)
uint16_t enqueue_depth_avail
Definition: rte_bbdev.h:287
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:597
__rte_experimental char * rte_bbdev_ops_param_string(void *op, enum rte_bbdev_op_type op_type, char *str, uint32_t len)
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:687
uint64_t enqueue_warn_count
Definition: rte_bbdev.h:274
#define RTE_BBDEV_NAME_MAX_LEN
Definition: rte_bbdev.h:477
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:748
uint64_t dequeue_warn_count
Definition: rte_bbdev.h:276
uint32_t queue_size_lim
Definition: rte_bbdev.h:331
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:841
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:657
uint16_t * fft_window_width
Definition: rte_bbdev.h:357
const char * dev_name
Definition: rte_bbdev.h:373
int rte_bbdev_stats_reset(uint16_t dev_id)
rte_bbdev_event_type
Definition: rte_bbdev.h:910
const struct rte_device * device
Definition: rte_bbdev.h:374
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:567
rte_bbdev_device_status
Definition: rte_bbdev.h:253
const struct rte_bbdev_op_cap * capabilities
Definition: rte_bbdev.h:353
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:717
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:337
static 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:901
enum rte_cpu_flag_t * cpu_flag_reqs
Definition: rte_bbdev.h:355
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:930
int rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id)