From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 7FBFB548B for ; Tue, 14 May 2019 21:46:19 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 May 2019 12:46:18 -0700 X-ExtLoop1: 1 Received: from skx-5gnr-sd5.sc.intel.com ([172.25.69.194]) by orsmga003.jf.intel.com with ESMTP; 14 May 2019 12:46:18 -0700 From: Nicolas Chautru To: Cc: dev@dpdk.org, Nicolas Chautru Date: Tue, 14 May 2019 12:45:40 -0700 Message-Id: <1557863143-174842-3-git-send-email-nicolas.chautru@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1557863143-174842-1-git-send-email-nicolas.chautru@intel.com> References: <1557533163-172544-1-git-send-email-nicolas.chautru@intel.com> <1557863143-174842-1-git-send-email-nicolas.chautru@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 2/5] bbdev: extension of BBDEV for 5G FEC X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 May 2019 19:46:20 -0000 Supporting API for FEC operation with LDPC Signed-off-by: Nicolas Chautru --- doc/guides/prog_guide/bbdev.rst | 509 ++++++++++++++++++-- drivers/baseband/fpga_lte_fec/fpga_lte_fec.c | 24 +- drivers/baseband/turbo_sw/bbdev_turbo_software.c | 36 +- lib/librte_bbdev/rte_bbdev.c | 22 +- lib/librte_bbdev/rte_bbdev.h | 137 +++++- lib/librte_bbdev/rte_bbdev_op.h | 577 ++++++++++++++++++----- 6 files changed, 1091 insertions(+), 214 deletions(-) diff --git a/doc/guides/prog_guide/bbdev.rst b/doc/guides/prog_guide/bbdev.rst index 658ffd4..9a47a9b 100644 --- a/doc/guides/prog_guide/bbdev.rst +++ b/doc/guides/prog_guide/bbdev.rst @@ -78,7 +78,7 @@ From the application point of view, each instance of a bbdev device consists of one or more queues identified by queue IDs. While different devices may have different capabilities (e.g. support different operation types), all queues on a device support identical configuration possibilities. A queue is configured -for only one type of operation and is configured at initialization time. +for only one type of operation and is configured at initializations time. When an operation is enqueued to a specific queue ID, the result is dequeued from the same queue ID. @@ -91,8 +91,7 @@ and queue configuration is applied with ``rte_bbdev_queue_configure(dev_id,queue_id,conf)``. Note that, although all queues on a device support same capabilities, they can be configured differently and will then behave differently. -Devices supporting interrupts can enable them by using -``rte_bbdev_intr_enable(dev_id)``. +Devices supporting interrupts can enable them by using ``rte_bbdev_intr_enable(dev_id)``. The configuration of each bbdev device includes the following operations: @@ -150,8 +149,6 @@ device. Once closed, it cannot be restarted. int rte_bbdev_start(uint16_t dev_id) int rte_bbdev_stop(uint16_t dev_id) int rte_bbdev_close(uint16_t dev_id) - int rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id) - int rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id) By default, all queues are started when the device is started, but they can be @@ -166,9 +163,9 @@ stopped individually. Logical Cores, Memory and Queues Relationships ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The bbdev device Library as the Poll Mode Driver library support NUMA for when -a processor's logical cores and interfaces utilize its local memory. Therefore -baseband operations, the mbuf being operated on should be allocated from memory +The bbdev poll mode device driver library supports NUMA architecture, in which +a processor's logical cores and interfaces utilize it's local memory. Therefore +with baseband operations, the mbuf being operated on should be allocated from memory pools created in the local memory. The buffers should, if possible, remain on the local processor to obtain the best performance results and buffer descriptors should be populated with mbufs allocated from a mempool allocated @@ -220,9 +217,9 @@ relation to Turbo Encoding and Decoding operations. RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP | RTE_BBDEV_TURBO_EARLY_TERMINATION, .max_llr_modulus = 16, - .num_buffers_src = RTE_BBDEV_MAX_CODE_BLOCKS, + .num_buffers_src = RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, .num_buffers_hard_out = - RTE_BBDEV_MAX_CODE_BLOCKS, + RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, .num_buffers_soft_out = 0, } }, @@ -234,8 +231,8 @@ relation to Turbo Encoding and Decoding operations. RTE_BBDEV_TURBO_CRC_24A_ATTACH | RTE_BBDEV_TURBO_RATE_MATCH | RTE_BBDEV_TURBO_RV_INDEX_BYPASS, - .num_buffers_src = RTE_BBDEV_MAX_CODE_BLOCKS, - .num_buffers_dst = RTE_BBDEV_MAX_CODE_BLOCKS, + .num_buffers_src = RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, + .num_buffers_dst = RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, } }, RTE_BBDEV_END_OF_CAPABILITIES_LIST() @@ -266,12 +263,13 @@ information: struct rte_bbdev_info { int socket_id; const char *dev_name; - const struct rte_bus *bus; + const struct rte_device *device; uint16_t num_queues; bool started; struct rte_bbdev_driver_info drv; }; + Operation Processing -------------------- @@ -335,14 +333,20 @@ processed on a particular bbdev device poll mode driver. int status; struct rte_mempool *mempool; void *opaque_data; - struct rte_bbdev_op_turbo_enc turbo_enc; + union { + struct rte_bbdev_op_turbo_enc turbo_enc; + struct rte_bbdev_op_ldpc_enc ldpc_enc; + } }; struct rte_bbdev_dec_op { int status; struct rte_mempool *mempool; void *opaque_data; - struct rte_bbdev_op_turbo_dec turbo_dec; + union { + struct rte_bbdev_op_turbo_dec turbo_enc; + struct rte_bbdev_op_ldpc_dec ldpc_enc; + } }; The operation structure by itself defines the operation type. It includes an @@ -399,19 +403,31 @@ BBDEV Inbound/Outbound Memory ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The bbdev operation structure contains all the mutable data relating to -performing Turbo coding on a referenced mbuf data buffer. It is used for either +performing Turbo and LDPC coding on a referenced mbuf data buffer. It is used for either encode or decode operations. -Turbo Encode operation accepts one input and one output. -Turbo Decode operation accepts one input and two outputs, called *hard-decision* -and *soft-decision* outputs. *Soft-decision* output is optional. + +.. csv-table:: Operation I/O + :header: "FEC", "In", "Out" + :widths: 20, 30, 30 + + "Turbo Encode", "input", "output" + "Turbo Decode", "input", "hard output" + " ", " ", "soft output (optional)" + "LDPC Encode", "input", "output" + "LDPC Decode", "input", "hard output" + "", "HQ combine (optional)", "HQ combine (optional)" + " ", "", "soft output (optional)" + It is expected that the application provides input and output mbuf pointers -allocated and ready to use. The baseband framework supports turbo coding on -Code Blocks (CB) and Transport Blocks (TB). +allocated and ready to use. + +The baseband framework supports FEC coding on Code Blocks (CB) and +Transport Blocks (TB). For the output buffer(s), the application is required to provide an allocated -and free mbuf, so that bbdev write back the resulting output. +and free mbuf, to which the resulting output will be written. The support of split "scattered" buffers is a driver-specific feature, so it is reported individually by the supporting driver as a capability. @@ -436,26 +452,26 @@ This structure has three elements: This mbuf pointer can point to one Code Block (CB) data buffer or multiple CBs contiguously located next to each other. A Transport Block (TB) represents a whole piece of data that is divided into one or more CBs. Maximum number of - CBs can be contained in one TB is defined by ``RTE_BBDEV_MAX_CODE_BLOCKS``. + CBs can be contained in one TB is defined by + ``RTE_BBDEV_(TURBO/LDPC)MAX_CODE_BLOCKS``. An mbuf data structure cannot represent more than one TB. The smallest piece of data that can be contained in one mbuf is one CB. An mbuf can include one contiguous CB, subset of contiguous CBs that are - belonging to one TB, or all contiguous CBs that are belonging to one TB. + belonging to one TB, or all contiguous CBs that belong to one TB. If a BBDEV PMD supports the extended capability "Scatter-Gather", then it is capable of collecting (gathering) non-contiguous (scattered) data from multiple locations in the memory. This capability is reported by the capability flags: - - ``RTE_BBDEV_TURBO_ENC_SCATTER_GATHER``, and + - ``RTE_BBDEV_TURBO_ENC_SCATTER_GATHER``, ``RTE_BBDEV_TURBO_DEC_SCATTER_GATHER``, - - ``RTE_BBDEV_TURBO_DEC_SCATTER_GATHER``. + - ``RTE_BBDEV_LDPC_ENC_SCATTER_GATHER``, ``RTE_BBDEV_LDPC_DEC_SCATTER_GATHER``. - Only if a BBDEV PMD supports this feature, chained mbuf data structures are - accepted. A chained mbuf can represent one non-contiguous CB or multiple - non-contiguous CBs. - The first mbuf segment in the given chained mbuf represents the first piece + Chained mbuf data structures are only accepted if a BBDEV PMD supports this + feature. A chained mbuf can represent one non-contiguous CB or multiple non-contiguous + CBs. The first mbuf segment in the given chained mbuf represents the first piece of the CB. Offset is only applicable to the first segment. ``length`` is the total length of the CB. @@ -506,14 +522,22 @@ BBDEV Turbo Encode Operation }; }; -The Turbo encode structure is composed of the ``input`` and ``output`` mbuf -data pointers. The provided mbuf pointer of ``input`` needs to be big enough to -stretch for extra CRC trailers. +The Turbo encode structure includes the ``input`` and ``output`` mbuf +data pointers. The provided mbuf pointer of ``input`` needs to be big +enough to stretch for extra CRC trailers. + +.. csv-table:: **struct rte_bbdev_op_turbo_enc** parameters + :header: "Parameter", "Description" + :widths: 10, 30 -``op_flags`` parameter holds all operation related flags, like whether CRC24A is -included by the application or not. + "input","input CB or TB data" + "output","rate matched CB or TB output buffer" + "op_flags","bitmask of all active operation capabilities" + "rv_index","redundancy version index [0..3]" + "code_block_mode","code block or transport block mode" + "cb_params", "code block specific parameters (code block mode only)" + "tb_params", "transport block specific parameters (transport block mode only)" -``code_block_mode`` flag identifies the mode in which bbdev is operating in. The encode interface works on both the code block (CB) and the transport block (TB). An operation executes in "CB-mode" when the CB is standalone. While @@ -525,21 +549,21 @@ are being enqueued. **NOTE:** It is assumed that all enqueued ops in one ``rte_bbdev_enqueue_enc_ops()`` call belong to one mode, either CB-mode or TB-mode. -In case that the CB is smaller than Z (6144 bits), then effectively the TB = CB. +In case that the TB is smaller than Z (6144 bits), then effectively the TB = CB. CRC24A is appended to the tail of the CB. The application is responsible for calculating and appending CRC24A before calling BBDEV in case that the underlying driver does not support CRC24A generation. In CB-mode, CRC24A/B is an optional operation. -The input ``k`` is the size of the CB (this maps to K as described in 3GPP TS -36.212 section 5.1.2), this size is inclusive of CRC24A/B. +The CB parameter ``k`` is the size of the CB (this maps to K as described +in 3GPP TS 36.212 section 5.1.2), this size is inclusive of CRC24A/B. The ``length`` is inclusive of CRC24A/B and equals to ``k`` in this case. Not all BBDEV PMDs are capable of CRC24A/B calculation. Flags ``RTE_BBDEV_TURBO_CRC_24A_ATTACH`` and ``RTE_BBDEV_TURBO_CRC_24B_ATTACH`` informs the application with relevant capability. These flags can be set in the -``op_flags`` parameter to indicate BBDEV to calculate and append CRC24A to CB -before going forward with Turbo encoding. +``op_flags`` parameter to indicate to BBDEV to calculate and append CRC24A/B +to CB before going forward with Turbo encoding. Output format of the CB encode will have the encoded CB in ``e`` size output (this maps to E described in 3GPP TS 36.212 section 5.1.4.1.2). The output mbuf @@ -600,13 +624,26 @@ BBDEV Turbo Decode Operation }; }; -The Turbo decode structure is composed of the ``input`` and ``output`` mbuf -data pointers. - -``op_flags`` parameter holds all operation related flags, like whether CRC24B is -retained or not. - -``code_block_mode`` flag identifies the mode in which bbdev is operating in. +The Turbo decode structure includes the ``input``, ``hard_output`` and +optionally the ``soft_output`` mbuf data pointers. + +.. csv-table:: **struct rte_bbdev_op_turbo_dec** parameters + :header: "Parameter", "Description" + :widths: 10, 30 + + "input","virtual circular buffer, wk, size 3*Kpi for each CB" + "hard output","hard decisions buffer, decoded output, size K for each CB" + "soft output","soft LLR output buffer (optional)" + "op_flags","bitmask of all active operation capabilities" + "rv_index","redundancy version index [0..3]" + "iter_max","maximum number of iterations to perofrm in decode all CBs" + "iter_min","minimum number of iterations to perform in decoding all CBs" + "iter_count","number of iterations to performed in decoding all CBs" + "ext_scale","scale factor on extrinsic info (5 bits)" + "num_maps","number of MAP engines to use in decode" + "code_block_mode","code block or transport block mode" + "cb_params", "code block specific parameters (code block mode only)" + "tb_params", "transport block specific parameters (transport block mode only)" Similarly, the decode interface works on both the code block (CB) and the transport block (TB). An operation executes in "CB-mode" when the CB is @@ -618,7 +655,8 @@ to a bigger TB are being enqueued. **NOTE:** It is assumed that all enqueued ops in one ``rte_bbdev_enqueue_dec_ops()`` call belong to one mode, either CB-mode or TB-mode. -The input ``k`` is the size of the decoded CB (this maps to K as described in + +The CB parameter ``k`` is the size of the decoded CB (this maps to K as described in 3GPP TS 36.212 section 5.1.2), this size is inclusive of CRC24A/B. The ``length`` is inclusive of CRC24A/B and equals to ``k`` in this case. @@ -638,9 +676,9 @@ Soft output is an optional capability for BBDEV PMDs. Setting flag CRC24B at the end of each CB. This might be useful for the application in debug mode. An LLR rate matched output is computed in the ``soft_output`` buffer structure -for the given ``e`` size (this maps to E described in 3GPP TS 36.212 section -5.1.4.1.2). The output mbuf buffer size needs to be big enough to hold the -encoded buffer of size ``e``. +for the given CB parameter ``e`` size (this maps to E described in +3GPP TS 36.212 section 5.1.4.1.2). The output mbuf buffer size needs to be big +enough to hold the encoded buffer of size ``e``. The first CB Virtual Circular Buffer (VCB) index is given by ``r`` but the number of the remaining CB VCBs is calculated automatically by BBDEV before @@ -669,6 +707,373 @@ TB-mode. CB-mode is a reduced version, where only one CB exists: Turbo decoding of Code Blocks in mbuf structure +BBDEV LDPC Encode Operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The operation flags that can be set for each LDPC encode operation are +given below. + + **NOTE:** The actual operation flags that may be used with a specific + BBDEV PMD are dependent on the driver capabilities as reported via + ``rte_bbdev_info_get()``, and may be a subset of those below. + ++--------------------------------------------------------------------+ +|Description of LDPC encode capability flags | ++====================================================================+ +|RTE_BBDEV_LDPC_INTERLEAVER_BYPASS | +| Set to bypass bit-level interleaver on output stream | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_RATE_MATCH | +| Set to enabling the RATE_MATCHING processing | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_CRC_24A_ATTACH | +| Set to attach transport block CRC-24A | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_CRC_24B_ATTACH | +| Set to attach code block CRC-24B | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_CRC_16_ATTACH | +| Set to attach code block CRC-16 | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_ENC_INTERRUPTS | +| Set if a device supports encoder dequeue interrupts | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_ENC_SCATTER_GATHER | +| Set if a device supports scatter-gather functionality | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_ENC_CONCATENATION | +| Set if a device supports concatenation of non byte aligned output | ++--------------------------------------------------------------------+ + +The structure passed for each LDPC encode operation is given below, +with the operation flags forming a bitmask in the ``op_flags`` field. + +.. code-block:: c + + struct rte_bbdev_op_ldpc_enc { + + struct rte_bbdev_op_data input; + struct rte_bbdev_op_data output; + + uint32_t op_flags; + uint8_t rv_index; + uint8_t basegraph; + uint16_t z_c; + uint16_t n_cb; + uint8_t q_m; + uint16_t n_filler; + uint8_t code_block_mode; + union { + struct rte_bbdev_op_enc_ldpc_cb_params cb_params; + struct rte_bbdev_op_enc_ldpc_tb_params tb_params; + }; + }; + +The LDPC encode parameters are set out in the table below. + ++----------------+--------------------------------------------------------------------+ +|Parameter |Description | ++================+====================================================================+ +|input |input CB or TB data | ++----------------+--------------------------------------------------------------------+ +|output |rate matched CB or TB output buffer | ++----------------+--------------------------------------------------------------------+ +|op_flags |bitmask of all active operation capabilities | ++----------------+--------------------------------------------------------------------+ +|rv_index |redundancy version index [0..3] | ++----------------+--------------------------------------------------------------------+ +|basegraph |Basegraph 1 or 2 | ++----------------+--------------------------------------------------------------------+ +|z_c |Zc, LDPC lifting size | ++----------------+--------------------------------------------------------------------+ +|n_cb |Ncb, length of the circular buffer in bits. | ++----------------+--------------------------------------------------------------------+ +|q_m |Qm, modulation order {2,4,6,8,10} | ++----------------+--------------------------------------------------------------------+ +|n_filler |number of filler bits | ++----------------+--------------------------------------------------------------------+ +|code_block_mode |code block or transport block mode | ++----------------+--------------------------------------------------------------------+ +|op_flags |bitmask of all active operation capabilities | ++----------------+--------------------------------------------------------------------+ +|**cb_params** |code block specific parameters (transport block mode only) | ++----------------+------------+-------------------------------------------------------+ +| |e |E, length of the rate matched output sequence in bits | ++----------------+------------+-------------------------------------------------------+ +|**tb_params** | transport block specific parameters (code block mode only) | ++----------------+------------+-------------------------------------------------------+ +| |c |number of CBs in the TB or partial TB | ++----------------+------------+-------------------------------------------------------+ +| |r |index of the first CB in the inbound mbuf data | ++----------------+------------+-------------------------------------------------------+ ++ +c_ab +number of CBs that use Ea before switching to Eb | ++----------------+------------+-------------------------------------------------------+ +| |ea |Ea, length of the RM output sequence in bits, r < cab | ++----------------+------------+-------------------------------------------------------+ +| |eb |Eb, length of the RM output sequence in bits, r >= cab | ++----------------+------------+-------------------------------------------------------+ + +The mbuf input ``input`` is mandatory for all BBDEV PMDs and is the +incoming code block or transport block data. + +The mbuf output ``output`` is mandatory and is the encoded CB(s). In +CB-mode ut contains the encoded CB of size ``e`` (E in 3GPP TS 38.212 +section 6.2.5). In TB-mode it contains multiple contiguous encoded CBs +of size ``ea`` or ``eb``. +The ``output`` buffer is allocated by the application with enough room +for the output data. + +The encode interface works on both a code block (CB) and a transport +block (TB) basis. + + **NOTE:** All enqueued ops in one ``rte_bbdev_enqueue_enc_ops()`` + call belong to one mode, either CB-mode or TB-mode. + +The valid modes of operation are: + +* CB-mode: one CB (attach CRC24B if required) +* CB-mode: one CB making up one TB (attach CRC24A if required) +* TB-mode: one or more CB of a partial TB (attach CRC24B(s) if required) +* TB-mode: one or more CB of a complete TB (attach CRC24AB(s) if required) + +In CB-mode if ``RTE_BBDEV_LDPC_CRC_24A_ATTACH`` is set then CRC24A +is appended to the CB. If ``RTE_BBDEV_LDPC_CRC_24A_ATTACH`` is not +set the application is responsible for calculating and appending CRC24A +before calling BBDEV. The input data mbuf ``length`` is inclusive of +CRC24A/B where present and is equal to the code block size ``K``. + +In TB-mode, CRC24A is assumed to be pre-calculated and appended to the +inbound TB data buffer, unless the ``RTE_BBDEV_LDPC_CRC_24A_ATTACH`` +flag is set when it is the responsibility of BBDEV. The input data +mbuf ``length`` is total size of the CBs inclusive of any CRC24A and +CRC24B in the case they were appended by the application. + +Not all BBDEV PMDs may be capable of CRC24A/B calculation. Flags +``RTE_BBDEV_LDPC_CRC_24A_ATTACH`` and ``RTE_BBDEV_LDPC_CRC_24B_ATTACH`` +inform the application of the relevant capability. These flags can be set +in the ``op_flags`` parameter to indicate BBDEV to calculate and append +CRC24A to CB before going forward with LDPC encoding. + +The difference between the partial and full-size TB is that BBDEV needs +the index of the first CB in this group and the number of CBs in the group. +The first CB index is given by ``r`` but the number of the CBs is +calculated by BBDEV before signalling to the driver. + +The number of CBs in the group should not be confused with ``c``, the +total number of CBs in the full TB (``C`` as per 3GPP TS 38.212 section 5.2.2) + +Figure 13.1 above showing the Turbo encoding of CBs using BBDEV +interface in TB-mode is also valid for LDPC encode. + +BBDEV LDPC Decode Operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The operation flags that can be set for each LDPC decode operation are +given below. + + **NOTE:** The actual operation flags that may be used with a specific + BBDEV PMD are dependent on the driver capabilities as reported via + ``rte_bbdev_info_get()``, and may be a subset of those below. + ++--------------------------------------------------------------------+ +|Description of LDPC decode capability flags | ++====================================================================+ +|RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK | +| Set for transport block CRC-24A checking | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_CRC_TYPE_24B_CHECK | +| Set for code block CRC-24B checking | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP | +| Set to drop the last CRC bits decoding output | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_DEINTERLEAVER_BYPASS | +| Set for bit-level de-interleaver bypass on input stream | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE | +| Set for HARQ combined input stream enable | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE | +| Set for HARQ combined output stream enable | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_DECODE_BYPASS | +| Set for LDPC decoder bypass | +| | +| RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE must be set | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_DECODE_SOFT_OUT | +| Set for soft-output stream enable | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_SOFT_OUT_RM_BYPASS | +| Set for Rate-Matching bypass on soft-out stream | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_SOFT_OUT_DEINTERLEAVER_BYPASS | +| Set for bit-level de-interleaver bypass on soft-output stream | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE | +| Set for iteration stopping on successful decode condition enable | +| | +| Where a successful decode is a successful syndrome check | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_DEC_INTERRUPTS | +| Set if a device supports decoder dequeue interrupts | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_DEC_SCATTER_GATHER | +| Set if a device supports scatter-gather functionality | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION | +| Set if a device supports input/output HARQ compression | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_LLR_COMPRESSION | +| Set if a device supports input LLR compression | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE | +| Set if a device supports HARQ input to device's internal memory | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE | +| Set if a device supports HARQ output to device's internal memory | ++--------------------------------------------------------------------+ + +The structure passed for each LDPC decode operation is given below, +with the operation flags forming a bitmask in the ``op_flags`` field. + +.. code-block:: c + + + struct rte_bbdev_op_ldpc_dec { + + struct rte_bbdev_op_data input; + struct rte_bbdev_op_data hard_output; + struct rte_bbdev_op_data soft_output; + struct rte_bbdev_op_data harq_combined_input; + struct rte_bbdev_op_data harq_combined_output; + + uint32_t op_flags; + uint8_t rv_index; + uint8_t basegraph; + uint16_t z_c; + uint16_t n_cb; + uint8_t q_m; + uint16_t n_filler; + uint8_t iter_max; + uint8_t iter_count; + uint8_t code_block_mode; + union { + struct rte_bbdev_op_dec_ldpc_cb_params cb_params; + struct rte_bbdev_op_dec_ldpc_tb_params tb_params; + }; + }; + + +The LDPC decode parameters are set out in the table below. + ++----------------+--------------------------------------------------------------------+ +|Parameter |Description | ++================+====================================================================+ +|input |input CB or TB data | ++----------------+--------------------------------------------------------------------+ +|hard_output |hard decisions buffer, decoded output | ++----------------+--------------------------------------------------------------------+ +|soft_output |soft LLR output buffer (optional) | ++----------------+--------------------------------------------------------------------+ +|harq_comb_input |HARQ combined input buffer (optional) | ++----------------+--------------------------------------------------------------------+ +|harq_comb_output|HARQ combined output buffer (optional) | ++----------------+--------------------------------------------------------------------+ +|op_flags |bitmask of all active operation capabilities | ++----------------+--------------------------------------------------------------------+ +|rv_index |redundancy version index [0..3] | ++----------------+--------------------------------------------------------------------+ +|basegraph |Basegraph 1 or 2 | ++----------------+--------------------------------------------------------------------+ +|z_c |Zc, LDPC lifting size | ++----------------+--------------------------------------------------------------------+ +|n_cb |Ncb, length of the circular buffer in bits. | ++----------------+--------------------------------------------------------------------+ +|q_m |Qm, modulation order {2,4,6,8,10} | ++----------------+--------------------------------------------------------------------+ +|n_filler |number of filler bits | ++----------------+--------------------------------------------------------------------+ +|iter_max |maximum number of iterations to perform in decode all CBs | ++----------------+--------------------------------------------------------------------+ +|iter_count |number of iterations performed in decoding all CBs | ++----------------+--------------------------------------------------------------------+ +|code_block_mode |code block or transport block mode | ++----------------+--------------------------------------------------------------------+ +|op_flags |bitmask of all active operation capabilities | ++----------------+--------------------------------------------------------------------+ +|**cb_params** |code block specific parameters (code block mode only) | ++----------------+------------+-------------------------------------------------------+ +| |e |E, length of the rate matched output sequence in bits | ++----------------+------------+-------------------------------------------------------+ +|**tb_params** | transport block specific parameters (transport block mode only) | ++----------------+------------+-------------------------------------------------------+ +| |c |number of CBs in the TB or partial TB | ++----------------+------------+-------------------------------------------------------+ +| |r |index of the first CB in the inbound mbuf data | ++----------------+------------+-------------------------------------------------------+ +| |c_ab |number of CBs that use Ea before switching to Eb | ++----------------+------------+-------------------------------------------------------+ +| |ea |Ea, length of the RM output sequence in bits, r < cab | ++----------------+------------+-------------------------------------------------------+ +| |eb |Eb, length of the RM output sequence in bits r >= cab | ++----------------+------------+-------------------------------------------------------+ + +The mbuf input ``input`` encoded CB data is mandatory for all BBDEV PMDs +and is the Virtual Circular Buffer data stream with null padding. +Each byte in the input circular buffer is the LLR value of each bit of +the original CB. + +The mbuf output ``hard_output`` is mandatory and is the decoded CBs size +K (CRC24A/B is the last 24-bit in each decoded CB). + +The mbuf output ``soft_output`` is optional and is an LLR rate matched +output of size ``e`` (this is ``E`` as per 3GPP TS 38.212 section 6.2.5). + +The mbuf input ``harq_combine_input`` is optional and is a buffer with +the input to the HARQ combination function of the device. If the +capability RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE is set +then the HARQ is stored in memory internal to the device and not visible +to BBDEV. + +The mbuf output ``harq_combine_output`` is optional and is a buffer for +the output of the HARQ combination function of the device. If the +capability RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE is set +then the HARQ is stored in memory internal to the device and not visible +to BBDEV. + +The output mbuf data structures are expected to be allocated by the +application with enough room for the output data. + +As with the LDPC encode, the decode interface works on both a code block +(CB) and a transport block (TB) basis. + + **NOTE:** All enqueued ops in one ``rte_bbdev_enqueue_dec_ops()`` + call belong to one mode, either CB-mode or TB-mode. + +The valid modes of operation are: + +* CB-mode: one CB (check CRC24B if required) +* CB-mode: one CB making up one TB (check CRC24A if required) +* TB-mode: one or more CB making up a partial TB (check CRC24B(s) if required) +* TB-mode: one or more CB making up a complete TB (check CRC24B(s) if required) + +The mbuf ``length`` is inclusive of CRC24A/B where present and is equal +the code block size ``K``. + +The first CB Virtual Circular Buffer (VCB) index is given by ``r`` but the +the number of the remaining CB VCBs is calculated automatically by BBDEV +and passed down to the driver. + +The number of remaining CB VCBs should not be confused with ``c``, the +total number of CBs in the full TB (``C`` as per 3GPP TS 38.212 section 5.2.2) + +The ``length`` is total size of the CBs inclusive of any CRC24A and CRC24B in +case they were appended by the application. + +Figure 13.2 above showing the Turbo decoding of CBs using BBDEV +interface in TB-mode is also valid for LDPC decode. + Sample code ----------- diff --git a/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c b/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c index 856b68e..64c96b3 100644 --- a/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c +++ b/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c @@ -607,9 +607,9 @@ struct __rte_cache_aligned fpga_queue { RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP, .max_llr_modulus = INT8_MAX, .num_buffers_src = - RTE_BBDEV_MAX_CODE_BLOCKS, + RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, .num_buffers_hard_out = - RTE_BBDEV_MAX_CODE_BLOCKS, + RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, .num_buffers_soft_out = 0 } }, @@ -621,9 +621,9 @@ struct __rte_cache_aligned fpga_queue { RTE_BBDEV_TURBO_RATE_MATCH | RTE_BBDEV_TURBO_ENC_INTERRUPTS, .num_buffers_src = - RTE_BBDEV_MAX_CODE_BLOCKS, + RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, .num_buffers_dst = - RTE_BBDEV_MAX_CODE_BLOCKS + RTE_BBDEV_TURBO_MAX_CODE_BLOCKS } }, RTE_BBDEV_END_OF_CAPABILITIES_LIST() @@ -1389,15 +1389,15 @@ struct __rte_cache_aligned fpga_queue { RTE_BBDEV_MAX_CB_SIZE); return -1; } - if (tb->c_neg > (RTE_BBDEV_MAX_CODE_BLOCKS - 1)) + if (tb->c_neg > (RTE_BBDEV_TURBO_MAX_CODE_BLOCKS - 1)) rte_bbdev_log(ERR, "c_neg (%u) is out of range 0 <= value <= %u", tb->c_neg, - RTE_BBDEV_MAX_CODE_BLOCKS - 1); - if (tb->c < 1 || tb->c > RTE_BBDEV_MAX_CODE_BLOCKS) { + RTE_BBDEV_TURBO_MAX_CODE_BLOCKS - 1); + if (tb->c < 1 || tb->c > RTE_BBDEV_TURBO_MAX_CODE_BLOCKS) { rte_bbdev_log(ERR, "c (%u) is out of range 1 <= value <= %u", - tb->c, RTE_BBDEV_MAX_CODE_BLOCKS); + tb->c, RTE_BBDEV_TURBO_MAX_CODE_BLOCKS); return -1; } if (tb->cab > tb->c) { @@ -1731,15 +1731,15 @@ struct __rte_cache_aligned fpga_queue { RTE_BBDEV_MAX_CB_SIZE); return -1; } - if (tb->c_neg > (RTE_BBDEV_MAX_CODE_BLOCKS - 1)) + if (tb->c_neg > (RTE_BBDEV_TURBO_MAX_CODE_BLOCKS - 1)) rte_bbdev_log(ERR, "c_neg (%u) is out of range 0 <= value <= %u", tb->c_neg, - RTE_BBDEV_MAX_CODE_BLOCKS - 1); - if (tb->c < 1 || tb->c > RTE_BBDEV_MAX_CODE_BLOCKS) { + RTE_BBDEV_TURBO_MAX_CODE_BLOCKS - 1); + if (tb->c < 1 || tb->c > RTE_BBDEV_TURBO_MAX_CODE_BLOCKS) { rte_bbdev_log(ERR, "c (%u) is out of range 1 <= value <= %u", - tb->c, RTE_BBDEV_MAX_CODE_BLOCKS); + tb->c, RTE_BBDEV_TURBO_MAX_CODE_BLOCKS); return -1; } if (tb->cab > tb->c) { diff --git a/drivers/baseband/turbo_sw/bbdev_turbo_software.c b/drivers/baseband/turbo_sw/bbdev_turbo_software.c index 5204a77..c714d03 100644 --- a/drivers/baseband/turbo_sw/bbdev_turbo_software.c +++ b/drivers/baseband/turbo_sw/bbdev_turbo_software.c @@ -33,9 +33,9 @@ rte_bbdev_log(DEBUG, RTE_STR(__LINE__) ":%s() " fmt, __func__, \ ##__VA_ARGS__) -#define DEINT_INPUT_BUF_SIZE (((RTE_BBDEV_MAX_CB_SIZE >> 3) + 1) * 48) +#define DEINT_INPUT_BUF_SIZE (((RTE_BBDEV_TURBO_MAX_CB_SIZE >> 3) + 1) * 48) #define DEINT_OUTPUT_BUF_SIZE (DEINT_INPUT_BUF_SIZE * 6) -#define ADAPTER_OUTPUT_BUF_SIZE ((RTE_BBDEV_MAX_CB_SIZE + 4) * 48) +#define ADAPTER_OUTPUT_BUF_SIZE ((RTE_BBDEV_TURBO_MAX_CB_SIZE + 4) * 48) /* private data structure */ struct bbdev_private { @@ -101,7 +101,7 @@ struct turbo_sw_queue { { int32_t result = 0; - if (k < RTE_BBDEV_MIN_CB_SIZE || k > RTE_BBDEV_MAX_CB_SIZE) + if (k < RTE_BBDEV_TURBO_MIN_CB_SIZE || k > RTE_BBDEV_TURBO_MAX_CB_SIZE) return -1; if (k > 2048) { @@ -154,9 +154,9 @@ struct turbo_sw_queue { RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP | RTE_BBDEV_TURBO_EARLY_TERMINATION, .max_llr_modulus = 16, - .num_buffers_src = RTE_BBDEV_MAX_CODE_BLOCKS, + .num_buffers_src = RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, .num_buffers_hard_out = - RTE_BBDEV_MAX_CODE_BLOCKS, + RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, .num_buffers_soft_out = 0, } }, @@ -168,8 +168,8 @@ struct turbo_sw_queue { RTE_BBDEV_TURBO_CRC_24A_ATTACH | RTE_BBDEV_TURBO_RATE_MATCH | RTE_BBDEV_TURBO_RV_INDEX_BYPASS, - .num_buffers_src = RTE_BBDEV_MAX_CODE_BLOCKS, - .num_buffers_dst = RTE_BBDEV_MAX_CODE_BLOCKS, + .num_buffers_src = RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, + .num_buffers_dst = RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, } }, RTE_BBDEV_END_OF_CAPABILITIES_LIST() @@ -248,7 +248,7 @@ struct turbo_sw_queue { return -ENAMETOOLONG; } q->enc_out = rte_zmalloc_socket(name, - ((RTE_BBDEV_MAX_TB_SIZE >> 3) + 3) * + ((RTE_BBDEV_TURBO_MAX_TB_SIZE >> 3) + 3) * sizeof(*q->enc_out) * 3, RTE_CACHE_LINE_SIZE, queue_conf->socket); if (q->enc_out == NULL) { @@ -268,7 +268,7 @@ struct turbo_sw_queue { return -ENAMETOOLONG; } q->enc_in = rte_zmalloc_socket(name, - (RTE_BBDEV_MAX_CB_SIZE >> 3) * sizeof(*q->enc_in), + (RTE_BBDEV_TURBO_MAX_CB_SIZE >> 3) * sizeof(*q->enc_in), RTE_CACHE_LINE_SIZE, queue_conf->socket); if (q->enc_in == NULL) { rte_bbdev_log(ERR, @@ -286,7 +286,7 @@ struct turbo_sw_queue { return -ENAMETOOLONG; } q->ag = rte_zmalloc_socket(name, - RTE_BBDEV_MAX_CB_SIZE * 10 * sizeof(*q->ag), + RTE_BBDEV_TURBO_MAX_CB_SIZE * 10 * sizeof(*q->ag), RTE_CACHE_LINE_SIZE, queue_conf->socket); if (q->ag == NULL) { rte_bbdev_log(ERR, @@ -304,7 +304,7 @@ struct turbo_sw_queue { return -ENAMETOOLONG; } q->code_block = rte_zmalloc_socket(name, - RTE_BBDEV_MAX_CB_SIZE * sizeof(*q->code_block), + RTE_BBDEV_TURBO_MAX_CB_SIZE * sizeof(*q->code_block), RTE_CACHE_LINE_SIZE, queue_conf->socket); if (q->code_block == NULL) { rte_bbdev_log(ERR, @@ -429,9 +429,9 @@ struct turbo_sw_queue { return -1; } - if (k > RTE_BBDEV_MAX_CB_SIZE) { + if (k > RTE_BBDEV_TURBO_MAX_CB_SIZE) { rte_bbdev_log(ERR, "CB size (%u) is too big, max: %d", - k, RTE_BBDEV_MAX_CB_SIZE); + k, RTE_BBDEV_TURBO_MAX_CB_SIZE); return -1; } @@ -456,9 +456,9 @@ struct turbo_sw_queue { return -1; } - if (kw > RTE_BBDEV_MAX_KW) { + if (kw > RTE_BBDEV_TURBO_MAX_KW) { rte_bbdev_log(ERR, "Input length (%u) is too big, max: %d", - kw, RTE_BBDEV_MAX_KW); + kw, RTE_BBDEV_TURBO_MAX_KW); return -1; } @@ -745,9 +745,9 @@ struct turbo_sw_queue { /* Clear op status */ op->status = 0; - if (mbuf_total_left > RTE_BBDEV_MAX_TB_SIZE >> 3) { + if (mbuf_total_left > RTE_BBDEV_TURBO_MAX_TB_SIZE >> 3) { rte_bbdev_log(ERR, "TB size (%u) is too big, max: %d", - mbuf_total_left, RTE_BBDEV_MAX_TB_SIZE); + mbuf_total_left, RTE_BBDEV_TURBO_MAX_TB_SIZE); op->status = 1 << RTE_BBDEV_DATA_ERROR; return; } @@ -1027,7 +1027,7 @@ struct turbo_sw_queue { * where D is the size of each output from turbo encoder block * (k + 4). */ - kw = RTE_ALIGN_CEIL(k + 4, RTE_BBDEV_C_SUBBLOCK) * 3; + kw = RTE_ALIGN_CEIL(k + 4, RTE_BBDEV_TURBO_C_SUBBLOCK) * 3; process_dec_cb(q, op, c, k, kw, m_in, m_out_head, m_out, in_offset, out_offset, check_bit(dec->op_flags, diff --git a/lib/librte_bbdev/rte_bbdev.c b/lib/librte_bbdev/rte_bbdev.c index a3ab5d9..7e4acfc 100644 --- a/lib/librte_bbdev/rte_bbdev.c +++ b/lib/librte_bbdev/rte_bbdev.c @@ -6,7 +6,6 @@ #include #include -#include #include #include #include @@ -215,7 +214,7 @@ struct rte_bbdev * __rte_experimental bbdev->data->dev_id = dev_id; bbdev->state = RTE_BBDEV_INITIALIZED; - ret = strlcpy(bbdev->data->name, name, RTE_BBDEV_NAME_MAX_LEN); + ret = snprintf(bbdev->data->name, RTE_BBDEV_NAME_MAX_LEN, "%s", name); if ((ret < 0) || (ret >= RTE_BBDEV_NAME_MAX_LEN)) { rte_bbdev_log(ERR, "Copying device name \"%s\" failed", name); return NULL; @@ -499,7 +498,7 @@ struct rte_bbdev * __rte_experimental if (conf->op_type == RTE_BBDEV_OP_TURBO_DEC && conf->priority > dev_info.max_ul_queue_priority) { rte_bbdev_log(ERR, - "Priority (%u) of queue %u of bdev %u must be <= %u", + "Priority (%u) of queue %u of bbdev %u must be <= %u", conf->priority, queue_id, dev_id, dev_info.max_ul_queue_priority); return -EINVAL; @@ -507,7 +506,7 @@ struct rte_bbdev * __rte_experimental if (conf->op_type == RTE_BBDEV_OP_TURBO_ENC && conf->priority > dev_info.max_dl_queue_priority) { rte_bbdev_log(ERR, - "Priority (%u) of queue %u of bdev %u must be <= %u", + "Priority (%u) of queue %u of bbdev %u must be <= %u", conf->priority, queue_id, dev_id, dev_info.max_dl_queue_priority); return -EINVAL; @@ -796,7 +795,7 @@ struct rte_bbdev * __rte_experimental memset(dev_info, 0, sizeof(*dev_info)); dev_info->dev_name = dev->data->name; dev_info->num_queues = dev->data->num_queues; - dev_info->bus = rte_bus_find_by_device(dev->device); + dev_info->device = dev->device; dev_info->socket_id = dev->data->socket_id; dev_info->started = dev->data->started; @@ -847,6 +846,12 @@ struct rte_bbdev * __rte_experimental case RTE_BBDEV_OP_TURBO_ENC: result = sizeof(struct rte_bbdev_enc_op); break; + case RTE_BBDEV_OP_LDPC_DEC: + result = sizeof(struct rte_bbdev_dec_op); + break; + case RTE_BBDEV_OP_LDPC_ENC: + result = sizeof(struct rte_bbdev_enc_op); + break; default: break; } @@ -861,11 +866,12 @@ struct rte_bbdev * __rte_experimental { enum rte_bbdev_op_type type = *(enum rte_bbdev_op_type *)arg; - if (type == RTE_BBDEV_OP_TURBO_DEC) { + if (type == RTE_BBDEV_OP_TURBO_DEC || type == RTE_BBDEV_OP_LDPC_DEC) { struct rte_bbdev_dec_op *op = element; memset(op, 0, mempool->elt_size); op->mempool = mempool; - } else if (type == RTE_BBDEV_OP_TURBO_ENC) { + } else if (type == RTE_BBDEV_OP_TURBO_ENC || + type == RTE_BBDEV_OP_LDPC_ENC) { struct rte_bbdev_enc_op *op = element; memset(op, 0, mempool->elt_size); op->mempool = mempool; @@ -1117,6 +1123,8 @@ struct rte_mempool * __rte_experimental "RTE_BBDEV_OP_NONE", "RTE_BBDEV_OP_TURBO_DEC", "RTE_BBDEV_OP_TURBO_ENC", + "RTE_BBDEV_OP_LDPC_DEC", + "RTE_BBDEV_OP_LDPC_ENC", }; if (op_type < RTE_BBDEV_OP_TYPE_COUNT) diff --git a/lib/librte_bbdev/rte_bbdev.h b/lib/librte_bbdev/rte_bbdev.h index d131692..63e382d 100644 --- a/lib/librte_bbdev/rte_bbdev.h +++ b/lib/librte_bbdev/rte_bbdev.h @@ -43,7 +43,7 @@ #define RTE_BBDEV_MAX_DEVS 128 /**< Max number of devices */ #endif -/** Flags indicate current state of BBDEV device */ +/** Flags indiciate current state of BBDEV device */ enum rte_bbdev_state { RTE_BBDEV_UNUSED, RTE_BBDEV_INITIALIZED @@ -161,7 +161,7 @@ struct rte_bbdev_queue_conf { /** * Start a device. - * This is the last step needed before enqueuing operations is possible. + * This is the last step needed before enqueueing operations is possible. * * @param dev_id * The identifier of the device. @@ -313,7 +313,7 @@ struct rte_bbdev_driver_info { struct rte_bbdev_info { int socket_id; /**< NUMA socket that device is on */ const char *dev_name; /**< Unique device name */ - const struct rte_bus *bus; /**< Bus information */ + const struct rte_device *device; /**< Device Information */ uint16_t num_queues; /**< Number of queues currently configured */ bool started; /**< Set if device is currently started */ struct rte_bbdev_driver_info drv; /**< Info from device driver */ @@ -433,6 +433,14 @@ struct __rte_cache_aligned rte_bbdev { rte_bbdev_dequeue_enc_ops_t dequeue_enc_ops; /**< Dequeue decode function */ rte_bbdev_dequeue_dec_ops_t dequeue_dec_ops; + /**< Enqueue encode function */ + rte_bbdev_enqueue_enc_ops_t enqueue_ldpc_enc_ops; + /**< Enqueue decode function */ + rte_bbdev_enqueue_dec_ops_t enqueue_ldpc_dec_ops; + /**< Dequeue encode function */ + rte_bbdev_dequeue_enc_ops_t dequeue_ldpc_enc_ops; + /**< Dequeue decode function */ + rte_bbdev_dequeue_dec_ops_t dequeue_ldpc_dec_ops; const struct rte_bbdev_ops *dev_ops; /**< Functions exported by PMD */ struct rte_bbdev_data *data; /**< Pointer to device data */ enum rte_bbdev_state state; /**< If device is currently used or not */ @@ -506,6 +514,67 @@ struct __rte_cache_aligned rte_bbdev { } /** + * Enqueue a burst of processed encode operations to a queue of the device. + * This functions only enqueues as many operations as currently possible and + * does not block until @p num_ops entries in the queue are available. + * This function does not provide any error notification to avoid the + * corresponding overhead. + * + * @param dev_id + * The identifier of the device. + * @param queue_id + * The index of the queue. + * @param ops + * Pointer array containing operations to be enqueued Must have at least + * @p num_ops entries + * @param num_ops + * The maximum number of operations to enqueue. + * + * @return + * The number of operations actually enqueued (this is the number of processed + * entries in the @p ops array). + */ +static inline uint16_t __rte_experimental +rte_bbdev_enqueue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id, + struct rte_bbdev_enc_op **ops, uint16_t num_ops) +{ + struct rte_bbdev *dev = &rte_bbdev_devices[dev_id]; + struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id]; + return dev->enqueue_ldpc_enc_ops(q_data, ops, num_ops); +} + +/** + * Enqueue a burst of processed decode operations to a queue of the device. + * This functions only enqueues as many operations as currently possible and + * does not block until @p num_ops entries in the queue are available. + * This function does not provide any error notification to avoid the + * corresponding overhead. + * + * @param dev_id + * The identifier of the device. + * @param queue_id + * The index of the queue. + * @param ops + * Pointer array containing operations to be enqueued Must have at least + * @p num_ops entries + * @param num_ops + * The maximum number of operations to enqueue. + * + * @return + * The number of operations actually enqueued (this is the number of processed + * entries in the @p ops array). + */ +static inline uint16_t __rte_experimental +rte_bbdev_enqueue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id, + struct rte_bbdev_dec_op **ops, uint16_t num_ops) +{ + struct rte_bbdev *dev = &rte_bbdev_devices[dev_id]; + struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id]; + return dev->enqueue_ldpc_dec_ops(q_data, ops, num_ops); +} + + +/** * Dequeue a burst of processed encode operations from a queue of the device. * This functions returns only the current contents of the queue, and does not * block until @ num_ops is available. @@ -566,6 +635,68 @@ struct __rte_cache_aligned rte_bbdev { return dev->dequeue_dec_ops(q_data, ops, num_ops); } + +/** + * Dequeue a burst of processed encode operations from a queue of the device. + * This functions returns only the current contents of the queue, and does not + * block until @ num_ops is available. + * This function does not provide any error notification to avoid the + * corresponding overhead. + * + * @param dev_id + * The identifier of the device. + * @param queue_id + * The index of the queue. + * @param ops + * Pointer array where operations will be dequeued to. Must have at least + * @p num_ops entries + * @param num_ops + * The maximum number of operations to dequeue. + * + * @return + * The number of operations actually dequeued (this is the number of entries + * copied into the @p ops array). + */ +static inline uint16_t __rte_experimental +rte_bbdev_dequeue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id, + struct rte_bbdev_enc_op **ops, uint16_t num_ops) +{ + struct rte_bbdev *dev = &rte_bbdev_devices[dev_id]; + struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id]; + return dev->dequeue_ldpc_enc_ops(q_data, ops, num_ops); +} + +/** + * Dequeue a burst of processed decode operations from a queue of the device. + * This functions returns only the current contents of the queue, and does not + * block until @ num_ops is available. + * This function does not provide any error notification to avoid the + * corresponding overhead. + * + * @param dev_id + * The identifier of the device. + * @param queue_id + * The index of the queue. + * @param ops + * Pointer array where operations will be dequeued to. Must have at least + * @p num_ops entries + * @param num_ops + * The maximum number of operations to dequeue. + * + * @return + * The number of operations actually dequeued (this is the number of entries + * copied into the @p ops array). + */ + +static inline uint16_t __rte_experimental +rte_bbdev_dequeue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id, + struct rte_bbdev_dec_op **ops, uint16_t num_ops) +{ + struct rte_bbdev *dev = &rte_bbdev_devices[dev_id]; + struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id]; + return dev->dequeue_ldpc_dec_ops(q_data, ops, num_ops); +} + /** Definitions of device event types */ enum rte_bbdev_event_type { RTE_BBDEV_EVENT_UNKNOWN, /**< unknown event type */ diff --git a/lib/librte_bbdev/rte_bbdev_op.h b/lib/librte_bbdev/rte_bbdev_op.h index 6be53f5..7ae6877 100644 --- a/lib/librte_bbdev/rte_bbdev_op.h +++ b/lib/librte_bbdev/rte_bbdev_op.h @@ -26,62 +26,66 @@ #include /* Number of columns in sub-block interleaver (36.212, section 5.1.4.1.1) */ -#define RTE_BBDEV_C_SUBBLOCK (32) +#define RTE_BBDEV_TURBO_C_SUBBLOCK (32) /* Maximum size of Transport Block (36.213, Table, Table 7.1.7.2.5-1) */ -#define RTE_BBDEV_MAX_TB_SIZE (391656) +#define RTE_BBDEV_TURBO_MAX_TB_SIZE (391656) /* Maximum size of Code Block (36.212, Table 5.1.3-3) */ -#define RTE_BBDEV_MAX_CB_SIZE (6144) +#define RTE_BBDEV_TURBO_MAX_CB_SIZE (6144) +/* Maximum size of Code Block */ +#define RTE_BBDEV_LDPC_MAX_CB_SIZE (8448) /* Minimum size of Code Block (36.212, Table 5.1.3-3) */ -#define RTE_BBDEV_MIN_CB_SIZE (40) +#define RTE_BBDEV_TURBO_MIN_CB_SIZE (40) /* Maximum size of circular buffer */ -#define RTE_BBDEV_MAX_KW (18528) +#define RTE_BBDEV_TURBO_MAX_KW (18528) /* - * Maximum number of Code Blocks in Transport Block. It is calculated based on - * maximum size of one Code Block and one Transport Block (considering CRC24A - * and CRC24B): + * Turbo: Maximum number of Code Blocks in Transport Block. It is calculated + * based on maximum size of one Code Block and one Transport Block + * (considering CRC24A and CRC24B): * (391656 + 24) / (6144 - 24) = 64 */ -#define RTE_BBDEV_MAX_CODE_BLOCKS (64) +#define RTE_BBDEV_TURBO_MAX_CODE_BLOCKS (64) +/* LDPC: Maximum number of Code Blocks in Transport Block.*/ +#define RTE_BBDEV_LDPC_MAX_CODE_BLOCKS (256) /** Flags for turbo decoder operation and capability structure */ enum rte_bbdev_op_td_flag_bitmasks { - /**< If sub block de-interleaving is to be performed. */ + /** If sub block de-interleaving is to be performed. */ RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE = (1ULL << 0), - /**< To use CRC Type 24B (otherwise use CRC Type 24A). */ + /** To use CRC Type 24B (otherwise use CRC Type 24A). */ RTE_BBDEV_TURBO_CRC_TYPE_24B = (1ULL << 1), - /**< If turbo equalization is to be performed. */ + /** If turbo equalization is to be performed. */ RTE_BBDEV_TURBO_EQUALIZER = (1ULL << 2), - /**< If set, saturate soft output to +/-127 */ + /** If set, saturate soft output to +/-127 */ RTE_BBDEV_TURBO_SOFT_OUT_SATURATE = (1ULL << 3), - /**< Set to 1 to start iteration from even, else odd; one iteration = + /** Set to 1 to start iteration from even, else odd; one iteration = * max_iteration + 0.5 */ RTE_BBDEV_TURBO_HALF_ITERATION_EVEN = (1ULL << 4), - /**< If 0, TD stops after CRC matches; else if 1, runs to end of next + /** If 0, TD stops after CRC matches; else if 1, runs to end of next * odd iteration after CRC matches */ RTE_BBDEV_TURBO_CONTINUE_CRC_MATCH = (1ULL << 5), - /**< Set if soft output is required to be output */ + /** Set if soft output is required to be output */ RTE_BBDEV_TURBO_SOFT_OUTPUT = (1ULL << 6), - /**< Set to enable early termination mode */ + /** Set to enable early termination mode */ RTE_BBDEV_TURBO_EARLY_TERMINATION = (1ULL << 7), - /**< Set if a device supports decoder dequeue interrupts */ + /** Set if a device supports decoder dequeue interrupts */ RTE_BBDEV_TURBO_DEC_INTERRUPTS = (1ULL << 9), - /**< Set if positive LLR encoded input is supported. Positive LLR value + /** Set if positive LLR encoded input is supported. Positive LLR value * represents the level of confidence for bit '1', and vice versa for * bit '0'. * This is mutually exclusive with RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN * when used to formalize the input data format. */ RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN = (1ULL << 10), - /**< Set if negative LLR encoded input is supported. Negative LLR value + /** Set if negative LLR encoded input is supported. Negative LLR value * represents the level of confidence for bit '1', and vice versa for * bit '0'. * This is mutually exclusive with RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN * when used to formalize the input data format. */ RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN = (1ULL << 11), - /**< Set if positive LLR soft output is supported. Positive LLR value + /** Set if positive LLR soft output is supported. Positive LLR value * represents the level of confidence for bit '1', and vice versa for * bit '0'. * This is mutually exclusive with @@ -89,7 +93,7 @@ enum rte_bbdev_op_td_flag_bitmasks { * the input data format. */ RTE_BBDEV_TURBO_POS_LLR_1_BIT_SOFT_OUT = (1ULL << 12), - /**< Set if negative LLR soft output is supported. Negative LLR value + /** Set if negative LLR soft output is supported. Negative LLR value * represents the level of confidence for bit '1', and vice versa for * bit '0'. * This is mutually exclusive with @@ -97,43 +101,110 @@ enum rte_bbdev_op_td_flag_bitmasks { * input data format. */ RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT = (1ULL << 13), - /**< Set if driver supports flexible parallel MAP engine decoding. If + /** Set if driver supports flexible parallel MAP engine decoding. If * not supported, num_maps (number of MAP engines) argument is unusable. */ RTE_BBDEV_TURBO_MAP_DEC = (1ULL << 14), - /**< Set if a device supports scatter-gather functionality */ + /** Set if a device supports scatter-gather functionality */ RTE_BBDEV_TURBO_DEC_SCATTER_GATHER = (1ULL << 15), - /**< Set to keep CRC24B bits appended while decoding. Only usable when + /** Set to keep CRC24B bits appended while decoding. Only usable when * decoding Transport Blocks (code_block_mode = 0). */ RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP = (1ULL << 16) }; + /** Flags for turbo encoder operation and capability structure */ enum rte_bbdev_op_te_flag_bitmasks { - /**< Ignore rv_index and set K0 = 0 */ + /** Ignore rv_index and set K0 = 0 */ RTE_BBDEV_TURBO_RV_INDEX_BYPASS = (1ULL << 0), - /**< If rate matching is to be performed */ + /** If rate matching is to be performed */ RTE_BBDEV_TURBO_RATE_MATCH = (1ULL << 1), - /**< This bit must be set to enable CRC-24B generation */ + /** This bit must be set to enable CRC-24B generation */ RTE_BBDEV_TURBO_CRC_24B_ATTACH = (1ULL << 2), - /**< This bit must be set to enable CRC-24A generation */ + /** This bit must be set to enable CRC-24A generation */ RTE_BBDEV_TURBO_CRC_24A_ATTACH = (1ULL << 3), - /**< Set if a device supports encoder dequeue interrupts */ + /** Set if a device supports encoder dequeue interrupts */ RTE_BBDEV_TURBO_ENC_INTERRUPTS = (1ULL << 4), - /**< Set if a device supports scatter-gather functionality */ + /** Set if a device supports scatter-gather functionality */ RTE_BBDEV_TURBO_ENC_SCATTER_GATHER = (1ULL << 5) }; -/**< Data input and output buffer for BBDEV operations */ +/** Flags for LDPC decoder operation and capability structure */ +enum rte_bbdev_op_ldpcdec_flag_bitmasks { + /** Set for transport block CRC-24A checking */ + RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK = (1ULL << 0), + /** Set for code block CRC-24B checking */ + RTE_BBDEV_LDPC_CRC_TYPE_24B_CHECK = (1ULL << 1), + /** Set to drop the last CRC bits decoding output */ + RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP = (1ULL << 2), + /** Set for bit-level de-interleaver bypass on Rx stream. */ + RTE_BBDEV_LDPC_DEINTERLEAVER_BYPASS = (1ULL << 3), + /** Set for HARQ combined input stream enable. */ + RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE = (1ULL << 4), + /** Set for HARQ combined output stream enable. */ + RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE = (1ULL << 5), + /** Set for LDPC decoder bypass. + * RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE must be set. + */ + RTE_BBDEV_LDPC_DECODE_BYPASS = (1ULL << 6), + /** Set for soft-output stream enable */ + RTE_BBDEV_LDPC_SOFT_OUT_ENABLE = (1ULL << 7), + /** Set for Rate-Matching bypass on soft-out stream. */ + RTE_BBDEV_LDPC_SOFT_OUT_RM_BYPASS = (1ULL << 8), + /** Set for bit-level de-interleaver bypass on soft-output stream. */ + RTE_BBDEV_LDPC_SOFT_OUT_DEINTERLEAVER_BYPASS = (1ULL << 9), + /** Set for iteration stopping on successful decode condition + * i.e. a successful syndrome check. + */ + RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE = (1ULL << 10), + /** Set if a device supports decoder dequeue interrupts. */ + RTE_BBDEV_LDPC_DEC_INTERRUPTS = (1ULL << 11), + /** Set if a device supports scatter-gather functionality. */ + RTE_BBDEV_LDPC_DEC_SCATTER_GATHER = (1ULL << 12), + /** Set if a device supports input/output HARQ compression. */ + RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION = (1ULL << 13), + /** Set if a device supports input LLR compression. */ + RTE_BBDEV_LDPC_LLR_COMPRESSION = (1ULL << 14), + /** Set if a device supports HARQ input from + * device's internal memory. + */ + RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE = (1ULL << 15), + /** Set if a device supports HARQ output to + * device's internal memory. + */ + RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE = (1ULL << 16) +}; + +/** Flags for LDPC encoder operation and capability structure */ +enum rte_bbdev_op_ldpcenc_flag_bitmasks { + /** Set for bit-level interleaver bypass on output stream. */ + RTE_BBDEV_LDPC_INTERLEAVER_BYPASS = (1ULL << 0), + /** If rate matching is to be performed */ + RTE_BBDEV_LDPC_RATE_MATCH = (1ULL << 1), + /** Set for transport block CRC-24A attach */ + RTE_BBDEV_LDPC_CRC_24A_ATTACH = (1ULL << 2), + /** Set for code block CRC-24B attach */ + RTE_BBDEV_LDPC_CRC_24B_ATTACH = (1ULL << 3), + /** Set for code block CRC-16 attach */ + RTE_BBDEV_LDPC_CRC_16_ATTACH = (1ULL << 4), + /** Set if a device supports encoder dequeue interrupts. */ + RTE_BBDEV_LDPC_ENC_INTERRUPTS = (1ULL << 5), + /** Set if a device supports scatter-gather functionality. */ + RTE_BBDEV_LDPC_ENC_SCATTER_GATHER = (1ULL << 6), + /** Set if a device supports concatenation of non byte aligned output */ + RTE_BBDEV_LDPC_ENC_CONCATENATION = (1ULL << 7) +}; + +/** Data input and output buffer for BBDEV operations */ struct rte_bbdev_op_data { - /**< The mbuf data structure representing the data for BBDEV operation. + /** The mbuf data structure representing the data for BBDEV operation. * * This mbuf pointer can point to one Code Block (CB) data buffer or * multiple CBs contiguously located next to each other. * A Transport Block (TB) represents a whole piece of data that is * divided into one or more CBs. Maximum number of CBs can be contained - * in one TB is defined by RTE_BBDEV_MAX_CODE_BLOCKS. + * in one TB is defined by RTE_BBDEV_(TURBO/LDPC)_MAX_CODE_BLOCKS. * * An mbuf data structure cannot represent more than one TB. The * smallest piece of data that can be contained in one mbuf is one CB. @@ -145,8 +216,8 @@ struct rte_bbdev_op_data { * then it is capable of collecting (gathering) non-contiguous * (scattered) data from multiple locations in the memory. * This capability is reported by the capability flags: - * - RTE_BBDEV_TURBO_ENC_SCATTER_GATHER and - * - RTE_BBDEV_TURBO_DEC_SCATTER_GATHER. + * - RTE_BBDEV_(TURBO/LDPC)_ENC_SCATTER_GATHER and + * - RTE_BBDEV_(TURBO/LDPC)_DEC_SCATTER_GATHER. * Only if a BBDEV PMD supports this feature, chained mbuf data * structures are accepted. A chained mbuf can represent one * non-contiguous CB or multiple non-contiguous CBs. @@ -157,7 +228,7 @@ struct rte_bbdev_op_data { * was a chained mbuf. */ struct rte_mbuf *data; - /**< The starting point of the BBDEV (encode/decode) operation, + /** The starting point of the BBDEV (encode/decode) operation, * in bytes. * * BBDEV starts to read data past this offset. @@ -165,13 +236,13 @@ struct rte_bbdev_op_data { * segment. */ uint32_t offset; - /**< The total data length to be processed in one operation, in bytes. + /** The total data length to be processed in one operation, in bytes. * * In case the mbuf data is representing one CB, this is the length of * the CB undergoing the operation. * If it's for multiple CBs, this is the total length of those CBs * undergoing the operation. - * If it's for one TB, this is the total length of the TB under + * If it is for one TB, this is the total length of the TB under * operation. * * In case of chained mbuf, this data length includes the lengths of the @@ -180,51 +251,83 @@ struct rte_bbdev_op_data { uint32_t length; }; -struct rte_bbdev_op_dec_cb_params { - /**< The K size of the input CB, in bits [40:6144], as specified in +/** Turbo decode code block parameters */ +struct rte_bbdev_op_dec_turbo_cb_params { + /** The K size of the input CB, in bits [40:6144], as specified in * 3GPP TS 36.212. * This size is inclusive of CRC bits, regardless whether it was * pre-calculated by the application or not. */ uint16_t k; - /**< The E length of the CB rate matched LLR output, in bytes, as in + /** The E length of the CB rate matched LLR output, in bytes, as in * 3GPP TS 36.212. */ uint32_t e; }; -struct rte_bbdev_op_dec_tb_params { - /**< The K- size of the input CB, in bits [40:6144], that is in the +/** LDPC decode code block parameters */ +struct rte_bbdev_op_dec_ldpc_cb_params { + /** Rate matching output sequence length in bits or LLRs. + * [3GPP TS38.212, section 5.4.2.1] + */ + uint32_t e; +}; + +/** Turbo decode transport block parameters */ +struct rte_bbdev_op_dec_turbo_tb_params { + /** The K- size of the input CB, in bits [40:6144], that is in the * Turbo operation when r < C-, as in 3GPP TS 36.212. */ uint16_t k_neg; - /**< The K+ size of the input CB, in bits [40:6144], that is in the + /** The K+ size of the input CB, in bits [40:6144], that is in the * Turbo operation when r >= C-, as in 3GPP TS 36.212. */ uint16_t k_pos; - /**< The number of CBs that have K- size, [0:63] */ + /** The number of CBs that have K- size, [0:63] */ uint8_t c_neg; - /**< The total number of CBs in the TB, [1:RTE_BBDEV_MAX_CODE_BLOCKS] */ + /** The total number of CBs in the TB, + * [1:RTE_BBDEV_TURBO_MAX_CODE_BLOCKS] + */ uint8_t c; - /**< The number of CBs that uses Ea before switching to Eb, [0:63] */ + /** The number of CBs that uses Ea before switching to Eb, [0:63] */ uint8_t cab; - /**< The E size of the CB rate matched output to use in the Turbo + /** The E size of the CB rate matched output to use in the Turbo * operation when r < cab */ uint32_t ea; - /**< The E size of the CB rate matched output to use in the Turbo + /** The E size of the CB rate matched output to use in the Turbo * operation when r >= cab */ uint32_t eb; - /**< The index of the first CB in the inbound mbuf data, default is 0 */ + /** The index of the first CB in the inbound mbuf data, default is 0 */ + uint8_t r; +}; + +/** LDPC decode transport block parameters */ +struct rte_bbdev_op_dec_ldpc_tb_params { + /** Ea, length after rate matching in bits, r < cab. + * [3GPP TS38.212, section 5.4.2.1] + */ + uint32_t ea; + /** Eb, length after rate matching in bits, r >= cab. + * [3GPP TS38.212, section 5.4.2.1] + */ + uint32_t eb; + /** The total number of CBs in the TB or partial TB + * [1:RTE_BBDEV_LDPC_MAX_CODE_BLOCKS] + */ + uint8_t c; + /** The index of the first CB in the inbound mbuf data, default is 0 */ uint8_t r; + /** The number of CBs that use Ea before switching to Eb, [0:63] */ + uint8_t cab; }; -/**< Operation structure for Turbo decode. - * An operation can perform on one CB at a time "CB-mode". - * An operation can perform on one or multiple CBs that are logically belonging - * to one TB "TB-mode". - * The provided K size parameter of the CB is its size out coming from the +/** Operation structure for Turbo decode. + * An operation can be performed on one CB at a time "CB-mode". + * An operation can be performed on one or multiple CBs that logically + * belong to one TB "TB-mode". + * The provided K size parameter of the CB is its size coming from the * decode operation. * CRC24A/B check is requested by the application by setting the flag * RTE_BBDEV_TURBO_CRC_TYPE_24B for CRC24B check or CRC24A otherwise. @@ -249,94 +352,192 @@ struct rte_bbdev_op_dec_tb_params { * application with enough room for the output data. */ struct rte_bbdev_op_turbo_dec { - /**< The Virtual Circular Buffer, wk, size 3*Kpi for each CB */ + /** The Virtual Circular Buffer, wk, size 3*Kpi for each CB */ struct rte_bbdev_op_data input; - /**< The hard decisions buffer for the decoded output, + /** The hard decisions buffer for the decoded output, * size K for each CB */ struct rte_bbdev_op_data hard_output; - /**< The soft LLR output buffer - optional */ + /** The soft LLR output buffer - optional */ struct rte_bbdev_op_data soft_output; - uint32_t op_flags; /**< Flags from rte_bbdev_op_td_flag_bitmasks */ - uint8_t rv_index; /**< Rv index for rate matching [0:3] */ - /**< The minimum number of iterations to perform in decoding all CBs in + /** Flags from rte_bbdev_op_td_flag_bitmasks */ + uint32_t op_flags; + + /** Rv index for rate matching [0:3] */ + uint8_t rv_index; + /** The minimum number of iterations to perform in decoding all CBs in * this operation - input */ uint8_t iter_min:4; - /**< The maximum number of iterations to perform in decoding all CBs in + /** The maximum number of iterations to perform in decoding all CBs in * this operation - input */ uint8_t iter_max:4; - /**< The maximum number of iterations that were perform in decoding all - * CBs in this decode operation - output + /** The maximum number of iterations that were performed in decoding + * all CBs in this decode operation - output */ uint8_t iter_count; - /**< 5 bit extrinsic scale (scale factor on extrinsic info) */ + /** 5 bit extrinsic scale (scale factor on extrinsic info) */ uint8_t ext_scale; - /**< Number of MAP engines to use in decode, - * must be power of 2 (or 0 to auto-select) + /** Number of MAP engines to use in decode, + * must be power of 2 (or 0 to auto-select) */ uint8_t num_maps; - uint8_t code_block_mode; /**< [0 - TB : 1 - CB] */ + /**< [0 - TB : 1 - CB] */ + uint8_t code_block_mode; union { /**< Struct which stores Code Block specific parameters */ - struct rte_bbdev_op_dec_cb_params cb_params; + struct rte_bbdev_op_dec_turbo_cb_params cb_params; /**< Struct which stores Transport Block specific parameters */ - struct rte_bbdev_op_dec_tb_params tb_params; + struct rte_bbdev_op_dec_turbo_tb_params tb_params; + }; +}; + +/** Operation structure for LDPC decode. + * + * An operation can be performed on one CB at a time "CB-mode". + * An operation can also be performed on one or multiple CBs that logically + * belong to a TB "TB-mode" (Currently not supported). + * + * The input encoded CB data is the Virtual Circular Buffer data stream. + * + * Each byte in the input circular buffer is the LLR value of each bit of the + * original CB. + * + * Hard output is a mandatory capability that all BBDEV PMDs support. This is + * the decoded CBs (CRC24A/B is the last 24-bit in each decoded CB). + * + * Soft output is an optional capability for BBDEV PMDs. If supported, an LLR + * rate matched output is computed in the soft_output buffer structure. + * These are A Posteriori Probabilities (APP) LLR samples for coded bits. + * + * HARQ combined output is an optional capability for BBDEV PMDs. + * If supported, a LLR output is streamed to the harq_combined_output + * buffer. + * + * HARQ combined input is an optional capability for BBDEV PMDs. + * If supported, a LLR input is streamed from the harq_combined_input + * buffer. + * + * The output mbuf data structure is expected to be allocated by the + * application with enough room for the output data. + */ +struct rte_bbdev_op_ldpc_dec { + /** The Virtual Circular Buffer for this code block, one LLR + * per bit of the original CB. + */ + struct rte_bbdev_op_data input; + /** The hard decisions buffer for the decoded output, + * size K for each CB + */ + struct rte_bbdev_op_data hard_output; + /** The soft LLR output LLR stream buffer - optional */ + struct rte_bbdev_op_data soft_output; + /** The HARQ combined LLR stream input buffer - optional */ + struct rte_bbdev_op_data harq_combined_input; + /** The HARQ combined LLR stream output buffer - optional */ + struct rte_bbdev_op_data harq_combined_output; + + /** Flags from rte_bbdev_op_ldpcdec_flag_bitmasks */ + uint32_t op_flags; + + /** Rate matching redundancy version + * [3GPP TS38.212, section 5.4.2.1] + */ + uint8_t rv_index; + /** The maximum number of iterations to perform in decoding CB in + * this operation - input + */ + uint8_t iter_max; + /** The number of iterations that were performed in decoding + * CB in this decode operation - output + */ + uint8_t iter_count; + /** 1: LDPC Base graph 1, 2: LDPC Base graph 2. + * [3GPP TS38.212, section 5.2.2] + */ + uint8_t basegraph; + /** Zc, LDPC lifting size. + * [3GPP TS38.212, section 5.2.2] + */ + uint16_t z_c; + /** Ncb, length of the circular buffer in bits. + * [3GPP TS38.212, section 5.4.2.1] + */ + uint16_t n_cb; + /** Qm, modulation order {2,4,6,8,10}. + * [3GPP TS38.212, section 5.4.2.2] + */ + uint8_t q_m; + /** Number of Filler bits, n_filler = K – K’ + * [3GPP TS38.212 section 5.2.2] + */ + uint16_t n_filler; + /** [0 - TB : 1 - CB] */ + uint8_t code_block_mode; + union { + /** Struct which stores Code Block specific parameters */ + struct rte_bbdev_op_dec_ldpc_cb_params cb_params; + /** Struct which stores Transport Block specific parameters */ + struct rte_bbdev_op_dec_ldpc_tb_params tb_params; }; }; -struct rte_bbdev_op_enc_cb_params { - /**< The K size of the input CB, in bits [40:6144], as specified in +/** Turbo encode code block parameters */ +struct rte_bbdev_op_enc_turbo_cb_params { + /** The K size of the input CB, in bits [40:6144], as specified in * 3GPP TS 36.212. * This size is inclusive of CRC24A, regardless whether it was * pre-calculated by the application or not. */ uint16_t k; - /**< The E length of the CB rate matched output, in bits, as in + /** The E length of the CB rate matched output, in bits, as in * 3GPP TS 36.212. */ uint32_t e; - /**< The Ncb soft buffer size of the CB rate matched output [K:3*Kpi], + /** The Ncb soft buffer size of the CB rate matched output [K:3*Kpi], * in bits, as specified in 3GPP TS 36.212. */ uint16_t ncb; }; -struct rte_bbdev_op_enc_tb_params { - /**< The K- size of the input CB, in bits [40:6144], that is in the +/** Turbo encode transport block parameters */ +struct rte_bbdev_op_enc_turbo_tb_params { + /** The K- size of the input CB, in bits [40:6144], that is in the * Turbo operation when r < C-, as in 3GPP TS 36.212. * This size is inclusive of CRC24B, regardless whether it was * pre-calculated and appended by the application or not. */ uint16_t k_neg; - /**< The K+ size of the input CB, in bits [40:6144], that is in the + /** The K+ size of the input CB, in bits [40:6144], that is in the * Turbo operation when r >= C-, as in 3GPP TS 36.212. * This size is inclusive of CRC24B, regardless whether it was * pre-calculated and appended by the application or not. */ uint16_t k_pos; - /**< The number of CBs that have K- size, [0:63] */ + /** The number of CBs that have K- size, [0:63] */ uint8_t c_neg; - /**< The total number of CBs in the TB, [1:RTE_BBDEV_MAX_CODE_BLOCKS] */ + /** The total number of CBs in the TB, + * [1:RTE_BBDEV_TURBO_MAX_CODE_BLOCKS] + */ uint8_t c; - /**< The number of CBs that uses Ea before switching to Eb, [0:63] */ + /** The number of CBs that uses Ea before switching to Eb, [0:63] */ uint8_t cab; - /**< The E size of the CB rate matched output to use in the Turbo + /** The E size of the CB rate matched output to use in the Turbo * operation when r < cab */ uint32_t ea; - /**< The E size of the CB rate matched output to use in the Turbo + /** The E size of the CB rate matched output to use in the Turbo * operation when r >= cab */ uint32_t eb; - /**< The Ncb soft buffer size for the rate matched CB that is used in + /** The Ncb soft buffer size for the rate matched CB that is used in * the Turbo operation when r < C-, [K:3*Kpi] */ uint16_t ncb_neg; - /**< The Ncb soft buffer size for the rate matched CB that is used in + /** The Ncb soft buffer size for the rate matched CB that is used in * the Turbo operation when r >= C-, [K:3*Kpi] */ uint16_t ncb_pos; @@ -344,10 +545,38 @@ struct rte_bbdev_op_enc_tb_params { uint8_t r; }; -/**< Operation structure for Turbo encode. - * An operation can perform on one CB at a time "CB-mode". - * An operation can perform on one or multiple CBs that are logically - * belonging to one TB "TB-mode". +/** LDPC encode code block parameters */ +struct rte_bbdev_op_enc_ldpc_cb_params { + /** E, length after rate matching in bits. + * [3GPP TS38.212, section 5.4.2.1] + */ + uint32_t e; +}; + +/** LDPC encode transport block parameters */ +struct rte_bbdev_op_enc_ldpc_tb_params { + /** Ea, length after rate matching in bits, r < cab. + * [3GPP TS38.212, section 5.4.2.1] + */ + uint32_t ea; + /** Eb, length after rate matching in bits, r >= cab. + * [3GPP TS38.212, section 5.4.2.1] + */ + uint32_t eb; + /** The total number of CBs in the TB or partial TB + * [1:RTE_BBDEV_LDPC_MAX_CODE_BLOCKS] + */ + uint8_t c; + /** The index of the first CB in the inbound mbuf data, default is 0 */ + uint8_t r; + /** The number of CBs that use Ea before switching to Eb, [0:63] */ + uint8_t cab; +}; + +/** Operation structure for Turbo encode. + * An operation can be performed on one CB at a time "CB-mode". + * An operation can pbe erformd on one or multiple CBs that logically + * belong to one TB "TB-mode". * * In CB-mode, CRC24A/B is an optional operation. K size parameter is not * affected by CRC24A/B inclusion, this only affects the inbound mbuf data @@ -364,44 +593,127 @@ struct rte_bbdev_op_enc_tb_params { * application with enough room for the output data. */ struct rte_bbdev_op_turbo_enc { - /**< The input CB or TB data */ + /** The input CB or TB data */ + struct rte_bbdev_op_data input; + /** The rate matched CB or TB output buffer */ + struct rte_bbdev_op_data output; + /** Flags from rte_bbdev_op_te_flag_bitmasks */ + uint32_t op_flags; + + /** Rv index for rate matching [0:3] */ + uint8_t rv_index; + /** [0 - TB : 1 - CB] */ + uint8_t code_block_mode; + union { + /** Struct which stores Code Block specific parameters */ + struct rte_bbdev_op_enc_turbo_cb_params cb_params; + /** Struct which stores Transport Block specific parameters */ + struct rte_bbdev_op_enc_turbo_tb_params tb_params; + }; +}; + +/** Operation structure for LDPC encode. + * An operation can be performed on one CB at a time "CB-mode". + * An operation can be performed on one or multiple CBs that logically + * belong to a TB "TB-mode". + * + * The input data is the CB or TB input to the decoder. + * + * The output data is the ratematched CB or TB data, or the output after + * bit-selection if RTE_BBDEV_LDPC_INTERLEAVER_BYPASS is set. + * + * The output mbuf data structure is expected to be allocated by the + * application with enough room for the output data. + */ +struct rte_bbdev_op_ldpc_enc { + /** The input TB or CB data */ struct rte_bbdev_op_data input; - /**< The rate matched CB or TB output buffer */ + /** The rate matched TB or CB output buffer */ struct rte_bbdev_op_data output; - uint32_t op_flags; /**< Flags from rte_bbdev_op_te_flag_bitmasks */ - uint8_t rv_index; /**< Rv index for rate matching [0:3] */ + /** Flags from rte_bbdev_op_ldpcenc_flag_bitmasks */ + uint32_t op_flags; - uint8_t code_block_mode; /**< [0 - TB : 1 - CB] */ + /** Rate matching redundancy version */ + uint8_t rv_index; + /** 0:Basegraph 0, 1: Basegraph 1. */ + uint8_t basegraph; + /** Zc, LDPC lifting size. + * [3GPP TS38.212, section 5.2.2] + */ + uint16_t z_c; + /** Ncb, length of the circular buffer in bits. + * [3GPP TS38.212, section 5.4.2.1] + */ + uint16_t n_cb; + /** Qm, modulation order {2,4,6,8,10}. + * [3GPP TS38.212, section 5.4.2.2] + */ + uint8_t q_m; + /** Number of Filler bits, n_filler = K – K’ + * [3GPP TS38.212 section 5.2.2] + */ + uint16_t n_filler; + /** [0 - TB : 1 - CB] */ + uint8_t code_block_mode; union { - /**< Struct which stores Code Block specific parameters */ - struct rte_bbdev_op_enc_cb_params cb_params; - /**< Struct which stores Transport Block specific parameters */ - struct rte_bbdev_op_enc_tb_params tb_params; + /** Struct which stores Code Block specific parameters */ + struct rte_bbdev_op_enc_ldpc_cb_params cb_params; + /** Struct which stores Transport Block specific parameters */ + struct rte_bbdev_op_enc_ldpc_tb_params tb_params; }; }; -/**< List of the capabilities for the Turbo Decoder */ +/** List of the capabilities for the Turbo Decoder */ struct rte_bbdev_op_cap_turbo_dec { - /**< Flags from rte_bbdev_op_td_flag_bitmasks */ + /** Flags from rte_bbdev_op_td_flag_bitmasks */ uint32_t capability_flags; /** Maximal LLR absolute value. Acceptable LLR values lie in range * [-max_llr_modulus, max_llr_modulus]. */ int8_t max_llr_modulus; + /** Num input code block buffers */ uint8_t num_buffers_src; /**< Num input code block buffers */ - /**< Num hard output code block buffers */ + /** Num hard output code block buffers */ uint8_t num_buffers_hard_out; - /**< Num soft output code block buffers if supported by the driver */ + /** Num soft output code block buffers if supported by the driver */ uint8_t num_buffers_soft_out; }; -/**< List of the capabilities for the Turbo Encoder */ +/** List of the capabilities for the Turbo Encoder */ struct rte_bbdev_op_cap_turbo_enc { - /**< Flags from rte_bbdev_op_te_flag_bitmasks */ + /** Flags from rte_bbdev_op_te_flag_bitmasks */ uint32_t capability_flags; - uint8_t num_buffers_src; /**< Num input code block buffers */ - uint8_t num_buffers_dst; /**< Num output code block buffers */ + /** Num input code block buffers */ + uint8_t num_buffers_src; + /** Num output code block buffers */ + uint8_t num_buffers_dst; +}; + +/** List of the capabilities for the LDPC Decoder */ +struct rte_bbdev_op_cap_ldpc_dec { + /** Flags from rte_bbdev_op_ldpcdec_flag_bitmasks */ + uint32_t capability_flags; + /** LLR size in bits. LLR is a two’s complement number. */ + int8_t llr_size; + /** LLR numbers of decimals bit for arithmetic representation */ + int8_t llr_decimals; + /** Num input code block buffers */ + uint16_t num_buffers_src; + /** Num hard output code block buffers */ + uint16_t num_buffers_hard_out; + /** Num soft output code block buffers if supported by the driver */ + uint16_t num_buffers_soft_out; +}; + +/** List of the capabilities for the LDPC Encoder */ +struct rte_bbdev_op_cap_ldpc_enc { + /** Flags from rte_bbdev_op_ldpcenc_flag_bitmasks */ + uint32_t capability_flags; + /** Num input code block buffers */ + uint16_t num_buffers_src; + /** Num output code block buffers */ + uint16_t num_buffers_dst; }; /** Different operation types supported by the device */ @@ -409,40 +721,59 @@ enum rte_bbdev_op_type { RTE_BBDEV_OP_NONE, /**< Dummy operation that does nothing */ RTE_BBDEV_OP_TURBO_DEC, /**< Turbo decode */ RTE_BBDEV_OP_TURBO_ENC, /**< Turbo encode */ + RTE_BBDEV_OP_LDPC_DEC, /**< LDPC decode */ + RTE_BBDEV_OP_LDPC_ENC, /**< LDPC encode */ RTE_BBDEV_OP_TYPE_COUNT, /**< Count of different op types */ }; -/**< Bit indexes of possible errors reported through status field */ +/** Bit indexes of possible errors reported through status field */ enum { RTE_BBDEV_DRV_ERROR, RTE_BBDEV_DATA_ERROR, RTE_BBDEV_CRC_ERROR, + RTE_BBDEV_SYNDROME_ERROR }; -/**< Structure specifying a single encode operation */ +/** Structure specifying a single encode operation */ struct rte_bbdev_enc_op { - int status; /**< Status of operation that was performed */ - struct rte_mempool *mempool; /**< Mempool which op instance is in */ - void *opaque_data; /**< Opaque pointer for user data */ - /**< Contains encoder specific parameters */ - struct rte_bbdev_op_turbo_enc turbo_enc; + /**< Status of operation that was performed */ + int status; + /**< Mempool which op instance is in */ + struct rte_mempool *mempool; + /**< Opaque pointer for user data */ + void *opaque_data; + union { + /** Contains turbo decoder specific parameters */ + struct rte_bbdev_op_turbo_enc turbo_enc; + /** Contains LDPC decoder specific parameters */ + struct rte_bbdev_op_ldpc_enc ldpc_enc; + }; }; -/**< Structure specifying a single decode operation */ +/** Structure specifying a single decode operation */ struct rte_bbdev_dec_op { - int status; /**< Status of operation that was performed */ - struct rte_mempool *mempool; /**< Mempool which op instance is in */ - void *opaque_data; /**< Opaque pointer for user data */ - /**< Contains decoder specific parameters */ - struct rte_bbdev_op_turbo_dec turbo_dec; + /** Status of operation that was performed */ + int status; + /** Mempool which op instance is in */ + struct rte_mempool *mempool; + /** Opaque pointer for user data */ + void *opaque_data; + union { + /** Contains turbo decoder specific parameters */ + struct rte_bbdev_op_turbo_dec turbo_dec; + /** Contains LDPC decoder specific parameters */ + struct rte_bbdev_op_ldpc_dec ldpc_dec; + }; }; -/**< Operation capabilities supported by a device */ +/** Operation capabilities supported by a device */ struct rte_bbdev_op_cap { enum rte_bbdev_op_type type; /**< Type of operation */ union { struct rte_bbdev_op_cap_turbo_dec turbo_dec; struct rte_bbdev_op_cap_turbo_enc turbo_enc; + struct rte_bbdev_op_cap_ldpc_dec ldpc_dec; + struct rte_bbdev_op_cap_ldpc_enc ldpc_enc; } cap; /**< Operation-type specific capabilities */ }; @@ -513,7 +844,8 @@ struct rte_mempool * __rte_experimental /* Check type */ priv = (struct rte_bbdev_op_pool_private *) rte_mempool_get_priv(mempool); - if (unlikely(priv->type != RTE_BBDEV_OP_TURBO_ENC)) + if (unlikely((priv->type != RTE_BBDEV_OP_TURBO_ENC) && + (priv->type != RTE_BBDEV_OP_LDPC_ENC))) return -EINVAL; /* Get elements */ @@ -548,7 +880,8 @@ struct rte_mempool * __rte_experimental /* Check type */ priv = (struct rte_bbdev_op_pool_private *) rte_mempool_get_priv(mempool); - if (unlikely(priv->type != RTE_BBDEV_OP_TURBO_DEC)) + if (unlikely((priv->type != RTE_BBDEV_OP_TURBO_DEC) && + (priv->type != RTE_BBDEV_OP_LDPC_DEC))) return -EINVAL; /* Get elements */ -- 1.8.3.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id DBBA0A00E6 for ; Tue, 14 May 2019 21:46:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 14E955B1E; Tue, 14 May 2019 21:46:23 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 7FBFB548B for ; Tue, 14 May 2019 21:46:19 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 May 2019 12:46:18 -0700 X-ExtLoop1: 1 Received: from skx-5gnr-sd5.sc.intel.com ([172.25.69.194]) by orsmga003.jf.intel.com with ESMTP; 14 May 2019 12:46:18 -0700 From: Nicolas Chautru To: Cc: dev@dpdk.org, Nicolas Chautru Date: Tue, 14 May 2019 12:45:40 -0700 Message-Id: <1557863143-174842-3-git-send-email-nicolas.chautru@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1557863143-174842-1-git-send-email-nicolas.chautru@intel.com> References: <1557533163-172544-1-git-send-email-nicolas.chautru@intel.com> <1557863143-174842-1-git-send-email-nicolas.chautru@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 2/5] bbdev: extension of BBDEV for 5G FEC X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Message-ID: <20190514194540.vH2_R65_1a0AbAnont2u14k1jqW1-Xu8nuS5bma-LTM@z> Supporting API for FEC operation with LDPC Signed-off-by: Nicolas Chautru --- doc/guides/prog_guide/bbdev.rst | 509 ++++++++++++++++++-- drivers/baseband/fpga_lte_fec/fpga_lte_fec.c | 24 +- drivers/baseband/turbo_sw/bbdev_turbo_software.c | 36 +- lib/librte_bbdev/rte_bbdev.c | 22 +- lib/librte_bbdev/rte_bbdev.h | 137 +++++- lib/librte_bbdev/rte_bbdev_op.h | 577 ++++++++++++++++++----- 6 files changed, 1091 insertions(+), 214 deletions(-) diff --git a/doc/guides/prog_guide/bbdev.rst b/doc/guides/prog_guide/bbdev.rst index 658ffd4..9a47a9b 100644 --- a/doc/guides/prog_guide/bbdev.rst +++ b/doc/guides/prog_guide/bbdev.rst @@ -78,7 +78,7 @@ From the application point of view, each instance of a bbdev device consists of one or more queues identified by queue IDs. While different devices may have different capabilities (e.g. support different operation types), all queues on a device support identical configuration possibilities. A queue is configured -for only one type of operation and is configured at initialization time. +for only one type of operation and is configured at initializations time. When an operation is enqueued to a specific queue ID, the result is dequeued from the same queue ID. @@ -91,8 +91,7 @@ and queue configuration is applied with ``rte_bbdev_queue_configure(dev_id,queue_id,conf)``. Note that, although all queues on a device support same capabilities, they can be configured differently and will then behave differently. -Devices supporting interrupts can enable them by using -``rte_bbdev_intr_enable(dev_id)``. +Devices supporting interrupts can enable them by using ``rte_bbdev_intr_enable(dev_id)``. The configuration of each bbdev device includes the following operations: @@ -150,8 +149,6 @@ device. Once closed, it cannot be restarted. int rte_bbdev_start(uint16_t dev_id) int rte_bbdev_stop(uint16_t dev_id) int rte_bbdev_close(uint16_t dev_id) - int rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id) - int rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id) By default, all queues are started when the device is started, but they can be @@ -166,9 +163,9 @@ stopped individually. Logical Cores, Memory and Queues Relationships ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The bbdev device Library as the Poll Mode Driver library support NUMA for when -a processor's logical cores and interfaces utilize its local memory. Therefore -baseband operations, the mbuf being operated on should be allocated from memory +The bbdev poll mode device driver library supports NUMA architecture, in which +a processor's logical cores and interfaces utilize it's local memory. Therefore +with baseband operations, the mbuf being operated on should be allocated from memory pools created in the local memory. The buffers should, if possible, remain on the local processor to obtain the best performance results and buffer descriptors should be populated with mbufs allocated from a mempool allocated @@ -220,9 +217,9 @@ relation to Turbo Encoding and Decoding operations. RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP | RTE_BBDEV_TURBO_EARLY_TERMINATION, .max_llr_modulus = 16, - .num_buffers_src = RTE_BBDEV_MAX_CODE_BLOCKS, + .num_buffers_src = RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, .num_buffers_hard_out = - RTE_BBDEV_MAX_CODE_BLOCKS, + RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, .num_buffers_soft_out = 0, } }, @@ -234,8 +231,8 @@ relation to Turbo Encoding and Decoding operations. RTE_BBDEV_TURBO_CRC_24A_ATTACH | RTE_BBDEV_TURBO_RATE_MATCH | RTE_BBDEV_TURBO_RV_INDEX_BYPASS, - .num_buffers_src = RTE_BBDEV_MAX_CODE_BLOCKS, - .num_buffers_dst = RTE_BBDEV_MAX_CODE_BLOCKS, + .num_buffers_src = RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, + .num_buffers_dst = RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, } }, RTE_BBDEV_END_OF_CAPABILITIES_LIST() @@ -266,12 +263,13 @@ information: struct rte_bbdev_info { int socket_id; const char *dev_name; - const struct rte_bus *bus; + const struct rte_device *device; uint16_t num_queues; bool started; struct rte_bbdev_driver_info drv; }; + Operation Processing -------------------- @@ -335,14 +333,20 @@ processed on a particular bbdev device poll mode driver. int status; struct rte_mempool *mempool; void *opaque_data; - struct rte_bbdev_op_turbo_enc turbo_enc; + union { + struct rte_bbdev_op_turbo_enc turbo_enc; + struct rte_bbdev_op_ldpc_enc ldpc_enc; + } }; struct rte_bbdev_dec_op { int status; struct rte_mempool *mempool; void *opaque_data; - struct rte_bbdev_op_turbo_dec turbo_dec; + union { + struct rte_bbdev_op_turbo_dec turbo_enc; + struct rte_bbdev_op_ldpc_dec ldpc_enc; + } }; The operation structure by itself defines the operation type. It includes an @@ -399,19 +403,31 @@ BBDEV Inbound/Outbound Memory ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The bbdev operation structure contains all the mutable data relating to -performing Turbo coding on a referenced mbuf data buffer. It is used for either +performing Turbo and LDPC coding on a referenced mbuf data buffer. It is used for either encode or decode operations. -Turbo Encode operation accepts one input and one output. -Turbo Decode operation accepts one input and two outputs, called *hard-decision* -and *soft-decision* outputs. *Soft-decision* output is optional. + +.. csv-table:: Operation I/O + :header: "FEC", "In", "Out" + :widths: 20, 30, 30 + + "Turbo Encode", "input", "output" + "Turbo Decode", "input", "hard output" + " ", " ", "soft output (optional)" + "LDPC Encode", "input", "output" + "LDPC Decode", "input", "hard output" + "", "HQ combine (optional)", "HQ combine (optional)" + " ", "", "soft output (optional)" + It is expected that the application provides input and output mbuf pointers -allocated and ready to use. The baseband framework supports turbo coding on -Code Blocks (CB) and Transport Blocks (TB). +allocated and ready to use. + +The baseband framework supports FEC coding on Code Blocks (CB) and +Transport Blocks (TB). For the output buffer(s), the application is required to provide an allocated -and free mbuf, so that bbdev write back the resulting output. +and free mbuf, to which the resulting output will be written. The support of split "scattered" buffers is a driver-specific feature, so it is reported individually by the supporting driver as a capability. @@ -436,26 +452,26 @@ This structure has three elements: This mbuf pointer can point to one Code Block (CB) data buffer or multiple CBs contiguously located next to each other. A Transport Block (TB) represents a whole piece of data that is divided into one or more CBs. Maximum number of - CBs can be contained in one TB is defined by ``RTE_BBDEV_MAX_CODE_BLOCKS``. + CBs can be contained in one TB is defined by + ``RTE_BBDEV_(TURBO/LDPC)MAX_CODE_BLOCKS``. An mbuf data structure cannot represent more than one TB. The smallest piece of data that can be contained in one mbuf is one CB. An mbuf can include one contiguous CB, subset of contiguous CBs that are - belonging to one TB, or all contiguous CBs that are belonging to one TB. + belonging to one TB, or all contiguous CBs that belong to one TB. If a BBDEV PMD supports the extended capability "Scatter-Gather", then it is capable of collecting (gathering) non-contiguous (scattered) data from multiple locations in the memory. This capability is reported by the capability flags: - - ``RTE_BBDEV_TURBO_ENC_SCATTER_GATHER``, and + - ``RTE_BBDEV_TURBO_ENC_SCATTER_GATHER``, ``RTE_BBDEV_TURBO_DEC_SCATTER_GATHER``, - - ``RTE_BBDEV_TURBO_DEC_SCATTER_GATHER``. + - ``RTE_BBDEV_LDPC_ENC_SCATTER_GATHER``, ``RTE_BBDEV_LDPC_DEC_SCATTER_GATHER``. - Only if a BBDEV PMD supports this feature, chained mbuf data structures are - accepted. A chained mbuf can represent one non-contiguous CB or multiple - non-contiguous CBs. - The first mbuf segment in the given chained mbuf represents the first piece + Chained mbuf data structures are only accepted if a BBDEV PMD supports this + feature. A chained mbuf can represent one non-contiguous CB or multiple non-contiguous + CBs. The first mbuf segment in the given chained mbuf represents the first piece of the CB. Offset is only applicable to the first segment. ``length`` is the total length of the CB. @@ -506,14 +522,22 @@ BBDEV Turbo Encode Operation }; }; -The Turbo encode structure is composed of the ``input`` and ``output`` mbuf -data pointers. The provided mbuf pointer of ``input`` needs to be big enough to -stretch for extra CRC trailers. +The Turbo encode structure includes the ``input`` and ``output`` mbuf +data pointers. The provided mbuf pointer of ``input`` needs to be big +enough to stretch for extra CRC trailers. + +.. csv-table:: **struct rte_bbdev_op_turbo_enc** parameters + :header: "Parameter", "Description" + :widths: 10, 30 -``op_flags`` parameter holds all operation related flags, like whether CRC24A is -included by the application or not. + "input","input CB or TB data" + "output","rate matched CB or TB output buffer" + "op_flags","bitmask of all active operation capabilities" + "rv_index","redundancy version index [0..3]" + "code_block_mode","code block or transport block mode" + "cb_params", "code block specific parameters (code block mode only)" + "tb_params", "transport block specific parameters (transport block mode only)" -``code_block_mode`` flag identifies the mode in which bbdev is operating in. The encode interface works on both the code block (CB) and the transport block (TB). An operation executes in "CB-mode" when the CB is standalone. While @@ -525,21 +549,21 @@ are being enqueued. **NOTE:** It is assumed that all enqueued ops in one ``rte_bbdev_enqueue_enc_ops()`` call belong to one mode, either CB-mode or TB-mode. -In case that the CB is smaller than Z (6144 bits), then effectively the TB = CB. +In case that the TB is smaller than Z (6144 bits), then effectively the TB = CB. CRC24A is appended to the tail of the CB. The application is responsible for calculating and appending CRC24A before calling BBDEV in case that the underlying driver does not support CRC24A generation. In CB-mode, CRC24A/B is an optional operation. -The input ``k`` is the size of the CB (this maps to K as described in 3GPP TS -36.212 section 5.1.2), this size is inclusive of CRC24A/B. +The CB parameter ``k`` is the size of the CB (this maps to K as described +in 3GPP TS 36.212 section 5.1.2), this size is inclusive of CRC24A/B. The ``length`` is inclusive of CRC24A/B and equals to ``k`` in this case. Not all BBDEV PMDs are capable of CRC24A/B calculation. Flags ``RTE_BBDEV_TURBO_CRC_24A_ATTACH`` and ``RTE_BBDEV_TURBO_CRC_24B_ATTACH`` informs the application with relevant capability. These flags can be set in the -``op_flags`` parameter to indicate BBDEV to calculate and append CRC24A to CB -before going forward with Turbo encoding. +``op_flags`` parameter to indicate to BBDEV to calculate and append CRC24A/B +to CB before going forward with Turbo encoding. Output format of the CB encode will have the encoded CB in ``e`` size output (this maps to E described in 3GPP TS 36.212 section 5.1.4.1.2). The output mbuf @@ -600,13 +624,26 @@ BBDEV Turbo Decode Operation }; }; -The Turbo decode structure is composed of the ``input`` and ``output`` mbuf -data pointers. - -``op_flags`` parameter holds all operation related flags, like whether CRC24B is -retained or not. - -``code_block_mode`` flag identifies the mode in which bbdev is operating in. +The Turbo decode structure includes the ``input``, ``hard_output`` and +optionally the ``soft_output`` mbuf data pointers. + +.. csv-table:: **struct rte_bbdev_op_turbo_dec** parameters + :header: "Parameter", "Description" + :widths: 10, 30 + + "input","virtual circular buffer, wk, size 3*Kpi for each CB" + "hard output","hard decisions buffer, decoded output, size K for each CB" + "soft output","soft LLR output buffer (optional)" + "op_flags","bitmask of all active operation capabilities" + "rv_index","redundancy version index [0..3]" + "iter_max","maximum number of iterations to perofrm in decode all CBs" + "iter_min","minimum number of iterations to perform in decoding all CBs" + "iter_count","number of iterations to performed in decoding all CBs" + "ext_scale","scale factor on extrinsic info (5 bits)" + "num_maps","number of MAP engines to use in decode" + "code_block_mode","code block or transport block mode" + "cb_params", "code block specific parameters (code block mode only)" + "tb_params", "transport block specific parameters (transport block mode only)" Similarly, the decode interface works on both the code block (CB) and the transport block (TB). An operation executes in "CB-mode" when the CB is @@ -618,7 +655,8 @@ to a bigger TB are being enqueued. **NOTE:** It is assumed that all enqueued ops in one ``rte_bbdev_enqueue_dec_ops()`` call belong to one mode, either CB-mode or TB-mode. -The input ``k`` is the size of the decoded CB (this maps to K as described in + +The CB parameter ``k`` is the size of the decoded CB (this maps to K as described in 3GPP TS 36.212 section 5.1.2), this size is inclusive of CRC24A/B. The ``length`` is inclusive of CRC24A/B and equals to ``k`` in this case. @@ -638,9 +676,9 @@ Soft output is an optional capability for BBDEV PMDs. Setting flag CRC24B at the end of each CB. This might be useful for the application in debug mode. An LLR rate matched output is computed in the ``soft_output`` buffer structure -for the given ``e`` size (this maps to E described in 3GPP TS 36.212 section -5.1.4.1.2). The output mbuf buffer size needs to be big enough to hold the -encoded buffer of size ``e``. +for the given CB parameter ``e`` size (this maps to E described in +3GPP TS 36.212 section 5.1.4.1.2). The output mbuf buffer size needs to be big +enough to hold the encoded buffer of size ``e``. The first CB Virtual Circular Buffer (VCB) index is given by ``r`` but the number of the remaining CB VCBs is calculated automatically by BBDEV before @@ -669,6 +707,373 @@ TB-mode. CB-mode is a reduced version, where only one CB exists: Turbo decoding of Code Blocks in mbuf structure +BBDEV LDPC Encode Operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The operation flags that can be set for each LDPC encode operation are +given below. + + **NOTE:** The actual operation flags that may be used with a specific + BBDEV PMD are dependent on the driver capabilities as reported via + ``rte_bbdev_info_get()``, and may be a subset of those below. + ++--------------------------------------------------------------------+ +|Description of LDPC encode capability flags | ++====================================================================+ +|RTE_BBDEV_LDPC_INTERLEAVER_BYPASS | +| Set to bypass bit-level interleaver on output stream | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_RATE_MATCH | +| Set to enabling the RATE_MATCHING processing | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_CRC_24A_ATTACH | +| Set to attach transport block CRC-24A | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_CRC_24B_ATTACH | +| Set to attach code block CRC-24B | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_CRC_16_ATTACH | +| Set to attach code block CRC-16 | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_ENC_INTERRUPTS | +| Set if a device supports encoder dequeue interrupts | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_ENC_SCATTER_GATHER | +| Set if a device supports scatter-gather functionality | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_ENC_CONCATENATION | +| Set if a device supports concatenation of non byte aligned output | ++--------------------------------------------------------------------+ + +The structure passed for each LDPC encode operation is given below, +with the operation flags forming a bitmask in the ``op_flags`` field. + +.. code-block:: c + + struct rte_bbdev_op_ldpc_enc { + + struct rte_bbdev_op_data input; + struct rte_bbdev_op_data output; + + uint32_t op_flags; + uint8_t rv_index; + uint8_t basegraph; + uint16_t z_c; + uint16_t n_cb; + uint8_t q_m; + uint16_t n_filler; + uint8_t code_block_mode; + union { + struct rte_bbdev_op_enc_ldpc_cb_params cb_params; + struct rte_bbdev_op_enc_ldpc_tb_params tb_params; + }; + }; + +The LDPC encode parameters are set out in the table below. + ++----------------+--------------------------------------------------------------------+ +|Parameter |Description | ++================+====================================================================+ +|input |input CB or TB data | ++----------------+--------------------------------------------------------------------+ +|output |rate matched CB or TB output buffer | ++----------------+--------------------------------------------------------------------+ +|op_flags |bitmask of all active operation capabilities | ++----------------+--------------------------------------------------------------------+ +|rv_index |redundancy version index [0..3] | ++----------------+--------------------------------------------------------------------+ +|basegraph |Basegraph 1 or 2 | ++----------------+--------------------------------------------------------------------+ +|z_c |Zc, LDPC lifting size | ++----------------+--------------------------------------------------------------------+ +|n_cb |Ncb, length of the circular buffer in bits. | ++----------------+--------------------------------------------------------------------+ +|q_m |Qm, modulation order {2,4,6,8,10} | ++----------------+--------------------------------------------------------------------+ +|n_filler |number of filler bits | ++----------------+--------------------------------------------------------------------+ +|code_block_mode |code block or transport block mode | ++----------------+--------------------------------------------------------------------+ +|op_flags |bitmask of all active operation capabilities | ++----------------+--------------------------------------------------------------------+ +|**cb_params** |code block specific parameters (transport block mode only) | ++----------------+------------+-------------------------------------------------------+ +| |e |E, length of the rate matched output sequence in bits | ++----------------+------------+-------------------------------------------------------+ +|**tb_params** | transport block specific parameters (code block mode only) | ++----------------+------------+-------------------------------------------------------+ +| |c |number of CBs in the TB or partial TB | ++----------------+------------+-------------------------------------------------------+ +| |r |index of the first CB in the inbound mbuf data | ++----------------+------------+-------------------------------------------------------+ ++ +c_ab +number of CBs that use Ea before switching to Eb | ++----------------+------------+-------------------------------------------------------+ +| |ea |Ea, length of the RM output sequence in bits, r < cab | ++----------------+------------+-------------------------------------------------------+ +| |eb |Eb, length of the RM output sequence in bits, r >= cab | ++----------------+------------+-------------------------------------------------------+ + +The mbuf input ``input`` is mandatory for all BBDEV PMDs and is the +incoming code block or transport block data. + +The mbuf output ``output`` is mandatory and is the encoded CB(s). In +CB-mode ut contains the encoded CB of size ``e`` (E in 3GPP TS 38.212 +section 6.2.5). In TB-mode it contains multiple contiguous encoded CBs +of size ``ea`` or ``eb``. +The ``output`` buffer is allocated by the application with enough room +for the output data. + +The encode interface works on both a code block (CB) and a transport +block (TB) basis. + + **NOTE:** All enqueued ops in one ``rte_bbdev_enqueue_enc_ops()`` + call belong to one mode, either CB-mode or TB-mode. + +The valid modes of operation are: + +* CB-mode: one CB (attach CRC24B if required) +* CB-mode: one CB making up one TB (attach CRC24A if required) +* TB-mode: one or more CB of a partial TB (attach CRC24B(s) if required) +* TB-mode: one or more CB of a complete TB (attach CRC24AB(s) if required) + +In CB-mode if ``RTE_BBDEV_LDPC_CRC_24A_ATTACH`` is set then CRC24A +is appended to the CB. If ``RTE_BBDEV_LDPC_CRC_24A_ATTACH`` is not +set the application is responsible for calculating and appending CRC24A +before calling BBDEV. The input data mbuf ``length`` is inclusive of +CRC24A/B where present and is equal to the code block size ``K``. + +In TB-mode, CRC24A is assumed to be pre-calculated and appended to the +inbound TB data buffer, unless the ``RTE_BBDEV_LDPC_CRC_24A_ATTACH`` +flag is set when it is the responsibility of BBDEV. The input data +mbuf ``length`` is total size of the CBs inclusive of any CRC24A and +CRC24B in the case they were appended by the application. + +Not all BBDEV PMDs may be capable of CRC24A/B calculation. Flags +``RTE_BBDEV_LDPC_CRC_24A_ATTACH`` and ``RTE_BBDEV_LDPC_CRC_24B_ATTACH`` +inform the application of the relevant capability. These flags can be set +in the ``op_flags`` parameter to indicate BBDEV to calculate and append +CRC24A to CB before going forward with LDPC encoding. + +The difference between the partial and full-size TB is that BBDEV needs +the index of the first CB in this group and the number of CBs in the group. +The first CB index is given by ``r`` but the number of the CBs is +calculated by BBDEV before signalling to the driver. + +The number of CBs in the group should not be confused with ``c``, the +total number of CBs in the full TB (``C`` as per 3GPP TS 38.212 section 5.2.2) + +Figure 13.1 above showing the Turbo encoding of CBs using BBDEV +interface in TB-mode is also valid for LDPC encode. + +BBDEV LDPC Decode Operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The operation flags that can be set for each LDPC decode operation are +given below. + + **NOTE:** The actual operation flags that may be used with a specific + BBDEV PMD are dependent on the driver capabilities as reported via + ``rte_bbdev_info_get()``, and may be a subset of those below. + ++--------------------------------------------------------------------+ +|Description of LDPC decode capability flags | ++====================================================================+ +|RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK | +| Set for transport block CRC-24A checking | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_CRC_TYPE_24B_CHECK | +| Set for code block CRC-24B checking | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP | +| Set to drop the last CRC bits decoding output | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_DEINTERLEAVER_BYPASS | +| Set for bit-level de-interleaver bypass on input stream | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE | +| Set for HARQ combined input stream enable | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE | +| Set for HARQ combined output stream enable | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_DECODE_BYPASS | +| Set for LDPC decoder bypass | +| | +| RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE must be set | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_DECODE_SOFT_OUT | +| Set for soft-output stream enable | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_SOFT_OUT_RM_BYPASS | +| Set for Rate-Matching bypass on soft-out stream | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_SOFT_OUT_DEINTERLEAVER_BYPASS | +| Set for bit-level de-interleaver bypass on soft-output stream | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE | +| Set for iteration stopping on successful decode condition enable | +| | +| Where a successful decode is a successful syndrome check | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_DEC_INTERRUPTS | +| Set if a device supports decoder dequeue interrupts | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_DEC_SCATTER_GATHER | +| Set if a device supports scatter-gather functionality | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION | +| Set if a device supports input/output HARQ compression | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_LLR_COMPRESSION | +| Set if a device supports input LLR compression | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE | +| Set if a device supports HARQ input to device's internal memory | ++--------------------------------------------------------------------+ +|RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE | +| Set if a device supports HARQ output to device's internal memory | ++--------------------------------------------------------------------+ + +The structure passed for each LDPC decode operation is given below, +with the operation flags forming a bitmask in the ``op_flags`` field. + +.. code-block:: c + + + struct rte_bbdev_op_ldpc_dec { + + struct rte_bbdev_op_data input; + struct rte_bbdev_op_data hard_output; + struct rte_bbdev_op_data soft_output; + struct rte_bbdev_op_data harq_combined_input; + struct rte_bbdev_op_data harq_combined_output; + + uint32_t op_flags; + uint8_t rv_index; + uint8_t basegraph; + uint16_t z_c; + uint16_t n_cb; + uint8_t q_m; + uint16_t n_filler; + uint8_t iter_max; + uint8_t iter_count; + uint8_t code_block_mode; + union { + struct rte_bbdev_op_dec_ldpc_cb_params cb_params; + struct rte_bbdev_op_dec_ldpc_tb_params tb_params; + }; + }; + + +The LDPC decode parameters are set out in the table below. + ++----------------+--------------------------------------------------------------------+ +|Parameter |Description | ++================+====================================================================+ +|input |input CB or TB data | ++----------------+--------------------------------------------------------------------+ +|hard_output |hard decisions buffer, decoded output | ++----------------+--------------------------------------------------------------------+ +|soft_output |soft LLR output buffer (optional) | ++----------------+--------------------------------------------------------------------+ +|harq_comb_input |HARQ combined input buffer (optional) | ++----------------+--------------------------------------------------------------------+ +|harq_comb_output|HARQ combined output buffer (optional) | ++----------------+--------------------------------------------------------------------+ +|op_flags |bitmask of all active operation capabilities | ++----------------+--------------------------------------------------------------------+ +|rv_index |redundancy version index [0..3] | ++----------------+--------------------------------------------------------------------+ +|basegraph |Basegraph 1 or 2 | ++----------------+--------------------------------------------------------------------+ +|z_c |Zc, LDPC lifting size | ++----------------+--------------------------------------------------------------------+ +|n_cb |Ncb, length of the circular buffer in bits. | ++----------------+--------------------------------------------------------------------+ +|q_m |Qm, modulation order {2,4,6,8,10} | ++----------------+--------------------------------------------------------------------+ +|n_filler |number of filler bits | ++----------------+--------------------------------------------------------------------+ +|iter_max |maximum number of iterations to perform in decode all CBs | ++----------------+--------------------------------------------------------------------+ +|iter_count |number of iterations performed in decoding all CBs | ++----------------+--------------------------------------------------------------------+ +|code_block_mode |code block or transport block mode | ++----------------+--------------------------------------------------------------------+ +|op_flags |bitmask of all active operation capabilities | ++----------------+--------------------------------------------------------------------+ +|**cb_params** |code block specific parameters (code block mode only) | ++----------------+------------+-------------------------------------------------------+ +| |e |E, length of the rate matched output sequence in bits | ++----------------+------------+-------------------------------------------------------+ +|**tb_params** | transport block specific parameters (transport block mode only) | ++----------------+------------+-------------------------------------------------------+ +| |c |number of CBs in the TB or partial TB | ++----------------+------------+-------------------------------------------------------+ +| |r |index of the first CB in the inbound mbuf data | ++----------------+------------+-------------------------------------------------------+ +| |c_ab |number of CBs that use Ea before switching to Eb | ++----------------+------------+-------------------------------------------------------+ +| |ea |Ea, length of the RM output sequence in bits, r < cab | ++----------------+------------+-------------------------------------------------------+ +| |eb |Eb, length of the RM output sequence in bits r >= cab | ++----------------+------------+-------------------------------------------------------+ + +The mbuf input ``input`` encoded CB data is mandatory for all BBDEV PMDs +and is the Virtual Circular Buffer data stream with null padding. +Each byte in the input circular buffer is the LLR value of each bit of +the original CB. + +The mbuf output ``hard_output`` is mandatory and is the decoded CBs size +K (CRC24A/B is the last 24-bit in each decoded CB). + +The mbuf output ``soft_output`` is optional and is an LLR rate matched +output of size ``e`` (this is ``E`` as per 3GPP TS 38.212 section 6.2.5). + +The mbuf input ``harq_combine_input`` is optional and is a buffer with +the input to the HARQ combination function of the device. If the +capability RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE is set +then the HARQ is stored in memory internal to the device and not visible +to BBDEV. + +The mbuf output ``harq_combine_output`` is optional and is a buffer for +the output of the HARQ combination function of the device. If the +capability RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE is set +then the HARQ is stored in memory internal to the device and not visible +to BBDEV. + +The output mbuf data structures are expected to be allocated by the +application with enough room for the output data. + +As with the LDPC encode, the decode interface works on both a code block +(CB) and a transport block (TB) basis. + + **NOTE:** All enqueued ops in one ``rte_bbdev_enqueue_dec_ops()`` + call belong to one mode, either CB-mode or TB-mode. + +The valid modes of operation are: + +* CB-mode: one CB (check CRC24B if required) +* CB-mode: one CB making up one TB (check CRC24A if required) +* TB-mode: one or more CB making up a partial TB (check CRC24B(s) if required) +* TB-mode: one or more CB making up a complete TB (check CRC24B(s) if required) + +The mbuf ``length`` is inclusive of CRC24A/B where present and is equal +the code block size ``K``. + +The first CB Virtual Circular Buffer (VCB) index is given by ``r`` but the +the number of the remaining CB VCBs is calculated automatically by BBDEV +and passed down to the driver. + +The number of remaining CB VCBs should not be confused with ``c``, the +total number of CBs in the full TB (``C`` as per 3GPP TS 38.212 section 5.2.2) + +The ``length`` is total size of the CBs inclusive of any CRC24A and CRC24B in +case they were appended by the application. + +Figure 13.2 above showing the Turbo decoding of CBs using BBDEV +interface in TB-mode is also valid for LDPC decode. + Sample code ----------- diff --git a/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c b/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c index 856b68e..64c96b3 100644 --- a/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c +++ b/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c @@ -607,9 +607,9 @@ struct __rte_cache_aligned fpga_queue { RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP, .max_llr_modulus = INT8_MAX, .num_buffers_src = - RTE_BBDEV_MAX_CODE_BLOCKS, + RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, .num_buffers_hard_out = - RTE_BBDEV_MAX_CODE_BLOCKS, + RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, .num_buffers_soft_out = 0 } }, @@ -621,9 +621,9 @@ struct __rte_cache_aligned fpga_queue { RTE_BBDEV_TURBO_RATE_MATCH | RTE_BBDEV_TURBO_ENC_INTERRUPTS, .num_buffers_src = - RTE_BBDEV_MAX_CODE_BLOCKS, + RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, .num_buffers_dst = - RTE_BBDEV_MAX_CODE_BLOCKS + RTE_BBDEV_TURBO_MAX_CODE_BLOCKS } }, RTE_BBDEV_END_OF_CAPABILITIES_LIST() @@ -1389,15 +1389,15 @@ struct __rte_cache_aligned fpga_queue { RTE_BBDEV_MAX_CB_SIZE); return -1; } - if (tb->c_neg > (RTE_BBDEV_MAX_CODE_BLOCKS - 1)) + if (tb->c_neg > (RTE_BBDEV_TURBO_MAX_CODE_BLOCKS - 1)) rte_bbdev_log(ERR, "c_neg (%u) is out of range 0 <= value <= %u", tb->c_neg, - RTE_BBDEV_MAX_CODE_BLOCKS - 1); - if (tb->c < 1 || tb->c > RTE_BBDEV_MAX_CODE_BLOCKS) { + RTE_BBDEV_TURBO_MAX_CODE_BLOCKS - 1); + if (tb->c < 1 || tb->c > RTE_BBDEV_TURBO_MAX_CODE_BLOCKS) { rte_bbdev_log(ERR, "c (%u) is out of range 1 <= value <= %u", - tb->c, RTE_BBDEV_MAX_CODE_BLOCKS); + tb->c, RTE_BBDEV_TURBO_MAX_CODE_BLOCKS); return -1; } if (tb->cab > tb->c) { @@ -1731,15 +1731,15 @@ struct __rte_cache_aligned fpga_queue { RTE_BBDEV_MAX_CB_SIZE); return -1; } - if (tb->c_neg > (RTE_BBDEV_MAX_CODE_BLOCKS - 1)) + if (tb->c_neg > (RTE_BBDEV_TURBO_MAX_CODE_BLOCKS - 1)) rte_bbdev_log(ERR, "c_neg (%u) is out of range 0 <= value <= %u", tb->c_neg, - RTE_BBDEV_MAX_CODE_BLOCKS - 1); - if (tb->c < 1 || tb->c > RTE_BBDEV_MAX_CODE_BLOCKS) { + RTE_BBDEV_TURBO_MAX_CODE_BLOCKS - 1); + if (tb->c < 1 || tb->c > RTE_BBDEV_TURBO_MAX_CODE_BLOCKS) { rte_bbdev_log(ERR, "c (%u) is out of range 1 <= value <= %u", - tb->c, RTE_BBDEV_MAX_CODE_BLOCKS); + tb->c, RTE_BBDEV_TURBO_MAX_CODE_BLOCKS); return -1; } if (tb->cab > tb->c) { diff --git a/drivers/baseband/turbo_sw/bbdev_turbo_software.c b/drivers/baseband/turbo_sw/bbdev_turbo_software.c index 5204a77..c714d03 100644 --- a/drivers/baseband/turbo_sw/bbdev_turbo_software.c +++ b/drivers/baseband/turbo_sw/bbdev_turbo_software.c @@ -33,9 +33,9 @@ rte_bbdev_log(DEBUG, RTE_STR(__LINE__) ":%s() " fmt, __func__, \ ##__VA_ARGS__) -#define DEINT_INPUT_BUF_SIZE (((RTE_BBDEV_MAX_CB_SIZE >> 3) + 1) * 48) +#define DEINT_INPUT_BUF_SIZE (((RTE_BBDEV_TURBO_MAX_CB_SIZE >> 3) + 1) * 48) #define DEINT_OUTPUT_BUF_SIZE (DEINT_INPUT_BUF_SIZE * 6) -#define ADAPTER_OUTPUT_BUF_SIZE ((RTE_BBDEV_MAX_CB_SIZE + 4) * 48) +#define ADAPTER_OUTPUT_BUF_SIZE ((RTE_BBDEV_TURBO_MAX_CB_SIZE + 4) * 48) /* private data structure */ struct bbdev_private { @@ -101,7 +101,7 @@ struct turbo_sw_queue { { int32_t result = 0; - if (k < RTE_BBDEV_MIN_CB_SIZE || k > RTE_BBDEV_MAX_CB_SIZE) + if (k < RTE_BBDEV_TURBO_MIN_CB_SIZE || k > RTE_BBDEV_TURBO_MAX_CB_SIZE) return -1; if (k > 2048) { @@ -154,9 +154,9 @@ struct turbo_sw_queue { RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP | RTE_BBDEV_TURBO_EARLY_TERMINATION, .max_llr_modulus = 16, - .num_buffers_src = RTE_BBDEV_MAX_CODE_BLOCKS, + .num_buffers_src = RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, .num_buffers_hard_out = - RTE_BBDEV_MAX_CODE_BLOCKS, + RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, .num_buffers_soft_out = 0, } }, @@ -168,8 +168,8 @@ struct turbo_sw_queue { RTE_BBDEV_TURBO_CRC_24A_ATTACH | RTE_BBDEV_TURBO_RATE_MATCH | RTE_BBDEV_TURBO_RV_INDEX_BYPASS, - .num_buffers_src = RTE_BBDEV_MAX_CODE_BLOCKS, - .num_buffers_dst = RTE_BBDEV_MAX_CODE_BLOCKS, + .num_buffers_src = RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, + .num_buffers_dst = RTE_BBDEV_TURBO_MAX_CODE_BLOCKS, } }, RTE_BBDEV_END_OF_CAPABILITIES_LIST() @@ -248,7 +248,7 @@ struct turbo_sw_queue { return -ENAMETOOLONG; } q->enc_out = rte_zmalloc_socket(name, - ((RTE_BBDEV_MAX_TB_SIZE >> 3) + 3) * + ((RTE_BBDEV_TURBO_MAX_TB_SIZE >> 3) + 3) * sizeof(*q->enc_out) * 3, RTE_CACHE_LINE_SIZE, queue_conf->socket); if (q->enc_out == NULL) { @@ -268,7 +268,7 @@ struct turbo_sw_queue { return -ENAMETOOLONG; } q->enc_in = rte_zmalloc_socket(name, - (RTE_BBDEV_MAX_CB_SIZE >> 3) * sizeof(*q->enc_in), + (RTE_BBDEV_TURBO_MAX_CB_SIZE >> 3) * sizeof(*q->enc_in), RTE_CACHE_LINE_SIZE, queue_conf->socket); if (q->enc_in == NULL) { rte_bbdev_log(ERR, @@ -286,7 +286,7 @@ struct turbo_sw_queue { return -ENAMETOOLONG; } q->ag = rte_zmalloc_socket(name, - RTE_BBDEV_MAX_CB_SIZE * 10 * sizeof(*q->ag), + RTE_BBDEV_TURBO_MAX_CB_SIZE * 10 * sizeof(*q->ag), RTE_CACHE_LINE_SIZE, queue_conf->socket); if (q->ag == NULL) { rte_bbdev_log(ERR, @@ -304,7 +304,7 @@ struct turbo_sw_queue { return -ENAMETOOLONG; } q->code_block = rte_zmalloc_socket(name, - RTE_BBDEV_MAX_CB_SIZE * sizeof(*q->code_block), + RTE_BBDEV_TURBO_MAX_CB_SIZE * sizeof(*q->code_block), RTE_CACHE_LINE_SIZE, queue_conf->socket); if (q->code_block == NULL) { rte_bbdev_log(ERR, @@ -429,9 +429,9 @@ struct turbo_sw_queue { return -1; } - if (k > RTE_BBDEV_MAX_CB_SIZE) { + if (k > RTE_BBDEV_TURBO_MAX_CB_SIZE) { rte_bbdev_log(ERR, "CB size (%u) is too big, max: %d", - k, RTE_BBDEV_MAX_CB_SIZE); + k, RTE_BBDEV_TURBO_MAX_CB_SIZE); return -1; } @@ -456,9 +456,9 @@ struct turbo_sw_queue { return -1; } - if (kw > RTE_BBDEV_MAX_KW) { + if (kw > RTE_BBDEV_TURBO_MAX_KW) { rte_bbdev_log(ERR, "Input length (%u) is too big, max: %d", - kw, RTE_BBDEV_MAX_KW); + kw, RTE_BBDEV_TURBO_MAX_KW); return -1; } @@ -745,9 +745,9 @@ struct turbo_sw_queue { /* Clear op status */ op->status = 0; - if (mbuf_total_left > RTE_BBDEV_MAX_TB_SIZE >> 3) { + if (mbuf_total_left > RTE_BBDEV_TURBO_MAX_TB_SIZE >> 3) { rte_bbdev_log(ERR, "TB size (%u) is too big, max: %d", - mbuf_total_left, RTE_BBDEV_MAX_TB_SIZE); + mbuf_total_left, RTE_BBDEV_TURBO_MAX_TB_SIZE); op->status = 1 << RTE_BBDEV_DATA_ERROR; return; } @@ -1027,7 +1027,7 @@ struct turbo_sw_queue { * where D is the size of each output from turbo encoder block * (k + 4). */ - kw = RTE_ALIGN_CEIL(k + 4, RTE_BBDEV_C_SUBBLOCK) * 3; + kw = RTE_ALIGN_CEIL(k + 4, RTE_BBDEV_TURBO_C_SUBBLOCK) * 3; process_dec_cb(q, op, c, k, kw, m_in, m_out_head, m_out, in_offset, out_offset, check_bit(dec->op_flags, diff --git a/lib/librte_bbdev/rte_bbdev.c b/lib/librte_bbdev/rte_bbdev.c index a3ab5d9..7e4acfc 100644 --- a/lib/librte_bbdev/rte_bbdev.c +++ b/lib/librte_bbdev/rte_bbdev.c @@ -6,7 +6,6 @@ #include #include -#include #include #include #include @@ -215,7 +214,7 @@ struct rte_bbdev * __rte_experimental bbdev->data->dev_id = dev_id; bbdev->state = RTE_BBDEV_INITIALIZED; - ret = strlcpy(bbdev->data->name, name, RTE_BBDEV_NAME_MAX_LEN); + ret = snprintf(bbdev->data->name, RTE_BBDEV_NAME_MAX_LEN, "%s", name); if ((ret < 0) || (ret >= RTE_BBDEV_NAME_MAX_LEN)) { rte_bbdev_log(ERR, "Copying device name \"%s\" failed", name); return NULL; @@ -499,7 +498,7 @@ struct rte_bbdev * __rte_experimental if (conf->op_type == RTE_BBDEV_OP_TURBO_DEC && conf->priority > dev_info.max_ul_queue_priority) { rte_bbdev_log(ERR, - "Priority (%u) of queue %u of bdev %u must be <= %u", + "Priority (%u) of queue %u of bbdev %u must be <= %u", conf->priority, queue_id, dev_id, dev_info.max_ul_queue_priority); return -EINVAL; @@ -507,7 +506,7 @@ struct rte_bbdev * __rte_experimental if (conf->op_type == RTE_BBDEV_OP_TURBO_ENC && conf->priority > dev_info.max_dl_queue_priority) { rte_bbdev_log(ERR, - "Priority (%u) of queue %u of bdev %u must be <= %u", + "Priority (%u) of queue %u of bbdev %u must be <= %u", conf->priority, queue_id, dev_id, dev_info.max_dl_queue_priority); return -EINVAL; @@ -796,7 +795,7 @@ struct rte_bbdev * __rte_experimental memset(dev_info, 0, sizeof(*dev_info)); dev_info->dev_name = dev->data->name; dev_info->num_queues = dev->data->num_queues; - dev_info->bus = rte_bus_find_by_device(dev->device); + dev_info->device = dev->device; dev_info->socket_id = dev->data->socket_id; dev_info->started = dev->data->started; @@ -847,6 +846,12 @@ struct rte_bbdev * __rte_experimental case RTE_BBDEV_OP_TURBO_ENC: result = sizeof(struct rte_bbdev_enc_op); break; + case RTE_BBDEV_OP_LDPC_DEC: + result = sizeof(struct rte_bbdev_dec_op); + break; + case RTE_BBDEV_OP_LDPC_ENC: + result = sizeof(struct rte_bbdev_enc_op); + break; default: break; } @@ -861,11 +866,12 @@ struct rte_bbdev * __rte_experimental { enum rte_bbdev_op_type type = *(enum rte_bbdev_op_type *)arg; - if (type == RTE_BBDEV_OP_TURBO_DEC) { + if (type == RTE_BBDEV_OP_TURBO_DEC || type == RTE_BBDEV_OP_LDPC_DEC) { struct rte_bbdev_dec_op *op = element; memset(op, 0, mempool->elt_size); op->mempool = mempool; - } else if (type == RTE_BBDEV_OP_TURBO_ENC) { + } else if (type == RTE_BBDEV_OP_TURBO_ENC || + type == RTE_BBDEV_OP_LDPC_ENC) { struct rte_bbdev_enc_op *op = element; memset(op, 0, mempool->elt_size); op->mempool = mempool; @@ -1117,6 +1123,8 @@ struct rte_mempool * __rte_experimental "RTE_BBDEV_OP_NONE", "RTE_BBDEV_OP_TURBO_DEC", "RTE_BBDEV_OP_TURBO_ENC", + "RTE_BBDEV_OP_LDPC_DEC", + "RTE_BBDEV_OP_LDPC_ENC", }; if (op_type < RTE_BBDEV_OP_TYPE_COUNT) diff --git a/lib/librte_bbdev/rte_bbdev.h b/lib/librte_bbdev/rte_bbdev.h index d131692..63e382d 100644 --- a/lib/librte_bbdev/rte_bbdev.h +++ b/lib/librte_bbdev/rte_bbdev.h @@ -43,7 +43,7 @@ #define RTE_BBDEV_MAX_DEVS 128 /**< Max number of devices */ #endif -/** Flags indicate current state of BBDEV device */ +/** Flags indiciate current state of BBDEV device */ enum rte_bbdev_state { RTE_BBDEV_UNUSED, RTE_BBDEV_INITIALIZED @@ -161,7 +161,7 @@ struct rte_bbdev_queue_conf { /** * Start a device. - * This is the last step needed before enqueuing operations is possible. + * This is the last step needed before enqueueing operations is possible. * * @param dev_id * The identifier of the device. @@ -313,7 +313,7 @@ struct rte_bbdev_driver_info { struct rte_bbdev_info { int socket_id; /**< NUMA socket that device is on */ const char *dev_name; /**< Unique device name */ - const struct rte_bus *bus; /**< Bus information */ + const struct rte_device *device; /**< Device Information */ uint16_t num_queues; /**< Number of queues currently configured */ bool started; /**< Set if device is currently started */ struct rte_bbdev_driver_info drv; /**< Info from device driver */ @@ -433,6 +433,14 @@ struct __rte_cache_aligned rte_bbdev { rte_bbdev_dequeue_enc_ops_t dequeue_enc_ops; /**< Dequeue decode function */ rte_bbdev_dequeue_dec_ops_t dequeue_dec_ops; + /**< Enqueue encode function */ + rte_bbdev_enqueue_enc_ops_t enqueue_ldpc_enc_ops; + /**< Enqueue decode function */ + rte_bbdev_enqueue_dec_ops_t enqueue_ldpc_dec_ops; + /**< Dequeue encode function */ + rte_bbdev_dequeue_enc_ops_t dequeue_ldpc_enc_ops; + /**< Dequeue decode function */ + rte_bbdev_dequeue_dec_ops_t dequeue_ldpc_dec_ops; const struct rte_bbdev_ops *dev_ops; /**< Functions exported by PMD */ struct rte_bbdev_data *data; /**< Pointer to device data */ enum rte_bbdev_state state; /**< If device is currently used or not */ @@ -506,6 +514,67 @@ struct __rte_cache_aligned rte_bbdev { } /** + * Enqueue a burst of processed encode operations to a queue of the device. + * This functions only enqueues as many operations as currently possible and + * does not block until @p num_ops entries in the queue are available. + * This function does not provide any error notification to avoid the + * corresponding overhead. + * + * @param dev_id + * The identifier of the device. + * @param queue_id + * The index of the queue. + * @param ops + * Pointer array containing operations to be enqueued Must have at least + * @p num_ops entries + * @param num_ops + * The maximum number of operations to enqueue. + * + * @return + * The number of operations actually enqueued (this is the number of processed + * entries in the @p ops array). + */ +static inline uint16_t __rte_experimental +rte_bbdev_enqueue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id, + struct rte_bbdev_enc_op **ops, uint16_t num_ops) +{ + struct rte_bbdev *dev = &rte_bbdev_devices[dev_id]; + struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id]; + return dev->enqueue_ldpc_enc_ops(q_data, ops, num_ops); +} + +/** + * Enqueue a burst of processed decode operations to a queue of the device. + * This functions only enqueues as many operations as currently possible and + * does not block until @p num_ops entries in the queue are available. + * This function does not provide any error notification to avoid the + * corresponding overhead. + * + * @param dev_id + * The identifier of the device. + * @param queue_id + * The index of the queue. + * @param ops + * Pointer array containing operations to be enqueued Must have at least + * @p num_ops entries + * @param num_ops + * The maximum number of operations to enqueue. + * + * @return + * The number of operations actually enqueued (this is the number of processed + * entries in the @p ops array). + */ +static inline uint16_t __rte_experimental +rte_bbdev_enqueue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id, + struct rte_bbdev_dec_op **ops, uint16_t num_ops) +{ + struct rte_bbdev *dev = &rte_bbdev_devices[dev_id]; + struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id]; + return dev->enqueue_ldpc_dec_ops(q_data, ops, num_ops); +} + + +/** * Dequeue a burst of processed encode operations from a queue of the device. * This functions returns only the current contents of the queue, and does not * block until @ num_ops is available. @@ -566,6 +635,68 @@ struct __rte_cache_aligned rte_bbdev { return dev->dequeue_dec_ops(q_data, ops, num_ops); } + +/** + * Dequeue a burst of processed encode operations from a queue of the device. + * This functions returns only the current contents of the queue, and does not + * block until @ num_ops is available. + * This function does not provide any error notification to avoid the + * corresponding overhead. + * + * @param dev_id + * The identifier of the device. + * @param queue_id + * The index of the queue. + * @param ops + * Pointer array where operations will be dequeued to. Must have at least + * @p num_ops entries + * @param num_ops + * The maximum number of operations to dequeue. + * + * @return + * The number of operations actually dequeued (this is the number of entries + * copied into the @p ops array). + */ +static inline uint16_t __rte_experimental +rte_bbdev_dequeue_ldpc_enc_ops(uint16_t dev_id, uint16_t queue_id, + struct rte_bbdev_enc_op **ops, uint16_t num_ops) +{ + struct rte_bbdev *dev = &rte_bbdev_devices[dev_id]; + struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id]; + return dev->dequeue_ldpc_enc_ops(q_data, ops, num_ops); +} + +/** + * Dequeue a burst of processed decode operations from a queue of the device. + * This functions returns only the current contents of the queue, and does not + * block until @ num_ops is available. + * This function does not provide any error notification to avoid the + * corresponding overhead. + * + * @param dev_id + * The identifier of the device. + * @param queue_id + * The index of the queue. + * @param ops + * Pointer array where operations will be dequeued to. Must have at least + * @p num_ops entries + * @param num_ops + * The maximum number of operations to dequeue. + * + * @return + * The number of operations actually dequeued (this is the number of entries + * copied into the @p ops array). + */ + +static inline uint16_t __rte_experimental +rte_bbdev_dequeue_ldpc_dec_ops(uint16_t dev_id, uint16_t queue_id, + struct rte_bbdev_dec_op **ops, uint16_t num_ops) +{ + struct rte_bbdev *dev = &rte_bbdev_devices[dev_id]; + struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id]; + return dev->dequeue_ldpc_dec_ops(q_data, ops, num_ops); +} + /** Definitions of device event types */ enum rte_bbdev_event_type { RTE_BBDEV_EVENT_UNKNOWN, /**< unknown event type */ diff --git a/lib/librte_bbdev/rte_bbdev_op.h b/lib/librte_bbdev/rte_bbdev_op.h index 6be53f5..7ae6877 100644 --- a/lib/librte_bbdev/rte_bbdev_op.h +++ b/lib/librte_bbdev/rte_bbdev_op.h @@ -26,62 +26,66 @@ #include /* Number of columns in sub-block interleaver (36.212, section 5.1.4.1.1) */ -#define RTE_BBDEV_C_SUBBLOCK (32) +#define RTE_BBDEV_TURBO_C_SUBBLOCK (32) /* Maximum size of Transport Block (36.213, Table, Table 7.1.7.2.5-1) */ -#define RTE_BBDEV_MAX_TB_SIZE (391656) +#define RTE_BBDEV_TURBO_MAX_TB_SIZE (391656) /* Maximum size of Code Block (36.212, Table 5.1.3-3) */ -#define RTE_BBDEV_MAX_CB_SIZE (6144) +#define RTE_BBDEV_TURBO_MAX_CB_SIZE (6144) +/* Maximum size of Code Block */ +#define RTE_BBDEV_LDPC_MAX_CB_SIZE (8448) /* Minimum size of Code Block (36.212, Table 5.1.3-3) */ -#define RTE_BBDEV_MIN_CB_SIZE (40) +#define RTE_BBDEV_TURBO_MIN_CB_SIZE (40) /* Maximum size of circular buffer */ -#define RTE_BBDEV_MAX_KW (18528) +#define RTE_BBDEV_TURBO_MAX_KW (18528) /* - * Maximum number of Code Blocks in Transport Block. It is calculated based on - * maximum size of one Code Block and one Transport Block (considering CRC24A - * and CRC24B): + * Turbo: Maximum number of Code Blocks in Transport Block. It is calculated + * based on maximum size of one Code Block and one Transport Block + * (considering CRC24A and CRC24B): * (391656 + 24) / (6144 - 24) = 64 */ -#define RTE_BBDEV_MAX_CODE_BLOCKS (64) +#define RTE_BBDEV_TURBO_MAX_CODE_BLOCKS (64) +/* LDPC: Maximum number of Code Blocks in Transport Block.*/ +#define RTE_BBDEV_LDPC_MAX_CODE_BLOCKS (256) /** Flags for turbo decoder operation and capability structure */ enum rte_bbdev_op_td_flag_bitmasks { - /**< If sub block de-interleaving is to be performed. */ + /** If sub block de-interleaving is to be performed. */ RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE = (1ULL << 0), - /**< To use CRC Type 24B (otherwise use CRC Type 24A). */ + /** To use CRC Type 24B (otherwise use CRC Type 24A). */ RTE_BBDEV_TURBO_CRC_TYPE_24B = (1ULL << 1), - /**< If turbo equalization is to be performed. */ + /** If turbo equalization is to be performed. */ RTE_BBDEV_TURBO_EQUALIZER = (1ULL << 2), - /**< If set, saturate soft output to +/-127 */ + /** If set, saturate soft output to +/-127 */ RTE_BBDEV_TURBO_SOFT_OUT_SATURATE = (1ULL << 3), - /**< Set to 1 to start iteration from even, else odd; one iteration = + /** Set to 1 to start iteration from even, else odd; one iteration = * max_iteration + 0.5 */ RTE_BBDEV_TURBO_HALF_ITERATION_EVEN = (1ULL << 4), - /**< If 0, TD stops after CRC matches; else if 1, runs to end of next + /** If 0, TD stops after CRC matches; else if 1, runs to end of next * odd iteration after CRC matches */ RTE_BBDEV_TURBO_CONTINUE_CRC_MATCH = (1ULL << 5), - /**< Set if soft output is required to be output */ + /** Set if soft output is required to be output */ RTE_BBDEV_TURBO_SOFT_OUTPUT = (1ULL << 6), - /**< Set to enable early termination mode */ + /** Set to enable early termination mode */ RTE_BBDEV_TURBO_EARLY_TERMINATION = (1ULL << 7), - /**< Set if a device supports decoder dequeue interrupts */ + /** Set if a device supports decoder dequeue interrupts */ RTE_BBDEV_TURBO_DEC_INTERRUPTS = (1ULL << 9), - /**< Set if positive LLR encoded input is supported. Positive LLR value + /** Set if positive LLR encoded input is supported. Positive LLR value * represents the level of confidence for bit '1', and vice versa for * bit '0'. * This is mutually exclusive with RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN * when used to formalize the input data format. */ RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN = (1ULL << 10), - /**< Set if negative LLR encoded input is supported. Negative LLR value + /** Set if negative LLR encoded input is supported. Negative LLR value * represents the level of confidence for bit '1', and vice versa for * bit '0'. * This is mutually exclusive with RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN * when used to formalize the input data format. */ RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN = (1ULL << 11), - /**< Set if positive LLR soft output is supported. Positive LLR value + /** Set if positive LLR soft output is supported. Positive LLR value * represents the level of confidence for bit '1', and vice versa for * bit '0'. * This is mutually exclusive with @@ -89,7 +93,7 @@ enum rte_bbdev_op_td_flag_bitmasks { * the input data format. */ RTE_BBDEV_TURBO_POS_LLR_1_BIT_SOFT_OUT = (1ULL << 12), - /**< Set if negative LLR soft output is supported. Negative LLR value + /** Set if negative LLR soft output is supported. Negative LLR value * represents the level of confidence for bit '1', and vice versa for * bit '0'. * This is mutually exclusive with @@ -97,43 +101,110 @@ enum rte_bbdev_op_td_flag_bitmasks { * input data format. */ RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT = (1ULL << 13), - /**< Set if driver supports flexible parallel MAP engine decoding. If + /** Set if driver supports flexible parallel MAP engine decoding. If * not supported, num_maps (number of MAP engines) argument is unusable. */ RTE_BBDEV_TURBO_MAP_DEC = (1ULL << 14), - /**< Set if a device supports scatter-gather functionality */ + /** Set if a device supports scatter-gather functionality */ RTE_BBDEV_TURBO_DEC_SCATTER_GATHER = (1ULL << 15), - /**< Set to keep CRC24B bits appended while decoding. Only usable when + /** Set to keep CRC24B bits appended while decoding. Only usable when * decoding Transport Blocks (code_block_mode = 0). */ RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP = (1ULL << 16) }; + /** Flags for turbo encoder operation and capability structure */ enum rte_bbdev_op_te_flag_bitmasks { - /**< Ignore rv_index and set K0 = 0 */ + /** Ignore rv_index and set K0 = 0 */ RTE_BBDEV_TURBO_RV_INDEX_BYPASS = (1ULL << 0), - /**< If rate matching is to be performed */ + /** If rate matching is to be performed */ RTE_BBDEV_TURBO_RATE_MATCH = (1ULL << 1), - /**< This bit must be set to enable CRC-24B generation */ + /** This bit must be set to enable CRC-24B generation */ RTE_BBDEV_TURBO_CRC_24B_ATTACH = (1ULL << 2), - /**< This bit must be set to enable CRC-24A generation */ + /** This bit must be set to enable CRC-24A generation */ RTE_BBDEV_TURBO_CRC_24A_ATTACH = (1ULL << 3), - /**< Set if a device supports encoder dequeue interrupts */ + /** Set if a device supports encoder dequeue interrupts */ RTE_BBDEV_TURBO_ENC_INTERRUPTS = (1ULL << 4), - /**< Set if a device supports scatter-gather functionality */ + /** Set if a device supports scatter-gather functionality */ RTE_BBDEV_TURBO_ENC_SCATTER_GATHER = (1ULL << 5) }; -/**< Data input and output buffer for BBDEV operations */ +/** Flags for LDPC decoder operation and capability structure */ +enum rte_bbdev_op_ldpcdec_flag_bitmasks { + /** Set for transport block CRC-24A checking */ + RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK = (1ULL << 0), + /** Set for code block CRC-24B checking */ + RTE_BBDEV_LDPC_CRC_TYPE_24B_CHECK = (1ULL << 1), + /** Set to drop the last CRC bits decoding output */ + RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP = (1ULL << 2), + /** Set for bit-level de-interleaver bypass on Rx stream. */ + RTE_BBDEV_LDPC_DEINTERLEAVER_BYPASS = (1ULL << 3), + /** Set for HARQ combined input stream enable. */ + RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE = (1ULL << 4), + /** Set for HARQ combined output stream enable. */ + RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE = (1ULL << 5), + /** Set for LDPC decoder bypass. + * RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE must be set. + */ + RTE_BBDEV_LDPC_DECODE_BYPASS = (1ULL << 6), + /** Set for soft-output stream enable */ + RTE_BBDEV_LDPC_SOFT_OUT_ENABLE = (1ULL << 7), + /** Set for Rate-Matching bypass on soft-out stream. */ + RTE_BBDEV_LDPC_SOFT_OUT_RM_BYPASS = (1ULL << 8), + /** Set for bit-level de-interleaver bypass on soft-output stream. */ + RTE_BBDEV_LDPC_SOFT_OUT_DEINTERLEAVER_BYPASS = (1ULL << 9), + /** Set for iteration stopping on successful decode condition + * i.e. a successful syndrome check. + */ + RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE = (1ULL << 10), + /** Set if a device supports decoder dequeue interrupts. */ + RTE_BBDEV_LDPC_DEC_INTERRUPTS = (1ULL << 11), + /** Set if a device supports scatter-gather functionality. */ + RTE_BBDEV_LDPC_DEC_SCATTER_GATHER = (1ULL << 12), + /** Set if a device supports input/output HARQ compression. */ + RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION = (1ULL << 13), + /** Set if a device supports input LLR compression. */ + RTE_BBDEV_LDPC_LLR_COMPRESSION = (1ULL << 14), + /** Set if a device supports HARQ input from + * device's internal memory. + */ + RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE = (1ULL << 15), + /** Set if a device supports HARQ output to + * device's internal memory. + */ + RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE = (1ULL << 16) +}; + +/** Flags for LDPC encoder operation and capability structure */ +enum rte_bbdev_op_ldpcenc_flag_bitmasks { + /** Set for bit-level interleaver bypass on output stream. */ + RTE_BBDEV_LDPC_INTERLEAVER_BYPASS = (1ULL << 0), + /** If rate matching is to be performed */ + RTE_BBDEV_LDPC_RATE_MATCH = (1ULL << 1), + /** Set for transport block CRC-24A attach */ + RTE_BBDEV_LDPC_CRC_24A_ATTACH = (1ULL << 2), + /** Set for code block CRC-24B attach */ + RTE_BBDEV_LDPC_CRC_24B_ATTACH = (1ULL << 3), + /** Set for code block CRC-16 attach */ + RTE_BBDEV_LDPC_CRC_16_ATTACH = (1ULL << 4), + /** Set if a device supports encoder dequeue interrupts. */ + RTE_BBDEV_LDPC_ENC_INTERRUPTS = (1ULL << 5), + /** Set if a device supports scatter-gather functionality. */ + RTE_BBDEV_LDPC_ENC_SCATTER_GATHER = (1ULL << 6), + /** Set if a device supports concatenation of non byte aligned output */ + RTE_BBDEV_LDPC_ENC_CONCATENATION = (1ULL << 7) +}; + +/** Data input and output buffer for BBDEV operations */ struct rte_bbdev_op_data { - /**< The mbuf data structure representing the data for BBDEV operation. + /** The mbuf data structure representing the data for BBDEV operation. * * This mbuf pointer can point to one Code Block (CB) data buffer or * multiple CBs contiguously located next to each other. * A Transport Block (TB) represents a whole piece of data that is * divided into one or more CBs. Maximum number of CBs can be contained - * in one TB is defined by RTE_BBDEV_MAX_CODE_BLOCKS. + * in one TB is defined by RTE_BBDEV_(TURBO/LDPC)_MAX_CODE_BLOCKS. * * An mbuf data structure cannot represent more than one TB. The * smallest piece of data that can be contained in one mbuf is one CB. @@ -145,8 +216,8 @@ struct rte_bbdev_op_data { * then it is capable of collecting (gathering) non-contiguous * (scattered) data from multiple locations in the memory. * This capability is reported by the capability flags: - * - RTE_BBDEV_TURBO_ENC_SCATTER_GATHER and - * - RTE_BBDEV_TURBO_DEC_SCATTER_GATHER. + * - RTE_BBDEV_(TURBO/LDPC)_ENC_SCATTER_GATHER and + * - RTE_BBDEV_(TURBO/LDPC)_DEC_SCATTER_GATHER. * Only if a BBDEV PMD supports this feature, chained mbuf data * structures are accepted. A chained mbuf can represent one * non-contiguous CB or multiple non-contiguous CBs. @@ -157,7 +228,7 @@ struct rte_bbdev_op_data { * was a chained mbuf. */ struct rte_mbuf *data; - /**< The starting point of the BBDEV (encode/decode) operation, + /** The starting point of the BBDEV (encode/decode) operation, * in bytes. * * BBDEV starts to read data past this offset. @@ -165,13 +236,13 @@ struct rte_bbdev_op_data { * segment. */ uint32_t offset; - /**< The total data length to be processed in one operation, in bytes. + /** The total data length to be processed in one operation, in bytes. * * In case the mbuf data is representing one CB, this is the length of * the CB undergoing the operation. * If it's for multiple CBs, this is the total length of those CBs * undergoing the operation. - * If it's for one TB, this is the total length of the TB under + * If it is for one TB, this is the total length of the TB under * operation. * * In case of chained mbuf, this data length includes the lengths of the @@ -180,51 +251,83 @@ struct rte_bbdev_op_data { uint32_t length; }; -struct rte_bbdev_op_dec_cb_params { - /**< The K size of the input CB, in bits [40:6144], as specified in +/** Turbo decode code block parameters */ +struct rte_bbdev_op_dec_turbo_cb_params { + /** The K size of the input CB, in bits [40:6144], as specified in * 3GPP TS 36.212. * This size is inclusive of CRC bits, regardless whether it was * pre-calculated by the application or not. */ uint16_t k; - /**< The E length of the CB rate matched LLR output, in bytes, as in + /** The E length of the CB rate matched LLR output, in bytes, as in * 3GPP TS 36.212. */ uint32_t e; }; -struct rte_bbdev_op_dec_tb_params { - /**< The K- size of the input CB, in bits [40:6144], that is in the +/** LDPC decode code block parameters */ +struct rte_bbdev_op_dec_ldpc_cb_params { + /** Rate matching output sequence length in bits or LLRs. + * [3GPP TS38.212, section 5.4.2.1] + */ + uint32_t e; +}; + +/** Turbo decode transport block parameters */ +struct rte_bbdev_op_dec_turbo_tb_params { + /** The K- size of the input CB, in bits [40:6144], that is in the * Turbo operation when r < C-, as in 3GPP TS 36.212. */ uint16_t k_neg; - /**< The K+ size of the input CB, in bits [40:6144], that is in the + /** The K+ size of the input CB, in bits [40:6144], that is in the * Turbo operation when r >= C-, as in 3GPP TS 36.212. */ uint16_t k_pos; - /**< The number of CBs that have K- size, [0:63] */ + /** The number of CBs that have K- size, [0:63] */ uint8_t c_neg; - /**< The total number of CBs in the TB, [1:RTE_BBDEV_MAX_CODE_BLOCKS] */ + /** The total number of CBs in the TB, + * [1:RTE_BBDEV_TURBO_MAX_CODE_BLOCKS] + */ uint8_t c; - /**< The number of CBs that uses Ea before switching to Eb, [0:63] */ + /** The number of CBs that uses Ea before switching to Eb, [0:63] */ uint8_t cab; - /**< The E size of the CB rate matched output to use in the Turbo + /** The E size of the CB rate matched output to use in the Turbo * operation when r < cab */ uint32_t ea; - /**< The E size of the CB rate matched output to use in the Turbo + /** The E size of the CB rate matched output to use in the Turbo * operation when r >= cab */ uint32_t eb; - /**< The index of the first CB in the inbound mbuf data, default is 0 */ + /** The index of the first CB in the inbound mbuf data, default is 0 */ + uint8_t r; +}; + +/** LDPC decode transport block parameters */ +struct rte_bbdev_op_dec_ldpc_tb_params { + /** Ea, length after rate matching in bits, r < cab. + * [3GPP TS38.212, section 5.4.2.1] + */ + uint32_t ea; + /** Eb, length after rate matching in bits, r >= cab. + * [3GPP TS38.212, section 5.4.2.1] + */ + uint32_t eb; + /** The total number of CBs in the TB or partial TB + * [1:RTE_BBDEV_LDPC_MAX_CODE_BLOCKS] + */ + uint8_t c; + /** The index of the first CB in the inbound mbuf data, default is 0 */ uint8_t r; + /** The number of CBs that use Ea before switching to Eb, [0:63] */ + uint8_t cab; }; -/**< Operation structure for Turbo decode. - * An operation can perform on one CB at a time "CB-mode". - * An operation can perform on one or multiple CBs that are logically belonging - * to one TB "TB-mode". - * The provided K size parameter of the CB is its size out coming from the +/** Operation structure for Turbo decode. + * An operation can be performed on one CB at a time "CB-mode". + * An operation can be performed on one or multiple CBs that logically + * belong to one TB "TB-mode". + * The provided K size parameter of the CB is its size coming from the * decode operation. * CRC24A/B check is requested by the application by setting the flag * RTE_BBDEV_TURBO_CRC_TYPE_24B for CRC24B check or CRC24A otherwise. @@ -249,94 +352,192 @@ struct rte_bbdev_op_dec_tb_params { * application with enough room for the output data. */ struct rte_bbdev_op_turbo_dec { - /**< The Virtual Circular Buffer, wk, size 3*Kpi for each CB */ + /** The Virtual Circular Buffer, wk, size 3*Kpi for each CB */ struct rte_bbdev_op_data input; - /**< The hard decisions buffer for the decoded output, + /** The hard decisions buffer for the decoded output, * size K for each CB */ struct rte_bbdev_op_data hard_output; - /**< The soft LLR output buffer - optional */ + /** The soft LLR output buffer - optional */ struct rte_bbdev_op_data soft_output; - uint32_t op_flags; /**< Flags from rte_bbdev_op_td_flag_bitmasks */ - uint8_t rv_index; /**< Rv index for rate matching [0:3] */ - /**< The minimum number of iterations to perform in decoding all CBs in + /** Flags from rte_bbdev_op_td_flag_bitmasks */ + uint32_t op_flags; + + /** Rv index for rate matching [0:3] */ + uint8_t rv_index; + /** The minimum number of iterations to perform in decoding all CBs in * this operation - input */ uint8_t iter_min:4; - /**< The maximum number of iterations to perform in decoding all CBs in + /** The maximum number of iterations to perform in decoding all CBs in * this operation - input */ uint8_t iter_max:4; - /**< The maximum number of iterations that were perform in decoding all - * CBs in this decode operation - output + /** The maximum number of iterations that were performed in decoding + * all CBs in this decode operation - output */ uint8_t iter_count; - /**< 5 bit extrinsic scale (scale factor on extrinsic info) */ + /** 5 bit extrinsic scale (scale factor on extrinsic info) */ uint8_t ext_scale; - /**< Number of MAP engines to use in decode, - * must be power of 2 (or 0 to auto-select) + /** Number of MAP engines to use in decode, + * must be power of 2 (or 0 to auto-select) */ uint8_t num_maps; - uint8_t code_block_mode; /**< [0 - TB : 1 - CB] */ + /**< [0 - TB : 1 - CB] */ + uint8_t code_block_mode; union { /**< Struct which stores Code Block specific parameters */ - struct rte_bbdev_op_dec_cb_params cb_params; + struct rte_bbdev_op_dec_turbo_cb_params cb_params; /**< Struct which stores Transport Block specific parameters */ - struct rte_bbdev_op_dec_tb_params tb_params; + struct rte_bbdev_op_dec_turbo_tb_params tb_params; + }; +}; + +/** Operation structure for LDPC decode. + * + * An operation can be performed on one CB at a time "CB-mode". + * An operation can also be performed on one or multiple CBs that logically + * belong to a TB "TB-mode" (Currently not supported). + * + * The input encoded CB data is the Virtual Circular Buffer data stream. + * + * Each byte in the input circular buffer is the LLR value of each bit of the + * original CB. + * + * Hard output is a mandatory capability that all BBDEV PMDs support. This is + * the decoded CBs (CRC24A/B is the last 24-bit in each decoded CB). + * + * Soft output is an optional capability for BBDEV PMDs. If supported, an LLR + * rate matched output is computed in the soft_output buffer structure. + * These are A Posteriori Probabilities (APP) LLR samples for coded bits. + * + * HARQ combined output is an optional capability for BBDEV PMDs. + * If supported, a LLR output is streamed to the harq_combined_output + * buffer. + * + * HARQ combined input is an optional capability for BBDEV PMDs. + * If supported, a LLR input is streamed from the harq_combined_input + * buffer. + * + * The output mbuf data structure is expected to be allocated by the + * application with enough room for the output data. + */ +struct rte_bbdev_op_ldpc_dec { + /** The Virtual Circular Buffer for this code block, one LLR + * per bit of the original CB. + */ + struct rte_bbdev_op_data input; + /** The hard decisions buffer for the decoded output, + * size K for each CB + */ + struct rte_bbdev_op_data hard_output; + /** The soft LLR output LLR stream buffer - optional */ + struct rte_bbdev_op_data soft_output; + /** The HARQ combined LLR stream input buffer - optional */ + struct rte_bbdev_op_data harq_combined_input; + /** The HARQ combined LLR stream output buffer - optional */ + struct rte_bbdev_op_data harq_combined_output; + + /** Flags from rte_bbdev_op_ldpcdec_flag_bitmasks */ + uint32_t op_flags; + + /** Rate matching redundancy version + * [3GPP TS38.212, section 5.4.2.1] + */ + uint8_t rv_index; + /** The maximum number of iterations to perform in decoding CB in + * this operation - input + */ + uint8_t iter_max; + /** The number of iterations that were performed in decoding + * CB in this decode operation - output + */ + uint8_t iter_count; + /** 1: LDPC Base graph 1, 2: LDPC Base graph 2. + * [3GPP TS38.212, section 5.2.2] + */ + uint8_t basegraph; + /** Zc, LDPC lifting size. + * [3GPP TS38.212, section 5.2.2] + */ + uint16_t z_c; + /** Ncb, length of the circular buffer in bits. + * [3GPP TS38.212, section 5.4.2.1] + */ + uint16_t n_cb; + /** Qm, modulation order {2,4,6,8,10}. + * [3GPP TS38.212, section 5.4.2.2] + */ + uint8_t q_m; + /** Number of Filler bits, n_filler = K – K’ + * [3GPP TS38.212 section 5.2.2] + */ + uint16_t n_filler; + /** [0 - TB : 1 - CB] */ + uint8_t code_block_mode; + union { + /** Struct which stores Code Block specific parameters */ + struct rte_bbdev_op_dec_ldpc_cb_params cb_params; + /** Struct which stores Transport Block specific parameters */ + struct rte_bbdev_op_dec_ldpc_tb_params tb_params; }; }; -struct rte_bbdev_op_enc_cb_params { - /**< The K size of the input CB, in bits [40:6144], as specified in +/** Turbo encode code block parameters */ +struct rte_bbdev_op_enc_turbo_cb_params { + /** The K size of the input CB, in bits [40:6144], as specified in * 3GPP TS 36.212. * This size is inclusive of CRC24A, regardless whether it was * pre-calculated by the application or not. */ uint16_t k; - /**< The E length of the CB rate matched output, in bits, as in + /** The E length of the CB rate matched output, in bits, as in * 3GPP TS 36.212. */ uint32_t e; - /**< The Ncb soft buffer size of the CB rate matched output [K:3*Kpi], + /** The Ncb soft buffer size of the CB rate matched output [K:3*Kpi], * in bits, as specified in 3GPP TS 36.212. */ uint16_t ncb; }; -struct rte_bbdev_op_enc_tb_params { - /**< The K- size of the input CB, in bits [40:6144], that is in the +/** Turbo encode transport block parameters */ +struct rte_bbdev_op_enc_turbo_tb_params { + /** The K- size of the input CB, in bits [40:6144], that is in the * Turbo operation when r < C-, as in 3GPP TS 36.212. * This size is inclusive of CRC24B, regardless whether it was * pre-calculated and appended by the application or not. */ uint16_t k_neg; - /**< The K+ size of the input CB, in bits [40:6144], that is in the + /** The K+ size of the input CB, in bits [40:6144], that is in the * Turbo operation when r >= C-, as in 3GPP TS 36.212. * This size is inclusive of CRC24B, regardless whether it was * pre-calculated and appended by the application or not. */ uint16_t k_pos; - /**< The number of CBs that have K- size, [0:63] */ + /** The number of CBs that have K- size, [0:63] */ uint8_t c_neg; - /**< The total number of CBs in the TB, [1:RTE_BBDEV_MAX_CODE_BLOCKS] */ + /** The total number of CBs in the TB, + * [1:RTE_BBDEV_TURBO_MAX_CODE_BLOCKS] + */ uint8_t c; - /**< The number of CBs that uses Ea before switching to Eb, [0:63] */ + /** The number of CBs that uses Ea before switching to Eb, [0:63] */ uint8_t cab; - /**< The E size of the CB rate matched output to use in the Turbo + /** The E size of the CB rate matched output to use in the Turbo * operation when r < cab */ uint32_t ea; - /**< The E size of the CB rate matched output to use in the Turbo + /** The E size of the CB rate matched output to use in the Turbo * operation when r >= cab */ uint32_t eb; - /**< The Ncb soft buffer size for the rate matched CB that is used in + /** The Ncb soft buffer size for the rate matched CB that is used in * the Turbo operation when r < C-, [K:3*Kpi] */ uint16_t ncb_neg; - /**< The Ncb soft buffer size for the rate matched CB that is used in + /** The Ncb soft buffer size for the rate matched CB that is used in * the Turbo operation when r >= C-, [K:3*Kpi] */ uint16_t ncb_pos; @@ -344,10 +545,38 @@ struct rte_bbdev_op_enc_tb_params { uint8_t r; }; -/**< Operation structure for Turbo encode. - * An operation can perform on one CB at a time "CB-mode". - * An operation can perform on one or multiple CBs that are logically - * belonging to one TB "TB-mode". +/** LDPC encode code block parameters */ +struct rte_bbdev_op_enc_ldpc_cb_params { + /** E, length after rate matching in bits. + * [3GPP TS38.212, section 5.4.2.1] + */ + uint32_t e; +}; + +/** LDPC encode transport block parameters */ +struct rte_bbdev_op_enc_ldpc_tb_params { + /** Ea, length after rate matching in bits, r < cab. + * [3GPP TS38.212, section 5.4.2.1] + */ + uint32_t ea; + /** Eb, length after rate matching in bits, r >= cab. + * [3GPP TS38.212, section 5.4.2.1] + */ + uint32_t eb; + /** The total number of CBs in the TB or partial TB + * [1:RTE_BBDEV_LDPC_MAX_CODE_BLOCKS] + */ + uint8_t c; + /** The index of the first CB in the inbound mbuf data, default is 0 */ + uint8_t r; + /** The number of CBs that use Ea before switching to Eb, [0:63] */ + uint8_t cab; +}; + +/** Operation structure for Turbo encode. + * An operation can be performed on one CB at a time "CB-mode". + * An operation can pbe erformd on one or multiple CBs that logically + * belong to one TB "TB-mode". * * In CB-mode, CRC24A/B is an optional operation. K size parameter is not * affected by CRC24A/B inclusion, this only affects the inbound mbuf data @@ -364,44 +593,127 @@ struct rte_bbdev_op_enc_tb_params { * application with enough room for the output data. */ struct rte_bbdev_op_turbo_enc { - /**< The input CB or TB data */ + /** The input CB or TB data */ + struct rte_bbdev_op_data input; + /** The rate matched CB or TB output buffer */ + struct rte_bbdev_op_data output; + /** Flags from rte_bbdev_op_te_flag_bitmasks */ + uint32_t op_flags; + + /** Rv index for rate matching [0:3] */ + uint8_t rv_index; + /** [0 - TB : 1 - CB] */ + uint8_t code_block_mode; + union { + /** Struct which stores Code Block specific parameters */ + struct rte_bbdev_op_enc_turbo_cb_params cb_params; + /** Struct which stores Transport Block specific parameters */ + struct rte_bbdev_op_enc_turbo_tb_params tb_params; + }; +}; + +/** Operation structure for LDPC encode. + * An operation can be performed on one CB at a time "CB-mode". + * An operation can be performed on one or multiple CBs that logically + * belong to a TB "TB-mode". + * + * The input data is the CB or TB input to the decoder. + * + * The output data is the ratematched CB or TB data, or the output after + * bit-selection if RTE_BBDEV_LDPC_INTERLEAVER_BYPASS is set. + * + * The output mbuf data structure is expected to be allocated by the + * application with enough room for the output data. + */ +struct rte_bbdev_op_ldpc_enc { + /** The input TB or CB data */ struct rte_bbdev_op_data input; - /**< The rate matched CB or TB output buffer */ + /** The rate matched TB or CB output buffer */ struct rte_bbdev_op_data output; - uint32_t op_flags; /**< Flags from rte_bbdev_op_te_flag_bitmasks */ - uint8_t rv_index; /**< Rv index for rate matching [0:3] */ + /** Flags from rte_bbdev_op_ldpcenc_flag_bitmasks */ + uint32_t op_flags; - uint8_t code_block_mode; /**< [0 - TB : 1 - CB] */ + /** Rate matching redundancy version */ + uint8_t rv_index; + /** 0:Basegraph 0, 1: Basegraph 1. */ + uint8_t basegraph; + /** Zc, LDPC lifting size. + * [3GPP TS38.212, section 5.2.2] + */ + uint16_t z_c; + /** Ncb, length of the circular buffer in bits. + * [3GPP TS38.212, section 5.4.2.1] + */ + uint16_t n_cb; + /** Qm, modulation order {2,4,6,8,10}. + * [3GPP TS38.212, section 5.4.2.2] + */ + uint8_t q_m; + /** Number of Filler bits, n_filler = K – K’ + * [3GPP TS38.212 section 5.2.2] + */ + uint16_t n_filler; + /** [0 - TB : 1 - CB] */ + uint8_t code_block_mode; union { - /**< Struct which stores Code Block specific parameters */ - struct rte_bbdev_op_enc_cb_params cb_params; - /**< Struct which stores Transport Block specific parameters */ - struct rte_bbdev_op_enc_tb_params tb_params; + /** Struct which stores Code Block specific parameters */ + struct rte_bbdev_op_enc_ldpc_cb_params cb_params; + /** Struct which stores Transport Block specific parameters */ + struct rte_bbdev_op_enc_ldpc_tb_params tb_params; }; }; -/**< List of the capabilities for the Turbo Decoder */ +/** List of the capabilities for the Turbo Decoder */ struct rte_bbdev_op_cap_turbo_dec { - /**< Flags from rte_bbdev_op_td_flag_bitmasks */ + /** Flags from rte_bbdev_op_td_flag_bitmasks */ uint32_t capability_flags; /** Maximal LLR absolute value. Acceptable LLR values lie in range * [-max_llr_modulus, max_llr_modulus]. */ int8_t max_llr_modulus; + /** Num input code block buffers */ uint8_t num_buffers_src; /**< Num input code block buffers */ - /**< Num hard output code block buffers */ + /** Num hard output code block buffers */ uint8_t num_buffers_hard_out; - /**< Num soft output code block buffers if supported by the driver */ + /** Num soft output code block buffers if supported by the driver */ uint8_t num_buffers_soft_out; }; -/**< List of the capabilities for the Turbo Encoder */ +/** List of the capabilities for the Turbo Encoder */ struct rte_bbdev_op_cap_turbo_enc { - /**< Flags from rte_bbdev_op_te_flag_bitmasks */ + /** Flags from rte_bbdev_op_te_flag_bitmasks */ uint32_t capability_flags; - uint8_t num_buffers_src; /**< Num input code block buffers */ - uint8_t num_buffers_dst; /**< Num output code block buffers */ + /** Num input code block buffers */ + uint8_t num_buffers_src; + /** Num output code block buffers */ + uint8_t num_buffers_dst; +}; + +/** List of the capabilities for the LDPC Decoder */ +struct rte_bbdev_op_cap_ldpc_dec { + /** Flags from rte_bbdev_op_ldpcdec_flag_bitmasks */ + uint32_t capability_flags; + /** LLR size in bits. LLR is a two’s complement number. */ + int8_t llr_size; + /** LLR numbers of decimals bit for arithmetic representation */ + int8_t llr_decimals; + /** Num input code block buffers */ + uint16_t num_buffers_src; + /** Num hard output code block buffers */ + uint16_t num_buffers_hard_out; + /** Num soft output code block buffers if supported by the driver */ + uint16_t num_buffers_soft_out; +}; + +/** List of the capabilities for the LDPC Encoder */ +struct rte_bbdev_op_cap_ldpc_enc { + /** Flags from rte_bbdev_op_ldpcenc_flag_bitmasks */ + uint32_t capability_flags; + /** Num input code block buffers */ + uint16_t num_buffers_src; + /** Num output code block buffers */ + uint16_t num_buffers_dst; }; /** Different operation types supported by the device */ @@ -409,40 +721,59 @@ enum rte_bbdev_op_type { RTE_BBDEV_OP_NONE, /**< Dummy operation that does nothing */ RTE_BBDEV_OP_TURBO_DEC, /**< Turbo decode */ RTE_BBDEV_OP_TURBO_ENC, /**< Turbo encode */ + RTE_BBDEV_OP_LDPC_DEC, /**< LDPC decode */ + RTE_BBDEV_OP_LDPC_ENC, /**< LDPC encode */ RTE_BBDEV_OP_TYPE_COUNT, /**< Count of different op types */ }; -/**< Bit indexes of possible errors reported through status field */ +/** Bit indexes of possible errors reported through status field */ enum { RTE_BBDEV_DRV_ERROR, RTE_BBDEV_DATA_ERROR, RTE_BBDEV_CRC_ERROR, + RTE_BBDEV_SYNDROME_ERROR }; -/**< Structure specifying a single encode operation */ +/** Structure specifying a single encode operation */ struct rte_bbdev_enc_op { - int status; /**< Status of operation that was performed */ - struct rte_mempool *mempool; /**< Mempool which op instance is in */ - void *opaque_data; /**< Opaque pointer for user data */ - /**< Contains encoder specific parameters */ - struct rte_bbdev_op_turbo_enc turbo_enc; + /**< Status of operation that was performed */ + int status; + /**< Mempool which op instance is in */ + struct rte_mempool *mempool; + /**< Opaque pointer for user data */ + void *opaque_data; + union { + /** Contains turbo decoder specific parameters */ + struct rte_bbdev_op_turbo_enc turbo_enc; + /** Contains LDPC decoder specific parameters */ + struct rte_bbdev_op_ldpc_enc ldpc_enc; + }; }; -/**< Structure specifying a single decode operation */ +/** Structure specifying a single decode operation */ struct rte_bbdev_dec_op { - int status; /**< Status of operation that was performed */ - struct rte_mempool *mempool; /**< Mempool which op instance is in */ - void *opaque_data; /**< Opaque pointer for user data */ - /**< Contains decoder specific parameters */ - struct rte_bbdev_op_turbo_dec turbo_dec; + /** Status of operation that was performed */ + int status; + /** Mempool which op instance is in */ + struct rte_mempool *mempool; + /** Opaque pointer for user data */ + void *opaque_data; + union { + /** Contains turbo decoder specific parameters */ + struct rte_bbdev_op_turbo_dec turbo_dec; + /** Contains LDPC decoder specific parameters */ + struct rte_bbdev_op_ldpc_dec ldpc_dec; + }; }; -/**< Operation capabilities supported by a device */ +/** Operation capabilities supported by a device */ struct rte_bbdev_op_cap { enum rte_bbdev_op_type type; /**< Type of operation */ union { struct rte_bbdev_op_cap_turbo_dec turbo_dec; struct rte_bbdev_op_cap_turbo_enc turbo_enc; + struct rte_bbdev_op_cap_ldpc_dec ldpc_dec; + struct rte_bbdev_op_cap_ldpc_enc ldpc_enc; } cap; /**< Operation-type specific capabilities */ }; @@ -513,7 +844,8 @@ struct rte_mempool * __rte_experimental /* Check type */ priv = (struct rte_bbdev_op_pool_private *) rte_mempool_get_priv(mempool); - if (unlikely(priv->type != RTE_BBDEV_OP_TURBO_ENC)) + if (unlikely((priv->type != RTE_BBDEV_OP_TURBO_ENC) && + (priv->type != RTE_BBDEV_OP_LDPC_ENC))) return -EINVAL; /* Get elements */ @@ -548,7 +880,8 @@ struct rte_mempool * __rte_experimental /* Check type */ priv = (struct rte_bbdev_op_pool_private *) rte_mempool_get_priv(mempool); - if (unlikely(priv->type != RTE_BBDEV_OP_TURBO_DEC)) + if (unlikely((priv->type != RTE_BBDEV_OP_TURBO_DEC) && + (priv->type != RTE_BBDEV_OP_LDPC_DEC))) return -EINVAL; /* Get elements */ -- 1.8.3.1