xref: /dpdk/lib/compressdev/rte_compressdev_internal.h (revision daa02b5cddbb8e11b31d41e2bf7bb1ae64dcae2f)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017-2018 Intel Corporation
3  */
4 
5 #ifndef _RTE_COMPRESSDEV_INTERNAL_H_
6 #define _RTE_COMPRESSDEV_INTERNAL_H_
7 
8 /* rte_compressdev_internal.h
9  * This file holds Compressdev private data structures.
10  */
11 #include <rte_log.h>
12 
13 #include "rte_comp.h"
14 
15 #define RTE_COMPRESSDEV_NAME_MAX_LEN	(64)
16 /**< Max length of name of comp PMD */
17 
18 /* Logging Macros */
19 extern int compressdev_logtype;
20 #define COMPRESSDEV_LOG(level, fmt, args...) \
21 	rte_log(RTE_LOG_ ## level, compressdev_logtype, "%s(): "fmt "\n", \
22 			__func__, ##args)
23 
24 /**
25  * Dequeue processed packets from queue pair of a device.
26  *
27  * @param qp
28  *   The queue pair from which to retrieve
29  *   processed operations.
30  * @param ops
31  *   The address of an array of pointers to
32  *   *rte_comp_op* structures that must be
33  *   large enough to store *nb_ops* pointers in it
34  * @param nb_ops
35  *   The maximum number of operations to dequeue
36  * @return
37  *   - The number of operations actually dequeued, which is the number
38  *   of pointers to *rte_comp_op* structures effectively supplied to the
39  *   *ops* array.
40  */
41 typedef uint16_t (*compressdev_dequeue_pkt_burst_t)(void *qp,
42 		struct rte_comp_op **ops, uint16_t nb_ops);
43 
44 /**
45  * Enqueue a burst of operations for processing.
46  *
47  * @param qp
48  *   The queue pair on which operations
49  *   are to be enqueued for processing
50  * @param ops
51  *   The address of an array of *nb_ops* pointers
52  *   to *rte_comp_op* structures which contain
53  *   the operations to be processed
54  * @param nb_ops
55  *   The number of operations to process
56  * @return
57  *   The number of operations actually enqueued on the device. The return
58  *   value can be less than the value of the *nb_ops* parameter when the
59  *   comp devices queue is full or if invalid parameters are specified in
60  *   a *rte_comp_op*.
61  */
62 
63 typedef uint16_t (*compressdev_enqueue_pkt_burst_t)(void *qp,
64 		struct rte_comp_op **ops, uint16_t nb_ops);
65 
66 /** The data structure associated with each comp device. */
67 struct rte_compressdev {
68 	compressdev_dequeue_pkt_burst_t dequeue_burst;
69 	/**< Pointer to PMD receive function */
70 	compressdev_enqueue_pkt_burst_t enqueue_burst;
71 	/**< Pointer to PMD transmit function */
72 
73 	struct rte_compressdev_data *data;
74 	/**< Pointer to device data */
75 	struct rte_compressdev_ops *dev_ops;
76 	/**< Functions exported by PMD */
77 	uint64_t feature_flags;
78 	/**< Supported features */
79 	struct rte_device *device;
80 	/**< Backing device */
81 
82 	__extension__
83 	uint8_t attached : 1;
84 	/**< Flag indicating the device is attached */
85 } __rte_cache_aligned;
86 
87 /**
88  *
89  * The data part, with no function pointers, associated with each device.
90  *
91  * This structure is safe to place in shared memory to be common among
92  * different processes in a multi-process configuration.
93  */
94 struct rte_compressdev_data {
95 	uint8_t dev_id;
96 	/**< Compress device identifier */
97 	uint8_t socket_id;
98 	/**< Socket identifier where memory is allocated */
99 	char name[RTE_COMPRESSDEV_NAME_MAX_LEN];
100 	/**< Unique identifier name */
101 
102 	__extension__
103 	uint8_t dev_started : 1;
104 	/**< Device state: STARTED(1)/STOPPED(0) */
105 
106 	void **queue_pairs;
107 	/**< Array of pointers to queue pairs. */
108 	uint16_t nb_queue_pairs;
109 	/**< Number of device queue pairs */
110 
111 	void *dev_private;
112 	/**< PMD-specific private data */
113 } __rte_cache_aligned;
114 #endif
115