xref: /dpdk/lib/bbdev/rte_bbdev_op.h (revision 02d36ef6a9528e0f4a3403956e66bcea5fadbf8c)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Intel Corporation
3  */
4 
5 #ifndef _RTE_BBDEV_OP_H_
6 #define _RTE_BBDEV_OP_H_
7 
8 /**
9  * @file rte_bbdev_op.h
10  *
11  * Defines wireless base band layer 1 operations and capabilities
12  */
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 #include <stdint.h>
19 
20 #include <rte_compat.h>
21 #include <rte_common.h>
22 #include <rte_mbuf.h>
23 #include <rte_memory.h>
24 #include <rte_mempool.h>
25 
26 /* Number of columns in sub-block interleaver (36.212, section 5.1.4.1.1) */
27 #define RTE_BBDEV_TURBO_C_SUBBLOCK (32)
28 /* Maximum size of Transport Block (36.213, Table, Table 7.1.7.2.5-1) */
29 #define RTE_BBDEV_TURBO_MAX_TB_SIZE (391656)
30 /* Maximum size of Code Block (36.212, Table 5.1.3-3) */
31 #define RTE_BBDEV_TURBO_MAX_CB_SIZE (6144)
32 /* Maximum size of Code Block */
33 #define RTE_BBDEV_LDPC_MAX_CB_SIZE (8448)
34 /* Minimum size of Code Block */
35 #define RTE_BBDEV_LDPC_MIN_CB_SIZE (40)
36 /* Maximum E size we can manage with default mbuf */
37 #define RTE_BBDEV_LDPC_E_MAX_MBUF (64000)
38 /* Minimum size of Code Block (36.212, Table 5.1.3-3) */
39 #define RTE_BBDEV_TURBO_MIN_CB_SIZE (40)
40 /* Maximum size of circular buffer */
41 #define RTE_BBDEV_TURBO_MAX_KW (18528)
42 /*
43  * Turbo: Maximum number of Code Blocks in Transport Block. It is calculated
44  * based on maximum size of one Code Block and one Transport Block
45  * (considering CRC24A and CRC24B):
46  * (391656 + 24) / (6144 - 24) = 64
47  */
48 #define RTE_BBDEV_TURBO_MAX_CODE_BLOCKS (64)
49 /* LDPC:  Maximum number of Code Blocks in Transport Block.*/
50 #define RTE_BBDEV_LDPC_MAX_CODE_BLOCKS (256)
51 /* 12 CS maximum */
52 #define RTE_BBDEV_MAX_CS_2 (6)
53 
54 /*
55  * Maximum size to be used to manage the enum rte_bbdev_op_type
56  * including padding for future enum insertion.
57  * The enum values must be explicitly kept smaller or equal to this padded maximum size.
58  */
59 #define RTE_BBDEV_OP_TYPE_SIZE_MAX 8
60 
61 /** Flags for turbo decoder operation and capability structure */
62 enum rte_bbdev_op_td_flag_bitmasks {
63 	/** If sub block de-interleaving is to be performed. */
64 	RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE = (1ULL << 0),
65 	/** To use CRC Type 24B (otherwise use CRC Type 24A). */
66 	RTE_BBDEV_TURBO_CRC_TYPE_24B = (1ULL << 1),
67 	/** If turbo equalization is to be performed. */
68 	RTE_BBDEV_TURBO_EQUALIZER = (1ULL << 2),
69 	/** If set, saturate soft output to +/-127 */
70 	RTE_BBDEV_TURBO_SOFT_OUT_SATURATE = (1ULL << 3),
71 	/** Set to 1 to start iteration from even, else odd; one iteration =
72 	 * max_iteration + 0.5
73 	 */
74 	RTE_BBDEV_TURBO_HALF_ITERATION_EVEN = (1ULL << 4),
75 	/** If 0, TD stops after CRC matches; else if 1, runs to end of next
76 	 * odd iteration after CRC matches
77 	 */
78 	RTE_BBDEV_TURBO_CONTINUE_CRC_MATCH = (1ULL << 5),
79 	/** Set if soft output is required to be output  */
80 	RTE_BBDEV_TURBO_SOFT_OUTPUT = (1ULL << 6),
81 	/** Set to enable early termination mode */
82 	RTE_BBDEV_TURBO_EARLY_TERMINATION = (1ULL << 7),
83 	/** Set if a device supports decoder dequeue interrupts */
84 	RTE_BBDEV_TURBO_DEC_INTERRUPTS = (1ULL << 9),
85 	/** Set if positive LLR encoded input is supported. Positive LLR value
86 	 * represents the level of confidence for bit '1', and vice versa for
87 	 * bit '0'.
88 	 * This is mutually exclusive with RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN
89 	 * when used to formalize the input data format.
90 	 */
91 	RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN = (1ULL << 10),
92 	/** Set if negative LLR encoded input is supported. Negative LLR value
93 	 * represents the level of confidence for bit '1', and vice versa for
94 	 * bit '0'.
95 	 * This is mutually exclusive with RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN
96 	 * when used to formalize the input data format.
97 	 */
98 	RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN = (1ULL << 11),
99 	/** Set if positive LLR soft output is supported. Positive LLR value
100 	 * represents the level of confidence for bit '1', and vice versa for
101 	 * bit '0'.
102 	 * This is mutually exclusive with
103 	 * RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT when used to formalize
104 	 * the input data format.
105 	 */
106 	RTE_BBDEV_TURBO_POS_LLR_1_BIT_SOFT_OUT = (1ULL << 12),
107 	/** Set if negative LLR soft output is supported. Negative LLR value
108 	 * represents the level of confidence for bit '1', and vice versa for
109 	 * bit '0'.
110 	 * This is mutually exclusive with
111 	 * RTE_BBDEV_TURBO_POS_LLR_1_BIT_SOFT_OUT when used to formalize the
112 	 * input data format.
113 	 */
114 	RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT = (1ULL << 13),
115 	/** Set if driver supports flexible parallel MAP engine decoding. If
116 	 * not supported, num_maps (number of MAP engines) argument is unusable.
117 	 */
118 	RTE_BBDEV_TURBO_MAP_DEC = (1ULL << 14),
119 	/** Set if a device supports scatter-gather functionality */
120 	RTE_BBDEV_TURBO_DEC_SCATTER_GATHER = (1ULL << 15),
121 	/** Set to keep CRC24B bits appended while decoding. Only usable when
122 	 * decoding Transport Block mode.
123 	 */
124 	RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP = (1ULL << 16),
125 	/** Set to drop CRC24B bits not to be appended while decoding.
126 	 */
127 	RTE_BBDEV_TURBO_DEC_CRC_24B_DROP = (1ULL << 17)
128 };
129 
130 
131 /** Flags for turbo encoder operation and capability structure */
132 enum rte_bbdev_op_te_flag_bitmasks {
133 	/** Ignore rv_index and set K0 = 0 */
134 	RTE_BBDEV_TURBO_RV_INDEX_BYPASS = (1ULL << 0),
135 	/** If rate matching is to be performed */
136 	RTE_BBDEV_TURBO_RATE_MATCH = (1ULL << 1),
137 	/** This bit must be set to enable CRC-24B generation */
138 	RTE_BBDEV_TURBO_CRC_24B_ATTACH = (1ULL << 2),
139 	/** This bit must be set to enable CRC-24A generation */
140 	RTE_BBDEV_TURBO_CRC_24A_ATTACH = (1ULL << 3),
141 	/** Set if a device supports encoder dequeue interrupts */
142 	RTE_BBDEV_TURBO_ENC_INTERRUPTS = (1ULL << 4),
143 	/** Set if a device supports scatter-gather functionality */
144 	RTE_BBDEV_TURBO_ENC_SCATTER_GATHER = (1ULL << 5)
145 };
146 
147 /** Flags for LDPC decoder operation and capability structure */
148 enum rte_bbdev_op_ldpcdec_flag_bitmasks {
149 	/** Set for transport block CRC-24A checking */
150 	RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK = (1ULL << 0),
151 	/** Set for code block CRC-24B checking */
152 	RTE_BBDEV_LDPC_CRC_TYPE_24B_CHECK = (1ULL << 1),
153 	/** Set to drop the last CRC bits decoding output */
154 	RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP = (1ULL << 2),
155 	/** Set for transport block CRC-16 checking */
156 	RTE_BBDEV_LDPC_CRC_TYPE_16_CHECK = (1ULL << 3),
157 	/** Set for bit-level de-interleaver bypass on Rx stream. */
158 	RTE_BBDEV_LDPC_DEINTERLEAVER_BYPASS = (1ULL << 4),
159 	/** Set for HARQ combined input stream enable. */
160 	RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE = (1ULL << 5),
161 	/** Set for HARQ combined output stream enable. */
162 	RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE = (1ULL << 6),
163 	/** Set for LDPC decoder bypass.
164 	 *  RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE must be set.
165 	 */
166 	RTE_BBDEV_LDPC_DECODE_BYPASS = (1ULL << 7),
167 	/** Set for soft-output stream enable */
168 	RTE_BBDEV_LDPC_SOFT_OUT_ENABLE = (1ULL << 8),
169 	/** Set for Rate-Matching bypass on soft-out stream. */
170 	RTE_BBDEV_LDPC_SOFT_OUT_RM_BYPASS = (1ULL << 9),
171 	/** Set for bit-level de-interleaver bypass on soft-output stream. */
172 	RTE_BBDEV_LDPC_SOFT_OUT_DEINTERLEAVER_BYPASS = (1ULL << 10),
173 	/** Set for iteration stopping on successful decode condition
174 	 *  i.e. a successful syndrome check.
175 	 */
176 	RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE = (1ULL << 11),
177 	/** Set if a device supports decoder dequeue interrupts. */
178 	RTE_BBDEV_LDPC_DEC_INTERRUPTS = (1ULL << 12),
179 	/** Set if a device supports scatter-gather functionality. */
180 	RTE_BBDEV_LDPC_DEC_SCATTER_GATHER = (1ULL << 13),
181 	/** Set if a device supports input/output HARQ compression. */
182 	RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION = (1ULL << 14),
183 	/** Set if a device supports input LLR compression. */
184 	RTE_BBDEV_LDPC_LLR_COMPRESSION = (1ULL << 15),
185 	/** Set if a device supports HARQ input from
186 	 *  device's internal memory.
187 	 */
188 	RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE = (1ULL << 16),
189 	/** Set if a device supports HARQ output to
190 	 *  device's internal memory.
191 	 */
192 	RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE = (1ULL << 17),
193 	/** Set if a device supports loop-back access to
194 	 *  HARQ internal memory. Intended for troubleshooting.
195 	 */
196 	RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK = (1ULL << 18),
197 	/** Set if a device includes LLR filler bits in the circular buffer
198 	 *  for HARQ memory. If not set, it is assumed the filler bits are not
199 	 *  in HARQ memory and handled directly by the LDPC decoder.
200 	 */
201 	RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_FILLERS = (1ULL << 19)
202 };
203 
204 /** Flags for LDPC encoder operation and capability structure */
205 enum rte_bbdev_op_ldpcenc_flag_bitmasks {
206 	/** Set for bit-level interleaver bypass on output stream. */
207 	RTE_BBDEV_LDPC_INTERLEAVER_BYPASS = (1ULL << 0),
208 	/** If rate matching is to be performed */
209 	RTE_BBDEV_LDPC_RATE_MATCH = (1ULL << 1),
210 	/** Set for transport block CRC-24A attach */
211 	RTE_BBDEV_LDPC_CRC_24A_ATTACH = (1ULL << 2),
212 	/** Set for code block CRC-24B attach */
213 	RTE_BBDEV_LDPC_CRC_24B_ATTACH = (1ULL << 3),
214 	/** Set for code block CRC-16 attach */
215 	RTE_BBDEV_LDPC_CRC_16_ATTACH = (1ULL << 4),
216 	/** Set if a device supports encoder dequeue interrupts. */
217 	RTE_BBDEV_LDPC_ENC_INTERRUPTS = (1ULL << 5),
218 	/** Set if a device supports scatter-gather functionality. */
219 	RTE_BBDEV_LDPC_ENC_SCATTER_GATHER = (1ULL << 6),
220 	/** Set if a device supports concatenation of non byte aligned output */
221 	RTE_BBDEV_LDPC_ENC_CONCATENATION = (1ULL << 7)
222 };
223 
224 /** Flags for FFT operation and capability structure. */
225 enum rte_bbdev_op_fft_flag_bitmasks {
226 	/** Flexible windowing capability. */
227 	RTE_BBDEV_FFT_WINDOWING = (1ULL << 0),
228 	/** Flexible adjustment of Cyclic Shift time offset. */
229 	RTE_BBDEV_FFT_CS_ADJUSTMENT = (1ULL << 1),
230 	/** Set for bypass the DFT and get directly into iDFT input. */
231 	RTE_BBDEV_FFT_DFT_BYPASS = (1ULL << 2),
232 	/** Set for bypass the IDFT and get directly the DFT output. */
233 	RTE_BBDEV_FFT_IDFT_BYPASS = (1ULL << 3),
234 	/** Set for bypass time domain windowing. */
235 	RTE_BBDEV_FFT_WINDOWING_BYPASS = (1ULL << 4),
236 	/** Set for optional power measurement on DFT output. */
237 	RTE_BBDEV_FFT_POWER_MEAS = (1ULL << 5),
238 	/** Set if the input data used FP16 format. */
239 	RTE_BBDEV_FFT_FP16_INPUT = (1ULL << 6),
240 	/** Set if the output data uses FP16 format. */
241 	RTE_BBDEV_FFT_FP16_OUTPUT = (1ULL << 7)
242 };
243 
244 /** Flags for the Code Block/Transport block mode  */
245 enum rte_bbdev_op_cb_mode {
246 	/** One operation is one or fraction of one transport block  */
247 	RTE_BBDEV_TRANSPORT_BLOCK = 0,
248 	/** One operation is one code block mode */
249 	RTE_BBDEV_CODE_BLOCK = 1,
250 };
251 
252 /** Data input and output buffer for BBDEV operations */
253 struct rte_bbdev_op_data {
254 	/** The mbuf data structure representing the data for BBDEV operation.
255 	 *
256 	 * This mbuf pointer can point to one Code Block (CB) data buffer or
257 	 * multiple CBs contiguously located next to each other.
258 	 * A Transport Block (TB) represents a whole piece of data that is
259 	 * divided into one or more CBs. Maximum number of CBs can be contained
260 	 * in one TB is defined by RTE_BBDEV_(TURBO/LDPC)_MAX_CODE_BLOCKS.
261 	 *
262 	 * An mbuf data structure cannot represent more than one TB. The
263 	 * smallest piece of data that can be contained in one mbuf is one CB.
264 	 * An mbuf can include one contiguous CB, subset of contiguous CBs that
265 	 * are belonging to one TB, or all contiguous CBs that are belonging to
266 	 * one TB.
267 	 *
268 	 * If a BBDEV PMD supports the extended capability "Scatter-Gather",
269 	 * then it is capable of collecting (gathering) non-contiguous
270 	 * (scattered) data from multiple locations in the memory.
271 	 * This capability is reported by the capability flags:
272 	 * - RTE_BBDEV_(TURBO/LDPC)_ENC_SCATTER_GATHER and
273 	 * - RTE_BBDEV_(TURBO/LDPC)_DEC_SCATTER_GATHER.
274 	 * Only if a BBDEV PMD supports this feature, chained mbuf data
275 	 * structures are accepted. A chained mbuf can represent one
276 	 * non-contiguous CB or multiple non-contiguous CBs.
277 	 * If BBDEV PMD does not support this feature, it will assume inbound
278 	 * mbuf data contains one segment.
279 	 *
280 	 * The output mbuf data though is always one segment, even if the input
281 	 * was a chained mbuf.
282 	 */
283 	struct rte_mbuf *data;
284 	/** The starting point of the BBDEV (encode/decode) operation,
285 	 * in bytes.
286 	 *
287 	 * BBDEV starts to read data past this offset.
288 	 * In case of chained mbuf, this offset applies only to the first mbuf
289 	 * segment.
290 	 */
291 	uint32_t offset;
292 	/** The total data length to be processed in one operation, in bytes.
293 	 *
294 	 * In case the mbuf data is representing one CB, this is the length of
295 	 * the CB undergoing the operation.
296 	 * If it's for multiple CBs, this is the total length of those CBs
297 	 * undergoing the operation.
298 	 * If it is for one TB, this is the total length of the TB under
299 	 * operation.
300 	 *
301 	 * In case of chained mbuf, this data length includes the lengths of the
302 	 * "scattered" data segments undergoing the operation.
303 	 */
304 	uint32_t length;
305 };
306 
307 /** Turbo decode code block parameters */
308 struct rte_bbdev_op_dec_turbo_cb_params {
309 	/** The K size of the input CB, in bits [40:6144], as specified in
310 	 * 3GPP TS 36.212.
311 	 * This size is inclusive of CRC bits, regardless whether it was
312 	 * pre-calculated by the application or not.
313 	 */
314 	uint16_t k;
315 	/** The E length of the CB rate matched LLR output, in bytes, as in
316 	 * 3GPP TS 36.212.
317 	 */
318 	uint32_t e;
319 };
320 
321 /** LDPC decode code block parameters */
322 struct rte_bbdev_op_dec_ldpc_cb_params {
323 	/** Rate matching output sequence length in bits or LLRs.
324 	 *  [3GPP TS38.212, section 5.4.2.1]
325 	 */
326 	uint32_t e;
327 };
328 
329 /** Turbo decode transport block parameters */
330 struct rte_bbdev_op_dec_turbo_tb_params {
331 	/** The K- size of the input CB, in bits [40:6144], that is in the
332 	 * Turbo operation when r < C-, as in 3GPP TS 36.212.
333 	 */
334 	uint16_t k_neg;
335 	/** The K+ size of the input CB, in bits [40:6144], that is in the
336 	 * Turbo operation when r >= C-, as in 3GPP TS 36.212.
337 	 */
338 	uint16_t k_pos;
339 	/** The number of CBs that have K- size, [0:63] */
340 	uint8_t c_neg;
341 	/** The total number of CBs in the TB,
342 	 * [1:RTE_BBDEV_TURBO_MAX_CODE_BLOCKS]
343 	 */
344 	uint8_t c;
345 	/** The number of CBs that uses Ea before switching to Eb, [0:63] */
346 	uint8_t cab;
347 	/** The E size of the CB rate matched output to use in the Turbo
348 	 * operation when r < cab
349 	 */
350 	uint32_t ea;
351 	/** The E size of the CB rate matched output to use in the Turbo
352 	 * operation when r >= cab
353 	 */
354 	uint32_t eb;
355 	/** The index of the first CB in the inbound mbuf data, default is 0 */
356 	uint8_t r;
357 };
358 
359 /** LDPC decode transport block parameters */
360 struct rte_bbdev_op_dec_ldpc_tb_params {
361 	/** Ea, length after rate matching in bits, r < cab.
362 	 *  [3GPP TS38.212, section 5.4.2.1]
363 	 */
364 	uint32_t ea;
365 	/** Eb, length after rate matching in bits, r >= cab.
366 	 *  [3GPP TS38.212, section 5.4.2.1]
367 	 */
368 	uint32_t eb;
369 	/** The total number of CBs in the TB or partial TB
370 	 * [1:RTE_BBDEV_LDPC_MAX_CODE_BLOCKS]
371 	 */
372 	uint8_t c;
373 	/** The index of the first CB in the inbound mbuf data, default is 0 */
374 	uint8_t r;
375 	/** The number of CBs that use Ea before switching to Eb, [0:63] */
376 	uint8_t cab;
377 };
378 
379 /** Operation structure for Turbo decode.
380  * An operation can be performed on one CB at a time "CB-mode".
381  * An operation can be performed on one or multiple CBs that logically
382  * belong to one TB "TB-mode".
383  * The provided K size parameter of the CB is its size coming from the
384  * decode operation.
385  * CRC24A/B check is requested by the application by setting the flag
386  * RTE_BBDEV_TURBO_CRC_TYPE_24B for CRC24B check or CRC24A otherwise.
387  * In TB-mode, BBDEV concatenates the decoded CBs one next to the other with
388  * relevant CRC24B in between.
389  *
390  * The input encoded CB data is the Virtual Circular Buffer data stream, wk,
391  * with the null padding included as described in 3GPP TS 36.212
392  * section 5.1.4.1.2 and shown in 3GPP TS 36.212 section 5.1.4.1 Figure 5.1.4-1.
393  * The size of the virtual circular buffer is 3*Kpi, where Kpi is the 32 byte
394  * aligned value of K, as specified in 3GPP TS 36.212 section 5.1.4.1.1.
395  *
396  * Each byte in the input circular buffer is the LLR value of each bit of the
397  * original CB.
398  *
399  * Hard output is a mandatory capability that all BBDEV PMDs support. This is
400  * the decoded CBs of K sizes (CRC24A/B is the last 24-bit in each decoded CB).
401  * Soft output is an optional capability for BBDEV PMDs. If supported, an LLR
402  * rate matched output is computed in the soft_output buffer structure.
403  *
404  * The output mbuf data structure is expected to be allocated by the
405  * application with enough room for the output data.
406  */
407 
408 /* Structure rte_bbdev_op_turbo_dec 8< */
409 struct rte_bbdev_op_turbo_dec {
410 	/** The Virtual Circular Buffer, wk, size 3*Kpi for each CB */
411 	struct rte_bbdev_op_data input;
412 	/** The hard decisions buffer for the decoded output,
413 	 * size K for each CB
414 	 */
415 	struct rte_bbdev_op_data hard_output;
416 	/** The soft LLR output buffer - optional */
417 	struct rte_bbdev_op_data soft_output;
418 
419 	/** Flags from rte_bbdev_op_td_flag_bitmasks */
420 	uint32_t op_flags;
421 
422 	/** Rv index for rate matching [0:3] */
423 	uint8_t rv_index;
424 	/** The minimum number of iterations to perform in decoding all CBs in
425 	 * this operation - input
426 	 */
427 	uint8_t iter_min:4;
428 	/** The maximum number of iterations to perform in decoding all CBs in
429 	 * this operation - input
430 	 */
431 	uint8_t iter_max:4;
432 	/** The maximum number of iterations that were performed in decoding
433 	 * all CBs in this decode operation - output
434 	 */
435 	uint8_t iter_count;
436 	/** 5 bit extrinsic scale (scale factor on extrinsic info) */
437 	uint8_t ext_scale;
438 	/** Number of MAP engines to use in decode,
439 	 *  must be power of 2 (or 0 to auto-select)
440 	 */
441 	uint8_t num_maps;
442 
443 	/** [0 - TB : 1 - CB] */
444 	uint8_t code_block_mode;
445 	union {
446 		/** Struct which stores Code Block specific parameters */
447 		struct rte_bbdev_op_dec_turbo_cb_params cb_params;
448 		/** Struct which stores Transport Block specific parameters */
449 		struct rte_bbdev_op_dec_turbo_tb_params tb_params;
450 	};
451 };
452 /* >8 End of structure rte_bbdev_op_turbo_dec. */
453 
454 /** Operation structure for LDPC decode.
455  *
456  * An operation can be performed on one CB at a time "CB-mode".
457  * An operation can also be performed on one or multiple CBs that logically
458  * belong to a TB "TB-mode" (Currently not supported).
459  *
460  * The input encoded CB data is the Virtual Circular Buffer data stream.
461  *
462  * Each byte in the input circular buffer is the LLR value of each bit of the
463  * original CB.
464  *
465  * Hard output is a mandatory capability that all BBDEV PMDs support. This is
466  * the decoded CBs (CRC24A/B is the last 24-bit in each decoded CB).
467  *
468  * Soft output is an optional capability for BBDEV PMDs. If supported, an LLR
469  * rate matched output is computed in the soft_output buffer structure.
470  * These are A Posteriori Probabilities (APP) LLR samples for coded bits.
471  *
472  * HARQ combined output is an optional capability for BBDEV PMDs.
473  * If supported, a LLR output is streamed to the harq_combined_output
474  * buffer.
475  *
476  * HARQ combined input is an optional capability for BBDEV PMDs.
477  * If supported, a LLR input is streamed from the harq_combined_input
478  * buffer.
479  *
480  * The output mbuf data structure is expected to be allocated by the
481  * application with enough room for the output data.
482  */
483 
484 /* Structure rte_bbdev_op_ldpc_dec 8< */
485 struct rte_bbdev_op_ldpc_dec {
486 	/** The Virtual Circular Buffer for this code block, one LLR
487 	 * per bit of the original CB.
488 	 */
489 	struct rte_bbdev_op_data input;
490 	/** The hard decisions buffer for the decoded output,
491 	 * size K for each CB
492 	 */
493 	struct rte_bbdev_op_data hard_output;
494 	/** The soft LLR output LLR stream buffer - optional */
495 	struct rte_bbdev_op_data soft_output;
496 	/** The HARQ combined LLR stream input buffer - optional */
497 	struct rte_bbdev_op_data harq_combined_input;
498 	/** The HARQ combined LLR stream output buffer - optional */
499 	struct rte_bbdev_op_data harq_combined_output;
500 
501 	/** Flags from rte_bbdev_op_ldpcdec_flag_bitmasks */
502 	uint32_t op_flags;
503 
504 	/** Rate matching redundancy version
505 	 *  [3GPP TS38.212, section 5.4.2.1]
506 	 */
507 	uint8_t rv_index;
508 	/** The maximum number of iterations to perform in decoding CB in
509 	 *  this operation - input
510 	 */
511 	uint8_t iter_max;
512 	/** The number of iterations that were performed in decoding
513 	 * CB in this decode operation - output
514 	 */
515 	uint8_t iter_count;
516 	/** 1: LDPC Base graph 1, 2: LDPC Base graph 2.
517 	 * [3GPP TS38.212, section 5.2.2]
518 	 */
519 	uint8_t basegraph;
520 	/** Zc, LDPC lifting size.
521 	 *  [3GPP TS38.212, section 5.2.2]
522 	 */
523 	uint16_t z_c;
524 	/** Ncb, length of the circular buffer in bits.
525 	 *  [3GPP TS38.212, section 5.4.2.1]
526 	 */
527 	uint16_t n_cb;
528 	/** Qm, modulation order {1,2,4,6,8}.
529 	 *  [3GPP TS38.212, section 5.4.2.2]
530 	 */
531 	uint8_t q_m;
532 	/** Number of Filler bits, n_filler = K – K’
533 	 *  [3GPP TS38.212 section 5.2.2]
534 	 */
535 	uint16_t n_filler;
536 	/** [0 - TB : 1 - CB] */
537 	uint8_t code_block_mode;
538 	union {
539 		/** Struct which stores Code Block specific parameters */
540 		struct rte_bbdev_op_dec_ldpc_cb_params cb_params;
541 		/** Struct which stores Transport Block specific parameters */
542 		struct rte_bbdev_op_dec_ldpc_tb_params tb_params;
543 	};
544 };
545 /* >8 End of structure rte_bbdev_op_ldpc_dec. */
546 
547 /** Turbo encode code block parameters */
548 struct rte_bbdev_op_enc_turbo_cb_params {
549 	/** The K size of the input CB, in bits [40:6144], as specified in
550 	 * 3GPP TS 36.212.
551 	 * This size is inclusive of CRC24A, regardless whether it was
552 	 * pre-calculated by the application or not.
553 	 */
554 	uint16_t k;
555 	/** The E length of the CB rate matched output, in bits, as in
556 	 * 3GPP TS 36.212.
557 	 */
558 	uint32_t e;
559 	/** The Ncb soft buffer size of the CB rate matched output [K:3*Kpi],
560 	 * in bits, as specified in 3GPP TS 36.212.
561 	 */
562 	uint16_t ncb;
563 };
564 
565 /** Turbo encode transport block parameters */
566 struct rte_bbdev_op_enc_turbo_tb_params {
567 	/** The K- size of the input CB, in bits [40:6144], that is in the
568 	 * Turbo operation when r < C-, as in 3GPP TS 36.212.
569 	 * This size is inclusive of CRC24B, regardless whether it was
570 	 * pre-calculated and appended by the application or not.
571 	 */
572 	uint16_t k_neg;
573 	/** The K+ size of the input CB, in bits [40:6144], that is in the
574 	 * Turbo operation when r >= C-, as in 3GPP TS 36.212.
575 	 * This size is inclusive of CRC24B, regardless whether it was
576 	 * pre-calculated and appended by the application or not.
577 	 */
578 	uint16_t k_pos;
579 	/** The number of CBs that have K- size, [0:63] */
580 	uint8_t c_neg;
581 	/** The total number of CBs in the TB,
582 	 * [1:RTE_BBDEV_TURBO_MAX_CODE_BLOCKS]
583 	 */
584 	uint8_t c;
585 	/** The number of CBs that uses Ea before switching to Eb, [0:63] */
586 	uint8_t cab;
587 	/** The E size of the CB rate matched output to use in the Turbo
588 	 * operation when r < cab
589 	 */
590 	uint32_t ea;
591 	/** The E size of the CB rate matched output to use in the Turbo
592 	 * operation when r >= cab
593 	 */
594 	uint32_t eb;
595 	/** The Ncb soft buffer size for the rate matched CB that is used in
596 	 * the Turbo operation when r < C-, [K:3*Kpi]
597 	 */
598 	uint16_t ncb_neg;
599 	/** The Ncb soft buffer size for the rate matched CB that is used in
600 	 * the Turbo operation when r >= C-, [K:3*Kpi]
601 	 */
602 	uint16_t ncb_pos;
603 	/** The index of the first CB in the inbound mbuf data, default is 0 */
604 	uint8_t r;
605 };
606 
607 /** LDPC encode code block parameters */
608 struct rte_bbdev_op_enc_ldpc_cb_params {
609 	/** E, length after rate matching in bits.
610 	 *  [3GPP TS38.212, section 5.4.2.1]
611 	 */
612 	uint32_t e;
613 };
614 
615 /** LDPC encode transport block parameters */
616 struct rte_bbdev_op_enc_ldpc_tb_params {
617 	/** Ea, length after rate matching in bits, r < cab.
618 	 *  [3GPP TS38.212, section 5.4.2.1]
619 	 */
620 	uint32_t ea;
621 	/** Eb, length after rate matching in bits, r >= cab.
622 	 *  [3GPP TS38.212, section 5.4.2.1]
623 	 */
624 	uint32_t eb;
625 	/** The total number of CBs in the TB or partial TB
626 	 * [1:RTE_BBDEV_LDPC_MAX_CODE_BLOCKS]
627 	 */
628 	uint8_t c;
629 	/** The index of the first CB in the inbound mbuf data, default is 0 */
630 	uint8_t r;
631 	/** The number of CBs that use Ea before switching to Eb, [0:63] */
632 	uint8_t cab;
633 };
634 
635 /** Operation structure for Turbo encode.
636  * An operation can be performed on one CB at a time "CB-mode".
637  * An operation can pbe erformd on one or multiple CBs that logically
638  * belong to one TB "TB-mode".
639  *
640  * In CB-mode, CRC24A/B is an optional operation. K size parameter is not
641  * affected by CRC24A/B inclusion, this only affects the inbound mbuf data
642  * length. Not all BBDEV PMDs are capable of CRC24A/B calculation. Flags
643  * RTE_BBDEV_TURBO_CRC_24A_ATTACH and RTE_BBDEV_TURBO_CRC_24B_ATTACH informs
644  * the application with relevant capability. These flags can be set in the
645  * op_flags parameter to indicate BBDEV to calculate and append CRC24A to CB
646  * before going forward with Turbo encoding.
647  *
648  * In TB-mode, CRC24A is assumed to be pre-calculated and appended to the
649  * inbound TB mbuf data buffer.
650  *
651  * The output mbuf data structure is expected to be allocated by the
652  * application with enough room for the output data.
653  */
654 
655 /* Structure rte_bbdev_op_turbo_enc 8< */
656 struct rte_bbdev_op_turbo_enc {
657 	/** The input CB or TB data */
658 	struct rte_bbdev_op_data input;
659 	/** The rate matched CB or TB output buffer */
660 	struct rte_bbdev_op_data output;
661 	/** Flags from rte_bbdev_op_te_flag_bitmasks */
662 	uint32_t op_flags;
663 
664 	/** Rv index for rate matching [0:3] */
665 	uint8_t rv_index;
666 	/** [0 - TB : 1 - CB] */
667 	uint8_t code_block_mode;
668 	union {
669 		/** Struct which stores Code Block specific parameters */
670 		struct rte_bbdev_op_enc_turbo_cb_params cb_params;
671 		/** Struct which stores Transport Block specific parameters */
672 		struct rte_bbdev_op_enc_turbo_tb_params tb_params;
673 	};
674 };
675 /* >8 End of structure rte_bbdev_op_turbo_enc. */
676 
677 /** Operation structure for LDPC encode.
678  * An operation can be performed on one CB at a time "CB-mode".
679  * An operation can be performed on one or multiple CBs that logically
680  * belong to a TB "TB-mode".
681  *
682  * The input data is the CB or TB input to the decoder.
683  *
684  * The output data is the ratematched CB or TB data, or the output after
685  * bit-selection if RTE_BBDEV_LDPC_INTERLEAVER_BYPASS is set.
686  *
687  * The output mbuf data structure is expected to be allocated by the
688  * application with enough room for the output data.
689  */
690 
691 /* Structure rte_bbdev_op_ldpc_enc 8< */
692 struct rte_bbdev_op_ldpc_enc {
693 	/** The input TB or CB data */
694 	struct rte_bbdev_op_data input;
695 	/** The rate matched TB or CB output buffer */
696 	struct rte_bbdev_op_data output;
697 
698 	/** Flags from rte_bbdev_op_ldpcenc_flag_bitmasks */
699 	uint32_t op_flags;
700 
701 	/** Rate matching redundancy version */
702 	uint8_t rv_index;
703 	/** 1: LDPC Base graph 1, 2: LDPC Base graph 2.
704 	 *  [3GPP TS38.212, section 5.2.2]
705 	 */
706 	uint8_t basegraph;
707 	/** Zc, LDPC lifting size.
708 	 *  [3GPP TS38.212, section 5.2.2]
709 	 */
710 	uint16_t z_c;
711 	/** Ncb, length of the circular buffer in bits.
712 	 *  [3GPP TS38.212, section 5.4.2.1]
713 	 */
714 	uint16_t n_cb;
715 	/** Qm, modulation order {2,4,6,8,10}.
716 	 *  [3GPP TS38.212, section 5.4.2.2]
717 	 */
718 	uint8_t q_m;
719 	/** Number of Filler bits, n_filler = K – K’
720 	 *  [3GPP TS38.212 section 5.2.2]
721 	 */
722 	uint16_t n_filler;
723 	/** [0 - TB : 1 - CB] */
724 	uint8_t code_block_mode;
725 	union {
726 		/** Struct which stores Code Block specific parameters */
727 		struct rte_bbdev_op_enc_ldpc_cb_params cb_params;
728 		/** Struct which stores Transport Block specific parameters */
729 		struct rte_bbdev_op_enc_ldpc_tb_params tb_params;
730 	};
731 };
732 /* >8 End of structure rte_bbdev_op_ldpc_enc. */
733 
734 /** Operation structure for FFT processing.
735  *
736  * The operation processes the data for multiple antennas in a single call
737  * (i.e. for all the REs belonging to a given SRS sequence for instance).
738  *
739  * The output mbuf data structure is expected to be allocated by the
740  * application with enough room for the output data.
741  */
742 
743 /* Structure rte_bbdev_op_fft 8< */
744 struct rte_bbdev_op_fft {
745 	/** Input data starting from first antenna. */
746 	struct rte_bbdev_op_data base_input;
747 	/** Output data starting from first antenna and first cyclic shift. */
748 	struct rte_bbdev_op_data base_output;
749 	/** Optional power measurement output data. */
750 	struct rte_bbdev_op_data power_meas_output;
751 	/** Flags from rte_bbdev_op_fft_flag_bitmasks. */
752 	uint32_t op_flags;
753 	/** Input sequence size in 32-bits points. */
754 	uint16_t input_sequence_size;
755 	/** Padding at the start of the sequence. */
756 	uint16_t input_leading_padding;
757 	/** Output sequence size in 32-bits points. */
758 	uint16_t output_sequence_size;
759 	/** Depadding at the start of the DFT output. */
760 	uint16_t output_leading_depadding;
761 	/** Window index being used for each cyclic shift output. */
762 	uint8_t window_index[RTE_BBDEV_MAX_CS_2];
763 	/** Bitmap of the cyclic shift output requested. */
764 	uint16_t cs_bitmap;
765 	/** Number of antennas as a log2 – 8 to 128. */
766 	uint8_t num_antennas_log2;
767 	/** iDFT size as a log2 - 32 to 2048. */
768 	uint8_t idft_log2;
769 	/** DFT size as a log2 - 8 to 2048. */
770 	uint8_t dft_log2;
771 	/** Adjustment of position of the cyclic shifts - -31 to 31. */
772 	int8_t cs_time_adjustment;
773 	/** iDFT shift down. */
774 	int8_t idft_shift;
775 	/** DFT shift down. */
776 	int8_t dft_shift;
777 	/** NCS reciprocal factor. */
778 	uint16_t ncs_reciprocal;
779 	/** Power measurement out shift down. */
780 	uint16_t power_shift;
781 	/** Adjust the FP6 exponent for INT<->FP16 conversion. */
782 	uint16_t fp16_exp_adjust;
783 };
784 /* >8 End of structure rte_bbdev_op_fft. */
785 
786 /** List of the capabilities for the Turbo Decoder */
787 struct rte_bbdev_op_cap_turbo_dec {
788 	/** Flags from rte_bbdev_op_td_flag_bitmasks */
789 	uint32_t capability_flags;
790 	/** Maximal LLR absolute value. Acceptable LLR values lie in range
791 	 * [-max_llr_modulus, max_llr_modulus].
792 	 */
793 	int8_t max_llr_modulus;
794 	/** Num input code block buffers */
795 	uint8_t num_buffers_src;  /**< Num input code block buffers */
796 	/** Num hard output code block buffers */
797 	uint8_t num_buffers_hard_out;
798 	/** Num soft output code block buffers if supported by the driver */
799 	uint8_t num_buffers_soft_out;
800 };
801 
802 /** List of the capabilities for the Turbo Encoder */
803 struct rte_bbdev_op_cap_turbo_enc {
804 	/** Flags from rte_bbdev_op_te_flag_bitmasks */
805 	uint32_t capability_flags;
806 	/** Num input code block buffers */
807 	uint8_t num_buffers_src;
808 	/** Num output code block buffers */
809 	uint8_t num_buffers_dst;
810 };
811 
812 /** List of the capabilities for the LDPC Decoder */
813 struct rte_bbdev_op_cap_ldpc_dec {
814 	/** Flags from rte_bbdev_op_ldpcdec_flag_bitmasks */
815 	uint32_t capability_flags;
816 	/** LLR size in bits. LLR is a two’s complement number. */
817 	int8_t llr_size;
818 	/** LLR numbers of decimals bit for arithmetic representation */
819 	int8_t llr_decimals;
820 	/** Num input code block buffers */
821 	uint16_t num_buffers_src;
822 	/** Num hard output code block buffers */
823 	uint16_t num_buffers_hard_out;
824 	/** Num soft output code block buffers if supported by the driver */
825 	uint16_t num_buffers_soft_out;
826 };
827 
828 /** List of the capabilities for the LDPC Encoder */
829 struct rte_bbdev_op_cap_ldpc_enc {
830 	/** Flags from rte_bbdev_op_ldpcenc_flag_bitmasks */
831 	uint32_t capability_flags;
832 	/** Num input code block buffers */
833 	uint16_t num_buffers_src;
834 	/** Num output code block buffers */
835 	uint16_t num_buffers_dst;
836 };
837 
838 /** List of the capabilities for the FFT. */
839 struct rte_bbdev_op_cap_fft {
840 	/** Flags from *rte_bbdev_op_fft_flag_bitmasks*. */
841 	uint32_t capability_flags;
842 	/** Number of input code block buffers. */
843 	uint16_t num_buffers_src;
844 	/** Number of output code block buffers. */
845 	uint16_t num_buffers_dst;
846 };
847 
848 /** Different operation types supported by the device.
849  *  The related macro RTE_BBDEV_OP_TYPE_SIZE_MAX can be used as an absolute maximum for
850  *  notably sizing array while allowing for future enumeration insertion.
851  */
852 enum rte_bbdev_op_type {
853 	RTE_BBDEV_OP_NONE,  /**< Dummy operation that does nothing */
854 	RTE_BBDEV_OP_TURBO_DEC,  /**< Turbo decode */
855 	RTE_BBDEV_OP_TURBO_ENC,  /**< Turbo encode */
856 	RTE_BBDEV_OP_LDPC_DEC,  /**< LDPC decode */
857 	RTE_BBDEV_OP_LDPC_ENC,  /**< LDPC encode */
858 	RTE_BBDEV_OP_FFT,  /**< FFT */
859 	/* Note: RTE_BBDEV_OP_TYPE_SIZE_MAX must be larger or equal to maximum enum value */
860 };
861 
862 /** Bit indexes of possible errors reported through status field */
863 enum {
864 	RTE_BBDEV_DRV_ERROR,
865 	RTE_BBDEV_DATA_ERROR,
866 	RTE_BBDEV_CRC_ERROR,
867 	RTE_BBDEV_SYNDROME_ERROR
868 };
869 
870 /** Structure specifying a single encode operation */
871 struct rte_bbdev_enc_op {
872 	/** Status of operation that was performed */
873 	int status;
874 	/** Mempool which op instance is in */
875 	struct rte_mempool *mempool;
876 	/** Opaque pointer for user data */
877 	void *opaque_data;
878 	union {
879 		/** Contains turbo decoder specific parameters */
880 		struct rte_bbdev_op_turbo_enc turbo_enc;
881 		/** Contains LDPC decoder specific parameters */
882 		struct rte_bbdev_op_ldpc_enc ldpc_enc;
883 	};
884 };
885 
886 /** Structure specifying a single decode operation */
887 struct rte_bbdev_dec_op {
888 	/** Status of operation that was performed */
889 	int status;
890 	/** Mempool which op instance is in */
891 	struct rte_mempool *mempool;
892 	/** Opaque pointer for user data */
893 	void *opaque_data;
894 	union {
895 		/** Contains turbo decoder specific parameters */
896 		struct rte_bbdev_op_turbo_dec turbo_dec;
897 		/** Contains LDPC decoder specific parameters */
898 		struct rte_bbdev_op_ldpc_dec ldpc_dec;
899 	};
900 };
901 
902 /** Structure specifying a single FFT operation. */
903 struct rte_bbdev_fft_op {
904 	/** Status of operation performed. */
905 	int status;
906 	/** Mempool used for op instance. */
907 	struct rte_mempool *mempool;
908 	/** Opaque pointer for user data. */
909 	void *opaque_data;
910 	/** Contains turbo decoder specific parameters. */
911 	struct rte_bbdev_op_fft fft;
912 };
913 
914 /** Operation capabilities supported by a device */
915 struct rte_bbdev_op_cap {
916 	enum rte_bbdev_op_type type;  /**< Type of operation */
917 	union {
918 		struct rte_bbdev_op_cap_turbo_dec turbo_dec;
919 		struct rte_bbdev_op_cap_turbo_enc turbo_enc;
920 		struct rte_bbdev_op_cap_ldpc_dec ldpc_dec;
921 		struct rte_bbdev_op_cap_ldpc_enc ldpc_enc;
922 		struct rte_bbdev_op_cap_fft fft;
923 	} cap;  /**< Operation-type specific capabilities */
924 };
925 
926 /** @internal Private data structure stored with operation pool. */
927 struct rte_bbdev_op_pool_private {
928 	enum rte_bbdev_op_type type;  /**< Type of operations in a pool */
929 };
930 
931 /**
932  * Converts queue operation type from enum to string
933  *
934  * @param op_type
935  *   Operation type as enum
936  *
937  * @returns
938  *   Operation type as string or NULL if op_type is invalid
939  *
940  */
941 const char*
942 rte_bbdev_op_type_str(enum rte_bbdev_op_type op_type);
943 
944 /**
945  * Creates a bbdev operation mempool
946  *
947  * @param name
948  *   Pool name.
949  * @param type
950  *   Operation type, use RTE_BBDEV_OP_NONE for a pool which supports all
951  *   operation types.
952  * @param num_elements
953  *   Number of elements in the pool.
954  * @param cache_size
955  *   Number of elements to cache on an lcore, see rte_mempool_create() for
956  *   further details about cache size.
957  * @param socket_id
958  *   Socket to allocate memory on.
959  *
960  * @return
961  *   - Pointer to a mempool on success,
962  *   - NULL pointer on failure.
963  */
964 struct rte_mempool *
965 rte_bbdev_op_pool_create(const char *name, enum rte_bbdev_op_type type,
966 		unsigned int num_elements, unsigned int cache_size,
967 		int socket_id);
968 
969 /**
970  * Bulk allocate encode operations from a mempool with parameter defaults reset.
971  *
972  * @param mempool
973  *   Operation mempool, created by rte_bbdev_op_pool_create().
974  * @param ops
975  *   Output array to place allocated operations
976  * @param num_ops
977  *   Number of operations to allocate
978  *
979  * @returns
980  *   - 0 on success
981  *   - EINVAL if invalid mempool is provided
982  */
983 static inline int
984 rte_bbdev_enc_op_alloc_bulk(struct rte_mempool *mempool,
985 		struct rte_bbdev_enc_op **ops, uint16_t num_ops)
986 {
987 	struct rte_bbdev_op_pool_private *priv;
988 
989 	/* Check type */
990 	priv = (struct rte_bbdev_op_pool_private *)
991 			rte_mempool_get_priv(mempool);
992 	if (unlikely((priv->type != RTE_BBDEV_OP_TURBO_ENC) &&
993 					(priv->type != RTE_BBDEV_OP_LDPC_ENC)))
994 		return -EINVAL;
995 
996 	/* Get elements */
997 	return rte_mempool_get_bulk(mempool, (void **)ops, num_ops);
998 }
999 
1000 /**
1001  * Bulk allocate decode operations from a mempool with parameter defaults reset.
1002  *
1003  * @param mempool
1004  *   Operation mempool, created by rte_bbdev_op_pool_create().
1005  * @param ops
1006  *   Output array to place allocated operations
1007  * @param num_ops
1008  *   Number of operations to allocate
1009  *
1010  * @returns
1011  *   - 0 on success
1012  *   - EINVAL if invalid mempool is provided
1013  */
1014 static inline int
1015 rte_bbdev_dec_op_alloc_bulk(struct rte_mempool *mempool,
1016 		struct rte_bbdev_dec_op **ops, uint16_t num_ops)
1017 {
1018 	struct rte_bbdev_op_pool_private *priv;
1019 
1020 	/* Check type */
1021 	priv = (struct rte_bbdev_op_pool_private *)
1022 			rte_mempool_get_priv(mempool);
1023 	if (unlikely((priv->type != RTE_BBDEV_OP_TURBO_DEC) &&
1024 					(priv->type != RTE_BBDEV_OP_LDPC_DEC)))
1025 		return -EINVAL;
1026 
1027 	/* Get elements */
1028 	return rte_mempool_get_bulk(mempool, (void **)ops, num_ops);
1029 }
1030 
1031 /**
1032  * Bulk allocate FFT operations from a mempool with default parameters.
1033  *
1034  * @param mempool
1035  *   Operation mempool, created by *rte_bbdev_op_pool_create*.
1036  * @param ops
1037  *   Output array to place allocated operations.
1038  * @param num_ops
1039  *   Number of operations to allocate.
1040  *
1041  * @returns
1042  *   - 0 on success.
1043  *   - EINVAL if invalid mempool is provided.
1044  */
1045 __rte_experimental
1046 static inline int
1047 rte_bbdev_fft_op_alloc_bulk(struct rte_mempool *mempool,
1048 		struct rte_bbdev_fft_op **ops, uint16_t num_ops)
1049 {
1050 	struct rte_bbdev_op_pool_private *priv;
1051 
1052 	/* Check type */
1053 	priv = (struct rte_bbdev_op_pool_private *)rte_mempool_get_priv(mempool);
1054 	if (unlikely(priv->type != RTE_BBDEV_OP_FFT))
1055 		return -EINVAL;
1056 
1057 	/* Get elements */
1058 	return rte_mempool_get_bulk(mempool, (void **)ops, num_ops);
1059 }
1060 
1061 /**
1062  * Free decode operation structures that were allocated by
1063  * rte_bbdev_dec_op_alloc_bulk().
1064  * All structures must belong to the same mempool.
1065  *
1066  * @param ops
1067  *   Operation structures
1068  * @param num_ops
1069  *   Number of structures
1070  */
1071 static inline void
1072 rte_bbdev_dec_op_free_bulk(struct rte_bbdev_dec_op **ops, unsigned int num_ops)
1073 {
1074 	if (num_ops > 0)
1075 		rte_mempool_put_bulk(ops[0]->mempool, (void **)ops, num_ops);
1076 }
1077 
1078 /**
1079  * Free encode operation structures that were allocated by
1080  * rte_bbdev_enc_op_alloc_bulk().
1081  * All structures must belong to the same mempool.
1082  *
1083  * @param ops
1084  *   Operation structures
1085  * @param num_ops
1086  *   Number of structures
1087  */
1088 static inline void
1089 rte_bbdev_enc_op_free_bulk(struct rte_bbdev_enc_op **ops, unsigned int num_ops)
1090 {
1091 	if (num_ops > 0)
1092 		rte_mempool_put_bulk(ops[0]->mempool, (void **)ops, num_ops);
1093 }
1094 
1095 /**
1096  * Free encode operation structures that were allocated by
1097  * *rte_bbdev_fft_op_alloc_bulk*.
1098  * All structures must belong to the same mempool.
1099  *
1100  * @param ops
1101  *   Operation structures.
1102  * @param num_ops
1103  *   Number of structures.
1104  */
1105 __rte_experimental
1106 static inline void
1107 rte_bbdev_fft_op_free_bulk(struct rte_bbdev_fft_op **ops, unsigned int num_ops)
1108 {
1109 	if (num_ops > 0)
1110 		rte_mempool_put_bulk(ops[0]->mempool, (void **)ops, num_ops);
1111 }
1112 
1113 #ifdef __cplusplus
1114 }
1115 #endif
1116 
1117 #endif /* _RTE_BBDEV_OP_H_ */
1118