1*4935e1e9SAmr Mokhtar.. SPDX-License-Identifier: BSD-3-Clause 2*4935e1e9SAmr Mokhtar Copyright(c) 2017 Intel Corporation 3*4935e1e9SAmr Mokhtar 4*4935e1e9SAmr MokhtarWireless Baseband Device Library 5*4935e1e9SAmr Mokhtar================================ 6*4935e1e9SAmr Mokhtar 7*4935e1e9SAmr MokhtarThe Wireless Baseband library provides a common programming framework that 8*4935e1e9SAmr Mokhtarabstracts HW accelerators based on FPGA and/or Fixed Function Accelerators that 9*4935e1e9SAmr Mokhtarassist with 3gpp Physical Layer processing. Furthermore, it decouples the 10*4935e1e9SAmr Mokhtarapplication from the compute-intensive wireless functions by abstracting their 11*4935e1e9SAmr Mokhtaroptimized libraries to appear as virtual bbdev devices. 12*4935e1e9SAmr Mokhtar 13*4935e1e9SAmr MokhtarThe functional scope of the BBDEV library are those functions in relation to 14*4935e1e9SAmr Mokhtarthe 3gpp Layer 1 signal processing (channel coding, modulation, ...). 15*4935e1e9SAmr Mokhtar 16*4935e1e9SAmr MokhtarThe framework currently only supports Turbo Code FEC function. 17*4935e1e9SAmr Mokhtar 18*4935e1e9SAmr Mokhtar 19*4935e1e9SAmr MokhtarDesign Principles 20*4935e1e9SAmr Mokhtar----------------- 21*4935e1e9SAmr Mokhtar 22*4935e1e9SAmr MokhtarThe Wireless Baseband library follows the same ideology of DPDK's Ethernet 23*4935e1e9SAmr MokhtarDevice and Crypto Device frameworks. Wireless Baseband provides a generic 24*4935e1e9SAmr Mokhtaracceleration abstraction framework which supports both physical (hardware) and 25*4935e1e9SAmr Mokhtarvirtual (software) wireless acceleration functions. 26*4935e1e9SAmr Mokhtar 27*4935e1e9SAmr MokhtarDevice Management 28*4935e1e9SAmr Mokhtar----------------- 29*4935e1e9SAmr Mokhtar 30*4935e1e9SAmr MokhtarDevice Creation 31*4935e1e9SAmr Mokhtar~~~~~~~~~~~~~~~ 32*4935e1e9SAmr Mokhtar 33*4935e1e9SAmr MokhtarPhysical bbdev devices are discovered during the PCI probe/enumeration of the 34*4935e1e9SAmr MokhtarEAL function which is executed at DPDK initialization, based on 35*4935e1e9SAmr Mokhtartheir PCI device identifier, each unique PCI BDF (bus/bridge, device, 36*4935e1e9SAmr Mokhtarfunction). 37*4935e1e9SAmr Mokhtar 38*4935e1e9SAmr MokhtarVirtual devices can be created by two mechanisms, either using the EAL command 39*4935e1e9SAmr Mokhtarline options or from within the application using an EAL API directly. 40*4935e1e9SAmr Mokhtar 41*4935e1e9SAmr MokhtarFrom the command line using the --vdev EAL option 42*4935e1e9SAmr Mokhtar 43*4935e1e9SAmr Mokhtar.. code-block:: console 44*4935e1e9SAmr Mokhtar 45*4935e1e9SAmr Mokhtar --vdev 'turbo_sw,max_nb_queues=8,socket_id=0' 46*4935e1e9SAmr Mokhtar 47*4935e1e9SAmr MokhtarOur using the rte_vdev_init API within the application code. 48*4935e1e9SAmr Mokhtar 49*4935e1e9SAmr Mokhtar.. code-block:: c 50*4935e1e9SAmr Mokhtar 51*4935e1e9SAmr Mokhtar rte_vdev_init("turbo_sw", "max_nb_queues=2,socket_id=0") 52*4935e1e9SAmr Mokhtar 53*4935e1e9SAmr MokhtarAll virtual bbdev devices support the following initialization parameters: 54*4935e1e9SAmr Mokhtar 55*4935e1e9SAmr Mokhtar- ``max_nb_queues`` - maximum number of queues supported by the device. 56*4935e1e9SAmr Mokhtar 57*4935e1e9SAmr Mokhtar- ``socket_id`` - socket on which to allocate the device resources on. 58*4935e1e9SAmr Mokhtar 59*4935e1e9SAmr Mokhtar 60*4935e1e9SAmr MokhtarDevice Identification 61*4935e1e9SAmr Mokhtar~~~~~~~~~~~~~~~~~~~~~ 62*4935e1e9SAmr Mokhtar 63*4935e1e9SAmr MokhtarEach device, whether virtual or physical is uniquely designated by two 64*4935e1e9SAmr Mokhtaridentifiers: 65*4935e1e9SAmr Mokhtar 66*4935e1e9SAmr Mokhtar- A unique device index used to designate the bbdev device in all functions 67*4935e1e9SAmr Mokhtar exported by the bbdev API. 68*4935e1e9SAmr Mokhtar 69*4935e1e9SAmr Mokhtar- A device name used to designate the bbdev device in console messages, for 70*4935e1e9SAmr Mokhtar administration or debugging purposes. For ease of use, the port name includes 71*4935e1e9SAmr Mokhtar the port index. 72*4935e1e9SAmr Mokhtar 73*4935e1e9SAmr Mokhtar 74*4935e1e9SAmr MokhtarDevice Configuration 75*4935e1e9SAmr Mokhtar~~~~~~~~~~~~~~~~~~~~ 76*4935e1e9SAmr Mokhtar 77*4935e1e9SAmr MokhtarFrom the application point of view, each instance of a bbdev device consists of 78*4935e1e9SAmr Mokhtarone or more queues identified by queue IDs. While different devices may have 79*4935e1e9SAmr Mokhtardifferent capabilities (e.g. support different operation types), all queues on 80*4935e1e9SAmr Mokhtara device support identical configuration possibilities. A queue is configured 81*4935e1e9SAmr Mokhtarfor only one type of operation and is configured at initializations time. 82*4935e1e9SAmr MokhtarWhen an operation is enqueued to a specific queue ID, the result is dequeued 83*4935e1e9SAmr Mokhtarfrom the same queue ID. 84*4935e1e9SAmr Mokhtar 85*4935e1e9SAmr MokhtarConfiguration of a device has two different levels: configuration that applies 86*4935e1e9SAmr Mokhtarto the whole device, and configuration that applies to a single queue. 87*4935e1e9SAmr Mokhtar 88*4935e1e9SAmr MokhtarDevice configuration is applied with 89*4935e1e9SAmr Mokhtar``rte_bbdev_setup_queues(dev_id,num_queues,socket_id)`` 90*4935e1e9SAmr Mokhtarand queue configuration is applied with 91*4935e1e9SAmr Mokhtar``rte_bbdev_queue_configure(dev_id,queue_id,conf)``. Note that, although all 92*4935e1e9SAmr Mokhtarqueues on a device support same capabilities, they can be configured differently 93*4935e1e9SAmr Mokhtarand will then behave differently. 94*4935e1e9SAmr MokhtarDevices supporting interrupts can enable them by using 95*4935e1e9SAmr Mokhtar``rte_bbdev_intr_enable(dev_id)``. 96*4935e1e9SAmr Mokhtar 97*4935e1e9SAmr MokhtarThe configuration of each bbdev device includes the following operations: 98*4935e1e9SAmr Mokhtar 99*4935e1e9SAmr Mokhtar- Allocation of resources, including hardware resources if a physical device. 100*4935e1e9SAmr Mokhtar- Resetting the device into a well-known default state. 101*4935e1e9SAmr Mokhtar- Initialization of statistics counters. 102*4935e1e9SAmr Mokhtar 103*4935e1e9SAmr MokhtarThe ``rte_bbdev_setup_queues`` API is used to setup queues for a bbdev device. 104*4935e1e9SAmr Mokhtar 105*4935e1e9SAmr Mokhtar.. code-block:: c 106*4935e1e9SAmr Mokhtar 107*4935e1e9SAmr Mokhtar int rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, 108*4935e1e9SAmr Mokhtar int socket_id); 109*4935e1e9SAmr Mokhtar 110*4935e1e9SAmr Mokhtar- ``num_queues`` argument identifies the total number of queues to setup for 111*4935e1e9SAmr Mokhtar this device. 112*4935e1e9SAmr Mokhtar 113*4935e1e9SAmr Mokhtar- ``socket_id`` specifies which socket will be used to allocate the memory. 114*4935e1e9SAmr Mokhtar 115*4935e1e9SAmr Mokhtar 116*4935e1e9SAmr MokhtarThe ``rte_bbdev_intr_enable`` API is used to enable interrupts for a bbdev 117*4935e1e9SAmr Mokhtardevice, if supported by the driver. Should be called before starting the device. 118*4935e1e9SAmr Mokhtar 119*4935e1e9SAmr Mokhtar.. code-block:: c 120*4935e1e9SAmr Mokhtar 121*4935e1e9SAmr Mokhtar int rte_bbdev_intr_enable(uint16_t dev_id); 122*4935e1e9SAmr Mokhtar 123*4935e1e9SAmr Mokhtar 124*4935e1e9SAmr MokhtarQueues Configuration 125*4935e1e9SAmr Mokhtar~~~~~~~~~~~~~~~~~~~~ 126*4935e1e9SAmr Mokhtar 127*4935e1e9SAmr MokhtarEach bbdev devices queue is individually configured through the 128*4935e1e9SAmr Mokhtar``rte_bbdev_queue_configure()`` API. 129*4935e1e9SAmr MokhtarEach queue resources may be allocated on a specified socket. 130*4935e1e9SAmr Mokhtar 131*4935e1e9SAmr Mokhtar.. code-block:: c 132*4935e1e9SAmr Mokhtar 133*4935e1e9SAmr Mokhtar struct rte_bbdev_queue_conf { 134*4935e1e9SAmr Mokhtar int socket; 135*4935e1e9SAmr Mokhtar uint32_t queue_size; 136*4935e1e9SAmr Mokhtar uint8_t priority; 137*4935e1e9SAmr Mokhtar bool deferred_start; 138*4935e1e9SAmr Mokhtar enum rte_bbdev_op_type op_type; 139*4935e1e9SAmr Mokhtar }; 140*4935e1e9SAmr Mokhtar 141*4935e1e9SAmr MokhtarDevice & Queues Management 142*4935e1e9SAmr Mokhtar~~~~~~~~~~~~~~~~~~~~~~~~~~ 143*4935e1e9SAmr Mokhtar 144*4935e1e9SAmr MokhtarAfter initialization, devices are in a stopped state, so must be started by the 145*4935e1e9SAmr Mokhtarapplication. If an application is finished using a device it can close the 146*4935e1e9SAmr Mokhtardevice. Once closed, it cannot be restarted. 147*4935e1e9SAmr Mokhtar 148*4935e1e9SAmr Mokhtar.. code-block:: c 149*4935e1e9SAmr Mokhtar 150*4935e1e9SAmr Mokhtar int rte_bbdev_start(uint16_t dev_id) 151*4935e1e9SAmr Mokhtar int rte_bbdev_stop(uint16_t dev_id) 152*4935e1e9SAmr Mokhtar int rte_bbdev_close(uint16_t dev_id) 153*4935e1e9SAmr Mokhtar int rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id) 154*4935e1e9SAmr Mokhtar int rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id) 155*4935e1e9SAmr Mokhtar 156*4935e1e9SAmr Mokhtar 157*4935e1e9SAmr MokhtarBy default, all queues are started when the device is started, but they can be 158*4935e1e9SAmr Mokhtarstopped individually. 159*4935e1e9SAmr Mokhtar 160*4935e1e9SAmr Mokhtar.. code-block:: c 161*4935e1e9SAmr Mokhtar 162*4935e1e9SAmr Mokhtar int rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id) 163*4935e1e9SAmr Mokhtar int rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id) 164*4935e1e9SAmr Mokhtar 165*4935e1e9SAmr Mokhtar 166*4935e1e9SAmr MokhtarLogical Cores, Memory and Queues Relationships 167*4935e1e9SAmr Mokhtar~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 168*4935e1e9SAmr Mokhtar 169*4935e1e9SAmr MokhtarThe bbdev device Library as the Poll Mode Driver library support NUMA for when 170*4935e1e9SAmr Mokhtara processor’s logical cores and interfaces utilize its local memory. Therefore 171*4935e1e9SAmr Mokhtarbaseband operations, the mbuf being operated on should be allocated from memory 172*4935e1e9SAmr Mokhtarpools created in the local memory. The buffers should, if possible, remain on 173*4935e1e9SAmr Mokhtarthe local processor to obtain the best performance results and buffer 174*4935e1e9SAmr Mokhtardescriptors should be populated with mbufs allocated from a mempool allocated 175*4935e1e9SAmr Mokhtarfrom local memory. 176*4935e1e9SAmr Mokhtar 177*4935e1e9SAmr MokhtarThe run-to-completion model also performs better, especially in the case of 178*4935e1e9SAmr Mokhtarvirtual bbdev devices, if the baseband operation and data buffers are in local 179*4935e1e9SAmr Mokhtarmemory instead of a remote processor's memory. This is also true for the 180*4935e1e9SAmr Mokhtarpipe-line model provided all logical cores used are located on the same processor. 181*4935e1e9SAmr Mokhtar 182*4935e1e9SAmr MokhtarMultiple logical cores should never share the same queue for enqueuing 183*4935e1e9SAmr Mokhtaroperations or dequeuing operations on the same bbdev device since this would 184*4935e1e9SAmr Mokhtarrequire global locks and hinder performance. It is however possible to use a 185*4935e1e9SAmr Mokhtardifferent logical core to dequeue an operation on a queue pair from the logical 186*4935e1e9SAmr Mokhtarcore which it was enqueued on. This means that a baseband burst enqueue/dequeue 187*4935e1e9SAmr MokhtarAPIs are a logical place to transition from one logical core to another in a 188*4935e1e9SAmr Mokhtarpacket processing pipeline. 189*4935e1e9SAmr Mokhtar 190*4935e1e9SAmr Mokhtar 191*4935e1e9SAmr MokhtarDevice Operation Capabilities 192*4935e1e9SAmr Mokhtar----------------------------- 193*4935e1e9SAmr Mokhtar 194*4935e1e9SAmr MokhtarCapabilities (in terms of operations supported, max number of queues, etc.) 195*4935e1e9SAmr Mokhtaridentify what a bbdev is capable of performing that differs from one device to 196*4935e1e9SAmr Mokhtaranother. For the full scope of the bbdev capability see the definition of the 197*4935e1e9SAmr Mokhtarstructure in the *DPDK API Reference*. 198*4935e1e9SAmr Mokhtar 199*4935e1e9SAmr Mokhtar.. code-block:: c 200*4935e1e9SAmr Mokhtar 201*4935e1e9SAmr Mokhtar struct rte_bbdev_op_cap; 202*4935e1e9SAmr Mokhtar 203*4935e1e9SAmr MokhtarA device reports its capabilities when registering itself in the bbdev framework. 204*4935e1e9SAmr MokhtarWith the aid of this capabilities mechanism, an application can query devices to 205*4935e1e9SAmr Mokhtardiscover which operations within the 3gpp physical layer they are capable of 206*4935e1e9SAmr Mokhtarperforming. Below is an example of the capabilities for a PMD it supports in 207*4935e1e9SAmr Mokhtarrelation to Turbo Encoding and Decoding operations. 208*4935e1e9SAmr Mokhtar 209*4935e1e9SAmr Mokhtar.. code-block:: c 210*4935e1e9SAmr Mokhtar 211*4935e1e9SAmr Mokhtar static const struct rte_bbdev_op_cap bbdev_capabilities[] = { 212*4935e1e9SAmr Mokhtar { 213*4935e1e9SAmr Mokhtar .type = RTE_BBDEV_OP_TURBO_DEC, 214*4935e1e9SAmr Mokhtar .cap.turbo_dec = { 215*4935e1e9SAmr Mokhtar .capability_flags = 216*4935e1e9SAmr Mokhtar RTE_BBDEV_TURBO_SUBBLOCK_DEINTERLEAVE | 217*4935e1e9SAmr Mokhtar RTE_BBDEV_TURBO_POS_LLR_1_BIT_IN | 218*4935e1e9SAmr Mokhtar RTE_BBDEV_TURBO_NEG_LLR_1_BIT_IN | 219*4935e1e9SAmr Mokhtar RTE_BBDEV_TURBO_CRC_TYPE_24B, 220*4935e1e9SAmr Mokhtar .num_buffers_src = RTE_BBDEV_MAX_CODE_BLOCKS, 221*4935e1e9SAmr Mokhtar .num_buffers_hard_out = 222*4935e1e9SAmr Mokhtar RTE_BBDEV_MAX_CODE_BLOCKS, 223*4935e1e9SAmr Mokhtar .num_buffers_soft_out = 0, 224*4935e1e9SAmr Mokhtar } 225*4935e1e9SAmr Mokhtar }, 226*4935e1e9SAmr Mokhtar { 227*4935e1e9SAmr Mokhtar .type = RTE_BBDEV_OP_TURBO_ENC, 228*4935e1e9SAmr Mokhtar .cap.turbo_enc = { 229*4935e1e9SAmr Mokhtar .capability_flags = 230*4935e1e9SAmr Mokhtar RTE_BBDEV_TURBO_CRC_24B_ATTACH | 231*4935e1e9SAmr Mokhtar RTE_BBDEV_TURBO_RATE_MATCH | 232*4935e1e9SAmr Mokhtar RTE_BBDEV_TURBO_RV_INDEX_BYPASS, 233*4935e1e9SAmr Mokhtar .num_buffers_src = RTE_BBDEV_MAX_CODE_BLOCKS, 234*4935e1e9SAmr Mokhtar .num_buffers_dst = RTE_BBDEV_MAX_CODE_BLOCKS, 235*4935e1e9SAmr Mokhtar } 236*4935e1e9SAmr Mokhtar }, 237*4935e1e9SAmr Mokhtar RTE_BBDEV_END_OF_CAPABILITIES_LIST() 238*4935e1e9SAmr Mokhtar }; 239*4935e1e9SAmr Mokhtar 240*4935e1e9SAmr MokhtarCapabilities Discovery 241*4935e1e9SAmr Mokhtar~~~~~~~~~~~~~~~~~~~~~~ 242*4935e1e9SAmr Mokhtar 243*4935e1e9SAmr MokhtarDiscovering the features and capabilities of a bbdev device poll mode driver 244*4935e1e9SAmr Mokhtaris achieved through the ``rte_bbdev_info_get()`` function. 245*4935e1e9SAmr Mokhtar 246*4935e1e9SAmr Mokhtar.. code-block:: c 247*4935e1e9SAmr Mokhtar 248*4935e1e9SAmr Mokhtar int rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info) 249*4935e1e9SAmr Mokhtar 250*4935e1e9SAmr MokhtarThis allows the user to query a specific bbdev PMD and get all the device 251*4935e1e9SAmr Mokhtarcapabilities. The ``rte_bbdev_info`` structure provides two levels of 252*4935e1e9SAmr Mokhtarinformation: 253*4935e1e9SAmr Mokhtar 254*4935e1e9SAmr Mokhtar- Device relevant information, like: name and related rte_bus. 255*4935e1e9SAmr Mokhtar 256*4935e1e9SAmr Mokhtar- Driver specific information, as defined by the ``struct rte_bbdev_driver_info`` 257*4935e1e9SAmr Mokhtar structure, this is where capabilities reside along with other specifics like: 258*4935e1e9SAmr Mokhtar maximum queue sizes and priority level. 259*4935e1e9SAmr Mokhtar 260*4935e1e9SAmr Mokhtar.. code-block:: c 261*4935e1e9SAmr Mokhtar 262*4935e1e9SAmr Mokhtar struct rte_bbdev_info { 263*4935e1e9SAmr Mokhtar int socket_id; 264*4935e1e9SAmr Mokhtar const char *dev_name; 265*4935e1e9SAmr Mokhtar const struct rte_bus *bus; 266*4935e1e9SAmr Mokhtar uint16_t num_queues; 267*4935e1e9SAmr Mokhtar bool started; 268*4935e1e9SAmr Mokhtar struct rte_bbdev_driver_info drv; 269*4935e1e9SAmr Mokhtar }; 270*4935e1e9SAmr Mokhtar 271*4935e1e9SAmr MokhtarOperation Processing 272*4935e1e9SAmr Mokhtar-------------------- 273*4935e1e9SAmr Mokhtar 274*4935e1e9SAmr MokhtarScheduling of baseband operations on DPDK's application data path is 275*4935e1e9SAmr Mokhtarperformed using a burst oriented asynchronous API set. A queue on a bbdev 276*4935e1e9SAmr Mokhtardevice accepts a burst of baseband operations using enqueue burst API. On physical 277*4935e1e9SAmr Mokhtarbbdev devices the enqueue burst API will place the operations to be processed 278*4935e1e9SAmr Mokhtaron the device's hardware input queue, for virtual devices the processing of the 279*4935e1e9SAmr Mokhtarbaseband operations is usually completed during the enqueue call to the bbdev 280*4935e1e9SAmr Mokhtardevice. The dequeue burst API will retrieve any processed operations available 281*4935e1e9SAmr Mokhtarfrom the queue on the bbdev device, from physical devices this is usually 282*4935e1e9SAmr Mokhtardirectly from the device's processed queue, and for virtual device's from a 283*4935e1e9SAmr Mokhtar``rte_ring`` where processed operations are place after being processed on the 284*4935e1e9SAmr Mokhtarenqueue call. 285*4935e1e9SAmr Mokhtar 286*4935e1e9SAmr Mokhtar 287*4935e1e9SAmr MokhtarEnqueue / Dequeue Burst APIs 288*4935e1e9SAmr Mokhtar~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 289*4935e1e9SAmr Mokhtar 290*4935e1e9SAmr MokhtarThe burst enqueue API uses a bbdev device identifier and a queue 291*4935e1e9SAmr Mokhtaridentifier to specify the bbdev device queue to schedule the processing on. 292*4935e1e9SAmr MokhtarThe ``num_ops`` parameter is the number of operations to process which are 293*4935e1e9SAmr Mokhtarsupplied in the ``ops`` array of ``rte_bbdev_*_op`` structures. 294*4935e1e9SAmr MokhtarThe enqueue function returns the number of operations it actually enqueued for 295*4935e1e9SAmr Mokhtarprocessing, a return value equal to ``num_ops`` means that all packets have been 296*4935e1e9SAmr Mokhtarenqueued. 297*4935e1e9SAmr Mokhtar 298*4935e1e9SAmr Mokhtar.. code-block:: c 299*4935e1e9SAmr Mokhtar 300*4935e1e9SAmr Mokhtar uint16_t rte_bbdev_enqueue_enc_ops(uint16_t dev_id, uint16_t queue_id, 301*4935e1e9SAmr Mokhtar struct rte_bbdev_enc_op **ops, uint16_t num_ops) 302*4935e1e9SAmr Mokhtar 303*4935e1e9SAmr Mokhtar uint16_t rte_bbdev_enqueue_dec_ops(uint16_t dev_id, uint16_t queue_id, 304*4935e1e9SAmr Mokhtar struct rte_bbdev_dec_op **ops, uint16_t num_ops) 305*4935e1e9SAmr Mokhtar 306*4935e1e9SAmr MokhtarThe dequeue API uses the same format as the enqueue API of processed but 307*4935e1e9SAmr Mokhtarthe ``num_ops`` and ``ops`` parameters are now used to specify the max processed 308*4935e1e9SAmr Mokhtaroperations the user wishes to retrieve and the location in which to store them. 309*4935e1e9SAmr MokhtarThe API call returns the actual number of processed operations returned, this 310*4935e1e9SAmr Mokhtarcan never be larger than ``num_ops``. 311*4935e1e9SAmr Mokhtar 312*4935e1e9SAmr Mokhtar.. code-block:: c 313*4935e1e9SAmr Mokhtar 314*4935e1e9SAmr Mokhtar uint16_t rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id, 315*4935e1e9SAmr Mokhtar struct rte_bbdev_enc_op **ops, uint16_t num_ops) 316*4935e1e9SAmr Mokhtar 317*4935e1e9SAmr Mokhtar uint16_t rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id, 318*4935e1e9SAmr Mokhtar struct rte_bbdev_dec_op **ops, uint16_t num_ops) 319*4935e1e9SAmr Mokhtar 320*4935e1e9SAmr MokhtarOperation Representation 321*4935e1e9SAmr Mokhtar~~~~~~~~~~~~~~~~~~~~~~~~ 322*4935e1e9SAmr Mokhtar 323*4935e1e9SAmr MokhtarAn encode bbdev operation is represented by ``rte_bbdev_enc_op`` structure, 324*4935e1e9SAmr Mokhtarand by ``rte_bbdev_dec_op`` for decode. These structures act as metadata 325*4935e1e9SAmr Mokhtarcontainers for all necessary information required for the bbdev operation to be 326*4935e1e9SAmr Mokhtarprocessed on a particular bbdev device poll mode driver. 327*4935e1e9SAmr Mokhtar 328*4935e1e9SAmr Mokhtar.. code-block:: c 329*4935e1e9SAmr Mokhtar 330*4935e1e9SAmr Mokhtar struct rte_bbdev_enc_op { 331*4935e1e9SAmr Mokhtar int status; 332*4935e1e9SAmr Mokhtar struct rte_mempool *mempool; 333*4935e1e9SAmr Mokhtar void *opaque_data; 334*4935e1e9SAmr Mokhtar struct rte_bbdev_op_turbo_enc turbo_enc; 335*4935e1e9SAmr Mokhtar }; 336*4935e1e9SAmr Mokhtar 337*4935e1e9SAmr Mokhtar struct rte_bbdev_dec_op { 338*4935e1e9SAmr Mokhtar int status; 339*4935e1e9SAmr Mokhtar struct rte_mempool *mempool; 340*4935e1e9SAmr Mokhtar void *opaque_data; 341*4935e1e9SAmr Mokhtar struct rte_bbdev_op_turbo_dec turbo_dec; 342*4935e1e9SAmr Mokhtar }; 343*4935e1e9SAmr Mokhtar 344*4935e1e9SAmr MokhtarThe operation structure by itself defines the operation type. It includes an 345*4935e1e9SAmr Mokhtaroperation status, a reference to the operation specific data, which can vary in 346*4935e1e9SAmr Mokhtarsize and content depending on the operation being provisioned. It also contains 347*4935e1e9SAmr Mokhtarthe source mempool for the operation, if it is allocated from a mempool. 348*4935e1e9SAmr Mokhtar 349*4935e1e9SAmr MokhtarIf bbdev operations are allocated from a bbdev operation mempool, see next 350*4935e1e9SAmr Mokhtarsection, there is also the ability to allocate private memory with the 351*4935e1e9SAmr Mokhtaroperation for applications purposes. 352*4935e1e9SAmr Mokhtar 353*4935e1e9SAmr MokhtarApplication software is responsible for specifying all the operation specific 354*4935e1e9SAmr Mokhtarfields in the ``rte_bbdev_*_op`` structure which are then used by the bbdev PMD 355*4935e1e9SAmr Mokhtarto process the requested operation. 356*4935e1e9SAmr Mokhtar 357*4935e1e9SAmr Mokhtar 358*4935e1e9SAmr MokhtarOperation Management and Allocation 359*4935e1e9SAmr Mokhtar~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 360*4935e1e9SAmr Mokhtar 361*4935e1e9SAmr MokhtarThe bbdev library provides an API set for managing bbdev operations which 362*4935e1e9SAmr Mokhtarutilize the Mempool Library to allocate operation buffers. Therefore, it ensures 363*4935e1e9SAmr Mokhtarthat the bbdev operation is interleaved optimally across the channels and 364*4935e1e9SAmr Mokhtarranks for optimal processing. 365*4935e1e9SAmr Mokhtar 366*4935e1e9SAmr Mokhtar.. code-block:: c 367*4935e1e9SAmr Mokhtar 368*4935e1e9SAmr Mokhtar struct rte_mempool * 369*4935e1e9SAmr Mokhtar rte_bbdev_op_pool_create(const char *name, enum rte_bbdev_op_type type, 370*4935e1e9SAmr Mokhtar unsigned int num_elements, unsigned int cache_size, 371*4935e1e9SAmr Mokhtar int socket_id) 372*4935e1e9SAmr Mokhtar 373*4935e1e9SAmr Mokhtar``rte_bbdev_*_op_alloc_bulk()`` and ``rte_bbdev_*_op_free_bulk()`` are used to 374*4935e1e9SAmr Mokhtarallocate bbdev operations of a specific type from a given bbdev operation mempool. 375*4935e1e9SAmr Mokhtar 376*4935e1e9SAmr Mokhtar.. code-block:: c 377*4935e1e9SAmr Mokhtar 378*4935e1e9SAmr Mokhtar int rte_bbdev_enc_op_alloc_bulk(struct rte_mempool *mempool, 379*4935e1e9SAmr Mokhtar struct rte_bbdev_enc_op **ops, uint16_t num_ops) 380*4935e1e9SAmr Mokhtar 381*4935e1e9SAmr Mokhtar int rte_bbdev_dec_op_alloc_bulk(struct rte_mempool *mempool, 382*4935e1e9SAmr Mokhtar struct rte_bbdev_dec_op **ops, uint16_t num_ops) 383*4935e1e9SAmr Mokhtar 384*4935e1e9SAmr Mokhtar``rte_bbdev_*_op_free_bulk()`` is called by the application to return an 385*4935e1e9SAmr Mokhtaroperation to its allocating pool. 386*4935e1e9SAmr Mokhtar 387*4935e1e9SAmr Mokhtar.. code-block:: c 388*4935e1e9SAmr Mokhtar 389*4935e1e9SAmr Mokhtar void rte_bbdev_dec_op_free_bulk(struct rte_bbdev_dec_op **ops, 390*4935e1e9SAmr Mokhtar unsigned int num_ops) 391*4935e1e9SAmr Mokhtar void rte_bbdev_enc_op_free_bulk(struct rte_bbdev_enc_op **ops, 392*4935e1e9SAmr Mokhtar unsigned int num_ops) 393*4935e1e9SAmr Mokhtar 394*4935e1e9SAmr MokhtarBBDEV Operations 395*4935e1e9SAmr Mokhtar~~~~~~~~~~~~~~~~ 396*4935e1e9SAmr Mokhtar 397*4935e1e9SAmr MokhtarThe bbdev operation structure contains all the mutable data relating to 398*4935e1e9SAmr Mokhtarperforming Turbo code processing on a referenced mbuf data buffer. It is used 399*4935e1e9SAmr Mokhtarfor either encode or decode operations. 400*4935e1e9SAmr Mokhtar 401*4935e1e9SAmr MokhtarTurbo Encode operation accepts one input and one output. 402*4935e1e9SAmr Mokhtar 403*4935e1e9SAmr MokhtarTurbo Decode operation accepts one input and two outputs, called *hard-decision* 404*4935e1e9SAmr Mokhtarand *soft-decision* outputs. *Soft-decision* output is optional. 405*4935e1e9SAmr Mokhtar 406*4935e1e9SAmr MokhtarIt is expected that the application provides input and output ``mbuf`` pointers 407*4935e1e9SAmr Mokhtarallocated and ready to use. The baseband framework supports turbo coding on 408*4935e1e9SAmr MokhtarCode Blocks (CB) and Transport Blocks (TB). 409*4935e1e9SAmr Mokhtar 410*4935e1e9SAmr MokhtarFor the output buffer(s), the application needs only to provide an allocated and 411*4935e1e9SAmr Mokhtarfree mbuf (containing only one mbuf segment), so that bbdev can write the 412*4935e1e9SAmr Mokhtaroperation outcome. 413*4935e1e9SAmr Mokhtar 414*4935e1e9SAmr Mokhtar**Turbo Encode Op structure** 415*4935e1e9SAmr Mokhtar 416*4935e1e9SAmr Mokhtar.. code-block:: c 417*4935e1e9SAmr Mokhtar 418*4935e1e9SAmr Mokhtar struct rte_bbdev_op_turbo_enc { 419*4935e1e9SAmr Mokhtar struct rte_bbdev_op_data input; 420*4935e1e9SAmr Mokhtar struct rte_bbdev_op_data output; 421*4935e1e9SAmr Mokhtar 422*4935e1e9SAmr Mokhtar uint32_t op_flags; 423*4935e1e9SAmr Mokhtar uint8_t rv_index; 424*4935e1e9SAmr Mokhtar uint8_t code_block_mode; 425*4935e1e9SAmr Mokhtar union { 426*4935e1e9SAmr Mokhtar struct rte_bbdev_op_enc_cb_params cb_params; 427*4935e1e9SAmr Mokhtar struct rte_bbdev_op_enc_tb_params tb_params; 428*4935e1e9SAmr Mokhtar }; 429*4935e1e9SAmr Mokhtar }; 430*4935e1e9SAmr Mokhtar 431*4935e1e9SAmr Mokhtar 432*4935e1e9SAmr Mokhtar**Turbo Decode Op structure** 433*4935e1e9SAmr Mokhtar 434*4935e1e9SAmr Mokhtar.. code-block:: c 435*4935e1e9SAmr Mokhtar 436*4935e1e9SAmr Mokhtar struct rte_bbdev_op_turbo_dec { 437*4935e1e9SAmr Mokhtar struct rte_bbdev_op_data input; 438*4935e1e9SAmr Mokhtar struct rte_bbdev_op_data hard_output; 439*4935e1e9SAmr Mokhtar struct rte_bbdev_op_data soft_output; 440*4935e1e9SAmr Mokhtar 441*4935e1e9SAmr Mokhtar uint32_t op_flags; 442*4935e1e9SAmr Mokhtar uint8_t rv_index; 443*4935e1e9SAmr Mokhtar uint8_t iter_min:4; 444*4935e1e9SAmr Mokhtar uint8_t iter_max:4; 445*4935e1e9SAmr Mokhtar uint8_t iter_count; 446*4935e1e9SAmr Mokhtar uint8_t ext_scale; 447*4935e1e9SAmr Mokhtar uint8_t num_maps; 448*4935e1e9SAmr Mokhtar uint8_t code_block_mode; 449*4935e1e9SAmr Mokhtar union { 450*4935e1e9SAmr Mokhtar struct rte_bbdev_op_dec_cb_params cb_params; 451*4935e1e9SAmr Mokhtar struct rte_bbdev_op_dec_tb_params tb_params; 452*4935e1e9SAmr Mokhtar }; 453*4935e1e9SAmr Mokhtar }; 454*4935e1e9SAmr Mokhtar 455*4935e1e9SAmr MokhtarInput and output data buffers are identified by ``rte_bbdev_op_data`` structure. 456*4935e1e9SAmr MokhtarThis structure has three elements: 457*4935e1e9SAmr Mokhtar 458*4935e1e9SAmr Mokhtar- ``data`` - This is the mbuf reference 459*4935e1e9SAmr Mokhtar 460*4935e1e9SAmr Mokhtar- ``offset`` - The starting point for the Turbo input/output, in bytes, from the 461*4935e1e9SAmr Mokhtar start of the data in the data buffer. It must be smaller than data_len of the 462*4935e1e9SAmr Mokhtar mbuf's first segment 463*4935e1e9SAmr Mokhtar 464*4935e1e9SAmr Mokhtar- ``length`` - The length, in bytes, of the buffer on which the Turbo operation 465*4935e1e9SAmr Mokhtar will or has been computed. For the input, the length is set by the application. 466*4935e1e9SAmr Mokhtar For the output(s), the length is computed by the bbdev PMD driver. 467*4935e1e9SAmr Mokhtar 468*4935e1e9SAmr MokhtarSample code 469*4935e1e9SAmr Mokhtar----------- 470*4935e1e9SAmr Mokhtar 471*4935e1e9SAmr MokhtarThe baseband device sample application gives an introduction on how to use the 472*4935e1e9SAmr Mokhtarbbdev framework, by giving a sample code performing a loop-back operation with a 473*4935e1e9SAmr Mokhtarbaseband processor capable of transceiving data packets. 474*4935e1e9SAmr Mokhtar 475*4935e1e9SAmr MokhtarThe following sample C-like pseudo-code shows the basic steps to encode several 476*4935e1e9SAmr Mokhtarbuffers using (**sw_trubo**) bbdev PMD. 477*4935e1e9SAmr Mokhtar 478*4935e1e9SAmr Mokhtar.. code-block:: c 479*4935e1e9SAmr Mokhtar 480*4935e1e9SAmr Mokhtar /* EAL Init */ 481*4935e1e9SAmr Mokhtar ret = rte_eal_init(argc, argv); 482*4935e1e9SAmr Mokhtar if (ret < 0) 483*4935e1e9SAmr Mokhtar rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n"); 484*4935e1e9SAmr Mokhtar 485*4935e1e9SAmr Mokhtar /* Get number of available bbdev devices */ 486*4935e1e9SAmr Mokhtar nb_bbdevs = rte_bbdev_count(); 487*4935e1e9SAmr Mokhtar if (nb_bbdevs == 0) 488*4935e1e9SAmr Mokhtar rte_exit(EXIT_FAILURE, "No bbdevs detected!\n"); 489*4935e1e9SAmr Mokhtar 490*4935e1e9SAmr Mokhtar /* Create bbdev op pools */ 491*4935e1e9SAmr Mokhtar bbdev_op_pool[RTE_BBDEV_OP_TURBO_ENC] = 492*4935e1e9SAmr Mokhtar rte_bbdev_op_pool_create("bbdev_op_pool_enc", 493*4935e1e9SAmr Mokhtar RTE_BBDEV_OP_TURBO_ENC, NB_MBUF, 128, rte_socket_id()); 494*4935e1e9SAmr Mokhtar 495*4935e1e9SAmr Mokhtar /* Get information for this device */ 496*4935e1e9SAmr Mokhtar rte_bbdev_info_get(dev_id, &info); 497*4935e1e9SAmr Mokhtar 498*4935e1e9SAmr Mokhtar /* Setup BBDEV device queues */ 499*4935e1e9SAmr Mokhtar ret = rte_bbdev_setup_queues(dev_id, qs_nb, info.socket_id); 500*4935e1e9SAmr Mokhtar if (ret < 0) 501*4935e1e9SAmr Mokhtar rte_exit(EXIT_FAILURE, 502*4935e1e9SAmr Mokhtar "ERROR(%d): BBDEV %u not configured properly\n", 503*4935e1e9SAmr Mokhtar ret, dev_id); 504*4935e1e9SAmr Mokhtar 505*4935e1e9SAmr Mokhtar /* setup device queues */ 506*4935e1e9SAmr Mokhtar qconf.socket = info.socket_id; 507*4935e1e9SAmr Mokhtar qconf.queue_size = info.drv.queue_size_lim; 508*4935e1e9SAmr Mokhtar qconf.op_type = RTE_BBDEV_OP_TURBO_ENC; 509*4935e1e9SAmr Mokhtar 510*4935e1e9SAmr Mokhtar for (q_id = 0; q_id < qs_nb; q_id++) { 511*4935e1e9SAmr Mokhtar /* Configure all queues belonging to this bbdev device */ 512*4935e1e9SAmr Mokhtar ret = rte_bbdev_queue_configure(dev_id, q_id, &qconf); 513*4935e1e9SAmr Mokhtar if (ret < 0) 514*4935e1e9SAmr Mokhtar rte_exit(EXIT_FAILURE, 515*4935e1e9SAmr Mokhtar "ERROR(%d): BBDEV %u queue %u not configured properly\n", 516*4935e1e9SAmr Mokhtar ret, dev_id, q_id); 517*4935e1e9SAmr Mokhtar } 518*4935e1e9SAmr Mokhtar 519*4935e1e9SAmr Mokhtar /* Start bbdev device */ 520*4935e1e9SAmr Mokhtar ret = rte_bbdev_start(dev_id); 521*4935e1e9SAmr Mokhtar 522*4935e1e9SAmr Mokhtar /* Create the mbuf mempool for pkts */ 523*4935e1e9SAmr Mokhtar mbuf_pool = rte_pktmbuf_pool_create("bbdev_mbuf_pool", 524*4935e1e9SAmr Mokhtar NB_MBUF, MEMPOOL_CACHE_SIZE, 0, 525*4935e1e9SAmr Mokhtar RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id()); 526*4935e1e9SAmr Mokhtar if (mbuf_pool == NULL) 527*4935e1e9SAmr Mokhtar rte_exit(EXIT_FAILURE, 528*4935e1e9SAmr Mokhtar "Unable to create '%s' pool\n", pool_name); 529*4935e1e9SAmr Mokhtar 530*4935e1e9SAmr Mokhtar while (!global_exit_flag) { 531*4935e1e9SAmr Mokhtar 532*4935e1e9SAmr Mokhtar /* Allocate burst of op structures in preparation for enqueue */ 533*4935e1e9SAmr Mokhtar if (rte_bbdev_enc_op_alloc_bulk(bbdev_op_pool[RTE_BBDEV_OP_TURBO_ENC], 534*4935e1e9SAmr Mokhtar ops_burst, op_num) != 0) 535*4935e1e9SAmr Mokhtar continue; 536*4935e1e9SAmr Mokhtar 537*4935e1e9SAmr Mokhtar /* Allocate input mbuf pkts */ 538*4935e1e9SAmr Mokhtar ret = rte_pktmbuf_alloc_bulk(mbuf_pool, input_pkts_burst, MAX_PKT_BURST); 539*4935e1e9SAmr Mokhtar if (ret < 0) 540*4935e1e9SAmr Mokhtar continue; 541*4935e1e9SAmr Mokhtar 542*4935e1e9SAmr Mokhtar /* Allocate output mbuf pkts */ 543*4935e1e9SAmr Mokhtar ret = rte_pktmbuf_alloc_bulk(mbuf_pool, output_pkts_burst, MAX_PKT_BURST); 544*4935e1e9SAmr Mokhtar if (ret < 0) 545*4935e1e9SAmr Mokhtar continue; 546*4935e1e9SAmr Mokhtar 547*4935e1e9SAmr Mokhtar for (j = 0; j < op_num; j++) { 548*4935e1e9SAmr Mokhtar /* Append the size of the ethernet header */ 549*4935e1e9SAmr Mokhtar rte_pktmbuf_append(input_pkts_burst[j], 550*4935e1e9SAmr Mokhtar sizeof(struct ether_hdr)); 551*4935e1e9SAmr Mokhtar 552*4935e1e9SAmr Mokhtar /* set op */ 553*4935e1e9SAmr Mokhtar 554*4935e1e9SAmr Mokhtar ops_burst[j]->turbo_enc.input.offset = 555*4935e1e9SAmr Mokhtar sizeof(struct ether_hdr); 556*4935e1e9SAmr Mokhtar 557*4935e1e9SAmr Mokhtar ops_burst[j]->turbo_enc->input.length = 558*4935e1e9SAmr Mokhtar rte_pktmbuf_pkt_len(bbdev_pkts[j]); 559*4935e1e9SAmr Mokhtar 560*4935e1e9SAmr Mokhtar ops_burst[j]->turbo_enc->input.data = 561*4935e1e9SAmr Mokhtar input_pkts_burst[j]; 562*4935e1e9SAmr Mokhtar 563*4935e1e9SAmr Mokhtar ops_burst[j]->turbo_enc->output.offset = 564*4935e1e9SAmr Mokhtar sizeof(struct ether_hdr); 565*4935e1e9SAmr Mokhtar 566*4935e1e9SAmr Mokhtar ops_burst[j]->turbo_enc->output.data = 567*4935e1e9SAmr Mokhtar output_pkts_burst[j]; 568*4935e1e9SAmr Mokhtar } 569*4935e1e9SAmr Mokhtar 570*4935e1e9SAmr Mokhtar /* Enqueue packets on BBDEV device */ 571*4935e1e9SAmr Mokhtar op_num = rte_bbdev_enqueue_enc_ops(qconf->bbdev_id, 572*4935e1e9SAmr Mokhtar qconf->bbdev_qs[q], ops_burst, 573*4935e1e9SAmr Mokhtar MAX_PKT_BURST); 574*4935e1e9SAmr Mokhtar 575*4935e1e9SAmr Mokhtar /* Dequeue packets from BBDEV device*/ 576*4935e1e9SAmr Mokhtar op_num = rte_bbdev_dequeue_enc_ops(qconf->bbdev_id, 577*4935e1e9SAmr Mokhtar qconf->bbdev_qs[q], ops_burst, 578*4935e1e9SAmr Mokhtar MAX_PKT_BURST); 579*4935e1e9SAmr Mokhtar } 580*4935e1e9SAmr Mokhtar 581*4935e1e9SAmr Mokhtar 582*4935e1e9SAmr MokhtarBBDEV Device API 583*4935e1e9SAmr Mokhtar~~~~~~~~~~~~~~~~ 584*4935e1e9SAmr Mokhtar 585*4935e1e9SAmr MokhtarThe bbdev Library API is described in the *DPDK API Reference* document. 586