14935e1e9SAmr Mokhtar.. SPDX-License-Identifier: BSD-3-Clause 24935e1e9SAmr Mokhtar Copyright(c) 2017 Intel Corporation 34935e1e9SAmr Mokhtar 44935e1e9SAmr MokhtarWireless Baseband Device Library 54935e1e9SAmr Mokhtar================================ 64935e1e9SAmr Mokhtar 74935e1e9SAmr MokhtarThe Wireless Baseband library provides a common programming framework that 84935e1e9SAmr Mokhtarabstracts HW accelerators based on FPGA and/or Fixed Function Accelerators that 9*7273821fSKamil Chalupnikassist with 3GPP Physical Layer processing. Furthermore, it decouples the 104935e1e9SAmr Mokhtarapplication from the compute-intensive wireless functions by abstracting their 114935e1e9SAmr Mokhtaroptimized libraries to appear as virtual bbdev devices. 124935e1e9SAmr Mokhtar 134935e1e9SAmr MokhtarThe functional scope of the BBDEV library are those functions in relation to 14*7273821fSKamil Chalupnikthe 3GPP Layer 1 signal processing (channel coding, modulation, ...). 154935e1e9SAmr Mokhtar 164935e1e9SAmr MokhtarThe framework currently only supports Turbo Code FEC function. 174935e1e9SAmr Mokhtar 184935e1e9SAmr Mokhtar 194935e1e9SAmr MokhtarDesign Principles 204935e1e9SAmr Mokhtar----------------- 214935e1e9SAmr Mokhtar 224935e1e9SAmr MokhtarThe Wireless Baseband library follows the same ideology of DPDK's Ethernet 234935e1e9SAmr MokhtarDevice and Crypto Device frameworks. Wireless Baseband provides a generic 244935e1e9SAmr Mokhtaracceleration abstraction framework which supports both physical (hardware) and 254935e1e9SAmr Mokhtarvirtual (software) wireless acceleration functions. 264935e1e9SAmr Mokhtar 274935e1e9SAmr MokhtarDevice Management 284935e1e9SAmr Mokhtar----------------- 294935e1e9SAmr Mokhtar 304935e1e9SAmr MokhtarDevice Creation 314935e1e9SAmr Mokhtar~~~~~~~~~~~~~~~ 324935e1e9SAmr Mokhtar 334935e1e9SAmr MokhtarPhysical bbdev devices are discovered during the PCI probe/enumeration of the 344935e1e9SAmr MokhtarEAL function which is executed at DPDK initialization, based on 354935e1e9SAmr Mokhtartheir PCI device identifier, each unique PCI BDF (bus/bridge, device, 364935e1e9SAmr Mokhtarfunction). 374935e1e9SAmr Mokhtar 384935e1e9SAmr MokhtarVirtual devices can be created by two mechanisms, either using the EAL command 394935e1e9SAmr Mokhtarline options or from within the application using an EAL API directly. 404935e1e9SAmr Mokhtar 414935e1e9SAmr MokhtarFrom the command line using the --vdev EAL option 424935e1e9SAmr Mokhtar 434935e1e9SAmr Mokhtar.. code-block:: console 444935e1e9SAmr Mokhtar 454935e1e9SAmr Mokhtar --vdev 'turbo_sw,max_nb_queues=8,socket_id=0' 464935e1e9SAmr Mokhtar 474935e1e9SAmr MokhtarOur using the rte_vdev_init API within the application code. 484935e1e9SAmr Mokhtar 494935e1e9SAmr Mokhtar.. code-block:: c 504935e1e9SAmr Mokhtar 514935e1e9SAmr Mokhtar rte_vdev_init("turbo_sw", "max_nb_queues=2,socket_id=0") 524935e1e9SAmr Mokhtar 534935e1e9SAmr MokhtarAll virtual bbdev devices support the following initialization parameters: 544935e1e9SAmr Mokhtar 554935e1e9SAmr Mokhtar- ``max_nb_queues`` - maximum number of queues supported by the device. 564935e1e9SAmr Mokhtar 574935e1e9SAmr Mokhtar- ``socket_id`` - socket on which to allocate the device resources on. 584935e1e9SAmr Mokhtar 594935e1e9SAmr Mokhtar 604935e1e9SAmr MokhtarDevice Identification 614935e1e9SAmr Mokhtar~~~~~~~~~~~~~~~~~~~~~ 624935e1e9SAmr Mokhtar 634935e1e9SAmr MokhtarEach device, whether virtual or physical is uniquely designated by two 644935e1e9SAmr Mokhtaridentifiers: 654935e1e9SAmr Mokhtar 664935e1e9SAmr Mokhtar- A unique device index used to designate the bbdev device in all functions 674935e1e9SAmr Mokhtar exported by the bbdev API. 684935e1e9SAmr Mokhtar 694935e1e9SAmr Mokhtar- A device name used to designate the bbdev device in console messages, for 704935e1e9SAmr Mokhtar administration or debugging purposes. For ease of use, the port name includes 714935e1e9SAmr Mokhtar the port index. 724935e1e9SAmr Mokhtar 734935e1e9SAmr Mokhtar 744935e1e9SAmr MokhtarDevice Configuration 754935e1e9SAmr Mokhtar~~~~~~~~~~~~~~~~~~~~ 764935e1e9SAmr Mokhtar 774935e1e9SAmr MokhtarFrom the application point of view, each instance of a bbdev device consists of 784935e1e9SAmr Mokhtarone or more queues identified by queue IDs. While different devices may have 794935e1e9SAmr Mokhtardifferent capabilities (e.g. support different operation types), all queues on 804935e1e9SAmr Mokhtara device support identical configuration possibilities. A queue is configured 814935e1e9SAmr Mokhtarfor only one type of operation and is configured at initializations time. 824935e1e9SAmr MokhtarWhen an operation is enqueued to a specific queue ID, the result is dequeued 834935e1e9SAmr Mokhtarfrom the same queue ID. 844935e1e9SAmr Mokhtar 854935e1e9SAmr MokhtarConfiguration of a device has two different levels: configuration that applies 864935e1e9SAmr Mokhtarto the whole device, and configuration that applies to a single queue. 874935e1e9SAmr Mokhtar 884935e1e9SAmr MokhtarDevice configuration is applied with 894935e1e9SAmr Mokhtar``rte_bbdev_setup_queues(dev_id,num_queues,socket_id)`` 904935e1e9SAmr Mokhtarand queue configuration is applied with 914935e1e9SAmr Mokhtar``rte_bbdev_queue_configure(dev_id,queue_id,conf)``. Note that, although all 924935e1e9SAmr Mokhtarqueues on a device support same capabilities, they can be configured differently 934935e1e9SAmr Mokhtarand will then behave differently. 944935e1e9SAmr MokhtarDevices supporting interrupts can enable them by using 954935e1e9SAmr Mokhtar``rte_bbdev_intr_enable(dev_id)``. 964935e1e9SAmr Mokhtar 974935e1e9SAmr MokhtarThe configuration of each bbdev device includes the following operations: 984935e1e9SAmr Mokhtar 994935e1e9SAmr Mokhtar- Allocation of resources, including hardware resources if a physical device. 1004935e1e9SAmr Mokhtar- Resetting the device into a well-known default state. 1014935e1e9SAmr Mokhtar- Initialization of statistics counters. 1024935e1e9SAmr Mokhtar 1034935e1e9SAmr MokhtarThe ``rte_bbdev_setup_queues`` API is used to setup queues for a bbdev device. 1044935e1e9SAmr Mokhtar 1054935e1e9SAmr Mokhtar.. code-block:: c 1064935e1e9SAmr Mokhtar 1074935e1e9SAmr Mokhtar int rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, 1084935e1e9SAmr Mokhtar int socket_id); 1094935e1e9SAmr Mokhtar 1104935e1e9SAmr Mokhtar- ``num_queues`` argument identifies the total number of queues to setup for 1114935e1e9SAmr Mokhtar this device. 1124935e1e9SAmr Mokhtar 1134935e1e9SAmr Mokhtar- ``socket_id`` specifies which socket will be used to allocate the memory. 1144935e1e9SAmr Mokhtar 1154935e1e9SAmr Mokhtar 1164935e1e9SAmr MokhtarThe ``rte_bbdev_intr_enable`` API is used to enable interrupts for a bbdev 1174935e1e9SAmr Mokhtardevice, if supported by the driver. Should be called before starting the device. 1184935e1e9SAmr Mokhtar 1194935e1e9SAmr Mokhtar.. code-block:: c 1204935e1e9SAmr Mokhtar 1214935e1e9SAmr Mokhtar int rte_bbdev_intr_enable(uint16_t dev_id); 1224935e1e9SAmr Mokhtar 1234935e1e9SAmr Mokhtar 1244935e1e9SAmr MokhtarQueues Configuration 1254935e1e9SAmr Mokhtar~~~~~~~~~~~~~~~~~~~~ 1264935e1e9SAmr Mokhtar 1274935e1e9SAmr MokhtarEach bbdev devices queue is individually configured through the 1284935e1e9SAmr Mokhtar``rte_bbdev_queue_configure()`` API. 1294935e1e9SAmr MokhtarEach queue resources may be allocated on a specified socket. 1304935e1e9SAmr Mokhtar 1314935e1e9SAmr Mokhtar.. code-block:: c 1324935e1e9SAmr Mokhtar 1334935e1e9SAmr Mokhtar struct rte_bbdev_queue_conf { 1344935e1e9SAmr Mokhtar int socket; 1354935e1e9SAmr Mokhtar uint32_t queue_size; 1364935e1e9SAmr Mokhtar uint8_t priority; 1374935e1e9SAmr Mokhtar bool deferred_start; 1384935e1e9SAmr Mokhtar enum rte_bbdev_op_type op_type; 1394935e1e9SAmr Mokhtar }; 1404935e1e9SAmr Mokhtar 1414935e1e9SAmr MokhtarDevice & Queues Management 1424935e1e9SAmr Mokhtar~~~~~~~~~~~~~~~~~~~~~~~~~~ 1434935e1e9SAmr Mokhtar 1444935e1e9SAmr MokhtarAfter initialization, devices are in a stopped state, so must be started by the 1454935e1e9SAmr Mokhtarapplication. If an application is finished using a device it can close the 1464935e1e9SAmr Mokhtardevice. Once closed, it cannot be restarted. 1474935e1e9SAmr Mokhtar 1484935e1e9SAmr Mokhtar.. code-block:: c 1494935e1e9SAmr Mokhtar 1504935e1e9SAmr Mokhtar int rte_bbdev_start(uint16_t dev_id) 1514935e1e9SAmr Mokhtar int rte_bbdev_stop(uint16_t dev_id) 1524935e1e9SAmr Mokhtar int rte_bbdev_close(uint16_t dev_id) 1534935e1e9SAmr Mokhtar int rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id) 1544935e1e9SAmr Mokhtar int rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id) 1554935e1e9SAmr Mokhtar 1564935e1e9SAmr Mokhtar 1574935e1e9SAmr MokhtarBy default, all queues are started when the device is started, but they can be 1584935e1e9SAmr Mokhtarstopped individually. 1594935e1e9SAmr Mokhtar 1604935e1e9SAmr Mokhtar.. code-block:: c 1614935e1e9SAmr Mokhtar 1624935e1e9SAmr Mokhtar int rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id) 1634935e1e9SAmr Mokhtar int rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id) 1644935e1e9SAmr Mokhtar 1654935e1e9SAmr Mokhtar 1664935e1e9SAmr MokhtarLogical Cores, Memory and Queues Relationships 1674935e1e9SAmr Mokhtar~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1684935e1e9SAmr Mokhtar 1694935e1e9SAmr MokhtarThe bbdev device Library as the Poll Mode Driver library support NUMA for when 170*7273821fSKamil Chalupnika processor's logical cores and interfaces utilize its local memory. Therefore 1714935e1e9SAmr Mokhtarbaseband operations, the mbuf being operated on should be allocated from memory 1724935e1e9SAmr Mokhtarpools created in the local memory. The buffers should, if possible, remain on 1734935e1e9SAmr Mokhtarthe local processor to obtain the best performance results and buffer 1744935e1e9SAmr Mokhtardescriptors should be populated with mbufs allocated from a mempool allocated 1754935e1e9SAmr Mokhtarfrom local memory. 1764935e1e9SAmr Mokhtar 1774935e1e9SAmr MokhtarThe run-to-completion model also performs better, especially in the case of 1784935e1e9SAmr Mokhtarvirtual bbdev devices, if the baseband operation and data buffers are in local 1794935e1e9SAmr Mokhtarmemory instead of a remote processor's memory. This is also true for the 1804935e1e9SAmr Mokhtarpipe-line model provided all logical cores used are located on the same processor. 1814935e1e9SAmr Mokhtar 1824935e1e9SAmr MokhtarMultiple logical cores should never share the same queue for enqueuing 1834935e1e9SAmr Mokhtaroperations or dequeuing operations on the same bbdev device since this would 1844935e1e9SAmr Mokhtarrequire global locks and hinder performance. It is however possible to use a 1854935e1e9SAmr Mokhtardifferent logical core to dequeue an operation on a queue pair from the logical 1864935e1e9SAmr Mokhtarcore which it was enqueued on. This means that a baseband burst enqueue/dequeue 1874935e1e9SAmr MokhtarAPIs are a logical place to transition from one logical core to another in a 1884935e1e9SAmr Mokhtarpacket processing pipeline. 1894935e1e9SAmr Mokhtar 1904935e1e9SAmr Mokhtar 1914935e1e9SAmr MokhtarDevice Operation Capabilities 1924935e1e9SAmr Mokhtar----------------------------- 1934935e1e9SAmr Mokhtar 1944935e1e9SAmr MokhtarCapabilities (in terms of operations supported, max number of queues, etc.) 1954935e1e9SAmr Mokhtaridentify what a bbdev is capable of performing that differs from one device to 1964935e1e9SAmr Mokhtaranother. For the full scope of the bbdev capability see the definition of the 1974935e1e9SAmr Mokhtarstructure in the *DPDK API Reference*. 1984935e1e9SAmr Mokhtar 1994935e1e9SAmr Mokhtar.. code-block:: c 2004935e1e9SAmr Mokhtar 2014935e1e9SAmr Mokhtar struct rte_bbdev_op_cap; 2024935e1e9SAmr Mokhtar 2034935e1e9SAmr MokhtarA device reports its capabilities when registering itself in the bbdev framework. 2044935e1e9SAmr MokhtarWith the aid of this capabilities mechanism, an application can query devices to 205*7273821fSKamil Chalupnikdiscover which operations within the 3GPP physical layer they are capable of 2064935e1e9SAmr Mokhtarperforming. Below is an example of the capabilities for a PMD it supports in 2074935e1e9SAmr Mokhtarrelation to Turbo Encoding and Decoding operations. 2084935e1e9SAmr Mokhtar 2094935e1e9SAmr Mokhtar.. code-block:: c 2104935e1e9SAmr Mokhtar 2114935e1e9SAmr Mokhtar static const struct rte_bbdev_op_cap bbdev_capabilities[] = { 2124935e1e9SAmr Mokhtar { 2134935e1e9SAmr Mokhtar .type = RTE_BBDEV_OP_TURBO_DEC, 2144935e1e9SAmr Mokhtar .cap.turbo_dec = { 2154935e1e9SAmr Mokhtar .capability_flags = 2164935e1e9SAmr Mokhtar RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE | 2174935e1e9SAmr Mokhtar RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN | 2184935e1e9SAmr Mokhtar RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN | 219*7273821fSKamil Chalupnik RTE_BBDEV_TURBO_CRC_TYPE_24B | 220*7273821fSKamil Chalupnik RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP | 221*7273821fSKamil Chalupnik RTE_BBDEV_TURBO_EARLY_TERMINATION, 222*7273821fSKamil Chalupnik .max_llr_modulus = 16, 2234935e1e9SAmr Mokhtar .num_buffers_src = RTE_BBDEV_MAX_CODE_BLOCKS, 2244935e1e9SAmr Mokhtar .num_buffers_hard_out = 2254935e1e9SAmr Mokhtar RTE_BBDEV_MAX_CODE_BLOCKS, 2264935e1e9SAmr Mokhtar .num_buffers_soft_out = 0, 2274935e1e9SAmr Mokhtar } 2284935e1e9SAmr Mokhtar }, 2294935e1e9SAmr Mokhtar { 2304935e1e9SAmr Mokhtar .type = RTE_BBDEV_OP_TURBO_ENC, 2314935e1e9SAmr Mokhtar .cap.turbo_enc = { 2324935e1e9SAmr Mokhtar .capability_flags = 2334935e1e9SAmr Mokhtar RTE_BBDEV_TURBO_CRC_24B_ATTACH | 234*7273821fSKamil Chalupnik RTE_BBDEV_TURBO_CRC_24A_ATTACH | 2354935e1e9SAmr Mokhtar RTE_BBDEV_TURBO_RATE_MATCH | 2364935e1e9SAmr Mokhtar RTE_BBDEV_TURBO_RV_INDEX_BYPASS, 2374935e1e9SAmr Mokhtar .num_buffers_src = RTE_BBDEV_MAX_CODE_BLOCKS, 2384935e1e9SAmr Mokhtar .num_buffers_dst = RTE_BBDEV_MAX_CODE_BLOCKS, 2394935e1e9SAmr Mokhtar } 2404935e1e9SAmr Mokhtar }, 2414935e1e9SAmr Mokhtar RTE_BBDEV_END_OF_CAPABILITIES_LIST() 2424935e1e9SAmr Mokhtar }; 2434935e1e9SAmr Mokhtar 2444935e1e9SAmr MokhtarCapabilities Discovery 2454935e1e9SAmr Mokhtar~~~~~~~~~~~~~~~~~~~~~~ 2464935e1e9SAmr Mokhtar 2474935e1e9SAmr MokhtarDiscovering the features and capabilities of a bbdev device poll mode driver 2484935e1e9SAmr Mokhtaris achieved through the ``rte_bbdev_info_get()`` function. 2494935e1e9SAmr Mokhtar 2504935e1e9SAmr Mokhtar.. code-block:: c 2514935e1e9SAmr Mokhtar 2524935e1e9SAmr Mokhtar int rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info) 2534935e1e9SAmr Mokhtar 2544935e1e9SAmr MokhtarThis allows the user to query a specific bbdev PMD and get all the device 2554935e1e9SAmr Mokhtarcapabilities. The ``rte_bbdev_info`` structure provides two levels of 2564935e1e9SAmr Mokhtarinformation: 2574935e1e9SAmr Mokhtar 2584935e1e9SAmr Mokhtar- Device relevant information, like: name and related rte_bus. 2594935e1e9SAmr Mokhtar 2604935e1e9SAmr Mokhtar- Driver specific information, as defined by the ``struct rte_bbdev_driver_info`` 2614935e1e9SAmr Mokhtar structure, this is where capabilities reside along with other specifics like: 2624935e1e9SAmr Mokhtar maximum queue sizes and priority level. 2634935e1e9SAmr Mokhtar 2644935e1e9SAmr Mokhtar.. code-block:: c 2654935e1e9SAmr Mokhtar 2664935e1e9SAmr Mokhtar struct rte_bbdev_info { 2674935e1e9SAmr Mokhtar int socket_id; 2684935e1e9SAmr Mokhtar const char *dev_name; 2694935e1e9SAmr Mokhtar const struct rte_bus *bus; 2704935e1e9SAmr Mokhtar uint16_t num_queues; 2714935e1e9SAmr Mokhtar bool started; 2724935e1e9SAmr Mokhtar struct rte_bbdev_driver_info drv; 2734935e1e9SAmr Mokhtar }; 2744935e1e9SAmr Mokhtar 2754935e1e9SAmr MokhtarOperation Processing 2764935e1e9SAmr Mokhtar-------------------- 2774935e1e9SAmr Mokhtar 2784935e1e9SAmr MokhtarScheduling of baseband operations on DPDK's application data path is 2794935e1e9SAmr Mokhtarperformed using a burst oriented asynchronous API set. A queue on a bbdev 2804935e1e9SAmr Mokhtardevice accepts a burst of baseband operations using enqueue burst API. On physical 2814935e1e9SAmr Mokhtarbbdev devices the enqueue burst API will place the operations to be processed 2824935e1e9SAmr Mokhtaron the device's hardware input queue, for virtual devices the processing of the 2834935e1e9SAmr Mokhtarbaseband operations is usually completed during the enqueue call to the bbdev 2844935e1e9SAmr Mokhtardevice. The dequeue burst API will retrieve any processed operations available 2854935e1e9SAmr Mokhtarfrom the queue on the bbdev device, from physical devices this is usually 2864935e1e9SAmr Mokhtardirectly from the device's processed queue, and for virtual device's from a 2874935e1e9SAmr Mokhtar``rte_ring`` where processed operations are place after being processed on the 2884935e1e9SAmr Mokhtarenqueue call. 2894935e1e9SAmr Mokhtar 2904935e1e9SAmr Mokhtar 2914935e1e9SAmr MokhtarEnqueue / Dequeue Burst APIs 2924935e1e9SAmr Mokhtar~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2934935e1e9SAmr Mokhtar 2944935e1e9SAmr MokhtarThe burst enqueue API uses a bbdev device identifier and a queue 2954935e1e9SAmr Mokhtaridentifier to specify the bbdev device queue to schedule the processing on. 2964935e1e9SAmr MokhtarThe ``num_ops`` parameter is the number of operations to process which are 2974935e1e9SAmr Mokhtarsupplied in the ``ops`` array of ``rte_bbdev_*_op`` structures. 2984935e1e9SAmr MokhtarThe enqueue function returns the number of operations it actually enqueued for 2994935e1e9SAmr Mokhtarprocessing, a return value equal to ``num_ops`` means that all packets have been 3004935e1e9SAmr Mokhtarenqueued. 3014935e1e9SAmr Mokhtar 3024935e1e9SAmr Mokhtar.. code-block:: c 3034935e1e9SAmr Mokhtar 3044935e1e9SAmr Mokhtar uint16_t rte_bbdev_enqueue_enc_ops(uint16_t dev_id, uint16_t queue_id, 3054935e1e9SAmr Mokhtar struct rte_bbdev_enc_op **ops, uint16_t num_ops) 3064935e1e9SAmr Mokhtar 3074935e1e9SAmr Mokhtar uint16_t rte_bbdev_enqueue_dec_ops(uint16_t dev_id, uint16_t queue_id, 3084935e1e9SAmr Mokhtar struct rte_bbdev_dec_op **ops, uint16_t num_ops) 3094935e1e9SAmr Mokhtar 3104935e1e9SAmr MokhtarThe dequeue API uses the same format as the enqueue API of processed but 3114935e1e9SAmr Mokhtarthe ``num_ops`` and ``ops`` parameters are now used to specify the max processed 3124935e1e9SAmr Mokhtaroperations the user wishes to retrieve and the location in which to store them. 3134935e1e9SAmr MokhtarThe API call returns the actual number of processed operations returned, this 3144935e1e9SAmr Mokhtarcan never be larger than ``num_ops``. 3154935e1e9SAmr Mokhtar 3164935e1e9SAmr Mokhtar.. code-block:: c 3174935e1e9SAmr Mokhtar 3184935e1e9SAmr Mokhtar uint16_t rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id, 3194935e1e9SAmr Mokhtar struct rte_bbdev_enc_op **ops, uint16_t num_ops) 3204935e1e9SAmr Mokhtar 3214935e1e9SAmr Mokhtar uint16_t rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id, 3224935e1e9SAmr Mokhtar struct rte_bbdev_dec_op **ops, uint16_t num_ops) 3234935e1e9SAmr Mokhtar 3244935e1e9SAmr MokhtarOperation Representation 3254935e1e9SAmr Mokhtar~~~~~~~~~~~~~~~~~~~~~~~~ 3264935e1e9SAmr Mokhtar 3274935e1e9SAmr MokhtarAn encode bbdev operation is represented by ``rte_bbdev_enc_op`` structure, 3284935e1e9SAmr Mokhtarand by ``rte_bbdev_dec_op`` for decode. These structures act as metadata 3294935e1e9SAmr Mokhtarcontainers for all necessary information required for the bbdev operation to be 3304935e1e9SAmr Mokhtarprocessed on a particular bbdev device poll mode driver. 3314935e1e9SAmr Mokhtar 3324935e1e9SAmr Mokhtar.. code-block:: c 3334935e1e9SAmr Mokhtar 3344935e1e9SAmr Mokhtar struct rte_bbdev_enc_op { 3354935e1e9SAmr Mokhtar int status; 3364935e1e9SAmr Mokhtar struct rte_mempool *mempool; 3374935e1e9SAmr Mokhtar void *opaque_data; 3384935e1e9SAmr Mokhtar struct rte_bbdev_op_turbo_enc turbo_enc; 3394935e1e9SAmr Mokhtar }; 3404935e1e9SAmr Mokhtar 3414935e1e9SAmr Mokhtar struct rte_bbdev_dec_op { 3424935e1e9SAmr Mokhtar int status; 3434935e1e9SAmr Mokhtar struct rte_mempool *mempool; 3444935e1e9SAmr Mokhtar void *opaque_data; 3454935e1e9SAmr Mokhtar struct rte_bbdev_op_turbo_dec turbo_dec; 3464935e1e9SAmr Mokhtar }; 3474935e1e9SAmr Mokhtar 3484935e1e9SAmr MokhtarThe operation structure by itself defines the operation type. It includes an 3494935e1e9SAmr Mokhtaroperation status, a reference to the operation specific data, which can vary in 3504935e1e9SAmr Mokhtarsize and content depending on the operation being provisioned. It also contains 3514935e1e9SAmr Mokhtarthe source mempool for the operation, if it is allocated from a mempool. 3524935e1e9SAmr Mokhtar 3534935e1e9SAmr MokhtarIf bbdev operations are allocated from a bbdev operation mempool, see next 3544935e1e9SAmr Mokhtarsection, there is also the ability to allocate private memory with the 3554935e1e9SAmr Mokhtaroperation for applications purposes. 3564935e1e9SAmr Mokhtar 3574935e1e9SAmr MokhtarApplication software is responsible for specifying all the operation specific 3584935e1e9SAmr Mokhtarfields in the ``rte_bbdev_*_op`` structure which are then used by the bbdev PMD 3594935e1e9SAmr Mokhtarto process the requested operation. 3604935e1e9SAmr Mokhtar 3614935e1e9SAmr Mokhtar 3624935e1e9SAmr MokhtarOperation Management and Allocation 3634935e1e9SAmr Mokhtar~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3644935e1e9SAmr Mokhtar 3654935e1e9SAmr MokhtarThe bbdev library provides an API set for managing bbdev operations which 3664935e1e9SAmr Mokhtarutilize the Mempool Library to allocate operation buffers. Therefore, it ensures 3674935e1e9SAmr Mokhtarthat the bbdev operation is interleaved optimally across the channels and 3684935e1e9SAmr Mokhtarranks for optimal processing. 3694935e1e9SAmr Mokhtar 3704935e1e9SAmr Mokhtar.. code-block:: c 3714935e1e9SAmr Mokhtar 3724935e1e9SAmr Mokhtar struct rte_mempool * 3734935e1e9SAmr Mokhtar rte_bbdev_op_pool_create(const char *name, enum rte_bbdev_op_type type, 3744935e1e9SAmr Mokhtar unsigned int num_elements, unsigned int cache_size, 3754935e1e9SAmr Mokhtar int socket_id) 3764935e1e9SAmr Mokhtar 3774935e1e9SAmr Mokhtar``rte_bbdev_*_op_alloc_bulk()`` and ``rte_bbdev_*_op_free_bulk()`` are used to 3784935e1e9SAmr Mokhtarallocate bbdev operations of a specific type from a given bbdev operation mempool. 3794935e1e9SAmr Mokhtar 3804935e1e9SAmr Mokhtar.. code-block:: c 3814935e1e9SAmr Mokhtar 3824935e1e9SAmr Mokhtar int rte_bbdev_enc_op_alloc_bulk(struct rte_mempool *mempool, 3834935e1e9SAmr Mokhtar struct rte_bbdev_enc_op **ops, uint16_t num_ops) 3844935e1e9SAmr Mokhtar 3854935e1e9SAmr Mokhtar int rte_bbdev_dec_op_alloc_bulk(struct rte_mempool *mempool, 3864935e1e9SAmr Mokhtar struct rte_bbdev_dec_op **ops, uint16_t num_ops) 3874935e1e9SAmr Mokhtar 3884935e1e9SAmr Mokhtar``rte_bbdev_*_op_free_bulk()`` is called by the application to return an 3894935e1e9SAmr Mokhtaroperation to its allocating pool. 3904935e1e9SAmr Mokhtar 3914935e1e9SAmr Mokhtar.. code-block:: c 3924935e1e9SAmr Mokhtar 3934935e1e9SAmr Mokhtar void rte_bbdev_dec_op_free_bulk(struct rte_bbdev_dec_op **ops, 3944935e1e9SAmr Mokhtar unsigned int num_ops) 3954935e1e9SAmr Mokhtar void rte_bbdev_enc_op_free_bulk(struct rte_bbdev_enc_op **ops, 3964935e1e9SAmr Mokhtar unsigned int num_ops) 3974935e1e9SAmr Mokhtar 398*7273821fSKamil ChalupnikBBDEV Inbound/Outbound Memory 399*7273821fSKamil Chalupnik~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4004935e1e9SAmr Mokhtar 4014935e1e9SAmr MokhtarThe bbdev operation structure contains all the mutable data relating to 402*7273821fSKamil Chalupnikperforming Turbo coding on a referenced mbuf data buffer. It is used for either 403*7273821fSKamil Chalupnikencode or decode operations. 4044935e1e9SAmr Mokhtar 4054935e1e9SAmr MokhtarTurbo Encode operation accepts one input and one output. 4064935e1e9SAmr MokhtarTurbo Decode operation accepts one input and two outputs, called *hard-decision* 4074935e1e9SAmr Mokhtarand *soft-decision* outputs. *Soft-decision* output is optional. 4084935e1e9SAmr Mokhtar 409*7273821fSKamil ChalupnikIt is expected that the application provides input and output mbuf pointers 4104935e1e9SAmr Mokhtarallocated and ready to use. The baseband framework supports turbo coding on 4114935e1e9SAmr MokhtarCode Blocks (CB) and Transport Blocks (TB). 4124935e1e9SAmr Mokhtar 413*7273821fSKamil ChalupnikFor the output buffer(s), the application is required to provide an allocated 414*7273821fSKamil Chalupnikand free mbuf, so that bbdev write back the resulting output. 4154935e1e9SAmr Mokhtar 416*7273821fSKamil ChalupnikThe support of split "scattered" buffers is a driver-specific feature, so it is 417*7273821fSKamil Chalupnikreported individually by the supporting driver as a capability. 418*7273821fSKamil Chalupnik 419*7273821fSKamil ChalupnikInput and output data buffers are identified by ``rte_bbdev_op_data`` structure, 420*7273821fSKamil Chalupnikas follows: 421*7273821fSKamil Chalupnik 422*7273821fSKamil Chalupnik.. code-block:: c 423*7273821fSKamil Chalupnik 424*7273821fSKamil Chalupnik struct rte_bbdev_op_data { 425*7273821fSKamil Chalupnik struct rte_mbuf *data; 426*7273821fSKamil Chalupnik uint32_t offset; 427*7273821fSKamil Chalupnik uint32_t length; 428*7273821fSKamil Chalupnik }; 429*7273821fSKamil Chalupnik 430*7273821fSKamil Chalupnik 431*7273821fSKamil ChalupnikThis structure has three elements: 432*7273821fSKamil Chalupnik 433*7273821fSKamil Chalupnik- ``data``: This is the mbuf data structure representing the data for BBDEV 434*7273821fSKamil Chalupnik operation. 435*7273821fSKamil Chalupnik 436*7273821fSKamil Chalupnik This mbuf pointer can point to one Code Block (CB) data buffer or multiple CBs 437*7273821fSKamil Chalupnik contiguously located next to each other. A Transport Block (TB) represents a 438*7273821fSKamil Chalupnik whole piece of data that is divided into one or more CBs. Maximum number of 439*7273821fSKamil Chalupnik CBs can be contained in one TB is defined by ``RTE_BBDEV_MAX_CODE_BLOCKS``. 440*7273821fSKamil Chalupnik 441*7273821fSKamil Chalupnik An mbuf data structure cannot represent more than one TB. The smallest piece 442*7273821fSKamil Chalupnik of data that can be contained in one mbuf is one CB. 443*7273821fSKamil Chalupnik An mbuf can include one contiguous CB, subset of contiguous CBs that are 444*7273821fSKamil Chalupnik belonging to one TB, or all contiguous CBs that are belonging to one TB. 445*7273821fSKamil Chalupnik 446*7273821fSKamil Chalupnik If a BBDEV PMD supports the extended capability "Scatter-Gather", then it is 447*7273821fSKamil Chalupnik capable of collecting (gathering) non-contiguous (scattered) data from 448*7273821fSKamil Chalupnik multiple locations in the memory. 449*7273821fSKamil Chalupnik This capability is reported by the capability flags: 450*7273821fSKamil Chalupnik 451*7273821fSKamil Chalupnik - ``RTE_BBDEV_TURBO_ENC_SCATTER_GATHER``, and 452*7273821fSKamil Chalupnik 453*7273821fSKamil Chalupnik - ``RTE_BBDEV_TURBO_DEC_SCATTER_GATHER``. 454*7273821fSKamil Chalupnik 455*7273821fSKamil Chalupnik Only if a BBDEV PMD supports this feature, chained mbuf data structures are 456*7273821fSKamil Chalupnik accepted. A chained mbuf can represent one non-contiguous CB or multiple 457*7273821fSKamil Chalupnik non-contiguous CBs. 458*7273821fSKamil Chalupnik The first mbuf segment in the given chained mbuf represents the first piece 459*7273821fSKamil Chalupnik of the CB. Offset is only applicable to the first segment. ``length`` is the 460*7273821fSKamil Chalupnik total length of the CB. 461*7273821fSKamil Chalupnik 462*7273821fSKamil Chalupnik BBDEV driver is responsible for identifying where the split is and enqueue 463*7273821fSKamil Chalupnik the split data to its internal queues. 464*7273821fSKamil Chalupnik 465*7273821fSKamil Chalupnik If BBDEV PMD does not support this feature, it will assume inbound mbuf data 466*7273821fSKamil Chalupnik contains one segment. 467*7273821fSKamil Chalupnik 468*7273821fSKamil Chalupnik The output mbuf data though is always one segment, even if the input was a 469*7273821fSKamil Chalupnik chained mbuf. 470*7273821fSKamil Chalupnik 471*7273821fSKamil Chalupnik 472*7273821fSKamil Chalupnik- ``offset``: This is the starting point of the BBDEV (encode/decode) operation, 473*7273821fSKamil Chalupnik in bytes. 474*7273821fSKamil Chalupnik 475*7273821fSKamil Chalupnik BBDEV starts to read data past this offset. 476*7273821fSKamil Chalupnik In case of chained mbuf, this offset applies only to the first mbuf segment. 477*7273821fSKamil Chalupnik 478*7273821fSKamil Chalupnik 479*7273821fSKamil Chalupnik- ``length``: This is the total data length to be processed in one operation, 480*7273821fSKamil Chalupnik in bytes. 481*7273821fSKamil Chalupnik 482*7273821fSKamil Chalupnik In case the mbuf data is representing one CB, this is the length of the CB 483*7273821fSKamil Chalupnik undergoing the operation. 484*7273821fSKamil Chalupnik If it is for multiple CBs, this is the total length of those CBs undergoing 485*7273821fSKamil Chalupnik the operation. 486*7273821fSKamil Chalupnik If it is for one TB, this is the total length of the TB under operation. 487*7273821fSKamil Chalupnik In case of chained mbuf, this data length includes the lengths of the 488*7273821fSKamil Chalupnik "scattered" data segments undergoing the operation. 489*7273821fSKamil Chalupnik 490*7273821fSKamil Chalupnik 491*7273821fSKamil ChalupnikBBDEV Turbo Encode Operation 492*7273821fSKamil Chalupnik~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4934935e1e9SAmr Mokhtar 4944935e1e9SAmr Mokhtar.. code-block:: c 4954935e1e9SAmr Mokhtar 4964935e1e9SAmr Mokhtar struct rte_bbdev_op_turbo_enc { 4974935e1e9SAmr Mokhtar struct rte_bbdev_op_data input; 4984935e1e9SAmr Mokhtar struct rte_bbdev_op_data output; 4994935e1e9SAmr Mokhtar 5004935e1e9SAmr Mokhtar uint32_t op_flags; 5014935e1e9SAmr Mokhtar uint8_t rv_index; 5024935e1e9SAmr Mokhtar uint8_t code_block_mode; 5034935e1e9SAmr Mokhtar union { 5044935e1e9SAmr Mokhtar struct rte_bbdev_op_enc_cb_params cb_params; 5054935e1e9SAmr Mokhtar struct rte_bbdev_op_enc_tb_params tb_params; 5064935e1e9SAmr Mokhtar }; 5074935e1e9SAmr Mokhtar }; 5084935e1e9SAmr Mokhtar 509*7273821fSKamil ChalupnikThe Turbo encode structure is composed of the ``input`` and ``output`` mbuf 510*7273821fSKamil Chalupnikdata pointers. The provided mbuf pointer of ``input`` needs to be big enough to 511*7273821fSKamil Chalupnikstretch for extra CRC trailers. 5124935e1e9SAmr Mokhtar 513*7273821fSKamil Chalupnik``op_flags`` parameter holds all operation related flags, like whether CRC24A is 514*7273821fSKamil Chalupnikincluded by the application or not. 515*7273821fSKamil Chalupnik 516*7273821fSKamil Chalupnik``code_block_mode`` flag identifies the mode in which bbdev is operating in. 517*7273821fSKamil Chalupnik 518*7273821fSKamil ChalupnikThe encode interface works on both the code block (CB) and the transport block 519*7273821fSKamil Chalupnik(TB). An operation executes in "CB-mode" when the CB is standalone. While 520*7273821fSKamil Chalupnik"TB-mode" executes when an operation performs on one or multiple CBs that 521*7273821fSKamil Chalupnikbelong to a TB. Therefore, a given data can be standalone CB, full-size TB or 522*7273821fSKamil Chalupnikpartial TB. Partial TB means that only a subset of CBs belonging to a bigger TB 523*7273821fSKamil Chalupnikare being enqueued. 524*7273821fSKamil Chalupnik 525*7273821fSKamil Chalupnik **NOTE:** It is assumed that all enqueued ops in one ``rte_bbdev_enqueue_enc_ops()`` 526*7273821fSKamil Chalupnik call belong to one mode, either CB-mode or TB-mode. 527*7273821fSKamil Chalupnik 528*7273821fSKamil ChalupnikIn case that the CB is smaller than Z (6144 bits), then effectively the TB = CB. 529*7273821fSKamil ChalupnikCRC24A is appended to the tail of the CB. The application is responsible for 530*7273821fSKamil Chalupnikcalculating and appending CRC24A before calling BBDEV in case that the 531*7273821fSKamil Chalupnikunderlying driver does not support CRC24A generation. 532*7273821fSKamil Chalupnik 533*7273821fSKamil ChalupnikIn CB-mode, CRC24A/B is an optional operation. 534*7273821fSKamil ChalupnikThe input ``k`` is the size of the CB (this maps to K as described in 3GPP TS 535*7273821fSKamil Chalupnik36.212 section 5.1.2), this size is inclusive of CRC24A/B. 536*7273821fSKamil ChalupnikThe ``length`` is inclusive of CRC24A/B and equals to ``k`` in this case. 537*7273821fSKamil Chalupnik 538*7273821fSKamil ChalupnikNot all BBDEV PMDs are capable of CRC24A/B calculation. Flags 539*7273821fSKamil Chalupnik``RTE_BBDEV_TURBO_CRC_24A_ATTACH`` and ``RTE_BBDEV_TURBO_CRC_24B_ATTACH`` 540*7273821fSKamil Chalupnikinforms the application with relevant capability. These flags can be set in the 541*7273821fSKamil Chalupnik``op_flags`` parameter to indicate BBDEV to calculate and append CRC24A to CB 542*7273821fSKamil Chalupnikbefore going forward with Turbo encoding. 543*7273821fSKamil Chalupnik 544*7273821fSKamil ChalupnikOutput format of the CB encode will have the encoded CB in ``e`` size output 545*7273821fSKamil Chalupnik(this maps to E described in 3GPP TS 36.212 section 5.1.4.1.2). The output mbuf 546*7273821fSKamil Chalupnikbuffer size needs to be big enough to hold the encoded buffer of size ``e``. 547*7273821fSKamil Chalupnik 548*7273821fSKamil ChalupnikIn TB-mode, CRC24A is assumed to be pre-calculated and appended to the inbound 549*7273821fSKamil ChalupnikTB mbuf data buffer. 550*7273821fSKamil ChalupnikThe output mbuf data structure is expected to be allocated by the application 551*7273821fSKamil Chalupnikwith enough room for the output data. 552*7273821fSKamil Chalupnik 553*7273821fSKamil ChalupnikThe difference between the partial and full-size TB is that we need to know the 554*7273821fSKamil Chalupnikindex of the first CB in this group and the number of CBs contained within. 555*7273821fSKamil ChalupnikThe first CB index is given by ``r`` but the number of the remaining CBs is 556*7273821fSKamil Chalupnikcalculated automatically by BBDEV before passing down to the driver. 557*7273821fSKamil Chalupnik 558*7273821fSKamil ChalupnikThe number of remaining CBs should not be confused with ``c``. ``c`` is the 559*7273821fSKamil Chalupniktotal number of CBs that composes the whole TB (this maps to C as 560*7273821fSKamil Chalupnikdescribed in 3GPP TS 36.212 section 5.1.2). 561*7273821fSKamil Chalupnik 562*7273821fSKamil ChalupnikThe ``length`` is total size of the CBs inclusive of any CRC24A and CRC24B in 563*7273821fSKamil Chalupnikcase they were appended by the application. 564*7273821fSKamil Chalupnik 565*7273821fSKamil ChalupnikThe case when one CB belongs to TB and is being enqueued individually to BBDEV, 566*7273821fSKamil Chalupnikthis case is considered as a special case of partial TB where its number of CBs 567*7273821fSKamil Chalupnikis 1. Therefore, it requires to get processed in TB-mode. 568*7273821fSKamil Chalupnik 569*7273821fSKamil Chalupnik 570*7273821fSKamil ChalupnikBBDEV Turbo Decode Operation 571*7273821fSKamil Chalupnik~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5724935e1e9SAmr Mokhtar 5734935e1e9SAmr Mokhtar.. code-block:: c 5744935e1e9SAmr Mokhtar 5754935e1e9SAmr Mokhtar struct rte_bbdev_op_turbo_dec { 5764935e1e9SAmr Mokhtar struct rte_bbdev_op_data input; 5774935e1e9SAmr Mokhtar struct rte_bbdev_op_data hard_output; 5784935e1e9SAmr Mokhtar struct rte_bbdev_op_data soft_output; 5794935e1e9SAmr Mokhtar 5804935e1e9SAmr Mokhtar uint32_t op_flags; 5814935e1e9SAmr Mokhtar uint8_t rv_index; 5824935e1e9SAmr Mokhtar uint8_t iter_min:4; 5834935e1e9SAmr Mokhtar uint8_t iter_max:4; 5844935e1e9SAmr Mokhtar uint8_t iter_count; 5854935e1e9SAmr Mokhtar uint8_t ext_scale; 5864935e1e9SAmr Mokhtar uint8_t num_maps; 5874935e1e9SAmr Mokhtar uint8_t code_block_mode; 5884935e1e9SAmr Mokhtar union { 5894935e1e9SAmr Mokhtar struct rte_bbdev_op_dec_cb_params cb_params; 5904935e1e9SAmr Mokhtar struct rte_bbdev_op_dec_tb_params tb_params; 5914935e1e9SAmr Mokhtar }; 5924935e1e9SAmr Mokhtar }; 5934935e1e9SAmr Mokhtar 594*7273821fSKamil ChalupnikThe Turbo decode structure is composed of the ``input`` and ``output`` mbuf 595*7273821fSKamil Chalupnikdata pointers. 5964935e1e9SAmr Mokhtar 597*7273821fSKamil Chalupnik``op_flags`` parameter holds all operation related flags, like whether CRC24B is 598*7273821fSKamil Chalupnikretained or not. 5994935e1e9SAmr Mokhtar 600*7273821fSKamil Chalupnik``code_block_mode`` flag identifies the mode in which bbdev is operating in. 6014935e1e9SAmr Mokhtar 602*7273821fSKamil ChalupnikSimilarly, the decode interface works on both the code block (CB) and the 603*7273821fSKamil Chalupniktransport block (TB). An operation executes in "CB-mode" when the CB is 604*7273821fSKamil Chalupnikstandalone. While "TB-mode" executes when an operation performs on one or 605*7273821fSKamil Chalupnikmultiple CBs that belong to a TB. Therefore, a given data can be standalone CB, 606*7273821fSKamil Chalupnikfull-size TB or partial TB. Partial TB means that only a subset of CBs belonging 607*7273821fSKamil Chalupnikto a bigger TB are being enqueued. 608*7273821fSKamil Chalupnik 609*7273821fSKamil Chalupnik **NOTE:** It is assumed that all enqueued ops in one ``rte_bbdev_enqueue_dec_ops()`` 610*7273821fSKamil Chalupnik call belong to one mode, either CB-mode or TB-mode. 611*7273821fSKamil Chalupnik 612*7273821fSKamil ChalupnikThe input ``k`` is the size of the decoded CB (this maps to K as described in 613*7273821fSKamil Chalupnik3GPP TS 36.212 section 5.1.2), this size is inclusive of CRC24A/B. 614*7273821fSKamil ChalupnikThe ``length`` is inclusive of CRC24A/B and equals to ``k`` in this case. 615*7273821fSKamil Chalupnik 616*7273821fSKamil ChalupnikThe input encoded CB data is the Virtual Circular Buffer data stream, wk, with 617*7273821fSKamil Chalupnikthe null padding included as described in 3GPP TS 36.212 section 5.1.4.1.2 and 618*7273821fSKamil Chalupnikshown in 3GPP TS 36.212 section 5.1.4.1 Figure 5.1.4-1. 619*7273821fSKamil ChalupnikThe size of the virtual circular buffer is 3*Kpi, where Kpi is the 32 byte 620*7273821fSKamil Chalupnikaligned value of K, as specified in 3GPP TS 36.212 section 5.1.4.1.1. 621*7273821fSKamil Chalupnik 622*7273821fSKamil ChalupnikEach byte in the input circular buffer is the LLR value of each bit of the 623*7273821fSKamil Chalupnikoriginal CB. 624*7273821fSKamil Chalupnik 625*7273821fSKamil Chalupnik``hard_output`` is a mandatory capability that all BBDEV PMDs support. This is 626*7273821fSKamil Chalupnikthe decoded CBs of K sizes (CRC24A/B is the last 24-bit in each decoded CB). 627*7273821fSKamil ChalupnikSoft output is an optional capability for BBDEV PMDs. Setting flag 628*7273821fSKamil Chalupnik``RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP`` in ``op_flags`` directs BBDEV to retain 629*7273821fSKamil ChalupnikCRC24B at the end of each CB. This might be useful for the application in debug 630*7273821fSKamil Chalupnikmode. 631*7273821fSKamil ChalupnikAn LLR rate matched output is computed in the ``soft_output`` buffer structure 632*7273821fSKamil Chalupnikfor the given ``e`` size (this maps to E described in 3GPP TS 36.212 section 633*7273821fSKamil Chalupnik5.1.4.1.2). The output mbuf buffer size needs to be big enough to hold the 634*7273821fSKamil Chalupnikencoded buffer of size ``e``. 635*7273821fSKamil Chalupnik 636*7273821fSKamil ChalupnikThe first CB Virtual Circular Buffer (VCB) index is given by ``r`` but the 637*7273821fSKamil Chalupniknumber of the remaining CB VCBs is calculated automatically by BBDEV before 638*7273821fSKamil Chalupnikpassing down to the driver. 639*7273821fSKamil Chalupnik 640*7273821fSKamil ChalupnikThe number of remaining CB VCBs should not be confused with ``c``. ``c`` is the 641*7273821fSKamil Chalupniktotal number of CBs that composes the whole TB (this maps to C as 642*7273821fSKamil Chalupnikdescribed in 3GPP TS 36.212 section 5.1.2). 643*7273821fSKamil Chalupnik 644*7273821fSKamil ChalupnikThe ``length`` is total size of the CBs inclusive of any CRC24A and CRC24B in 645*7273821fSKamil Chalupnikcase they were appended by the application. 646*7273821fSKamil Chalupnik 647*7273821fSKamil ChalupnikThe case when one CB belongs to TB and is being enqueued individually to BBDEV, 648*7273821fSKamil Chalupnikthis case is considered as a special case of partial TB where its number of CBs 649*7273821fSKamil Chalupnikis 1. Therefore, it requires to get processed in TB-mode. 650*7273821fSKamil Chalupnik 651*7273821fSKamil ChalupnikThe output mbuf data structure is expected to be allocated by the application 652*7273821fSKamil Chalupnikwith enough room for the output data. 653*7273821fSKamil Chalupnik 6544935e1e9SAmr Mokhtar 6554935e1e9SAmr MokhtarSample code 6564935e1e9SAmr Mokhtar----------- 6574935e1e9SAmr Mokhtar 6584935e1e9SAmr MokhtarThe baseband device sample application gives an introduction on how to use the 6594935e1e9SAmr Mokhtarbbdev framework, by giving a sample code performing a loop-back operation with a 6604935e1e9SAmr Mokhtarbaseband processor capable of transceiving data packets. 6614935e1e9SAmr Mokhtar 6624935e1e9SAmr MokhtarThe following sample C-like pseudo-code shows the basic steps to encode several 6634935e1e9SAmr Mokhtarbuffers using (**sw_trubo**) bbdev PMD. 6644935e1e9SAmr Mokhtar 6654935e1e9SAmr Mokhtar.. code-block:: c 6664935e1e9SAmr Mokhtar 6674935e1e9SAmr Mokhtar /* EAL Init */ 6684935e1e9SAmr Mokhtar ret = rte_eal_init(argc, argv); 6694935e1e9SAmr Mokhtar if (ret < 0) 6704935e1e9SAmr Mokhtar rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n"); 6714935e1e9SAmr Mokhtar 6724935e1e9SAmr Mokhtar /* Get number of available bbdev devices */ 6734935e1e9SAmr Mokhtar nb_bbdevs = rte_bbdev_count(); 6744935e1e9SAmr Mokhtar if (nb_bbdevs == 0) 6754935e1e9SAmr Mokhtar rte_exit(EXIT_FAILURE, "No bbdevs detected!\n"); 6764935e1e9SAmr Mokhtar 6774935e1e9SAmr Mokhtar /* Create bbdev op pools */ 6784935e1e9SAmr Mokhtar bbdev_op_pool[RTE_BBDEV_OP_TURBO_ENC] = 6794935e1e9SAmr Mokhtar rte_bbdev_op_pool_create("bbdev_op_pool_enc", 6804935e1e9SAmr Mokhtar RTE_BBDEV_OP_TURBO_ENC, NB_MBUF, 128, rte_socket_id()); 6814935e1e9SAmr Mokhtar 6824935e1e9SAmr Mokhtar /* Get information for this device */ 6834935e1e9SAmr Mokhtar rte_bbdev_info_get(dev_id, &info); 6844935e1e9SAmr Mokhtar 6854935e1e9SAmr Mokhtar /* Setup BBDEV device queues */ 6864935e1e9SAmr Mokhtar ret = rte_bbdev_setup_queues(dev_id, qs_nb, info.socket_id); 6874935e1e9SAmr Mokhtar if (ret < 0) 6884935e1e9SAmr Mokhtar rte_exit(EXIT_FAILURE, 6894935e1e9SAmr Mokhtar "ERROR(%d): BBDEV %u not configured properly\n", 6904935e1e9SAmr Mokhtar ret, dev_id); 6914935e1e9SAmr Mokhtar 6924935e1e9SAmr Mokhtar /* setup device queues */ 6934935e1e9SAmr Mokhtar qconf.socket = info.socket_id; 6944935e1e9SAmr Mokhtar qconf.queue_size = info.drv.queue_size_lim; 6954935e1e9SAmr Mokhtar qconf.op_type = RTE_BBDEV_OP_TURBO_ENC; 6964935e1e9SAmr Mokhtar 6974935e1e9SAmr Mokhtar for (q_id = 0; q_id < qs_nb; q_id++) { 6984935e1e9SAmr Mokhtar /* Configure all queues belonging to this bbdev device */ 6994935e1e9SAmr Mokhtar ret = rte_bbdev_queue_configure(dev_id, q_id, &qconf); 7004935e1e9SAmr Mokhtar if (ret < 0) 7014935e1e9SAmr Mokhtar rte_exit(EXIT_FAILURE, 7024935e1e9SAmr Mokhtar "ERROR(%d): BBDEV %u queue %u not configured properly\n", 7034935e1e9SAmr Mokhtar ret, dev_id, q_id); 7044935e1e9SAmr Mokhtar } 7054935e1e9SAmr Mokhtar 7064935e1e9SAmr Mokhtar /* Start bbdev device */ 7074935e1e9SAmr Mokhtar ret = rte_bbdev_start(dev_id); 7084935e1e9SAmr Mokhtar 7094935e1e9SAmr Mokhtar /* Create the mbuf mempool for pkts */ 7104935e1e9SAmr Mokhtar mbuf_pool = rte_pktmbuf_pool_create("bbdev_mbuf_pool", 7114935e1e9SAmr Mokhtar NB_MBUF, MEMPOOL_CACHE_SIZE, 0, 7124935e1e9SAmr Mokhtar RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id()); 7134935e1e9SAmr Mokhtar if (mbuf_pool == NULL) 7144935e1e9SAmr Mokhtar rte_exit(EXIT_FAILURE, 7154935e1e9SAmr Mokhtar "Unable to create '%s' pool\n", pool_name); 7164935e1e9SAmr Mokhtar 7174935e1e9SAmr Mokhtar while (!global_exit_flag) { 7184935e1e9SAmr Mokhtar 7194935e1e9SAmr Mokhtar /* Allocate burst of op structures in preparation for enqueue */ 7204935e1e9SAmr Mokhtar if (rte_bbdev_enc_op_alloc_bulk(bbdev_op_pool[RTE_BBDEV_OP_TURBO_ENC], 7214935e1e9SAmr Mokhtar ops_burst, op_num) != 0) 7224935e1e9SAmr Mokhtar continue; 7234935e1e9SAmr Mokhtar 7244935e1e9SAmr Mokhtar /* Allocate input mbuf pkts */ 7254935e1e9SAmr Mokhtar ret = rte_pktmbuf_alloc_bulk(mbuf_pool, input_pkts_burst, MAX_PKT_BURST); 7264935e1e9SAmr Mokhtar if (ret < 0) 7274935e1e9SAmr Mokhtar continue; 7284935e1e9SAmr Mokhtar 7294935e1e9SAmr Mokhtar /* Allocate output mbuf pkts */ 7304935e1e9SAmr Mokhtar ret = rte_pktmbuf_alloc_bulk(mbuf_pool, output_pkts_burst, MAX_PKT_BURST); 7314935e1e9SAmr Mokhtar if (ret < 0) 7324935e1e9SAmr Mokhtar continue; 7334935e1e9SAmr Mokhtar 7344935e1e9SAmr Mokhtar for (j = 0; j < op_num; j++) { 7354935e1e9SAmr Mokhtar /* Append the size of the ethernet header */ 7364935e1e9SAmr Mokhtar rte_pktmbuf_append(input_pkts_burst[j], 7374935e1e9SAmr Mokhtar sizeof(struct ether_hdr)); 7384935e1e9SAmr Mokhtar 7394935e1e9SAmr Mokhtar /* set op */ 7404935e1e9SAmr Mokhtar 7414935e1e9SAmr Mokhtar ops_burst[j]->turbo_enc.input.offset = 7424935e1e9SAmr Mokhtar sizeof(struct ether_hdr); 7434935e1e9SAmr Mokhtar 7444935e1e9SAmr Mokhtar ops_burst[j]->turbo_enc->input.length = 7454935e1e9SAmr Mokhtar rte_pktmbuf_pkt_len(bbdev_pkts[j]); 7464935e1e9SAmr Mokhtar 7474935e1e9SAmr Mokhtar ops_burst[j]->turbo_enc->input.data = 7484935e1e9SAmr Mokhtar input_pkts_burst[j]; 7494935e1e9SAmr Mokhtar 7504935e1e9SAmr Mokhtar ops_burst[j]->turbo_enc->output.offset = 7514935e1e9SAmr Mokhtar sizeof(struct ether_hdr); 7524935e1e9SAmr Mokhtar 7534935e1e9SAmr Mokhtar ops_burst[j]->turbo_enc->output.data = 7544935e1e9SAmr Mokhtar output_pkts_burst[j]; 7554935e1e9SAmr Mokhtar } 7564935e1e9SAmr Mokhtar 7574935e1e9SAmr Mokhtar /* Enqueue packets on BBDEV device */ 7584935e1e9SAmr Mokhtar op_num = rte_bbdev_enqueue_enc_ops(qconf->bbdev_id, 7594935e1e9SAmr Mokhtar qconf->bbdev_qs[q], ops_burst, 7604935e1e9SAmr Mokhtar MAX_PKT_BURST); 7614935e1e9SAmr Mokhtar 7624935e1e9SAmr Mokhtar /* Dequeue packets from BBDEV device*/ 7634935e1e9SAmr Mokhtar op_num = rte_bbdev_dequeue_enc_ops(qconf->bbdev_id, 7644935e1e9SAmr Mokhtar qconf->bbdev_qs[q], ops_burst, 7654935e1e9SAmr Mokhtar MAX_PKT_BURST); 7664935e1e9SAmr Mokhtar } 7674935e1e9SAmr Mokhtar 7684935e1e9SAmr Mokhtar 7694935e1e9SAmr MokhtarBBDEV Device API 7704935e1e9SAmr Mokhtar~~~~~~~~~~~~~~~~ 7714935e1e9SAmr Mokhtar 7724935e1e9SAmr MokhtarThe bbdev Library API is described in the *DPDK API Reference* document. 773