DPDK  20.08.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 
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_atomic.h>
37 #include <rte_bus.h>
38 #include <rte_cpuflags.h>
39 #include <rte_memory.h>
40 
41 #include "rte_bbdev_op.h"
42 
43 #ifndef RTE_BBDEV_MAX_DEVS
44 #define RTE_BBDEV_MAX_DEVS 128
45 #endif
46 
49  RTE_BBDEV_UNUSED,
50  RTE_BBDEV_INITIALIZED
51 };
52 
59 __rte_experimental
60 uint16_t
61 rte_bbdev_count(void);
62 
72 __rte_experimental
73 bool
74 rte_bbdev_is_valid(uint16_t dev_id);
75 
86 __rte_experimental
87 uint16_t
88 rte_bbdev_find_next(uint16_t dev_id);
89 
91 #define RTE_BBDEV_FOREACH(i) for (i = rte_bbdev_find_next(-1); \
92  i < RTE_BBDEV_MAX_DEVS; \
93  i = rte_bbdev_find_next(i))
94 
116 __rte_experimental
117 int
118 rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id);
119 
134 __rte_experimental
135 int
136 rte_bbdev_intr_enable(uint16_t dev_id);
137 
140  int socket;
141  uint32_t queue_size;
142  uint8_t priority;
145 };
146 
164 __rte_experimental
165 int
166 rte_bbdev_queue_configure(uint16_t dev_id, uint16_t queue_id,
167  const struct rte_bbdev_queue_conf *conf);
168 
180 __rte_experimental
181 int
182 rte_bbdev_start(uint16_t dev_id);
183 
194 __rte_experimental
195 int
196 rte_bbdev_stop(uint16_t dev_id);
197 
208 __rte_experimental
209 int
210 rte_bbdev_close(uint16_t dev_id);
211 
226 __rte_experimental
227 int
228 rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id);
229 
242 __rte_experimental
243 int
244 rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id);
245 
248  uint64_t enqueued_count;
249  uint64_t dequeued_count;
261 };
262 
276 __rte_experimental
277 int
278 rte_bbdev_stats_get(uint16_t dev_id, struct rte_bbdev_stats *stats);
279 
288 __rte_experimental
289 int
290 rte_bbdev_stats_reset(uint16_t dev_id);
291 
295  const char *driver_name;
296 
298  unsigned int max_num_queues;
300  uint32_t queue_size_lim;
310  uint16_t min_alignment;
318  const enum rte_cpu_flag_t *cpu_flag_reqs;
319 };
320 
322 #define RTE_BBDEV_END_OF_CAPABILITIES_LIST() \
323  { RTE_BBDEV_OP_NONE }
324 
330  int socket_id;
331  const char *dev_name;
332  const struct rte_device *device;
333  uint16_t num_queues;
334  bool started;
336 };
337 
351 __rte_experimental
352 int
353 rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info);
354 
360  bool started;
361 };
362 
378 __rte_experimental
379 int
380 rte_bbdev_queue_info_get(uint16_t dev_id, uint16_t queue_id,
381  struct rte_bbdev_queue_info *queue_info);
382 
384 struct rte_bbdev_queue_data {
385  void *queue_private;
386  struct rte_bbdev_queue_conf conf;
387  struct rte_bbdev_stats queue_stats;
388  bool started;
389 };
390 
392 typedef uint16_t (*rte_bbdev_enqueue_enc_ops_t)(
393  struct rte_bbdev_queue_data *q_data,
394  struct rte_bbdev_enc_op **ops,
395  uint16_t num);
396 
398 typedef uint16_t (*rte_bbdev_enqueue_dec_ops_t)(
399  struct rte_bbdev_queue_data *q_data,
400  struct rte_bbdev_dec_op **ops,
401  uint16_t num);
402 
404 typedef uint16_t (*rte_bbdev_dequeue_enc_ops_t)(
405  struct rte_bbdev_queue_data *q_data,
406  struct rte_bbdev_enc_op **ops, uint16_t num);
407 
409 typedef uint16_t (*rte_bbdev_dequeue_dec_ops_t)(
410  struct rte_bbdev_queue_data *q_data,
411  struct rte_bbdev_dec_op **ops, uint16_t num);
412 
413 #define RTE_BBDEV_NAME_MAX_LEN 64
421 struct rte_bbdev_data {
422  char name[RTE_BBDEV_NAME_MAX_LEN];
423  void *dev_private;
424  uint16_t num_queues;
425  struct rte_bbdev_queue_data *queues;
426  uint16_t dev_id;
427  int socket_id;
428  bool started;
430  rte_atomic16_t process_cnt;
431 };
432 
433 /* Forward declarations */
434 struct rte_bbdev_ops;
435 struct rte_bbdev_callback;
436 struct rte_intr_handle;
437 
439 TAILQ_HEAD(rte_bbdev_cb_list, rte_bbdev_callback);
440 
445 struct __rte_cache_aligned rte_bbdev {
447  rte_bbdev_enqueue_enc_ops_t enqueue_enc_ops;
449  rte_bbdev_enqueue_dec_ops_t enqueue_dec_ops;
451  rte_bbdev_dequeue_enc_ops_t dequeue_enc_ops;
453  rte_bbdev_dequeue_dec_ops_t dequeue_dec_ops;
455  rte_bbdev_enqueue_enc_ops_t enqueue_ldpc_enc_ops;
457  rte_bbdev_enqueue_dec_ops_t enqueue_ldpc_dec_ops;
459  rte_bbdev_dequeue_enc_ops_t dequeue_ldpc_enc_ops;
461  rte_bbdev_dequeue_dec_ops_t dequeue_ldpc_dec_ops;
462  const struct rte_bbdev_ops *dev_ops;
463  struct rte_bbdev_data *data;
464  enum rte_bbdev_state state;
465  struct rte_device *device;
467  struct rte_bbdev_cb_list list_cbs;
468  struct rte_intr_handle *intr_handle;
469 };
470 
472 extern struct rte_bbdev rte_bbdev_devices[];
473 
495 __rte_experimental
496 static inline uint16_t
497 rte_bbdev_enqueue_enc_ops(uint16_t dev_id, uint16_t queue_id,
498  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
499 {
500  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
501  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
502  return dev->enqueue_enc_ops(q_data, ops, num_ops);
503 }
504 
526 __rte_experimental
527 static inline uint16_t
528 rte_bbdev_enqueue_dec_ops(uint16_t dev_id, uint16_t queue_id,
529  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
530 {
531  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
532  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
533  return dev->enqueue_dec_ops(q_data, ops, num_ops);
534 }
535 
557 __rte_experimental
558 static inline uint16_t
559 rte_bbdev_enqueue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,
560  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
561 {
562  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
563  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
564  return dev->enqueue_ldpc_enc_ops(q_data, ops, num_ops);
565 }
566 
588 __rte_experimental
589 static inline uint16_t
590 rte_bbdev_enqueue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id,
591  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
592 {
593  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
594  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
595  return dev->enqueue_ldpc_dec_ops(q_data, ops, num_ops);
596 }
597 
598 
621 __rte_experimental
622 static inline uint16_t
623 rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id,
624  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
625 {
626  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
627  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
628  return dev->dequeue_enc_ops(q_data, ops, num_ops);
629 }
630 
654 __rte_experimental
655 static inline uint16_t
656 rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id,
657  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
658 {
659  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
660  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
661  return dev->dequeue_dec_ops(q_data, ops, num_ops);
662 }
663 
664 
686 __rte_experimental
687 static inline uint16_t
688 rte_bbdev_dequeue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,
689  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
690 {
691  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
692  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
693  return dev->dequeue_ldpc_enc_ops(q_data, ops, num_ops);
694 }
695 
717 __rte_experimental
718 static inline uint16_t
719 rte_bbdev_dequeue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id,
720  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
721 {
722  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
723  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
724  return dev->dequeue_ldpc_dec_ops(q_data, ops, num_ops);
725 }
726 
733 };
734 
748 typedef void (*rte_bbdev_cb_fn)(uint16_t dev_id,
749  enum rte_bbdev_event_type event, void *cb_arg,
750  void *ret_param);
751 
769 __rte_experimental
770 int
771 rte_bbdev_callback_register(uint16_t dev_id, enum rte_bbdev_event_type event,
772  rte_bbdev_cb_fn cb_fn, void *cb_arg);
773 
793 __rte_experimental
794 int
795 rte_bbdev_callback_unregister(uint16_t dev_id, enum rte_bbdev_event_type event,
796  rte_bbdev_cb_fn cb_fn, void *cb_arg);
797 
814 __rte_experimental
815 int
816 rte_bbdev_queue_intr_enable(uint16_t dev_id, uint16_t queue_id);
817 
831 __rte_experimental
832 int
833 rte_bbdev_queue_intr_disable(uint16_t dev_id, uint16_t queue_id);
834 
859 __rte_experimental
860 int
861 rte_bbdev_queue_intr_ctl(uint16_t dev_id, uint16_t queue_id, int epfd, int op,
862  void *data);
863 
864 #ifdef __cplusplus
865 }
866 #endif
867 
868 #endif /* _RTE_BBDEV_H_ */
uint64_t acc_offload_cycles
Definition: rte_bbdev.h:260
uint16_t num_queues
Definition: rte_bbdev.h:333
__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:248
uint64_t dequeue_err_count
Definition: rte_bbdev.h:253
const char * driver_name
Definition: rte_bbdev.h:295
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:312
uint8_t max_dl_queue_priority
Definition: rte_bbdev.h:304
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:656
struct rte_bbdev_driver_info drv
Definition: rte_bbdev.h:335
uint16_t min_alignment
Definition: rte_bbdev.h:310
__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:559
unsigned int max_num_queues
Definition: rte_bbdev.h:298
enum rte_bbdev_op_type op_type
Definition: rte_bbdev.h:144
__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:590
__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:623
__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:413
uint32_t queue_size_lim
Definition: rte_bbdev.h:300
rte_bbdev_state
Definition: rte_bbdev.h:48
#define __rte_cache_aligned
Definition: rte_common.h:376
struct rte_bbdev_queue_conf conf
Definition: rte_bbdev.h:358
__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:331
rte_bbdev_event_type
Definition: rte_bbdev.h:728
__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:688
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:719
__rte_experimental uint16_t rte_bbdev_count(void)
const struct rte_device * device
Definition: rte_bbdev.h:332
__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:528
__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:316
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:497
struct rte_bbdev_queue_conf default_queue_conf
Definition: rte_bbdev.h:314
uint8_t max_ul_queue_priority
Definition: rte_bbdev.h:306
enum rte_cpu_flag_t * cpu_flag_reqs
Definition: rte_bbdev.h:318
__rte_experimental bool rte_bbdev_is_valid(uint16_t dev_id)
uint64_t enqueue_err_count
Definition: rte_bbdev.h:251
uint64_t dequeued_count
Definition: rte_bbdev.h:249
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:748