DPDK  20.05.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 
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;
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 
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;
429  rte_atomic16_t process_cnt;
430 };
431 
432 /* Forward declarations */
433 struct rte_bbdev_ops;
434 struct rte_bbdev_callback;
435 struct rte_intr_handle;
436 
438 TAILQ_HEAD(rte_bbdev_cb_list, rte_bbdev_callback);
439 
444 struct __rte_cache_aligned rte_bbdev {
446  rte_bbdev_enqueue_enc_ops_t enqueue_enc_ops;
448  rte_bbdev_enqueue_dec_ops_t enqueue_dec_ops;
450  rte_bbdev_dequeue_enc_ops_t dequeue_enc_ops;
452  rte_bbdev_dequeue_dec_ops_t dequeue_dec_ops;
454  rte_bbdev_enqueue_enc_ops_t enqueue_ldpc_enc_ops;
456  rte_bbdev_enqueue_dec_ops_t enqueue_ldpc_dec_ops;
458  rte_bbdev_dequeue_enc_ops_t dequeue_ldpc_enc_ops;
460  rte_bbdev_dequeue_dec_ops_t dequeue_ldpc_dec_ops;
461  const struct rte_bbdev_ops *dev_ops;
462  struct rte_bbdev_data *data;
463  enum rte_bbdev_state state;
464  struct rte_device *device;
466  struct rte_bbdev_cb_list list_cbs;
467  struct rte_intr_handle *intr_handle;
468 };
469 
471 extern struct rte_bbdev rte_bbdev_devices[];
472 
494 __rte_experimental
495 static inline uint16_t
496 rte_bbdev_enqueue_enc_ops(uint16_t dev_id, uint16_t queue_id,
497  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
498 {
499  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
500  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
501  return dev->enqueue_enc_ops(q_data, ops, num_ops);
502 }
503 
525 __rte_experimental
526 static inline uint16_t
527 rte_bbdev_enqueue_dec_ops(uint16_t dev_id, uint16_t queue_id,
528  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
529 {
530  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
531  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
532  return dev->enqueue_dec_ops(q_data, ops, num_ops);
533 }
534 
556 __rte_experimental
557 static inline uint16_t
558 rte_bbdev_enqueue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,
559  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
560 {
561  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
562  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
563  return dev->enqueue_ldpc_enc_ops(q_data, ops, num_ops);
564 }
565 
587 __rte_experimental
588 static inline uint16_t
589 rte_bbdev_enqueue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id,
590  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
591 {
592  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
593  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
594  return dev->enqueue_ldpc_dec_ops(q_data, ops, num_ops);
595 }
596 
597 
620 __rte_experimental
621 static inline uint16_t
622 rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id,
623  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
624 {
625  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
626  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
627  return dev->dequeue_enc_ops(q_data, ops, num_ops);
628 }
629 
653 __rte_experimental
654 static inline uint16_t
655 rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id,
656  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
657 {
658  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
659  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
660  return dev->dequeue_dec_ops(q_data, ops, num_ops);
661 }
662 
663 
685 __rte_experimental
686 static inline uint16_t
687 rte_bbdev_dequeue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,
688  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
689 {
690  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
691  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
692  return dev->dequeue_ldpc_enc_ops(q_data, ops, num_ops);
693 }
694 
716 __rte_experimental
717 static inline uint16_t
718 rte_bbdev_dequeue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id,
719  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
720 {
721  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
722  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
723  return dev->dequeue_ldpc_dec_ops(q_data, ops, num_ops);
724 }
725 
732 };
733 
747 typedef void (*rte_bbdev_cb_fn)(uint16_t dev_id,
748  enum rte_bbdev_event_type event, void *cb_arg,
749  void *ret_param);
750 
768 __rte_experimental
769 int
770 rte_bbdev_callback_register(uint16_t dev_id, enum rte_bbdev_event_type event,
771  rte_bbdev_cb_fn cb_fn, void *cb_arg);
772 
792 __rte_experimental
793 int
794 rte_bbdev_callback_unregister(uint16_t dev_id, enum rte_bbdev_event_type event,
795  rte_bbdev_cb_fn cb_fn, void *cb_arg);
796 
813 __rte_experimental
814 int
815 rte_bbdev_queue_intr_enable(uint16_t dev_id, uint16_t queue_id);
816 
830 __rte_experimental
831 int
832 rte_bbdev_queue_intr_disable(uint16_t dev_id, uint16_t queue_id);
833 
858 __rte_experimental
859 int
860 rte_bbdev_queue_intr_ctl(uint16_t dev_id, uint16_t queue_id, int epfd, int op,
861  void *data);
862 
863 #ifdef __cplusplus
864 }
865 #endif
866 
867 #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:655
struct rte_bbdev_driver_info drv
Definition: rte_bbdev.h:334
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:558
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:589
__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:622
__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
struct rte_bbdev_queue_conf conf
Definition: rte_bbdev.h:357
__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:727
__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:687
#define __rte_cache_aligned
Definition: rte_common.h:367
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:718
__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:527
__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:496
struct rte_bbdev_queue_conf default_queue_conf
Definition: rte_bbdev.h:313
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:747