xref: /dpdk/doc/guides/prog_guide/bbdev.rst (revision 7a86a806dcf32213171adc9dc36d87b3d0c2750b)
1..  SPDX-License-Identifier: BSD-3-Clause
2    Copyright(c) 2017 Intel Corporation
3
4Wireless Baseband Device Library
5================================
6
7The Wireless Baseband library provides a common programming framework that
8abstracts HW accelerators based on FPGA and/or Fixed Function Accelerators that
9assist with 3GPP Physical Layer processing. Furthermore, it decouples the
10application from the compute-intensive wireless functions by abstracting their
11optimized libraries to appear as virtual bbdev devices.
12
13The functional scope of the BBDEV library are those functions in relation to
14the 3GPP Layer 1 signal processing (channel coding, modulation, ...).
15
16The framework currently only supports FEC function.
17
18
19Design Principles
20-----------------
21
22The Wireless Baseband library follows the same ideology of DPDK's Ethernet
23Device and Crypto Device frameworks. Wireless Baseband provides a generic
24acceleration abstraction framework which supports both physical (hardware) and
25virtual (software) wireless acceleration functions.
26
27Device Management
28-----------------
29
30Device Creation
31~~~~~~~~~~~~~~~
32
33Physical bbdev devices are discovered during the PCI probe/enumeration of the
34EAL function which is executed at DPDK initialization, based on
35their PCI device identifier, each unique PCI BDF (bus/bridge, device,
36function).
37
38Virtual devices can be created by two mechanisms, either using the EAL command
39line options or from within the application using an EAL API directly.
40
41From the command line using the --vdev EAL option
42
43.. code-block:: console
44
45   --vdev 'baseband_turbo_sw,max_nb_queues=8,socket_id=0'
46
47Or using the rte_vdev_init API within the application code.
48
49.. code-block:: c
50
51    rte_vdev_init("baseband_turbo_sw", "max_nb_queues=2,socket_id=0")
52
53All virtual bbdev devices support the following initialization parameters:
54
55- ``max_nb_queues`` - maximum number of queues supported by the device.
56
57- ``socket_id`` - socket on which to allocate the device resources on.
58
59
60Device Identification
61~~~~~~~~~~~~~~~~~~~~~
62
63Each device, whether virtual or physical is uniquely designated by two
64identifiers:
65
66- A unique device index used to designate the bbdev device in all functions
67  exported by the bbdev API.
68
69- A device name used to designate the bbdev device in console messages, for
70  administration or debugging purposes. For ease of use, the port name includes
71  the port index.
72
73
74Device Configuration
75~~~~~~~~~~~~~~~~~~~~
76
77From the application point of view, each instance of a bbdev device consists of
78one or more queues identified by queue IDs. While different devices may have
79different capabilities (e.g. support different operation types), all queues on
80a device support identical configuration possibilities. A queue is configured
81for only one type of operation and is configured at initialization time.
82When an operation is enqueued to a specific queue ID, the result is dequeued
83from the same queue ID.
84
85Configuration of a device has two different levels: configuration that applies
86to the whole device, and configuration that applies to a single queue.
87
88Device configuration is applied with
89``rte_bbdev_setup_queues(dev_id,num_queues,socket_id)``
90and queue configuration is applied with
91``rte_bbdev_queue_configure(dev_id,queue_id,conf)``. Note that, although all
92queues on a device support same capabilities, they can be configured differently
93and will then behave differently.
94Devices supporting interrupts can enable them by using
95``rte_bbdev_intr_enable(dev_id)``.
96
97The configuration of each bbdev device includes the following operations:
98
99- Allocation of resources, including hardware resources if a physical device.
100- Resetting the device into a well-known default state.
101- Initialization of statistics counters.
102
103The ``rte_bbdev_setup_queues`` API is used to setup queues for a bbdev device.
104
105.. code-block:: c
106
107   int rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues,
108            int socket_id);
109
110- ``num_queues`` argument identifies the total number of queues to setup for
111  this device.
112
113- ``socket_id`` specifies which socket will be used to allocate the memory.
114
115
116The ``rte_bbdev_intr_enable`` API is used to enable interrupts for a bbdev
117device, if supported by the driver. Should be called before starting the device.
118
119.. code-block:: c
120
121   int rte_bbdev_intr_enable(uint16_t dev_id);
122
123
124Queues Configuration
125~~~~~~~~~~~~~~~~~~~~
126
127Each bbdev devices queue is individually configured through the
128``rte_bbdev_queue_configure()`` API.
129Each queue resources may be allocated on a specified socket.
130
131.. code-block:: c
132
133    struct rte_bbdev_queue_conf {
134        int socket;
135        uint32_t queue_size;
136        uint8_t priority;
137        bool deferred_start;
138        enum rte_bbdev_op_type op_type;
139    };
140
141Device & Queues Management
142~~~~~~~~~~~~~~~~~~~~~~~~~~
143
144After initialization, devices are in a stopped state, so must be started by the
145application. If an application is finished using a device it can close the
146device. Once closed, it cannot be restarted.
147
148.. code-block:: c
149
150    int rte_bbdev_start(uint16_t dev_id)
151    int rte_bbdev_stop(uint16_t dev_id)
152    int rte_bbdev_close(uint16_t dev_id)
153    int rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id)
154    int rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id)
155
156
157By default, all queues are started when the device is started, but they can be
158stopped individually.
159
160.. code-block:: c
161
162    int rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id)
163    int rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id)
164
165
166Logical Cores, Memory and Queues Relationships
167~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
168
169The bbdev poll mode device driver library supports NUMA architecture, in which
170a processor's logical cores and interfaces utilize it's local memory. Therefore
171with baseband operations, the mbuf being operated on should be allocated from memory
172pools created in the local memory. The buffers should, if possible, remain on
173the local processor to obtain the best performance results and buffer
174descriptors should be populated with mbufs allocated from a mempool allocated
175from local memory.
176
177The run-to-completion model also performs better, especially in the case of
178virtual bbdev devices, if the baseband operation and data buffers are in local
179memory instead of a remote processor's memory. This is also true for the
180pipe-line model provided all logical cores used are located on the same processor.
181
182Multiple logical cores should never share the same queue for enqueuing
183operations or dequeuing operations on the same bbdev device since this would
184require global locks and hinder performance. It is however possible to use a
185different logical core to dequeue an operation on a queue pair from the logical
186core which it was enqueued on. This means that a baseband burst enqueue/dequeue
187APIs are a logical place to transition from one logical core to another in a
188packet processing pipeline.
189
190
191Device Operation Capabilities
192-----------------------------
193
194Capabilities (in terms of operations supported, max number of queues, etc.)
195identify what a bbdev is capable of performing that differs from one device to
196another. For the full scope of the bbdev capability see the definition of the
197structure in the *DPDK API Reference*.
198
199.. code-block:: c
200
201   struct rte_bbdev_op_cap;
202
203A device reports its capabilities when registering itself in the bbdev framework.
204With the aid of this capabilities mechanism, an application can query devices to
205discover which operations within the 3GPP physical layer they are capable of
206performing. Below is an example of the capabilities for a PMD it supports in
207relation to Turbo Encoding and Decoding operations.
208
209.. code-block:: c
210
211    static const struct rte_bbdev_op_cap bbdev_capabilities[] = {
212        {
213            .type = RTE_BBDEV_OP_TURBO_DEC,
214            .cap.turbo_dec = {
215                .capability_flags =
216                    RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE |
217                    RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN |
218                    RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN |
219                    RTE_BBDEV_TURBO_CRC_TYPE_24B |
220                    RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP |
221                    RTE_BBDEV_TURBO_EARLY_TERMINATION,
222                .max_llr_modulus = 16,
223                .num_buffers_src = RTE_BBDEV_TURBO_MAX_CODE_BLOCKS,
224                .num_buffers_hard_out =
225                        RTE_BBDEV_TURBO_MAX_CODE_BLOCKS,
226                .num_buffers_soft_out = 0,
227            }
228        },
229        {
230            .type   = RTE_BBDEV_OP_TURBO_ENC,
231            .cap.turbo_enc = {
232                .capability_flags =
233                        RTE_BBDEV_TURBO_CRC_24B_ATTACH |
234                        RTE_BBDEV_TURBO_CRC_24A_ATTACH |
235                        RTE_BBDEV_TURBO_RATE_MATCH |
236                        RTE_BBDEV_TURBO_RV_INDEX_BYPASS,
237                .num_buffers_src = RTE_BBDEV_TURBO_MAX_CODE_BLOCKS,
238                .num_buffers_dst = RTE_BBDEV_TURBO_MAX_CODE_BLOCKS,
239            }
240        },
241        RTE_BBDEV_END_OF_CAPABILITIES_LIST()
242    };
243
244Capabilities Discovery
245~~~~~~~~~~~~~~~~~~~~~~
246
247Discovering the features and capabilities of a bbdev device poll mode driver
248is achieved through the ``rte_bbdev_info_get()`` function.
249
250.. code-block:: c
251
252   int rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info)
253
254This allows the user to query a specific bbdev PMD and get all the device
255capabilities. The ``rte_bbdev_info`` structure provides two levels of
256information:
257
258- Device relevant information, like: name and related rte_bus.
259
260- Driver specific information, as defined by the ``struct rte_bbdev_driver_info``
261  structure, this is where capabilities reside along with other specifics like:
262  maximum queue sizes and priority level.
263
264.. code-block:: c
265
266    struct rte_bbdev_info {
267        int socket_id;
268        const char *dev_name;
269        const struct rte_device *device;
270        uint16_t num_queues;
271        bool started;
272        struct rte_bbdev_driver_info drv;
273    };
274
275
276Operation Processing
277--------------------
278
279Scheduling of baseband operations on DPDK's application data path is
280performed using a burst oriented asynchronous API set. A queue on a bbdev
281device accepts a burst of baseband operations using enqueue burst API. On physical
282bbdev devices the enqueue burst API will place the operations to be processed
283on the device's hardware input queue, for virtual devices the processing of the
284baseband operations is usually completed during the enqueue call to the bbdev
285device. The dequeue burst API will retrieve any processed operations available
286from the queue on the bbdev device, from physical devices this is usually
287directly from the device's processed queue, and for virtual device's from a
288``rte_ring`` where processed operations are placed after being processed on the
289enqueue call.
290
291
292Enqueue / Dequeue Burst APIs
293~~~~~~~~~~~~~~~~~~~~~~~~~~~~
294
295The burst enqueue API uses a bbdev device identifier and a queue
296identifier to specify the bbdev device queue to schedule the processing on.
297The ``num_ops`` parameter is the number of operations to process which are
298supplied in the ``ops`` array of ``rte_bbdev_*_op`` structures.
299The enqueue function returns the number of operations it actually enqueued for
300processing, a return value equal to ``num_ops`` means that all packets have been
301enqueued.
302
303.. code-block:: c
304
305    uint16_t rte_bbdev_enqueue_enc_ops(uint16_t dev_id, uint16_t queue_id,
306            struct rte_bbdev_enc_op **ops, uint16_t num_ops)
307
308    uint16_t rte_bbdev_enqueue_dec_ops(uint16_t dev_id, uint16_t queue_id,
309            struct rte_bbdev_dec_op **ops, uint16_t num_ops)
310
311The dequeue API uses the same format as the enqueue API of processed but
312the ``num_ops`` and ``ops`` parameters are now used to specify the max processed
313operations the user wishes to retrieve and the location in which to store them.
314The API call returns the actual number of processed operations returned, this
315can never be larger than ``num_ops``.
316
317.. code-block:: c
318
319    uint16_t rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id,
320            struct rte_bbdev_enc_op **ops, uint16_t num_ops)
321
322    uint16_t rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id,
323            struct rte_bbdev_dec_op **ops, uint16_t num_ops)
324
325Operation Representation
326~~~~~~~~~~~~~~~~~~~~~~~~
327
328An encode bbdev operation is represented by ``rte_bbdev_enc_op`` structure,
329and by ``rte_bbdev_dec_op`` for decode. These structures act as metadata
330containers for all necessary information required for the bbdev operation to be
331processed on a particular bbdev device poll mode driver.
332
333.. code-block:: c
334
335    struct rte_bbdev_enc_op {
336        int status;
337        struct rte_mempool *mempool;
338        void *opaque_data;
339        union {
340            struct rte_bbdev_op_turbo_enc turbo_enc;
341            struct rte_bbdev_op_ldpc_enc ldpc_enc;
342        }
343    };
344
345    struct rte_bbdev_dec_op {
346        int status;
347        struct rte_mempool *mempool;
348        void *opaque_data;
349        union {
350            struct rte_bbdev_op_turbo_dec turbo_enc;
351            struct rte_bbdev_op_ldpc_dec ldpc_enc;
352        }
353    };
354
355The operation structure by itself defines the operation type. It includes an
356operation status, a reference to the operation specific data, which can vary in
357size and content depending on the operation being provisioned. It also contains
358the source mempool for the operation, if it is allocated from a mempool.
359
360If bbdev operations are allocated from a bbdev operation mempool, see next
361section, there is also the ability to allocate private memory with the
362operation for applications purposes.
363
364Application software is responsible for specifying all the operation specific
365fields in the ``rte_bbdev_*_op`` structure which are then used by the bbdev PMD
366to process the requested operation.
367
368
369Operation Management and Allocation
370~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
371
372The bbdev library provides an API set for managing bbdev operations which
373utilize the Mempool Library to allocate operation buffers. Therefore, it ensures
374that the bbdev operation is interleaved optimally across the channels and
375ranks for optimal processing.
376
377.. code-block:: c
378
379    struct rte_mempool *
380    rte_bbdev_op_pool_create(const char *name, enum rte_bbdev_op_type type,
381            unsigned int num_elements, unsigned int cache_size,
382            int socket_id)
383
384``rte_bbdev_*_op_alloc_bulk()`` and ``rte_bbdev_*_op_free_bulk()`` are used to
385allocate bbdev operations of a specific type from a given bbdev operation mempool.
386
387.. code-block:: c
388
389    int rte_bbdev_enc_op_alloc_bulk(struct rte_mempool *mempool,
390            struct rte_bbdev_enc_op **ops, uint16_t num_ops)
391
392    int rte_bbdev_dec_op_alloc_bulk(struct rte_mempool *mempool,
393            struct rte_bbdev_dec_op **ops, uint16_t num_ops)
394
395``rte_bbdev_*_op_free_bulk()`` is called by the application to return an
396operation to its allocating pool.
397
398.. code-block:: c
399
400    void rte_bbdev_dec_op_free_bulk(struct rte_bbdev_dec_op **ops,
401            unsigned int num_ops)
402    void rte_bbdev_enc_op_free_bulk(struct rte_bbdev_enc_op **ops,
403            unsigned int num_ops)
404
405BBDEV Inbound/Outbound Memory
406~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
407
408The bbdev operation structure contains all the mutable data relating to
409performing Turbo and LDPC coding on a referenced mbuf data buffer. It is used for either
410encode or decode operations.
411
412
413.. csv-table:: Operation I/O
414   :header: "FEC", "In", "Out"
415   :widths: 20, 30, 30
416
417   "Turbo Encode", "input", "output"
418   "Turbo Decode", "input", "hard output"
419   " ", " ", "soft output (optional)"
420   "LDPC Encode", "input", "output"
421   "LDPC Decode", "input", "hard output"
422   "", "HQ combine (optional)", "HQ combine (optional)"
423   " ", "", "soft output (optional)"
424
425
426It is expected that the application provides input and output mbuf pointers
427allocated and ready to use.
428
429The baseband framework supports FEC coding on Code Blocks (CB) and
430Transport Blocks (TB).
431
432For the output buffer(s), the application is required to provide an allocated
433and free mbuf, to which the resulting output will be written.
434
435The support of split "scattered" buffers is a driver-specific feature, so it is
436reported individually by the supporting driver as a capability.
437
438Input and output data buffers are identified by ``rte_bbdev_op_data`` structure,
439as follows:
440
441.. code-block:: c
442
443    struct rte_bbdev_op_data {
444        struct rte_mbuf *data;
445        uint32_t offset;
446        uint32_t length;
447    };
448
449
450This structure has three elements:
451
452- ``data``: This is the mbuf data structure representing the data for BBDEV
453  operation.
454
455  This mbuf pointer can point to one Code Block (CB) data buffer or multiple CBs
456  contiguously located next to each other. A Transport Block (TB) represents a
457  whole piece of data that is divided into one or more CBs. Maximum number of
458  CBs can be contained in one TB is defined by
459  ``RTE_BBDEV_(TURBO/LDPC)MAX_CODE_BLOCKS``.
460
461  An mbuf data structure cannot represent more than one TB. The smallest piece
462  of data that can be contained in one mbuf is one CB.
463  An mbuf can include one contiguous CB, subset of contiguous CBs that are
464  belonging to one TB, or all contiguous CBs that belong to one TB.
465
466  If a BBDEV PMD supports the extended capability "Scatter-Gather", then it is
467  capable of collecting (gathering) non-contiguous (scattered) data from
468  multiple locations in the memory.
469  This capability is reported by the capability flags:
470
471  - ``RTE_BBDEV_TURBO_ENC_SCATTER_GATHER``, ``RTE_BBDEV_TURBO_DEC_SCATTER_GATHER``,
472
473  - ``RTE_BBDEV_LDPC_ENC_SCATTER_GATHER``, ``RTE_BBDEV_LDPC_DEC_SCATTER_GATHER``.
474
475  Chained mbuf data structures are only accepted if a BBDEV PMD supports this
476  feature. A chained mbuf can represent one non-contiguous CB or multiple non-contiguous
477  CBs. The first mbuf segment in the given chained mbuf represents the first piece
478  of the CB. Offset is only applicable to the first segment. ``length`` is the
479  total length of the CB.
480
481  BBDEV driver is responsible for identifying where the split is and enqueue
482  the split data to its internal queues.
483
484  If BBDEV PMD does not support this feature, it will assume inbound mbuf data
485  contains one segment.
486
487  The output mbuf data though is always one segment, even if the input was a
488  chained mbuf.
489
490
491- ``offset``: This is the starting point of the BBDEV (encode/decode) operation,
492  in bytes.
493
494  BBDEV starts to read data past this offset.
495  In case of chained mbuf, this offset applies only to the first mbuf segment.
496
497
498- ``length``: This is the total data length to be processed in one operation,
499  in bytes.
500
501  In case the mbuf data is representing one CB, this is the length of the CB
502  undergoing the operation.
503  If it is for multiple CBs, this is the total length of those CBs undergoing
504  the operation.
505  If it is for one TB, this is the total length of the TB under operation.
506  In case of chained mbuf, this data length includes the lengths of the
507  "scattered" data segments undergoing the operation.
508
509
510BBDEV Turbo Encode Operation
511~~~~~~~~~~~~~~~~~~~~~~~~~~~~
512
513.. literalinclude:: ../../../lib/bbdev/rte_bbdev_op.h
514   :language: c
515   :start-after: Structure rte_bbdev_op_turbo_enc 8<
516   :end-before: >8 End of structure rte_bbdev_op_turbo_enc.
517
518The Turbo encode structure includes the ``input`` and ``output`` mbuf
519data pointers. The provided mbuf pointer of ``input`` needs to be big
520enough to stretch for extra CRC trailers.
521
522.. csv-table:: **struct rte_bbdev_op_turbo_enc** parameters
523   :header: "Parameter", "Description"
524   :widths: 10, 30
525
526   "input","input CB or TB data"
527   "output","rate matched CB or TB output buffer"
528   "op_flags","bitmask of all active operation capabilities"
529   "rv_index","redundancy version index [0..3]"
530   "code_block_mode","code block or transport block mode"
531   "cb_params", "code block specific parameters (code block mode only)"
532   "tb_params", "transport block specific parameters (transport block mode only)"
533
534
535The encode interface works on both the code block (CB) and the transport block
536(TB). An operation executes in "CB-mode" when the CB is standalone. While
537"TB-mode" executes when an operation performs on one or multiple CBs that
538belong to a TB. Therefore, a given data can be standalone CB, full-size TB or
539partial TB. Partial TB means that only a subset of CBs belonging to a bigger TB
540are being enqueued.
541
542  **NOTE:** It is assumed that all enqueued ops in one ``rte_bbdev_enqueue_enc_ops()``
543  call belong to one mode, either CB-mode or TB-mode.
544
545In case that the TB is smaller than Z (6144 bits), then effectively the TB = CB.
546CRC24A is appended to the tail of the CB. The application is responsible for
547calculating and appending CRC24A before calling BBDEV in case that the
548underlying driver does not support CRC24A generation.
549
550In CB-mode, CRC24A/B is an optional operation.
551The CB parameter ``k`` is the size of the CB (this maps to K as described
552in 3GPP TS 36.212 section 5.1.2), this size is inclusive of CRC24A/B.
553The ``length`` is inclusive of CRC24A/B and equals to ``k`` in this case.
554
555Not all BBDEV PMDs are capable of CRC24A/B calculation. Flags
556``RTE_BBDEV_TURBO_CRC_24A_ATTACH`` and ``RTE_BBDEV_TURBO_CRC_24B_ATTACH``
557informs the application with relevant capability. These flags can be set in the
558``op_flags`` parameter to indicate to BBDEV to calculate and append CRC24A/B
559to CB before going forward with Turbo encoding.
560
561Output format of the CB encode will have the encoded CB in ``e`` size output
562(this maps to E described in 3GPP TS 36.212 section 5.1.4.1.2). The output mbuf
563buffer size needs to be big enough to hold the encoded buffer of size ``e``.
564
565In TB-mode, CRC24A is assumed to be pre-calculated and appended to the inbound
566TB mbuf data buffer.
567The output mbuf data structure is expected to be allocated by the application
568with enough room for the output data.
569
570The difference between the partial and full-size TB is that we need to know the
571index of the first CB in this group and the number of CBs contained within.
572The first CB index is given by ``r`` but the number of the remaining CBs is
573calculated automatically by BBDEV before passing down to the driver.
574
575The number of remaining CBs should not be confused with ``c``. ``c`` is the
576total number of CBs that composes the whole TB (this maps to C as
577described in 3GPP TS 36.212 section 5.1.2).
578
579The ``length`` is total size of the CBs inclusive of any CRC24A and CRC24B in
580case they were appended by the application.
581
582The case when one CB belongs to TB and is being enqueued individually to BBDEV,
583this case is considered as a special case of partial TB where its number of CBs
584is 1. Therefore, it requires to get processed in TB-mode.
585
586The figure below visualizes the encoding of CBs using BBDEV interface in
587TB-mode. CB-mode is a reduced version, where only one CB exists:
588
589.. _figure_turbo_tb_encode:
590
591.. figure:: img/turbo_tb_encode.*
592
593    Turbo encoding of Code Blocks in mbuf structure
594
595
596BBDEV Turbo Decode Operation
597~~~~~~~~~~~~~~~~~~~~~~~~~~~~
598
599.. literalinclude:: ../../../lib/bbdev/rte_bbdev_op.h
600   :language: c
601   :start-after: Structure rte_bbdev_op_turbo_dec 8<
602   :end-before: >8 End of structure rte_bbdev_op_turbo_dec.
603
604The Turbo decode structure includes the ``input``, ``hard_output`` and
605optionally the ``soft_output`` mbuf data pointers.
606
607.. csv-table:: **struct rte_bbdev_op_turbo_dec** parameters
608   :header: "Parameter", "Description"
609   :widths: 10, 30
610
611   "input","virtual circular buffer, wk, size 3*Kpi for each CB"
612   "hard output","hard decisions buffer, decoded output, size K for each CB"
613   "soft output","soft LLR output buffer (optional)"
614   "op_flags","bitmask of all active operation capabilities"
615   "rv_index","redundancy version index [0..3]"
616   "iter_max","maximum number of iterations to perform in decode all CBs"
617   "iter_min","minimum number of iterations to perform in decoding all CBs"
618   "iter_count","number of iterations to performed in decoding all CBs"
619   "ext_scale","scale factor on extrinsic info (5 bits)"
620   "num_maps","number of MAP engines to use in decode"
621   "code_block_mode","code block or transport block mode"
622   "cb_params", "code block specific parameters (code block mode only)"
623   "tb_params", "transport block specific parameters (transport block mode only)"
624
625Similarly, the decode interface works on both the code block (CB) and the
626transport block (TB). An operation executes in "CB-mode" when the CB is
627standalone. While "TB-mode" executes when an operation performs on one or
628multiple CBs that belong to a TB. Therefore, a given data can be standalone CB,
629full-size TB or partial TB. Partial TB means that only a subset of CBs belonging
630to a bigger TB are being enqueued.
631
632  **NOTE:** It is assumed that all enqueued ops in one ``rte_bbdev_enqueue_dec_ops()``
633  call belong to one mode, either CB-mode or TB-mode.
634
635
636The CB parameter ``k`` is the size of the decoded CB (this maps to K as described in
6373GPP TS 36.212 section 5.1.2), this size is inclusive of CRC24A/B.
638The ``length`` is inclusive of CRC24A/B and equals to ``k`` in this case.
639
640The input encoded CB data is the Virtual Circular Buffer data stream, wk, with
641the null padding included as described in 3GPP TS 36.212 section 5.1.4.1.2 and
642shown in 3GPP TS 36.212 section 5.1.4.1 Figure 5.1.4-1.
643The size of the virtual circular buffer is 3*Kpi, where Kpi is the 32 byte
644aligned value of K, as specified in 3GPP TS 36.212 section 5.1.4.1.1.
645
646Each byte in the input circular buffer is the LLR value of each bit of the
647original CB.
648
649``hard_output`` is a mandatory capability that all BBDEV PMDs support. This is
650the decoded CBs of K sizes (CRC24A/B is the last 24-bit in each decoded CB).
651Soft output is an optional capability for BBDEV PMDs. Setting flag
652``RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP`` in ``op_flags`` directs BBDEV to retain
653CRC24B at the end of each CB. This might be useful for the application in debug
654mode.
655An LLR rate matched output is computed in the ``soft_output`` buffer structure
656for the given CB parameter ``e`` size (this maps to E described in
6573GPP TS 36.212 section 5.1.4.1.2). The output mbuf buffer size needs to be big
658enough to hold the encoded buffer of size ``e``.
659
660The first CB Virtual Circular Buffer (VCB) index is given by ``r`` but the
661number of the remaining CB VCBs is calculated automatically by BBDEV before
662passing down to the driver.
663
664The number of remaining CB VCBs should not be confused with ``c``. ``c`` is the
665total number of CBs that composes the whole TB (this maps to C as
666described in 3GPP TS 36.212 section 5.1.2).
667
668The ``length`` is total size of the CBs inclusive of any CRC24A and CRC24B in
669case they were appended by the application.
670
671The case when one CB belongs to TB and is being enqueued individually to BBDEV,
672this case is considered as a special case of partial TB where its number of CBs
673is 1. Therefore, it requires to get processed in TB-mode.
674
675The output mbuf data structure is expected to be allocated by the application
676with enough room for the output data.
677
678The figure below visualizes the decoding of CBs using BBDEV interface in
679TB-mode. CB-mode is a reduced version, where only one CB exists:
680
681.. _figure_turbo_tb_decode:
682
683.. figure:: img/turbo_tb_decode.*
684
685    Turbo decoding of Code Blocks in mbuf structure
686
687BBDEV LDPC Encode Operation
688~~~~~~~~~~~~~~~~~~~~~~~~~~~~
689
690The operation flags that can be set for each LDPC encode operation are
691given below.
692
693  **NOTE:** The actual operation flags that may be used with a specific
694  BBDEV PMD are dependent on the driver capabilities as reported via
695  ``rte_bbdev_info_get()``, and may be a subset of those below.
696
697+--------------------------------------------------------------------+
698|Description of LDPC encode capability flags                         |
699+====================================================================+
700|RTE_BBDEV_LDPC_INTERLEAVER_BYPASS                                   |
701| Set to bypass bit-level interleaver on output stream               |
702+--------------------------------------------------------------------+
703|RTE_BBDEV_LDPC_RATE_MATCH                                           |
704| Set to enabling the RATE_MATCHING processing                       |
705+--------------------------------------------------------------------+
706|RTE_BBDEV_LDPC_CRC_24A_ATTACH                                       |
707| Set to attach transport block CRC-24A                              |
708+--------------------------------------------------------------------+
709|RTE_BBDEV_LDPC_CRC_24B_ATTACH                                       |
710| Set to attach code block CRC-24B                                   |
711+--------------------------------------------------------------------+
712|RTE_BBDEV_LDPC_CRC_16_ATTACH                                        |
713| Set to attach code block CRC-16                                    |
714+--------------------------------------------------------------------+
715|RTE_BBDEV_LDPC_ENC_INTERRUPTS                                       |
716| Set if a device supports encoder dequeue interrupts                |
717+--------------------------------------------------------------------+
718|RTE_BBDEV_LDPC_ENC_SCATTER_GATHER                                   |
719| Set if a device supports scatter-gather functionality              |
720+--------------------------------------------------------------------+
721|RTE_BBDEV_LDPC_ENC_CONCATENATION                                    |
722| Set if a device supports concatenation of non byte aligned output  |
723+--------------------------------------------------------------------+
724
725The structure passed for each LDPC encode operation is given below,
726with the operation flags forming a bitmask in the ``op_flags`` field.
727
728.. literalinclude:: ../../../lib/bbdev/rte_bbdev_op.h
729   :language: c
730   :start-after: Structure rte_bbdev_op_ldpc_enc 8<
731   :end-before: >8 End of structure rte_bbdev_op_ldpc_enc.
732
733The LDPC encode parameters are set out in the table below.
734
735+----------------+--------------------------------------------------------------------+
736|Parameter       |Description                                                         |
737+================+====================================================================+
738|input           |input CB or TB data                                                 |
739+----------------+--------------------------------------------------------------------+
740|output          |rate matched CB or TB output buffer                                 |
741+----------------+--------------------------------------------------------------------+
742|op_flags        |bitmask of all active operation capabilities                        |
743+----------------+--------------------------------------------------------------------+
744|rv_index        |redundancy version index [0..3]                                     |
745+----------------+--------------------------------------------------------------------+
746|basegraph       |Basegraph 1 or 2                                                    |
747+----------------+--------------------------------------------------------------------+
748|z_c             |Zc, LDPC lifting size                                               |
749+----------------+--------------------------------------------------------------------+
750|n_cb            |Ncb, length of the circular buffer in bits.                         |
751+----------------+--------------------------------------------------------------------+
752|q_m             |Qm, modulation order {2,4,6,8,10}                                   |
753+----------------+--------------------------------------------------------------------+
754|n_filler        |number of filler bits                                               |
755+----------------+--------------------------------------------------------------------+
756|code_block_mode |code block or transport block mode                                  |
757+----------------+--------------------------------------------------------------------+
758|op_flags        |bitmask of all active operation capabilities                        |
759+----------------+--------------------------------------------------------------------+
760|**cb_params**   |code block specific parameters (code block mode only)               |
761+----------------+------------+-------------------------------------------------------+
762|                |e           |E, length of the rate matched output sequence in bits  |
763+----------------+------------+-------------------------------------------------------+
764|**tb_params**   | transport block specific parameters (transport block mode only)    |
765+----------------+------------+-------------------------------------------------------+
766|                |c           |number of CBs in the TB or partial TB                  |
767+----------------+------------+-------------------------------------------------------+
768|                |r           |index of the first CB in the inbound mbuf data         |
769+----------------+------------+-------------------------------------------------------+
770|                |c_ab        |number of CBs that use Ea before switching to Eb       |
771+----------------+------------+-------------------------------------------------------+
772|                |ea          |Ea, length of the RM output sequence in bits, r < cab  |
773+----------------+------------+-------------------------------------------------------+
774|                |eb          |Eb, length of the RM output sequence in bits, r >= cab |
775+----------------+------------+-------------------------------------------------------+
776
777The mbuf input ``input`` is mandatory for all BBDEV PMDs and is the
778incoming code block or transport block data.
779
780The mbuf output ``output`` is mandatory and is the encoded CB(s). In
781CB-mode ut contains the encoded CB of size ``e`` (E  in 3GPP TS 38.212
782section 6.2.5). In TB-mode it contains multiple contiguous encoded CBs
783of size ``ea`` or ``eb``.
784The ``output`` buffer is allocated by the application with enough room
785for the output data.
786
787The encode interface works on both a code block (CB) and a transport
788block (TB) basis.
789
790  **NOTE:** All enqueued ops in one ``rte_bbdev_enqueue_enc_ops()``
791  call belong to one mode, either CB-mode or TB-mode.
792
793The valid modes of operation are:
794
795* CB-mode: one CB (attach CRC24B if required)
796* CB-mode: one CB making up one TB (attach CRC24A if required)
797* TB-mode: one or more CB of a partial TB (attach CRC24B(s) if required)
798* TB-mode: one or more CB of a complete TB (attach CRC24AB(s) if required)
799
800In CB-mode if ``RTE_BBDEV_LDPC_CRC_24A_ATTACH`` is set then CRC24A
801is appended to the CB. If ``RTE_BBDEV_LDPC_CRC_24A_ATTACH`` is not
802set the application is responsible for calculating and appending CRC24A
803before calling BBDEV. The input data mbuf ``length`` is inclusive of
804CRC24A/B where present and is equal to the code block size ``K``.
805
806In TB-mode, CRC24A is assumed to be pre-calculated and appended to the
807inbound TB data buffer, unless the ``RTE_BBDEV_LDPC_CRC_24A_ATTACH``
808flag is set when it is the  responsibility of BBDEV. The input data
809mbuf ``length`` is total size of the CBs inclusive of any CRC24A and
810CRC24B in the case they were appended by the application.
811
812Not all BBDEV PMDs may be capable of CRC24A/B calculation. Flags
813``RTE_BBDEV_LDPC_CRC_24A_ATTACH`` and ``RTE_BBDEV_LDPC_CRC_24B_ATTACH``
814inform the application of the relevant capability. These flags can be set
815in the ``op_flags`` parameter to indicate BBDEV to calculate and append
816CRC24A to CB before going forward with LDPC encoding.
817
818The difference between the partial and full-size TB is that BBDEV needs
819the index of the first CB in this group and the number of CBs in the group.
820The first CB index is given by ``r`` but the number of the CBs is
821calculated by BBDEV before signalling to the driver.
822
823The number of CBs in the group should not be confused with ``c``, the
824total number of CBs in the full TB (``C`` as per 3GPP TS 38.212 section 5.2.2)
825
826Figure :numref:`figure_turbo_tb_encode` above
827showing the Turbo encoding of CBs using BBDEV interface in TB-mode
828is also valid for LDPC encode.
829
830BBDEV LDPC Decode Operation
831~~~~~~~~~~~~~~~~~~~~~~~~~~~~
832
833The operation flags that can be set for each LDPC decode operation are
834given below.
835
836  **NOTE:** The actual operation flags that may be used with a specific
837  BBDEV PMD are dependent on the driver capabilities as reported via
838  ``rte_bbdev_info_get()``, and may be a subset of those below.
839
840+--------------------------------------------------------------------+
841|Description of LDPC decode capability flags                         |
842+====================================================================+
843|RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK                                   |
844| Set for transport block CRC-24A checking                           |
845+--------------------------------------------------------------------+
846|RTE_BBDEV_LDPC_CRC_TYPE_24B_CHECK                                   |
847| Set for code block CRC-24B checking                                |
848+--------------------------------------------------------------------+
849|RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP                                    |
850| Set to drop the last CRC bits decoding output                      |
851+--------------------------------------------------------------------+
852|RTE_BBDEV_LDPC_CRC_TYPE_16_CHECK                                    |
853| Set for code block CRC-16 checking                                 |
854+--------------------------------------------------------------------+
855|RTE_BBDEV_LDPC_DEINTERLEAVER_BYPASS                                 |
856| Set for bit-level de-interleaver bypass on input stream            |
857+--------------------------------------------------------------------+
858|RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE                                 |
859| Set for HARQ combined input stream enable                          |
860+--------------------------------------------------------------------+
861|RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE                                |
862| Set for HARQ combined output stream enable                         |
863+--------------------------------------------------------------------+
864|RTE_BBDEV_LDPC_DECODE_BYPASS                                        |
865| Set for LDPC decoder bypass                                        |
866|                                                                    |
867| RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE must be set                   |
868+--------------------------------------------------------------------+
869|RTE_BBDEV_LDPC_DECODE_SOFT_OUT                                      |
870| Set for soft-output stream  enable                                 |
871+--------------------------------------------------------------------+
872|RTE_BBDEV_LDPC_SOFT_OUT_RM_BYPASS                                   |
873| Set for Rate-Matching bypass on soft-out stream                    |
874+--------------------------------------------------------------------+
875|RTE_BBDEV_LDPC_SOFT_OUT_DEINTERLEAVER_BYPASS                        |
876| Set for bit-level de-interleaver bypass on soft-output stream      |
877+--------------------------------------------------------------------+
878|RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE                                |
879| Set for iteration stopping on successful decode condition enable   |
880|                                                                    |
881| Where a successful decode is a successful syndrome check           |
882+--------------------------------------------------------------------+
883|RTE_BBDEV_LDPC_DEC_INTERRUPTS                                       |
884| Set if a device supports decoder dequeue interrupts                |
885+--------------------------------------------------------------------+
886|RTE_BBDEV_LDPC_DEC_SCATTER_GATHER                                   |
887| Set if a device supports scatter-gather functionality              |
888+--------------------------------------------------------------------+
889|RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION                                |
890| Set if a device supports input/output HARQ compression             |
891| Data is packed as 6 bits by dropping and saturating the MSBs       |
892+--------------------------------------------------------------------+
893|RTE_BBDEV_LDPC_LLR_COMPRESSION                                      |
894| Set if a device supports input LLR compression                     |
895| Data is packed as 6 bits by dropping and saturating the MSBs       |
896+--------------------------------------------------------------------+
897|RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE                       |
898| Set if a device supports HARQ input to device's internal memory    |
899+--------------------------------------------------------------------+
900|RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE                      |
901| Set if a device supports HARQ output to device's internal memory   |
902+--------------------------------------------------------------------+
903|RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK                        |
904| Set if a device supports loopback access to HARQ internal memory   |
905+--------------------------------------------------------------------+
906|RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_FILLERS                         |
907| Set if a device includes LLR filler bits in HARQ circular buffer   |
908+--------------------------------------------------------------------+
909|RTE_BBDEV_LDPC_HARQ_4BIT_COMPRESSION                                |
910|Set if a device supports input/output 4 bits HARQ compression       |
911+--------------------------------------------------------------------+
912
913The structure passed for each LDPC decode operation is given below,
914with the operation flags forming a bitmask in the ``op_flags`` field.
915
916.. literalinclude:: ../../../lib/bbdev/rte_bbdev_op.h
917   :language: c
918   :start-after: Structure rte_bbdev_op_ldpc_dec 8<
919   :end-before: >8 End of structure rte_bbdev_op_ldpc_dec.
920
921The LDPC decode parameters are set out in the table below.
922
923+----------------+--------------------------------------------------------------------+
924|Parameter       |Description                                                         |
925+================+====================================================================+
926|input           |input CB or TB data                                                 |
927+----------------+--------------------------------------------------------------------+
928|hard_output     |hard decisions buffer, decoded output                               |
929+----------------+--------------------------------------------------------------------+
930|soft_output     |soft LLR output buffer (optional)                                   |
931+----------------+--------------------------------------------------------------------+
932|harq_comb_input |HARQ combined input buffer (optional)                               |
933+----------------+--------------------------------------------------------------------+
934|harq_comb_output|HARQ combined output buffer (optional)                              |
935+----------------+--------------------------------------------------------------------+
936|op_flags        |bitmask of all active operation capabilities                        |
937+----------------+--------------------------------------------------------------------+
938|rv_index        |redundancy version index [0..3]                                     |
939+----------------+--------------------------------------------------------------------+
940|basegraph       |Basegraph 1 or 2                                                    |
941+----------------+--------------------------------------------------------------------+
942|z_c             |Zc, LDPC lifting size                                               |
943+----------------+--------------------------------------------------------------------+
944|n_cb            |Ncb, length of the circular buffer in bits.                         |
945+----------------+--------------------------------------------------------------------+
946|q_m             |Qm, modulation order {1,2,4,6,8} from pi/2-BPSK to 256QAM           |
947+----------------+--------------------------------------------------------------------+
948|n_filler        |number of filler bits                                               |
949+----------------+--------------------------------------------------------------------+
950|iter_max        |maximum number of iterations to perform in decode all CBs           |
951+----------------+--------------------------------------------------------------------+
952|iter_count      |number of iterations performed in decoding all CBs                  |
953+----------------+--------------------------------------------------------------------+
954|code_block_mode |code block or transport block mode                                  |
955+----------------+--------------------------------------------------------------------+
956|op_flags        |bitmask of all active operation capabilities                        |
957+----------------+--------------------------------------------------------------------+
958|**cb_params**   |code block specific parameters (code block mode only)               |
959+----------------+------------+-------------------------------------------------------+
960|                |e           |E, length of the rate matched output sequence in bits  |
961+----------------+------------+-------------------------------------------------------+
962|**tb_params**   | transport block specific parameters (transport block mode only)    |
963+----------------+------------+-------------------------------------------------------+
964|                |c           |number of CBs in the TB or partial TB                  |
965+----------------+------------+-------------------------------------------------------+
966|                |r           |index of the first CB in the inbound mbuf data         |
967+----------------+------------+-------------------------------------------------------+
968|                |c_ab        |number of CBs that use Ea before switching to Eb       |
969+----------------+------------+-------------------------------------------------------+
970|                |ea          |Ea, length of the RM output sequence in bits, r < cab  |
971+----------------+------------+-------------------------------------------------------+
972|                |eb          |Eb, length of the RM output sequence in bits  r >= cab |
973+----------------+------------+-------------------------------------------------------+
974
975The mbuf input ``input`` encoded CB data is mandatory for all BBDEV PMDs
976and is the Virtual Circular Buffer data stream with null padding.
977Each byte in the input circular buffer is the LLR value of each bit of
978the original CB.
979
980The mbuf output ``hard_output`` is mandatory and is the decoded CBs size
981K (CRC24A/B is the last 24-bit in each decoded CB).
982
983The mbuf output ``soft_output`` is optional and is an LLR rate matched
984output of size ``e`` (this is ``E`` as per 3GPP TS 38.212 section 6.2.5).
985
986The mbuf input ``harq_combine_input`` is optional and is a buffer with
987the input to the HARQ combination function of the device. If the
988capability RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE is set
989then the HARQ is stored in memory internal to the device and not visible
990to BBDEV.
991
992The mbuf output ``harq_combine_output`` is optional and is a buffer for
993the output of the HARQ combination function of the device. If the
994capability RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE is set
995then the HARQ is stored in memory internal to the device and not visible
996to BBDEV.
997
998.. note::
999
1000    More explicitly for a typical usage of HARQ retransmission
1001    in a VRAN application using a HW PMD, there will be 2 cases.
1002
1003    For 1st transmission, only the HARQ output is enabled:
1004
1005    - the harq_combined_output.offset is provided to a given address.
1006      ie. typically an integer index * 32K,
1007      where the index is tracked by the application based on code block index
1008      for a given UE and HARQ process.
1009
1010    - the related operation flag would notably include
1011      RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE and RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION.
1012
1013    - note that no explicit flush or reset of the memory is required.
1014
1015    For 2nd transmission, an input is also required to benefit from HARQ combination gain:
1016
1017    - the changes mentioned above are the same (note that rvIndex may be adjusted).
1018
1019    - the operation flag would additionally include the LDPC_HQ_COMBINE_IN_ENABLE flag.
1020
1021    - the harq_combined_input.offset must be set to the address of the related code block
1022      (ie. same as the harq_combine_output index above for the same code block, HARQ process, UE).
1023
1024    - the harq_combined_input.length must be set to the length
1025      which was provided back in the related harq_combined_output.length
1026      when it has processed and dequeued (previous HARQ iteration).
1027
1028
1029The output mbuf data structures are expected to be allocated by the
1030application with enough room for the output data.
1031
1032As with the LDPC encode, the decode interface works on both a code block
1033(CB) and a transport block (TB) basis.
1034
1035  **NOTE:** All enqueued ops in one ``rte_bbdev_enqueue_dec_ops()``
1036  call belong to one mode, either CB-mode or TB-mode.
1037
1038The valid modes of operation are:
1039
1040* CB-mode: one CB (check CRC24B if required)
1041* CB-mode: one CB making up one TB (check CRC24A if required)
1042* TB-mode: one or more CB making up a partial TB (check CRC24B(s) if required)
1043* TB-mode: one or more CB making up a complete TB (check CRC24B(s) if required)
1044
1045The mbuf ``length`` is inclusive of CRC24A/B where present and is equal
1046the code block size ``K``.
1047
1048The first CB Virtual Circular Buffer (VCB) index is given by ``r`` but the
1049number of the remaining CB VCBs is calculated automatically by BBDEV
1050and passed down to the driver.
1051
1052The number of remaining CB VCBs should not be confused with ``c``, the
1053total number of CBs in the full TB (``C`` as per 3GPP TS 38.212 section 5.2.2)
1054
1055The ``length`` is total size of the CBs inclusive of any CRC24A and CRC24B in
1056case they were appended by the application.
1057
1058Figure :numref:`figure_turbo_tb_decode` above
1059showing the Turbo decoding of CBs using BBDEV interface in TB-mode
1060is also valid for LDPC decode.
1061
1062BBDEV FFT Operation
1063~~~~~~~~~~~~~~~~~~~
1064
1065This operation allows to run a combination of DFT and/or IDFT and/or time-domain windowing.
1066These can be used in a modular fashion (using bypass modes) or as a processing pipeline
1067which can be used for FFT-based baseband signal processing.
1068
1069In more details it allows :
1070
1071* to process the data first through an IDFT of adjustable size and padding;
1072* to perform the windowing as a programmable cyclic shift offset of the data
1073  followed by a pointwise multiplication by a time domain window;
1074* to process the related data through a DFT of adjustable size and
1075  de-padding for each such cyclic shift output.
1076
1077A flexible number of Rx antennas are being processed in parallel with the same configuration.
1078The API allows more generally for flexibility in what the PMD may support (capability flags) and
1079flexibility to adjust some of the parameters of the processing.
1080
1081The structure passed for each FFT operation is given below,
1082with the operation flags forming a bitmask in the ``op_flags`` field.
1083
1084  **NOTE:** The actual operation flags that may be used with a specific
1085  bbdev PMD are dependent on the driver capabilities as reported via
1086  ``rte_bbdev_info_get()``, and may be a subset of those below.
1087
1088.. literalinclude:: ../../../lib/bbdev/rte_bbdev_op.h
1089   :language: c
1090   :start-after: Structure rte_bbdev_op_fft 8<
1091   :end-before: >8 End of structure rte_bbdev_op_fft.
1092
1093+--------------------------------------------------------------------+
1094|Description of FFT capability flags                                 |
1095+====================================================================+
1096|RTE_BBDEV_FFT_WINDOWING                                             |
1097| Set to enable/support windowing in time domain                     |
1098+--------------------------------------------------------------------+
1099|RTE_BBDEV_FFT_CS_ADJUSTMENT                                         |
1100| Set to enable/support  the cyclic shift time offset adjustment     |
1101+--------------------------------------------------------------------+
1102|RTE_BBDEV_FFT_DFT_BYPASS                                            |
1103| Set to bypass the DFT and use directly the IDFT as an option       |
1104+--------------------------------------------------------------------+
1105|RTE_BBDEV_FFT_IDFT_BYPASS                                           |
1106| Set to bypass the IDFT and use directly the DFT as an option       |
1107+--------------------------------------------------------------------+
1108|RTE_BBDEV_FFT_WINDOWING_BYPASS                                      |
1109| Set to bypass the time domain windowing  as an option              |
1110+--------------------------------------------------------------------+
1111|RTE_BBDEV_FFT_POWER_MEAS                                            |
1112| Set to provide an optional power measurement of the DFT output     |
1113+--------------------------------------------------------------------+
1114|RTE_BBDEV_FFT_FP16_INPUT                                            |
1115| Set if the input data shall use FP16 format instead of INT16       |
1116+--------------------------------------------------------------------+
1117|RTE_BBDEV_FFT_FP16_OUTPUT                                           |
1118| Set if the output data shall use FP16 format instead of INT16      |
1119+--------------------------------------------------------------------+
1120|RTE_BBDEV_FFT_TIMING_OFFSET_PER_CS                                  |
1121| Set if device supports adjusting time offset per CS                |
1122+--------------------------------------------------------------------+
1123|RTE_BBDEV_FFT_TIMING_ERROR                                          |
1124| Set if device supports correcting for timing error                 |
1125+--------------------------------------------------------------------+
1126|RTE_BBDEV_FFT_DEWINDOWING                                           |
1127| Set if enabling the option FFT Dewindowing in Frequency domain     |
1128+--------------------------------------------------------------------+
1129|RTE_BBDEV_FFT_FREQ_RESAMPLING                                       |
1130| Set if device supports the optional frequency resampling           |
1131+--------------------------------------------------------------------+
1132
1133The FFT parameters are set out in the table below.
1134
1135+-------------------------+--------------------------------------------------------------+
1136|Parameter                |Description                                                   |
1137+=========================+==============================================================+
1138|base_input               |input data                                                    |
1139+-------------------------+--------------------------------------------------------------+
1140|base_output              |output data                                                   |
1141+-------------------------+--------------------------------------------------------------+
1142|dewindowing_input        |optional frequency domain dewindowing input data              |
1143+-------------------------+--------------------------------------------------------------+
1144|power_meas_output        |optional output data with power measurement on DFT output     |
1145+-------------------------+--------------------------------------------------------------+
1146|op_flags                 |bitmask of all active operation capabilities                  |
1147+-------------------------+--------------------------------------------------------------+
1148|input_sequence_size      |size of the input sequence in 32-bits points per antenna      |
1149+-------------------------+--------------------------------------------------------------+
1150|input_leading_padding    |number of points padded at the start of input data            |
1151+-------------------------+--------------------------------------------------------------+
1152|output_sequence_size     |size of the output sequence per antenna and cyclic shift      |
1153+-------------------------+--------------------------------------------------------------+
1154|output_leading_depadding |number of points de-padded at the start of output data        |
1155+-------------------------+--------------------------------------------------------------+
1156|window_index             |optional windowing profile index used for each cyclic shift   |
1157+-------------------------+--------------------------------------------------------------+
1158|cs_bitmap                |bitmap of the cyclic shift output requested (LSB for index 0) |
1159+-------------------------+--------------------------------------------------------------+
1160|num_antennas_log2        |number of antennas as a log2 (10 maps to 1024...)             |
1161+-------------------------+--------------------------------------------------------------+
1162|idft_log2                |IDFT size as a log2                                           |
1163+-------------------------+--------------------------------------------------------------+
1164|dft_log2                 |DFT size as a log2                                            |
1165+-------------------------+--------------------------------------------------------------+
1166|cs_time_adjustment       |adjustment of time position of all the cyclic shift output    |
1167+-------------------------+--------------------------------------------------------------+
1168|idft_shift               |shift down of signal level post iDFT                          |
1169+-------------------------+--------------------------------------------------------------+
1170|dft_shift                |shift down of signal level post DFT                           |
1171+-------------------------+--------------------------------------------------------------+
1172|ncs_reciprocal           |inverse of max number of CS normalized to 15b (ie. 231 for 12)|
1173+-------------------------+--------------------------------------------------------------+
1174|power_shift              |shift down of level of power measurement when enabled         |
1175+-------------------------+--------------------------------------------------------------+
1176|fp16_exp_adjust          |value added to FP16 exponent at conversion from INT16         |
1177+-------------------------+--------------------------------------------------------------+
1178|freq_resample_mode       |frequency ressampling mode (0:transparent, 1-2: resample)     |
1179+-------------------------+--------------------------------------------------------------+
1180| output_depadded_size    |output depadded size prior to frequency resampling            |
1181+-------------------------+--------------------------------------------------------------+
1182|cs_theta_0               |timing error correction initial phase                         |
1183+-------------------------+--------------------------------------------------------------+
1184|cs_theta_d               |timing error correction phase increment                       |
1185+-------------------------+--------------------------------------------------------------+
1186|time_offset              |time offset per CS of time domain samples                     |
1187+-------------------------+--------------------------------------------------------------+
1188
1189The mbuf input ``base_input`` is mandatory for all bbdev PMDs and
1190is the incoming data for the processing. Its size may not fit into an actual mbuf,
1191but the structure is used to pass iova address.
1192The mbuf output ``output`` is mandatory and is output of the FFT processing chain.
1193Each point is a complex number of 32bits :
1194either as 2 INT16 or as 2 FP16 based when the option supported.
1195The data layout is based on contiguous concatenation of output data
1196first by cyclic shift then by antenna.
1197
1198BBDEV MLD-TS Operation
1199~~~~~~~~~~~~~~~~~~~~~~
1200
1201This operation allows to run the Tree Search (TS) portion of a Maximum Likelihood processing (MLD).
1202
1203This alternate equalization option accelerates the exploration of the best combination of
1204transmitted symbols across layers minimizing the Euclidean distance between the received and
1205reconstructed signal, then generates the LLRs to be used by the LDPC Decoder.
1206The input is the results of the Q R decomposition: Q^Hy signal and R matrix.
1207
1208The structure passed for each MLD-TS operation is given below,
1209with the operation flags forming a bitmask in the ``op_flags`` field.
1210
1211  **NOTE:** The actual operation flags that may be used with a specific
1212  bbdev PMD are dependent on the driver capabilities as reported via
1213  ``rte_bbdev_info_get()``, and may be a subset of those below.
1214
1215.. literalinclude:: ../../../lib/bbdev/rte_bbdev_op.h
1216   :language: c
1217   :start-after: Structure rte_bbdev_op_mldts 8<
1218   :end-before: >8 End of structure rte_bbdev_op_mldts.
1219
1220+--------------------------------------------------------------------+
1221|Description of MLD-TS capability flags                              |
1222+====================================================================+
1223|RTE_BBDEV_MLDTS_REP                                                 |
1224| Set if the option to use repeated data from R channel is supported |
1225+--------------------------------------------------------------------+
1226
1227The MLD-TS parameters are set out in the table below.
1228
1229+-------------------------+--------------------------------------------------------------+
1230|Parameter                |Description                                                   |
1231+=========================+==============================================================+
1232|qhy_input                |input data qHy                                                |
1233+-------------------------+--------------------------------------------------------------+
1234|r_input                  |input data R triangular matrix                                |
1235+-------------------------+--------------------------------------------------------------+
1236|output                   |output data (LLRs)                                            |
1237+-------------------------+--------------------------------------------------------------+
1238|op_flags                 |bitmask of all active operation capabilities                  |
1239+-------------------------+--------------------------------------------------------------+
1240|num_rbs                  |number of Resource Blocks                                     |
1241+-------------------------+--------------------------------------------------------------+
1242|num_layers               |number of overlapping layers                                  |
1243+-------------------------+--------------------------------------------------------------+
1244|q_m                      |array of modulation order for each layer                      |
1245+-------------------------+--------------------------------------------------------------+
1246|r_rep                    |optional row repetition for the R matrix (subcarriers)        |
1247+-------------------------+--------------------------------------------------------------+
1248|c_rep                    |optional column repetition for the R matrix (symbols)         |
1249+-------------------------+--------------------------------------------------------------+
1250
1251Sample code
1252-----------
1253
1254The baseband device sample application gives an introduction on how to use the
1255bbdev framework, by giving a sample code performing a loop-back operation with a
1256baseband processor capable of transceiving data packets.
1257
1258The following sample C-like pseudo-code shows the basic steps to encode several
1259buffers using (**sw_turbo**) bbdev PMD.
1260
1261.. code-block:: c
1262
1263    /* EAL Init */
1264    ret = rte_eal_init(argc, argv);
1265    if (ret < 0)
1266        rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n");
1267
1268    /* Get number of available bbdev devices */
1269    nb_bbdevs = rte_bbdev_count();
1270    if (nb_bbdevs == 0)
1271        rte_exit(EXIT_FAILURE, "No bbdevs detected!\n");
1272
1273    /* Create bbdev op pools */
1274    bbdev_op_pool[RTE_BBDEV_OP_TURBO_ENC] =
1275            rte_bbdev_op_pool_create("bbdev_op_pool_enc",
1276            RTE_BBDEV_OP_TURBO_ENC, NB_MBUF, 128, rte_socket_id());
1277
1278    /* Get information for this device */
1279    rte_bbdev_info_get(dev_id, &info);
1280
1281    /* Setup BBDEV device queues */
1282    ret = rte_bbdev_setup_queues(dev_id, qs_nb, info.socket_id);
1283    if (ret < 0)
1284        rte_exit(EXIT_FAILURE,
1285                "ERROR(%d): BBDEV %u not configured properly\n",
1286                ret, dev_id);
1287
1288    /* setup device queues */
1289    qconf.socket = info.socket_id;
1290    qconf.queue_size = info.drv.queue_size_lim;
1291    qconf.op_type = RTE_BBDEV_OP_TURBO_ENC;
1292
1293    for (q_id = 0; q_id < qs_nb; q_id++) {
1294        /* Configure all queues belonging to this bbdev device */
1295        ret = rte_bbdev_queue_configure(dev_id, q_id, &qconf);
1296        if (ret < 0)
1297            rte_exit(EXIT_FAILURE,
1298                    "ERROR(%d): BBDEV %u queue %u not configured properly\n",
1299                    ret, dev_id, q_id);
1300    }
1301
1302    /* Start bbdev device */
1303    ret = rte_bbdev_start(dev_id);
1304
1305    /* Create the mbuf mempool for pkts */
1306    mbuf_pool = rte_pktmbuf_pool_create("bbdev_mbuf_pool",
1307            NB_MBUF, MEMPOOL_CACHE_SIZE, 0,
1308            RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id());
1309    if (mbuf_pool == NULL)
1310        rte_exit(EXIT_FAILURE,
1311                "Unable to create '%s' pool\n", pool_name);
1312
1313    while (!global_exit_flag) {
1314
1315        /* Allocate burst of op structures in preparation for enqueue */
1316        if (rte_bbdev_enc_op_alloc_bulk(bbdev_op_pool[RTE_BBDEV_OP_TURBO_ENC],
1317            ops_burst, op_num) != 0)
1318            continue;
1319
1320        /* Allocate input mbuf pkts */
1321        ret = rte_pktmbuf_alloc_bulk(mbuf_pool, input_pkts_burst, MAX_PKT_BURST);
1322        if (ret < 0)
1323            continue;
1324
1325        /* Allocate output mbuf pkts */
1326        ret = rte_pktmbuf_alloc_bulk(mbuf_pool, output_pkts_burst, MAX_PKT_BURST);
1327        if (ret < 0)
1328            continue;
1329
1330        for (j = 0; j < op_num; j++) {
1331            /* Append the size of the ethernet header */
1332            rte_pktmbuf_append(input_pkts_burst[j],
1333                    sizeof(struct rte_ether_hdr));
1334
1335            /* set op */
1336
1337            ops_burst[j]->turbo_enc.input.offset =
1338                sizeof(struct rte_ether_hdr);
1339
1340            ops_burst[j]->turbo_enc->input.length =
1341                rte_pktmbuf_pkt_len(bbdev_pkts[j]);
1342
1343            ops_burst[j]->turbo_enc->input.data =
1344                input_pkts_burst[j];
1345
1346            ops_burst[j]->turbo_enc->output.offset =
1347                sizeof(struct rte_ether_hdr);
1348
1349            ops_burst[j]->turbo_enc->output.data =
1350                    output_pkts_burst[j];
1351        }
1352
1353        /* Enqueue packets on BBDEV device */
1354        op_num = rte_bbdev_enqueue_enc_ops(qconf->bbdev_id,
1355                qconf->bbdev_qs[q], ops_burst,
1356                MAX_PKT_BURST);
1357
1358        /* Dequeue packets from BBDEV device*/
1359        op_num = rte_bbdev_dequeue_enc_ops(qconf->bbdev_id,
1360                qconf->bbdev_qs[q], ops_burst,
1361                MAX_PKT_BURST);
1362    }
1363
1364
1365BBDEV Device API
1366~~~~~~~~~~~~~~~~
1367
1368The bbdev Library API is described in the *DPDK API Reference* document.
1369