1d30ea906Sjfb8856606 /* SPDX-License-Identifier: BSD-3-Clause
2d30ea906Sjfb8856606 * Copyright(c) 2017 Intel Corporation
3d30ea906Sjfb8856606 */
4d30ea906Sjfb8856606
5d30ea906Sjfb8856606 #ifndef _RTE_BBDEV_OP_H_
6d30ea906Sjfb8856606 #define _RTE_BBDEV_OP_H_
7d30ea906Sjfb8856606
8d30ea906Sjfb8856606 /**
9d30ea906Sjfb8856606 * @file rte_bbdev_op.h
10d30ea906Sjfb8856606 *
11d30ea906Sjfb8856606 * Defines wireless base band layer 1 operations and capabilities
12d30ea906Sjfb8856606 *
13d30ea906Sjfb8856606 * @warning
14d30ea906Sjfb8856606 * @b EXPERIMENTAL: this API may change without prior notice
15d30ea906Sjfb8856606 */
16d30ea906Sjfb8856606
17d30ea906Sjfb8856606 #ifdef __cplusplus
18d30ea906Sjfb8856606 extern "C" {
19d30ea906Sjfb8856606 #endif
20d30ea906Sjfb8856606
21d30ea906Sjfb8856606 #include <stdint.h>
22d30ea906Sjfb8856606
23d30ea906Sjfb8856606 #include <rte_common.h>
24d30ea906Sjfb8856606 #include <rte_mbuf.h>
25d30ea906Sjfb8856606 #include <rte_memory.h>
26d30ea906Sjfb8856606 #include <rte_mempool.h>
27d30ea906Sjfb8856606
28d30ea906Sjfb8856606 /* Number of columns in sub-block interleaver (36.212, section 5.1.4.1.1) */
294418919fSjohnjiang #define RTE_BBDEV_TURBO_C_SUBBLOCK (32)
30d30ea906Sjfb8856606 /* Maximum size of Transport Block (36.213, Table, Table 7.1.7.2.5-1) */
314418919fSjohnjiang #define RTE_BBDEV_TURBO_MAX_TB_SIZE (391656)
32d30ea906Sjfb8856606 /* Maximum size of Code Block (36.212, Table 5.1.3-3) */
334418919fSjohnjiang #define RTE_BBDEV_TURBO_MAX_CB_SIZE (6144)
344418919fSjohnjiang /* Maximum size of Code Block */
354418919fSjohnjiang #define RTE_BBDEV_LDPC_MAX_CB_SIZE (8448)
36*2d9fd380Sjfb8856606 /* Minimum size of Code Block */
37*2d9fd380Sjfb8856606 #define RTE_BBDEV_LDPC_MIN_CB_SIZE (40)
38*2d9fd380Sjfb8856606 /* Maximum E size we can manage with default mbuf */
39*2d9fd380Sjfb8856606 #define RTE_BBDEV_LDPC_E_MAX_MBUF (64000)
40d30ea906Sjfb8856606 /* Minimum size of Code Block (36.212, Table 5.1.3-3) */
414418919fSjohnjiang #define RTE_BBDEV_TURBO_MIN_CB_SIZE (40)
42d30ea906Sjfb8856606 /* Maximum size of circular buffer */
434418919fSjohnjiang #define RTE_BBDEV_TURBO_MAX_KW (18528)
44d30ea906Sjfb8856606 /*
454418919fSjohnjiang * Turbo: Maximum number of Code Blocks in Transport Block. It is calculated
464418919fSjohnjiang * based on maximum size of one Code Block and one Transport Block
474418919fSjohnjiang * (considering CRC24A and CRC24B):
48d30ea906Sjfb8856606 * (391656 + 24) / (6144 - 24) = 64
49d30ea906Sjfb8856606 */
504418919fSjohnjiang #define RTE_BBDEV_TURBO_MAX_CODE_BLOCKS (64)
514418919fSjohnjiang /* LDPC: Maximum number of Code Blocks in Transport Block.*/
524418919fSjohnjiang #define RTE_BBDEV_LDPC_MAX_CODE_BLOCKS (256)
53d30ea906Sjfb8856606
54d30ea906Sjfb8856606 /** Flags for turbo decoder operation and capability structure */
55d30ea906Sjfb8856606 enum rte_bbdev_op_td_flag_bitmasks {
564418919fSjohnjiang /** If sub block de-interleaving is to be performed. */
57d30ea906Sjfb8856606 RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE = (1ULL << 0),
584418919fSjohnjiang /** To use CRC Type 24B (otherwise use CRC Type 24A). */
59d30ea906Sjfb8856606 RTE_BBDEV_TURBO_CRC_TYPE_24B = (1ULL << 1),
604418919fSjohnjiang /** If turbo equalization is to be performed. */
61d30ea906Sjfb8856606 RTE_BBDEV_TURBO_EQUALIZER = (1ULL << 2),
624418919fSjohnjiang /** If set, saturate soft output to +/-127 */
63d30ea906Sjfb8856606 RTE_BBDEV_TURBO_SOFT_OUT_SATURATE = (1ULL << 3),
644418919fSjohnjiang /** Set to 1 to start iteration from even, else odd; one iteration =
65d30ea906Sjfb8856606 * max_iteration + 0.5
66d30ea906Sjfb8856606 */
67d30ea906Sjfb8856606 RTE_BBDEV_TURBO_HALF_ITERATION_EVEN = (1ULL << 4),
684418919fSjohnjiang /** If 0, TD stops after CRC matches; else if 1, runs to end of next
69d30ea906Sjfb8856606 * odd iteration after CRC matches
70d30ea906Sjfb8856606 */
71d30ea906Sjfb8856606 RTE_BBDEV_TURBO_CONTINUE_CRC_MATCH = (1ULL << 5),
724418919fSjohnjiang /** Set if soft output is required to be output */
73d30ea906Sjfb8856606 RTE_BBDEV_TURBO_SOFT_OUTPUT = (1ULL << 6),
744418919fSjohnjiang /** Set to enable early termination mode */
75d30ea906Sjfb8856606 RTE_BBDEV_TURBO_EARLY_TERMINATION = (1ULL << 7),
764418919fSjohnjiang /** Set if a device supports decoder dequeue interrupts */
77d30ea906Sjfb8856606 RTE_BBDEV_TURBO_DEC_INTERRUPTS = (1ULL << 9),
784418919fSjohnjiang /** Set if positive LLR encoded input is supported. Positive LLR value
79d30ea906Sjfb8856606 * represents the level of confidence for bit '1', and vice versa for
80d30ea906Sjfb8856606 * bit '0'.
81d30ea906Sjfb8856606 * This is mutually exclusive with RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN
82d30ea906Sjfb8856606 * when used to formalize the input data format.
83d30ea906Sjfb8856606 */
84d30ea906Sjfb8856606 RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN = (1ULL << 10),
854418919fSjohnjiang /** Set if negative LLR encoded input is supported. Negative LLR value
86d30ea906Sjfb8856606 * represents the level of confidence for bit '1', and vice versa for
87d30ea906Sjfb8856606 * bit '0'.
88d30ea906Sjfb8856606 * This is mutually exclusive with RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN
89d30ea906Sjfb8856606 * when used to formalize the input data format.
90d30ea906Sjfb8856606 */
91d30ea906Sjfb8856606 RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN = (1ULL << 11),
924418919fSjohnjiang /** Set if positive LLR soft output is supported. Positive LLR value
93d30ea906Sjfb8856606 * represents the level of confidence for bit '1', and vice versa for
94d30ea906Sjfb8856606 * bit '0'.
95d30ea906Sjfb8856606 * This is mutually exclusive with
96d30ea906Sjfb8856606 * RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT when used to formalize
97d30ea906Sjfb8856606 * the input data format.
98d30ea906Sjfb8856606 */
99d30ea906Sjfb8856606 RTE_BBDEV_TURBO_POS_LLR_1_BIT_SOFT_OUT = (1ULL << 12),
1004418919fSjohnjiang /** Set if negative LLR soft output is supported. Negative LLR value
101d30ea906Sjfb8856606 * represents the level of confidence for bit '1', and vice versa for
102d30ea906Sjfb8856606 * bit '0'.
103d30ea906Sjfb8856606 * This is mutually exclusive with
104d30ea906Sjfb8856606 * RTE_BBDEV_TURBO_POS_LLR_1_BIT_SOFT_OUT when used to formalize the
105d30ea906Sjfb8856606 * input data format.
106d30ea906Sjfb8856606 */
107d30ea906Sjfb8856606 RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT = (1ULL << 13),
1084418919fSjohnjiang /** Set if driver supports flexible parallel MAP engine decoding. If
109d30ea906Sjfb8856606 * not supported, num_maps (number of MAP engines) argument is unusable.
110d30ea906Sjfb8856606 */
111d30ea906Sjfb8856606 RTE_BBDEV_TURBO_MAP_DEC = (1ULL << 14),
1124418919fSjohnjiang /** Set if a device supports scatter-gather functionality */
113d30ea906Sjfb8856606 RTE_BBDEV_TURBO_DEC_SCATTER_GATHER = (1ULL << 15),
1144418919fSjohnjiang /** Set to keep CRC24B bits appended while decoding. Only usable when
115d30ea906Sjfb8856606 * decoding Transport Blocks (code_block_mode = 0).
116d30ea906Sjfb8856606 */
117d30ea906Sjfb8856606 RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP = (1ULL << 16)
118d30ea906Sjfb8856606 };
119d30ea906Sjfb8856606
1204418919fSjohnjiang
121d30ea906Sjfb8856606 /** Flags for turbo encoder operation and capability structure */
122d30ea906Sjfb8856606 enum rte_bbdev_op_te_flag_bitmasks {
1234418919fSjohnjiang /** Ignore rv_index and set K0 = 0 */
124d30ea906Sjfb8856606 RTE_BBDEV_TURBO_RV_INDEX_BYPASS = (1ULL << 0),
1254418919fSjohnjiang /** If rate matching is to be performed */
126d30ea906Sjfb8856606 RTE_BBDEV_TURBO_RATE_MATCH = (1ULL << 1),
1274418919fSjohnjiang /** This bit must be set to enable CRC-24B generation */
128d30ea906Sjfb8856606 RTE_BBDEV_TURBO_CRC_24B_ATTACH = (1ULL << 2),
1294418919fSjohnjiang /** This bit must be set to enable CRC-24A generation */
130d30ea906Sjfb8856606 RTE_BBDEV_TURBO_CRC_24A_ATTACH = (1ULL << 3),
1314418919fSjohnjiang /** Set if a device supports encoder dequeue interrupts */
132d30ea906Sjfb8856606 RTE_BBDEV_TURBO_ENC_INTERRUPTS = (1ULL << 4),
1334418919fSjohnjiang /** Set if a device supports scatter-gather functionality */
134d30ea906Sjfb8856606 RTE_BBDEV_TURBO_ENC_SCATTER_GATHER = (1ULL << 5)
135d30ea906Sjfb8856606 };
136d30ea906Sjfb8856606
1374418919fSjohnjiang /** Flags for LDPC decoder operation and capability structure */
1384418919fSjohnjiang enum rte_bbdev_op_ldpcdec_flag_bitmasks {
1394418919fSjohnjiang /** Set for transport block CRC-24A checking */
1404418919fSjohnjiang RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK = (1ULL << 0),
1414418919fSjohnjiang /** Set for code block CRC-24B checking */
1424418919fSjohnjiang RTE_BBDEV_LDPC_CRC_TYPE_24B_CHECK = (1ULL << 1),
1434418919fSjohnjiang /** Set to drop the last CRC bits decoding output */
1444418919fSjohnjiang RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP = (1ULL << 2),
1454418919fSjohnjiang /** Set for bit-level de-interleaver bypass on Rx stream. */
1464418919fSjohnjiang RTE_BBDEV_LDPC_DEINTERLEAVER_BYPASS = (1ULL << 3),
1474418919fSjohnjiang /** Set for HARQ combined input stream enable. */
1484418919fSjohnjiang RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE = (1ULL << 4),
1494418919fSjohnjiang /** Set for HARQ combined output stream enable. */
1504418919fSjohnjiang RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE = (1ULL << 5),
1514418919fSjohnjiang /** Set for LDPC decoder bypass.
1524418919fSjohnjiang * RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE must be set.
1534418919fSjohnjiang */
1544418919fSjohnjiang RTE_BBDEV_LDPC_DECODE_BYPASS = (1ULL << 6),
1554418919fSjohnjiang /** Set for soft-output stream enable */
1564418919fSjohnjiang RTE_BBDEV_LDPC_SOFT_OUT_ENABLE = (1ULL << 7),
1574418919fSjohnjiang /** Set for Rate-Matching bypass on soft-out stream. */
1584418919fSjohnjiang RTE_BBDEV_LDPC_SOFT_OUT_RM_BYPASS = (1ULL << 8),
1594418919fSjohnjiang /** Set for bit-level de-interleaver bypass on soft-output stream. */
1604418919fSjohnjiang RTE_BBDEV_LDPC_SOFT_OUT_DEINTERLEAVER_BYPASS = (1ULL << 9),
1614418919fSjohnjiang /** Set for iteration stopping on successful decode condition
1624418919fSjohnjiang * i.e. a successful syndrome check.
1634418919fSjohnjiang */
1644418919fSjohnjiang RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE = (1ULL << 10),
1654418919fSjohnjiang /** Set if a device supports decoder dequeue interrupts. */
1664418919fSjohnjiang RTE_BBDEV_LDPC_DEC_INTERRUPTS = (1ULL << 11),
1674418919fSjohnjiang /** Set if a device supports scatter-gather functionality. */
1684418919fSjohnjiang RTE_BBDEV_LDPC_DEC_SCATTER_GATHER = (1ULL << 12),
1694418919fSjohnjiang /** Set if a device supports input/output HARQ compression. */
1704418919fSjohnjiang RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION = (1ULL << 13),
1714418919fSjohnjiang /** Set if a device supports input LLR compression. */
1724418919fSjohnjiang RTE_BBDEV_LDPC_LLR_COMPRESSION = (1ULL << 14),
1734418919fSjohnjiang /** Set if a device supports HARQ input from
1744418919fSjohnjiang * device's internal memory.
1754418919fSjohnjiang */
1764418919fSjohnjiang RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE = (1ULL << 15),
1774418919fSjohnjiang /** Set if a device supports HARQ output to
1784418919fSjohnjiang * device's internal memory.
1794418919fSjohnjiang */
1804418919fSjohnjiang RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE = (1ULL << 16),
1814418919fSjohnjiang /** Set if a device supports loop-back access to
1824418919fSjohnjiang * HARQ internal memory. Intended for troubleshooting.
1834418919fSjohnjiang */
184*2d9fd380Sjfb8856606 RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK = (1ULL << 17),
185*2d9fd380Sjfb8856606 /** Set if a device includes LLR filler bits in the circular buffer
186*2d9fd380Sjfb8856606 * for HARQ memory. If not set, it is assumed the filler bits are not
187*2d9fd380Sjfb8856606 * in HARQ memory and handled directly by the LDPC decoder.
188*2d9fd380Sjfb8856606 */
189*2d9fd380Sjfb8856606 RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_FILLERS = (1ULL << 18)
1904418919fSjohnjiang };
1914418919fSjohnjiang
1924418919fSjohnjiang /** Flags for LDPC encoder operation and capability structure */
1934418919fSjohnjiang enum rte_bbdev_op_ldpcenc_flag_bitmasks {
1944418919fSjohnjiang /** Set for bit-level interleaver bypass on output stream. */
1954418919fSjohnjiang RTE_BBDEV_LDPC_INTERLEAVER_BYPASS = (1ULL << 0),
1964418919fSjohnjiang /** If rate matching is to be performed */
1974418919fSjohnjiang RTE_BBDEV_LDPC_RATE_MATCH = (1ULL << 1),
1984418919fSjohnjiang /** Set for transport block CRC-24A attach */
1994418919fSjohnjiang RTE_BBDEV_LDPC_CRC_24A_ATTACH = (1ULL << 2),
2004418919fSjohnjiang /** Set for code block CRC-24B attach */
2014418919fSjohnjiang RTE_BBDEV_LDPC_CRC_24B_ATTACH = (1ULL << 3),
2024418919fSjohnjiang /** Set for code block CRC-16 attach */
2034418919fSjohnjiang RTE_BBDEV_LDPC_CRC_16_ATTACH = (1ULL << 4),
2044418919fSjohnjiang /** Set if a device supports encoder dequeue interrupts. */
2054418919fSjohnjiang RTE_BBDEV_LDPC_ENC_INTERRUPTS = (1ULL << 5),
2064418919fSjohnjiang /** Set if a device supports scatter-gather functionality. */
2074418919fSjohnjiang RTE_BBDEV_LDPC_ENC_SCATTER_GATHER = (1ULL << 6),
2084418919fSjohnjiang /** Set if a device supports concatenation of non byte aligned output */
2094418919fSjohnjiang RTE_BBDEV_LDPC_ENC_CONCATENATION = (1ULL << 7)
2104418919fSjohnjiang };
2114418919fSjohnjiang
2124418919fSjohnjiang /** Data input and output buffer for BBDEV operations */
213d30ea906Sjfb8856606 struct rte_bbdev_op_data {
2144418919fSjohnjiang /** The mbuf data structure representing the data for BBDEV operation.
215d30ea906Sjfb8856606 *
216d30ea906Sjfb8856606 * This mbuf pointer can point to one Code Block (CB) data buffer or
217d30ea906Sjfb8856606 * multiple CBs contiguously located next to each other.
218d30ea906Sjfb8856606 * A Transport Block (TB) represents a whole piece of data that is
219d30ea906Sjfb8856606 * divided into one or more CBs. Maximum number of CBs can be contained
2204418919fSjohnjiang * in one TB is defined by RTE_BBDEV_(TURBO/LDPC)_MAX_CODE_BLOCKS.
221d30ea906Sjfb8856606 *
222d30ea906Sjfb8856606 * An mbuf data structure cannot represent more than one TB. The
223d30ea906Sjfb8856606 * smallest piece of data that can be contained in one mbuf is one CB.
224d30ea906Sjfb8856606 * An mbuf can include one contiguous CB, subset of contiguous CBs that
225d30ea906Sjfb8856606 * are belonging to one TB, or all contiguous CBs that are belonging to
226d30ea906Sjfb8856606 * one TB.
227d30ea906Sjfb8856606 *
228d30ea906Sjfb8856606 * If a BBDEV PMD supports the extended capability "Scatter-Gather",
229d30ea906Sjfb8856606 * then it is capable of collecting (gathering) non-contiguous
230d30ea906Sjfb8856606 * (scattered) data from multiple locations in the memory.
231d30ea906Sjfb8856606 * This capability is reported by the capability flags:
2324418919fSjohnjiang * - RTE_BBDEV_(TURBO/LDPC)_ENC_SCATTER_GATHER and
2334418919fSjohnjiang * - RTE_BBDEV_(TURBO/LDPC)_DEC_SCATTER_GATHER.
234d30ea906Sjfb8856606 * Only if a BBDEV PMD supports this feature, chained mbuf data
235d30ea906Sjfb8856606 * structures are accepted. A chained mbuf can represent one
236d30ea906Sjfb8856606 * non-contiguous CB or multiple non-contiguous CBs.
237d30ea906Sjfb8856606 * If BBDEV PMD does not support this feature, it will assume inbound
238d30ea906Sjfb8856606 * mbuf data contains one segment.
239d30ea906Sjfb8856606 *
240d30ea906Sjfb8856606 * The output mbuf data though is always one segment, even if the input
241d30ea906Sjfb8856606 * was a chained mbuf.
242d30ea906Sjfb8856606 */
243d30ea906Sjfb8856606 struct rte_mbuf *data;
2444418919fSjohnjiang /** The starting point of the BBDEV (encode/decode) operation,
245d30ea906Sjfb8856606 * in bytes.
246d30ea906Sjfb8856606 *
247d30ea906Sjfb8856606 * BBDEV starts to read data past this offset.
248d30ea906Sjfb8856606 * In case of chained mbuf, this offset applies only to the first mbuf
249d30ea906Sjfb8856606 * segment.
250d30ea906Sjfb8856606 */
251d30ea906Sjfb8856606 uint32_t offset;
2524418919fSjohnjiang /** The total data length to be processed in one operation, in bytes.
253d30ea906Sjfb8856606 *
254d30ea906Sjfb8856606 * In case the mbuf data is representing one CB, this is the length of
255d30ea906Sjfb8856606 * the CB undergoing the operation.
256d30ea906Sjfb8856606 * If it's for multiple CBs, this is the total length of those CBs
257d30ea906Sjfb8856606 * undergoing the operation.
2584418919fSjohnjiang * If it is for one TB, this is the total length of the TB under
259d30ea906Sjfb8856606 * operation.
260d30ea906Sjfb8856606 *
261d30ea906Sjfb8856606 * In case of chained mbuf, this data length includes the lengths of the
262d30ea906Sjfb8856606 * "scattered" data segments undergoing the operation.
263d30ea906Sjfb8856606 */
264d30ea906Sjfb8856606 uint32_t length;
265d30ea906Sjfb8856606 };
266d30ea906Sjfb8856606
2674418919fSjohnjiang /** Turbo decode code block parameters */
2684418919fSjohnjiang struct rte_bbdev_op_dec_turbo_cb_params {
2694418919fSjohnjiang /** The K size of the input CB, in bits [40:6144], as specified in
270d30ea906Sjfb8856606 * 3GPP TS 36.212.
271d30ea906Sjfb8856606 * This size is inclusive of CRC bits, regardless whether it was
272d30ea906Sjfb8856606 * pre-calculated by the application or not.
273d30ea906Sjfb8856606 */
274d30ea906Sjfb8856606 uint16_t k;
2754418919fSjohnjiang /** The E length of the CB rate matched LLR output, in bytes, as in
276d30ea906Sjfb8856606 * 3GPP TS 36.212.
277d30ea906Sjfb8856606 */
278d30ea906Sjfb8856606 uint32_t e;
279d30ea906Sjfb8856606 };
280d30ea906Sjfb8856606
2814418919fSjohnjiang /** LDPC decode code block parameters */
2824418919fSjohnjiang struct rte_bbdev_op_dec_ldpc_cb_params {
2834418919fSjohnjiang /** Rate matching output sequence length in bits or LLRs.
2844418919fSjohnjiang * [3GPP TS38.212, section 5.4.2.1]
2854418919fSjohnjiang */
2864418919fSjohnjiang uint32_t e;
2874418919fSjohnjiang };
2884418919fSjohnjiang
2894418919fSjohnjiang /** Turbo decode transport block parameters */
2904418919fSjohnjiang struct rte_bbdev_op_dec_turbo_tb_params {
2914418919fSjohnjiang /** The K- size of the input CB, in bits [40:6144], that is in the
292d30ea906Sjfb8856606 * Turbo operation when r < C-, as in 3GPP TS 36.212.
293d30ea906Sjfb8856606 */
294d30ea906Sjfb8856606 uint16_t k_neg;
2954418919fSjohnjiang /** The K+ size of the input CB, in bits [40:6144], that is in the
296d30ea906Sjfb8856606 * Turbo operation when r >= C-, as in 3GPP TS 36.212.
297d30ea906Sjfb8856606 */
298d30ea906Sjfb8856606 uint16_t k_pos;
2994418919fSjohnjiang /** The number of CBs that have K- size, [0:63] */
300d30ea906Sjfb8856606 uint8_t c_neg;
3014418919fSjohnjiang /** The total number of CBs in the TB,
3024418919fSjohnjiang * [1:RTE_BBDEV_TURBO_MAX_CODE_BLOCKS]
3034418919fSjohnjiang */
304d30ea906Sjfb8856606 uint8_t c;
3054418919fSjohnjiang /** The number of CBs that uses Ea before switching to Eb, [0:63] */
306d30ea906Sjfb8856606 uint8_t cab;
3074418919fSjohnjiang /** The E size of the CB rate matched output to use in the Turbo
308d30ea906Sjfb8856606 * operation when r < cab
309d30ea906Sjfb8856606 */
310d30ea906Sjfb8856606 uint32_t ea;
3114418919fSjohnjiang /** The E size of the CB rate matched output to use in the Turbo
312d30ea906Sjfb8856606 * operation when r >= cab
313d30ea906Sjfb8856606 */
314d30ea906Sjfb8856606 uint32_t eb;
3154418919fSjohnjiang /** The index of the first CB in the inbound mbuf data, default is 0 */
3164418919fSjohnjiang uint8_t r;
317d30ea906Sjfb8856606 };
318d30ea906Sjfb8856606
3194418919fSjohnjiang /** LDPC decode transport block parameters */
3204418919fSjohnjiang struct rte_bbdev_op_dec_ldpc_tb_params {
3214418919fSjohnjiang /** Ea, length after rate matching in bits, r < cab.
3224418919fSjohnjiang * [3GPP TS38.212, section 5.4.2.1]
3234418919fSjohnjiang */
3244418919fSjohnjiang uint32_t ea;
3254418919fSjohnjiang /** Eb, length after rate matching in bits, r >= cab.
3264418919fSjohnjiang * [3GPP TS38.212, section 5.4.2.1]
3274418919fSjohnjiang */
3284418919fSjohnjiang uint32_t eb;
3294418919fSjohnjiang /** The total number of CBs in the TB or partial TB
3304418919fSjohnjiang * [1:RTE_BBDEV_LDPC_MAX_CODE_BLOCKS]
3314418919fSjohnjiang */
3324418919fSjohnjiang uint8_t c;
3334418919fSjohnjiang /** The index of the first CB in the inbound mbuf data, default is 0 */
3344418919fSjohnjiang uint8_t r;
3354418919fSjohnjiang /** The number of CBs that use Ea before switching to Eb, [0:63] */
3364418919fSjohnjiang uint8_t cab;
3374418919fSjohnjiang };
3384418919fSjohnjiang
3394418919fSjohnjiang /** Operation structure for Turbo decode.
3404418919fSjohnjiang * An operation can be performed on one CB at a time "CB-mode".
3414418919fSjohnjiang * An operation can be performed on one or multiple CBs that logically
3424418919fSjohnjiang * belong to one TB "TB-mode".
3434418919fSjohnjiang * The provided K size parameter of the CB is its size coming from the
344d30ea906Sjfb8856606 * decode operation.
345d30ea906Sjfb8856606 * CRC24A/B check is requested by the application by setting the flag
346d30ea906Sjfb8856606 * RTE_BBDEV_TURBO_CRC_TYPE_24B for CRC24B check or CRC24A otherwise.
347d30ea906Sjfb8856606 * In TB-mode, BBDEV concatenates the decoded CBs one next to the other with
348d30ea906Sjfb8856606 * relevant CRC24B in between.
349d30ea906Sjfb8856606 *
350d30ea906Sjfb8856606 * The input encoded CB data is the Virtual Circular Buffer data stream, wk,
351d30ea906Sjfb8856606 * with the null padding included as described in 3GPP TS 36.212
352d30ea906Sjfb8856606 * section 5.1.4.1.2 and shown in 3GPP TS 36.212 section 5.1.4.1 Figure 5.1.4-1.
353d30ea906Sjfb8856606 * The size of the virtual circular buffer is 3*Kpi, where Kpi is the 32 byte
354d30ea906Sjfb8856606 * aligned value of K, as specified in 3GPP TS 36.212 section 5.1.4.1.1.
355d30ea906Sjfb8856606 *
356d30ea906Sjfb8856606 * Each byte in the input circular buffer is the LLR value of each bit of the
357d30ea906Sjfb8856606 * original CB.
358d30ea906Sjfb8856606 *
359d30ea906Sjfb8856606 * Hard output is a mandatory capability that all BBDEV PMDs support. This is
360d30ea906Sjfb8856606 * the decoded CBs of K sizes (CRC24A/B is the last 24-bit in each decoded CB).
361d30ea906Sjfb8856606 * Soft output is an optional capability for BBDEV PMDs. If supported, an LLR
362d30ea906Sjfb8856606 * rate matched output is computed in the soft_output buffer structure.
363d30ea906Sjfb8856606 *
364d30ea906Sjfb8856606 * The output mbuf data structure is expected to be allocated by the
365d30ea906Sjfb8856606 * application with enough room for the output data.
366d30ea906Sjfb8856606 */
367d30ea906Sjfb8856606 struct rte_bbdev_op_turbo_dec {
3684418919fSjohnjiang /** The Virtual Circular Buffer, wk, size 3*Kpi for each CB */
369d30ea906Sjfb8856606 struct rte_bbdev_op_data input;
3704418919fSjohnjiang /** The hard decisions buffer for the decoded output,
371d30ea906Sjfb8856606 * size K for each CB
372d30ea906Sjfb8856606 */
373d30ea906Sjfb8856606 struct rte_bbdev_op_data hard_output;
3744418919fSjohnjiang /** The soft LLR output buffer - optional */
375d30ea906Sjfb8856606 struct rte_bbdev_op_data soft_output;
376d30ea906Sjfb8856606
3774418919fSjohnjiang /** Flags from rte_bbdev_op_td_flag_bitmasks */
3784418919fSjohnjiang uint32_t op_flags;
3794418919fSjohnjiang
3804418919fSjohnjiang /** Rv index for rate matching [0:3] */
3814418919fSjohnjiang uint8_t rv_index;
3824418919fSjohnjiang /** The minimum number of iterations to perform in decoding all CBs in
383d30ea906Sjfb8856606 * this operation - input
384d30ea906Sjfb8856606 */
385d30ea906Sjfb8856606 uint8_t iter_min:4;
3864418919fSjohnjiang /** The maximum number of iterations to perform in decoding all CBs in
387d30ea906Sjfb8856606 * this operation - input
388d30ea906Sjfb8856606 */
389d30ea906Sjfb8856606 uint8_t iter_max:4;
3904418919fSjohnjiang /** The maximum number of iterations that were performed in decoding
3914418919fSjohnjiang * all CBs in this decode operation - output
392d30ea906Sjfb8856606 */
393d30ea906Sjfb8856606 uint8_t iter_count;
3944418919fSjohnjiang /** 5 bit extrinsic scale (scale factor on extrinsic info) */
395d30ea906Sjfb8856606 uint8_t ext_scale;
3964418919fSjohnjiang /** Number of MAP engines to use in decode,
397d30ea906Sjfb8856606 * must be power of 2 (or 0 to auto-select)
398d30ea906Sjfb8856606 */
399d30ea906Sjfb8856606 uint8_t num_maps;
400d30ea906Sjfb8856606
4010c6bd470Sfengbojiang /** [0 - TB : 1 - CB] */
4024418919fSjohnjiang uint8_t code_block_mode;
403d30ea906Sjfb8856606 union {
4040c6bd470Sfengbojiang /** Struct which stores Code Block specific parameters */
4054418919fSjohnjiang struct rte_bbdev_op_dec_turbo_cb_params cb_params;
4060c6bd470Sfengbojiang /** Struct which stores Transport Block specific parameters */
4074418919fSjohnjiang struct rte_bbdev_op_dec_turbo_tb_params tb_params;
408d30ea906Sjfb8856606 };
409d30ea906Sjfb8856606 };
410d30ea906Sjfb8856606
4114418919fSjohnjiang /** Operation structure for LDPC decode.
4124418919fSjohnjiang *
4134418919fSjohnjiang * An operation can be performed on one CB at a time "CB-mode".
4144418919fSjohnjiang * An operation can also be performed on one or multiple CBs that logically
4154418919fSjohnjiang * belong to a TB "TB-mode" (Currently not supported).
4164418919fSjohnjiang *
4174418919fSjohnjiang * The input encoded CB data is the Virtual Circular Buffer data stream.
4184418919fSjohnjiang *
4194418919fSjohnjiang * Each byte in the input circular buffer is the LLR value of each bit of the
4204418919fSjohnjiang * original CB.
4214418919fSjohnjiang *
4224418919fSjohnjiang * Hard output is a mandatory capability that all BBDEV PMDs support. This is
4234418919fSjohnjiang * the decoded CBs (CRC24A/B is the last 24-bit in each decoded CB).
4244418919fSjohnjiang *
4254418919fSjohnjiang * Soft output is an optional capability for BBDEV PMDs. If supported, an LLR
4264418919fSjohnjiang * rate matched output is computed in the soft_output buffer structure.
4274418919fSjohnjiang * These are A Posteriori Probabilities (APP) LLR samples for coded bits.
4284418919fSjohnjiang *
4294418919fSjohnjiang * HARQ combined output is an optional capability for BBDEV PMDs.
4304418919fSjohnjiang * If supported, a LLR output is streamed to the harq_combined_output
4314418919fSjohnjiang * buffer.
4324418919fSjohnjiang *
4334418919fSjohnjiang * HARQ combined input is an optional capability for BBDEV PMDs.
4344418919fSjohnjiang * If supported, a LLR input is streamed from the harq_combined_input
4354418919fSjohnjiang * buffer.
4364418919fSjohnjiang *
4374418919fSjohnjiang * The output mbuf data structure is expected to be allocated by the
4384418919fSjohnjiang * application with enough room for the output data.
4394418919fSjohnjiang */
4404418919fSjohnjiang struct rte_bbdev_op_ldpc_dec {
4414418919fSjohnjiang /** The Virtual Circular Buffer for this code block, one LLR
4424418919fSjohnjiang * per bit of the original CB.
4434418919fSjohnjiang */
4444418919fSjohnjiang struct rte_bbdev_op_data input;
4454418919fSjohnjiang /** The hard decisions buffer for the decoded output,
4464418919fSjohnjiang * size K for each CB
4474418919fSjohnjiang */
4484418919fSjohnjiang struct rte_bbdev_op_data hard_output;
4494418919fSjohnjiang /** The soft LLR output LLR stream buffer - optional */
4504418919fSjohnjiang struct rte_bbdev_op_data soft_output;
4514418919fSjohnjiang /** The HARQ combined LLR stream input buffer - optional */
4524418919fSjohnjiang struct rte_bbdev_op_data harq_combined_input;
4534418919fSjohnjiang /** The HARQ combined LLR stream output buffer - optional */
4544418919fSjohnjiang struct rte_bbdev_op_data harq_combined_output;
4554418919fSjohnjiang
4564418919fSjohnjiang /** Flags from rte_bbdev_op_ldpcdec_flag_bitmasks */
4574418919fSjohnjiang uint32_t op_flags;
4584418919fSjohnjiang
4594418919fSjohnjiang /** Rate matching redundancy version
4604418919fSjohnjiang * [3GPP TS38.212, section 5.4.2.1]
4614418919fSjohnjiang */
4624418919fSjohnjiang uint8_t rv_index;
4634418919fSjohnjiang /** The maximum number of iterations to perform in decoding CB in
4644418919fSjohnjiang * this operation - input
4654418919fSjohnjiang */
4664418919fSjohnjiang uint8_t iter_max;
4674418919fSjohnjiang /** The number of iterations that were performed in decoding
4684418919fSjohnjiang * CB in this decode operation - output
4694418919fSjohnjiang */
4704418919fSjohnjiang uint8_t iter_count;
4714418919fSjohnjiang /** 1: LDPC Base graph 1, 2: LDPC Base graph 2.
4724418919fSjohnjiang * [3GPP TS38.212, section 5.2.2]
4734418919fSjohnjiang */
4744418919fSjohnjiang uint8_t basegraph;
4754418919fSjohnjiang /** Zc, LDPC lifting size.
4764418919fSjohnjiang * [3GPP TS38.212, section 5.2.2]
4774418919fSjohnjiang */
4784418919fSjohnjiang uint16_t z_c;
4794418919fSjohnjiang /** Ncb, length of the circular buffer in bits.
4804418919fSjohnjiang * [3GPP TS38.212, section 5.4.2.1]
4814418919fSjohnjiang */
4824418919fSjohnjiang uint16_t n_cb;
4834418919fSjohnjiang /** Qm, modulation order {1,2,4,6,8}.
4844418919fSjohnjiang * [3GPP TS38.212, section 5.4.2.2]
4854418919fSjohnjiang */
4864418919fSjohnjiang uint8_t q_m;
4874418919fSjohnjiang /** Number of Filler bits, n_filler = K – K’
4884418919fSjohnjiang * [3GPP TS38.212 section 5.2.2]
4894418919fSjohnjiang */
4904418919fSjohnjiang uint16_t n_filler;
4914418919fSjohnjiang /** [0 - TB : 1 - CB] */
4924418919fSjohnjiang uint8_t code_block_mode;
4934418919fSjohnjiang union {
4944418919fSjohnjiang /** Struct which stores Code Block specific parameters */
4954418919fSjohnjiang struct rte_bbdev_op_dec_ldpc_cb_params cb_params;
4964418919fSjohnjiang /** Struct which stores Transport Block specific parameters */
4974418919fSjohnjiang struct rte_bbdev_op_dec_ldpc_tb_params tb_params;
4984418919fSjohnjiang };
4994418919fSjohnjiang };
5004418919fSjohnjiang
5014418919fSjohnjiang /** Turbo encode code block parameters */
5024418919fSjohnjiang struct rte_bbdev_op_enc_turbo_cb_params {
5034418919fSjohnjiang /** The K size of the input CB, in bits [40:6144], as specified in
504d30ea906Sjfb8856606 * 3GPP TS 36.212.
505d30ea906Sjfb8856606 * This size is inclusive of CRC24A, regardless whether it was
506d30ea906Sjfb8856606 * pre-calculated by the application or not.
507d30ea906Sjfb8856606 */
508d30ea906Sjfb8856606 uint16_t k;
5094418919fSjohnjiang /** The E length of the CB rate matched output, in bits, as in
510d30ea906Sjfb8856606 * 3GPP TS 36.212.
511d30ea906Sjfb8856606 */
512d30ea906Sjfb8856606 uint32_t e;
5134418919fSjohnjiang /** The Ncb soft buffer size of the CB rate matched output [K:3*Kpi],
514d30ea906Sjfb8856606 * in bits, as specified in 3GPP TS 36.212.
515d30ea906Sjfb8856606 */
516d30ea906Sjfb8856606 uint16_t ncb;
517d30ea906Sjfb8856606 };
518d30ea906Sjfb8856606
5194418919fSjohnjiang /** Turbo encode transport block parameters */
5204418919fSjohnjiang struct rte_bbdev_op_enc_turbo_tb_params {
5214418919fSjohnjiang /** The K- size of the input CB, in bits [40:6144], that is in the
522d30ea906Sjfb8856606 * Turbo operation when r < C-, as in 3GPP TS 36.212.
523d30ea906Sjfb8856606 * This size is inclusive of CRC24B, regardless whether it was
524d30ea906Sjfb8856606 * pre-calculated and appended by the application or not.
525d30ea906Sjfb8856606 */
526d30ea906Sjfb8856606 uint16_t k_neg;
5274418919fSjohnjiang /** The K+ size of the input CB, in bits [40:6144], that is in the
528d30ea906Sjfb8856606 * Turbo operation when r >= C-, as in 3GPP TS 36.212.
529d30ea906Sjfb8856606 * This size is inclusive of CRC24B, regardless whether it was
530d30ea906Sjfb8856606 * pre-calculated and appended by the application or not.
531d30ea906Sjfb8856606 */
532d30ea906Sjfb8856606 uint16_t k_pos;
5334418919fSjohnjiang /** The number of CBs that have K- size, [0:63] */
534d30ea906Sjfb8856606 uint8_t c_neg;
5354418919fSjohnjiang /** The total number of CBs in the TB,
5364418919fSjohnjiang * [1:RTE_BBDEV_TURBO_MAX_CODE_BLOCKS]
5374418919fSjohnjiang */
538d30ea906Sjfb8856606 uint8_t c;
5394418919fSjohnjiang /** The number of CBs that uses Ea before switching to Eb, [0:63] */
540d30ea906Sjfb8856606 uint8_t cab;
5414418919fSjohnjiang /** The E size of the CB rate matched output to use in the Turbo
542d30ea906Sjfb8856606 * operation when r < cab
543d30ea906Sjfb8856606 */
544d30ea906Sjfb8856606 uint32_t ea;
5454418919fSjohnjiang /** The E size of the CB rate matched output to use in the Turbo
546d30ea906Sjfb8856606 * operation when r >= cab
547d30ea906Sjfb8856606 */
548d30ea906Sjfb8856606 uint32_t eb;
5494418919fSjohnjiang /** The Ncb soft buffer size for the rate matched CB that is used in
550d30ea906Sjfb8856606 * the Turbo operation when r < C-, [K:3*Kpi]
551d30ea906Sjfb8856606 */
552d30ea906Sjfb8856606 uint16_t ncb_neg;
5534418919fSjohnjiang /** The Ncb soft buffer size for the rate matched CB that is used in
554d30ea906Sjfb8856606 * the Turbo operation when r >= C-, [K:3*Kpi]
555d30ea906Sjfb8856606 */
556d30ea906Sjfb8856606 uint16_t ncb_pos;
5570c6bd470Sfengbojiang /** The index of the first CB in the inbound mbuf data, default is 0 */
558d30ea906Sjfb8856606 uint8_t r;
559d30ea906Sjfb8856606 };
560d30ea906Sjfb8856606
5614418919fSjohnjiang /** LDPC encode code block parameters */
5624418919fSjohnjiang struct rte_bbdev_op_enc_ldpc_cb_params {
5634418919fSjohnjiang /** E, length after rate matching in bits.
5644418919fSjohnjiang * [3GPP TS38.212, section 5.4.2.1]
5654418919fSjohnjiang */
5664418919fSjohnjiang uint32_t e;
5674418919fSjohnjiang };
5684418919fSjohnjiang
5694418919fSjohnjiang /** LDPC encode transport block parameters */
5704418919fSjohnjiang struct rte_bbdev_op_enc_ldpc_tb_params {
5714418919fSjohnjiang /** Ea, length after rate matching in bits, r < cab.
5724418919fSjohnjiang * [3GPP TS38.212, section 5.4.2.1]
5734418919fSjohnjiang */
5744418919fSjohnjiang uint32_t ea;
5754418919fSjohnjiang /** Eb, length after rate matching in bits, r >= cab.
5764418919fSjohnjiang * [3GPP TS38.212, section 5.4.2.1]
5774418919fSjohnjiang */
5784418919fSjohnjiang uint32_t eb;
5794418919fSjohnjiang /** The total number of CBs in the TB or partial TB
5804418919fSjohnjiang * [1:RTE_BBDEV_LDPC_MAX_CODE_BLOCKS]
5814418919fSjohnjiang */
5824418919fSjohnjiang uint8_t c;
5834418919fSjohnjiang /** The index of the first CB in the inbound mbuf data, default is 0 */
5844418919fSjohnjiang uint8_t r;
5854418919fSjohnjiang /** The number of CBs that use Ea before switching to Eb, [0:63] */
5864418919fSjohnjiang uint8_t cab;
5874418919fSjohnjiang };
5884418919fSjohnjiang
5894418919fSjohnjiang /** Operation structure for Turbo encode.
5904418919fSjohnjiang * An operation can be performed on one CB at a time "CB-mode".
5914418919fSjohnjiang * An operation can pbe erformd on one or multiple CBs that logically
5924418919fSjohnjiang * belong to one TB "TB-mode".
593d30ea906Sjfb8856606 *
594d30ea906Sjfb8856606 * In CB-mode, CRC24A/B is an optional operation. K size parameter is not
595d30ea906Sjfb8856606 * affected by CRC24A/B inclusion, this only affects the inbound mbuf data
596d30ea906Sjfb8856606 * length. Not all BBDEV PMDs are capable of CRC24A/B calculation. Flags
597d30ea906Sjfb8856606 * RTE_BBDEV_TURBO_CRC_24A_ATTACH and RTE_BBDEV_TURBO_CRC_24B_ATTACH informs
598d30ea906Sjfb8856606 * the application with relevant capability. These flags can be set in the
599d30ea906Sjfb8856606 * op_flags parameter to indicate BBDEV to calculate and append CRC24A to CB
600d30ea906Sjfb8856606 * before going forward with Turbo encoding.
601d30ea906Sjfb8856606 *
602d30ea906Sjfb8856606 * In TB-mode, CRC24A is assumed to be pre-calculated and appended to the
603d30ea906Sjfb8856606 * inbound TB mbuf data buffer.
604d30ea906Sjfb8856606 *
605d30ea906Sjfb8856606 * The output mbuf data structure is expected to be allocated by the
606d30ea906Sjfb8856606 * application with enough room for the output data.
607d30ea906Sjfb8856606 */
608d30ea906Sjfb8856606 struct rte_bbdev_op_turbo_enc {
6094418919fSjohnjiang /** The input CB or TB data */
610d30ea906Sjfb8856606 struct rte_bbdev_op_data input;
6114418919fSjohnjiang /** The rate matched CB or TB output buffer */
6124418919fSjohnjiang struct rte_bbdev_op_data output;
6134418919fSjohnjiang /** Flags from rte_bbdev_op_te_flag_bitmasks */
6144418919fSjohnjiang uint32_t op_flags;
6154418919fSjohnjiang
6164418919fSjohnjiang /** Rv index for rate matching [0:3] */
6174418919fSjohnjiang uint8_t rv_index;
6184418919fSjohnjiang /** [0 - TB : 1 - CB] */
6194418919fSjohnjiang uint8_t code_block_mode;
6204418919fSjohnjiang union {
6214418919fSjohnjiang /** Struct which stores Code Block specific parameters */
6224418919fSjohnjiang struct rte_bbdev_op_enc_turbo_cb_params cb_params;
6234418919fSjohnjiang /** Struct which stores Transport Block specific parameters */
6244418919fSjohnjiang struct rte_bbdev_op_enc_turbo_tb_params tb_params;
6254418919fSjohnjiang };
6264418919fSjohnjiang };
6274418919fSjohnjiang
6284418919fSjohnjiang /** Operation structure for LDPC encode.
6294418919fSjohnjiang * An operation can be performed on one CB at a time "CB-mode".
6304418919fSjohnjiang * An operation can be performed on one or multiple CBs that logically
6314418919fSjohnjiang * belong to a TB "TB-mode".
6324418919fSjohnjiang *
6334418919fSjohnjiang * The input data is the CB or TB input to the decoder.
6344418919fSjohnjiang *
6354418919fSjohnjiang * The output data is the ratematched CB or TB data, or the output after
6364418919fSjohnjiang * bit-selection if RTE_BBDEV_LDPC_INTERLEAVER_BYPASS is set.
6374418919fSjohnjiang *
6384418919fSjohnjiang * The output mbuf data structure is expected to be allocated by the
6394418919fSjohnjiang * application with enough room for the output data.
6404418919fSjohnjiang */
6414418919fSjohnjiang struct rte_bbdev_op_ldpc_enc {
6424418919fSjohnjiang /** The input TB or CB data */
6434418919fSjohnjiang struct rte_bbdev_op_data input;
6444418919fSjohnjiang /** The rate matched TB or CB output buffer */
645d30ea906Sjfb8856606 struct rte_bbdev_op_data output;
646d30ea906Sjfb8856606
6474418919fSjohnjiang /** Flags from rte_bbdev_op_ldpcenc_flag_bitmasks */
6484418919fSjohnjiang uint32_t op_flags;
649d30ea906Sjfb8856606
6504418919fSjohnjiang /** Rate matching redundancy version */
6514418919fSjohnjiang uint8_t rv_index;
6524418919fSjohnjiang /** 1: LDPC Base graph 1, 2: LDPC Base graph 2.
6534418919fSjohnjiang * [3GPP TS38.212, section 5.2.2]
6544418919fSjohnjiang */
6554418919fSjohnjiang uint8_t basegraph;
6564418919fSjohnjiang /** Zc, LDPC lifting size.
6574418919fSjohnjiang * [3GPP TS38.212, section 5.2.2]
6584418919fSjohnjiang */
6594418919fSjohnjiang uint16_t z_c;
6604418919fSjohnjiang /** Ncb, length of the circular buffer in bits.
6614418919fSjohnjiang * [3GPP TS38.212, section 5.4.2.1]
6624418919fSjohnjiang */
6634418919fSjohnjiang uint16_t n_cb;
6644418919fSjohnjiang /** Qm, modulation order {2,4,6,8,10}.
6654418919fSjohnjiang * [3GPP TS38.212, section 5.4.2.2]
6664418919fSjohnjiang */
6674418919fSjohnjiang uint8_t q_m;
6684418919fSjohnjiang /** Number of Filler bits, n_filler = K – K’
6694418919fSjohnjiang * [3GPP TS38.212 section 5.2.2]
6704418919fSjohnjiang */
6714418919fSjohnjiang uint16_t n_filler;
6724418919fSjohnjiang /** [0 - TB : 1 - CB] */
6734418919fSjohnjiang uint8_t code_block_mode;
674d30ea906Sjfb8856606 union {
6754418919fSjohnjiang /** Struct which stores Code Block specific parameters */
6764418919fSjohnjiang struct rte_bbdev_op_enc_ldpc_cb_params cb_params;
6774418919fSjohnjiang /** Struct which stores Transport Block specific parameters */
6784418919fSjohnjiang struct rte_bbdev_op_enc_ldpc_tb_params tb_params;
679d30ea906Sjfb8856606 };
680d30ea906Sjfb8856606 };
681d30ea906Sjfb8856606
6824418919fSjohnjiang /** List of the capabilities for the Turbo Decoder */
683d30ea906Sjfb8856606 struct rte_bbdev_op_cap_turbo_dec {
6844418919fSjohnjiang /** Flags from rte_bbdev_op_td_flag_bitmasks */
685d30ea906Sjfb8856606 uint32_t capability_flags;
686d30ea906Sjfb8856606 /** Maximal LLR absolute value. Acceptable LLR values lie in range
687d30ea906Sjfb8856606 * [-max_llr_modulus, max_llr_modulus].
688d30ea906Sjfb8856606 */
689d30ea906Sjfb8856606 int8_t max_llr_modulus;
6904418919fSjohnjiang /** Num input code block buffers */
691d30ea906Sjfb8856606 uint8_t num_buffers_src; /**< Num input code block buffers */
6924418919fSjohnjiang /** Num hard output code block buffers */
693d30ea906Sjfb8856606 uint8_t num_buffers_hard_out;
6944418919fSjohnjiang /** Num soft output code block buffers if supported by the driver */
695d30ea906Sjfb8856606 uint8_t num_buffers_soft_out;
696d30ea906Sjfb8856606 };
697d30ea906Sjfb8856606
6984418919fSjohnjiang /** List of the capabilities for the Turbo Encoder */
699d30ea906Sjfb8856606 struct rte_bbdev_op_cap_turbo_enc {
7004418919fSjohnjiang /** Flags from rte_bbdev_op_te_flag_bitmasks */
701d30ea906Sjfb8856606 uint32_t capability_flags;
7024418919fSjohnjiang /** Num input code block buffers */
7034418919fSjohnjiang uint8_t num_buffers_src;
7044418919fSjohnjiang /** Num output code block buffers */
7054418919fSjohnjiang uint8_t num_buffers_dst;
7064418919fSjohnjiang };
7074418919fSjohnjiang
7084418919fSjohnjiang /** List of the capabilities for the LDPC Decoder */
7094418919fSjohnjiang struct rte_bbdev_op_cap_ldpc_dec {
7104418919fSjohnjiang /** Flags from rte_bbdev_op_ldpcdec_flag_bitmasks */
7114418919fSjohnjiang uint32_t capability_flags;
7124418919fSjohnjiang /** LLR size in bits. LLR is a two’s complement number. */
7134418919fSjohnjiang int8_t llr_size;
7144418919fSjohnjiang /** LLR numbers of decimals bit for arithmetic representation */
7154418919fSjohnjiang int8_t llr_decimals;
7164418919fSjohnjiang /** Num input code block buffers */
7174418919fSjohnjiang uint16_t num_buffers_src;
7184418919fSjohnjiang /** Num hard output code block buffers */
7194418919fSjohnjiang uint16_t num_buffers_hard_out;
7204418919fSjohnjiang /** Num soft output code block buffers if supported by the driver */
7214418919fSjohnjiang uint16_t num_buffers_soft_out;
7224418919fSjohnjiang };
7234418919fSjohnjiang
7244418919fSjohnjiang /** List of the capabilities for the LDPC Encoder */
7254418919fSjohnjiang struct rte_bbdev_op_cap_ldpc_enc {
7264418919fSjohnjiang /** Flags from rte_bbdev_op_ldpcenc_flag_bitmasks */
7274418919fSjohnjiang uint32_t capability_flags;
7284418919fSjohnjiang /** Num input code block buffers */
7294418919fSjohnjiang uint16_t num_buffers_src;
7304418919fSjohnjiang /** Num output code block buffers */
7314418919fSjohnjiang uint16_t num_buffers_dst;
732d30ea906Sjfb8856606 };
733d30ea906Sjfb8856606
734d30ea906Sjfb8856606 /** Different operation types supported by the device */
735d30ea906Sjfb8856606 enum rte_bbdev_op_type {
736d30ea906Sjfb8856606 RTE_BBDEV_OP_NONE, /**< Dummy operation that does nothing */
737d30ea906Sjfb8856606 RTE_BBDEV_OP_TURBO_DEC, /**< Turbo decode */
738d30ea906Sjfb8856606 RTE_BBDEV_OP_TURBO_ENC, /**< Turbo encode */
7394418919fSjohnjiang RTE_BBDEV_OP_LDPC_DEC, /**< LDPC decode */
7404418919fSjohnjiang RTE_BBDEV_OP_LDPC_ENC, /**< LDPC encode */
741d30ea906Sjfb8856606 RTE_BBDEV_OP_TYPE_COUNT, /**< Count of different op types */
742d30ea906Sjfb8856606 };
743d30ea906Sjfb8856606
7444418919fSjohnjiang /** Bit indexes of possible errors reported through status field */
745d30ea906Sjfb8856606 enum {
746d30ea906Sjfb8856606 RTE_BBDEV_DRV_ERROR,
747d30ea906Sjfb8856606 RTE_BBDEV_DATA_ERROR,
748d30ea906Sjfb8856606 RTE_BBDEV_CRC_ERROR,
7494418919fSjohnjiang RTE_BBDEV_SYNDROME_ERROR
750d30ea906Sjfb8856606 };
751d30ea906Sjfb8856606
7524418919fSjohnjiang /** Structure specifying a single encode operation */
753d30ea906Sjfb8856606 struct rte_bbdev_enc_op {
7540c6bd470Sfengbojiang /** Status of operation that was performed */
7554418919fSjohnjiang int status;
7560c6bd470Sfengbojiang /** Mempool which op instance is in */
7574418919fSjohnjiang struct rte_mempool *mempool;
7580c6bd470Sfengbojiang /** Opaque pointer for user data */
7594418919fSjohnjiang void *opaque_data;
7604418919fSjohnjiang union {
7614418919fSjohnjiang /** Contains turbo decoder specific parameters */
762d30ea906Sjfb8856606 struct rte_bbdev_op_turbo_enc turbo_enc;
7634418919fSjohnjiang /** Contains LDPC decoder specific parameters */
7644418919fSjohnjiang struct rte_bbdev_op_ldpc_enc ldpc_enc;
7654418919fSjohnjiang };
766d30ea906Sjfb8856606 };
767d30ea906Sjfb8856606
7684418919fSjohnjiang /** Structure specifying a single decode operation */
769d30ea906Sjfb8856606 struct rte_bbdev_dec_op {
7704418919fSjohnjiang /** Status of operation that was performed */
7714418919fSjohnjiang int status;
7724418919fSjohnjiang /** Mempool which op instance is in */
7734418919fSjohnjiang struct rte_mempool *mempool;
7744418919fSjohnjiang /** Opaque pointer for user data */
7754418919fSjohnjiang void *opaque_data;
7764418919fSjohnjiang union {
7774418919fSjohnjiang /** Contains turbo decoder specific parameters */
778d30ea906Sjfb8856606 struct rte_bbdev_op_turbo_dec turbo_dec;
7794418919fSjohnjiang /** Contains LDPC decoder specific parameters */
7804418919fSjohnjiang struct rte_bbdev_op_ldpc_dec ldpc_dec;
7814418919fSjohnjiang };
782d30ea906Sjfb8856606 };
783d30ea906Sjfb8856606
7844418919fSjohnjiang /** Operation capabilities supported by a device */
785d30ea906Sjfb8856606 struct rte_bbdev_op_cap {
786d30ea906Sjfb8856606 enum rte_bbdev_op_type type; /**< Type of operation */
787d30ea906Sjfb8856606 union {
788d30ea906Sjfb8856606 struct rte_bbdev_op_cap_turbo_dec turbo_dec;
789d30ea906Sjfb8856606 struct rte_bbdev_op_cap_turbo_enc turbo_enc;
7904418919fSjohnjiang struct rte_bbdev_op_cap_ldpc_dec ldpc_dec;
7914418919fSjohnjiang struct rte_bbdev_op_cap_ldpc_enc ldpc_enc;
792d30ea906Sjfb8856606 } cap; /**< Operation-type specific capabilities */
793d30ea906Sjfb8856606 };
794d30ea906Sjfb8856606
7950c6bd470Sfengbojiang /** @internal Private data structure stored with operation pool. */
796d30ea906Sjfb8856606 struct rte_bbdev_op_pool_private {
797d30ea906Sjfb8856606 enum rte_bbdev_op_type type; /**< Type of operations in a pool */
798d30ea906Sjfb8856606 };
799d30ea906Sjfb8856606
800d30ea906Sjfb8856606 /**
801d30ea906Sjfb8856606 * Converts queue operation type from enum to string
802d30ea906Sjfb8856606 *
803d30ea906Sjfb8856606 * @param op_type
804d30ea906Sjfb8856606 * Operation type as enum
805d30ea906Sjfb8856606 *
806d30ea906Sjfb8856606 * @returns
807d30ea906Sjfb8856606 * Operation type as string or NULL if op_type is invalid
808d30ea906Sjfb8856606 *
809d30ea906Sjfb8856606 */
8104418919fSjohnjiang __rte_experimental
811d30ea906Sjfb8856606 const char*
812d30ea906Sjfb8856606 rte_bbdev_op_type_str(enum rte_bbdev_op_type op_type);
813d30ea906Sjfb8856606
814d30ea906Sjfb8856606 /**
815d30ea906Sjfb8856606 * Creates a bbdev operation mempool
816d30ea906Sjfb8856606 *
817d30ea906Sjfb8856606 * @param name
818d30ea906Sjfb8856606 * Pool name.
819d30ea906Sjfb8856606 * @param type
820d30ea906Sjfb8856606 * Operation type, use RTE_BBDEV_OP_NONE for a pool which supports all
821d30ea906Sjfb8856606 * operation types.
822d30ea906Sjfb8856606 * @param num_elements
823d30ea906Sjfb8856606 * Number of elements in the pool.
824d30ea906Sjfb8856606 * @param cache_size
825d30ea906Sjfb8856606 * Number of elements to cache on an lcore, see rte_mempool_create() for
826d30ea906Sjfb8856606 * further details about cache size.
827d30ea906Sjfb8856606 * @param socket_id
828d30ea906Sjfb8856606 * Socket to allocate memory on.
829d30ea906Sjfb8856606 *
830d30ea906Sjfb8856606 * @return
831d30ea906Sjfb8856606 * - Pointer to a mempool on success,
832d30ea906Sjfb8856606 * - NULL pointer on failure.
833d30ea906Sjfb8856606 */
8344418919fSjohnjiang __rte_experimental
835d30ea906Sjfb8856606 struct rte_mempool *
836d30ea906Sjfb8856606 rte_bbdev_op_pool_create(const char *name, enum rte_bbdev_op_type type,
837d30ea906Sjfb8856606 unsigned int num_elements, unsigned int cache_size,
838d30ea906Sjfb8856606 int socket_id);
839d30ea906Sjfb8856606
840d30ea906Sjfb8856606 /**
841d30ea906Sjfb8856606 * Bulk allocate encode operations from a mempool with parameter defaults reset.
842d30ea906Sjfb8856606 *
843d30ea906Sjfb8856606 * @param mempool
844d30ea906Sjfb8856606 * Operation mempool, created by rte_bbdev_op_pool_create().
845d30ea906Sjfb8856606 * @param ops
846d30ea906Sjfb8856606 * Output array to place allocated operations
847d30ea906Sjfb8856606 * @param num_ops
848d30ea906Sjfb8856606 * Number of operations to allocate
849d30ea906Sjfb8856606 *
850d30ea906Sjfb8856606 * @returns
851d30ea906Sjfb8856606 * - 0 on success
852d30ea906Sjfb8856606 * - EINVAL if invalid mempool is provided
853d30ea906Sjfb8856606 */
8544418919fSjohnjiang __rte_experimental
855d30ea906Sjfb8856606 static inline int
rte_bbdev_enc_op_alloc_bulk(struct rte_mempool * mempool,struct rte_bbdev_enc_op ** ops,uint16_t num_ops)856d30ea906Sjfb8856606 rte_bbdev_enc_op_alloc_bulk(struct rte_mempool *mempool,
857d30ea906Sjfb8856606 struct rte_bbdev_enc_op **ops, uint16_t num_ops)
858d30ea906Sjfb8856606 {
859d30ea906Sjfb8856606 struct rte_bbdev_op_pool_private *priv;
860d30ea906Sjfb8856606 int ret;
861d30ea906Sjfb8856606
862d30ea906Sjfb8856606 /* Check type */
863d30ea906Sjfb8856606 priv = (struct rte_bbdev_op_pool_private *)
864d30ea906Sjfb8856606 rte_mempool_get_priv(mempool);
8654418919fSjohnjiang if (unlikely((priv->type != RTE_BBDEV_OP_TURBO_ENC) &&
8664418919fSjohnjiang (priv->type != RTE_BBDEV_OP_LDPC_ENC)))
867d30ea906Sjfb8856606 return -EINVAL;
868d30ea906Sjfb8856606
869d30ea906Sjfb8856606 /* Get elements */
870d30ea906Sjfb8856606 ret = rte_mempool_get_bulk(mempool, (void **)ops, num_ops);
871d30ea906Sjfb8856606 if (unlikely(ret < 0))
872d30ea906Sjfb8856606 return ret;
873d30ea906Sjfb8856606
874d30ea906Sjfb8856606 return 0;
875d30ea906Sjfb8856606 }
876d30ea906Sjfb8856606
877d30ea906Sjfb8856606 /**
878d30ea906Sjfb8856606 * Bulk allocate decode operations from a mempool with parameter defaults reset.
879d30ea906Sjfb8856606 *
880d30ea906Sjfb8856606 * @param mempool
881d30ea906Sjfb8856606 * Operation mempool, created by rte_bbdev_op_pool_create().
882d30ea906Sjfb8856606 * @param ops
883d30ea906Sjfb8856606 * Output array to place allocated operations
884d30ea906Sjfb8856606 * @param num_ops
885d30ea906Sjfb8856606 * Number of operations to allocate
886d30ea906Sjfb8856606 *
887d30ea906Sjfb8856606 * @returns
888d30ea906Sjfb8856606 * - 0 on success
889d30ea906Sjfb8856606 * - EINVAL if invalid mempool is provided
890d30ea906Sjfb8856606 */
8914418919fSjohnjiang __rte_experimental
892d30ea906Sjfb8856606 static inline int
rte_bbdev_dec_op_alloc_bulk(struct rte_mempool * mempool,struct rte_bbdev_dec_op ** ops,uint16_t num_ops)893d30ea906Sjfb8856606 rte_bbdev_dec_op_alloc_bulk(struct rte_mempool *mempool,
894d30ea906Sjfb8856606 struct rte_bbdev_dec_op **ops, uint16_t num_ops)
895d30ea906Sjfb8856606 {
896d30ea906Sjfb8856606 struct rte_bbdev_op_pool_private *priv;
897d30ea906Sjfb8856606 int ret;
898d30ea906Sjfb8856606
899d30ea906Sjfb8856606 /* Check type */
900d30ea906Sjfb8856606 priv = (struct rte_bbdev_op_pool_private *)
901d30ea906Sjfb8856606 rte_mempool_get_priv(mempool);
9024418919fSjohnjiang if (unlikely((priv->type != RTE_BBDEV_OP_TURBO_DEC) &&
9034418919fSjohnjiang (priv->type != RTE_BBDEV_OP_LDPC_DEC)))
904d30ea906Sjfb8856606 return -EINVAL;
905d30ea906Sjfb8856606
906d30ea906Sjfb8856606 /* Get elements */
907d30ea906Sjfb8856606 ret = rte_mempool_get_bulk(mempool, (void **)ops, num_ops);
908d30ea906Sjfb8856606 if (unlikely(ret < 0))
909d30ea906Sjfb8856606 return ret;
910d30ea906Sjfb8856606
911d30ea906Sjfb8856606 return 0;
912d30ea906Sjfb8856606 }
913d30ea906Sjfb8856606
914d30ea906Sjfb8856606 /**
915d30ea906Sjfb8856606 * Free decode operation structures that were allocated by
916d30ea906Sjfb8856606 * rte_bbdev_dec_op_alloc_bulk().
917d30ea906Sjfb8856606 * All structures must belong to the same mempool.
918d30ea906Sjfb8856606 *
919d30ea906Sjfb8856606 * @param ops
920d30ea906Sjfb8856606 * Operation structures
921d30ea906Sjfb8856606 * @param num_ops
922d30ea906Sjfb8856606 * Number of structures
923d30ea906Sjfb8856606 */
9244418919fSjohnjiang __rte_experimental
925d30ea906Sjfb8856606 static inline void
rte_bbdev_dec_op_free_bulk(struct rte_bbdev_dec_op ** ops,unsigned int num_ops)926d30ea906Sjfb8856606 rte_bbdev_dec_op_free_bulk(struct rte_bbdev_dec_op **ops, unsigned int num_ops)
927d30ea906Sjfb8856606 {
928d30ea906Sjfb8856606 if (num_ops > 0)
929d30ea906Sjfb8856606 rte_mempool_put_bulk(ops[0]->mempool, (void **)ops, num_ops);
930d30ea906Sjfb8856606 }
931d30ea906Sjfb8856606
932d30ea906Sjfb8856606 /**
933d30ea906Sjfb8856606 * Free encode operation structures that were allocated by
934d30ea906Sjfb8856606 * rte_bbdev_enc_op_alloc_bulk().
935d30ea906Sjfb8856606 * All structures must belong to the same mempool.
936d30ea906Sjfb8856606 *
937d30ea906Sjfb8856606 * @param ops
938d30ea906Sjfb8856606 * Operation structures
939d30ea906Sjfb8856606 * @param num_ops
940d30ea906Sjfb8856606 * Number of structures
941d30ea906Sjfb8856606 */
9424418919fSjohnjiang __rte_experimental
943d30ea906Sjfb8856606 static inline void
rte_bbdev_enc_op_free_bulk(struct rte_bbdev_enc_op ** ops,unsigned int num_ops)944d30ea906Sjfb8856606 rte_bbdev_enc_op_free_bulk(struct rte_bbdev_enc_op **ops, unsigned int num_ops)
945d30ea906Sjfb8856606 {
946d30ea906Sjfb8856606 if (num_ops > 0)
947d30ea906Sjfb8856606 rte_mempool_put_bulk(ops[0]->mempool, (void **)ops, num_ops);
948d30ea906Sjfb8856606 }
949d30ea906Sjfb8856606
950d30ea906Sjfb8856606 #ifdef __cplusplus
951d30ea906Sjfb8856606 }
952d30ea906Sjfb8856606 #endif
953d30ea906Sjfb8856606
954d30ea906Sjfb8856606 #endif /* _RTE_BBDEV_OP_H_ */
955