DPDK  23.03.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 
318  const char *driver_name;
319 
321  unsigned int max_num_queues;
323  unsigned int num_queues[RTE_BBDEV_OP_TYPE_SIZE_MAX];
325  unsigned int queue_priority[RTE_BBDEV_OP_TYPE_SIZE_MAX];
327  uint32_t queue_size_lim;
337  enum rte_bbdev_device_status device_status;
341  uint16_t min_alignment;
347  struct rte_bbdev_queue_conf default_queue_conf;
351  const enum rte_cpu_flag_t *cpu_flag_reqs;
352 };
353 
355 #define RTE_BBDEV_END_OF_CAPABILITIES_LIST() \
356  { RTE_BBDEV_OP_NONE }
357 
363  int socket_id;
364  const char *dev_name;
365  const struct rte_device *device;
366  uint16_t num_queues;
367  bool started;
369 };
370 
384 int
385 rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info);
386 
390  struct rte_bbdev_queue_conf conf;
392  bool started;
393 };
394 
410 int
411 rte_bbdev_queue_info_get(uint16_t dev_id, uint16_t queue_id,
412  struct rte_bbdev_queue_info *queue_info);
413 
415 struct rte_bbdev_queue_data {
416  void *queue_private;
417  struct rte_bbdev_queue_conf conf;
418  struct rte_bbdev_stats queue_stats;
419  enum rte_bbdev_enqueue_status enqueue_status;
420  bool started;
421 };
422 
424 typedef uint16_t (*rte_bbdev_enqueue_enc_ops_t)(
425  struct rte_bbdev_queue_data *q_data,
426  struct rte_bbdev_enc_op **ops,
427  uint16_t num);
428 
430 typedef uint16_t (*rte_bbdev_enqueue_dec_ops_t)(
431  struct rte_bbdev_queue_data *q_data,
432  struct rte_bbdev_dec_op **ops,
433  uint16_t num);
434 
436 typedef uint16_t (*rte_bbdev_enqueue_fft_ops_t)(
437  struct rte_bbdev_queue_data *q_data,
438  struct rte_bbdev_fft_op **ops,
439  uint16_t num);
440 
442 typedef uint16_t (*rte_bbdev_dequeue_enc_ops_t)(
443  struct rte_bbdev_queue_data *q_data,
444  struct rte_bbdev_enc_op **ops, uint16_t num);
445 
447 typedef uint16_t (*rte_bbdev_dequeue_dec_ops_t)(
448  struct rte_bbdev_queue_data *q_data,
449  struct rte_bbdev_dec_op **ops, uint16_t num);
450 
452 typedef uint16_t (*rte_bbdev_dequeue_fft_ops_t)(
453  struct rte_bbdev_queue_data *q_data,
454  struct rte_bbdev_fft_op **ops, uint16_t num);
455 
456 #define RTE_BBDEV_NAME_MAX_LEN 64
464 struct rte_bbdev_data {
465  char name[RTE_BBDEV_NAME_MAX_LEN];
466  void *dev_private;
467  uint16_t num_queues;
468  struct rte_bbdev_queue_data *queues;
469  uint16_t dev_id;
470  int socket_id;
471  bool started;
472  uint16_t process_cnt;
473 };
474 
475 /* Forward declarations */
476 struct rte_bbdev_ops;
477 struct rte_bbdev_callback;
478 struct rte_intr_handle;
479 
481 RTE_TAILQ_HEAD(rte_bbdev_cb_list, rte_bbdev_callback);
482 
487 struct __rte_cache_aligned rte_bbdev {
489  rte_bbdev_enqueue_enc_ops_t enqueue_enc_ops;
491  rte_bbdev_enqueue_dec_ops_t enqueue_dec_ops;
493  rte_bbdev_dequeue_enc_ops_t dequeue_enc_ops;
495  rte_bbdev_dequeue_dec_ops_t dequeue_dec_ops;
497  rte_bbdev_enqueue_enc_ops_t enqueue_ldpc_enc_ops;
499  rte_bbdev_enqueue_dec_ops_t enqueue_ldpc_dec_ops;
501  rte_bbdev_dequeue_enc_ops_t dequeue_ldpc_enc_ops;
503  rte_bbdev_dequeue_dec_ops_t dequeue_ldpc_dec_ops;
505  rte_bbdev_enqueue_fft_ops_t enqueue_fft_ops;
507  rte_bbdev_dequeue_fft_ops_t dequeue_fft_ops;
508  const struct rte_bbdev_ops *dev_ops;
509  struct rte_bbdev_data *data;
510  enum rte_bbdev_state state;
511  struct rte_device *device;
513  struct rte_bbdev_cb_list list_cbs;
514  struct rte_intr_handle *intr_handle;
515 };
516 
518 extern struct rte_bbdev rte_bbdev_devices[];
519 
541 static inline uint16_t
542 rte_bbdev_enqueue_enc_ops(uint16_t dev_id, uint16_t queue_id,
543  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
544 {
545  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
546  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
547  return dev->enqueue_enc_ops(q_data, ops, num_ops);
548 }
549 
571 static inline uint16_t
572 rte_bbdev_enqueue_dec_ops(uint16_t dev_id, uint16_t queue_id,
573  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
574 {
575  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
576  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
577  return dev->enqueue_dec_ops(q_data, ops, num_ops);
578 }
579 
601 static inline uint16_t
602 rte_bbdev_enqueue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,
603  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
604 {
605  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
606  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
607  return dev->enqueue_ldpc_enc_ops(q_data, ops, num_ops);
608 }
609 
631 static inline uint16_t
632 rte_bbdev_enqueue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id,
633  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
634 {
635  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
636  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
637  return dev->enqueue_ldpc_dec_ops(q_data, ops, num_ops);
638 }
639 
661 __rte_experimental
662 static inline uint16_t
663 rte_bbdev_enqueue_fft_ops(uint16_t dev_id, uint16_t queue_id,
664  struct rte_bbdev_fft_op **ops, uint16_t num_ops)
665 {
666  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
667  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
668  return dev->enqueue_fft_ops(q_data, ops, num_ops);
669 }
670 
693 static inline uint16_t
694 rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id,
695  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
696 {
697  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
698  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
699  return dev->dequeue_enc_ops(q_data, ops, num_ops);
700 }
701 
725 static inline uint16_t
726 rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id,
727  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
728 {
729  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
730  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
731  return dev->dequeue_dec_ops(q_data, ops, num_ops);
732 }
733 
734 
756 static inline uint16_t
757 rte_bbdev_dequeue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,
758  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
759 {
760  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
761  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
762  return dev->dequeue_ldpc_enc_ops(q_data, ops, num_ops);
763 }
764 
786 static inline uint16_t
787 rte_bbdev_dequeue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id,
788  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
789 {
790  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
791  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
792  return dev->dequeue_ldpc_dec_ops(q_data, ops, num_ops);
793 }
794 
816 __rte_experimental
817 static inline uint16_t
818 rte_bbdev_dequeue_fft_ops(uint16_t dev_id, uint16_t queue_id,
819  struct rte_bbdev_fft_op **ops, uint16_t num_ops)
820 {
821  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
822  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
823  return dev->dequeue_fft_ops(q_data, ops, num_ops);
824 }
825 
832 };
833 
847 typedef void (*rte_bbdev_cb_fn)(uint16_t dev_id,
848  enum rte_bbdev_event_type event, void *cb_arg,
849  void *ret_param);
850 
868 int
869 rte_bbdev_callback_register(uint16_t dev_id, enum rte_bbdev_event_type event,
870  rte_bbdev_cb_fn cb_fn, void *cb_arg);
871 
891 int
892 rte_bbdev_callback_unregister(uint16_t dev_id, enum rte_bbdev_event_type event,
893  rte_bbdev_cb_fn cb_fn, void *cb_arg);
894 
911 int
912 rte_bbdev_queue_intr_enable(uint16_t dev_id, uint16_t queue_id);
913 
927 int
928 rte_bbdev_queue_intr_disable(uint16_t dev_id, uint16_t queue_id);
929 
954 int
955 rte_bbdev_queue_intr_ctl(uint16_t dev_id, uint16_t queue_id, int epfd, int op,
956  void *data);
957 
968 __rte_experimental
969 const char*
971 
982 __rte_experimental
983 const char*
985 
986 #ifdef __cplusplus
987 }
988 #endif
989 
990 #endif /* _RTE_BBDEV_H_ */
static __rte_experimental 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:818
uint64_t acc_offload_cycles
Definition: rte_bbdev.h:285
uint16_t num_queues
Definition: rte_bbdev.h:366
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:602
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:318
rte_bbdev_op_type
Definition: rte_bbdev_op.h:852
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:757
uint32_t harq_buffer_size
Definition: rte_bbdev.h:339
uint8_t max_dl_queue_priority
Definition: rte_bbdev.h:331
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:726
static __rte_experimental 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:663
int rte_bbdev_queue_info_get(uint16_t dev_id, uint16_t queue_id, struct rte_bbdev_queue_info *queue_info)
__rte_experimental const char * rte_bbdev_enqueue_status_str(enum rte_bbdev_enqueue_status status)
uint16_t rte_bbdev_find_next(uint16_t dev_id)
uint16_t min_alignment
Definition: rte_bbdev.h:341
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)
void * dev_private
unsigned int max_num_queues
Definition: rte_bbdev.h:321
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)
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:572
bool rte_bbdev_is_valid(uint16_t dev_id)
uint64_t enqueue_warn_count
Definition: rte_bbdev.h:274
#define RTE_BBDEV_NAME_MAX_LEN
Definition: rte_bbdev.h:456
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:694
uint64_t dequeue_warn_count
Definition: rte_bbdev.h:276
uint32_t queue_size_lim
Definition: rte_bbdev.h:327
rte_bbdev_state
Definition: rte_bbdev.h:47
#define __rte_cache_aligned
Definition: rte_common.h:440
__rte_experimental const char * rte_bbdev_device_status_str(enum rte_bbdev_device_status status)
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:787
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:632
const char * dev_name
Definition: rte_bbdev.h:364
int rte_bbdev_stats_reset(uint16_t dev_id)
rte_bbdev_event_type
Definition: rte_bbdev.h:827
const struct rte_device * device
Definition: rte_bbdev.h:365
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:542
rte_bbdev_device_status
Definition: rte_bbdev.h:253
const struct rte_bbdev_op_cap * capabilities
Definition: rte_bbdev.h:349
int rte_bbdev_stop(uint16_t dev_id)
int rte_bbdev_close(uint16_t dev_id)
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:333
enum rte_cpu_flag_t * cpu_flag_reqs
Definition: rte_bbdev.h:351
uint64_t enqueue_err_count
Definition: rte_bbdev.h:270
uint64_t dequeued_count
Definition: rte_bbdev.h:268
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:847
int rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id)