DPDK  19.08.2
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 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #include <stdint.h>
31 #include <stdbool.h>
32 #include <string.h>
33 
34 #include <rte_compat.h>
35 #include <rte_atomic.h>
36 #include <rte_bus.h>
37 #include <rte_cpuflags.h>
38 #include <rte_memory.h>
39 
40 #include "rte_bbdev_op.h"
41 
42 #ifndef RTE_BBDEV_MAX_DEVS
43 #define RTE_BBDEV_MAX_DEVS 128
44 #endif
45 
48  RTE_BBDEV_UNUSED,
49  RTE_BBDEV_INITIALIZED
50 };
51 
58 __rte_experimental
59 uint16_t
60 rte_bbdev_count(void);
61 
71 __rte_experimental
72 bool
73 rte_bbdev_is_valid(uint16_t dev_id);
74 
85 __rte_experimental
86 uint16_t
87 rte_bbdev_find_next(uint16_t dev_id);
88 
90 #define RTE_BBDEV_FOREACH(i) for (i = rte_bbdev_find_next(-1); \
91  i < RTE_BBDEV_MAX_DEVS; \
92  i = rte_bbdev_find_next(i))
93 
115 __rte_experimental
116 int
117 rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id);
118 
133 __rte_experimental
134 int
135 rte_bbdev_intr_enable(uint16_t dev_id);
136 
139  int socket;
140  uint32_t queue_size;
141  uint8_t priority;
144 };
145 
163 __rte_experimental
164 int
165 rte_bbdev_queue_configure(uint16_t dev_id, uint16_t queue_id,
166  const struct rte_bbdev_queue_conf *conf);
167 
179 __rte_experimental
180 int
181 rte_bbdev_start(uint16_t dev_id);
182 
193 __rte_experimental
194 int
195 rte_bbdev_stop(uint16_t dev_id);
196 
207 __rte_experimental
208 int
209 rte_bbdev_close(uint16_t dev_id);
210 
225 __rte_experimental
226 int
227 rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id);
228 
241 __rte_experimental
242 int
243 rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id);
244 
247  uint64_t enqueued_count;
248  uint64_t dequeued_count;
260 };
261 
275 __rte_experimental
276 int
277 rte_bbdev_stats_get(uint16_t dev_id, struct rte_bbdev_stats *stats);
278 
287 __rte_experimental
288 int
289 rte_bbdev_stats_reset(uint16_t dev_id);
290 
294  const char *driver_name;
295 
297  unsigned int max_num_queues;
299  uint32_t queue_size_lim;
309  uint16_t min_alignment;
315  const enum rte_cpu_flag_t *cpu_flag_reqs;
316 };
317 
319 #define RTE_BBDEV_END_OF_CAPABILITIES_LIST() \
320  { RTE_BBDEV_OP_NONE }
321 
327  int socket_id;
328  const char *dev_name;
329  const struct rte_device *device;
330  uint16_t num_queues;
331  bool started;
333 };
334 
348 __rte_experimental
349 int
350 rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info);
351 
357  bool started;
358 };
359 
375 __rte_experimental
376 int
377 rte_bbdev_queue_info_get(uint16_t dev_id, uint16_t queue_id,
378  struct rte_bbdev_queue_info *queue_info);
379 
381 struct rte_bbdev_queue_data {
382  void *queue_private;
383  struct rte_bbdev_queue_conf conf;
384  struct rte_bbdev_stats queue_stats;
385  bool started;
386 };
387 
389 typedef uint16_t (*rte_bbdev_enqueue_enc_ops_t)(
390  struct rte_bbdev_queue_data *q_data,
391  struct rte_bbdev_enc_op **ops,
392  uint16_t num);
393 
395 typedef uint16_t (*rte_bbdev_enqueue_dec_ops_t)(
396  struct rte_bbdev_queue_data *q_data,
397  struct rte_bbdev_dec_op **ops,
398  uint16_t num);
399 
401 typedef uint16_t (*rte_bbdev_dequeue_enc_ops_t)(
402  struct rte_bbdev_queue_data *q_data,
403  struct rte_bbdev_enc_op **ops, uint16_t num);
404 
406 typedef uint16_t (*rte_bbdev_dequeue_dec_ops_t)(
407  struct rte_bbdev_queue_data *q_data,
408  struct rte_bbdev_dec_op **ops, uint16_t num);
409 
410 #define RTE_BBDEV_NAME_MAX_LEN 64
418 struct rte_bbdev_data {
419  char name[RTE_BBDEV_NAME_MAX_LEN];
420  void *dev_private;
421  uint16_t num_queues;
422  struct rte_bbdev_queue_data *queues;
423  uint16_t dev_id;
424  int socket_id;
425  bool started;
427  rte_atomic16_t process_cnt;
428 };
429 
430 /* Forward declarations */
431 struct rte_bbdev_ops;
432 struct rte_bbdev_callback;
433 struct rte_intr_handle;
434 
436 TAILQ_HEAD(rte_bbdev_cb_list, rte_bbdev_callback);
437 
442 struct __rte_cache_aligned rte_bbdev {
444  rte_bbdev_enqueue_enc_ops_t enqueue_enc_ops;
446  rte_bbdev_enqueue_dec_ops_t enqueue_dec_ops;
448  rte_bbdev_dequeue_enc_ops_t dequeue_enc_ops;
450  rte_bbdev_dequeue_dec_ops_t dequeue_dec_ops;
452  rte_bbdev_enqueue_enc_ops_t enqueue_ldpc_enc_ops;
454  rte_bbdev_enqueue_dec_ops_t enqueue_ldpc_dec_ops;
456  rte_bbdev_dequeue_enc_ops_t dequeue_ldpc_enc_ops;
458  rte_bbdev_dequeue_dec_ops_t dequeue_ldpc_dec_ops;
459  const struct rte_bbdev_ops *dev_ops;
460  struct rte_bbdev_data *data;
461  enum rte_bbdev_state state;
462  struct rte_device *device;
464  struct rte_bbdev_cb_list list_cbs;
465  struct rte_intr_handle *intr_handle;
466 };
467 
469 extern struct rte_bbdev rte_bbdev_devices[];
470 
492 __rte_experimental
493 static inline uint16_t
494 rte_bbdev_enqueue_enc_ops(uint16_t dev_id, uint16_t queue_id,
495  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
496 {
497  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
498  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
499  return dev->enqueue_enc_ops(q_data, ops, num_ops);
500 }
501 
523 __rte_experimental
524 static inline uint16_t
525 rte_bbdev_enqueue_dec_ops(uint16_t dev_id, uint16_t queue_id,
526  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
527 {
528  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
529  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
530  return dev->enqueue_dec_ops(q_data, ops, num_ops);
531 }
532 
554 __rte_experimental
555 static inline uint16_t
556 rte_bbdev_enqueue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,
557  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
558 {
559  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
560  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
561  return dev->enqueue_ldpc_enc_ops(q_data, ops, num_ops);
562 }
563 
585 __rte_experimental
586 static inline uint16_t
587 rte_bbdev_enqueue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id,
588  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
589 {
590  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
591  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
592  return dev->enqueue_ldpc_dec_ops(q_data, ops, num_ops);
593 }
594 
595 
617 __rte_experimental
618 static inline uint16_t
619 rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id,
620  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
621 {
622  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
623  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
624  return dev->dequeue_enc_ops(q_data, ops, num_ops);
625 }
626 
649 __rte_experimental
650 static inline uint16_t
651 rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id,
652  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
653 {
654  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
655  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
656  return dev->dequeue_dec_ops(q_data, ops, num_ops);
657 }
658 
659 
681 __rte_experimental
682 static inline uint16_t
683 rte_bbdev_dequeue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,
684  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
685 {
686  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
687  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
688  return dev->dequeue_ldpc_enc_ops(q_data, ops, num_ops);
689 }
690 
712 __rte_experimental
713 static inline uint16_t
714 rte_bbdev_dequeue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id,
715  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
716 {
717  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
718  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
719  return dev->dequeue_ldpc_dec_ops(q_data, ops, num_ops);
720 }
721 
728 };
729 
743 typedef void (*rte_bbdev_cb_fn)(uint16_t dev_id,
744  enum rte_bbdev_event_type event, void *cb_arg,
745  void *ret_param);
746 
764 __rte_experimental
765 int
766 rte_bbdev_callback_register(uint16_t dev_id, enum rte_bbdev_event_type event,
767  rte_bbdev_cb_fn cb_fn, void *cb_arg);
768 
788 __rte_experimental
789 int
790 rte_bbdev_callback_unregister(uint16_t dev_id, enum rte_bbdev_event_type event,
791  rte_bbdev_cb_fn cb_fn, void *cb_arg);
792 
809 __rte_experimental
810 int
811 rte_bbdev_queue_intr_enable(uint16_t dev_id, uint16_t queue_id);
812 
826 __rte_experimental
827 int
828 rte_bbdev_queue_intr_disable(uint16_t dev_id, uint16_t queue_id);
829 
854 __rte_experimental
855 int
856 rte_bbdev_queue_intr_ctl(uint16_t dev_id, uint16_t queue_id, int epfd, int op,
857  void *data);
858 
859 #ifdef __cplusplus
860 }
861 #endif
862 
863 #endif /* _RTE_BBDEV_H_ */
uint64_t acc_offload_cycles
Definition: rte_bbdev.h:259
uint16_t num_queues
Definition: rte_bbdev.h:330
__rte_experimental int rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info)
__rte_experimental int rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id)
TAILQ_HEAD(rte_bbdev_cb_list, rte_bbdev_callback)
__rte_experimental int rte_bbdev_intr_enable(uint16_t dev_id)
uint64_t enqueued_count
Definition: rte_bbdev.h:247
uint64_t dequeue_err_count
Definition: rte_bbdev.h:252
const char * driver_name
Definition: rte_bbdev.h:294
rte_bbdev_op_type
Definition: rte_bbdev_op.h:728
__rte_experimental 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_dl_queue_priority
Definition: rte_bbdev.h:303
static __rte_experimental 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:651
struct rte_bbdev_driver_info drv
Definition: rte_bbdev.h:332
uint16_t min_alignment
Definition: rte_bbdev.h:309
__rte_experimental int rte_bbdev_stats_get(uint16_t dev_id, struct rte_bbdev_stats *stats)
static __rte_experimental 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:556
unsigned int max_num_queues
Definition: rte_bbdev.h:297
enum rte_bbdev_op_type op_type
Definition: rte_bbdev.h:143
__rte_experimental int rte_bbdev_stats_reset(uint16_t dev_id)
static __rte_experimental 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:587
__rte_experimental int rte_bbdev_queue_info_get(uint16_t dev_id, uint16_t queue_id, struct rte_bbdev_queue_info *queue_info)
__rte_experimental int rte_bbdev_callback_unregister(uint16_t dev_id, enum rte_bbdev_event_type event, rte_bbdev_cb_fn cb_fn, void *cb_arg)
__rte_experimental int rte_bbdev_close(uint16_t dev_id)
static __rte_experimental 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:619
__rte_experimental int rte_bbdev_stop(uint16_t dev_id)
__rte_experimental int rte_bbdev_queue_intr_enable(uint16_t dev_id, uint16_t queue_id)
#define RTE_BBDEV_NAME_MAX_LEN
Definition: rte_bbdev.h:410
uint32_t queue_size_lim
Definition: rte_bbdev.h:299
rte_bbdev_state
Definition: rte_bbdev.h:47
struct rte_bbdev_queue_conf conf
Definition: rte_bbdev.h:355
__rte_experimental int rte_bbdev_queue_configure(uint16_t dev_id, uint16_t queue_id, const struct rte_bbdev_queue_conf *conf)
#define __rte_cache_aligned
Definition: rte_memory.h:64
__rte_experimental int rte_bbdev_queue_intr_ctl(uint16_t dev_id, uint16_t queue_id, int epfd, int op, void *data)
__rte_experimental int rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id)
const char * dev_name
Definition: rte_bbdev.h:328
rte_bbdev_event_type
Definition: rte_bbdev.h:723
__rte_experimental uint16_t rte_bbdev_find_next(uint16_t dev_id)
static __rte_experimental 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:683
static __rte_experimental 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:714
__rte_experimental uint16_t rte_bbdev_count(void)
const struct rte_device * device
Definition: rte_bbdev.h:329
__rte_experimental int rte_bbdev_queue_intr_disable(uint16_t dev_id, uint16_t queue_id)
__rte_experimental int rte_bbdev_start(uint16_t dev_id)
static __rte_experimental 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:525
__rte_experimental int rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id)
const struct rte_bbdev_op_cap * capabilities
Definition: rte_bbdev.h:313
static __rte_experimental 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:494
struct rte_bbdev_queue_conf default_queue_conf
Definition: rte_bbdev.h:311
uint8_t max_ul_queue_priority
Definition: rte_bbdev.h:305
enum rte_cpu_flag_t * cpu_flag_reqs
Definition: rte_bbdev.h:315
__rte_experimental bool rte_bbdev_is_valid(uint16_t dev_id)
uint64_t enqueue_err_count
Definition: rte_bbdev.h:250
uint64_t dequeued_count
Definition: rte_bbdev.h:248
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:743