DPDK  20.11.3
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 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #include <stdint.h>
32 #include <stdbool.h>
33 #include <string.h>
34 
35 #include <rte_compat.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;
313  struct rte_bbdev_queue_conf default_queue_conf;
317  const enum rte_cpu_flag_t *cpu_flag_reqs;
318 };
319 
321 #define RTE_BBDEV_END_OF_CAPABILITIES_LIST() \
322  { RTE_BBDEV_OP_NONE }
323 
329  int socket_id;
330  const char *dev_name;
331  const struct rte_device *device;
332  uint16_t num_queues;
333  bool started;
335 };
336 
350 __rte_experimental
351 int
352 rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info);
353 
357  struct rte_bbdev_queue_conf conf;
359  bool started;
360 };
361 
377 __rte_experimental
378 int
379 rte_bbdev_queue_info_get(uint16_t dev_id, uint16_t queue_id,
380  struct rte_bbdev_queue_info *queue_info);
381 
383 struct rte_bbdev_queue_data {
384  void *queue_private;
385  struct rte_bbdev_queue_conf conf;
386  struct rte_bbdev_stats queue_stats;
387  bool started;
388 };
389 
391 typedef uint16_t (*rte_bbdev_enqueue_enc_ops_t)(
392  struct rte_bbdev_queue_data *q_data,
393  struct rte_bbdev_enc_op **ops,
394  uint16_t num);
395 
397 typedef uint16_t (*rte_bbdev_enqueue_dec_ops_t)(
398  struct rte_bbdev_queue_data *q_data,
399  struct rte_bbdev_dec_op **ops,
400  uint16_t num);
401 
403 typedef uint16_t (*rte_bbdev_dequeue_enc_ops_t)(
404  struct rte_bbdev_queue_data *q_data,
405  struct rte_bbdev_enc_op **ops, uint16_t num);
406 
408 typedef uint16_t (*rte_bbdev_dequeue_dec_ops_t)(
409  struct rte_bbdev_queue_data *q_data,
410  struct rte_bbdev_dec_op **ops, uint16_t num);
411 
412 #define RTE_BBDEV_NAME_MAX_LEN 64
420 struct rte_bbdev_data {
421  char name[RTE_BBDEV_NAME_MAX_LEN];
422  void *dev_private;
423  uint16_t num_queues;
424  struct rte_bbdev_queue_data *queues;
425  uint16_t dev_id;
426  int socket_id;
427  bool started;
428  uint16_t process_cnt;
429 };
430 
431 /* Forward declarations */
432 struct rte_bbdev_ops;
433 struct rte_bbdev_callback;
434 struct rte_intr_handle;
435 
437 TAILQ_HEAD(rte_bbdev_cb_list, rte_bbdev_callback);
438 
443 struct __rte_cache_aligned rte_bbdev {
445  rte_bbdev_enqueue_enc_ops_t enqueue_enc_ops;
447  rte_bbdev_enqueue_dec_ops_t enqueue_dec_ops;
449  rte_bbdev_dequeue_enc_ops_t dequeue_enc_ops;
451  rte_bbdev_dequeue_dec_ops_t dequeue_dec_ops;
453  rte_bbdev_enqueue_enc_ops_t enqueue_ldpc_enc_ops;
455  rte_bbdev_enqueue_dec_ops_t enqueue_ldpc_dec_ops;
457  rte_bbdev_dequeue_enc_ops_t dequeue_ldpc_enc_ops;
459  rte_bbdev_dequeue_dec_ops_t dequeue_ldpc_dec_ops;
460  const struct rte_bbdev_ops *dev_ops;
461  struct rte_bbdev_data *data;
462  enum rte_bbdev_state state;
463  struct rte_device *device;
465  struct rte_bbdev_cb_list list_cbs;
466  struct rte_intr_handle *intr_handle;
467 };
468 
470 extern struct rte_bbdev rte_bbdev_devices[];
471 
493 __rte_experimental
494 static inline uint16_t
495 rte_bbdev_enqueue_enc_ops(uint16_t dev_id, uint16_t queue_id,
496  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
497 {
498  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
499  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
500  return dev->enqueue_enc_ops(q_data, ops, num_ops);
501 }
502 
524 __rte_experimental
525 static inline uint16_t
526 rte_bbdev_enqueue_dec_ops(uint16_t dev_id, uint16_t queue_id,
527  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
528 {
529  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
530  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
531  return dev->enqueue_dec_ops(q_data, ops, num_ops);
532 }
533 
555 __rte_experimental
556 static inline uint16_t
557 rte_bbdev_enqueue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,
558  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
559 {
560  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
561  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
562  return dev->enqueue_ldpc_enc_ops(q_data, ops, num_ops);
563 }
564 
586 __rte_experimental
587 static inline uint16_t
588 rte_bbdev_enqueue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id,
589  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
590 {
591  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
592  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
593  return dev->enqueue_ldpc_dec_ops(q_data, ops, num_ops);
594 }
595 
596 
619 __rte_experimental
620 static inline uint16_t
621 rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id,
622  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
623 {
624  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
625  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
626  return dev->dequeue_enc_ops(q_data, ops, num_ops);
627 }
628 
652 __rte_experimental
653 static inline uint16_t
654 rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id,
655  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
656 {
657  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
658  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
659  return dev->dequeue_dec_ops(q_data, ops, num_ops);
660 }
661 
662 
684 __rte_experimental
685 static inline uint16_t
686 rte_bbdev_dequeue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,
687  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
688 {
689  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
690  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
691  return dev->dequeue_ldpc_enc_ops(q_data, ops, num_ops);
692 }
693 
715 __rte_experimental
716 static inline uint16_t
717 rte_bbdev_dequeue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id,
718  struct rte_bbdev_dec_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->dequeue_ldpc_dec_ops(q_data, ops, num_ops);
723 }
724 
731 };
732 
746 typedef void (*rte_bbdev_cb_fn)(uint16_t dev_id,
747  enum rte_bbdev_event_type event, void *cb_arg,
748  void *ret_param);
749 
767 __rte_experimental
768 int
769 rte_bbdev_callback_register(uint16_t dev_id, enum rte_bbdev_event_type event,
770  rte_bbdev_cb_fn cb_fn, void *cb_arg);
771 
791 __rte_experimental
792 int
793 rte_bbdev_callback_unregister(uint16_t dev_id, enum rte_bbdev_event_type event,
794  rte_bbdev_cb_fn cb_fn, void *cb_arg);
795 
812 __rte_experimental
813 int
814 rte_bbdev_queue_intr_enable(uint16_t dev_id, uint16_t queue_id);
815 
829 __rte_experimental
830 int
831 rte_bbdev_queue_intr_disable(uint16_t dev_id, uint16_t queue_id);
832 
857 __rte_experimental
858 int
859 rte_bbdev_queue_intr_ctl(uint16_t dev_id, uint16_t queue_id, int epfd, int op,
860  void *data);
861 
862 #ifdef __cplusplus
863 }
864 #endif
865 
866 #endif /* _RTE_BBDEV_H_ */
uint64_t acc_offload_cycles
Definition: rte_bbdev.h:259
uint16_t num_queues
Definition: rte_bbdev.h:332
__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:735
__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)
uint32_t harq_buffer_size
Definition: rte_bbdev.h:311
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:654
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:557
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:588
__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:621
__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:412
uint32_t queue_size_lim
Definition: rte_bbdev.h:299
rte_bbdev_state
Definition: rte_bbdev.h:47
#define __rte_cache_aligned
Definition: rte_common.h:400
__rte_experimental int rte_bbdev_queue_configure(uint16_t dev_id, uint16_t queue_id, const struct rte_bbdev_queue_conf *conf)
__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:330
rte_bbdev_event_type
Definition: rte_bbdev.h:726
__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:686
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:717
__rte_experimental uint16_t rte_bbdev_count(void)
const struct rte_device * device
Definition: rte_bbdev.h:331
__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:526
__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:315
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:495
uint8_t max_ul_queue_priority
Definition: rte_bbdev.h:305
enum rte_cpu_flag_t * cpu_flag_reqs
Definition: rte_bbdev.h:317
__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:746