199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
299a2dd95SBruce Richardson * Copyright(c) 2017 Intel Corporation
399a2dd95SBruce Richardson */
499a2dd95SBruce Richardson
599a2dd95SBruce Richardson #ifndef _RTE_BBDEV_OP_H_
699a2dd95SBruce Richardson #define _RTE_BBDEV_OP_H_
799a2dd95SBruce Richardson
899a2dd95SBruce Richardson /**
999a2dd95SBruce Richardson * @file rte_bbdev_op.h
1099a2dd95SBruce Richardson *
1199a2dd95SBruce Richardson * Defines wireless base band layer 1 operations and capabilities
1299a2dd95SBruce Richardson */
1399a2dd95SBruce Richardson
1499a2dd95SBruce Richardson #ifdef __cplusplus
1599a2dd95SBruce Richardson extern "C" {
1699a2dd95SBruce Richardson #endif
1799a2dd95SBruce Richardson
1899a2dd95SBruce Richardson #include <stdint.h>
1999a2dd95SBruce Richardson
2099a2dd95SBruce Richardson #include <rte_common.h>
2199a2dd95SBruce Richardson #include <rte_mbuf.h>
2299a2dd95SBruce Richardson #include <rte_memory.h>
2399a2dd95SBruce Richardson #include <rte_mempool.h>
2499a2dd95SBruce Richardson
2599a2dd95SBruce Richardson /* Number of columns in sub-block interleaver (36.212, section 5.1.4.1.1) */
2699a2dd95SBruce Richardson #define RTE_BBDEV_TURBO_C_SUBBLOCK (32)
2799a2dd95SBruce Richardson /* Maximum size of Transport Block (36.213, Table, Table 7.1.7.2.5-1) */
2899a2dd95SBruce Richardson #define RTE_BBDEV_TURBO_MAX_TB_SIZE (391656)
2999a2dd95SBruce Richardson /* Maximum size of Code Block (36.212, Table 5.1.3-3) */
3099a2dd95SBruce Richardson #define RTE_BBDEV_TURBO_MAX_CB_SIZE (6144)
3199a2dd95SBruce Richardson /* Maximum size of Code Block */
3299a2dd95SBruce Richardson #define RTE_BBDEV_LDPC_MAX_CB_SIZE (8448)
3399a2dd95SBruce Richardson /* Minimum size of Code Block */
3499a2dd95SBruce Richardson #define RTE_BBDEV_LDPC_MIN_CB_SIZE (40)
3599a2dd95SBruce Richardson /* Maximum E size we can manage with default mbuf */
3699a2dd95SBruce Richardson #define RTE_BBDEV_LDPC_E_MAX_MBUF (64000)
3799a2dd95SBruce Richardson /* Minimum size of Code Block (36.212, Table 5.1.3-3) */
3899a2dd95SBruce Richardson #define RTE_BBDEV_TURBO_MIN_CB_SIZE (40)
3999a2dd95SBruce Richardson /* Maximum size of circular buffer */
4099a2dd95SBruce Richardson #define RTE_BBDEV_TURBO_MAX_KW (18528)
4199a2dd95SBruce Richardson /*
4299a2dd95SBruce Richardson * Turbo: Maximum number of Code Blocks in Transport Block. It is calculated
4399a2dd95SBruce Richardson * based on maximum size of one Code Block and one Transport Block
4499a2dd95SBruce Richardson * (considering CRC24A and CRC24B):
4599a2dd95SBruce Richardson * (391656 + 24) / (6144 - 24) = 64
4699a2dd95SBruce Richardson */
4799a2dd95SBruce Richardson #define RTE_BBDEV_TURBO_MAX_CODE_BLOCKS (64)
4899a2dd95SBruce Richardson /* LDPC: Maximum number of Code Blocks in Transport Block.*/
4999a2dd95SBruce Richardson #define RTE_BBDEV_LDPC_MAX_CODE_BLOCKS (256)
5099a2dd95SBruce Richardson
5199a2dd95SBruce Richardson /** Flags for turbo decoder operation and capability structure */
5299a2dd95SBruce Richardson enum rte_bbdev_op_td_flag_bitmasks {
5399a2dd95SBruce Richardson /** If sub block de-interleaving is to be performed. */
5499a2dd95SBruce Richardson RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE = (1ULL << 0),
5599a2dd95SBruce Richardson /** To use CRC Type 24B (otherwise use CRC Type 24A). */
5699a2dd95SBruce Richardson RTE_BBDEV_TURBO_CRC_TYPE_24B = (1ULL << 1),
5799a2dd95SBruce Richardson /** If turbo equalization is to be performed. */
5899a2dd95SBruce Richardson RTE_BBDEV_TURBO_EQUALIZER = (1ULL << 2),
5999a2dd95SBruce Richardson /** If set, saturate soft output to +/-127 */
6099a2dd95SBruce Richardson RTE_BBDEV_TURBO_SOFT_OUT_SATURATE = (1ULL << 3),
6199a2dd95SBruce Richardson /** Set to 1 to start iteration from even, else odd; one iteration =
6299a2dd95SBruce Richardson * max_iteration + 0.5
6399a2dd95SBruce Richardson */
6499a2dd95SBruce Richardson RTE_BBDEV_TURBO_HALF_ITERATION_EVEN = (1ULL << 4),
6599a2dd95SBruce Richardson /** If 0, TD stops after CRC matches; else if 1, runs to end of next
6699a2dd95SBruce Richardson * odd iteration after CRC matches
6799a2dd95SBruce Richardson */
6899a2dd95SBruce Richardson RTE_BBDEV_TURBO_CONTINUE_CRC_MATCH = (1ULL << 5),
6999a2dd95SBruce Richardson /** Set if soft output is required to be output */
7099a2dd95SBruce Richardson RTE_BBDEV_TURBO_SOFT_OUTPUT = (1ULL << 6),
7199a2dd95SBruce Richardson /** Set to enable early termination mode */
7299a2dd95SBruce Richardson RTE_BBDEV_TURBO_EARLY_TERMINATION = (1ULL << 7),
7399a2dd95SBruce Richardson /** Set if a device supports decoder dequeue interrupts */
7499a2dd95SBruce Richardson RTE_BBDEV_TURBO_DEC_INTERRUPTS = (1ULL << 9),
7599a2dd95SBruce Richardson /** Set if positive LLR encoded input is supported. Positive LLR value
7699a2dd95SBruce Richardson * represents the level of confidence for bit '1', and vice versa for
7799a2dd95SBruce Richardson * bit '0'.
7899a2dd95SBruce Richardson * This is mutually exclusive with RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN
7999a2dd95SBruce Richardson * when used to formalize the input data format.
8099a2dd95SBruce Richardson */
8199a2dd95SBruce Richardson RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN = (1ULL << 10),
8299a2dd95SBruce Richardson /** Set if negative LLR encoded input is supported. Negative LLR value
8399a2dd95SBruce Richardson * represents the level of confidence for bit '1', and vice versa for
8499a2dd95SBruce Richardson * bit '0'.
8599a2dd95SBruce Richardson * This is mutually exclusive with RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN
8699a2dd95SBruce Richardson * when used to formalize the input data format.
8799a2dd95SBruce Richardson */
8899a2dd95SBruce Richardson RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN = (1ULL << 11),
8999a2dd95SBruce Richardson /** Set if positive LLR soft output is supported. Positive LLR value
9099a2dd95SBruce Richardson * represents the level of confidence for bit '1', and vice versa for
9199a2dd95SBruce Richardson * bit '0'.
9299a2dd95SBruce Richardson * This is mutually exclusive with
9399a2dd95SBruce Richardson * RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT when used to formalize
9499a2dd95SBruce Richardson * the input data format.
9599a2dd95SBruce Richardson */
9699a2dd95SBruce Richardson RTE_BBDEV_TURBO_POS_LLR_1_BIT_SOFT_OUT = (1ULL << 12),
9799a2dd95SBruce Richardson /** Set if negative LLR soft output is supported. Negative LLR value
9899a2dd95SBruce Richardson * represents the level of confidence for bit '1', and vice versa for
9999a2dd95SBruce Richardson * bit '0'.
10099a2dd95SBruce Richardson * This is mutually exclusive with
10199a2dd95SBruce Richardson * RTE_BBDEV_TURBO_POS_LLR_1_BIT_SOFT_OUT when used to formalize the
10299a2dd95SBruce Richardson * input data format.
10399a2dd95SBruce Richardson */
10499a2dd95SBruce Richardson RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT = (1ULL << 13),
10599a2dd95SBruce Richardson /** Set if driver supports flexible parallel MAP engine decoding. If
10699a2dd95SBruce Richardson * not supported, num_maps (number of MAP engines) argument is unusable.
10799a2dd95SBruce Richardson */
10899a2dd95SBruce Richardson RTE_BBDEV_TURBO_MAP_DEC = (1ULL << 14),
10999a2dd95SBruce Richardson /** Set if a device supports scatter-gather functionality */
11099a2dd95SBruce Richardson RTE_BBDEV_TURBO_DEC_SCATTER_GATHER = (1ULL << 15),
11199a2dd95SBruce Richardson /** Set to keep CRC24B bits appended while decoding. Only usable when
11299a2dd95SBruce Richardson * decoding Transport Block mode.
11399a2dd95SBruce Richardson */
114*10ea15e3SNicolas Chautru RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP = (1ULL << 16),
115*10ea15e3SNicolas Chautru /** Set to drop CRC24B bits not to be appended while decoding.
116*10ea15e3SNicolas Chautru */
117*10ea15e3SNicolas Chautru RTE_BBDEV_TURBO_DEC_CRC_24B_DROP = (1ULL << 17)
11899a2dd95SBruce Richardson };
11999a2dd95SBruce Richardson
12099a2dd95SBruce Richardson
12199a2dd95SBruce Richardson /** Flags for turbo encoder operation and capability structure */
12299a2dd95SBruce Richardson enum rte_bbdev_op_te_flag_bitmasks {
12399a2dd95SBruce Richardson /** Ignore rv_index and set K0 = 0 */
12499a2dd95SBruce Richardson RTE_BBDEV_TURBO_RV_INDEX_BYPASS = (1ULL << 0),
12599a2dd95SBruce Richardson /** If rate matching is to be performed */
12699a2dd95SBruce Richardson RTE_BBDEV_TURBO_RATE_MATCH = (1ULL << 1),
12799a2dd95SBruce Richardson /** This bit must be set to enable CRC-24B generation */
12899a2dd95SBruce Richardson RTE_BBDEV_TURBO_CRC_24B_ATTACH = (1ULL << 2),
12999a2dd95SBruce Richardson /** This bit must be set to enable CRC-24A generation */
13099a2dd95SBruce Richardson RTE_BBDEV_TURBO_CRC_24A_ATTACH = (1ULL << 3),
13199a2dd95SBruce Richardson /** Set if a device supports encoder dequeue interrupts */
13299a2dd95SBruce Richardson RTE_BBDEV_TURBO_ENC_INTERRUPTS = (1ULL << 4),
13399a2dd95SBruce Richardson /** Set if a device supports scatter-gather functionality */
13499a2dd95SBruce Richardson RTE_BBDEV_TURBO_ENC_SCATTER_GATHER = (1ULL << 5)
13599a2dd95SBruce Richardson };
13699a2dd95SBruce Richardson
13799a2dd95SBruce Richardson /** Flags for LDPC decoder operation and capability structure */
13899a2dd95SBruce Richardson enum rte_bbdev_op_ldpcdec_flag_bitmasks {
13999a2dd95SBruce Richardson /** Set for transport block CRC-24A checking */
14099a2dd95SBruce Richardson RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK = (1ULL << 0),
14199a2dd95SBruce Richardson /** Set for code block CRC-24B checking */
14299a2dd95SBruce Richardson RTE_BBDEV_LDPC_CRC_TYPE_24B_CHECK = (1ULL << 1),
14399a2dd95SBruce Richardson /** Set to drop the last CRC bits decoding output */
14499a2dd95SBruce Richardson RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP = (1ULL << 2),
145cc360fd3SNicolas Chautru /** Set for transport block CRC-16 checking */
146cc360fd3SNicolas Chautru RTE_BBDEV_LDPC_CRC_TYPE_16_CHECK = (1ULL << 3),
14799a2dd95SBruce Richardson /** Set for bit-level de-interleaver bypass on Rx stream. */
148cc360fd3SNicolas Chautru RTE_BBDEV_LDPC_DEINTERLEAVER_BYPASS = (1ULL << 4),
14999a2dd95SBruce Richardson /** Set for HARQ combined input stream enable. */
150cc360fd3SNicolas Chautru RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE = (1ULL << 5),
15199a2dd95SBruce Richardson /** Set for HARQ combined output stream enable. */
152cc360fd3SNicolas Chautru RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE = (1ULL << 6),
15399a2dd95SBruce Richardson /** Set for LDPC decoder bypass.
15499a2dd95SBruce Richardson * RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE must be set.
15599a2dd95SBruce Richardson */
156cc360fd3SNicolas Chautru RTE_BBDEV_LDPC_DECODE_BYPASS = (1ULL << 7),
15799a2dd95SBruce Richardson /** Set for soft-output stream enable */
158cc360fd3SNicolas Chautru RTE_BBDEV_LDPC_SOFT_OUT_ENABLE = (1ULL << 8),
15999a2dd95SBruce Richardson /** Set for Rate-Matching bypass on soft-out stream. */
160cc360fd3SNicolas Chautru RTE_BBDEV_LDPC_SOFT_OUT_RM_BYPASS = (1ULL << 9),
16199a2dd95SBruce Richardson /** Set for bit-level de-interleaver bypass on soft-output stream. */
162cc360fd3SNicolas Chautru RTE_BBDEV_LDPC_SOFT_OUT_DEINTERLEAVER_BYPASS = (1ULL << 10),
16399a2dd95SBruce Richardson /** Set for iteration stopping on successful decode condition
16499a2dd95SBruce Richardson * i.e. a successful syndrome check.
16599a2dd95SBruce Richardson */
166cc360fd3SNicolas Chautru RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE = (1ULL << 11),
16799a2dd95SBruce Richardson /** Set if a device supports decoder dequeue interrupts. */
168cc360fd3SNicolas Chautru RTE_BBDEV_LDPC_DEC_INTERRUPTS = (1ULL << 12),
16999a2dd95SBruce Richardson /** Set if a device supports scatter-gather functionality. */
170cc360fd3SNicolas Chautru RTE_BBDEV_LDPC_DEC_SCATTER_GATHER = (1ULL << 13),
17199a2dd95SBruce Richardson /** Set if a device supports input/output HARQ compression. */
172cc360fd3SNicolas Chautru RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION = (1ULL << 14),
17399a2dd95SBruce Richardson /** Set if a device supports input LLR compression. */
174cc360fd3SNicolas Chautru RTE_BBDEV_LDPC_LLR_COMPRESSION = (1ULL << 15),
17599a2dd95SBruce Richardson /** Set if a device supports HARQ input from
17699a2dd95SBruce Richardson * device's internal memory.
17799a2dd95SBruce Richardson */
178cc360fd3SNicolas Chautru RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE = (1ULL << 16),
17999a2dd95SBruce Richardson /** Set if a device supports HARQ output to
18099a2dd95SBruce Richardson * device's internal memory.
18199a2dd95SBruce Richardson */
182cc360fd3SNicolas Chautru RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE = (1ULL << 17),
18399a2dd95SBruce Richardson /** Set if a device supports loop-back access to
18499a2dd95SBruce Richardson * HARQ internal memory. Intended for troubleshooting.
18599a2dd95SBruce Richardson */
186cc360fd3SNicolas Chautru RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK = (1ULL << 18),
18799a2dd95SBruce Richardson /** Set if a device includes LLR filler bits in the circular buffer
18899a2dd95SBruce Richardson * for HARQ memory. If not set, it is assumed the filler bits are not
18999a2dd95SBruce Richardson * in HARQ memory and handled directly by the LDPC decoder.
19099a2dd95SBruce Richardson */
191cc360fd3SNicolas Chautru RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_FILLERS = (1ULL << 19)
19299a2dd95SBruce Richardson };
19399a2dd95SBruce Richardson
19499a2dd95SBruce Richardson /** Flags for LDPC encoder operation and capability structure */
19599a2dd95SBruce Richardson enum rte_bbdev_op_ldpcenc_flag_bitmasks {
19699a2dd95SBruce Richardson /** Set for bit-level interleaver bypass on output stream. */
19799a2dd95SBruce Richardson RTE_BBDEV_LDPC_INTERLEAVER_BYPASS = (1ULL << 0),
19899a2dd95SBruce Richardson /** If rate matching is to be performed */
19999a2dd95SBruce Richardson RTE_BBDEV_LDPC_RATE_MATCH = (1ULL << 1),
20099a2dd95SBruce Richardson /** Set for transport block CRC-24A attach */
20199a2dd95SBruce Richardson RTE_BBDEV_LDPC_CRC_24A_ATTACH = (1ULL << 2),
20299a2dd95SBruce Richardson /** Set for code block CRC-24B attach */
20399a2dd95SBruce Richardson RTE_BBDEV_LDPC_CRC_24B_ATTACH = (1ULL << 3),
20499a2dd95SBruce Richardson /** Set for code block CRC-16 attach */
20599a2dd95SBruce Richardson RTE_BBDEV_LDPC_CRC_16_ATTACH = (1ULL << 4),
20699a2dd95SBruce Richardson /** Set if a device supports encoder dequeue interrupts. */
20799a2dd95SBruce Richardson RTE_BBDEV_LDPC_ENC_INTERRUPTS = (1ULL << 5),
20899a2dd95SBruce Richardson /** Set if a device supports scatter-gather functionality. */
20999a2dd95SBruce Richardson RTE_BBDEV_LDPC_ENC_SCATTER_GATHER = (1ULL << 6),
21099a2dd95SBruce Richardson /** Set if a device supports concatenation of non byte aligned output */
21199a2dd95SBruce Richardson RTE_BBDEV_LDPC_ENC_CONCATENATION = (1ULL << 7)
21299a2dd95SBruce Richardson };
21399a2dd95SBruce Richardson
21499a2dd95SBruce Richardson /** Flags for the Code Block/Transport block mode */
21599a2dd95SBruce Richardson enum rte_bbdev_op_cb_mode {
21699a2dd95SBruce Richardson /** One operation is one or fraction of one transport block */
21799a2dd95SBruce Richardson RTE_BBDEV_TRANSPORT_BLOCK = 0,
21899a2dd95SBruce Richardson /** One operation is one code block mode */
21999a2dd95SBruce Richardson RTE_BBDEV_CODE_BLOCK = 1,
22099a2dd95SBruce Richardson };
22199a2dd95SBruce Richardson
22299a2dd95SBruce Richardson /** Data input and output buffer for BBDEV operations */
22399a2dd95SBruce Richardson struct rte_bbdev_op_data {
22499a2dd95SBruce Richardson /** The mbuf data structure representing the data for BBDEV operation.
22599a2dd95SBruce Richardson *
22699a2dd95SBruce Richardson * This mbuf pointer can point to one Code Block (CB) data buffer or
22799a2dd95SBruce Richardson * multiple CBs contiguously located next to each other.
22899a2dd95SBruce Richardson * A Transport Block (TB) represents a whole piece of data that is
22999a2dd95SBruce Richardson * divided into one or more CBs. Maximum number of CBs can be contained
23099a2dd95SBruce Richardson * in one TB is defined by RTE_BBDEV_(TURBO/LDPC)_MAX_CODE_BLOCKS.
23199a2dd95SBruce Richardson *
23299a2dd95SBruce Richardson * An mbuf data structure cannot represent more than one TB. The
23399a2dd95SBruce Richardson * smallest piece of data that can be contained in one mbuf is one CB.
23499a2dd95SBruce Richardson * An mbuf can include one contiguous CB, subset of contiguous CBs that
23599a2dd95SBruce Richardson * are belonging to one TB, or all contiguous CBs that are belonging to
23699a2dd95SBruce Richardson * one TB.
23799a2dd95SBruce Richardson *
23899a2dd95SBruce Richardson * If a BBDEV PMD supports the extended capability "Scatter-Gather",
23999a2dd95SBruce Richardson * then it is capable of collecting (gathering) non-contiguous
24099a2dd95SBruce Richardson * (scattered) data from multiple locations in the memory.
24199a2dd95SBruce Richardson * This capability is reported by the capability flags:
24299a2dd95SBruce Richardson * - RTE_BBDEV_(TURBO/LDPC)_ENC_SCATTER_GATHER and
24399a2dd95SBruce Richardson * - RTE_BBDEV_(TURBO/LDPC)_DEC_SCATTER_GATHER.
24499a2dd95SBruce Richardson * Only if a BBDEV PMD supports this feature, chained mbuf data
24599a2dd95SBruce Richardson * structures are accepted. A chained mbuf can represent one
24699a2dd95SBruce Richardson * non-contiguous CB or multiple non-contiguous CBs.
24799a2dd95SBruce Richardson * If BBDEV PMD does not support this feature, it will assume inbound
24899a2dd95SBruce Richardson * mbuf data contains one segment.
24999a2dd95SBruce Richardson *
25099a2dd95SBruce Richardson * The output mbuf data though is always one segment, even if the input
25199a2dd95SBruce Richardson * was a chained mbuf.
25299a2dd95SBruce Richardson */
25399a2dd95SBruce Richardson struct rte_mbuf *data;
25499a2dd95SBruce Richardson /** The starting point of the BBDEV (encode/decode) operation,
25599a2dd95SBruce Richardson * in bytes.
25699a2dd95SBruce Richardson *
25799a2dd95SBruce Richardson * BBDEV starts to read data past this offset.
25899a2dd95SBruce Richardson * In case of chained mbuf, this offset applies only to the first mbuf
25999a2dd95SBruce Richardson * segment.
26099a2dd95SBruce Richardson */
26199a2dd95SBruce Richardson uint32_t offset;
26299a2dd95SBruce Richardson /** The total data length to be processed in one operation, in bytes.
26399a2dd95SBruce Richardson *
26499a2dd95SBruce Richardson * In case the mbuf data is representing one CB, this is the length of
26599a2dd95SBruce Richardson * the CB undergoing the operation.
26699a2dd95SBruce Richardson * If it's for multiple CBs, this is the total length of those CBs
26799a2dd95SBruce Richardson * undergoing the operation.
26899a2dd95SBruce Richardson * If it is for one TB, this is the total length of the TB under
26999a2dd95SBruce Richardson * operation.
27099a2dd95SBruce Richardson *
27199a2dd95SBruce Richardson * In case of chained mbuf, this data length includes the lengths of the
27299a2dd95SBruce Richardson * "scattered" data segments undergoing the operation.
27399a2dd95SBruce Richardson */
27499a2dd95SBruce Richardson uint32_t length;
27599a2dd95SBruce Richardson };
27699a2dd95SBruce Richardson
27799a2dd95SBruce Richardson /** Turbo decode code block parameters */
27899a2dd95SBruce Richardson struct rte_bbdev_op_dec_turbo_cb_params {
27999a2dd95SBruce Richardson /** The K size of the input CB, in bits [40:6144], as specified in
28099a2dd95SBruce Richardson * 3GPP TS 36.212.
28199a2dd95SBruce Richardson * This size is inclusive of CRC bits, regardless whether it was
28299a2dd95SBruce Richardson * pre-calculated by the application or not.
28399a2dd95SBruce Richardson */
28499a2dd95SBruce Richardson uint16_t k;
28599a2dd95SBruce Richardson /** The E length of the CB rate matched LLR output, in bytes, as in
28699a2dd95SBruce Richardson * 3GPP TS 36.212.
28799a2dd95SBruce Richardson */
28899a2dd95SBruce Richardson uint32_t e;
28999a2dd95SBruce Richardson };
29099a2dd95SBruce Richardson
29199a2dd95SBruce Richardson /** LDPC decode code block parameters */
29299a2dd95SBruce Richardson struct rte_bbdev_op_dec_ldpc_cb_params {
29399a2dd95SBruce Richardson /** Rate matching output sequence length in bits or LLRs.
29499a2dd95SBruce Richardson * [3GPP TS38.212, section 5.4.2.1]
29599a2dd95SBruce Richardson */
29699a2dd95SBruce Richardson uint32_t e;
29799a2dd95SBruce Richardson };
29899a2dd95SBruce Richardson
29999a2dd95SBruce Richardson /** Turbo decode transport block parameters */
30099a2dd95SBruce Richardson struct rte_bbdev_op_dec_turbo_tb_params {
30199a2dd95SBruce Richardson /** The K- size of the input CB, in bits [40:6144], that is in the
30299a2dd95SBruce Richardson * Turbo operation when r < C-, as in 3GPP TS 36.212.
30399a2dd95SBruce Richardson */
30499a2dd95SBruce Richardson uint16_t k_neg;
30599a2dd95SBruce Richardson /** The K+ size of the input CB, in bits [40:6144], that is in the
30699a2dd95SBruce Richardson * Turbo operation when r >= C-, as in 3GPP TS 36.212.
30799a2dd95SBruce Richardson */
30899a2dd95SBruce Richardson uint16_t k_pos;
30999a2dd95SBruce Richardson /** The number of CBs that have K- size, [0:63] */
31099a2dd95SBruce Richardson uint8_t c_neg;
31199a2dd95SBruce Richardson /** The total number of CBs in the TB,
31299a2dd95SBruce Richardson * [1:RTE_BBDEV_TURBO_MAX_CODE_BLOCKS]
31399a2dd95SBruce Richardson */
31499a2dd95SBruce Richardson uint8_t c;
31599a2dd95SBruce Richardson /** The number of CBs that uses Ea before switching to Eb, [0:63] */
31699a2dd95SBruce Richardson uint8_t cab;
31799a2dd95SBruce Richardson /** The E size of the CB rate matched output to use in the Turbo
31899a2dd95SBruce Richardson * operation when r < cab
31999a2dd95SBruce Richardson */
32099a2dd95SBruce Richardson uint32_t ea;
32199a2dd95SBruce Richardson /** The E size of the CB rate matched output to use in the Turbo
32299a2dd95SBruce Richardson * operation when r >= cab
32399a2dd95SBruce Richardson */
32499a2dd95SBruce Richardson uint32_t eb;
32599a2dd95SBruce Richardson /** The index of the first CB in the inbound mbuf data, default is 0 */
32699a2dd95SBruce Richardson uint8_t r;
32799a2dd95SBruce Richardson };
32899a2dd95SBruce Richardson
32999a2dd95SBruce Richardson /** LDPC decode transport block parameters */
33099a2dd95SBruce Richardson struct rte_bbdev_op_dec_ldpc_tb_params {
33199a2dd95SBruce Richardson /** Ea, length after rate matching in bits, r < cab.
33299a2dd95SBruce Richardson * [3GPP TS38.212, section 5.4.2.1]
33399a2dd95SBruce Richardson */
33499a2dd95SBruce Richardson uint32_t ea;
33599a2dd95SBruce Richardson /** Eb, length after rate matching in bits, r >= cab.
33699a2dd95SBruce Richardson * [3GPP TS38.212, section 5.4.2.1]
33799a2dd95SBruce Richardson */
33899a2dd95SBruce Richardson uint32_t eb;
33999a2dd95SBruce Richardson /** The total number of CBs in the TB or partial TB
34099a2dd95SBruce Richardson * [1:RTE_BBDEV_LDPC_MAX_CODE_BLOCKS]
34199a2dd95SBruce Richardson */
34299a2dd95SBruce Richardson uint8_t c;
34399a2dd95SBruce Richardson /** The index of the first CB in the inbound mbuf data, default is 0 */
34499a2dd95SBruce Richardson uint8_t r;
34599a2dd95SBruce Richardson /** The number of CBs that use Ea before switching to Eb, [0:63] */
34699a2dd95SBruce Richardson uint8_t cab;
34799a2dd95SBruce Richardson };
34899a2dd95SBruce Richardson
34999a2dd95SBruce Richardson /** Operation structure for Turbo decode.
35099a2dd95SBruce Richardson * An operation can be performed on one CB at a time "CB-mode".
35199a2dd95SBruce Richardson * An operation can be performed on one or multiple CBs that logically
35299a2dd95SBruce Richardson * belong to one TB "TB-mode".
35399a2dd95SBruce Richardson * The provided K size parameter of the CB is its size coming from the
35499a2dd95SBruce Richardson * decode operation.
35599a2dd95SBruce Richardson * CRC24A/B check is requested by the application by setting the flag
35699a2dd95SBruce Richardson * RTE_BBDEV_TURBO_CRC_TYPE_24B for CRC24B check or CRC24A otherwise.
35799a2dd95SBruce Richardson * In TB-mode, BBDEV concatenates the decoded CBs one next to the other with
35899a2dd95SBruce Richardson * relevant CRC24B in between.
35999a2dd95SBruce Richardson *
36099a2dd95SBruce Richardson * The input encoded CB data is the Virtual Circular Buffer data stream, wk,
36199a2dd95SBruce Richardson * with the null padding included as described in 3GPP TS 36.212
36299a2dd95SBruce Richardson * section 5.1.4.1.2 and shown in 3GPP TS 36.212 section 5.1.4.1 Figure 5.1.4-1.
36399a2dd95SBruce Richardson * The size of the virtual circular buffer is 3*Kpi, where Kpi is the 32 byte
36499a2dd95SBruce Richardson * aligned value of K, as specified in 3GPP TS 36.212 section 5.1.4.1.1.
36599a2dd95SBruce Richardson *
36699a2dd95SBruce Richardson * Each byte in the input circular buffer is the LLR value of each bit of the
36799a2dd95SBruce Richardson * original CB.
36899a2dd95SBruce Richardson *
36999a2dd95SBruce Richardson * Hard output is a mandatory capability that all BBDEV PMDs support. This is
37099a2dd95SBruce Richardson * the decoded CBs of K sizes (CRC24A/B is the last 24-bit in each decoded CB).
37199a2dd95SBruce Richardson * Soft output is an optional capability for BBDEV PMDs. If supported, an LLR
37299a2dd95SBruce Richardson * rate matched output is computed in the soft_output buffer structure.
37399a2dd95SBruce Richardson *
37499a2dd95SBruce Richardson * The output mbuf data structure is expected to be allocated by the
37599a2dd95SBruce Richardson * application with enough room for the output data.
37699a2dd95SBruce Richardson */
37799a2dd95SBruce Richardson struct rte_bbdev_op_turbo_dec {
37899a2dd95SBruce Richardson /** The Virtual Circular Buffer, wk, size 3*Kpi for each CB */
37999a2dd95SBruce Richardson struct rte_bbdev_op_data input;
38099a2dd95SBruce Richardson /** The hard decisions buffer for the decoded output,
38199a2dd95SBruce Richardson * size K for each CB
38299a2dd95SBruce Richardson */
38399a2dd95SBruce Richardson struct rte_bbdev_op_data hard_output;
38499a2dd95SBruce Richardson /** The soft LLR output buffer - optional */
38599a2dd95SBruce Richardson struct rte_bbdev_op_data soft_output;
38699a2dd95SBruce Richardson
38799a2dd95SBruce Richardson /** Flags from rte_bbdev_op_td_flag_bitmasks */
38899a2dd95SBruce Richardson uint32_t op_flags;
38999a2dd95SBruce Richardson
39099a2dd95SBruce Richardson /** Rv index for rate matching [0:3] */
39199a2dd95SBruce Richardson uint8_t rv_index;
39299a2dd95SBruce Richardson /** The minimum number of iterations to perform in decoding all CBs in
39399a2dd95SBruce Richardson * this operation - input
39499a2dd95SBruce Richardson */
39599a2dd95SBruce Richardson uint8_t iter_min:4;
39699a2dd95SBruce Richardson /** The maximum number of iterations to perform in decoding all CBs in
39799a2dd95SBruce Richardson * this operation - input
39899a2dd95SBruce Richardson */
39999a2dd95SBruce Richardson uint8_t iter_max:4;
40099a2dd95SBruce Richardson /** The maximum number of iterations that were performed in decoding
40199a2dd95SBruce Richardson * all CBs in this decode operation - output
40299a2dd95SBruce Richardson */
40399a2dd95SBruce Richardson uint8_t iter_count;
40499a2dd95SBruce Richardson /** 5 bit extrinsic scale (scale factor on extrinsic info) */
40599a2dd95SBruce Richardson uint8_t ext_scale;
40699a2dd95SBruce Richardson /** Number of MAP engines to use in decode,
40799a2dd95SBruce Richardson * must be power of 2 (or 0 to auto-select)
40899a2dd95SBruce Richardson */
40999a2dd95SBruce Richardson uint8_t num_maps;
41099a2dd95SBruce Richardson
41199a2dd95SBruce Richardson /** [0 - TB : 1 - CB] */
41299a2dd95SBruce Richardson uint8_t code_block_mode;
41399a2dd95SBruce Richardson union {
41499a2dd95SBruce Richardson /** Struct which stores Code Block specific parameters */
41599a2dd95SBruce Richardson struct rte_bbdev_op_dec_turbo_cb_params cb_params;
41699a2dd95SBruce Richardson /** Struct which stores Transport Block specific parameters */
41799a2dd95SBruce Richardson struct rte_bbdev_op_dec_turbo_tb_params tb_params;
41899a2dd95SBruce Richardson };
41999a2dd95SBruce Richardson };
42099a2dd95SBruce Richardson
42199a2dd95SBruce Richardson /** Operation structure for LDPC decode.
42299a2dd95SBruce Richardson *
42399a2dd95SBruce Richardson * An operation can be performed on one CB at a time "CB-mode".
42499a2dd95SBruce Richardson * An operation can also be performed on one or multiple CBs that logically
42599a2dd95SBruce Richardson * belong to a TB "TB-mode" (Currently not supported).
42699a2dd95SBruce Richardson *
42799a2dd95SBruce Richardson * The input encoded CB data is the Virtual Circular Buffer data stream.
42899a2dd95SBruce Richardson *
42999a2dd95SBruce Richardson * Each byte in the input circular buffer is the LLR value of each bit of the
43099a2dd95SBruce Richardson * original CB.
43199a2dd95SBruce Richardson *
43299a2dd95SBruce Richardson * Hard output is a mandatory capability that all BBDEV PMDs support. This is
43399a2dd95SBruce Richardson * the decoded CBs (CRC24A/B is the last 24-bit in each decoded CB).
43499a2dd95SBruce Richardson *
43599a2dd95SBruce Richardson * Soft output is an optional capability for BBDEV PMDs. If supported, an LLR
43699a2dd95SBruce Richardson * rate matched output is computed in the soft_output buffer structure.
43799a2dd95SBruce Richardson * These are A Posteriori Probabilities (APP) LLR samples for coded bits.
43899a2dd95SBruce Richardson *
43999a2dd95SBruce Richardson * HARQ combined output is an optional capability for BBDEV PMDs.
44099a2dd95SBruce Richardson * If supported, a LLR output is streamed to the harq_combined_output
44199a2dd95SBruce Richardson * buffer.
44299a2dd95SBruce Richardson *
44399a2dd95SBruce Richardson * HARQ combined input is an optional capability for BBDEV PMDs.
44499a2dd95SBruce Richardson * If supported, a LLR input is streamed from the harq_combined_input
44599a2dd95SBruce Richardson * buffer.
44699a2dd95SBruce Richardson *
44799a2dd95SBruce Richardson * The output mbuf data structure is expected to be allocated by the
44899a2dd95SBruce Richardson * application with enough room for the output data.
44999a2dd95SBruce Richardson */
45099a2dd95SBruce Richardson struct rte_bbdev_op_ldpc_dec {
45199a2dd95SBruce Richardson /** The Virtual Circular Buffer for this code block, one LLR
45299a2dd95SBruce Richardson * per bit of the original CB.
45399a2dd95SBruce Richardson */
45499a2dd95SBruce Richardson struct rte_bbdev_op_data input;
45599a2dd95SBruce Richardson /** The hard decisions buffer for the decoded output,
45699a2dd95SBruce Richardson * size K for each CB
45799a2dd95SBruce Richardson */
45899a2dd95SBruce Richardson struct rte_bbdev_op_data hard_output;
45999a2dd95SBruce Richardson /** The soft LLR output LLR stream buffer - optional */
46099a2dd95SBruce Richardson struct rte_bbdev_op_data soft_output;
46199a2dd95SBruce Richardson /** The HARQ combined LLR stream input buffer - optional */
46299a2dd95SBruce Richardson struct rte_bbdev_op_data harq_combined_input;
46399a2dd95SBruce Richardson /** The HARQ combined LLR stream output buffer - optional */
46499a2dd95SBruce Richardson struct rte_bbdev_op_data harq_combined_output;
46599a2dd95SBruce Richardson
46699a2dd95SBruce Richardson /** Flags from rte_bbdev_op_ldpcdec_flag_bitmasks */
46799a2dd95SBruce Richardson uint32_t op_flags;
46899a2dd95SBruce Richardson
46999a2dd95SBruce Richardson /** Rate matching redundancy version
47099a2dd95SBruce Richardson * [3GPP TS38.212, section 5.4.2.1]
47199a2dd95SBruce Richardson */
47299a2dd95SBruce Richardson uint8_t rv_index;
47399a2dd95SBruce Richardson /** The maximum number of iterations to perform in decoding CB in
47499a2dd95SBruce Richardson * this operation - input
47599a2dd95SBruce Richardson */
47699a2dd95SBruce Richardson uint8_t iter_max;
47799a2dd95SBruce Richardson /** The number of iterations that were performed in decoding
47899a2dd95SBruce Richardson * CB in this decode operation - output
47999a2dd95SBruce Richardson */
48099a2dd95SBruce Richardson uint8_t iter_count;
48199a2dd95SBruce Richardson /** 1: LDPC Base graph 1, 2: LDPC Base graph 2.
48299a2dd95SBruce Richardson * [3GPP TS38.212, section 5.2.2]
48399a2dd95SBruce Richardson */
48499a2dd95SBruce Richardson uint8_t basegraph;
48599a2dd95SBruce Richardson /** Zc, LDPC lifting size.
48699a2dd95SBruce Richardson * [3GPP TS38.212, section 5.2.2]
48799a2dd95SBruce Richardson */
48899a2dd95SBruce Richardson uint16_t z_c;
48999a2dd95SBruce Richardson /** Ncb, length of the circular buffer in bits.
49099a2dd95SBruce Richardson * [3GPP TS38.212, section 5.4.2.1]
49199a2dd95SBruce Richardson */
49299a2dd95SBruce Richardson uint16_t n_cb;
49399a2dd95SBruce Richardson /** Qm, modulation order {1,2,4,6,8}.
49499a2dd95SBruce Richardson * [3GPP TS38.212, section 5.4.2.2]
49599a2dd95SBruce Richardson */
49699a2dd95SBruce Richardson uint8_t q_m;
49799a2dd95SBruce Richardson /** Number of Filler bits, n_filler = K – K’
49899a2dd95SBruce Richardson * [3GPP TS38.212 section 5.2.2]
49999a2dd95SBruce Richardson */
50099a2dd95SBruce Richardson uint16_t n_filler;
50199a2dd95SBruce Richardson /** [0 - TB : 1 - CB] */
50299a2dd95SBruce Richardson uint8_t code_block_mode;
50399a2dd95SBruce Richardson union {
50499a2dd95SBruce Richardson /** Struct which stores Code Block specific parameters */
50599a2dd95SBruce Richardson struct rte_bbdev_op_dec_ldpc_cb_params cb_params;
50699a2dd95SBruce Richardson /** Struct which stores Transport Block specific parameters */
50799a2dd95SBruce Richardson struct rte_bbdev_op_dec_ldpc_tb_params tb_params;
50899a2dd95SBruce Richardson };
50999a2dd95SBruce Richardson };
51099a2dd95SBruce Richardson
51199a2dd95SBruce Richardson /** Turbo encode code block parameters */
51299a2dd95SBruce Richardson struct rte_bbdev_op_enc_turbo_cb_params {
51399a2dd95SBruce Richardson /** The K size of the input CB, in bits [40:6144], as specified in
51499a2dd95SBruce Richardson * 3GPP TS 36.212.
51599a2dd95SBruce Richardson * This size is inclusive of CRC24A, regardless whether it was
51699a2dd95SBruce Richardson * pre-calculated by the application or not.
51799a2dd95SBruce Richardson */
51899a2dd95SBruce Richardson uint16_t k;
51999a2dd95SBruce Richardson /** The E length of the CB rate matched output, in bits, as in
52099a2dd95SBruce Richardson * 3GPP TS 36.212.
52199a2dd95SBruce Richardson */
52299a2dd95SBruce Richardson uint32_t e;
52399a2dd95SBruce Richardson /** The Ncb soft buffer size of the CB rate matched output [K:3*Kpi],
52499a2dd95SBruce Richardson * in bits, as specified in 3GPP TS 36.212.
52599a2dd95SBruce Richardson */
52699a2dd95SBruce Richardson uint16_t ncb;
52799a2dd95SBruce Richardson };
52899a2dd95SBruce Richardson
52999a2dd95SBruce Richardson /** Turbo encode transport block parameters */
53099a2dd95SBruce Richardson struct rte_bbdev_op_enc_turbo_tb_params {
53199a2dd95SBruce Richardson /** The K- size of the input CB, in bits [40:6144], that is in the
53299a2dd95SBruce Richardson * Turbo operation when r < C-, as in 3GPP TS 36.212.
53399a2dd95SBruce Richardson * This size is inclusive of CRC24B, regardless whether it was
53499a2dd95SBruce Richardson * pre-calculated and appended by the application or not.
53599a2dd95SBruce Richardson */
53699a2dd95SBruce Richardson uint16_t k_neg;
53799a2dd95SBruce Richardson /** The K+ size of the input CB, in bits [40:6144], that is in the
53899a2dd95SBruce Richardson * Turbo operation when r >= C-, as in 3GPP TS 36.212.
53999a2dd95SBruce Richardson * This size is inclusive of CRC24B, regardless whether it was
54099a2dd95SBruce Richardson * pre-calculated and appended by the application or not.
54199a2dd95SBruce Richardson */
54299a2dd95SBruce Richardson uint16_t k_pos;
54399a2dd95SBruce Richardson /** The number of CBs that have K- size, [0:63] */
54499a2dd95SBruce Richardson uint8_t c_neg;
54599a2dd95SBruce Richardson /** The total number of CBs in the TB,
54699a2dd95SBruce Richardson * [1:RTE_BBDEV_TURBO_MAX_CODE_BLOCKS]
54799a2dd95SBruce Richardson */
54899a2dd95SBruce Richardson uint8_t c;
54999a2dd95SBruce Richardson /** The number of CBs that uses Ea before switching to Eb, [0:63] */
55099a2dd95SBruce Richardson uint8_t cab;
55199a2dd95SBruce Richardson /** The E size of the CB rate matched output to use in the Turbo
55299a2dd95SBruce Richardson * operation when r < cab
55399a2dd95SBruce Richardson */
55499a2dd95SBruce Richardson uint32_t ea;
55599a2dd95SBruce Richardson /** The E size of the CB rate matched output to use in the Turbo
55699a2dd95SBruce Richardson * operation when r >= cab
55799a2dd95SBruce Richardson */
55899a2dd95SBruce Richardson uint32_t eb;
55999a2dd95SBruce Richardson /** The Ncb soft buffer size for the rate matched CB that is used in
56099a2dd95SBruce Richardson * the Turbo operation when r < C-, [K:3*Kpi]
56199a2dd95SBruce Richardson */
56299a2dd95SBruce Richardson uint16_t ncb_neg;
56399a2dd95SBruce Richardson /** The Ncb soft buffer size for the rate matched CB that is used in
56499a2dd95SBruce Richardson * the Turbo operation when r >= C-, [K:3*Kpi]
56599a2dd95SBruce Richardson */
56699a2dd95SBruce Richardson uint16_t ncb_pos;
56799a2dd95SBruce Richardson /** The index of the first CB in the inbound mbuf data, default is 0 */
56899a2dd95SBruce Richardson uint8_t r;
56999a2dd95SBruce Richardson };
57099a2dd95SBruce Richardson
57199a2dd95SBruce Richardson /** LDPC encode code block parameters */
57299a2dd95SBruce Richardson struct rte_bbdev_op_enc_ldpc_cb_params {
57399a2dd95SBruce Richardson /** E, length after rate matching in bits.
57499a2dd95SBruce Richardson * [3GPP TS38.212, section 5.4.2.1]
57599a2dd95SBruce Richardson */
57699a2dd95SBruce Richardson uint32_t e;
57799a2dd95SBruce Richardson };
57899a2dd95SBruce Richardson
57999a2dd95SBruce Richardson /** LDPC encode transport block parameters */
58099a2dd95SBruce Richardson struct rte_bbdev_op_enc_ldpc_tb_params {
58199a2dd95SBruce Richardson /** Ea, length after rate matching in bits, r < cab.
58299a2dd95SBruce Richardson * [3GPP TS38.212, section 5.4.2.1]
58399a2dd95SBruce Richardson */
58499a2dd95SBruce Richardson uint32_t ea;
58599a2dd95SBruce Richardson /** Eb, length after rate matching in bits, r >= cab.
58699a2dd95SBruce Richardson * [3GPP TS38.212, section 5.4.2.1]
58799a2dd95SBruce Richardson */
58899a2dd95SBruce Richardson uint32_t eb;
58999a2dd95SBruce Richardson /** The total number of CBs in the TB or partial TB
59099a2dd95SBruce Richardson * [1:RTE_BBDEV_LDPC_MAX_CODE_BLOCKS]
59199a2dd95SBruce Richardson */
59299a2dd95SBruce Richardson uint8_t c;
59399a2dd95SBruce Richardson /** The index of the first CB in the inbound mbuf data, default is 0 */
59499a2dd95SBruce Richardson uint8_t r;
59599a2dd95SBruce Richardson /** The number of CBs that use Ea before switching to Eb, [0:63] */
59699a2dd95SBruce Richardson uint8_t cab;
59799a2dd95SBruce Richardson };
59899a2dd95SBruce Richardson
59999a2dd95SBruce Richardson /** Operation structure for Turbo encode.
60099a2dd95SBruce Richardson * An operation can be performed on one CB at a time "CB-mode".
60199a2dd95SBruce Richardson * An operation can pbe erformd on one or multiple CBs that logically
60299a2dd95SBruce Richardson * belong to one TB "TB-mode".
60399a2dd95SBruce Richardson *
60499a2dd95SBruce Richardson * In CB-mode, CRC24A/B is an optional operation. K size parameter is not
60599a2dd95SBruce Richardson * affected by CRC24A/B inclusion, this only affects the inbound mbuf data
60699a2dd95SBruce Richardson * length. Not all BBDEV PMDs are capable of CRC24A/B calculation. Flags
60799a2dd95SBruce Richardson * RTE_BBDEV_TURBO_CRC_24A_ATTACH and RTE_BBDEV_TURBO_CRC_24B_ATTACH informs
60899a2dd95SBruce Richardson * the application with relevant capability. These flags can be set in the
60999a2dd95SBruce Richardson * op_flags parameter to indicate BBDEV to calculate and append CRC24A to CB
61099a2dd95SBruce Richardson * before going forward with Turbo encoding.
61199a2dd95SBruce Richardson *
61299a2dd95SBruce Richardson * In TB-mode, CRC24A is assumed to be pre-calculated and appended to the
61399a2dd95SBruce Richardson * inbound TB mbuf data buffer.
61499a2dd95SBruce Richardson *
61599a2dd95SBruce Richardson * The output mbuf data structure is expected to be allocated by the
61699a2dd95SBruce Richardson * application with enough room for the output data.
61799a2dd95SBruce Richardson */
61899a2dd95SBruce Richardson struct rte_bbdev_op_turbo_enc {
61999a2dd95SBruce Richardson /** The input CB or TB data */
62099a2dd95SBruce Richardson struct rte_bbdev_op_data input;
62199a2dd95SBruce Richardson /** The rate matched CB or TB output buffer */
62299a2dd95SBruce Richardson struct rte_bbdev_op_data output;
62399a2dd95SBruce Richardson /** Flags from rte_bbdev_op_te_flag_bitmasks */
62499a2dd95SBruce Richardson uint32_t op_flags;
62599a2dd95SBruce Richardson
62699a2dd95SBruce Richardson /** Rv index for rate matching [0:3] */
62799a2dd95SBruce Richardson uint8_t rv_index;
62899a2dd95SBruce Richardson /** [0 - TB : 1 - CB] */
62999a2dd95SBruce Richardson uint8_t code_block_mode;
63099a2dd95SBruce Richardson union {
63199a2dd95SBruce Richardson /** Struct which stores Code Block specific parameters */
63299a2dd95SBruce Richardson struct rte_bbdev_op_enc_turbo_cb_params cb_params;
63399a2dd95SBruce Richardson /** Struct which stores Transport Block specific parameters */
63499a2dd95SBruce Richardson struct rte_bbdev_op_enc_turbo_tb_params tb_params;
63599a2dd95SBruce Richardson };
63699a2dd95SBruce Richardson };
63799a2dd95SBruce Richardson
63899a2dd95SBruce Richardson /** Operation structure for LDPC encode.
63999a2dd95SBruce Richardson * An operation can be performed on one CB at a time "CB-mode".
64099a2dd95SBruce Richardson * An operation can be performed on one or multiple CBs that logically
64199a2dd95SBruce Richardson * belong to a TB "TB-mode".
64299a2dd95SBruce Richardson *
64399a2dd95SBruce Richardson * The input data is the CB or TB input to the decoder.
64499a2dd95SBruce Richardson *
64599a2dd95SBruce Richardson * The output data is the ratematched CB or TB data, or the output after
64699a2dd95SBruce Richardson * bit-selection if RTE_BBDEV_LDPC_INTERLEAVER_BYPASS is set.
64799a2dd95SBruce Richardson *
64899a2dd95SBruce Richardson * The output mbuf data structure is expected to be allocated by the
64999a2dd95SBruce Richardson * application with enough room for the output data.
65099a2dd95SBruce Richardson */
65199a2dd95SBruce Richardson struct rte_bbdev_op_ldpc_enc {
65299a2dd95SBruce Richardson /** The input TB or CB data */
65399a2dd95SBruce Richardson struct rte_bbdev_op_data input;
65499a2dd95SBruce Richardson /** The rate matched TB or CB output buffer */
65599a2dd95SBruce Richardson struct rte_bbdev_op_data output;
65699a2dd95SBruce Richardson
65799a2dd95SBruce Richardson /** Flags from rte_bbdev_op_ldpcenc_flag_bitmasks */
65899a2dd95SBruce Richardson uint32_t op_flags;
65999a2dd95SBruce Richardson
66099a2dd95SBruce Richardson /** Rate matching redundancy version */
66199a2dd95SBruce Richardson uint8_t rv_index;
66299a2dd95SBruce Richardson /** 1: LDPC Base graph 1, 2: LDPC Base graph 2.
66399a2dd95SBruce Richardson * [3GPP TS38.212, section 5.2.2]
66499a2dd95SBruce Richardson */
66599a2dd95SBruce Richardson uint8_t basegraph;
66699a2dd95SBruce Richardson /** Zc, LDPC lifting size.
66799a2dd95SBruce Richardson * [3GPP TS38.212, section 5.2.2]
66899a2dd95SBruce Richardson */
66999a2dd95SBruce Richardson uint16_t z_c;
67099a2dd95SBruce Richardson /** Ncb, length of the circular buffer in bits.
67199a2dd95SBruce Richardson * [3GPP TS38.212, section 5.4.2.1]
67299a2dd95SBruce Richardson */
67399a2dd95SBruce Richardson uint16_t n_cb;
67499a2dd95SBruce Richardson /** Qm, modulation order {2,4,6,8,10}.
67599a2dd95SBruce Richardson * [3GPP TS38.212, section 5.4.2.2]
67699a2dd95SBruce Richardson */
67799a2dd95SBruce Richardson uint8_t q_m;
67899a2dd95SBruce Richardson /** Number of Filler bits, n_filler = K – K’
67999a2dd95SBruce Richardson * [3GPP TS38.212 section 5.2.2]
68099a2dd95SBruce Richardson */
68199a2dd95SBruce Richardson uint16_t n_filler;
68299a2dd95SBruce Richardson /** [0 - TB : 1 - CB] */
68399a2dd95SBruce Richardson uint8_t code_block_mode;
68499a2dd95SBruce Richardson union {
68599a2dd95SBruce Richardson /** Struct which stores Code Block specific parameters */
68699a2dd95SBruce Richardson struct rte_bbdev_op_enc_ldpc_cb_params cb_params;
68799a2dd95SBruce Richardson /** Struct which stores Transport Block specific parameters */
68899a2dd95SBruce Richardson struct rte_bbdev_op_enc_ldpc_tb_params tb_params;
68999a2dd95SBruce Richardson };
69099a2dd95SBruce Richardson };
69199a2dd95SBruce Richardson
69299a2dd95SBruce Richardson /** List of the capabilities for the Turbo Decoder */
69399a2dd95SBruce Richardson struct rte_bbdev_op_cap_turbo_dec {
69499a2dd95SBruce Richardson /** Flags from rte_bbdev_op_td_flag_bitmasks */
69599a2dd95SBruce Richardson uint32_t capability_flags;
69699a2dd95SBruce Richardson /** Maximal LLR absolute value. Acceptable LLR values lie in range
69799a2dd95SBruce Richardson * [-max_llr_modulus, max_llr_modulus].
69899a2dd95SBruce Richardson */
69999a2dd95SBruce Richardson int8_t max_llr_modulus;
70099a2dd95SBruce Richardson /** Num input code block buffers */
70199a2dd95SBruce Richardson uint8_t num_buffers_src; /**< Num input code block buffers */
70299a2dd95SBruce Richardson /** Num hard output code block buffers */
70399a2dd95SBruce Richardson uint8_t num_buffers_hard_out;
70499a2dd95SBruce Richardson /** Num soft output code block buffers if supported by the driver */
70599a2dd95SBruce Richardson uint8_t num_buffers_soft_out;
70699a2dd95SBruce Richardson };
70799a2dd95SBruce Richardson
70899a2dd95SBruce Richardson /** List of the capabilities for the Turbo Encoder */
70999a2dd95SBruce Richardson struct rte_bbdev_op_cap_turbo_enc {
71099a2dd95SBruce Richardson /** Flags from rte_bbdev_op_te_flag_bitmasks */
71199a2dd95SBruce Richardson uint32_t capability_flags;
71299a2dd95SBruce Richardson /** Num input code block buffers */
71399a2dd95SBruce Richardson uint8_t num_buffers_src;
71499a2dd95SBruce Richardson /** Num output code block buffers */
71599a2dd95SBruce Richardson uint8_t num_buffers_dst;
71699a2dd95SBruce Richardson };
71799a2dd95SBruce Richardson
71899a2dd95SBruce Richardson /** List of the capabilities for the LDPC Decoder */
71999a2dd95SBruce Richardson struct rte_bbdev_op_cap_ldpc_dec {
72099a2dd95SBruce Richardson /** Flags from rte_bbdev_op_ldpcdec_flag_bitmasks */
72199a2dd95SBruce Richardson uint32_t capability_flags;
72299a2dd95SBruce Richardson /** LLR size in bits. LLR is a two’s complement number. */
72399a2dd95SBruce Richardson int8_t llr_size;
72499a2dd95SBruce Richardson /** LLR numbers of decimals bit for arithmetic representation */
72599a2dd95SBruce Richardson int8_t llr_decimals;
72699a2dd95SBruce Richardson /** Num input code block buffers */
72799a2dd95SBruce Richardson uint16_t num_buffers_src;
72899a2dd95SBruce Richardson /** Num hard output code block buffers */
72999a2dd95SBruce Richardson uint16_t num_buffers_hard_out;
73099a2dd95SBruce Richardson /** Num soft output code block buffers if supported by the driver */
73199a2dd95SBruce Richardson uint16_t num_buffers_soft_out;
73299a2dd95SBruce Richardson };
73399a2dd95SBruce Richardson
73499a2dd95SBruce Richardson /** List of the capabilities for the LDPC Encoder */
73599a2dd95SBruce Richardson struct rte_bbdev_op_cap_ldpc_enc {
73699a2dd95SBruce Richardson /** Flags from rte_bbdev_op_ldpcenc_flag_bitmasks */
73799a2dd95SBruce Richardson uint32_t capability_flags;
73899a2dd95SBruce Richardson /** Num input code block buffers */
73999a2dd95SBruce Richardson uint16_t num_buffers_src;
74099a2dd95SBruce Richardson /** Num output code block buffers */
74199a2dd95SBruce Richardson uint16_t num_buffers_dst;
74299a2dd95SBruce Richardson };
74399a2dd95SBruce Richardson
74499a2dd95SBruce Richardson /** Different operation types supported by the device */
74599a2dd95SBruce Richardson enum rte_bbdev_op_type {
74699a2dd95SBruce Richardson RTE_BBDEV_OP_NONE, /**< Dummy operation that does nothing */
74799a2dd95SBruce Richardson RTE_BBDEV_OP_TURBO_DEC, /**< Turbo decode */
74899a2dd95SBruce Richardson RTE_BBDEV_OP_TURBO_ENC, /**< Turbo encode */
74999a2dd95SBruce Richardson RTE_BBDEV_OP_LDPC_DEC, /**< LDPC decode */
75099a2dd95SBruce Richardson RTE_BBDEV_OP_LDPC_ENC, /**< LDPC encode */
75199a2dd95SBruce Richardson RTE_BBDEV_OP_TYPE_COUNT, /**< Count of different op types */
75299a2dd95SBruce Richardson };
75399a2dd95SBruce Richardson
75499a2dd95SBruce Richardson /** Bit indexes of possible errors reported through status field */
75599a2dd95SBruce Richardson enum {
75699a2dd95SBruce Richardson RTE_BBDEV_DRV_ERROR,
75799a2dd95SBruce Richardson RTE_BBDEV_DATA_ERROR,
75899a2dd95SBruce Richardson RTE_BBDEV_CRC_ERROR,
75999a2dd95SBruce Richardson RTE_BBDEV_SYNDROME_ERROR
76099a2dd95SBruce Richardson };
76199a2dd95SBruce Richardson
76299a2dd95SBruce Richardson /** Structure specifying a single encode operation */
76399a2dd95SBruce Richardson struct rte_bbdev_enc_op {
76499a2dd95SBruce Richardson /** Status of operation that was performed */
76599a2dd95SBruce Richardson int status;
76699a2dd95SBruce Richardson /** Mempool which op instance is in */
76799a2dd95SBruce Richardson struct rte_mempool *mempool;
76899a2dd95SBruce Richardson /** Opaque pointer for user data */
76999a2dd95SBruce Richardson void *opaque_data;
77099a2dd95SBruce Richardson union {
77199a2dd95SBruce Richardson /** Contains turbo decoder specific parameters */
77299a2dd95SBruce Richardson struct rte_bbdev_op_turbo_enc turbo_enc;
77399a2dd95SBruce Richardson /** Contains LDPC decoder specific parameters */
77499a2dd95SBruce Richardson struct rte_bbdev_op_ldpc_enc ldpc_enc;
77599a2dd95SBruce Richardson };
77699a2dd95SBruce Richardson };
77799a2dd95SBruce Richardson
77899a2dd95SBruce Richardson /** Structure specifying a single decode operation */
77999a2dd95SBruce Richardson struct rte_bbdev_dec_op {
78099a2dd95SBruce Richardson /** Status of operation that was performed */
78199a2dd95SBruce Richardson int status;
78299a2dd95SBruce Richardson /** Mempool which op instance is in */
78399a2dd95SBruce Richardson struct rte_mempool *mempool;
78499a2dd95SBruce Richardson /** Opaque pointer for user data */
78599a2dd95SBruce Richardson void *opaque_data;
78699a2dd95SBruce Richardson union {
78799a2dd95SBruce Richardson /** Contains turbo decoder specific parameters */
78899a2dd95SBruce Richardson struct rte_bbdev_op_turbo_dec turbo_dec;
78999a2dd95SBruce Richardson /** Contains LDPC decoder specific parameters */
79099a2dd95SBruce Richardson struct rte_bbdev_op_ldpc_dec ldpc_dec;
79199a2dd95SBruce Richardson };
79299a2dd95SBruce Richardson };
79399a2dd95SBruce Richardson
79499a2dd95SBruce Richardson /** Operation capabilities supported by a device */
79599a2dd95SBruce Richardson struct rte_bbdev_op_cap {
79699a2dd95SBruce Richardson enum rte_bbdev_op_type type; /**< Type of operation */
79799a2dd95SBruce Richardson union {
79899a2dd95SBruce Richardson struct rte_bbdev_op_cap_turbo_dec turbo_dec;
79999a2dd95SBruce Richardson struct rte_bbdev_op_cap_turbo_enc turbo_enc;
80099a2dd95SBruce Richardson struct rte_bbdev_op_cap_ldpc_dec ldpc_dec;
80199a2dd95SBruce Richardson struct rte_bbdev_op_cap_ldpc_enc ldpc_enc;
80299a2dd95SBruce Richardson } cap; /**< Operation-type specific capabilities */
80399a2dd95SBruce Richardson };
80499a2dd95SBruce Richardson
80599a2dd95SBruce Richardson /** @internal Private data structure stored with operation pool. */
80699a2dd95SBruce Richardson struct rte_bbdev_op_pool_private {
80799a2dd95SBruce Richardson enum rte_bbdev_op_type type; /**< Type of operations in a pool */
80899a2dd95SBruce Richardson };
80999a2dd95SBruce Richardson
81099a2dd95SBruce Richardson /**
81199a2dd95SBruce Richardson * Converts queue operation type from enum to string
81299a2dd95SBruce Richardson *
81399a2dd95SBruce Richardson * @param op_type
81499a2dd95SBruce Richardson * Operation type as enum
81599a2dd95SBruce Richardson *
81699a2dd95SBruce Richardson * @returns
81799a2dd95SBruce Richardson * Operation type as string or NULL if op_type is invalid
81899a2dd95SBruce Richardson *
81999a2dd95SBruce Richardson */
82099a2dd95SBruce Richardson const char*
82199a2dd95SBruce Richardson rte_bbdev_op_type_str(enum rte_bbdev_op_type op_type);
82299a2dd95SBruce Richardson
82399a2dd95SBruce Richardson /**
82499a2dd95SBruce Richardson * Creates a bbdev operation mempool
82599a2dd95SBruce Richardson *
82699a2dd95SBruce Richardson * @param name
82799a2dd95SBruce Richardson * Pool name.
82899a2dd95SBruce Richardson * @param type
82999a2dd95SBruce Richardson * Operation type, use RTE_BBDEV_OP_NONE for a pool which supports all
83099a2dd95SBruce Richardson * operation types.
83199a2dd95SBruce Richardson * @param num_elements
83299a2dd95SBruce Richardson * Number of elements in the pool.
83399a2dd95SBruce Richardson * @param cache_size
83499a2dd95SBruce Richardson * Number of elements to cache on an lcore, see rte_mempool_create() for
83599a2dd95SBruce Richardson * further details about cache size.
83699a2dd95SBruce Richardson * @param socket_id
83799a2dd95SBruce Richardson * Socket to allocate memory on.
83899a2dd95SBruce Richardson *
83999a2dd95SBruce Richardson * @return
84099a2dd95SBruce Richardson * - Pointer to a mempool on success,
84199a2dd95SBruce Richardson * - NULL pointer on failure.
84299a2dd95SBruce Richardson */
84399a2dd95SBruce Richardson struct rte_mempool *
84499a2dd95SBruce Richardson rte_bbdev_op_pool_create(const char *name, enum rte_bbdev_op_type type,
84599a2dd95SBruce Richardson unsigned int num_elements, unsigned int cache_size,
84699a2dd95SBruce Richardson int socket_id);
84799a2dd95SBruce Richardson
84899a2dd95SBruce Richardson /**
84999a2dd95SBruce Richardson * Bulk allocate encode operations from a mempool with parameter defaults reset.
85099a2dd95SBruce Richardson *
85199a2dd95SBruce Richardson * @param mempool
85299a2dd95SBruce Richardson * Operation mempool, created by rte_bbdev_op_pool_create().
85399a2dd95SBruce Richardson * @param ops
85499a2dd95SBruce Richardson * Output array to place allocated operations
85599a2dd95SBruce Richardson * @param num_ops
85699a2dd95SBruce Richardson * Number of operations to allocate
85799a2dd95SBruce Richardson *
85899a2dd95SBruce Richardson * @returns
85999a2dd95SBruce Richardson * - 0 on success
86099a2dd95SBruce Richardson * - EINVAL if invalid mempool is provided
86199a2dd95SBruce Richardson */
86299a2dd95SBruce Richardson static inline int
rte_bbdev_enc_op_alloc_bulk(struct rte_mempool * mempool,struct rte_bbdev_enc_op ** ops,uint16_t num_ops)86399a2dd95SBruce Richardson rte_bbdev_enc_op_alloc_bulk(struct rte_mempool *mempool,
86499a2dd95SBruce Richardson struct rte_bbdev_enc_op **ops, uint16_t num_ops)
86599a2dd95SBruce Richardson {
86699a2dd95SBruce Richardson struct rte_bbdev_op_pool_private *priv;
86799a2dd95SBruce Richardson int ret;
86899a2dd95SBruce Richardson
86999a2dd95SBruce Richardson /* Check type */
87099a2dd95SBruce Richardson priv = (struct rte_bbdev_op_pool_private *)
87199a2dd95SBruce Richardson rte_mempool_get_priv(mempool);
87299a2dd95SBruce Richardson if (unlikely((priv->type != RTE_BBDEV_OP_TURBO_ENC) &&
87399a2dd95SBruce Richardson (priv->type != RTE_BBDEV_OP_LDPC_ENC)))
87499a2dd95SBruce Richardson return -EINVAL;
87599a2dd95SBruce Richardson
87699a2dd95SBruce Richardson /* Get elements */
87799a2dd95SBruce Richardson ret = rte_mempool_get_bulk(mempool, (void **)ops, num_ops);
87899a2dd95SBruce Richardson if (unlikely(ret < 0))
87999a2dd95SBruce Richardson return ret;
88099a2dd95SBruce Richardson
88199a2dd95SBruce Richardson return 0;
88299a2dd95SBruce Richardson }
88399a2dd95SBruce Richardson
88499a2dd95SBruce Richardson /**
88599a2dd95SBruce Richardson * Bulk allocate decode operations from a mempool with parameter defaults reset.
88699a2dd95SBruce Richardson *
88799a2dd95SBruce Richardson * @param mempool
88899a2dd95SBruce Richardson * Operation mempool, created by rte_bbdev_op_pool_create().
88999a2dd95SBruce Richardson * @param ops
89099a2dd95SBruce Richardson * Output array to place allocated operations
89199a2dd95SBruce Richardson * @param num_ops
89299a2dd95SBruce Richardson * Number of operations to allocate
89399a2dd95SBruce Richardson *
89499a2dd95SBruce Richardson * @returns
89599a2dd95SBruce Richardson * - 0 on success
89699a2dd95SBruce Richardson * - EINVAL if invalid mempool is provided
89799a2dd95SBruce Richardson */
89899a2dd95SBruce Richardson static inline int
rte_bbdev_dec_op_alloc_bulk(struct rte_mempool * mempool,struct rte_bbdev_dec_op ** ops,uint16_t num_ops)89999a2dd95SBruce Richardson rte_bbdev_dec_op_alloc_bulk(struct rte_mempool *mempool,
90099a2dd95SBruce Richardson struct rte_bbdev_dec_op **ops, uint16_t num_ops)
90199a2dd95SBruce Richardson {
90299a2dd95SBruce Richardson struct rte_bbdev_op_pool_private *priv;
90399a2dd95SBruce Richardson int ret;
90499a2dd95SBruce Richardson
90599a2dd95SBruce Richardson /* Check type */
90699a2dd95SBruce Richardson priv = (struct rte_bbdev_op_pool_private *)
90799a2dd95SBruce Richardson rte_mempool_get_priv(mempool);
90899a2dd95SBruce Richardson if (unlikely((priv->type != RTE_BBDEV_OP_TURBO_DEC) &&
90999a2dd95SBruce Richardson (priv->type != RTE_BBDEV_OP_LDPC_DEC)))
91099a2dd95SBruce Richardson return -EINVAL;
91199a2dd95SBruce Richardson
91299a2dd95SBruce Richardson /* Get elements */
91399a2dd95SBruce Richardson ret = rte_mempool_get_bulk(mempool, (void **)ops, num_ops);
91499a2dd95SBruce Richardson if (unlikely(ret < 0))
91599a2dd95SBruce Richardson return ret;
91699a2dd95SBruce Richardson
91799a2dd95SBruce Richardson return 0;
91899a2dd95SBruce Richardson }
91999a2dd95SBruce Richardson
92099a2dd95SBruce Richardson /**
92199a2dd95SBruce Richardson * Free decode operation structures that were allocated by
92299a2dd95SBruce Richardson * rte_bbdev_dec_op_alloc_bulk().
92399a2dd95SBruce Richardson * All structures must belong to the same mempool.
92499a2dd95SBruce Richardson *
92599a2dd95SBruce Richardson * @param ops
92699a2dd95SBruce Richardson * Operation structures
92799a2dd95SBruce Richardson * @param num_ops
92899a2dd95SBruce Richardson * Number of structures
92999a2dd95SBruce Richardson */
93099a2dd95SBruce Richardson static inline void
rte_bbdev_dec_op_free_bulk(struct rte_bbdev_dec_op ** ops,unsigned int num_ops)93199a2dd95SBruce Richardson rte_bbdev_dec_op_free_bulk(struct rte_bbdev_dec_op **ops, unsigned int num_ops)
93299a2dd95SBruce Richardson {
93399a2dd95SBruce Richardson if (num_ops > 0)
93499a2dd95SBruce Richardson rte_mempool_put_bulk(ops[0]->mempool, (void **)ops, num_ops);
93599a2dd95SBruce Richardson }
93699a2dd95SBruce Richardson
93799a2dd95SBruce Richardson /**
93899a2dd95SBruce Richardson * Free encode operation structures that were allocated by
93999a2dd95SBruce Richardson * rte_bbdev_enc_op_alloc_bulk().
94099a2dd95SBruce Richardson * All structures must belong to the same mempool.
94199a2dd95SBruce Richardson *
94299a2dd95SBruce Richardson * @param ops
94399a2dd95SBruce Richardson * Operation structures
94499a2dd95SBruce Richardson * @param num_ops
94599a2dd95SBruce Richardson * Number of structures
94699a2dd95SBruce Richardson */
94799a2dd95SBruce Richardson static inline void
rte_bbdev_enc_op_free_bulk(struct rte_bbdev_enc_op ** ops,unsigned int num_ops)94899a2dd95SBruce Richardson rte_bbdev_enc_op_free_bulk(struct rte_bbdev_enc_op **ops, unsigned int num_ops)
94999a2dd95SBruce Richardson {
95099a2dd95SBruce Richardson if (num_ops > 0)
95199a2dd95SBruce Richardson rte_mempool_put_bulk(ops[0]->mempool, (void **)ops, num_ops);
95299a2dd95SBruce Richardson }
95399a2dd95SBruce Richardson
95499a2dd95SBruce Richardson #ifdef __cplusplus
95599a2dd95SBruce Richardson }
95699a2dd95SBruce Richardson #endif
95799a2dd95SBruce Richardson
95899a2dd95SBruce Richardson #endif /* _RTE_BBDEV_OP_H_ */
959