DPDK  18.05.1
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;
243  uint64_t offload_time;
244 };
245 
259 int __rte_experimental
260 rte_bbdev_stats_get(uint16_t dev_id, struct rte_bbdev_stats *stats);
261 
270 int __rte_experimental
271 rte_bbdev_stats_reset(uint16_t dev_id);
272 
276  const char *driver_name;
277 
279  unsigned int max_num_queues;
281  uint32_t queue_size_lim;
291  uint16_t min_alignment;
295  const struct rte_bbdev_op_cap *capabilities;
297  const enum rte_cpu_flag_t *cpu_flag_reqs;
298 };
299 
301 #define RTE_BBDEV_END_OF_CAPABILITIES_LIST() \
302  { RTE_BBDEV_OP_NONE }
303 
309  int socket_id;
310  const char *dev_name;
311  const struct rte_bus *bus;
312  uint16_t num_queues;
313  bool started;
315 };
316 
330 int __rte_experimental
331 rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info);
332 
338  bool started;
339 };
340 
356 int __rte_experimental
357 rte_bbdev_queue_info_get(uint16_t dev_id, uint16_t queue_id,
358  struct rte_bbdev_queue_info *queue_info);
359 
361 struct rte_bbdev_queue_data {
362  void *queue_private;
363  struct rte_bbdev_queue_conf conf;
364  struct rte_bbdev_stats queue_stats;
365  bool started;
366 };
367 
369 typedef uint16_t (*rte_bbdev_enqueue_enc_ops_t)(
370  struct rte_bbdev_queue_data *q_data,
371  struct rte_bbdev_enc_op **ops,
372  uint16_t num);
373 
375 typedef uint16_t (*rte_bbdev_enqueue_dec_ops_t)(
376  struct rte_bbdev_queue_data *q_data,
377  struct rte_bbdev_dec_op **ops,
378  uint16_t num);
379 
381 typedef uint16_t (*rte_bbdev_dequeue_enc_ops_t)(
382  struct rte_bbdev_queue_data *q_data,
383  struct rte_bbdev_enc_op **ops, uint16_t num);
384 
386 typedef uint16_t (*rte_bbdev_dequeue_dec_ops_t)(
387  struct rte_bbdev_queue_data *q_data,
388  struct rte_bbdev_dec_op **ops, uint16_t num);
389 
390 #define RTE_BBDEV_NAME_MAX_LEN 64
398 struct rte_bbdev_data {
399  char name[RTE_BBDEV_NAME_MAX_LEN];
400  void *dev_private;
401  uint16_t num_queues;
402  struct rte_bbdev_queue_data *queues;
403  uint16_t dev_id;
404  int socket_id;
405  bool started;
407  rte_atomic16_t process_cnt;
408 };
409 
410 /* Forward declarations */
411 struct rte_bbdev_ops;
412 struct rte_bbdev_callback;
413 struct rte_intr_handle;
414 
416 TAILQ_HEAD(rte_bbdev_cb_list, rte_bbdev_callback);
417 
422 struct __rte_cache_aligned rte_bbdev {
424  rte_bbdev_enqueue_enc_ops_t enqueue_enc_ops;
426  rte_bbdev_enqueue_dec_ops_t enqueue_dec_ops;
428  rte_bbdev_dequeue_enc_ops_t dequeue_enc_ops;
430  rte_bbdev_dequeue_dec_ops_t dequeue_dec_ops;
431  const struct rte_bbdev_ops *dev_ops;
432  struct rte_bbdev_data *data;
433  enum rte_bbdev_state state;
434  struct rte_device *device;
436  struct rte_bbdev_cb_list list_cbs;
437  struct rte_intr_handle *intr_handle;
438 };
439 
441 extern struct rte_bbdev rte_bbdev_devices[];
442 
464 static inline uint16_t
465 rte_bbdev_enqueue_enc_ops(uint16_t dev_id, uint16_t queue_id,
466  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
467 {
468  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
469  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
470  return dev->enqueue_enc_ops(q_data, ops, num_ops);
471 }
472 
494 static inline uint16_t
495 rte_bbdev_enqueue_dec_ops(uint16_t dev_id, uint16_t queue_id,
496  struct rte_bbdev_dec_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_dec_ops(q_data, ops, num_ops);
501 }
502 
524 static inline uint16_t
525 rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id,
526  struct rte_bbdev_enc_op **ops, uint16_t num_ops)
527 {
528  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
529  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
530  return dev->dequeue_enc_ops(q_data, ops, num_ops);
531 }
532 
555 static inline uint16_t
556 rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id,
557  struct rte_bbdev_dec_op **ops, uint16_t num_ops)
558 {
559  struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
560  struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
561  return dev->dequeue_dec_ops(q_data, ops, num_ops);
562 }
563 
570 };
571 
585 typedef void (*rte_bbdev_cb_fn)(uint16_t dev_id,
586  enum rte_bbdev_event_type event, void *cb_arg,
587  void *ret_param);
588 
606 int __rte_experimental
607 rte_bbdev_callback_register(uint16_t dev_id, enum rte_bbdev_event_type event,
608  rte_bbdev_cb_fn cb_fn, void *cb_arg);
609 
629 int __rte_experimental
630 rte_bbdev_callback_unregister(uint16_t dev_id, enum rte_bbdev_event_type event,
631  rte_bbdev_cb_fn cb_fn, void *cb_arg);
632 
649 int __rte_experimental
650 rte_bbdev_queue_intr_enable(uint16_t dev_id, uint16_t queue_id);
651 
665 int __rte_experimental
666 rte_bbdev_queue_intr_disable(uint16_t dev_id, uint16_t queue_id);
667 
692 int __rte_experimental
693 rte_bbdev_queue_intr_ctl(uint16_t dev_id, uint16_t queue_id, int epfd, int op,
694  void *data);
695 
696 #ifdef __cplusplus
697 }
698 #endif
699 
700 #endif /* _RTE_BBDEV_H_ */