DPDK  21.11.8
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 #include <string.h>
30 
31 #include <rte_compat.h>
32 #include <rte_bus.h>
33 #include <rte_cpuflags.h>
34 #include <rte_memory.h>
35 
36 #include "rte_bbdev_op.h"
37 
38 #ifndef RTE_BBDEV_MAX_DEVS
39 #define RTE_BBDEV_MAX_DEVS 128
40 #endif
41 
44  RTE_BBDEV_UNUSED,
45  RTE_BBDEV_INITIALIZED
46 };
47 
54 uint16_t
55 rte_bbdev_count(void);
56 
66 bool
67 rte_bbdev_is_valid(uint16_t dev_id);
68 
79 uint16_t
80 rte_bbdev_find_next(uint16_t dev_id);
81 
83 #define RTE_BBDEV_FOREACH(i) for (i = rte_bbdev_find_next(-1); \
84  i < RTE_BBDEV_MAX_DEVS; \
85  i = rte_bbdev_find_next(i))
86 
108 int
109 rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id);
110 
125 int
126 rte_bbdev_intr_enable(uint16_t dev_id);
127 
130  int socket;
131  uint32_t queue_size;
132  uint8_t priority;
135 };
136 
154 int
155 rte_bbdev_queue_configure(uint16_t dev_id, uint16_t queue_id,
156  const struct rte_bbdev_queue_conf *conf);
157 
169 int
170 rte_bbdev_start(uint16_t dev_id);
171 
182 int
183 rte_bbdev_stop(uint16_t dev_id);
184 
195 int
196 rte_bbdev_close(uint16_t dev_id);
197 
212 int
213 rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id);
214 
227 int
228 rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id);
229 
232  uint64_t enqueued_count;
233  uint64_t dequeued_count;
245 };
246 
260 int
261 rte_bbdev_stats_get(uint16_t dev_id, struct rte_bbdev_stats *stats);
262 
271 int
272 rte_bbdev_stats_reset(uint16_t dev_id);
273 
277  const char *driver_name;
278 
280  unsigned int max_num_queues;
282  uint32_t queue_size_lim;
292  uint16_t min_alignment;
300  struct rte_bbdev_queue_conf default_queue_conf;
304  const enum rte_cpu_flag_t *cpu_flag_reqs;
305 };
306 
308 #define RTE_BBDEV_END_OF_CAPABILITIES_LIST() \
309  { RTE_BBDEV_OP_NONE }
310 
316  int socket_id;
317  const char *dev_name;
318  const struct rte_device *device;
319  uint16_t num_queues;
320  bool started;
322 };
323 
337 int
338 rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info);
339 
343  struct rte_bbdev_queue_conf conf;
345  bool started;
346 };
347 
363 int
364 rte_bbdev_queue_info_get(uint16_t dev_id, uint16_t queue_id,
365  struct rte_bbdev_queue_info *queue_info);
366 
368 struct rte_bbdev_queue_data {
369  void *queue_private;
370  struct rte_bbdev_queue_conf conf;
371  struct rte_bbdev_stats queue_stats;
372  bool started;
373 };
374 
376 typedef uint16_t (*rte_bbdev_enqueue_enc_ops_t)(
377  struct rte_bbdev_queue_data *q_data,
378  struct rte_bbdev_enc_op **ops,
379  uint16_t num);
380 
382 typedef uint16_t (*rte_bbdev_enqueue_dec_ops_t)(
383  struct rte_bbdev_queue_data *q_data,
384  struct rte_bbdev_dec_op **ops,
385  uint16_t num);
386 
388 typedef uint16_t (*rte_bbdev_dequeue_enc_ops_t)(
389  struct rte_bbdev_queue_data *q_data,
390  struct rte_bbdev_enc_op **ops, uint16_t num);
391 
393 typedef uint16_t (*rte_bbdev_dequeue_dec_ops_t)(
394  struct rte_bbdev_queue_data *q_data,
395  struct rte_bbdev_dec_op **ops, uint16_t num);
396 
397 #define RTE_BBDEV_NAME_MAX_LEN 64
405 struct rte_bbdev_data {
406  char name[RTE_BBDEV_NAME_MAX_LEN];
407  void *dev_private;
408  uint16_t num_queues;
409  struct rte_bbdev_queue_data *queues;
410  uint16_t dev_id;
411  int socket_id;
412  bool started;
413  uint16_t process_cnt;
414 };
415 
416 /* Forward declarations */
417 struct rte_bbdev_ops;
418 struct rte_bbdev_callback;
419 struct rte_intr_handle;
420 
422 RTE_TAILQ_HEAD(rte_bbdev_cb_list, rte_bbdev_callback);
423 
428 struct __rte_cache_aligned rte_bbdev {
430  rte_bbdev_enqueue_enc_ops_t enqueue_enc_ops;
432  rte_bbdev_enqueue_dec_ops_t enqueue_dec_ops;
434  rte_bbdev_dequeue_enc_ops_t dequeue_enc_ops;
436  rte_bbdev_dequeue_dec_ops_t dequeue_dec_ops;
438  rte_bbdev_enqueue_enc_ops_t enqueue_ldpc_enc_ops;
440  rte_bbdev_enqueue_dec_ops_t enqueue_ldpc_dec_ops;
442  rte_bbdev_dequeue_enc_ops_t dequeue_ldpc_enc_ops;
444  rte_bbdev_dequeue_dec_ops_t dequeue_ldpc_dec_ops;
445  const struct rte_bbdev_ops *dev_ops;
446  struct rte_bbdev_data *data;
447  enum rte_bbdev_state state;
448  struct rte_device *device;
450  struct rte_bbdev_cb_list list_cbs;
451  struct rte_intr_handle *intr_handle;
452 };
453 
455 extern struct rte_bbdev rte_bbdev_devices[];
456 
478 static inline uint16_t
479 rte_bbdev_enqueue_enc_ops(uint16_t dev_id, uint16_t queue_id,
480  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
481 {
482  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
483  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
484  return dev->enqueue_enc_ops(q_data, ops, num_ops);
485 }
486 
508 static inline uint16_t
509 rte_bbdev_enqueue_dec_ops(uint16_t dev_id, uint16_t queue_id,
510  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
511 {
512  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
513  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
514  return dev->enqueue_dec_ops(q_data, ops, num_ops);
515 }
516 
538 static inline uint16_t
539 rte_bbdev_enqueue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,
540  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
541 {
542  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
543  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
544  return dev->enqueue_ldpc_enc_ops(q_data, ops, num_ops);
545 }
546 
568 static inline uint16_t
569 rte_bbdev_enqueue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id,
570  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
571 {
572  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
573  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
574  return dev->enqueue_ldpc_dec_ops(q_data, ops, num_ops);
575 }
576 
577 
600 static inline uint16_t
601 rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id,
602  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
603 {
604  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
605  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
606  return dev->dequeue_enc_ops(q_data, ops, num_ops);
607 }
608 
632 static inline uint16_t
633 rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id,
634  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
635 {
636  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
637  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
638  return dev->dequeue_dec_ops(q_data, ops, num_ops);
639 }
640 
641 
663 static inline uint16_t
664 rte_bbdev_dequeue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,
665  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
666 {
667  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
668  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
669  return dev->dequeue_ldpc_enc_ops(q_data, ops, num_ops);
670 }
671 
693 static inline uint16_t
694 rte_bbdev_dequeue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id,
695  struct rte_bbdev_dec_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_ldpc_dec_ops(q_data, ops, num_ops);
700 }
701 
708 };
709 
723 typedef void (*rte_bbdev_cb_fn)(uint16_t dev_id,
724  enum rte_bbdev_event_type event, void *cb_arg,
725  void *ret_param);
726 
744 int
745 rte_bbdev_callback_register(uint16_t dev_id, enum rte_bbdev_event_type event,
746  rte_bbdev_cb_fn cb_fn, void *cb_arg);
747 
767 int
768 rte_bbdev_callback_unregister(uint16_t dev_id, enum rte_bbdev_event_type event,
769  rte_bbdev_cb_fn cb_fn, void *cb_arg);
770 
787 int
788 rte_bbdev_queue_intr_enable(uint16_t dev_id, uint16_t queue_id);
789 
803 int
804 rte_bbdev_queue_intr_disable(uint16_t dev_id, uint16_t queue_id);
805 
830 int
831 rte_bbdev_queue_intr_ctl(uint16_t dev_id, uint16_t queue_id, int epfd, int op,
832  void *data);
833 
834 #ifdef __cplusplus
835 }
836 #endif
837 
838 #endif /* _RTE_BBDEV_H_ */
uint64_t acc_offload_cycles
Definition: rte_bbdev.h:244
uint16_t num_queues
Definition: rte_bbdev.h:319
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:232
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:539
RTE_TAILQ_HEAD(rte_bbdev_cb_list, rte_bbdev_callback)
uint64_t dequeue_err_count
Definition: rte_bbdev.h:237
const char * driver_name
Definition: rte_bbdev.h:277
rte_bbdev_op_type
Definition: rte_bbdev_op.h:745
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:664
uint32_t harq_buffer_size
Definition: rte_bbdev.h:294
uint8_t max_dl_queue_priority
Definition: rte_bbdev.h:286
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:633
int rte_bbdev_queue_info_get(uint16_t dev_id, uint16_t queue_id, struct rte_bbdev_queue_info *queue_info)
uint16_t rte_bbdev_find_next(uint16_t dev_id)
uint16_t min_alignment
Definition: rte_bbdev.h:292
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:280
enum rte_bbdev_op_type op_type
Definition: rte_bbdev.h:134
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:509
bool rte_bbdev_is_valid(uint16_t dev_id)
#define RTE_BBDEV_NAME_MAX_LEN
Definition: rte_bbdev.h:397
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:601
uint32_t queue_size_lim
Definition: rte_bbdev.h:282
rte_bbdev_state
Definition: rte_bbdev.h:43
#define __rte_cache_aligned
Definition: rte_common.h:420
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:694
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:569
const char * dev_name
Definition: rte_bbdev.h:317
int rte_bbdev_stats_reset(uint16_t dev_id)
rte_bbdev_event_type
Definition: rte_bbdev.h:703
const struct rte_device * device
Definition: rte_bbdev.h:318
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:479
const struct rte_bbdev_op_cap * capabilities
Definition: rte_bbdev.h:302
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:288
enum rte_cpu_flag_t * cpu_flag_reqs
Definition: rte_bbdev.h:304
uint64_t enqueue_err_count
Definition: rte_bbdev.h:235
uint64_t dequeued_count
Definition: rte_bbdev.h:233
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:723
int rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id)