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