DPDK  22.11.0-rc0
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_cpuflags.h>
31 
32 #include "rte_bbdev_op.h"
33 
34 #ifndef RTE_BBDEV_MAX_DEVS
35 #define RTE_BBDEV_MAX_DEVS 128
36 #endif
37 
40  RTE_BBDEV_UNUSED,
41  RTE_BBDEV_INITIALIZED
42 };
43 
50 uint16_t
51 rte_bbdev_count(void);
52 
62 bool
63 rte_bbdev_is_valid(uint16_t dev_id);
64 
75 uint16_t
76 rte_bbdev_find_next(uint16_t dev_id);
77 
79 #define RTE_BBDEV_FOREACH(i) for (i = rte_bbdev_find_next(-1); \
80  i < RTE_BBDEV_MAX_DEVS; \
81  i = rte_bbdev_find_next(i))
82 
104 int
105 rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id);
106 
121 int
122 rte_bbdev_intr_enable(uint16_t dev_id);
123 
126  int socket;
127  uint32_t queue_size;
128  uint8_t priority;
131 };
132 
150 int
151 rte_bbdev_queue_configure(uint16_t dev_id, uint16_t queue_id,
152  const struct rte_bbdev_queue_conf *conf);
153 
165 int
166 rte_bbdev_start(uint16_t dev_id);
167 
178 int
179 rte_bbdev_stop(uint16_t dev_id);
180 
191 int
192 rte_bbdev_close(uint16_t dev_id);
193 
208 int
209 rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id);
210 
223 int
224 rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id);
225 
228  uint64_t enqueued_count;
229  uint64_t dequeued_count;
241 };
242 
256 int
257 rte_bbdev_stats_get(uint16_t dev_id, struct rte_bbdev_stats *stats);
258 
267 int
268 rte_bbdev_stats_reset(uint16_t dev_id);
269 
273  const char *driver_name;
274 
276  unsigned int max_num_queues;
278  uint32_t queue_size_lim;
288  uint16_t min_alignment;
296  struct rte_bbdev_queue_conf default_queue_conf;
300  const enum rte_cpu_flag_t *cpu_flag_reqs;
301 };
302 
304 #define RTE_BBDEV_END_OF_CAPABILITIES_LIST() \
305  { RTE_BBDEV_OP_NONE }
306 
312  int socket_id;
313  const char *dev_name;
314  const struct rte_device *device;
315  uint16_t num_queues;
316  bool started;
318 };
319 
333 int
334 rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info);
335 
339  struct rte_bbdev_queue_conf conf;
341  bool started;
342 };
343 
359 int
360 rte_bbdev_queue_info_get(uint16_t dev_id, uint16_t queue_id,
361  struct rte_bbdev_queue_info *queue_info);
362 
364 struct rte_bbdev_queue_data {
365  void *queue_private;
366  struct rte_bbdev_queue_conf conf;
367  struct rte_bbdev_stats queue_stats;
368  bool started;
369 };
370 
372 typedef uint16_t (*rte_bbdev_enqueue_enc_ops_t)(
373  struct rte_bbdev_queue_data *q_data,
374  struct rte_bbdev_enc_op **ops,
375  uint16_t num);
376 
378 typedef uint16_t (*rte_bbdev_enqueue_dec_ops_t)(
379  struct rte_bbdev_queue_data *q_data,
380  struct rte_bbdev_dec_op **ops,
381  uint16_t num);
382 
384 typedef uint16_t (*rte_bbdev_dequeue_enc_ops_t)(
385  struct rte_bbdev_queue_data *q_data,
386  struct rte_bbdev_enc_op **ops, uint16_t num);
387 
389 typedef uint16_t (*rte_bbdev_dequeue_dec_ops_t)(
390  struct rte_bbdev_queue_data *q_data,
391  struct rte_bbdev_dec_op **ops, uint16_t num);
392 
393 #define RTE_BBDEV_NAME_MAX_LEN 64
401 struct rte_bbdev_data {
402  char name[RTE_BBDEV_NAME_MAX_LEN];
403  void *dev_private;
404  uint16_t num_queues;
405  struct rte_bbdev_queue_data *queues;
406  uint16_t dev_id;
407  int socket_id;
408  bool started;
409  uint16_t process_cnt;
410 };
411 
412 /* Forward declarations */
413 struct rte_bbdev_ops;
414 struct rte_bbdev_callback;
415 struct rte_intr_handle;
416 
418 RTE_TAILQ_HEAD(rte_bbdev_cb_list, rte_bbdev_callback);
419 
424 struct __rte_cache_aligned rte_bbdev {
426  rte_bbdev_enqueue_enc_ops_t enqueue_enc_ops;
428  rte_bbdev_enqueue_dec_ops_t enqueue_dec_ops;
430  rte_bbdev_dequeue_enc_ops_t dequeue_enc_ops;
432  rte_bbdev_dequeue_dec_ops_t dequeue_dec_ops;
434  rte_bbdev_enqueue_enc_ops_t enqueue_ldpc_enc_ops;
436  rte_bbdev_enqueue_dec_ops_t enqueue_ldpc_dec_ops;
438  rte_bbdev_dequeue_enc_ops_t dequeue_ldpc_enc_ops;
440  rte_bbdev_dequeue_dec_ops_t dequeue_ldpc_dec_ops;
441  const struct rte_bbdev_ops *dev_ops;
442  struct rte_bbdev_data *data;
443  enum rte_bbdev_state state;
444  struct rte_device *device;
446  struct rte_bbdev_cb_list list_cbs;
447  struct rte_intr_handle *intr_handle;
448 };
449 
451 extern struct rte_bbdev rte_bbdev_devices[];
452 
474 static inline uint16_t
475 rte_bbdev_enqueue_enc_ops(uint16_t dev_id, uint16_t queue_id,
476  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
477 {
478  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
479  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
480  return dev->enqueue_enc_ops(q_data, ops, num_ops);
481 }
482 
504 static inline uint16_t
505 rte_bbdev_enqueue_dec_ops(uint16_t dev_id, uint16_t queue_id,
506  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
507 {
508  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
509  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
510  return dev->enqueue_dec_ops(q_data, ops, num_ops);
511 }
512 
534 static inline uint16_t
535 rte_bbdev_enqueue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,
536  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
537 {
538  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
539  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
540  return dev->enqueue_ldpc_enc_ops(q_data, ops, num_ops);
541 }
542 
564 static inline uint16_t
565 rte_bbdev_enqueue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id,
566  struct rte_bbdev_dec_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_ldpc_dec_ops(q_data, ops, num_ops);
571 }
572 
573 
596 static inline uint16_t
597 rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id,
598  struct rte_bbdev_enc_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->dequeue_enc_ops(q_data, ops, num_ops);
603 }
604 
628 static inline uint16_t
629 rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id,
630  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
631 {
632  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
633  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
634  return dev->dequeue_dec_ops(q_data, ops, num_ops);
635 }
636 
637 
659 static inline uint16_t
660 rte_bbdev_dequeue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,
661  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
662 {
663  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
664  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
665  return dev->dequeue_ldpc_enc_ops(q_data, ops, num_ops);
666 }
667 
689 static inline uint16_t
690 rte_bbdev_dequeue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id,
691  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
692 {
693  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
694  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
695  return dev->dequeue_ldpc_dec_ops(q_data, ops, num_ops);
696 }
697 
704 };
705 
719 typedef void (*rte_bbdev_cb_fn)(uint16_t dev_id,
720  enum rte_bbdev_event_type event, void *cb_arg,
721  void *ret_param);
722 
740 int
741 rte_bbdev_callback_register(uint16_t dev_id, enum rte_bbdev_event_type event,
742  rte_bbdev_cb_fn cb_fn, void *cb_arg);
743 
763 int
764 rte_bbdev_callback_unregister(uint16_t dev_id, enum rte_bbdev_event_type event,
765  rte_bbdev_cb_fn cb_fn, void *cb_arg);
766 
783 int
784 rte_bbdev_queue_intr_enable(uint16_t dev_id, uint16_t queue_id);
785 
799 int
800 rte_bbdev_queue_intr_disable(uint16_t dev_id, uint16_t queue_id);
801 
826 int
827 rte_bbdev_queue_intr_ctl(uint16_t dev_id, uint16_t queue_id, int epfd, int op,
828  void *data);
829 
830 #ifdef __cplusplus
831 }
832 #endif
833 
834 #endif /* _RTE_BBDEV_H_ */
uint64_t acc_offload_cycles
Definition: rte_bbdev.h:240
uint16_t num_queues
Definition: rte_bbdev.h:315
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:228
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:535
RTE_TAILQ_HEAD(rte_bbdev_cb_list, rte_bbdev_callback)
uint64_t dequeue_err_count
Definition: rte_bbdev.h:233
const char * driver_name
Definition: rte_bbdev.h:273
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:660
uint32_t harq_buffer_size
Definition: rte_bbdev.h:290
uint8_t max_dl_queue_priority
Definition: rte_bbdev.h:282
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:629
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:288
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:276
enum rte_bbdev_op_type op_type
Definition: rte_bbdev.h:130
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:505
bool rte_bbdev_is_valid(uint16_t dev_id)
#define RTE_BBDEV_NAME_MAX_LEN
Definition: rte_bbdev.h:393
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:597
uint32_t queue_size_lim
Definition: rte_bbdev.h:278
rte_bbdev_state
Definition: rte_bbdev.h:39
#define __rte_cache_aligned
Definition: rte_common.h:440
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:690
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:565
const char * dev_name
Definition: rte_bbdev.h:313
int rte_bbdev_stats_reset(uint16_t dev_id)
rte_bbdev_event_type
Definition: rte_bbdev.h:699
const struct rte_device * device
Definition: rte_bbdev.h:314
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:475
const struct rte_bbdev_op_cap * capabilities
Definition: rte_bbdev.h:298
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:284
enum rte_cpu_flag_t * cpu_flag_reqs
Definition: rte_bbdev.h:300
uint64_t enqueue_err_count
Definition: rte_bbdev.h:231
uint64_t dequeued_count
Definition: rte_bbdev.h:229
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:719
int rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id)