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