xref: /f-stack/dpdk/doc/guides/prog_guide/bbdev.rst (revision 2d9fd380)
1d30ea906Sjfb8856606..  SPDX-License-Identifier: BSD-3-Clause
2d30ea906Sjfb8856606    Copyright(c) 2017 Intel Corporation
3d30ea906Sjfb8856606
4d30ea906Sjfb8856606Wireless Baseband Device Library
5d30ea906Sjfb8856606================================
6d30ea906Sjfb8856606
7d30ea906Sjfb8856606The Wireless Baseband library provides a common programming framework that
8d30ea906Sjfb8856606abstracts HW accelerators based on FPGA and/or Fixed Function Accelerators that
9d30ea906Sjfb8856606assist with 3GPP Physical Layer processing. Furthermore, it decouples the
10d30ea906Sjfb8856606application from the compute-intensive wireless functions by abstracting their
11d30ea906Sjfb8856606optimized libraries to appear as virtual bbdev devices.
12d30ea906Sjfb8856606
13d30ea906Sjfb8856606The functional scope of the BBDEV library are those functions in relation to
14d30ea906Sjfb8856606the 3GPP Layer 1 signal processing (channel coding, modulation, ...).
15d30ea906Sjfb8856606
16*2d9fd380Sjfb8856606The framework currently only supports FEC function.
17d30ea906Sjfb8856606
18d30ea906Sjfb8856606
19d30ea906Sjfb8856606Design Principles
20d30ea906Sjfb8856606-----------------
21d30ea906Sjfb8856606
22d30ea906Sjfb8856606The Wireless Baseband library follows the same ideology of DPDK's Ethernet
23d30ea906Sjfb8856606Device and Crypto Device frameworks. Wireless Baseband provides a generic
24d30ea906Sjfb8856606acceleration abstraction framework which supports both physical (hardware) and
25d30ea906Sjfb8856606virtual (software) wireless acceleration functions.
26d30ea906Sjfb8856606
27d30ea906Sjfb8856606Device Management
28d30ea906Sjfb8856606-----------------
29d30ea906Sjfb8856606
30d30ea906Sjfb8856606Device Creation
31d30ea906Sjfb8856606~~~~~~~~~~~~~~~
32d30ea906Sjfb8856606
33d30ea906Sjfb8856606Physical bbdev devices are discovered during the PCI probe/enumeration of the
34d30ea906Sjfb8856606EAL function which is executed at DPDK initialization, based on
35d30ea906Sjfb8856606their PCI device identifier, each unique PCI BDF (bus/bridge, device,
36d30ea906Sjfb8856606function).
37d30ea906Sjfb8856606
38d30ea906Sjfb8856606Virtual devices can be created by two mechanisms, either using the EAL command
39d30ea906Sjfb8856606line options or from within the application using an EAL API directly.
40d30ea906Sjfb8856606
41d30ea906Sjfb8856606From the command line using the --vdev EAL option
42d30ea906Sjfb8856606
43d30ea906Sjfb8856606.. code-block:: console
44d30ea906Sjfb8856606
45d30ea906Sjfb8856606   --vdev 'baseband_turbo_sw,max_nb_queues=8,socket_id=0'
46d30ea906Sjfb8856606
474b05018fSfengbojiangOr using the rte_vdev_init API within the application code.
48d30ea906Sjfb8856606
49d30ea906Sjfb8856606.. code-block:: c
50d30ea906Sjfb8856606
51d30ea906Sjfb8856606    rte_vdev_init("baseband_turbo_sw", "max_nb_queues=2,socket_id=0")
52d30ea906Sjfb8856606
53d30ea906Sjfb8856606All virtual bbdev devices support the following initialization parameters:
54d30ea906Sjfb8856606
55d30ea906Sjfb8856606- ``max_nb_queues`` - maximum number of queues supported by the device.
56d30ea906Sjfb8856606
57d30ea906Sjfb8856606- ``socket_id`` - socket on which to allocate the device resources on.
58d30ea906Sjfb8856606
59d30ea906Sjfb8856606
60d30ea906Sjfb8856606Device Identification
61d30ea906Sjfb8856606~~~~~~~~~~~~~~~~~~~~~
62d30ea906Sjfb8856606
63d30ea906Sjfb8856606Each device, whether virtual or physical is uniquely designated by two
64d30ea906Sjfb8856606identifiers:
65d30ea906Sjfb8856606
66d30ea906Sjfb8856606- A unique device index used to designate the bbdev device in all functions
67d30ea906Sjfb8856606  exported by the bbdev API.
68d30ea906Sjfb8856606
69d30ea906Sjfb8856606- A device name used to designate the bbdev device in console messages, for
70d30ea906Sjfb8856606  administration or debugging purposes. For ease of use, the port name includes
71d30ea906Sjfb8856606  the port index.
72d30ea906Sjfb8856606
73d30ea906Sjfb8856606
74d30ea906Sjfb8856606Device Configuration
75d30ea906Sjfb8856606~~~~~~~~~~~~~~~~~~~~
76d30ea906Sjfb8856606
77d30ea906Sjfb8856606From the application point of view, each instance of a bbdev device consists of
78d30ea906Sjfb8856606one or more queues identified by queue IDs. While different devices may have
79d30ea906Sjfb8856606different capabilities (e.g. support different operation types), all queues on
80d30ea906Sjfb8856606a device support identical configuration possibilities. A queue is configured
811646932aSjfb8856606for only one type of operation and is configured at initialization time.
82d30ea906Sjfb8856606When an operation is enqueued to a specific queue ID, the result is dequeued
83d30ea906Sjfb8856606from the same queue ID.
84d30ea906Sjfb8856606
85d30ea906Sjfb8856606Configuration of a device has two different levels: configuration that applies
86d30ea906Sjfb8856606to the whole device, and configuration that applies to a single queue.
87d30ea906Sjfb8856606
88d30ea906Sjfb8856606Device configuration is applied with
89d30ea906Sjfb8856606``rte_bbdev_setup_queues(dev_id,num_queues,socket_id)``
90d30ea906Sjfb8856606and queue configuration is applied with
91d30ea906Sjfb8856606``rte_bbdev_queue_configure(dev_id,queue_id,conf)``. Note that, although all
92d30ea906Sjfb8856606queues on a device support same capabilities, they can be configured differently
93d30ea906Sjfb8856606and will then behave differently.
94d30ea906Sjfb8856606Devices supporting interrupts can enable them by using
95d30ea906Sjfb8856606``rte_bbdev_intr_enable(dev_id)``.
96d30ea906Sjfb8856606
97d30ea906Sjfb8856606The configuration of each bbdev device includes the following operations:
98d30ea906Sjfb8856606
99d30ea906Sjfb8856606- Allocation of resources, including hardware resources if a physical device.
100d30ea906Sjfb8856606- Resetting the device into a well-known default state.
101d30ea906Sjfb8856606- Initialization of statistics counters.
102d30ea906Sjfb8856606
103d30ea906Sjfb8856606The ``rte_bbdev_setup_queues`` API is used to setup queues for a bbdev device.
104d30ea906Sjfb8856606
105d30ea906Sjfb8856606.. code-block:: c
106d30ea906Sjfb8856606
107d30ea906Sjfb8856606   int rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues,
108d30ea906Sjfb8856606            int socket_id);
109d30ea906Sjfb8856606
110d30ea906Sjfb8856606- ``num_queues`` argument identifies the total number of queues to setup for
111d30ea906Sjfb8856606  this device.
112d30ea906Sjfb8856606
113d30ea906Sjfb8856606- ``socket_id`` specifies which socket will be used to allocate the memory.
114d30ea906Sjfb8856606
115d30ea906Sjfb8856606
116d30ea906Sjfb8856606The ``rte_bbdev_intr_enable`` API is used to enable interrupts for a bbdev
117d30ea906Sjfb8856606device, if supported by the driver. Should be called before starting the device.
118d30ea906Sjfb8856606
119d30ea906Sjfb8856606.. code-block:: c
120d30ea906Sjfb8856606
121d30ea906Sjfb8856606   int rte_bbdev_intr_enable(uint16_t dev_id);
122d30ea906Sjfb8856606
123d30ea906Sjfb8856606
124d30ea906Sjfb8856606Queues Configuration
125d30ea906Sjfb8856606~~~~~~~~~~~~~~~~~~~~
126d30ea906Sjfb8856606
127d30ea906Sjfb8856606Each bbdev devices queue is individually configured through the
128d30ea906Sjfb8856606``rte_bbdev_queue_configure()`` API.
129d30ea906Sjfb8856606Each queue resources may be allocated on a specified socket.
130d30ea906Sjfb8856606
131d30ea906Sjfb8856606.. code-block:: c
132d30ea906Sjfb8856606
133d30ea906Sjfb8856606    struct rte_bbdev_queue_conf {
134d30ea906Sjfb8856606        int socket;
135d30ea906Sjfb8856606        uint32_t queue_size;
136d30ea906Sjfb8856606        uint8_t priority;
137d30ea906Sjfb8856606        bool deferred_start;
138d30ea906Sjfb8856606        enum rte_bbdev_op_type op_type;
139d30ea906Sjfb8856606    };
140d30ea906Sjfb8856606
141d30ea906Sjfb8856606Device & Queues Management
142d30ea906Sjfb8856606~~~~~~~~~~~~~~~~~~~~~~~~~~
143d30ea906Sjfb8856606
144d30ea906Sjfb8856606After initialization, devices are in a stopped state, so must be started by the
145d30ea906Sjfb8856606application. If an application is finished using a device it can close the
146d30ea906Sjfb8856606device. Once closed, it cannot be restarted.
147d30ea906Sjfb8856606
148d30ea906Sjfb8856606.. code-block:: c
149d30ea906Sjfb8856606
150d30ea906Sjfb8856606    int rte_bbdev_start(uint16_t dev_id)
151d30ea906Sjfb8856606    int rte_bbdev_stop(uint16_t dev_id)
152d30ea906Sjfb8856606    int rte_bbdev_close(uint16_t dev_id)
153d30ea906Sjfb8856606    int rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id)
154d30ea906Sjfb8856606    int rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id)
155d30ea906Sjfb8856606
156d30ea906Sjfb8856606
157d30ea906Sjfb8856606By default, all queues are started when the device is started, but they can be
158d30ea906Sjfb8856606stopped individually.
159d30ea906Sjfb8856606
160d30ea906Sjfb8856606.. code-block:: c
161d30ea906Sjfb8856606
162d30ea906Sjfb8856606    int rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id)
163d30ea906Sjfb8856606    int rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id)
164d30ea906Sjfb8856606
165d30ea906Sjfb8856606
166d30ea906Sjfb8856606Logical Cores, Memory and Queues Relationships
167d30ea906Sjfb8856606~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
168d30ea906Sjfb8856606
1694418919fSjohnjiangThe bbdev poll mode device driver library supports NUMA architecture, in which
1704418919fSjohnjianga processor's logical cores and interfaces utilize it's local memory. Therefore
1714418919fSjohnjiangwith baseband operations, the mbuf being operated on should be allocated from memory
172d30ea906Sjfb8856606pools created in the local memory. The buffers should, if possible, remain on
173d30ea906Sjfb8856606the local processor to obtain the best performance results and buffer
174d30ea906Sjfb8856606descriptors should be populated with mbufs allocated from a mempool allocated
175d30ea906Sjfb8856606from local memory.
176d30ea906Sjfb8856606
177d30ea906Sjfb8856606The run-to-completion model also performs better, especially in the case of
178d30ea906Sjfb8856606virtual bbdev devices, if the baseband operation and data buffers are in local
179d30ea906Sjfb8856606memory instead of a remote processor's memory. This is also true for the
180d30ea906Sjfb8856606pipe-line model provided all logical cores used are located on the same processor.
181d30ea906Sjfb8856606
182d30ea906Sjfb8856606Multiple logical cores should never share the same queue for enqueuing
183d30ea906Sjfb8856606operations or dequeuing operations on the same bbdev device since this would
184d30ea906Sjfb8856606require global locks and hinder performance. It is however possible to use a
185d30ea906Sjfb8856606different logical core to dequeue an operation on a queue pair from the logical
186d30ea906Sjfb8856606core which it was enqueued on. This means that a baseband burst enqueue/dequeue
187d30ea906Sjfb8856606APIs are a logical place to transition from one logical core to another in a
188d30ea906Sjfb8856606packet processing pipeline.
189d30ea906Sjfb8856606
190d30ea906Sjfb8856606
191d30ea906Sjfb8856606Device Operation Capabilities
192d30ea906Sjfb8856606-----------------------------
193d30ea906Sjfb8856606
194d30ea906Sjfb8856606Capabilities (in terms of operations supported, max number of queues, etc.)
195d30ea906Sjfb8856606identify what a bbdev is capable of performing that differs from one device to
196d30ea906Sjfb8856606another. For the full scope of the bbdev capability see the definition of the
197d30ea906Sjfb8856606structure in the *DPDK API Reference*.
198d30ea906Sjfb8856606
199d30ea906Sjfb8856606.. code-block:: c
200d30ea906Sjfb8856606
201d30ea906Sjfb8856606   struct rte_bbdev_op_cap;
202d30ea906Sjfb8856606
203d30ea906Sjfb8856606A device reports its capabilities when registering itself in the bbdev framework.
204d30ea906Sjfb8856606With the aid of this capabilities mechanism, an application can query devices to
205d30ea906Sjfb8856606discover which operations within the 3GPP physical layer they are capable of
206d30ea906Sjfb8856606performing. Below is an example of the capabilities for a PMD it supports in
207d30ea906Sjfb8856606relation to Turbo Encoding and Decoding operations.
208d30ea906Sjfb8856606
209d30ea906Sjfb8856606.. code-block:: c
210d30ea906Sjfb8856606
211d30ea906Sjfb8856606    static const struct rte_bbdev_op_cap bbdev_capabilities[] = {
212d30ea906Sjfb8856606        {
213d30ea906Sjfb8856606            .type = RTE_BBDEV_OP_TURBO_DEC,
214d30ea906Sjfb8856606            .cap.turbo_dec = {
215d30ea906Sjfb8856606                .capability_flags =
216d30ea906Sjfb8856606                    RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE |
217d30ea906Sjfb8856606                    RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN |
218d30ea906Sjfb8856606                    RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN |
219d30ea906Sjfb8856606                    RTE_BBDEV_TURBO_CRC_TYPE_24B |
220d30ea906Sjfb8856606                    RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP |
221d30ea906Sjfb8856606                    RTE_BBDEV_TURBO_EARLY_TERMINATION,
222d30ea906Sjfb8856606                .max_llr_modulus = 16,
2234418919fSjohnjiang                .num_buffers_src = RTE_BBDEV_TURBO_MAX_CODE_BLOCKS,
224d30ea906Sjfb8856606                .num_buffers_hard_out =
2254418919fSjohnjiang                        RTE_BBDEV_TURBO_MAX_CODE_BLOCKS,
226d30ea906Sjfb8856606                .num_buffers_soft_out = 0,
227d30ea906Sjfb8856606            }
228d30ea906Sjfb8856606        },
229d30ea906Sjfb8856606        {
230d30ea906Sjfb8856606            .type   = RTE_BBDEV_OP_TURBO_ENC,
231d30ea906Sjfb8856606            .cap.turbo_enc = {
232d30ea906Sjfb8856606                .capability_flags =
233d30ea906Sjfb8856606                        RTE_BBDEV_TURBO_CRC_24B_ATTACH |
234d30ea906Sjfb8856606                        RTE_BBDEV_TURBO_CRC_24A_ATTACH |
235d30ea906Sjfb8856606                        RTE_BBDEV_TURBO_RATE_MATCH |
236d30ea906Sjfb8856606                        RTE_BBDEV_TURBO_RV_INDEX_BYPASS,
2374418919fSjohnjiang                .num_buffers_src = RTE_BBDEV_TURBO_MAX_CODE_BLOCKS,
2384418919fSjohnjiang                .num_buffers_dst = RTE_BBDEV_TURBO_MAX_CODE_BLOCKS,
239d30ea906Sjfb8856606            }
240d30ea906Sjfb8856606        },
241d30ea906Sjfb8856606        RTE_BBDEV_END_OF_CAPABILITIES_LIST()
242d30ea906Sjfb8856606    };
243d30ea906Sjfb8856606
244d30ea906Sjfb8856606Capabilities Discovery
245d30ea906Sjfb8856606~~~~~~~~~~~~~~~~~~~~~~
246d30ea906Sjfb8856606
247d30ea906Sjfb8856606Discovering the features and capabilities of a bbdev device poll mode driver
248d30ea906Sjfb8856606is achieved through the ``rte_bbdev_info_get()`` function.
249d30ea906Sjfb8856606
250d30ea906Sjfb8856606.. code-block:: c
251d30ea906Sjfb8856606
252d30ea906Sjfb8856606   int rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info)
253d30ea906Sjfb8856606
254d30ea906Sjfb8856606This allows the user to query a specific bbdev PMD and get all the device
255d30ea906Sjfb8856606capabilities. The ``rte_bbdev_info`` structure provides two levels of
256d30ea906Sjfb8856606information:
257d30ea906Sjfb8856606
258d30ea906Sjfb8856606- Device relevant information, like: name and related rte_bus.
259d30ea906Sjfb8856606
260d30ea906Sjfb8856606- Driver specific information, as defined by the ``struct rte_bbdev_driver_info``
261d30ea906Sjfb8856606  structure, this is where capabilities reside along with other specifics like:
262d30ea906Sjfb8856606  maximum queue sizes and priority level.
263d30ea906Sjfb8856606
264d30ea906Sjfb8856606.. code-block:: c
265d30ea906Sjfb8856606
266d30ea906Sjfb8856606    struct rte_bbdev_info {
267d30ea906Sjfb8856606        int socket_id;
268d30ea906Sjfb8856606        const char *dev_name;
2694418919fSjohnjiang        const struct rte_device *device;
270d30ea906Sjfb8856606        uint16_t num_queues;
271d30ea906Sjfb8856606        bool started;
272d30ea906Sjfb8856606        struct rte_bbdev_driver_info drv;
273d30ea906Sjfb8856606    };
274d30ea906Sjfb8856606
2754418919fSjohnjiang
276d30ea906Sjfb8856606Operation Processing
277d30ea906Sjfb8856606--------------------
278d30ea906Sjfb8856606
279d30ea906Sjfb8856606Scheduling of baseband operations on DPDK's application data path is
280d30ea906Sjfb8856606performed using a burst oriented asynchronous API set. A queue on a bbdev
281d30ea906Sjfb8856606device accepts a burst of baseband operations using enqueue burst API. On physical
282d30ea906Sjfb8856606bbdev devices the enqueue burst API will place the operations to be processed
283d30ea906Sjfb8856606on the device's hardware input queue, for virtual devices the processing of the
284d30ea906Sjfb8856606baseband operations is usually completed during the enqueue call to the bbdev
285d30ea906Sjfb8856606device. The dequeue burst API will retrieve any processed operations available
286d30ea906Sjfb8856606from the queue on the bbdev device, from physical devices this is usually
287d30ea906Sjfb8856606directly from the device's processed queue, and for virtual device's from a
2884b05018fSfengbojiang``rte_ring`` where processed operations are placed after being processed on the
289d30ea906Sjfb8856606enqueue call.
290d30ea906Sjfb8856606
291d30ea906Sjfb8856606
292d30ea906Sjfb8856606Enqueue / Dequeue Burst APIs
293d30ea906Sjfb8856606~~~~~~~~~~~~~~~~~~~~~~~~~~~~
294d30ea906Sjfb8856606
295d30ea906Sjfb8856606The burst enqueue API uses a bbdev device identifier and a queue
296d30ea906Sjfb8856606identifier to specify the bbdev device queue to schedule the processing on.
297d30ea906Sjfb8856606The ``num_ops`` parameter is the number of operations to process which are
298d30ea906Sjfb8856606supplied in the ``ops`` array of ``rte_bbdev_*_op`` structures.
299d30ea906Sjfb8856606The enqueue function returns the number of operations it actually enqueued for
300d30ea906Sjfb8856606processing, a return value equal to ``num_ops`` means that all packets have been
301d30ea906Sjfb8856606enqueued.
302d30ea906Sjfb8856606
303d30ea906Sjfb8856606.. code-block:: c
304d30ea906Sjfb8856606
305d30ea906Sjfb8856606    uint16_t rte_bbdev_enqueue_enc_ops(uint16_t dev_id, uint16_t queue_id,
306d30ea906Sjfb8856606            struct rte_bbdev_enc_op **ops, uint16_t num_ops)
307d30ea906Sjfb8856606
308d30ea906Sjfb8856606    uint16_t rte_bbdev_enqueue_dec_ops(uint16_t dev_id, uint16_t queue_id,
309d30ea906Sjfb8856606            struct rte_bbdev_dec_op **ops, uint16_t num_ops)
310d30ea906Sjfb8856606
311d30ea906Sjfb8856606The dequeue API uses the same format as the enqueue API of processed but
312d30ea906Sjfb8856606the ``num_ops`` and ``ops`` parameters are now used to specify the max processed
313d30ea906Sjfb8856606operations the user wishes to retrieve and the location in which to store them.
314d30ea906Sjfb8856606The API call returns the actual number of processed operations returned, this
315d30ea906Sjfb8856606can never be larger than ``num_ops``.
316d30ea906Sjfb8856606
317d30ea906Sjfb8856606.. code-block:: c
318d30ea906Sjfb8856606
319d30ea906Sjfb8856606    uint16_t rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id,
320d30ea906Sjfb8856606            struct rte_bbdev_enc_op **ops, uint16_t num_ops)
321d30ea906Sjfb8856606
322d30ea906Sjfb8856606    uint16_t rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id,
323d30ea906Sjfb8856606            struct rte_bbdev_dec_op **ops, uint16_t num_ops)
324d30ea906Sjfb8856606
325d30ea906Sjfb8856606Operation Representation
326d30ea906Sjfb8856606~~~~~~~~~~~~~~~~~~~~~~~~
327d30ea906Sjfb8856606
328d30ea906Sjfb8856606An encode bbdev operation is represented by ``rte_bbdev_enc_op`` structure,
329d30ea906Sjfb8856606and by ``rte_bbdev_dec_op`` for decode. These structures act as metadata
330d30ea906Sjfb8856606containers for all necessary information required for the bbdev operation to be
331d30ea906Sjfb8856606processed on a particular bbdev device poll mode driver.
332d30ea906Sjfb8856606
333d30ea906Sjfb8856606.. code-block:: c
334d30ea906Sjfb8856606
335d30ea906Sjfb8856606    struct rte_bbdev_enc_op {
336d30ea906Sjfb8856606        int status;
337d30ea906Sjfb8856606        struct rte_mempool *mempool;
338d30ea906Sjfb8856606        void *opaque_data;
3394418919fSjohnjiang        union {
340d30ea906Sjfb8856606            struct rte_bbdev_op_turbo_enc turbo_enc;
3414418919fSjohnjiang            struct rte_bbdev_op_ldpc_enc ldpc_enc;
3424418919fSjohnjiang        }
343d30ea906Sjfb8856606    };
344d30ea906Sjfb8856606
345d30ea906Sjfb8856606    struct rte_bbdev_dec_op {
346d30ea906Sjfb8856606        int status;
347d30ea906Sjfb8856606        struct rte_mempool *mempool;
348d30ea906Sjfb8856606        void *opaque_data;
3494418919fSjohnjiang        union {
3504418919fSjohnjiang            struct rte_bbdev_op_turbo_dec turbo_enc;
3514418919fSjohnjiang            struct rte_bbdev_op_ldpc_dec ldpc_enc;
3524418919fSjohnjiang        }
353d30ea906Sjfb8856606    };
354d30ea906Sjfb8856606
355d30ea906Sjfb8856606The operation structure by itself defines the operation type. It includes an
356d30ea906Sjfb8856606operation status, a reference to the operation specific data, which can vary in
357d30ea906Sjfb8856606size and content depending on the operation being provisioned. It also contains
358d30ea906Sjfb8856606the source mempool for the operation, if it is allocated from a mempool.
359d30ea906Sjfb8856606
360d30ea906Sjfb8856606If bbdev operations are allocated from a bbdev operation mempool, see next
361d30ea906Sjfb8856606section, there is also the ability to allocate private memory with the
362d30ea906Sjfb8856606operation for applications purposes.
363d30ea906Sjfb8856606
364d30ea906Sjfb8856606Application software is responsible for specifying all the operation specific
365d30ea906Sjfb8856606fields in the ``rte_bbdev_*_op`` structure which are then used by the bbdev PMD
366d30ea906Sjfb8856606to process the requested operation.
367d30ea906Sjfb8856606
368d30ea906Sjfb8856606
369d30ea906Sjfb8856606Operation Management and Allocation
370d30ea906Sjfb8856606~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
371d30ea906Sjfb8856606
372d30ea906Sjfb8856606The bbdev library provides an API set for managing bbdev operations which
373d30ea906Sjfb8856606utilize the Mempool Library to allocate operation buffers. Therefore, it ensures
374d30ea906Sjfb8856606that the bbdev operation is interleaved optimally across the channels and
375d30ea906Sjfb8856606ranks for optimal processing.
376d30ea906Sjfb8856606
377d30ea906Sjfb8856606.. code-block:: c
378d30ea906Sjfb8856606
379d30ea906Sjfb8856606    struct rte_mempool *
380d30ea906Sjfb8856606    rte_bbdev_op_pool_create(const char *name, enum rte_bbdev_op_type type,
381d30ea906Sjfb8856606            unsigned int num_elements, unsigned int cache_size,
382d30ea906Sjfb8856606            int socket_id)
383d30ea906Sjfb8856606
384d30ea906Sjfb8856606``rte_bbdev_*_op_alloc_bulk()`` and ``rte_bbdev_*_op_free_bulk()`` are used to
385d30ea906Sjfb8856606allocate bbdev operations of a specific type from a given bbdev operation mempool.
386d30ea906Sjfb8856606
387d30ea906Sjfb8856606.. code-block:: c
388d30ea906Sjfb8856606
389d30ea906Sjfb8856606    int rte_bbdev_enc_op_alloc_bulk(struct rte_mempool *mempool,
390d30ea906Sjfb8856606            struct rte_bbdev_enc_op **ops, uint16_t num_ops)
391d30ea906Sjfb8856606
392d30ea906Sjfb8856606    int rte_bbdev_dec_op_alloc_bulk(struct rte_mempool *mempool,
393d30ea906Sjfb8856606            struct rte_bbdev_dec_op **ops, uint16_t num_ops)
394d30ea906Sjfb8856606
395d30ea906Sjfb8856606``rte_bbdev_*_op_free_bulk()`` is called by the application to return an
396d30ea906Sjfb8856606operation to its allocating pool.
397d30ea906Sjfb8856606
398d30ea906Sjfb8856606.. code-block:: c
399d30ea906Sjfb8856606
400d30ea906Sjfb8856606    void rte_bbdev_dec_op_free_bulk(struct rte_bbdev_dec_op **ops,
401d30ea906Sjfb8856606            unsigned int num_ops)
402d30ea906Sjfb8856606    void rte_bbdev_enc_op_free_bulk(struct rte_bbdev_enc_op **ops,
403d30ea906Sjfb8856606            unsigned int num_ops)
404d30ea906Sjfb8856606
405d30ea906Sjfb8856606BBDEV Inbound/Outbound Memory
406d30ea906Sjfb8856606~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
407d30ea906Sjfb8856606
408d30ea906Sjfb8856606The bbdev operation structure contains all the mutable data relating to
4094418919fSjohnjiangperforming Turbo and LDPC coding on a referenced mbuf data buffer. It is used for either
410d30ea906Sjfb8856606encode or decode operations.
411d30ea906Sjfb8856606
4124418919fSjohnjiang
4134418919fSjohnjiang.. csv-table:: Operation I/O
4144418919fSjohnjiang   :header: "FEC", "In", "Out"
4154418919fSjohnjiang   :widths: 20, 30, 30
4164418919fSjohnjiang
4174418919fSjohnjiang   "Turbo Encode", "input", "output"
4184418919fSjohnjiang   "Turbo Decode", "input", "hard output"
4194418919fSjohnjiang   " ", " ", "soft output (optional)"
4204418919fSjohnjiang   "LDPC Encode", "input", "output"
4214418919fSjohnjiang   "LDPC Decode", "input", "hard output"
4224418919fSjohnjiang   "", "HQ combine (optional)", "HQ combine (optional)"
4234418919fSjohnjiang   " ", "", "soft output (optional)"
4244418919fSjohnjiang
425d30ea906Sjfb8856606
426d30ea906Sjfb8856606It is expected that the application provides input and output mbuf pointers
4274418919fSjohnjiangallocated and ready to use.
4284418919fSjohnjiang
4294418919fSjohnjiangThe baseband framework supports FEC coding on Code Blocks (CB) and
4304418919fSjohnjiangTransport Blocks (TB).
431d30ea906Sjfb8856606
432d30ea906Sjfb8856606For the output buffer(s), the application is required to provide an allocated
4334418919fSjohnjiangand free mbuf, to which the resulting output will be written.
434d30ea906Sjfb8856606
435d30ea906Sjfb8856606The support of split "scattered" buffers is a driver-specific feature, so it is
436d30ea906Sjfb8856606reported individually by the supporting driver as a capability.
437d30ea906Sjfb8856606
438d30ea906Sjfb8856606Input and output data buffers are identified by ``rte_bbdev_op_data`` structure,
439d30ea906Sjfb8856606as follows:
440d30ea906Sjfb8856606
441d30ea906Sjfb8856606.. code-block:: c
442d30ea906Sjfb8856606
443d30ea906Sjfb8856606    struct rte_bbdev_op_data {
444d30ea906Sjfb8856606        struct rte_mbuf *data;
445d30ea906Sjfb8856606        uint32_t offset;
446d30ea906Sjfb8856606        uint32_t length;
447d30ea906Sjfb8856606    };
448d30ea906Sjfb8856606
449d30ea906Sjfb8856606
450d30ea906Sjfb8856606This structure has three elements:
451d30ea906Sjfb8856606
452d30ea906Sjfb8856606- ``data``: This is the mbuf data structure representing the data for BBDEV
453d30ea906Sjfb8856606  operation.
454d30ea906Sjfb8856606
455d30ea906Sjfb8856606  This mbuf pointer can point to one Code Block (CB) data buffer or multiple CBs
456d30ea906Sjfb8856606  contiguously located next to each other. A Transport Block (TB) represents a
457d30ea906Sjfb8856606  whole piece of data that is divided into one or more CBs. Maximum number of
4584418919fSjohnjiang  CBs can be contained in one TB is defined by
4594418919fSjohnjiang  ``RTE_BBDEV_(TURBO/LDPC)MAX_CODE_BLOCKS``.
460d30ea906Sjfb8856606
461d30ea906Sjfb8856606  An mbuf data structure cannot represent more than one TB. The smallest piece
462d30ea906Sjfb8856606  of data that can be contained in one mbuf is one CB.
463d30ea906Sjfb8856606  An mbuf can include one contiguous CB, subset of contiguous CBs that are
4644418919fSjohnjiang  belonging to one TB, or all contiguous CBs that belong to one TB.
465d30ea906Sjfb8856606
466d30ea906Sjfb8856606  If a BBDEV PMD supports the extended capability "Scatter-Gather", then it is
467d30ea906Sjfb8856606  capable of collecting (gathering) non-contiguous (scattered) data from
468d30ea906Sjfb8856606  multiple locations in the memory.
469d30ea906Sjfb8856606  This capability is reported by the capability flags:
470d30ea906Sjfb8856606
4714418919fSjohnjiang  - ``RTE_BBDEV_TURBO_ENC_SCATTER_GATHER``, ``RTE_BBDEV_TURBO_DEC_SCATTER_GATHER``,
472d30ea906Sjfb8856606
4734418919fSjohnjiang  - ``RTE_BBDEV_LDPC_ENC_SCATTER_GATHER``, ``RTE_BBDEV_LDPC_DEC_SCATTER_GATHER``.
474d30ea906Sjfb8856606
4754418919fSjohnjiang  Chained mbuf data structures are only accepted if a BBDEV PMD supports this
4764418919fSjohnjiang  feature. A chained mbuf can represent one non-contiguous CB or multiple non-contiguous
4774418919fSjohnjiang  CBs. The first mbuf segment in the given chained mbuf represents the first piece
478d30ea906Sjfb8856606  of the CB. Offset is only applicable to the first segment. ``length`` is the
479d30ea906Sjfb8856606  total length of the CB.
480d30ea906Sjfb8856606
481d30ea906Sjfb8856606  BBDEV driver is responsible for identifying where the split is and enqueue
482d30ea906Sjfb8856606  the split data to its internal queues.
483d30ea906Sjfb8856606
484d30ea906Sjfb8856606  If BBDEV PMD does not support this feature, it will assume inbound mbuf data
485d30ea906Sjfb8856606  contains one segment.
486d30ea906Sjfb8856606
487d30ea906Sjfb8856606  The output mbuf data though is always one segment, even if the input was a
488d30ea906Sjfb8856606  chained mbuf.
489d30ea906Sjfb8856606
490d30ea906Sjfb8856606
491d30ea906Sjfb8856606- ``offset``: This is the starting point of the BBDEV (encode/decode) operation,
492d30ea906Sjfb8856606  in bytes.
493d30ea906Sjfb8856606
494d30ea906Sjfb8856606  BBDEV starts to read data past this offset.
495d30ea906Sjfb8856606  In case of chained mbuf, this offset applies only to the first mbuf segment.
496d30ea906Sjfb8856606
497d30ea906Sjfb8856606
498d30ea906Sjfb8856606- ``length``: This is the total data length to be processed in one operation,
499d30ea906Sjfb8856606  in bytes.
500d30ea906Sjfb8856606
501d30ea906Sjfb8856606  In case the mbuf data is representing one CB, this is the length of the CB
502d30ea906Sjfb8856606  undergoing the operation.
503d30ea906Sjfb8856606  If it is for multiple CBs, this is the total length of those CBs undergoing
504d30ea906Sjfb8856606  the operation.
505d30ea906Sjfb8856606  If it is for one TB, this is the total length of the TB under operation.
506d30ea906Sjfb8856606  In case of chained mbuf, this data length includes the lengths of the
507d30ea906Sjfb8856606  "scattered" data segments undergoing the operation.
508d30ea906Sjfb8856606
509d30ea906Sjfb8856606
510d30ea906Sjfb8856606BBDEV Turbo Encode Operation
511d30ea906Sjfb8856606~~~~~~~~~~~~~~~~~~~~~~~~~~~~
512d30ea906Sjfb8856606
513d30ea906Sjfb8856606.. code-block:: c
514d30ea906Sjfb8856606
515d30ea906Sjfb8856606    struct rte_bbdev_op_turbo_enc {
516d30ea906Sjfb8856606        struct rte_bbdev_op_data input;
517d30ea906Sjfb8856606        struct rte_bbdev_op_data output;
518d30ea906Sjfb8856606
519d30ea906Sjfb8856606        uint32_t op_flags;
520d30ea906Sjfb8856606        uint8_t rv_index;
521d30ea906Sjfb8856606        uint8_t code_block_mode;
522d30ea906Sjfb8856606        union {
523d30ea906Sjfb8856606            struct rte_bbdev_op_enc_cb_params cb_params;
524d30ea906Sjfb8856606            struct rte_bbdev_op_enc_tb_params tb_params;
525d30ea906Sjfb8856606        };
526d30ea906Sjfb8856606    };
527d30ea906Sjfb8856606
5284418919fSjohnjiangThe Turbo encode structure includes the ``input`` and ``output`` mbuf
5294418919fSjohnjiangdata pointers. The provided mbuf pointer of ``input`` needs to be big
5304418919fSjohnjiangenough to stretch for extra CRC trailers.
531d30ea906Sjfb8856606
5324418919fSjohnjiang.. csv-table:: **struct rte_bbdev_op_turbo_enc** parameters
5334418919fSjohnjiang   :header: "Parameter", "Description"
5344418919fSjohnjiang   :widths: 10, 30
535d30ea906Sjfb8856606
5364418919fSjohnjiang   "input","input CB or TB data"
5374418919fSjohnjiang   "output","rate matched CB or TB output buffer"
5384418919fSjohnjiang   "op_flags","bitmask of all active operation capabilities"
5394418919fSjohnjiang   "rv_index","redundancy version index [0..3]"
5404418919fSjohnjiang   "code_block_mode","code block or transport block mode"
5414418919fSjohnjiang   "cb_params", "code block specific parameters (code block mode only)"
5424418919fSjohnjiang   "tb_params", "transport block specific parameters (transport block mode only)"
5434418919fSjohnjiang
544d30ea906Sjfb8856606
545d30ea906Sjfb8856606The encode interface works on both the code block (CB) and the transport block
546d30ea906Sjfb8856606(TB). An operation executes in "CB-mode" when the CB is standalone. While
547d30ea906Sjfb8856606"TB-mode" executes when an operation performs on one or multiple CBs that
548d30ea906Sjfb8856606belong to a TB. Therefore, a given data can be standalone CB, full-size TB or
549d30ea906Sjfb8856606partial TB. Partial TB means that only a subset of CBs belonging to a bigger TB
550d30ea906Sjfb8856606are being enqueued.
551d30ea906Sjfb8856606
552d30ea906Sjfb8856606  **NOTE:** It is assumed that all enqueued ops in one ``rte_bbdev_enqueue_enc_ops()``
553d30ea906Sjfb8856606  call belong to one mode, either CB-mode or TB-mode.
554d30ea906Sjfb8856606
5554418919fSjohnjiangIn case that the TB is smaller than Z (6144 bits), then effectively the TB = CB.
556d30ea906Sjfb8856606CRC24A is appended to the tail of the CB. The application is responsible for
557d30ea906Sjfb8856606calculating and appending CRC24A before calling BBDEV in case that the
558d30ea906Sjfb8856606underlying driver does not support CRC24A generation.
559d30ea906Sjfb8856606
560d30ea906Sjfb8856606In CB-mode, CRC24A/B is an optional operation.
5614418919fSjohnjiangThe CB parameter ``k`` is the size of the CB (this maps to K as described
5624418919fSjohnjiangin 3GPP TS 36.212 section 5.1.2), this size is inclusive of CRC24A/B.
563d30ea906Sjfb8856606The ``length`` is inclusive of CRC24A/B and equals to ``k`` in this case.
564d30ea906Sjfb8856606
565d30ea906Sjfb8856606Not all BBDEV PMDs are capable of CRC24A/B calculation. Flags
566d30ea906Sjfb8856606``RTE_BBDEV_TURBO_CRC_24A_ATTACH`` and ``RTE_BBDEV_TURBO_CRC_24B_ATTACH``
567d30ea906Sjfb8856606informs the application with relevant capability. These flags can be set in the
5684418919fSjohnjiang``op_flags`` parameter to indicate to BBDEV to calculate and append CRC24A/B
5694418919fSjohnjiangto CB before going forward with Turbo encoding.
570d30ea906Sjfb8856606
571d30ea906Sjfb8856606Output format of the CB encode will have the encoded CB in ``e`` size output
572d30ea906Sjfb8856606(this maps to E described in 3GPP TS 36.212 section 5.1.4.1.2). The output mbuf
573d30ea906Sjfb8856606buffer size needs to be big enough to hold the encoded buffer of size ``e``.
574d30ea906Sjfb8856606
575d30ea906Sjfb8856606In TB-mode, CRC24A is assumed to be pre-calculated and appended to the inbound
576d30ea906Sjfb8856606TB mbuf data buffer.
577d30ea906Sjfb8856606The output mbuf data structure is expected to be allocated by the application
578d30ea906Sjfb8856606with enough room for the output data.
579d30ea906Sjfb8856606
580d30ea906Sjfb8856606The difference between the partial and full-size TB is that we need to know the
581d30ea906Sjfb8856606index of the first CB in this group and the number of CBs contained within.
582d30ea906Sjfb8856606The first CB index is given by ``r`` but the number of the remaining CBs is
583d30ea906Sjfb8856606calculated automatically by BBDEV before passing down to the driver.
584d30ea906Sjfb8856606
585d30ea906Sjfb8856606The number of remaining CBs should not be confused with ``c``. ``c`` is the
586d30ea906Sjfb8856606total number of CBs that composes the whole TB (this maps to C as
587d30ea906Sjfb8856606described in 3GPP TS 36.212 section 5.1.2).
588d30ea906Sjfb8856606
589d30ea906Sjfb8856606The ``length`` is total size of the CBs inclusive of any CRC24A and CRC24B in
590d30ea906Sjfb8856606case they were appended by the application.
591d30ea906Sjfb8856606
592d30ea906Sjfb8856606The case when one CB belongs to TB and is being enqueued individually to BBDEV,
593d30ea906Sjfb8856606this case is considered as a special case of partial TB where its number of CBs
594d30ea906Sjfb8856606is 1. Therefore, it requires to get processed in TB-mode.
595d30ea906Sjfb8856606
596d30ea906Sjfb8856606The figure below visualizes the encoding of CBs using BBDEV interface in
597d30ea906Sjfb8856606TB-mode. CB-mode is a reduced version, where only one CB exists:
598d30ea906Sjfb8856606
599d30ea906Sjfb8856606.. _figure_turbo_tb_encode:
600d30ea906Sjfb8856606
601d30ea906Sjfb8856606.. figure:: img/turbo_tb_encode.*
602d30ea906Sjfb8856606
603d30ea906Sjfb8856606    Turbo encoding of Code Blocks in mbuf structure
604d30ea906Sjfb8856606
605d30ea906Sjfb8856606
606d30ea906Sjfb8856606BBDEV Turbo Decode Operation
607d30ea906Sjfb8856606~~~~~~~~~~~~~~~~~~~~~~~~~~~~
608d30ea906Sjfb8856606
609d30ea906Sjfb8856606.. code-block:: c
610d30ea906Sjfb8856606
611d30ea906Sjfb8856606    struct rte_bbdev_op_turbo_dec {
612d30ea906Sjfb8856606        struct rte_bbdev_op_data input;
613d30ea906Sjfb8856606        struct rte_bbdev_op_data hard_output;
614d30ea906Sjfb8856606        struct rte_bbdev_op_data soft_output;
615d30ea906Sjfb8856606
616d30ea906Sjfb8856606        uint32_t op_flags;
617d30ea906Sjfb8856606        uint8_t rv_index;
618d30ea906Sjfb8856606        uint8_t iter_min:4;
619d30ea906Sjfb8856606        uint8_t iter_max:4;
620d30ea906Sjfb8856606        uint8_t iter_count;
621d30ea906Sjfb8856606        uint8_t ext_scale;
622d30ea906Sjfb8856606        uint8_t num_maps;
623d30ea906Sjfb8856606        uint8_t code_block_mode;
624d30ea906Sjfb8856606        union {
625d30ea906Sjfb8856606            struct rte_bbdev_op_dec_cb_params cb_params;
626d30ea906Sjfb8856606            struct rte_bbdev_op_dec_tb_params tb_params;
627d30ea906Sjfb8856606        };
628d30ea906Sjfb8856606    };
629d30ea906Sjfb8856606
6304418919fSjohnjiangThe Turbo decode structure includes the ``input``, ``hard_output`` and
6314418919fSjohnjiangoptionally the ``soft_output`` mbuf data pointers.
632d30ea906Sjfb8856606
6334418919fSjohnjiang.. csv-table:: **struct rte_bbdev_op_turbo_dec** parameters
6344418919fSjohnjiang   :header: "Parameter", "Description"
6354418919fSjohnjiang   :widths: 10, 30
636d30ea906Sjfb8856606
6374418919fSjohnjiang   "input","virtual circular buffer, wk, size 3*Kpi for each CB"
6384418919fSjohnjiang   "hard output","hard decisions buffer, decoded output, size K for each CB"
6394418919fSjohnjiang   "soft output","soft LLR output buffer (optional)"
6404418919fSjohnjiang   "op_flags","bitmask of all active operation capabilities"
6414418919fSjohnjiang   "rv_index","redundancy version index [0..3]"
6424418919fSjohnjiang   "iter_max","maximum number of iterations to perofrm in decode all CBs"
6434418919fSjohnjiang   "iter_min","minimum number of iterations to perform in decoding all CBs"
6444418919fSjohnjiang   "iter_count","number of iterations to performed in decoding all CBs"
6454418919fSjohnjiang   "ext_scale","scale factor on extrinsic info (5 bits)"
6464418919fSjohnjiang   "num_maps","number of MAP engines to use in decode"
6474418919fSjohnjiang   "code_block_mode","code block or transport block mode"
6484418919fSjohnjiang   "cb_params", "code block specific parameters (code block mode only)"
6494418919fSjohnjiang   "tb_params", "transport block specific parameters (transport block mode only)"
650d30ea906Sjfb8856606
651d30ea906Sjfb8856606Similarly, the decode interface works on both the code block (CB) and the
652d30ea906Sjfb8856606transport block (TB). An operation executes in "CB-mode" when the CB is
653d30ea906Sjfb8856606standalone. While "TB-mode" executes when an operation performs on one or
654d30ea906Sjfb8856606multiple CBs that belong to a TB. Therefore, a given data can be standalone CB,
655d30ea906Sjfb8856606full-size TB or partial TB. Partial TB means that only a subset of CBs belonging
656d30ea906Sjfb8856606to a bigger TB are being enqueued.
657d30ea906Sjfb8856606
658d30ea906Sjfb8856606  **NOTE:** It is assumed that all enqueued ops in one ``rte_bbdev_enqueue_dec_ops()``
659d30ea906Sjfb8856606  call belong to one mode, either CB-mode or TB-mode.
660d30ea906Sjfb8856606
6614418919fSjohnjiang
6624418919fSjohnjiangThe CB parameter ``k`` is the size of the decoded CB (this maps to K as described in
663d30ea906Sjfb88566063GPP TS 36.212 section 5.1.2), this size is inclusive of CRC24A/B.
664d30ea906Sjfb8856606The ``length`` is inclusive of CRC24A/B and equals to ``k`` in this case.
665d30ea906Sjfb8856606
666d30ea906Sjfb8856606The input encoded CB data is the Virtual Circular Buffer data stream, wk, with
667d30ea906Sjfb8856606the null padding included as described in 3GPP TS 36.212 section 5.1.4.1.2 and
668d30ea906Sjfb8856606shown in 3GPP TS 36.212 section 5.1.4.1 Figure 5.1.4-1.
669d30ea906Sjfb8856606The size of the virtual circular buffer is 3*Kpi, where Kpi is the 32 byte
670d30ea906Sjfb8856606aligned value of K, as specified in 3GPP TS 36.212 section 5.1.4.1.1.
671d30ea906Sjfb8856606
672d30ea906Sjfb8856606Each byte in the input circular buffer is the LLR value of each bit of the
673d30ea906Sjfb8856606original CB.
674d30ea906Sjfb8856606
675d30ea906Sjfb8856606``hard_output`` is a mandatory capability that all BBDEV PMDs support. This is
676d30ea906Sjfb8856606the decoded CBs of K sizes (CRC24A/B is the last 24-bit in each decoded CB).
677d30ea906Sjfb8856606Soft output is an optional capability for BBDEV PMDs. Setting flag
678d30ea906Sjfb8856606``RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP`` in ``op_flags`` directs BBDEV to retain
679d30ea906Sjfb8856606CRC24B at the end of each CB. This might be useful for the application in debug
680d30ea906Sjfb8856606mode.
681d30ea906Sjfb8856606An LLR rate matched output is computed in the ``soft_output`` buffer structure
6824418919fSjohnjiangfor the given CB parameter ``e`` size (this maps to E described in
6834418919fSjohnjiang3GPP TS 36.212 section 5.1.4.1.2). The output mbuf buffer size needs to be big
6844418919fSjohnjiangenough to hold the encoded buffer of size ``e``.
685d30ea906Sjfb8856606
686d30ea906Sjfb8856606The first CB Virtual Circular Buffer (VCB) index is given by ``r`` but the
687d30ea906Sjfb8856606number of the remaining CB VCBs is calculated automatically by BBDEV before
688d30ea906Sjfb8856606passing down to the driver.
689d30ea906Sjfb8856606
690d30ea906Sjfb8856606The number of remaining CB VCBs should not be confused with ``c``. ``c`` is the
691d30ea906Sjfb8856606total number of CBs that composes the whole TB (this maps to C as
692d30ea906Sjfb8856606described in 3GPP TS 36.212 section 5.1.2).
693d30ea906Sjfb8856606
694d30ea906Sjfb8856606The ``length`` is total size of the CBs inclusive of any CRC24A and CRC24B in
695d30ea906Sjfb8856606case they were appended by the application.
696d30ea906Sjfb8856606
697d30ea906Sjfb8856606The case when one CB belongs to TB and is being enqueued individually to BBDEV,
698d30ea906Sjfb8856606this case is considered as a special case of partial TB where its number of CBs
699d30ea906Sjfb8856606is 1. Therefore, it requires to get processed in TB-mode.
700d30ea906Sjfb8856606
701d30ea906Sjfb8856606The output mbuf data structure is expected to be allocated by the application
702d30ea906Sjfb8856606with enough room for the output data.
703d30ea906Sjfb8856606
704d30ea906Sjfb8856606The figure below visualizes the decoding of CBs using BBDEV interface in
705d30ea906Sjfb8856606TB-mode. CB-mode is a reduced version, where only one CB exists:
706d30ea906Sjfb8856606
707d30ea906Sjfb8856606.. _figure_turbo_tb_decode:
708d30ea906Sjfb8856606
709d30ea906Sjfb8856606.. figure:: img/turbo_tb_decode.*
710d30ea906Sjfb8856606
711d30ea906Sjfb8856606    Turbo decoding of Code Blocks in mbuf structure
712d30ea906Sjfb8856606
7134418919fSjohnjiangBBDEV LDPC Encode Operation
7144418919fSjohnjiang~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7154418919fSjohnjiang
7164418919fSjohnjiangThe operation flags that can be set for each LDPC encode operation are
7174418919fSjohnjianggiven below.
7184418919fSjohnjiang
7194418919fSjohnjiang  **NOTE:** The actual operation flags that may be used with a specific
7204418919fSjohnjiang  BBDEV PMD are dependent on the driver capabilities as reported via
7214418919fSjohnjiang  ``rte_bbdev_info_get()``, and may be a subset of those below.
7224418919fSjohnjiang
7234418919fSjohnjiang+--------------------------------------------------------------------+
7244418919fSjohnjiang|Description of LDPC encode capability flags                         |
7254418919fSjohnjiang+====================================================================+
7264418919fSjohnjiang|RTE_BBDEV_LDPC_INTERLEAVER_BYPASS                                   |
7274418919fSjohnjiang| Set to bypass bit-level interleaver on output stream               |
7284418919fSjohnjiang+--------------------------------------------------------------------+
7294418919fSjohnjiang|RTE_BBDEV_LDPC_RATE_MATCH                                           |
7304418919fSjohnjiang| Set to enabling the RATE_MATCHING processing                       |
7314418919fSjohnjiang+--------------------------------------------------------------------+
7324418919fSjohnjiang|RTE_BBDEV_LDPC_CRC_24A_ATTACH                                       |
7334418919fSjohnjiang| Set to attach transport block CRC-24A                              |
7344418919fSjohnjiang+--------------------------------------------------------------------+
7354418919fSjohnjiang|RTE_BBDEV_LDPC_CRC_24B_ATTACH                                       |
7364418919fSjohnjiang| Set to attach code block CRC-24B                                   |
7374418919fSjohnjiang+--------------------------------------------------------------------+
7384418919fSjohnjiang|RTE_BBDEV_LDPC_CRC_16_ATTACH                                        |
7394418919fSjohnjiang| Set to attach code block CRC-16                                    |
7404418919fSjohnjiang+--------------------------------------------------------------------+
7414418919fSjohnjiang|RTE_BBDEV_LDPC_ENC_INTERRUPTS                                       |
7424418919fSjohnjiang| Set if a device supports encoder dequeue interrupts                |
7434418919fSjohnjiang+--------------------------------------------------------------------+
7444418919fSjohnjiang|RTE_BBDEV_LDPC_ENC_SCATTER_GATHER                                   |
7454418919fSjohnjiang| Set if a device supports scatter-gather functionality              |
7464418919fSjohnjiang+--------------------------------------------------------------------+
7474418919fSjohnjiang|RTE_BBDEV_LDPC_ENC_CONCATENATION                                    |
7484418919fSjohnjiang| Set if a device supports concatenation of non byte aligned output  |
7494418919fSjohnjiang+--------------------------------------------------------------------+
7504418919fSjohnjiang
7514418919fSjohnjiangThe structure passed for each LDPC encode operation is given below,
7524418919fSjohnjiangwith the operation flags forming a bitmask in the ``op_flags`` field.
7534418919fSjohnjiang
7544418919fSjohnjiang.. code-block:: c
7554418919fSjohnjiang
7564418919fSjohnjiang    struct rte_bbdev_op_ldpc_enc {
7574418919fSjohnjiang
7584418919fSjohnjiang        struct rte_bbdev_op_data input;
7594418919fSjohnjiang        struct rte_bbdev_op_data output;
7604418919fSjohnjiang
7614418919fSjohnjiang        uint32_t op_flags;
7624418919fSjohnjiang        uint8_t rv_index;
7634418919fSjohnjiang        uint8_t basegraph;
7644418919fSjohnjiang        uint16_t z_c;
7654418919fSjohnjiang        uint16_t n_cb;
7664418919fSjohnjiang        uint8_t q_m;
7674418919fSjohnjiang        uint16_t n_filler;
7684418919fSjohnjiang        uint8_t code_block_mode;
7694418919fSjohnjiang        union {
7704418919fSjohnjiang            struct rte_bbdev_op_enc_ldpc_cb_params cb_params;
7714418919fSjohnjiang            struct rte_bbdev_op_enc_ldpc_tb_params tb_params;
7724418919fSjohnjiang        };
7734418919fSjohnjiang    };
7744418919fSjohnjiang
7754418919fSjohnjiangThe LDPC encode parameters are set out in the table below.
7764418919fSjohnjiang
7774418919fSjohnjiang+----------------+--------------------------------------------------------------------+
7784418919fSjohnjiang|Parameter       |Description                                                         |
7794418919fSjohnjiang+================+====================================================================+
7804418919fSjohnjiang|input           |input CB or TB data                                                 |
7814418919fSjohnjiang+----------------+--------------------------------------------------------------------+
7824418919fSjohnjiang|output          |rate matched CB or TB output buffer                                 |
7834418919fSjohnjiang+----------------+--------------------------------------------------------------------+
7844418919fSjohnjiang|op_flags        |bitmask of all active operation capabilities                        |
7854418919fSjohnjiang+----------------+--------------------------------------------------------------------+
7864418919fSjohnjiang|rv_index        |redundancy version index [0..3]                                     |
7874418919fSjohnjiang+----------------+--------------------------------------------------------------------+
7884418919fSjohnjiang|basegraph       |Basegraph 1 or 2                                                    |
7894418919fSjohnjiang+----------------+--------------------------------------------------------------------+
7904418919fSjohnjiang|z_c             |Zc, LDPC lifting size                                               |
7914418919fSjohnjiang+----------------+--------------------------------------------------------------------+
7924418919fSjohnjiang|n_cb            |Ncb, length of the circular buffer in bits.                         |
7934418919fSjohnjiang+----------------+--------------------------------------------------------------------+
7944418919fSjohnjiang|q_m             |Qm, modulation order {2,4,6,8,10}                                   |
7954418919fSjohnjiang+----------------+--------------------------------------------------------------------+
7964418919fSjohnjiang|n_filler        |number of filler bits                                               |
7974418919fSjohnjiang+----------------+--------------------------------------------------------------------+
7984418919fSjohnjiang|code_block_mode |code block or transport block mode                                  |
7994418919fSjohnjiang+----------------+--------------------------------------------------------------------+
8004418919fSjohnjiang|op_flags        |bitmask of all active operation capabilities                        |
8014418919fSjohnjiang+----------------+--------------------------------------------------------------------+
8024418919fSjohnjiang|**cb_params**   |code block specific parameters (code block mode only)               |
8034418919fSjohnjiang+----------------+------------+-------------------------------------------------------+
8044418919fSjohnjiang|                |e           |E, length of the rate matched output sequence in bits  |
8054418919fSjohnjiang+----------------+------------+-------------------------------------------------------+
8064418919fSjohnjiang|**tb_params**   | transport block specific parameters (transport block mode only)    |
8074418919fSjohnjiang+----------------+------------+-------------------------------------------------------+
8084418919fSjohnjiang|                |c           |number of CBs in the TB or partial TB                  |
8094418919fSjohnjiang+----------------+------------+-------------------------------------------------------+
8104418919fSjohnjiang|                |r           |index of the first CB in the inbound mbuf data         |
8114418919fSjohnjiang+----------------+------------+-------------------------------------------------------+
8124418919fSjohnjiang|                |c_ab        |number of CBs that use Ea before switching to Eb       |
8134418919fSjohnjiang+----------------+------------+-------------------------------------------------------+
8144418919fSjohnjiang|                |ea          |Ea, length of the RM output sequence in bits, r < cab  |
8154418919fSjohnjiang+----------------+------------+-------------------------------------------------------+
8164418919fSjohnjiang|                |eb          |Eb, length of the RM output sequence in bits, r >= cab |
8174418919fSjohnjiang+----------------+------------+-------------------------------------------------------+
8184418919fSjohnjiang
8194418919fSjohnjiangThe mbuf input ``input`` is mandatory for all BBDEV PMDs and is the
8204418919fSjohnjiangincoming code block or transport block data.
8214418919fSjohnjiang
8224418919fSjohnjiangThe mbuf output ``output`` is mandatory and is the encoded CB(s). In
8234418919fSjohnjiangCB-mode ut contains the encoded CB of size ``e`` (E  in 3GPP TS 38.212
8244418919fSjohnjiangsection 6.2.5). In TB-mode it contains multiple contiguous encoded CBs
8254418919fSjohnjiangof size ``ea`` or ``eb``.
8264418919fSjohnjiangThe ``output`` buffer is allocated by the application with enough room
8274418919fSjohnjiangfor the output data.
8284418919fSjohnjiang
8294418919fSjohnjiangThe encode interface works on both a code block (CB) and a transport
8304418919fSjohnjiangblock (TB) basis.
8314418919fSjohnjiang
8324418919fSjohnjiang  **NOTE:** All enqueued ops in one ``rte_bbdev_enqueue_enc_ops()``
8334418919fSjohnjiang  call belong to one mode, either CB-mode or TB-mode.
8344418919fSjohnjiang
8354418919fSjohnjiangThe valid modes of operation are:
8364418919fSjohnjiang
8374418919fSjohnjiang* CB-mode: one CB (attach CRC24B if required)
8384418919fSjohnjiang* CB-mode: one CB making up one TB (attach CRC24A if required)
8394418919fSjohnjiang* TB-mode: one or more CB of a partial TB (attach CRC24B(s) if required)
8404418919fSjohnjiang* TB-mode: one or more CB of a complete TB (attach CRC24AB(s) if required)
8414418919fSjohnjiang
8424418919fSjohnjiangIn CB-mode if ``RTE_BBDEV_LDPC_CRC_24A_ATTACH`` is set then CRC24A
8434418919fSjohnjiangis appended to the CB. If ``RTE_BBDEV_LDPC_CRC_24A_ATTACH`` is not
8444418919fSjohnjiangset the application is responsible for calculating and appending CRC24A
8454418919fSjohnjiangbefore calling BBDEV. The input data mbuf ``length`` is inclusive of
8464418919fSjohnjiangCRC24A/B where present and is equal to the code block size ``K``.
8474418919fSjohnjiang
8484418919fSjohnjiangIn TB-mode, CRC24A is assumed to be pre-calculated and appended to the
8494418919fSjohnjianginbound TB data buffer, unless the ``RTE_BBDEV_LDPC_CRC_24A_ATTACH``
8504418919fSjohnjiangflag is set when it is the  responsibility of BBDEV. The input data
8514418919fSjohnjiangmbuf ``length`` is total size of the CBs inclusive of any CRC24A and
8524418919fSjohnjiangCRC24B in the case they were appended by the application.
8534418919fSjohnjiang
8544418919fSjohnjiangNot all BBDEV PMDs may be capable of CRC24A/B calculation. Flags
8554418919fSjohnjiang``RTE_BBDEV_LDPC_CRC_24A_ATTACH`` and ``RTE_BBDEV_LDPC_CRC_24B_ATTACH``
8564418919fSjohnjianginform the application of the relevant capability. These flags can be set
8574418919fSjohnjiangin the ``op_flags`` parameter to indicate BBDEV to calculate and append
8584418919fSjohnjiangCRC24A to CB before going forward with LDPC encoding.
8594418919fSjohnjiang
8604418919fSjohnjiangThe difference between the partial and full-size TB is that BBDEV needs
8614418919fSjohnjiangthe index of the first CB in this group and the number of CBs in the group.
8624418919fSjohnjiangThe first CB index is given by ``r`` but the number of the CBs is
8634418919fSjohnjiangcalculated by BBDEV before signalling to the driver.
8644418919fSjohnjiang
8654418919fSjohnjiangThe number of CBs in the group should not be confused with ``c``, the
8664418919fSjohnjiangtotal number of CBs in the full TB (``C`` as per 3GPP TS 38.212 section 5.2.2)
8674418919fSjohnjiang
8684418919fSjohnjiangFigure :numref:`figure_turbo_tb_encode` above
8694418919fSjohnjiangshowing the Turbo encoding of CBs using BBDEV interface in TB-mode
8704418919fSjohnjiangis also valid for LDPC encode.
8714418919fSjohnjiang
8724418919fSjohnjiangBBDEV LDPC Decode Operation
8734418919fSjohnjiang~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8744418919fSjohnjiang
8754418919fSjohnjiangThe operation flags that can be set for each LDPC decode operation are
8764418919fSjohnjianggiven below.
8774418919fSjohnjiang
8784418919fSjohnjiang  **NOTE:** The actual operation flags that may be used with a specific
8794418919fSjohnjiang  BBDEV PMD are dependent on the driver capabilities as reported via
8804418919fSjohnjiang  ``rte_bbdev_info_get()``, and may be a subset of those below.
8814418919fSjohnjiang
8824418919fSjohnjiang+--------------------------------------------------------------------+
8834418919fSjohnjiang|Description of LDPC decode capability flags                         |
8844418919fSjohnjiang+====================================================================+
8854418919fSjohnjiang|RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK                                   |
8864418919fSjohnjiang| Set for transport block CRC-24A checking                           |
8874418919fSjohnjiang+--------------------------------------------------------------------+
8884418919fSjohnjiang|RTE_BBDEV_LDPC_CRC_TYPE_24B_CHECK                                   |
8894418919fSjohnjiang| Set for code block CRC-24B checking                                |
8904418919fSjohnjiang+--------------------------------------------------------------------+
8914418919fSjohnjiang|RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP                                    |
8924418919fSjohnjiang| Set to drop the last CRC bits decoding output                      |
8934418919fSjohnjiang+--------------------------------------------------------------------+
8944418919fSjohnjiang|RTE_BBDEV_LDPC_DEINTERLEAVER_BYPASS                                 |
8954418919fSjohnjiang| Set for bit-level de-interleaver bypass on input stream            |
8964418919fSjohnjiang+--------------------------------------------------------------------+
8974418919fSjohnjiang|RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE                                 |
8984418919fSjohnjiang| Set for HARQ combined input stream enable                          |
8994418919fSjohnjiang+--------------------------------------------------------------------+
9004418919fSjohnjiang|RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE                                |
9014418919fSjohnjiang| Set for HARQ combined output stream enable                         |
9024418919fSjohnjiang+--------------------------------------------------------------------+
9034418919fSjohnjiang|RTE_BBDEV_LDPC_DECODE_BYPASS                                        |
9044418919fSjohnjiang| Set for LDPC decoder bypass                                        |
9054418919fSjohnjiang|                                                                    |
9064418919fSjohnjiang| RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE must be set                   |
9074418919fSjohnjiang+--------------------------------------------------------------------+
9084418919fSjohnjiang|RTE_BBDEV_LDPC_DECODE_SOFT_OUT                                      |
9094418919fSjohnjiang| Set for soft-output stream  enable                                 |
9104418919fSjohnjiang+--------------------------------------------------------------------+
9114418919fSjohnjiang|RTE_BBDEV_LDPC_SOFT_OUT_RM_BYPASS                                   |
9124418919fSjohnjiang| Set for Rate-Matching bypass on soft-out stream                    |
9134418919fSjohnjiang+--------------------------------------------------------------------+
9144418919fSjohnjiang|RTE_BBDEV_LDPC_SOFT_OUT_DEINTERLEAVER_BYPASS                        |
9154418919fSjohnjiang| Set for bit-level de-interleaver bypass on soft-output stream      |
9164418919fSjohnjiang+--------------------------------------------------------------------+
9174418919fSjohnjiang|RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE                                |
9184418919fSjohnjiang| Set for iteration stopping on successful decode condition enable   |
9194418919fSjohnjiang|                                                                    |
9204418919fSjohnjiang| Where a successful decode is a successful syndrome check           |
9214418919fSjohnjiang+--------------------------------------------------------------------+
9224418919fSjohnjiang|RTE_BBDEV_LDPC_DEC_INTERRUPTS                                       |
9234418919fSjohnjiang| Set if a device supports decoder dequeue interrupts                |
9244418919fSjohnjiang+--------------------------------------------------------------------+
9254418919fSjohnjiang|RTE_BBDEV_LDPC_DEC_SCATTER_GATHER                                   |
9264418919fSjohnjiang| Set if a device supports scatter-gather functionality              |
9274418919fSjohnjiang+--------------------------------------------------------------------+
9284418919fSjohnjiang|RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION                                |
9294418919fSjohnjiang| Set if a device supports input/output HARQ compression             |
930*2d9fd380Sjfb8856606| Data is packed as 6 bits by dropping and saturating the MSBs       |
9314418919fSjohnjiang+--------------------------------------------------------------------+
9324418919fSjohnjiang|RTE_BBDEV_LDPC_LLR_COMPRESSION                                      |
9334418919fSjohnjiang| Set if a device supports input LLR compression                     |
934*2d9fd380Sjfb8856606| Data is packed as 6 bits by dropping and saturating the MSBs       |
9354418919fSjohnjiang+--------------------------------------------------------------------+
9364418919fSjohnjiang|RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE                       |
9374418919fSjohnjiang| Set if a device supports HARQ input to device's internal memory    |
9384418919fSjohnjiang+--------------------------------------------------------------------+
9394418919fSjohnjiang|RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE                      |
9404418919fSjohnjiang| Set if a device supports HARQ output to device's internal memory   |
9414418919fSjohnjiang+--------------------------------------------------------------------+
9424418919fSjohnjiang|RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK                        |
9434418919fSjohnjiang| Set if a device supports loopback access to HARQ internal memory   |
9444418919fSjohnjiang+--------------------------------------------------------------------+
9454418919fSjohnjiang
9464418919fSjohnjiangThe structure passed for each LDPC decode operation is given below,
9474418919fSjohnjiangwith the operation flags forming a bitmask in the ``op_flags`` field.
9484418919fSjohnjiang
9494418919fSjohnjiang.. code-block:: c
9504418919fSjohnjiang
9514418919fSjohnjiang
9524418919fSjohnjiang    struct rte_bbdev_op_ldpc_dec {
9534418919fSjohnjiang
9544418919fSjohnjiang        struct rte_bbdev_op_data input;
9554418919fSjohnjiang        struct rte_bbdev_op_data hard_output;
9564418919fSjohnjiang        struct rte_bbdev_op_data soft_output;
9574418919fSjohnjiang        struct rte_bbdev_op_data harq_combined_input;
9584418919fSjohnjiang        struct rte_bbdev_op_data harq_combined_output;
9594418919fSjohnjiang
9604418919fSjohnjiang        uint32_t op_flags;
9614418919fSjohnjiang        uint8_t rv_index;
9624418919fSjohnjiang        uint8_t basegraph;
9634418919fSjohnjiang        uint16_t z_c;
9644418919fSjohnjiang        uint16_t n_cb;
9654418919fSjohnjiang        uint8_t q_m;
9664418919fSjohnjiang        uint16_t n_filler;
9674418919fSjohnjiang        uint8_t iter_max;
9684418919fSjohnjiang        uint8_t iter_count;
9694418919fSjohnjiang        uint8_t code_block_mode;
9704418919fSjohnjiang        union {
9714418919fSjohnjiang            struct rte_bbdev_op_dec_ldpc_cb_params cb_params;
9724418919fSjohnjiang            struct rte_bbdev_op_dec_ldpc_tb_params tb_params;
9734418919fSjohnjiang        };
9744418919fSjohnjiang    };
9754418919fSjohnjiang
9764418919fSjohnjiang
9774418919fSjohnjiangThe LDPC decode parameters are set out in the table below.
9784418919fSjohnjiang
9794418919fSjohnjiang+----------------+--------------------------------------------------------------------+
9804418919fSjohnjiang|Parameter       |Description                                                         |
9814418919fSjohnjiang+================+====================================================================+
9824418919fSjohnjiang|input           |input CB or TB data                                                 |
9834418919fSjohnjiang+----------------+--------------------------------------------------------------------+
9844418919fSjohnjiang|hard_output     |hard decisions buffer, decoded output                               |
9854418919fSjohnjiang+----------------+--------------------------------------------------------------------+
9864418919fSjohnjiang|soft_output     |soft LLR output buffer (optional)                                   |
9874418919fSjohnjiang+----------------+--------------------------------------------------------------------+
9884418919fSjohnjiang|harq_comb_input |HARQ combined input buffer (optional)                               |
9894418919fSjohnjiang+----------------+--------------------------------------------------------------------+
9904418919fSjohnjiang|harq_comb_output|HARQ combined output buffer (optional)                              |
9914418919fSjohnjiang+----------------+--------------------------------------------------------------------+
9924418919fSjohnjiang|op_flags        |bitmask of all active operation capabilities                        |
9934418919fSjohnjiang+----------------+--------------------------------------------------------------------+
9944418919fSjohnjiang|rv_index        |redundancy version index [0..3]                                     |
9954418919fSjohnjiang+----------------+--------------------------------------------------------------------+
9964418919fSjohnjiang|basegraph       |Basegraph 1 or 2                                                    |
9974418919fSjohnjiang+----------------+--------------------------------------------------------------------+
9984418919fSjohnjiang|z_c             |Zc, LDPC lifting size                                               |
9994418919fSjohnjiang+----------------+--------------------------------------------------------------------+
10004418919fSjohnjiang|n_cb            |Ncb, length of the circular buffer in bits.                         |
10014418919fSjohnjiang+----------------+--------------------------------------------------------------------+
10024418919fSjohnjiang|q_m             |Qm, modulation order {1,2,4,6,8} from pi/2-BPSK to 256QAM           |
10034418919fSjohnjiang+----------------+--------------------------------------------------------------------+
10044418919fSjohnjiang|n_filler        |number of filler bits                                               |
10054418919fSjohnjiang+----------------+--------------------------------------------------------------------+
10064418919fSjohnjiang|iter_max        |maximum number of iterations to perform in decode all CBs           |
10074418919fSjohnjiang+----------------+--------------------------------------------------------------------+
10084418919fSjohnjiang|iter_count      |number of iterations performed in decoding all CBs                  |
10094418919fSjohnjiang+----------------+--------------------------------------------------------------------+
10104418919fSjohnjiang|code_block_mode |code block or transport block mode                                  |
10114418919fSjohnjiang+----------------+--------------------------------------------------------------------+
10124418919fSjohnjiang|op_flags        |bitmask of all active operation capabilities                        |
10134418919fSjohnjiang+----------------+--------------------------------------------------------------------+
10144418919fSjohnjiang|**cb_params**   |code block specific parameters (code block mode only)               |
10154418919fSjohnjiang+----------------+------------+-------------------------------------------------------+
10164418919fSjohnjiang|                |e           |E, length of the rate matched output sequence in bits  |
10174418919fSjohnjiang+----------------+------------+-------------------------------------------------------+
10184418919fSjohnjiang|**tb_params**   | transport block specific parameters (transport block mode only)    |
10194418919fSjohnjiang+----------------+------------+-------------------------------------------------------+
10204418919fSjohnjiang|                |c           |number of CBs in the TB or partial TB                  |
10214418919fSjohnjiang+----------------+------------+-------------------------------------------------------+
10224418919fSjohnjiang|                |r           |index of the first CB in the inbound mbuf data         |
10234418919fSjohnjiang+----------------+------------+-------------------------------------------------------+
10244418919fSjohnjiang|                |c_ab        |number of CBs that use Ea before switching to Eb       |
10254418919fSjohnjiang+----------------+------------+-------------------------------------------------------+
10264418919fSjohnjiang|                |ea          |Ea, length of the RM output sequence in bits, r < cab  |
10274418919fSjohnjiang+----------------+------------+-------------------------------------------------------+
10284418919fSjohnjiang|                |eb          |Eb, length of the RM output sequence in bits  r >= cab |
10294418919fSjohnjiang+----------------+------------+-------------------------------------------------------+
10304418919fSjohnjiang
10314418919fSjohnjiangThe mbuf input ``input`` encoded CB data is mandatory for all BBDEV PMDs
10324418919fSjohnjiangand is the Virtual Circular Buffer data stream with null padding.
10334418919fSjohnjiangEach byte in the input circular buffer is the LLR value of each bit of
10344418919fSjohnjiangthe original CB.
10354418919fSjohnjiang
10364418919fSjohnjiangThe mbuf output ``hard_output`` is mandatory and is the decoded CBs size
10374418919fSjohnjiangK (CRC24A/B is the last 24-bit in each decoded CB).
10384418919fSjohnjiang
10394418919fSjohnjiangThe mbuf output ``soft_output`` is optional and is an LLR rate matched
10404418919fSjohnjiangoutput of size ``e`` (this is ``E`` as per 3GPP TS 38.212 section 6.2.5).
10414418919fSjohnjiang
10424418919fSjohnjiangThe mbuf input ``harq_combine_input`` is optional and is a buffer with
10434418919fSjohnjiangthe input to the HARQ combination function of the device. If the
10444418919fSjohnjiangcapability RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE is set
10454418919fSjohnjiangthen the HARQ is stored in memory internal to the device and not visible
10464418919fSjohnjiangto BBDEV.
10474418919fSjohnjiang
10484418919fSjohnjiangThe mbuf output ``harq_combine_output`` is optional and is a buffer for
10494418919fSjohnjiangthe output of the HARQ combination function of the device. If the
10504418919fSjohnjiangcapability RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE is set
10514418919fSjohnjiangthen the HARQ is stored in memory internal to the device and not visible
10524418919fSjohnjiangto BBDEV.
10534418919fSjohnjiang
10544418919fSjohnjiangThe output mbuf data structures are expected to be allocated by the
10554418919fSjohnjiangapplication with enough room for the output data.
10564418919fSjohnjiang
10574418919fSjohnjiangAs with the LDPC encode, the decode interface works on both a code block
10584418919fSjohnjiang(CB) and a transport block (TB) basis.
10594418919fSjohnjiang
10604418919fSjohnjiang  **NOTE:** All enqueued ops in one ``rte_bbdev_enqueue_dec_ops()``
10614418919fSjohnjiang  call belong to one mode, either CB-mode or TB-mode.
10624418919fSjohnjiang
10634418919fSjohnjiangThe valid modes of operation are:
10644418919fSjohnjiang
10654418919fSjohnjiang* CB-mode: one CB (check CRC24B if required)
10664418919fSjohnjiang* CB-mode: one CB making up one TB (check CRC24A if required)
10674418919fSjohnjiang* TB-mode: one or more CB making up a partial TB (check CRC24B(s) if required)
10684418919fSjohnjiang* TB-mode: one or more CB making up a complete TB (check CRC24B(s) if required)
10694418919fSjohnjiang
10704418919fSjohnjiangThe mbuf ``length`` is inclusive of CRC24A/B where present and is equal
10714418919fSjohnjiangthe code block size ``K``.
10724418919fSjohnjiang
10734418919fSjohnjiangThe first CB Virtual Circular Buffer (VCB) index is given by ``r`` but the
10744418919fSjohnjiangnumber of the remaining CB VCBs is calculated automatically by BBDEV
10754418919fSjohnjiangand passed down to the driver.
10764418919fSjohnjiang
10774418919fSjohnjiangThe number of remaining CB VCBs should not be confused with ``c``, the
10784418919fSjohnjiangtotal number of CBs in the full TB (``C`` as per 3GPP TS 38.212 section 5.2.2)
10794418919fSjohnjiang
10804418919fSjohnjiangThe ``length`` is total size of the CBs inclusive of any CRC24A and CRC24B in
10814418919fSjohnjiangcase they were appended by the application.
10824418919fSjohnjiang
10834418919fSjohnjiangFigure :numref:`figure_turbo_tb_decode` above
10844418919fSjohnjiangshowing the Turbo decoding of CBs using BBDEV interface in TB-mode
10854418919fSjohnjiangis also valid for LDPC decode.
10864418919fSjohnjiang
1087d30ea906Sjfb8856606
1088d30ea906Sjfb8856606Sample code
1089d30ea906Sjfb8856606-----------
1090d30ea906Sjfb8856606
1091d30ea906Sjfb8856606The baseband device sample application gives an introduction on how to use the
1092d30ea906Sjfb8856606bbdev framework, by giving a sample code performing a loop-back operation with a
1093d30ea906Sjfb8856606baseband processor capable of transceiving data packets.
1094d30ea906Sjfb8856606
1095d30ea906Sjfb8856606The following sample C-like pseudo-code shows the basic steps to encode several
10961646932aSjfb8856606buffers using (**sw_turbo**) bbdev PMD.
1097d30ea906Sjfb8856606
1098d30ea906Sjfb8856606.. code-block:: c
1099d30ea906Sjfb8856606
1100d30ea906Sjfb8856606    /* EAL Init */
1101d30ea906Sjfb8856606    ret = rte_eal_init(argc, argv);
1102d30ea906Sjfb8856606    if (ret < 0)
1103d30ea906Sjfb8856606        rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n");
1104d30ea906Sjfb8856606
1105d30ea906Sjfb8856606    /* Get number of available bbdev devices */
1106d30ea906Sjfb8856606    nb_bbdevs = rte_bbdev_count();
1107d30ea906Sjfb8856606    if (nb_bbdevs == 0)
1108d30ea906Sjfb8856606        rte_exit(EXIT_FAILURE, "No bbdevs detected!\n");
1109d30ea906Sjfb8856606
1110d30ea906Sjfb8856606    /* Create bbdev op pools */
1111d30ea906Sjfb8856606    bbdev_op_pool[RTE_BBDEV_OP_TURBO_ENC] =
1112d30ea906Sjfb8856606            rte_bbdev_op_pool_create("bbdev_op_pool_enc",
1113d30ea906Sjfb8856606            RTE_BBDEV_OP_TURBO_ENC, NB_MBUF, 128, rte_socket_id());
1114d30ea906Sjfb8856606
1115d30ea906Sjfb8856606    /* Get information for this device */
1116d30ea906Sjfb8856606    rte_bbdev_info_get(dev_id, &info);
1117d30ea906Sjfb8856606
1118d30ea906Sjfb8856606    /* Setup BBDEV device queues */
1119d30ea906Sjfb8856606    ret = rte_bbdev_setup_queues(dev_id, qs_nb, info.socket_id);
1120d30ea906Sjfb8856606    if (ret < 0)
1121d30ea906Sjfb8856606        rte_exit(EXIT_FAILURE,
1122d30ea906Sjfb8856606                "ERROR(%d): BBDEV %u not configured properly\n",
1123d30ea906Sjfb8856606                ret, dev_id);
1124d30ea906Sjfb8856606
1125d30ea906Sjfb8856606    /* setup device queues */
1126d30ea906Sjfb8856606    qconf.socket = info.socket_id;
1127d30ea906Sjfb8856606    qconf.queue_size = info.drv.queue_size_lim;
1128d30ea906Sjfb8856606    qconf.op_type = RTE_BBDEV_OP_TURBO_ENC;
1129d30ea906Sjfb8856606
1130d30ea906Sjfb8856606    for (q_id = 0; q_id < qs_nb; q_id++) {
1131d30ea906Sjfb8856606        /* Configure all queues belonging to this bbdev device */
1132d30ea906Sjfb8856606        ret = rte_bbdev_queue_configure(dev_id, q_id, &qconf);
1133d30ea906Sjfb8856606        if (ret < 0)
1134d30ea906Sjfb8856606            rte_exit(EXIT_FAILURE,
1135d30ea906Sjfb8856606                    "ERROR(%d): BBDEV %u queue %u not configured properly\n",
1136d30ea906Sjfb8856606                    ret, dev_id, q_id);
1137d30ea906Sjfb8856606    }
1138d30ea906Sjfb8856606
1139d30ea906Sjfb8856606    /* Start bbdev device */
1140d30ea906Sjfb8856606    ret = rte_bbdev_start(dev_id);
1141d30ea906Sjfb8856606
1142d30ea906Sjfb8856606    /* Create the mbuf mempool for pkts */
1143d30ea906Sjfb8856606    mbuf_pool = rte_pktmbuf_pool_create("bbdev_mbuf_pool",
1144d30ea906Sjfb8856606            NB_MBUF, MEMPOOL_CACHE_SIZE, 0,
1145d30ea906Sjfb8856606            RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id());
1146d30ea906Sjfb8856606    if (mbuf_pool == NULL)
1147d30ea906Sjfb8856606        rte_exit(EXIT_FAILURE,
1148d30ea906Sjfb8856606                "Unable to create '%s' pool\n", pool_name);
1149d30ea906Sjfb8856606
1150d30ea906Sjfb8856606    while (!global_exit_flag) {
1151d30ea906Sjfb8856606
1152d30ea906Sjfb8856606        /* Allocate burst of op structures in preparation for enqueue */
1153d30ea906Sjfb8856606        if (rte_bbdev_enc_op_alloc_bulk(bbdev_op_pool[RTE_BBDEV_OP_TURBO_ENC],
1154d30ea906Sjfb8856606            ops_burst, op_num) != 0)
1155d30ea906Sjfb8856606            continue;
1156d30ea906Sjfb8856606
1157d30ea906Sjfb8856606        /* Allocate input mbuf pkts */
1158d30ea906Sjfb8856606        ret = rte_pktmbuf_alloc_bulk(mbuf_pool, input_pkts_burst, MAX_PKT_BURST);
1159d30ea906Sjfb8856606        if (ret < 0)
1160d30ea906Sjfb8856606            continue;
1161d30ea906Sjfb8856606
1162d30ea906Sjfb8856606        /* Allocate output mbuf pkts */
1163d30ea906Sjfb8856606        ret = rte_pktmbuf_alloc_bulk(mbuf_pool, output_pkts_burst, MAX_PKT_BURST);
1164d30ea906Sjfb8856606        if (ret < 0)
1165d30ea906Sjfb8856606            continue;
1166d30ea906Sjfb8856606
1167d30ea906Sjfb8856606        for (j = 0; j < op_num; j++) {
1168d30ea906Sjfb8856606            /* Append the size of the ethernet header */
1169d30ea906Sjfb8856606            rte_pktmbuf_append(input_pkts_burst[j],
11704418919fSjohnjiang                    sizeof(struct rte_ether_hdr));
1171d30ea906Sjfb8856606
1172d30ea906Sjfb8856606            /* set op */
1173d30ea906Sjfb8856606
1174d30ea906Sjfb8856606            ops_burst[j]->turbo_enc.input.offset =
11754418919fSjohnjiang                sizeof(struct rte_ether_hdr);
1176d30ea906Sjfb8856606
1177d30ea906Sjfb8856606            ops_burst[j]->turbo_enc->input.length =
1178d30ea906Sjfb8856606                rte_pktmbuf_pkt_len(bbdev_pkts[j]);
1179d30ea906Sjfb8856606
1180d30ea906Sjfb8856606            ops_burst[j]->turbo_enc->input.data =
1181d30ea906Sjfb8856606                input_pkts_burst[j];
1182d30ea906Sjfb8856606
1183d30ea906Sjfb8856606            ops_burst[j]->turbo_enc->output.offset =
11844418919fSjohnjiang                sizeof(struct rte_ether_hdr);
1185d30ea906Sjfb8856606
1186d30ea906Sjfb8856606            ops_burst[j]->turbo_enc->output.data =
1187d30ea906Sjfb8856606                    output_pkts_burst[j];
1188d30ea906Sjfb8856606        }
1189d30ea906Sjfb8856606
1190d30ea906Sjfb8856606        /* Enqueue packets on BBDEV device */
1191d30ea906Sjfb8856606        op_num = rte_bbdev_enqueue_enc_ops(qconf->bbdev_id,
1192d30ea906Sjfb8856606                qconf->bbdev_qs[q], ops_burst,
1193d30ea906Sjfb8856606                MAX_PKT_BURST);
1194d30ea906Sjfb8856606
1195d30ea906Sjfb8856606        /* Dequeue packets from BBDEV device*/
1196d30ea906Sjfb8856606        op_num = rte_bbdev_dequeue_enc_ops(qconf->bbdev_id,
1197d30ea906Sjfb8856606                qconf->bbdev_qs[q], ops_burst,
1198d30ea906Sjfb8856606                MAX_PKT_BURST);
1199d30ea906Sjfb8856606    }
1200d30ea906Sjfb8856606
1201d30ea906Sjfb8856606
1202d30ea906Sjfb8856606BBDEV Device API
1203d30ea906Sjfb8856606~~~~~~~~~~~~~~~~
1204d30ea906Sjfb8856606
1205d30ea906Sjfb8856606The bbdev Library API is described in the *DPDK API Reference* document.
1206