DPDK  18.11.11
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 uint16_t __rte_experimental
60 rte_bbdev_count(void);
61 
71 bool __rte_experimental
72 rte_bbdev_is_valid(uint16_t dev_id);
73 
84 uint16_t __rte_experimental
85 rte_bbdev_find_next(uint16_t dev_id);
86 
88 #define RTE_BBDEV_FOREACH(i) for (i = rte_bbdev_find_next(-1); \
89  i < RTE_BBDEV_MAX_DEVS; \
90  i = rte_bbdev_find_next(i))
91 
113 int __rte_experimental
114 rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id);
115 
130 int __rte_experimental
131 rte_bbdev_intr_enable(uint16_t dev_id);
132 
135  int socket;
136  uint32_t queue_size;
137  uint8_t priority;
140 };
141 
159 int __rte_experimental
160 rte_bbdev_queue_configure(uint16_t dev_id, uint16_t queue_id,
161  const struct rte_bbdev_queue_conf *conf);
162 
174 int __rte_experimental
175 rte_bbdev_start(uint16_t dev_id);
176 
187 int __rte_experimental
188 rte_bbdev_stop(uint16_t dev_id);
189 
200 int __rte_experimental
201 rte_bbdev_close(uint16_t dev_id);
202 
217 int __rte_experimental
218 rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id);
219 
232 int __rte_experimental
233 rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id);
234 
237  uint64_t enqueued_count;
238  uint64_t dequeued_count;
244  uint64_t offload_time;
245 };
246 
260 int __rte_experimental
261 rte_bbdev_stats_get(uint16_t dev_id, struct rte_bbdev_stats *stats);
262 
271 int __rte_experimental
272 rte_bbdev_stats_reset(uint16_t dev_id);
273 
277  const char *driver_name;
278 
280  unsigned int max_num_queues;
282  uint32_t queue_size_lim;
292  uint16_t min_alignment;
296  const struct rte_bbdev_op_cap *capabilities;
298  const enum rte_cpu_flag_t *cpu_flag_reqs;
299 };
300 
302 #define RTE_BBDEV_END_OF_CAPABILITIES_LIST() \
303  { RTE_BBDEV_OP_NONE }
304 
310  int socket_id;
311  const char *dev_name;
312  const struct rte_bus *bus;
313  uint16_t num_queues;
314  bool started;
316 };
317 
331 int __rte_experimental
332 rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info);
333 
339  bool started;
340 };
341 
357 int __rte_experimental
358 rte_bbdev_queue_info_get(uint16_t dev_id, uint16_t queue_id,
359  struct rte_bbdev_queue_info *queue_info);
360 
362 struct rte_bbdev_queue_data {
363  void *queue_private;
364  struct rte_bbdev_queue_conf conf;
365  struct rte_bbdev_stats queue_stats;
366  bool started;
367 };
368 
370 typedef uint16_t (*rte_bbdev_enqueue_enc_ops_t)(
371  struct rte_bbdev_queue_data *q_data,
372  struct rte_bbdev_enc_op **ops,
373  uint16_t num);
374 
376 typedef uint16_t (*rte_bbdev_enqueue_dec_ops_t)(
377  struct rte_bbdev_queue_data *q_data,
378  struct rte_bbdev_dec_op **ops,
379  uint16_t num);
380 
382 typedef uint16_t (*rte_bbdev_dequeue_enc_ops_t)(
383  struct rte_bbdev_queue_data *q_data,
384  struct rte_bbdev_enc_op **ops, uint16_t num);
385 
387 typedef uint16_t (*rte_bbdev_dequeue_dec_ops_t)(
388  struct rte_bbdev_queue_data *q_data,
389  struct rte_bbdev_dec_op **ops, uint16_t num);
390 
391 #define RTE_BBDEV_NAME_MAX_LEN 64
399 struct rte_bbdev_data {
400  char name[RTE_BBDEV_NAME_MAX_LEN];
401  void *dev_private;
402  uint16_t num_queues;
403  struct rte_bbdev_queue_data *queues;
404  uint16_t dev_id;
405  int socket_id;
406  bool started;
408  rte_atomic16_t process_cnt;
409 };
410 
411 /* Forward declarations */
412 struct rte_bbdev_ops;
413 struct rte_bbdev_callback;
414 struct rte_intr_handle;
415 
417 TAILQ_HEAD(rte_bbdev_cb_list, rte_bbdev_callback);
418 
423 struct __rte_cache_aligned rte_bbdev {
425  rte_bbdev_enqueue_enc_ops_t enqueue_enc_ops;
427  rte_bbdev_enqueue_dec_ops_t enqueue_dec_ops;
429  rte_bbdev_dequeue_enc_ops_t dequeue_enc_ops;
431  rte_bbdev_dequeue_dec_ops_t dequeue_dec_ops;
432  const struct rte_bbdev_ops *dev_ops;
433  struct rte_bbdev_data *data;
434  enum rte_bbdev_state state;
435  struct rte_device *device;
437  struct rte_bbdev_cb_list list_cbs;
438  struct rte_intr_handle *intr_handle;
439 };
440 
442 extern struct rte_bbdev rte_bbdev_devices[];
443 
465 static inline uint16_t
466 rte_bbdev_enqueue_enc_ops(uint16_t dev_id, uint16_t queue_id,
467  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
468 {
469  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
470  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
471  return dev->enqueue_enc_ops(q_data, ops, num_ops);
472 }
473 
495 static inline uint16_t
496 rte_bbdev_enqueue_dec_ops(uint16_t dev_id, uint16_t queue_id,
497  struct rte_bbdev_dec_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_dec_ops(q_data, ops, num_ops);
502 }
503 
525 static inline uint16_t
526 rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id,
527  struct rte_bbdev_enc_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->dequeue_enc_ops(q_data, ops, num_ops);
532 }
533 
556 static inline uint16_t
557 rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id,
558  struct rte_bbdev_dec_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->dequeue_dec_ops(q_data, ops, num_ops);
563 }
564 
571 };
572 
586 typedef void (*rte_bbdev_cb_fn)(uint16_t dev_id,
587  enum rte_bbdev_event_type event, void *cb_arg,
588  void *ret_param);
589 
607 int __rte_experimental
608 rte_bbdev_callback_register(uint16_t dev_id, enum rte_bbdev_event_type event,
609  rte_bbdev_cb_fn cb_fn, void *cb_arg);
610 
630 int __rte_experimental
631 rte_bbdev_callback_unregister(uint16_t dev_id, enum rte_bbdev_event_type event,
632  rte_bbdev_cb_fn cb_fn, void *cb_arg);
633 
650 int __rte_experimental
651 rte_bbdev_queue_intr_enable(uint16_t dev_id, uint16_t queue_id);
652 
666 int __rte_experimental
667 rte_bbdev_queue_intr_disable(uint16_t dev_id, uint16_t queue_id);
668 
693 int __rte_experimental
694 rte_bbdev_queue_intr_ctl(uint16_t dev_id, uint16_t queue_id, int epfd, int op,
695  void *data);
696 
697 #ifdef __cplusplus
698 }
699 #endif
700 
701 #endif /* _RTE_BBDEV_H_ */
uint16_t num_queues
Definition: rte_bbdev.h:313
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:237
uint64_t dequeue_err_count
Definition: rte_bbdev.h:242
const char * driver_name
Definition: rte_bbdev.h:277
rte_bbdev_op_type
Definition: rte_bbdev_op.h:407
uint8_t max_dl_queue_priority
Definition: rte_bbdev.h:286
static 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:557
bool __rte_experimental rte_bbdev_is_valid(uint16_t dev_id)
uint64_t offload_time
Definition: rte_bbdev.h:244
struct rte_bbdev_driver_info drv
Definition: rte_bbdev.h:315
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:292
int __rte_experimental rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id)
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:280
enum rte_bbdev_op_type op_type
Definition: rte_bbdev.h:139
int __rte_experimental rte_bbdev_stats_get(uint16_t dev_id, struct rte_bbdev_stats *stats)
static 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:496
#define RTE_BBDEV_NAME_MAX_LEN
Definition: rte_bbdev.h:391
static 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:526
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:282
rte_bbdev_state
Definition: rte_bbdev.h:48
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:337
uint16_t __rte_experimental rte_bbdev_count(void)
const char * dev_name
Definition: rte_bbdev.h:311
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:566
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)
#define __rte_cache_aligned
Definition: rte_memory.h:66
int __rte_experimental rte_bbdev_intr_enable(uint16_t dev_id)
static 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:466
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:312
const struct rte_bbdev_op_cap * capabilities
Definition: rte_bbdev.h:296
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:294
uint8_t max_ul_queue_priority
Definition: rte_bbdev.h:288
int __rte_experimental rte_bbdev_stop(uint16_t dev_id)
enum rte_cpu_flag_t * cpu_flag_reqs
Definition: rte_bbdev.h:298
uint64_t enqueue_err_count
Definition: rte_bbdev.h:240
uint64_t dequeued_count
Definition: rte_bbdev.h:238
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:586