devtools: pass custom options to checkpatch
[dpdk.git] / lib / librte_bbdev / rte_bbdev_op.h
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  * @warning
14  * @b EXPERIMENTAL: this API may change without prior notice
15  */
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 #include <stdint.h>
22
23 #include <rte_common.h>
24 #include <rte_mbuf.h>
25 #include <rte_memory.h>
26 #include <rte_mempool.h>
27
28 /* Number of columns in sub-block interleaver (36.212, section 5.1.4.1.1) */
29 #define RTE_BBDEV_C_SUBBLOCK (32)
30 /* Maximum size of Transport Block (36.213, Table, Table 7.1.7.2.5-1) */
31 #define RTE_BBDEV_MAX_TB_SIZE (391656)
32 /* Maximum size of Code Block (36.212, Table 5.1.3-3) */
33 #define RTE_BBDEV_MAX_CB_SIZE (6144)
34 /* Minimum size of Code Block (36.212, Table 5.1.3-3) */
35 #define RTE_BBDEV_MIN_CB_SIZE (40)
36 /* Maximum size of circular buffer */
37 #define RTE_BBDEV_MAX_KW (18528)
38 /*
39  * Maximum number of Code Blocks in Transport Block. It is calculated based on
40  * maximum size of one Code Block and one Transport Block (considering CRC24A
41  * and CRC24B):
42  * (391656 + 24) / (6144 - 24) = 64
43  */
44 #define RTE_BBDEV_MAX_CODE_BLOCKS (64)
45
46 /** Flags for turbo decoder operation and capability structure */
47 enum rte_bbdev_op_td_flag_bitmasks {
48         /**< If sub block de-interleaving is to be performed. */
49         RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE = (1ULL << 0),
50         /**< To use CRC Type 24B (otherwise use CRC Type 24A). */
51         RTE_BBDEV_TURBO_CRC_TYPE_24B = (1ULL << 1),
52         /**< If turbo equalization is to be performed. */
53         RTE_BBDEV_TURBO_EQUALIZER = (1ULL << 2),
54         /**< If set, saturate soft output to +/-127 */
55         RTE_BBDEV_TURBO_SOFT_OUT_SATURATE = (1ULL << 3),
56         /**< Set to 1 to start iteration from even, else odd; one iteration =
57          * max_iteration + 0.5
58          */
59         RTE_BBDEV_TURBO_HALF_ITERATION_EVEN = (1ULL << 4),
60         /**< If 0, TD stops after CRC matches; else if 1, runs to end of next
61          * odd iteration after CRC matches
62          */
63         RTE_BBDEV_TURBO_CONTINUE_CRC_MATCH = (1ULL << 5),
64         /**< Set if soft output is required to be output  */
65         RTE_BBDEV_TURBO_SOFT_OUTPUT = (1ULL << 6),
66         /**< Set to enable early termination mode */
67         RTE_BBDEV_TURBO_EARLY_TERMINATION = (1ULL << 7),
68         /**< Set if a device supports decoder dequeue interrupts */
69         RTE_BBDEV_TURBO_DEC_INTERRUPTS = (1ULL << 9),
70         /**< Set if positive LLR encoded input is supported. Positive LLR value
71          * represents the level of confidence for bit '1', and vice versa for
72          * bit '0'.
73          * This is mutually exclusive with RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN
74          * when used to formalize the input data format.
75          */
76         RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN = (1ULL << 10),
77         /**< Set if negative LLR encoded input is supported. Negative LLR value
78          * represents the level of confidence for bit '1', and vice versa for
79          * bit '0'.
80          * This is mutually exclusive with RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN
81          * when used to formalize the input data format.
82          */
83         RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN = (1ULL << 11),
84         /**< Set if positive LLR soft output 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
88          * RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT when used to formalize
89          * the input data format.
90          */
91         RTE_BBDEV_TURBO_POS_LLR_1_BIT_SOFT_OUT = (1ULL << 12),
92         /**< Set if negative LLR soft output 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
96          * RTE_BBDEV_TURBO_POS_LLR_1_BIT_SOFT_OUT when used to formalize the
97          * input data format.
98          */
99         RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT = (1ULL << 13),
100         /**< Set if driver supports flexible parallel MAP engine decoding. If
101          * not supported, num_maps (number of MAP engines) argument is unusable.
102          */
103         RTE_BBDEV_TURBO_MAP_DEC = (1ULL << 14),
104         /**< Set if a device supports scatter-gather functionality */
105         RTE_BBDEV_TURBO_DEC_SCATTER_GATHER = (1ULL << 15),
106         /**< Set to keep CRC24B bits appended while decoding. Only usable when
107          * decoding Transport Blocks (code_block_mode = 0).
108          */
109         RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP = (1ULL << 16)
110 };
111
112 /** Flags for turbo encoder operation and capability structure */
113 enum rte_bbdev_op_te_flag_bitmasks {
114         /**< Ignore rv_index and set K0 = 0 */
115         RTE_BBDEV_TURBO_RV_INDEX_BYPASS = (1ULL << 0),
116         /**< If rate matching is to be performed */
117         RTE_BBDEV_TURBO_RATE_MATCH = (1ULL << 1),
118         /**< This bit must be set to enable CRC-24B generation */
119         RTE_BBDEV_TURBO_CRC_24B_ATTACH = (1ULL << 2),
120         /**< This bit must be set to enable CRC-24A generation */
121         RTE_BBDEV_TURBO_CRC_24A_ATTACH = (1ULL << 3),
122         /**< Set if a device supports encoder dequeue interrupts */
123         RTE_BBDEV_TURBO_ENC_INTERRUPTS = (1ULL << 4),
124         /**< Set if a device supports scatter-gather functionality */
125         RTE_BBDEV_TURBO_ENC_SCATTER_GATHER = (1ULL << 5)
126 };
127
128 /**< Data input and output buffer for BBDEV operations */
129 struct rte_bbdev_op_data {
130         /**< The mbuf data structure representing the data for BBDEV operation.
131          *
132          * This mbuf pointer can point to one Code Block (CB) data buffer or
133          * multiple CBs contiguously located next to each other.
134          * A Transport Block (TB) represents a whole piece of data that is
135          * divided into one or more CBs. Maximum number of CBs can be contained
136          * in one TB is defined by RTE_BBDEV_MAX_CODE_BLOCKS.
137          *
138          * An mbuf data structure cannot represent more than one TB. The
139          * smallest piece of data that can be contained in one mbuf is one CB.
140          * An mbuf can include one contiguous CB, subset of contiguous CBs that
141          * are belonging to one TB, or all contiguous CBs that are belonging to
142          * one TB.
143          *
144          * If a BBDEV PMD supports the extended capability "Scatter-Gather",
145          * then it is capable of collecting (gathering) non-contiguous
146          * (scattered) data from multiple locations in the memory.
147          * This capability is reported by the capability flags:
148          * - RTE_BBDEV_TURBO_ENC_SCATTER_GATHER and
149          * - RTE_BBDEV_TURBO_DEC_SCATTER_GATHER.
150          * Only if a BBDEV PMD supports this feature, chained mbuf data
151          * structures are accepted. A chained mbuf can represent one
152          * non-contiguous CB or multiple non-contiguous CBs.
153          * If BBDEV PMD does not support this feature, it will assume inbound
154          * mbuf data contains one segment.
155          *
156          * The output mbuf data though is always one segment, even if the input
157          * was a chained mbuf.
158          */
159         struct rte_mbuf *data;
160         /**< The starting point of the BBDEV (encode/decode) operation,
161          * in bytes.
162          *
163          * BBDEV starts to read data past this offset.
164          * In case of chained mbuf, this offset applies only to the first mbuf
165          * segment.
166          */
167         uint32_t offset;
168         /**< The total data length to be processed in one operation, in bytes.
169          *
170          * In case the mbuf data is representing one CB, this is the length of
171          * the CB undergoing the operation.
172          * If it's for multiple CBs, this is the total length of those CBs
173          * undergoing the operation.
174          * If it's for one TB, this is the total length of the TB under
175          * operation.
176          *
177          * In case of chained mbuf, this data length includes the lengths of the
178          * "scattered" data segments undergoing the operation.
179          */
180         uint32_t length;
181 };
182
183 struct rte_bbdev_op_dec_cb_params {
184         /**< The K size of the input CB, in bits [40:6144], as specified in
185          * 3GPP TS 36.212.
186          * This size is inclusive of CRC bits, regardless whether it was
187          * pre-calculated by the application or not.
188          */
189         uint16_t k;
190         /**< The E length of the CB rate matched LLR output, in bytes, as in
191          * 3GPP TS 36.212.
192          */
193         uint32_t e;
194 };
195
196 struct rte_bbdev_op_dec_tb_params {
197         /**< The K- size of the input CB, in bits [40:6144], that is in the
198          * Turbo operation when r < C-, as in 3GPP TS 36.212.
199          */
200         uint16_t k_neg;
201         /**< The K+ size of the input CB, in bits [40:6144], that is in the
202          * Turbo operation when r >= C-, as in 3GPP TS 36.212.
203          */
204         uint16_t k_pos;
205         /**< The number of CBs that have K- size, [0:63] */
206         uint8_t c_neg;
207         /**< The total number of CBs in the TB, [1:RTE_BBDEV_MAX_CODE_BLOCKS] */
208         uint8_t c;
209         /**< The number of CBs that uses Ea before switching to Eb, [0:63] */
210         uint8_t cab;
211         /**< The E size of the CB rate matched output to use in the Turbo
212          * operation when r < cab
213          */
214         uint32_t ea;
215         /**< The E size of the CB rate matched output to use in the Turbo
216          * operation when r >= cab
217          */
218         uint32_t eb;
219         /**< The index of the first CB in the inbound mbuf data, default is 0 */
220         uint8_t r;
221 };
222
223 /**< Operation structure for Turbo decode.
224  * An operation can perform on one CB at a time "CB-mode".
225  * An operation can perform on one or multiple CBs that are logically belonging
226  * to one TB "TB-mode".
227  * The provided K size parameter of the CB is its size out coming from the
228  * decode operation.
229  * CRC24A/B check is requested by the application by setting the flag
230  * RTE_BBDEV_TURBO_CRC_TYPE_24B for CRC24B check or CRC24A otherwise.
231  * In TB-mode, BBDEV concatenates the decoded CBs one next to the other with
232  * relevant CRC24B in between.
233  *
234  * The input encoded CB data is the Virtual Circular Buffer data stream, wk,
235  * with the null padding included as described in 3GPP TS 36.212
236  * section 5.1.4.1.2 and shown in 3GPP TS 36.212 section 5.1.4.1 Figure 5.1.4-1.
237  * The size of the virtual circular buffer is 3*Kpi, where Kpi is the 32 byte
238  * aligned value of K, as specified in 3GPP TS 36.212 section 5.1.4.1.1.
239  *
240  * Each byte in the input circular buffer is the LLR value of each bit of the
241  * original CB.
242  *
243  * Hard output is a mandatory capability that all BBDEV PMDs support. This is
244  * the decoded CBs of K sizes (CRC24A/B is the last 24-bit in each decoded CB).
245  * Soft output is an optional capability for BBDEV PMDs. If supported, an LLR
246  * rate matched output is computed in the soft_output buffer structure.
247  *
248  * The output mbuf data structure is expected to be allocated by the
249  * application with enough room for the output data.
250  */
251 struct rte_bbdev_op_turbo_dec {
252         /**< The Virtual Circular Buffer, wk, size 3*Kpi for each CB */
253         struct rte_bbdev_op_data input;
254         /**< The hard decisions buffer for the decoded output,
255          * size K for each CB
256          */
257         struct rte_bbdev_op_data hard_output;
258         /**< The soft LLR output buffer - optional */
259         struct rte_bbdev_op_data soft_output;
260
261         uint32_t op_flags;  /**< Flags from rte_bbdev_op_td_flag_bitmasks */
262         uint8_t rv_index;  /**< Rv index for rate matching [0:3] */
263         /**< The minimum number of iterations to perform in decoding all CBs in
264          * this operation - input
265          */
266         uint8_t iter_min:4;
267         /**< The maximum number of iterations to perform in decoding all CBs in
268          * this operation - input
269          */
270         uint8_t iter_max:4;
271         /**< The maximum number of iterations that were perform in decoding all
272          * CBs in this decode operation - output
273          */
274         uint8_t iter_count;
275         /**< 5 bit extrinsic scale (scale factor on extrinsic info) */
276         uint8_t ext_scale;
277         /**< Number of MAP engines to use in decode,
278          * must be power of 2 (or 0 to auto-select)
279          */
280         uint8_t num_maps;
281
282         uint8_t code_block_mode; /**< [0 - TB : 1 - CB] */
283         union {
284                 /**< Struct which stores Code Block specific parameters */
285                 struct rte_bbdev_op_dec_cb_params cb_params;
286                 /**< Struct which stores Transport Block specific parameters */
287                 struct rte_bbdev_op_dec_tb_params tb_params;
288         };
289 };
290
291 struct rte_bbdev_op_enc_cb_params {
292         /**< The K size of the input CB, in bits [40:6144], as specified in
293          * 3GPP TS 36.212.
294          * This size is inclusive of CRC24A, regardless whether it was
295          * pre-calculated by the application or not.
296          */
297         uint16_t k;
298         /**< The E length of the CB rate matched output, in bits, as in
299          * 3GPP TS 36.212.
300          */
301         uint32_t e;
302         /**< The Ncb soft buffer size of the CB rate matched output [K:3*Kpi],
303          * in bits, as specified in 3GPP TS 36.212.
304          */
305         uint16_t ncb;
306 };
307
308 struct rte_bbdev_op_enc_tb_params {
309         /**< The K- size of the input CB, in bits [40:6144], that is in the
310          * Turbo operation when r < C-, as in 3GPP TS 36.212.
311          * This size is inclusive of CRC24B, regardless whether it was
312          * pre-calculated and appended by the application or not.
313          */
314         uint16_t k_neg;
315         /**< The K+ size of the input CB, in bits [40:6144], that is in the
316          * Turbo operation when r >= C-, as in 3GPP TS 36.212.
317          * This size is inclusive of CRC24B, regardless whether it was
318          * pre-calculated and appended by the application or not.
319          */
320         uint16_t k_pos;
321         /**< The number of CBs that have K- size, [0:63] */
322         uint8_t c_neg;
323         /**< The total number of CBs in the TB, [1:RTE_BBDEV_MAX_CODE_BLOCKS] */
324         uint8_t c;
325         /**< The number of CBs that uses Ea before switching to Eb, [0:63] */
326         uint8_t cab;
327         /**< The E size of the CB rate matched output to use in the Turbo
328          * operation when r < cab
329          */
330         uint32_t ea;
331         /**< The E size of the CB rate matched output to use in the Turbo
332          * operation when r >= cab
333          */
334         uint32_t eb;
335         /**< The Ncb soft buffer size for the rate matched CB that is used in
336          * the Turbo operation when r < C-, [K:3*Kpi]
337          */
338         uint16_t ncb_neg;
339         /**< The Ncb soft buffer size for the rate matched CB that is used in
340          * the Turbo operation when r >= C-, [K:3*Kpi]
341          */
342         uint16_t ncb_pos;
343         /**< The index of the first CB in the inbound mbuf data, default is 0 */
344         uint8_t r;
345 };
346
347 /**< Operation structure for Turbo encode.
348  * An operation can perform on one CB at a time "CB-mode".
349  * An operation can perform on one or multiple CBs that are logically
350  * belonging to one TB "TB-mode".
351  *
352  * In CB-mode, CRC24A/B is an optional operation. K size parameter is not
353  * affected by CRC24A/B inclusion, this only affects the inbound mbuf data
354  * length. Not all BBDEV PMDs are capable of CRC24A/B calculation. Flags
355  * RTE_BBDEV_TURBO_CRC_24A_ATTACH and RTE_BBDEV_TURBO_CRC_24B_ATTACH informs
356  * the application with relevant capability. These flags can be set in the
357  * op_flags parameter to indicate BBDEV to calculate and append CRC24A to CB
358  * before going forward with Turbo encoding.
359  *
360  * In TB-mode, CRC24A is assumed to be pre-calculated and appended to the
361  * inbound TB mbuf data buffer.
362  *
363  * The output mbuf data structure is expected to be allocated by the
364  * application with enough room for the output data.
365  */
366 struct rte_bbdev_op_turbo_enc {
367         /**< The input CB or TB data */
368         struct rte_bbdev_op_data input;
369         /**< The rate matched CB or TB output buffer */
370         struct rte_bbdev_op_data output;
371
372         uint32_t op_flags;  /**< Flags from rte_bbdev_op_te_flag_bitmasks */
373         uint8_t rv_index;  /**< Rv index for rate matching [0:3] */
374
375         uint8_t code_block_mode; /**< [0 - TB : 1 - CB] */
376         union {
377                 /**< Struct which stores Code Block specific parameters */
378                 struct rte_bbdev_op_enc_cb_params cb_params;
379                 /**< Struct which stores Transport Block specific parameters */
380                 struct rte_bbdev_op_enc_tb_params tb_params;
381         };
382 };
383
384 /**< List of the capabilities for the Turbo Decoder */
385 struct rte_bbdev_op_cap_turbo_dec {
386         /**< Flags from rte_bbdev_op_td_flag_bitmasks */
387         uint32_t capability_flags;
388         /** Maximal LLR absolute value. Acceptable LLR values lie in range
389          * [-max_llr_modulus, max_llr_modulus].
390          */
391         int8_t max_llr_modulus;
392         uint8_t num_buffers_src;  /**< Num input code block buffers */
393         /**< Num hard output code block buffers */
394         uint8_t num_buffers_hard_out;
395         /**< Num soft output code block buffers if supported by the driver */
396         uint8_t num_buffers_soft_out;
397 };
398
399 /**< List of the capabilities for the Turbo Encoder */
400 struct rte_bbdev_op_cap_turbo_enc {
401         /**< Flags from rte_bbdev_op_te_flag_bitmasks */
402         uint32_t capability_flags;
403         uint8_t num_buffers_src;  /**< Num input code block buffers */
404         uint8_t num_buffers_dst;  /**< Num output code block buffers */
405 };
406
407 /** Different operation types supported by the device */
408 enum rte_bbdev_op_type {
409         RTE_BBDEV_OP_NONE,  /**< Dummy operation that does nothing */
410         RTE_BBDEV_OP_TURBO_DEC,  /**< Turbo decode */
411         RTE_BBDEV_OP_TURBO_ENC,  /**< Turbo encode */
412         RTE_BBDEV_OP_TYPE_COUNT,  /**< Count of different op types */
413 };
414
415 /**< Bit indexes of possible errors reported through status field */
416 enum {
417         RTE_BBDEV_DRV_ERROR,
418         RTE_BBDEV_DATA_ERROR,
419         RTE_BBDEV_CRC_ERROR,
420 };
421
422 /**< Structure specifying a single encode operation */
423 struct rte_bbdev_enc_op {
424         int status;  /**< Status of operation that was performed */
425         struct rte_mempool *mempool;  /**< Mempool which op instance is in */
426         void *opaque_data;  /**< Opaque pointer for user data */
427         /**< Contains encoder specific parameters */
428         struct rte_bbdev_op_turbo_enc turbo_enc;
429 };
430
431 /**< Structure specifying a single decode operation */
432 struct rte_bbdev_dec_op {
433         int status;  /**< Status of operation that was performed */
434         struct rte_mempool *mempool;  /**< Mempool which op instance is in */
435         void *opaque_data;  /**< Opaque pointer for user data */
436         /**< Contains decoder specific parameters */
437         struct rte_bbdev_op_turbo_dec turbo_dec;
438 };
439
440 /**< Operation capabilities supported by a device */
441 struct rte_bbdev_op_cap {
442         enum rte_bbdev_op_type type;  /**< Type of operation */
443         union {
444                 struct rte_bbdev_op_cap_turbo_dec turbo_dec;
445                 struct rte_bbdev_op_cap_turbo_enc turbo_enc;
446         } cap;  /**< Operation-type specific capabilities */
447 };
448
449 /**< @internal Private data structure stored with operation pool. */
450 struct rte_bbdev_op_pool_private {
451         enum rte_bbdev_op_type type;  /**< Type of operations in a pool */
452 };
453
454 /**
455  * Converts queue operation type from enum to string
456  *
457  * @param op_type
458  *   Operation type as enum
459  *
460  * @returns
461  *   Operation type as string or NULL if op_type is invalid
462  *
463  */
464 __rte_experimental
465 const char*
466 rte_bbdev_op_type_str(enum rte_bbdev_op_type op_type);
467
468 /**
469  * Creates a bbdev operation mempool
470  *
471  * @param name
472  *   Pool name.
473  * @param type
474  *   Operation type, use RTE_BBDEV_OP_NONE for a pool which supports all
475  *   operation types.
476  * @param num_elements
477  *   Number of elements in the pool.
478  * @param cache_size
479  *   Number of elements to cache on an lcore, see rte_mempool_create() for
480  *   further details about cache size.
481  * @param socket_id
482  *   Socket to allocate memory on.
483  *
484  * @return
485  *   - Pointer to a mempool on success,
486  *   - NULL pointer on failure.
487  */
488 __rte_experimental
489 struct rte_mempool *
490 rte_bbdev_op_pool_create(const char *name, enum rte_bbdev_op_type type,
491                 unsigned int num_elements, unsigned int cache_size,
492                 int socket_id);
493
494 /**
495  * Bulk allocate encode operations from a mempool with parameter defaults reset.
496  *
497  * @param mempool
498  *   Operation mempool, created by rte_bbdev_op_pool_create().
499  * @param ops
500  *   Output array to place allocated operations
501  * @param num_ops
502  *   Number of operations to allocate
503  *
504  * @returns
505  *   - 0 on success
506  *   - EINVAL if invalid mempool is provided
507  */
508 __rte_experimental
509 static inline int
510 rte_bbdev_enc_op_alloc_bulk(struct rte_mempool *mempool,
511                 struct rte_bbdev_enc_op **ops, uint16_t num_ops)
512 {
513         struct rte_bbdev_op_pool_private *priv;
514         int ret;
515
516         /* Check type */
517         priv = (struct rte_bbdev_op_pool_private *)
518                         rte_mempool_get_priv(mempool);
519         if (unlikely(priv->type != RTE_BBDEV_OP_TURBO_ENC))
520                 return -EINVAL;
521
522         /* Get elements */
523         ret = rte_mempool_get_bulk(mempool, (void **)ops, num_ops);
524         if (unlikely(ret < 0))
525                 return ret;
526
527         return 0;
528 }
529
530 /**
531  * Bulk allocate decode operations from a mempool with parameter defaults reset.
532  *
533  * @param mempool
534  *   Operation mempool, created by rte_bbdev_op_pool_create().
535  * @param ops
536  *   Output array to place allocated operations
537  * @param num_ops
538  *   Number of operations to allocate
539  *
540  * @returns
541  *   - 0 on success
542  *   - EINVAL if invalid mempool is provided
543  */
544 __rte_experimental
545 static inline int
546 rte_bbdev_dec_op_alloc_bulk(struct rte_mempool *mempool,
547                 struct rte_bbdev_dec_op **ops, uint16_t num_ops)
548 {
549         struct rte_bbdev_op_pool_private *priv;
550         int ret;
551
552         /* Check type */
553         priv = (struct rte_bbdev_op_pool_private *)
554                         rte_mempool_get_priv(mempool);
555         if (unlikely(priv->type != RTE_BBDEV_OP_TURBO_DEC))
556                 return -EINVAL;
557
558         /* Get elements */
559         ret = rte_mempool_get_bulk(mempool, (void **)ops, num_ops);
560         if (unlikely(ret < 0))
561                 return ret;
562
563         return 0;
564 }
565
566 /**
567  * Free decode operation structures that were allocated by
568  * rte_bbdev_dec_op_alloc_bulk().
569  * All structures must belong to the same mempool.
570  *
571  * @param ops
572  *   Operation structures
573  * @param num_ops
574  *   Number of structures
575  */
576 __rte_experimental
577 static inline void
578 rte_bbdev_dec_op_free_bulk(struct rte_bbdev_dec_op **ops, unsigned int num_ops)
579 {
580         if (num_ops > 0)
581                 rte_mempool_put_bulk(ops[0]->mempool, (void **)ops, num_ops);
582 }
583
584 /**
585  * Free encode operation structures that were allocated by
586  * rte_bbdev_enc_op_alloc_bulk().
587  * All structures must belong to the same mempool.
588  *
589  * @param ops
590  *   Operation structures
591  * @param num_ops
592  *   Number of structures
593  */
594 __rte_experimental
595 static inline void
596 rte_bbdev_enc_op_free_bulk(struct rte_bbdev_enc_op **ops, unsigned int num_ops)
597 {
598         if (num_ops > 0)
599                 rte_mempool_put_bulk(ops[0]->mempool, (void **)ops, num_ops);
600 }
601
602 #ifdef __cplusplus
603 }
604 #endif
605
606 #endif /* _RTE_BBDEV_OP_H_ */