1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Intel Corporation
5 #ifndef _RTE_BBDEV_OP_H_
6 #define _RTE_BBDEV_OP_H_
11 * Defines wireless base band layer 1 operations and capabilities
14 * @b EXPERIMENTAL: this API may change without prior notice
23 #include <rte_common.h>
25 #include <rte_memory.h>
26 #include <rte_mempool.h>
28 /* Number of columns in sub-block interleaver (36.212, section 5.1.4.1.1) */
29 #define RTE_BBDEV_TURBO_C_SUBBLOCK (32)
30 /* Maximum size of Transport Block (36.213, Table, Table 7.1.7.2.5-1) */
31 #define RTE_BBDEV_TURBO_MAX_TB_SIZE (391656)
32 /* Maximum size of Code Block (36.212, Table 5.1.3-3) */
33 #define RTE_BBDEV_TURBO_MAX_CB_SIZE (6144)
34 /* Maximum size of Code Block */
35 #define RTE_BBDEV_LDPC_MAX_CB_SIZE (8448)
36 /* Minimum size of Code Block */
37 #define RTE_BBDEV_LDPC_MIN_CB_SIZE (40)
38 /* Maximum E size we can manage with default mbuf */
39 #define RTE_BBDEV_LDPC_E_MAX_MBUF (64000)
40 /* Minimum size of Code Block (36.212, Table 5.1.3-3) */
41 #define RTE_BBDEV_TURBO_MIN_CB_SIZE (40)
42 /* Maximum size of circular buffer */
43 #define RTE_BBDEV_TURBO_MAX_KW (18528)
45 * Turbo: Maximum number of Code Blocks in Transport Block. It is calculated
46 * based on maximum size of one Code Block and one Transport Block
47 * (considering CRC24A and CRC24B):
48 * (391656 + 24) / (6144 - 24) = 64
50 #define RTE_BBDEV_TURBO_MAX_CODE_BLOCKS (64)
51 /* LDPC: Maximum number of Code Blocks in Transport Block.*/
52 #define RTE_BBDEV_LDPC_MAX_CODE_BLOCKS (256)
54 /** Flags for turbo decoder operation and capability structure */
55 enum rte_bbdev_op_td_flag_bitmasks {
56 /** If sub block de-interleaving is to be performed. */
57 RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE = (1ULL << 0),
58 /** To use CRC Type 24B (otherwise use CRC Type 24A). */
59 RTE_BBDEV_TURBO_CRC_TYPE_24B = (1ULL << 1),
60 /** If turbo equalization is to be performed. */
61 RTE_BBDEV_TURBO_EQUALIZER = (1ULL << 2),
62 /** If set, saturate soft output to +/-127 */
63 RTE_BBDEV_TURBO_SOFT_OUT_SATURATE = (1ULL << 3),
64 /** Set to 1 to start iteration from even, else odd; one iteration =
67 RTE_BBDEV_TURBO_HALF_ITERATION_EVEN = (1ULL << 4),
68 /** If 0, TD stops after CRC matches; else if 1, runs to end of next
69 * odd iteration after CRC matches
71 RTE_BBDEV_TURBO_CONTINUE_CRC_MATCH = (1ULL << 5),
72 /** Set if soft output is required to be output */
73 RTE_BBDEV_TURBO_SOFT_OUTPUT = (1ULL << 6),
74 /** Set to enable early termination mode */
75 RTE_BBDEV_TURBO_EARLY_TERMINATION = (1ULL << 7),
76 /** Set if a device supports decoder dequeue interrupts */
77 RTE_BBDEV_TURBO_DEC_INTERRUPTS = (1ULL << 9),
78 /** Set if positive LLR encoded input is supported. Positive LLR value
79 * represents the level of confidence for bit '1', and vice versa for
81 * This is mutually exclusive with RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN
82 * when used to formalize the input data format.
84 RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN = (1ULL << 10),
85 /** Set if negative LLR encoded input is supported. Negative LLR value
86 * represents the level of confidence for bit '1', and vice versa for
88 * This is mutually exclusive with RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN
89 * when used to formalize the input data format.
91 RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN = (1ULL << 11),
92 /** Set if positive LLR soft output is supported. Positive LLR value
93 * represents the level of confidence for bit '1', and vice versa for
95 * This is mutually exclusive with
96 * RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT when used to formalize
97 * the input data format.
99 RTE_BBDEV_TURBO_POS_LLR_1_BIT_SOFT_OUT = (1ULL << 12),
100 /** Set if negative LLR soft output is supported. Negative LLR value
101 * represents the level of confidence for bit '1', and vice versa for
103 * This is mutually exclusive with
104 * RTE_BBDEV_TURBO_POS_LLR_1_BIT_SOFT_OUT when used to formalize the
107 RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT = (1ULL << 13),
108 /** Set if driver supports flexible parallel MAP engine decoding. If
109 * not supported, num_maps (number of MAP engines) argument is unusable.
111 RTE_BBDEV_TURBO_MAP_DEC = (1ULL << 14),
112 /** Set if a device supports scatter-gather functionality */
113 RTE_BBDEV_TURBO_DEC_SCATTER_GATHER = (1ULL << 15),
114 /** Set to keep CRC24B bits appended while decoding. Only usable when
115 * decoding Transport Blocks (code_block_mode = 0).
117 RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP = (1ULL << 16)
121 /** Flags for turbo encoder operation and capability structure */
122 enum rte_bbdev_op_te_flag_bitmasks {
123 /** Ignore rv_index and set K0 = 0 */
124 RTE_BBDEV_TURBO_RV_INDEX_BYPASS = (1ULL << 0),
125 /** If rate matching is to be performed */
126 RTE_BBDEV_TURBO_RATE_MATCH = (1ULL << 1),
127 /** This bit must be set to enable CRC-24B generation */
128 RTE_BBDEV_TURBO_CRC_24B_ATTACH = (1ULL << 2),
129 /** This bit must be set to enable CRC-24A generation */
130 RTE_BBDEV_TURBO_CRC_24A_ATTACH = (1ULL << 3),
131 /** Set if a device supports encoder dequeue interrupts */
132 RTE_BBDEV_TURBO_ENC_INTERRUPTS = (1ULL << 4),
133 /** Set if a device supports scatter-gather functionality */
134 RTE_BBDEV_TURBO_ENC_SCATTER_GATHER = (1ULL << 5)
137 /** Flags for LDPC decoder operation and capability structure */
138 enum rte_bbdev_op_ldpcdec_flag_bitmasks {
139 /** Set for transport block CRC-24A checking */
140 RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK = (1ULL << 0),
141 /** Set for code block CRC-24B checking */
142 RTE_BBDEV_LDPC_CRC_TYPE_24B_CHECK = (1ULL << 1),
143 /** Set to drop the last CRC bits decoding output */
144 RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP = (1ULL << 2),
145 /** Set for bit-level de-interleaver bypass on Rx stream. */
146 RTE_BBDEV_LDPC_DEINTERLEAVER_BYPASS = (1ULL << 3),
147 /** Set for HARQ combined input stream enable. */
148 RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE = (1ULL << 4),
149 /** Set for HARQ combined output stream enable. */
150 RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE = (1ULL << 5),
151 /** Set for LDPC decoder bypass.
152 * RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE must be set.
154 RTE_BBDEV_LDPC_DECODE_BYPASS = (1ULL << 6),
155 /** Set for soft-output stream enable */
156 RTE_BBDEV_LDPC_SOFT_OUT_ENABLE = (1ULL << 7),
157 /** Set for Rate-Matching bypass on soft-out stream. */
158 RTE_BBDEV_LDPC_SOFT_OUT_RM_BYPASS = (1ULL << 8),
159 /** Set for bit-level de-interleaver bypass on soft-output stream. */
160 RTE_BBDEV_LDPC_SOFT_OUT_DEINTERLEAVER_BYPASS = (1ULL << 9),
161 /** Set for iteration stopping on successful decode condition
162 * i.e. a successful syndrome check.
164 RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE = (1ULL << 10),
165 /** Set if a device supports decoder dequeue interrupts. */
166 RTE_BBDEV_LDPC_DEC_INTERRUPTS = (1ULL << 11),
167 /** Set if a device supports scatter-gather functionality. */
168 RTE_BBDEV_LDPC_DEC_SCATTER_GATHER = (1ULL << 12),
169 /** Set if a device supports input/output HARQ compression. */
170 RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION = (1ULL << 13),
171 /** Set if a device supports input LLR compression. */
172 RTE_BBDEV_LDPC_LLR_COMPRESSION = (1ULL << 14),
173 /** Set if a device supports HARQ input from
174 * device's internal memory.
176 RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE = (1ULL << 15),
177 /** Set if a device supports HARQ output to
178 * device's internal memory.
180 RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE = (1ULL << 16),
181 /** Set if a device supports loop-back access to
182 * HARQ internal memory. Intended for troubleshooting.
184 RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK = (1ULL << 17),
185 /** Set if a device includes LLR filler bits in the circular buffer
186 * for HARQ memory. If not set, it is assumed the filler bits are not
187 * in HARQ memory and handled directly by the LDPC decoder.
189 RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_FILLERS = (1ULL << 18)
192 /** Flags for LDPC encoder operation and capability structure */
193 enum rte_bbdev_op_ldpcenc_flag_bitmasks {
194 /** Set for bit-level interleaver bypass on output stream. */
195 RTE_BBDEV_LDPC_INTERLEAVER_BYPASS = (1ULL << 0),
196 /** If rate matching is to be performed */
197 RTE_BBDEV_LDPC_RATE_MATCH = (1ULL << 1),
198 /** Set for transport block CRC-24A attach */
199 RTE_BBDEV_LDPC_CRC_24A_ATTACH = (1ULL << 2),
200 /** Set for code block CRC-24B attach */
201 RTE_BBDEV_LDPC_CRC_24B_ATTACH = (1ULL << 3),
202 /** Set for code block CRC-16 attach */
203 RTE_BBDEV_LDPC_CRC_16_ATTACH = (1ULL << 4),
204 /** Set if a device supports encoder dequeue interrupts. */
205 RTE_BBDEV_LDPC_ENC_INTERRUPTS = (1ULL << 5),
206 /** Set if a device supports scatter-gather functionality. */
207 RTE_BBDEV_LDPC_ENC_SCATTER_GATHER = (1ULL << 6),
208 /** Set if a device supports concatenation of non byte aligned output */
209 RTE_BBDEV_LDPC_ENC_CONCATENATION = (1ULL << 7)
212 /** Data input and output buffer for BBDEV operations */
213 struct rte_bbdev_op_data {
214 /** The mbuf data structure representing the data for BBDEV operation.
216 * This mbuf pointer can point to one Code Block (CB) data buffer or
217 * multiple CBs contiguously located next to each other.
218 * A Transport Block (TB) represents a whole piece of data that is
219 * divided into one or more CBs. Maximum number of CBs can be contained
220 * in one TB is defined by RTE_BBDEV_(TURBO/LDPC)_MAX_CODE_BLOCKS.
222 * An mbuf data structure cannot represent more than one TB. The
223 * smallest piece of data that can be contained in one mbuf is one CB.
224 * An mbuf can include one contiguous CB, subset of contiguous CBs that
225 * are belonging to one TB, or all contiguous CBs that are belonging to
228 * If a BBDEV PMD supports the extended capability "Scatter-Gather",
229 * then it is capable of collecting (gathering) non-contiguous
230 * (scattered) data from multiple locations in the memory.
231 * This capability is reported by the capability flags:
232 * - RTE_BBDEV_(TURBO/LDPC)_ENC_SCATTER_GATHER and
233 * - RTE_BBDEV_(TURBO/LDPC)_DEC_SCATTER_GATHER.
234 * Only if a BBDEV PMD supports this feature, chained mbuf data
235 * structures are accepted. A chained mbuf can represent one
236 * non-contiguous CB or multiple non-contiguous CBs.
237 * If BBDEV PMD does not support this feature, it will assume inbound
238 * mbuf data contains one segment.
240 * The output mbuf data though is always one segment, even if the input
241 * was a chained mbuf.
243 struct rte_mbuf *data;
244 /** The starting point of the BBDEV (encode/decode) operation,
247 * BBDEV starts to read data past this offset.
248 * In case of chained mbuf, this offset applies only to the first mbuf
252 /** The total data length to be processed in one operation, in bytes.
254 * In case the mbuf data is representing one CB, this is the length of
255 * the CB undergoing the operation.
256 * If it's for multiple CBs, this is the total length of those CBs
257 * undergoing the operation.
258 * If it is for one TB, this is the total length of the TB under
261 * In case of chained mbuf, this data length includes the lengths of the
262 * "scattered" data segments undergoing the operation.
267 /** Turbo decode code block parameters */
268 struct rte_bbdev_op_dec_turbo_cb_params {
269 /** The K size of the input CB, in bits [40:6144], as specified in
271 * This size is inclusive of CRC bits, regardless whether it was
272 * pre-calculated by the application or not.
275 /** The E length of the CB rate matched LLR output, in bytes, as in
281 /** LDPC decode code block parameters */
282 struct rte_bbdev_op_dec_ldpc_cb_params {
283 /** Rate matching output sequence length in bits or LLRs.
284 * [3GPP TS38.212, section 5.4.2.1]
289 /** Turbo decode transport block parameters */
290 struct rte_bbdev_op_dec_turbo_tb_params {
291 /** The K- size of the input CB, in bits [40:6144], that is in the
292 * Turbo operation when r < C-, as in 3GPP TS 36.212.
295 /** The K+ size of the input CB, in bits [40:6144], that is in the
296 * Turbo operation when r >= C-, as in 3GPP TS 36.212.
299 /** The number of CBs that have K- size, [0:63] */
301 /** The total number of CBs in the TB,
302 * [1:RTE_BBDEV_TURBO_MAX_CODE_BLOCKS]
305 /** The number of CBs that uses Ea before switching to Eb, [0:63] */
307 /** The E size of the CB rate matched output to use in the Turbo
308 * operation when r < cab
311 /** The E size of the CB rate matched output to use in the Turbo
312 * operation when r >= cab
315 /** The index of the first CB in the inbound mbuf data, default is 0 */
319 /** LDPC decode transport block parameters */
320 struct rte_bbdev_op_dec_ldpc_tb_params {
321 /** Ea, length after rate matching in bits, r < cab.
322 * [3GPP TS38.212, section 5.4.2.1]
325 /** Eb, length after rate matching in bits, r >= cab.
326 * [3GPP TS38.212, section 5.4.2.1]
329 /** The total number of CBs in the TB or partial TB
330 * [1:RTE_BBDEV_LDPC_MAX_CODE_BLOCKS]
333 /** The index of the first CB in the inbound mbuf data, default is 0 */
335 /** The number of CBs that use Ea before switching to Eb, [0:63] */
339 /** Operation structure for Turbo decode.
340 * An operation can be performed on one CB at a time "CB-mode".
341 * An operation can be performed on one or multiple CBs that logically
342 * belong to one TB "TB-mode".
343 * The provided K size parameter of the CB is its size coming from the
345 * CRC24A/B check is requested by the application by setting the flag
346 * RTE_BBDEV_TURBO_CRC_TYPE_24B for CRC24B check or CRC24A otherwise.
347 * In TB-mode, BBDEV concatenates the decoded CBs one next to the other with
348 * relevant CRC24B in between.
350 * The input encoded CB data is the Virtual Circular Buffer data stream, wk,
351 * with the null padding included as described in 3GPP TS 36.212
352 * section 5.1.4.1.2 and shown in 3GPP TS 36.212 section 5.1.4.1 Figure 5.1.4-1.
353 * The size of the virtual circular buffer is 3*Kpi, where Kpi is the 32 byte
354 * aligned value of K, as specified in 3GPP TS 36.212 section 5.1.4.1.1.
356 * Each byte in the input circular buffer is the LLR value of each bit of the
359 * Hard output is a mandatory capability that all BBDEV PMDs support. This is
360 * the decoded CBs of K sizes (CRC24A/B is the last 24-bit in each decoded CB).
361 * Soft output is an optional capability for BBDEV PMDs. If supported, an LLR
362 * rate matched output is computed in the soft_output buffer structure.
364 * The output mbuf data structure is expected to be allocated by the
365 * application with enough room for the output data.
367 struct rte_bbdev_op_turbo_dec {
368 /** The Virtual Circular Buffer, wk, size 3*Kpi for each CB */
369 struct rte_bbdev_op_data input;
370 /** The hard decisions buffer for the decoded output,
373 struct rte_bbdev_op_data hard_output;
374 /** The soft LLR output buffer - optional */
375 struct rte_bbdev_op_data soft_output;
377 /** Flags from rte_bbdev_op_td_flag_bitmasks */
380 /** Rv index for rate matching [0:3] */
382 /** The minimum number of iterations to perform in decoding all CBs in
383 * this operation - input
386 /** The maximum number of iterations to perform in decoding all CBs in
387 * this operation - input
390 /** The maximum number of iterations that were performed in decoding
391 * all CBs in this decode operation - output
394 /** 5 bit extrinsic scale (scale factor on extrinsic info) */
396 /** Number of MAP engines to use in decode,
397 * must be power of 2 (or 0 to auto-select)
401 /**< [0 - TB : 1 - CB] */
402 uint8_t code_block_mode;
404 /**< Struct which stores Code Block specific parameters */
405 struct rte_bbdev_op_dec_turbo_cb_params cb_params;
406 /**< Struct which stores Transport Block specific parameters */
407 struct rte_bbdev_op_dec_turbo_tb_params tb_params;
411 /** Operation structure for LDPC decode.
413 * An operation can be performed on one CB at a time "CB-mode".
414 * An operation can also be performed on one or multiple CBs that logically
415 * belong to a TB "TB-mode" (Currently not supported).
417 * The input encoded CB data is the Virtual Circular Buffer data stream.
419 * Each byte in the input circular buffer is the LLR value of each bit of the
422 * Hard output is a mandatory capability that all BBDEV PMDs support. This is
423 * the decoded CBs (CRC24A/B is the last 24-bit in each decoded CB).
425 * Soft output is an optional capability for BBDEV PMDs. If supported, an LLR
426 * rate matched output is computed in the soft_output buffer structure.
427 * These are A Posteriori Probabilities (APP) LLR samples for coded bits.
429 * HARQ combined output is an optional capability for BBDEV PMDs.
430 * If supported, a LLR output is streamed to the harq_combined_output
433 * HARQ combined input is an optional capability for BBDEV PMDs.
434 * If supported, a LLR input is streamed from the harq_combined_input
437 * The output mbuf data structure is expected to be allocated by the
438 * application with enough room for the output data.
440 struct rte_bbdev_op_ldpc_dec {
441 /** The Virtual Circular Buffer for this code block, one LLR
442 * per bit of the original CB.
444 struct rte_bbdev_op_data input;
445 /** The hard decisions buffer for the decoded output,
448 struct rte_bbdev_op_data hard_output;
449 /** The soft LLR output LLR stream buffer - optional */
450 struct rte_bbdev_op_data soft_output;
451 /** The HARQ combined LLR stream input buffer - optional */
452 struct rte_bbdev_op_data harq_combined_input;
453 /** The HARQ combined LLR stream output buffer - optional */
454 struct rte_bbdev_op_data harq_combined_output;
456 /** Flags from rte_bbdev_op_ldpcdec_flag_bitmasks */
459 /** Rate matching redundancy version
460 * [3GPP TS38.212, section 5.4.2.1]
463 /** The maximum number of iterations to perform in decoding CB in
464 * this operation - input
467 /** The number of iterations that were performed in decoding
468 * CB in this decode operation - output
471 /** 1: LDPC Base graph 1, 2: LDPC Base graph 2.
472 * [3GPP TS38.212, section 5.2.2]
475 /** Zc, LDPC lifting size.
476 * [3GPP TS38.212, section 5.2.2]
479 /** Ncb, length of the circular buffer in bits.
480 * [3GPP TS38.212, section 5.4.2.1]
483 /** Qm, modulation order {1,2,4,6,8}.
484 * [3GPP TS38.212, section 5.4.2.2]
487 /** Number of Filler bits, n_filler = K – K’
488 * [3GPP TS38.212 section 5.2.2]
491 /** [0 - TB : 1 - CB] */
492 uint8_t code_block_mode;
494 /** Struct which stores Code Block specific parameters */
495 struct rte_bbdev_op_dec_ldpc_cb_params cb_params;
496 /** Struct which stores Transport Block specific parameters */
497 struct rte_bbdev_op_dec_ldpc_tb_params tb_params;
501 /** Turbo encode code block parameters */
502 struct rte_bbdev_op_enc_turbo_cb_params {
503 /** The K size of the input CB, in bits [40:6144], as specified in
505 * This size is inclusive of CRC24A, regardless whether it was
506 * pre-calculated by the application or not.
509 /** The E length of the CB rate matched output, in bits, as in
513 /** The Ncb soft buffer size of the CB rate matched output [K:3*Kpi],
514 * in bits, as specified in 3GPP TS 36.212.
519 /** Turbo encode transport block parameters */
520 struct rte_bbdev_op_enc_turbo_tb_params {
521 /** The K- size of the input CB, in bits [40:6144], that is in the
522 * Turbo operation when r < C-, as in 3GPP TS 36.212.
523 * This size is inclusive of CRC24B, regardless whether it was
524 * pre-calculated and appended by the application or not.
527 /** The K+ size of the input CB, in bits [40:6144], that is in the
528 * Turbo operation when r >= C-, as in 3GPP TS 36.212.
529 * This size is inclusive of CRC24B, regardless whether it was
530 * pre-calculated and appended by the application or not.
533 /** The number of CBs that have K- size, [0:63] */
535 /** The total number of CBs in the TB,
536 * [1:RTE_BBDEV_TURBO_MAX_CODE_BLOCKS]
539 /** The number of CBs that uses Ea before switching to Eb, [0:63] */
541 /** The E size of the CB rate matched output to use in the Turbo
542 * operation when r < cab
545 /** The E size of the CB rate matched output to use in the Turbo
546 * operation when r >= cab
549 /** The Ncb soft buffer size for the rate matched CB that is used in
550 * the Turbo operation when r < C-, [K:3*Kpi]
553 /** The Ncb soft buffer size for the rate matched CB that is used in
554 * the Turbo operation when r >= C-, [K:3*Kpi]
557 /**< The index of the first CB in the inbound mbuf data, default is 0 */
561 /** LDPC encode code block parameters */
562 struct rte_bbdev_op_enc_ldpc_cb_params {
563 /** E, length after rate matching in bits.
564 * [3GPP TS38.212, section 5.4.2.1]
569 /** LDPC encode transport block parameters */
570 struct rte_bbdev_op_enc_ldpc_tb_params {
571 /** Ea, length after rate matching in bits, r < cab.
572 * [3GPP TS38.212, section 5.4.2.1]
575 /** Eb, length after rate matching in bits, r >= cab.
576 * [3GPP TS38.212, section 5.4.2.1]
579 /** The total number of CBs in the TB or partial TB
580 * [1:RTE_BBDEV_LDPC_MAX_CODE_BLOCKS]
583 /** The index of the first CB in the inbound mbuf data, default is 0 */
585 /** The number of CBs that use Ea before switching to Eb, [0:63] */
589 /** Operation structure for Turbo encode.
590 * An operation can be performed on one CB at a time "CB-mode".
591 * An operation can pbe erformd on one or multiple CBs that logically
592 * belong to one TB "TB-mode".
594 * In CB-mode, CRC24A/B is an optional operation. K size parameter is not
595 * affected by CRC24A/B inclusion, this only affects the inbound mbuf data
596 * length. Not all BBDEV PMDs are capable of CRC24A/B calculation. Flags
597 * RTE_BBDEV_TURBO_CRC_24A_ATTACH and RTE_BBDEV_TURBO_CRC_24B_ATTACH informs
598 * the application with relevant capability. These flags can be set in the
599 * op_flags parameter to indicate BBDEV to calculate and append CRC24A to CB
600 * before going forward with Turbo encoding.
602 * In TB-mode, CRC24A is assumed to be pre-calculated and appended to the
603 * inbound TB mbuf data buffer.
605 * The output mbuf data structure is expected to be allocated by the
606 * application with enough room for the output data.
608 struct rte_bbdev_op_turbo_enc {
609 /** The input CB or TB data */
610 struct rte_bbdev_op_data input;
611 /** The rate matched CB or TB output buffer */
612 struct rte_bbdev_op_data output;
613 /** Flags from rte_bbdev_op_te_flag_bitmasks */
616 /** Rv index for rate matching [0:3] */
618 /** [0 - TB : 1 - CB] */
619 uint8_t code_block_mode;
621 /** Struct which stores Code Block specific parameters */
622 struct rte_bbdev_op_enc_turbo_cb_params cb_params;
623 /** Struct which stores Transport Block specific parameters */
624 struct rte_bbdev_op_enc_turbo_tb_params tb_params;
628 /** Operation structure for LDPC encode.
629 * An operation can be performed on one CB at a time "CB-mode".
630 * An operation can be performed on one or multiple CBs that logically
631 * belong to a TB "TB-mode".
633 * The input data is the CB or TB input to the decoder.
635 * The output data is the ratematched CB or TB data, or the output after
636 * bit-selection if RTE_BBDEV_LDPC_INTERLEAVER_BYPASS is set.
638 * The output mbuf data structure is expected to be allocated by the
639 * application with enough room for the output data.
641 struct rte_bbdev_op_ldpc_enc {
642 /** The input TB or CB data */
643 struct rte_bbdev_op_data input;
644 /** The rate matched TB or CB output buffer */
645 struct rte_bbdev_op_data output;
647 /** Flags from rte_bbdev_op_ldpcenc_flag_bitmasks */
650 /** Rate matching redundancy version */
652 /** 1: LDPC Base graph 1, 2: LDPC Base graph 2.
653 * [3GPP TS38.212, section 5.2.2]
656 /** Zc, LDPC lifting size.
657 * [3GPP TS38.212, section 5.2.2]
660 /** Ncb, length of the circular buffer in bits.
661 * [3GPP TS38.212, section 5.4.2.1]
664 /** Qm, modulation order {2,4,6,8,10}.
665 * [3GPP TS38.212, section 5.4.2.2]
668 /** Number of Filler bits, n_filler = K – K’
669 * [3GPP TS38.212 section 5.2.2]
672 /** [0 - TB : 1 - CB] */
673 uint8_t code_block_mode;
675 /** Struct which stores Code Block specific parameters */
676 struct rte_bbdev_op_enc_ldpc_cb_params cb_params;
677 /** Struct which stores Transport Block specific parameters */
678 struct rte_bbdev_op_enc_ldpc_tb_params tb_params;
682 /** List of the capabilities for the Turbo Decoder */
683 struct rte_bbdev_op_cap_turbo_dec {
684 /** Flags from rte_bbdev_op_td_flag_bitmasks */
685 uint32_t capability_flags;
686 /** Maximal LLR absolute value. Acceptable LLR values lie in range
687 * [-max_llr_modulus, max_llr_modulus].
689 int8_t max_llr_modulus;
690 /** Num input code block buffers */
691 uint8_t num_buffers_src; /**< Num input code block buffers */
692 /** Num hard output code block buffers */
693 uint8_t num_buffers_hard_out;
694 /** Num soft output code block buffers if supported by the driver */
695 uint8_t num_buffers_soft_out;
698 /** List of the capabilities for the Turbo Encoder */
699 struct rte_bbdev_op_cap_turbo_enc {
700 /** Flags from rte_bbdev_op_te_flag_bitmasks */
701 uint32_t capability_flags;
702 /** Num input code block buffers */
703 uint8_t num_buffers_src;
704 /** Num output code block buffers */
705 uint8_t num_buffers_dst;
708 /** List of the capabilities for the LDPC Decoder */
709 struct rte_bbdev_op_cap_ldpc_dec {
710 /** Flags from rte_bbdev_op_ldpcdec_flag_bitmasks */
711 uint32_t capability_flags;
712 /** LLR size in bits. LLR is a two’s complement number. */
714 /** LLR numbers of decimals bit for arithmetic representation */
716 /** Num input code block buffers */
717 uint16_t num_buffers_src;
718 /** Num hard output code block buffers */
719 uint16_t num_buffers_hard_out;
720 /** Num soft output code block buffers if supported by the driver */
721 uint16_t num_buffers_soft_out;
724 /** List of the capabilities for the LDPC Encoder */
725 struct rte_bbdev_op_cap_ldpc_enc {
726 /** Flags from rte_bbdev_op_ldpcenc_flag_bitmasks */
727 uint32_t capability_flags;
728 /** Num input code block buffers */
729 uint16_t num_buffers_src;
730 /** Num output code block buffers */
731 uint16_t num_buffers_dst;
734 /** Different operation types supported by the device */
735 enum rte_bbdev_op_type {
736 RTE_BBDEV_OP_NONE, /**< Dummy operation that does nothing */
737 RTE_BBDEV_OP_TURBO_DEC, /**< Turbo decode */
738 RTE_BBDEV_OP_TURBO_ENC, /**< Turbo encode */
739 RTE_BBDEV_OP_LDPC_DEC, /**< LDPC decode */
740 RTE_BBDEV_OP_LDPC_ENC, /**< LDPC encode */
741 RTE_BBDEV_OP_TYPE_COUNT, /**< Count of different op types */
744 /** Bit indexes of possible errors reported through status field */
747 RTE_BBDEV_DATA_ERROR,
749 RTE_BBDEV_SYNDROME_ERROR
752 /** Structure specifying a single encode operation */
753 struct rte_bbdev_enc_op {
754 /**< Status of operation that was performed */
756 /**< Mempool which op instance is in */
757 struct rte_mempool *mempool;
758 /**< Opaque pointer for user data */
761 /** Contains turbo decoder specific parameters */
762 struct rte_bbdev_op_turbo_enc turbo_enc;
763 /** Contains LDPC decoder specific parameters */
764 struct rte_bbdev_op_ldpc_enc ldpc_enc;
768 /** Structure specifying a single decode operation */
769 struct rte_bbdev_dec_op {
770 /** Status of operation that was performed */
772 /** Mempool which op instance is in */
773 struct rte_mempool *mempool;
774 /** Opaque pointer for user data */
777 /** Contains turbo decoder specific parameters */
778 struct rte_bbdev_op_turbo_dec turbo_dec;
779 /** Contains LDPC decoder specific parameters */
780 struct rte_bbdev_op_ldpc_dec ldpc_dec;
784 /** Operation capabilities supported by a device */
785 struct rte_bbdev_op_cap {
786 enum rte_bbdev_op_type type; /**< Type of operation */
788 struct rte_bbdev_op_cap_turbo_dec turbo_dec;
789 struct rte_bbdev_op_cap_turbo_enc turbo_enc;
790 struct rte_bbdev_op_cap_ldpc_dec ldpc_dec;
791 struct rte_bbdev_op_cap_ldpc_enc ldpc_enc;
792 } cap; /**< Operation-type specific capabilities */
795 /**< @internal Private data structure stored with operation pool. */
796 struct rte_bbdev_op_pool_private {
797 enum rte_bbdev_op_type type; /**< Type of operations in a pool */
801 * Converts queue operation type from enum to string
804 * Operation type as enum
807 * Operation type as string or NULL if op_type is invalid
812 rte_bbdev_op_type_str(enum rte_bbdev_op_type op_type);
815 * Creates a bbdev operation mempool
820 * Operation type, use RTE_BBDEV_OP_NONE for a pool which supports all
822 * @param num_elements
823 * Number of elements in the pool.
825 * Number of elements to cache on an lcore, see rte_mempool_create() for
826 * further details about cache size.
828 * Socket to allocate memory on.
831 * - Pointer to a mempool on success,
832 * - NULL pointer on failure.
836 rte_bbdev_op_pool_create(const char *name, enum rte_bbdev_op_type type,
837 unsigned int num_elements, unsigned int cache_size,
841 * Bulk allocate encode operations from a mempool with parameter defaults reset.
844 * Operation mempool, created by rte_bbdev_op_pool_create().
846 * Output array to place allocated operations
848 * Number of operations to allocate
852 * - EINVAL if invalid mempool is provided
856 rte_bbdev_enc_op_alloc_bulk(struct rte_mempool *mempool,
857 struct rte_bbdev_enc_op **ops, uint16_t num_ops)
859 struct rte_bbdev_op_pool_private *priv;
863 priv = (struct rte_bbdev_op_pool_private *)
864 rte_mempool_get_priv(mempool);
865 if (unlikely((priv->type != RTE_BBDEV_OP_TURBO_ENC) &&
866 (priv->type != RTE_BBDEV_OP_LDPC_ENC)))
870 ret = rte_mempool_get_bulk(mempool, (void **)ops, num_ops);
871 if (unlikely(ret < 0))
878 * Bulk allocate decode operations from a mempool with parameter defaults reset.
881 * Operation mempool, created by rte_bbdev_op_pool_create().
883 * Output array to place allocated operations
885 * Number of operations to allocate
889 * - EINVAL if invalid mempool is provided
893 rte_bbdev_dec_op_alloc_bulk(struct rte_mempool *mempool,
894 struct rte_bbdev_dec_op **ops, uint16_t num_ops)
896 struct rte_bbdev_op_pool_private *priv;
900 priv = (struct rte_bbdev_op_pool_private *)
901 rte_mempool_get_priv(mempool);
902 if (unlikely((priv->type != RTE_BBDEV_OP_TURBO_DEC) &&
903 (priv->type != RTE_BBDEV_OP_LDPC_DEC)))
907 ret = rte_mempool_get_bulk(mempool, (void **)ops, num_ops);
908 if (unlikely(ret < 0))
915 * Free decode operation structures that were allocated by
916 * rte_bbdev_dec_op_alloc_bulk().
917 * All structures must belong to the same mempool.
920 * Operation structures
922 * Number of structures
926 rte_bbdev_dec_op_free_bulk(struct rte_bbdev_dec_op **ops, unsigned int num_ops)
929 rte_mempool_put_bulk(ops[0]->mempool, (void **)ops, num_ops);
933 * Free encode operation structures that were allocated by
934 * rte_bbdev_enc_op_alloc_bulk().
935 * All structures must belong to the same mempool.
938 * Operation structures
940 * Number of structures
944 rte_bbdev_enc_op_free_bulk(struct rte_bbdev_enc_op **ops, unsigned int num_ops)
947 rte_mempool_put_bulk(ops[0]->mempool, (void **)ops, num_ops);
954 #endif /* _RTE_BBDEV_OP_H_ */