DPDK  19.08.0-rc0
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 uint16_t __rte_experimental
59 rte_bbdev_count(void);
60 
70 bool __rte_experimental
71 rte_bbdev_is_valid(uint16_t dev_id);
72 
83 uint16_t __rte_experimental
84 rte_bbdev_find_next(uint16_t dev_id);
85 
87 #define RTE_BBDEV_FOREACH(i) for (i = rte_bbdev_find_next(-1); \
88  i < RTE_BBDEV_MAX_DEVS; \
89  i = rte_bbdev_find_next(i))
90 
112 int __rte_experimental
113 rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id);
114 
129 int __rte_experimental
130 rte_bbdev_intr_enable(uint16_t dev_id);
131 
134  int socket;
135  uint32_t queue_size;
136  uint8_t priority;
139 };
140 
158 int __rte_experimental
159 rte_bbdev_queue_configure(uint16_t dev_id, uint16_t queue_id,
160  const struct rte_bbdev_queue_conf *conf);
161 
173 int __rte_experimental
174 rte_bbdev_start(uint16_t dev_id);
175 
186 int __rte_experimental
187 rte_bbdev_stop(uint16_t dev_id);
188 
199 int __rte_experimental
200 rte_bbdev_close(uint16_t dev_id);
201 
216 int __rte_experimental
217 rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id);
218 
231 int __rte_experimental
232 rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id);
233 
236  uint64_t enqueued_count;
237  uint64_t dequeued_count;
249 };
250 
264 int __rte_experimental
265 rte_bbdev_stats_get(uint16_t dev_id, struct rte_bbdev_stats *stats);
266 
275 int __rte_experimental
276 rte_bbdev_stats_reset(uint16_t dev_id);
277 
281  const char *driver_name;
282 
284  unsigned int max_num_queues;
286  uint32_t queue_size_lim;
296  uint16_t min_alignment;
300  const struct rte_bbdev_op_cap *capabilities;
302  const enum rte_cpu_flag_t *cpu_flag_reqs;
303 };
304 
306 #define RTE_BBDEV_END_OF_CAPABILITIES_LIST() \
307  { RTE_BBDEV_OP_NONE }
308 
314  int socket_id;
315  const char *dev_name;
316  const struct rte_bus *bus;
317  uint16_t num_queues;
318  bool started;
320 };
321 
335 int __rte_experimental
336 rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info);
337 
343  bool started;
344 };
345 
361 int __rte_experimental
362 rte_bbdev_queue_info_get(uint16_t dev_id, uint16_t queue_id,
363  struct rte_bbdev_queue_info *queue_info);
364 
366 struct rte_bbdev_queue_data {
367  void *queue_private;
368  struct rte_bbdev_queue_conf conf;
369  struct rte_bbdev_stats queue_stats;
370  bool started;
371 };
372 
374 typedef uint16_t (*rte_bbdev_enqueue_enc_ops_t)(
375  struct rte_bbdev_queue_data *q_data,
376  struct rte_bbdev_enc_op **ops,
377  uint16_t num);
378 
380 typedef uint16_t (*rte_bbdev_enqueue_dec_ops_t)(
381  struct rte_bbdev_queue_data *q_data,
382  struct rte_bbdev_dec_op **ops,
383  uint16_t num);
384 
386 typedef uint16_t (*rte_bbdev_dequeue_enc_ops_t)(
387  struct rte_bbdev_queue_data *q_data,
388  struct rte_bbdev_enc_op **ops, uint16_t num);
389 
391 typedef uint16_t (*rte_bbdev_dequeue_dec_ops_t)(
392  struct rte_bbdev_queue_data *q_data,
393  struct rte_bbdev_dec_op **ops, uint16_t num);
394 
395 #define RTE_BBDEV_NAME_MAX_LEN 64
403 struct rte_bbdev_data {
404  char name[RTE_BBDEV_NAME_MAX_LEN];
405  void *dev_private;
406  uint16_t num_queues;
407  struct rte_bbdev_queue_data *queues;
408  uint16_t dev_id;
409  int socket_id;
410  bool started;
412  rte_atomic16_t process_cnt;
413 };
414 
415 /* Forward declarations */
416 struct rte_bbdev_ops;
417 struct rte_bbdev_callback;
418 struct rte_intr_handle;
419 
421 TAILQ_HEAD(rte_bbdev_cb_list, rte_bbdev_callback);
422 
427 struct __rte_cache_aligned rte_bbdev {
429  rte_bbdev_enqueue_enc_ops_t enqueue_enc_ops;
431  rte_bbdev_enqueue_dec_ops_t enqueue_dec_ops;
433  rte_bbdev_dequeue_enc_ops_t dequeue_enc_ops;
435  rte_bbdev_dequeue_dec_ops_t dequeue_dec_ops;
436  const struct rte_bbdev_ops *dev_ops;
437  struct rte_bbdev_data *data;
438  enum rte_bbdev_state state;
439  struct rte_device *device;
441  struct rte_bbdev_cb_list list_cbs;
442  struct rte_intr_handle *intr_handle;
443 };
444 
446 extern struct rte_bbdev rte_bbdev_devices[];
447 
469 static inline uint16_t __rte_experimental
470 rte_bbdev_enqueue_enc_ops(uint16_t dev_id, uint16_t queue_id,
471  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
472 {
473  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
474  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
475  return dev->enqueue_enc_ops(q_data, ops, num_ops);
476 }
477 
499 static inline uint16_t __rte_experimental
500 rte_bbdev_enqueue_dec_ops(uint16_t dev_id, uint16_t queue_id,
501  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
502 {
503  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
504  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
505  return dev->enqueue_dec_ops(q_data, ops, num_ops);
506 }
507 
529 static inline uint16_t __rte_experimental
530 rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id,
531  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
532 {
533  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
534  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
535  return dev->dequeue_enc_ops(q_data, ops, num_ops);
536 }
537 
560 static inline uint16_t __rte_experimental
561 rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id,
562  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
563 {
564  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
565  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
566  return dev->dequeue_dec_ops(q_data, ops, num_ops);
567 }
568 
575 };
576 
590 typedef void (*rte_bbdev_cb_fn)(uint16_t dev_id,
591  enum rte_bbdev_event_type event, void *cb_arg,
592  void *ret_param);
593 
611 int __rte_experimental
612 rte_bbdev_callback_register(uint16_t dev_id, enum rte_bbdev_event_type event,
613  rte_bbdev_cb_fn cb_fn, void *cb_arg);
614 
634 int __rte_experimental
635 rte_bbdev_callback_unregister(uint16_t dev_id, enum rte_bbdev_event_type event,
636  rte_bbdev_cb_fn cb_fn, void *cb_arg);
637 
654 int __rte_experimental
655 rte_bbdev_queue_intr_enable(uint16_t dev_id, uint16_t queue_id);
656 
670 int __rte_experimental
671 rte_bbdev_queue_intr_disable(uint16_t dev_id, uint16_t queue_id);
672 
697 int __rte_experimental
698 rte_bbdev_queue_intr_ctl(uint16_t dev_id, uint16_t queue_id, int epfd, int op,
699  void *data);
700 
701 #ifdef __cplusplus
702 }
703 #endif
704 
705 #endif /* _RTE_BBDEV_H_ */
uint64_t acc_offload_cycles
Definition: rte_bbdev.h:248
uint16_t num_queues
Definition: rte_bbdev.h:317
int __rte_experimental rte_bbdev_close(uint16_t dev_id)
TAILQ_HEAD(rte_bbdev_cb_list, rte_bbdev_callback)
int __rte_experimental rte_bbdev_queue_intr_disable(uint16_t dev_id, uint16_t queue_id)
uint16_t __rte_experimental rte_bbdev_find_next(uint16_t dev_id)
uint64_t enqueued_count
Definition: rte_bbdev.h:236
uint64_t dequeue_err_count
Definition: rte_bbdev.h:241
const char * driver_name
Definition: rte_bbdev.h:281
rte_bbdev_op_type
Definition: rte_bbdev_op.h:408
uint8_t max_dl_queue_priority
Definition: rte_bbdev.h:290
static uint16_t __rte_experimental 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:561
bool __rte_experimental rte_bbdev_is_valid(uint16_t dev_id)
struct rte_bbdev_driver_info drv
Definition: rte_bbdev.h:319
int __rte_experimental rte_bbdev_callback_unregister(uint16_t dev_id, enum rte_bbdev_event_type event, rte_bbdev_cb_fn cb_fn, void *cb_arg)
uint16_t min_alignment
Definition: rte_bbdev.h:296
int __rte_experimental rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id)
static uint16_t __rte_experimental 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:500
int __rte_experimental rte_bbdev_queue_intr_enable(uint16_t dev_id, uint16_t queue_id)
unsigned int max_num_queues
Definition: rte_bbdev.h:284
enum rte_bbdev_op_type op_type
Definition: rte_bbdev.h:138
int __rte_experimental rte_bbdev_stats_get(uint16_t dev_id, struct rte_bbdev_stats *stats)
static uint16_t __rte_experimental 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:470
#define RTE_BBDEV_NAME_MAX_LEN
Definition: rte_bbdev.h:395
int __rte_experimental rte_bbdev_queue_info_get(uint16_t dev_id, uint16_t queue_id, struct rte_bbdev_queue_info *queue_info)
uint32_t queue_size_lim
Definition: rte_bbdev.h:286
rte_bbdev_state
Definition: rte_bbdev.h:47
int __rte_experimental rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id)
struct rte_bbdev_queue_conf conf
Definition: rte_bbdev.h:341
#define __rte_cache_aligned
Definition: rte_memory.h:66
uint16_t __rte_experimental rte_bbdev_count(void)
const char * dev_name
Definition: rte_bbdev.h:315
int __rte_experimental rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id)
rte_bbdev_event_type
Definition: rte_bbdev.h:570
int __rte_experimental rte_bbdev_stats_reset(uint16_t dev_id)
int __rte_experimental rte_bbdev_queue_intr_ctl(uint16_t dev_id, uint16_t queue_id, int epfd, int op, void *data)
int __rte_experimental rte_bbdev_intr_enable(uint16_t dev_id)
int __rte_experimental rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info)
int __rte_experimental rte_bbdev_queue_configure(uint16_t dev_id, uint16_t queue_id, const struct rte_bbdev_queue_conf *conf)
int __rte_experimental rte_bbdev_start(uint16_t dev_id)
const struct rte_bus * bus
Definition: rte_bbdev.h:316
const struct rte_bbdev_op_cap * capabilities
Definition: rte_bbdev.h:300
static uint16_t __rte_experimental 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:530
int __rte_experimental rte_bbdev_callback_register(uint16_t dev_id, enum rte_bbdev_event_type event, rte_bbdev_cb_fn cb_fn, void *cb_arg)
struct rte_bbdev_queue_conf default_queue_conf
Definition: rte_bbdev.h:298
uint8_t max_ul_queue_priority
Definition: rte_bbdev.h:292
int __rte_experimental rte_bbdev_stop(uint16_t dev_id)
enum rte_cpu_flag_t * cpu_flag_reqs
Definition: rte_bbdev.h:302
uint64_t enqueue_err_count
Definition: rte_bbdev.h:239
uint64_t dequeued_count
Definition: rte_bbdev.h:237
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:590