DPDK  19.11.10
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;
312  struct rte_bbdev_queue_conf default_queue_conf;
316  const enum rte_cpu_flag_t *cpu_flag_reqs;
317 };
318 
320 #define RTE_BBDEV_END_OF_CAPABILITIES_LIST() \
321  { RTE_BBDEV_OP_NONE }
322 
328  int socket_id;
329  const char *dev_name;
330  const struct rte_device *device;
331  uint16_t num_queues;
332  bool started;
334 };
335 
349 __rte_experimental
350 int
351 rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info);
352 
356  struct rte_bbdev_queue_conf conf;
358  bool started;
359 };
360 
376 __rte_experimental
377 int
378 rte_bbdev_queue_info_get(uint16_t dev_id, uint16_t queue_id,
379  struct rte_bbdev_queue_info *queue_info);
380 
382 struct rte_bbdev_queue_data {
383  void *queue_private;
384  struct rte_bbdev_queue_conf conf;
385  struct rte_bbdev_stats queue_stats;
386  bool started;
387 };
388 
390 typedef uint16_t (*rte_bbdev_enqueue_enc_ops_t)(
391  struct rte_bbdev_queue_data *q_data,
392  struct rte_bbdev_enc_op **ops,
393  uint16_t num);
394 
396 typedef uint16_t (*rte_bbdev_enqueue_dec_ops_t)(
397  struct rte_bbdev_queue_data *q_data,
398  struct rte_bbdev_dec_op **ops,
399  uint16_t num);
400 
402 typedef uint16_t (*rte_bbdev_dequeue_enc_ops_t)(
403  struct rte_bbdev_queue_data *q_data,
404  struct rte_bbdev_enc_op **ops, uint16_t num);
405 
407 typedef uint16_t (*rte_bbdev_dequeue_dec_ops_t)(
408  struct rte_bbdev_queue_data *q_data,
409  struct rte_bbdev_dec_op **ops, uint16_t num);
410 
411 #define RTE_BBDEV_NAME_MAX_LEN 64
419 struct rte_bbdev_data {
420  char name[RTE_BBDEV_NAME_MAX_LEN];
421  void *dev_private;
422  uint16_t num_queues;
423  struct rte_bbdev_queue_data *queues;
424  uint16_t dev_id;
425  int socket_id;
426  bool started;
428  rte_atomic16_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 
618 __rte_experimental
619 static inline uint16_t
620 rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id,
621  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
622 {
623  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
624  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
625  return dev->dequeue_enc_ops(q_data, ops, num_ops);
626 }
627 
650 __rte_experimental
651 static inline uint16_t
652 rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id,
653  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
654 {
655  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
656  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
657  return dev->dequeue_dec_ops(q_data, ops, num_ops);
658 }
659 
660 
682 __rte_experimental
683 static inline uint16_t
684 rte_bbdev_dequeue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id,
685  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
686 {
687  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
688  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
689  return dev->dequeue_ldpc_enc_ops(q_data, ops, num_ops);
690 }
691 
713 __rte_experimental
714 static inline uint16_t
715 rte_bbdev_dequeue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id,
716  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
717 {
718  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
719  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
720  return dev->dequeue_ldpc_dec_ops(q_data, ops, num_ops);
721 }
722 
729 };
730 
744 typedef void (*rte_bbdev_cb_fn)(uint16_t dev_id,
745  enum rte_bbdev_event_type event, void *cb_arg,
746  void *ret_param);
747 
765 __rte_experimental
766 int
767 rte_bbdev_callback_register(uint16_t dev_id, enum rte_bbdev_event_type event,
768  rte_bbdev_cb_fn cb_fn, void *cb_arg);
769 
789 __rte_experimental
790 int
791 rte_bbdev_callback_unregister(uint16_t dev_id, enum rte_bbdev_event_type event,
792  rte_bbdev_cb_fn cb_fn, void *cb_arg);
793 
810 __rte_experimental
811 int
812 rte_bbdev_queue_intr_enable(uint16_t dev_id, uint16_t queue_id);
813 
827 __rte_experimental
828 int
829 rte_bbdev_queue_intr_disable(uint16_t dev_id, uint16_t queue_id);
830 
855 __rte_experimental
856 int
857 rte_bbdev_queue_intr_ctl(uint16_t dev_id, uint16_t queue_id, int epfd, int op,
858  void *data);
859 
860 #ifdef __cplusplus
861 }
862 #endif
863 
864 #endif /* _RTE_BBDEV_H_ */
uint64_t acc_offload_cycles
Definition: rte_bbdev.h:260
uint16_t num_queues
Definition: rte_bbdev.h:331
__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: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: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:652
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:557
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: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:620
__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:411
uint32_t queue_size_lim
Definition: rte_bbdev.h:300
rte_bbdev_state
Definition: rte_bbdev.h:48
__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:329
rte_bbdev_event_type
Definition: rte_bbdev.h:724
__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:684
#define __rte_cache_aligned
Definition: rte_common.h:317
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:715
__rte_experimental uint16_t rte_bbdev_count(void)
const struct rte_device * device
Definition: rte_bbdev.h:330
__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:314
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:306
enum rte_cpu_flag_t * cpu_flag_reqs
Definition: rte_bbdev.h:316
__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:744