1 .. SPDX-License-Identifier: BSD-3-Clause
2 Copyright(c) 2017 Intel Corporation
4 Wireless Baseband Device Library
5 ================================
7 The Wireless Baseband library provides a common programming framework that
8 abstracts HW accelerators based on FPGA and/or Fixed Function Accelerators that
9 assist with 3GPP Physical Layer processing. Furthermore, it decouples the
10 application from the compute-intensive wireless functions by abstracting their
11 optimized libraries to appear as virtual bbdev devices.
13 The functional scope of the BBDEV library are those functions in relation to
14 the 3GPP Layer 1 signal processing (channel coding, modulation, ...).
16 The framework currently only supports Turbo Code FEC function.
22 The Wireless Baseband library follows the same ideology of DPDK's Ethernet
23 Device and Crypto Device frameworks. Wireless Baseband provides a generic
24 acceleration abstraction framework which supports both physical (hardware) and
25 virtual (software) wireless acceleration functions.
33 Physical bbdev devices are discovered during the PCI probe/enumeration of the
34 EAL function which is executed at DPDK initialization, based on
35 their PCI device identifier, each unique PCI BDF (bus/bridge, device,
38 Virtual devices can be created by two mechanisms, either using the EAL command
39 line options or from within the application using an EAL API directly.
41 From the command line using the --vdev EAL option
43 .. code-block:: console
45 --vdev 'baseband_turbo_sw,max_nb_queues=8,socket_id=0'
47 Our using the rte_vdev_init API within the application code.
51 rte_vdev_init("baseband_turbo_sw", "max_nb_queues=2,socket_id=0")
53 All virtual bbdev devices support the following initialization parameters:
55 - ``max_nb_queues`` - maximum number of queues supported by the device.
57 - ``socket_id`` - socket on which to allocate the device resources on.
63 Each device, whether virtual or physical is uniquely designated by two
66 - A unique device index used to designate the bbdev device in all functions
67 exported by the bbdev API.
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
77 From the application point of view, each instance of a bbdev device consists of
78 one or more queues identified by queue IDs. While different devices may have
79 different capabilities (e.g. support different operation types), all queues on
80 a device support identical configuration possibilities. A queue is configured
81 for only one type of operation and is configured at initializations time.
82 When an operation is enqueued to a specific queue ID, the result is dequeued
83 from the same queue ID.
85 Configuration of a device has two different levels: configuration that applies
86 to the whole device, and configuration that applies to a single queue.
88 Device configuration is applied with
89 ``rte_bbdev_setup_queues(dev_id,num_queues,socket_id)``
90 and queue configuration is applied with
91 ``rte_bbdev_queue_configure(dev_id,queue_id,conf)``. Note that, although all
92 queues on a device support same capabilities, they can be configured differently
93 and will then behave differently.
94 Devices supporting interrupts can enable them by using
95 ``rte_bbdev_intr_enable(dev_id)``.
97 The configuration of each bbdev device includes the following operations:
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.
103 The ``rte_bbdev_setup_queues`` API is used to setup queues for a bbdev device.
107 int rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues,
110 - ``num_queues`` argument identifies the total number of queues to setup for
113 - ``socket_id`` specifies which socket will be used to allocate the memory.
116 The ``rte_bbdev_intr_enable`` API is used to enable interrupts for a bbdev
117 device, if supported by the driver. Should be called before starting the device.
121 int rte_bbdev_intr_enable(uint16_t dev_id);
127 Each bbdev devices queue is individually configured through the
128 ``rte_bbdev_queue_configure()`` API.
129 Each queue resources may be allocated on a specified socket.
133 struct rte_bbdev_queue_conf {
138 enum rte_bbdev_op_type op_type;
141 Device & Queues Management
142 ~~~~~~~~~~~~~~~~~~~~~~~~~~
144 After initialization, devices are in a stopped state, so must be started by the
145 application. If an application is finished using a device it can close the
146 device. Once closed, it cannot be restarted.
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)
157 By default, all queues are started when the device is started, but they can be
158 stopped individually.
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)
166 Logical Cores, Memory and Queues Relationships
167 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
169 The bbdev device Library as the Poll Mode Driver library support NUMA for when
170 a processor's logical cores and interfaces utilize its local memory. Therefore
171 baseband operations, the mbuf being operated on should be allocated from memory
172 pools created in the local memory. The buffers should, if possible, remain on
173 the local processor to obtain the best performance results and buffer
174 descriptors should be populated with mbufs allocated from a mempool allocated
177 The run-to-completion model also performs better, especially in the case of
178 virtual bbdev devices, if the baseband operation and data buffers are in local
179 memory instead of a remote processor's memory. This is also true for the
180 pipe-line model provided all logical cores used are located on the same processor.
182 Multiple logical cores should never share the same queue for enqueuing
183 operations or dequeuing operations on the same bbdev device since this would
184 require global locks and hinder performance. It is however possible to use a
185 different logical core to dequeue an operation on a queue pair from the logical
186 core which it was enqueued on. This means that a baseband burst enqueue/dequeue
187 APIs are a logical place to transition from one logical core to another in a
188 packet processing pipeline.
191 Device Operation Capabilities
192 -----------------------------
194 Capabilities (in terms of operations supported, max number of queues, etc.)
195 identify what a bbdev is capable of performing that differs from one device to
196 another. For the full scope of the bbdev capability see the definition of the
197 structure in the *DPDK API Reference*.
201 struct rte_bbdev_op_cap;
203 A device reports its capabilities when registering itself in the bbdev framework.
204 With the aid of this capabilities mechanism, an application can query devices to
205 discover which operations within the 3GPP physical layer they are capable of
206 performing. Below is an example of the capabilities for a PMD it supports in
207 relation to Turbo Encoding and Decoding operations.
211 static const struct rte_bbdev_op_cap bbdev_capabilities[] = {
213 .type = RTE_BBDEV_OP_TURBO_DEC,
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_MAX_CODE_BLOCKS,
224 .num_buffers_hard_out =
225 RTE_BBDEV_MAX_CODE_BLOCKS,
226 .num_buffers_soft_out = 0,
230 .type = RTE_BBDEV_OP_TURBO_ENC,
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_MAX_CODE_BLOCKS,
238 .num_buffers_dst = RTE_BBDEV_MAX_CODE_BLOCKS,
241 RTE_BBDEV_END_OF_CAPABILITIES_LIST()
244 Capabilities Discovery
245 ~~~~~~~~~~~~~~~~~~~~~~
247 Discovering the features and capabilities of a bbdev device poll mode driver
248 is achieved through the ``rte_bbdev_info_get()`` function.
252 int rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info)
254 This allows the user to query a specific bbdev PMD and get all the device
255 capabilities. The ``rte_bbdev_info`` structure provides two levels of
258 - Device relevant information, like: name and related rte_bus.
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.
266 struct rte_bbdev_info {
268 const char *dev_name;
269 const struct rte_bus *bus;
272 struct rte_bbdev_driver_info drv;
278 Scheduling of baseband operations on DPDK's application data path is
279 performed using a burst oriented asynchronous API set. A queue on a bbdev
280 device accepts a burst of baseband operations using enqueue burst API. On physical
281 bbdev devices the enqueue burst API will place the operations to be processed
282 on the device's hardware input queue, for virtual devices the processing of the
283 baseband operations is usually completed during the enqueue call to the bbdev
284 device. The dequeue burst API will retrieve any processed operations available
285 from the queue on the bbdev device, from physical devices this is usually
286 directly from the device's processed queue, and for virtual device's from a
287 ``rte_ring`` where processed operations are place after being processed on the
291 Enqueue / Dequeue Burst APIs
292 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
294 The burst enqueue API uses a bbdev device identifier and a queue
295 identifier to specify the bbdev device queue to schedule the processing on.
296 The ``num_ops`` parameter is the number of operations to process which are
297 supplied in the ``ops`` array of ``rte_bbdev_*_op`` structures.
298 The enqueue function returns the number of operations it actually enqueued for
299 processing, a return value equal to ``num_ops`` means that all packets have been
304 uint16_t rte_bbdev_enqueue_enc_ops(uint16_t dev_id, uint16_t queue_id,
305 struct rte_bbdev_enc_op **ops, uint16_t num_ops)
307 uint16_t rte_bbdev_enqueue_dec_ops(uint16_t dev_id, uint16_t queue_id,
308 struct rte_bbdev_dec_op **ops, uint16_t num_ops)
310 The dequeue API uses the same format as the enqueue API of processed but
311 the ``num_ops`` and ``ops`` parameters are now used to specify the max processed
312 operations the user wishes to retrieve and the location in which to store them.
313 The API call returns the actual number of processed operations returned, this
314 can never be larger than ``num_ops``.
318 uint16_t rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id,
319 struct rte_bbdev_enc_op **ops, uint16_t num_ops)
321 uint16_t rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id,
322 struct rte_bbdev_dec_op **ops, uint16_t num_ops)
324 Operation Representation
325 ~~~~~~~~~~~~~~~~~~~~~~~~
327 An encode bbdev operation is represented by ``rte_bbdev_enc_op`` structure,
328 and by ``rte_bbdev_dec_op`` for decode. These structures act as metadata
329 containers for all necessary information required for the bbdev operation to be
330 processed on a particular bbdev device poll mode driver.
334 struct rte_bbdev_enc_op {
336 struct rte_mempool *mempool;
338 struct rte_bbdev_op_turbo_enc turbo_enc;
341 struct rte_bbdev_dec_op {
343 struct rte_mempool *mempool;
345 struct rte_bbdev_op_turbo_dec turbo_dec;
348 The operation structure by itself defines the operation type. It includes an
349 operation status, a reference to the operation specific data, which can vary in
350 size and content depending on the operation being provisioned. It also contains
351 the source mempool for the operation, if it is allocated from a mempool.
353 If bbdev operations are allocated from a bbdev operation mempool, see next
354 section, there is also the ability to allocate private memory with the
355 operation for applications purposes.
357 Application software is responsible for specifying all the operation specific
358 fields in the ``rte_bbdev_*_op`` structure which are then used by the bbdev PMD
359 to process the requested operation.
362 Operation Management and Allocation
363 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
365 The bbdev library provides an API set for managing bbdev operations which
366 utilize the Mempool Library to allocate operation buffers. Therefore, it ensures
367 that the bbdev operation is interleaved optimally across the channels and
368 ranks for optimal processing.
373 rte_bbdev_op_pool_create(const char *name, enum rte_bbdev_op_type type,
374 unsigned int num_elements, unsigned int cache_size,
377 ``rte_bbdev_*_op_alloc_bulk()`` and ``rte_bbdev_*_op_free_bulk()`` are used to
378 allocate bbdev operations of a specific type from a given bbdev operation mempool.
382 int rte_bbdev_enc_op_alloc_bulk(struct rte_mempool *mempool,
383 struct rte_bbdev_enc_op **ops, uint16_t num_ops)
385 int rte_bbdev_dec_op_alloc_bulk(struct rte_mempool *mempool,
386 struct rte_bbdev_dec_op **ops, uint16_t num_ops)
388 ``rte_bbdev_*_op_free_bulk()`` is called by the application to return an
389 operation to its allocating pool.
393 void rte_bbdev_dec_op_free_bulk(struct rte_bbdev_dec_op **ops,
394 unsigned int num_ops)
395 void rte_bbdev_enc_op_free_bulk(struct rte_bbdev_enc_op **ops,
396 unsigned int num_ops)
398 BBDEV Inbound/Outbound Memory
399 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
401 The bbdev operation structure contains all the mutable data relating to
402 performing Turbo coding on a referenced mbuf data buffer. It is used for either
403 encode or decode operations.
405 Turbo Encode operation accepts one input and one output.
406 Turbo Decode operation accepts one input and two outputs, called *hard-decision*
407 and *soft-decision* outputs. *Soft-decision* output is optional.
409 It is expected that the application provides input and output mbuf pointers
410 allocated and ready to use. The baseband framework supports turbo coding on
411 Code Blocks (CB) and Transport Blocks (TB).
413 For the output buffer(s), the application is required to provide an allocated
414 and free mbuf, so that bbdev write back the resulting output.
416 The support of split "scattered" buffers is a driver-specific feature, so it is
417 reported individually by the supporting driver as a capability.
419 Input and output data buffers are identified by ``rte_bbdev_op_data`` structure,
424 struct rte_bbdev_op_data {
425 struct rte_mbuf *data;
431 This structure has three elements:
433 - ``data``: This is the mbuf data structure representing the data for BBDEV
436 This mbuf pointer can point to one Code Block (CB) data buffer or multiple CBs
437 contiguously located next to each other. A Transport Block (TB) represents a
438 whole piece of data that is divided into one or more CBs. Maximum number of
439 CBs can be contained in one TB is defined by ``RTE_BBDEV_MAX_CODE_BLOCKS``.
441 An mbuf data structure cannot represent more than one TB. The smallest piece
442 of data that can be contained in one mbuf is one CB.
443 An mbuf can include one contiguous CB, subset of contiguous CBs that are
444 belonging to one TB, or all contiguous CBs that are belonging to one TB.
446 If a BBDEV PMD supports the extended capability "Scatter-Gather", then it is
447 capable of collecting (gathering) non-contiguous (scattered) data from
448 multiple locations in the memory.
449 This capability is reported by the capability flags:
451 - ``RTE_BBDEV_TURBO_ENC_SCATTER_GATHER``, and
453 - ``RTE_BBDEV_TURBO_DEC_SCATTER_GATHER``.
455 Only if a BBDEV PMD supports this feature, chained mbuf data structures are
456 accepted. A chained mbuf can represent one non-contiguous CB or multiple
458 The first mbuf segment in the given chained mbuf represents the first piece
459 of the CB. Offset is only applicable to the first segment. ``length`` is the
460 total length of the CB.
462 BBDEV driver is responsible for identifying where the split is and enqueue
463 the split data to its internal queues.
465 If BBDEV PMD does not support this feature, it will assume inbound mbuf data
466 contains one segment.
468 The output mbuf data though is always one segment, even if the input was a
472 - ``offset``: This is the starting point of the BBDEV (encode/decode) operation,
475 BBDEV starts to read data past this offset.
476 In case of chained mbuf, this offset applies only to the first mbuf segment.
479 - ``length``: This is the total data length to be processed in one operation,
482 In case the mbuf data is representing one CB, this is the length of the CB
483 undergoing the operation.
484 If it is for multiple CBs, this is the total length of those CBs undergoing
486 If it is for one TB, this is the total length of the TB under operation.
487 In case of chained mbuf, this data length includes the lengths of the
488 "scattered" data segments undergoing the operation.
491 BBDEV Turbo Encode Operation
492 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
496 struct rte_bbdev_op_turbo_enc {
497 struct rte_bbdev_op_data input;
498 struct rte_bbdev_op_data output;
502 uint8_t code_block_mode;
504 struct rte_bbdev_op_enc_cb_params cb_params;
505 struct rte_bbdev_op_enc_tb_params tb_params;
509 The Turbo encode structure is composed of the ``input`` and ``output`` mbuf
510 data pointers. The provided mbuf pointer of ``input`` needs to be big enough to
511 stretch for extra CRC trailers.
513 ``op_flags`` parameter holds all operation related flags, like whether CRC24A is
514 included by the application or not.
516 ``code_block_mode`` flag identifies the mode in which bbdev is operating in.
518 The encode interface works on both the code block (CB) and the transport block
519 (TB). An operation executes in "CB-mode" when the CB is standalone. While
520 "TB-mode" executes when an operation performs on one or multiple CBs that
521 belong to a TB. Therefore, a given data can be standalone CB, full-size TB or
522 partial TB. Partial TB means that only a subset of CBs belonging to a bigger TB
525 **NOTE:** It is assumed that all enqueued ops in one ``rte_bbdev_enqueue_enc_ops()``
526 call belong to one mode, either CB-mode or TB-mode.
528 In case that the CB is smaller than Z (6144 bits), then effectively the TB = CB.
529 CRC24A is appended to the tail of the CB. The application is responsible for
530 calculating and appending CRC24A before calling BBDEV in case that the
531 underlying driver does not support CRC24A generation.
533 In CB-mode, CRC24A/B is an optional operation.
534 The input ``k`` is the size of the CB (this maps to K as described in 3GPP TS
535 36.212 section 5.1.2), this size is inclusive of CRC24A/B.
536 The ``length`` is inclusive of CRC24A/B and equals to ``k`` in this case.
538 Not all BBDEV PMDs are capable of CRC24A/B calculation. Flags
539 ``RTE_BBDEV_TURBO_CRC_24A_ATTACH`` and ``RTE_BBDEV_TURBO_CRC_24B_ATTACH``
540 informs the application with relevant capability. These flags can be set in the
541 ``op_flags`` parameter to indicate BBDEV to calculate and append CRC24A to CB
542 before going forward with Turbo encoding.
544 Output format of the CB encode will have the encoded CB in ``e`` size output
545 (this maps to E described in 3GPP TS 36.212 section 5.1.4.1.2). The output mbuf
546 buffer size needs to be big enough to hold the encoded buffer of size ``e``.
548 In TB-mode, CRC24A is assumed to be pre-calculated and appended to the inbound
550 The output mbuf data structure is expected to be allocated by the application
551 with enough room for the output data.
553 The difference between the partial and full-size TB is that we need to know the
554 index of the first CB in this group and the number of CBs contained within.
555 The first CB index is given by ``r`` but the number of the remaining CBs is
556 calculated automatically by BBDEV before passing down to the driver.
558 The number of remaining CBs should not be confused with ``c``. ``c`` is the
559 total number of CBs that composes the whole TB (this maps to C as
560 described in 3GPP TS 36.212 section 5.1.2).
562 The ``length`` is total size of the CBs inclusive of any CRC24A and CRC24B in
563 case they were appended by the application.
565 The case when one CB belongs to TB and is being enqueued individually to BBDEV,
566 this case is considered as a special case of partial TB where its number of CBs
567 is 1. Therefore, it requires to get processed in TB-mode.
569 The figure below visualizes the encoding of CBs using BBDEV interface in
570 TB-mode. CB-mode is a reduced version, where only one CB exists:
572 .. _figure_turbo_tb_encode:
574 .. figure:: img/turbo_tb_encode.svg
576 Turbo encoding of Code Blocks in mbuf structure
579 BBDEV Turbo Decode Operation
580 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
584 struct rte_bbdev_op_turbo_dec {
585 struct rte_bbdev_op_data input;
586 struct rte_bbdev_op_data hard_output;
587 struct rte_bbdev_op_data soft_output;
596 uint8_t code_block_mode;
598 struct rte_bbdev_op_dec_cb_params cb_params;
599 struct rte_bbdev_op_dec_tb_params tb_params;
603 The Turbo decode structure is composed of the ``input`` and ``output`` mbuf
606 ``op_flags`` parameter holds all operation related flags, like whether CRC24B is
609 ``code_block_mode`` flag identifies the mode in which bbdev is operating in.
611 Similarly, the decode interface works on both the code block (CB) and the
612 transport block (TB). An operation executes in "CB-mode" when the CB is
613 standalone. While "TB-mode" executes when an operation performs on one or
614 multiple CBs that belong to a TB. Therefore, a given data can be standalone CB,
615 full-size TB or partial TB. Partial TB means that only a subset of CBs belonging
616 to a bigger TB are being enqueued.
618 **NOTE:** It is assumed that all enqueued ops in one ``rte_bbdev_enqueue_dec_ops()``
619 call belong to one mode, either CB-mode or TB-mode.
621 The input ``k`` is the size of the decoded CB (this maps to K as described in
622 3GPP TS 36.212 section 5.1.2), this size is inclusive of CRC24A/B.
623 The ``length`` is inclusive of CRC24A/B and equals to ``k`` in this case.
625 The input encoded CB data is the Virtual Circular Buffer data stream, wk, with
626 the null padding included as described in 3GPP TS 36.212 section 5.1.4.1.2 and
627 shown in 3GPP TS 36.212 section 5.1.4.1 Figure 5.1.4-1.
628 The size of the virtual circular buffer is 3*Kpi, where Kpi is the 32 byte
629 aligned value of K, as specified in 3GPP TS 36.212 section 5.1.4.1.1.
631 Each byte in the input circular buffer is the LLR value of each bit of the
634 ``hard_output`` is a mandatory capability that all BBDEV PMDs support. This is
635 the decoded CBs of K sizes (CRC24A/B is the last 24-bit in each decoded CB).
636 Soft output is an optional capability for BBDEV PMDs. Setting flag
637 ``RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP`` in ``op_flags`` directs BBDEV to retain
638 CRC24B at the end of each CB. This might be useful for the application in debug
640 An LLR rate matched output is computed in the ``soft_output`` buffer structure
641 for the given ``e`` size (this maps to E described in 3GPP TS 36.212 section
642 5.1.4.1.2). The output mbuf buffer size needs to be big enough to hold the
643 encoded buffer of size ``e``.
645 The first CB Virtual Circular Buffer (VCB) index is given by ``r`` but the
646 number of the remaining CB VCBs is calculated automatically by BBDEV before
647 passing down to the driver.
649 The number of remaining CB VCBs should not be confused with ``c``. ``c`` is the
650 total number of CBs that composes the whole TB (this maps to C as
651 described in 3GPP TS 36.212 section 5.1.2).
653 The ``length`` is total size of the CBs inclusive of any CRC24A and CRC24B in
654 case they were appended by the application.
656 The case when one CB belongs to TB and is being enqueued individually to BBDEV,
657 this case is considered as a special case of partial TB where its number of CBs
658 is 1. Therefore, it requires to get processed in TB-mode.
660 The output mbuf data structure is expected to be allocated by the application
661 with enough room for the output data.
663 The figure below visualizes the decoding of CBs using BBDEV interface in
664 TB-mode. CB-mode is a reduced version, where only one CB exists:
666 .. _figure_turbo_tb_decode:
668 .. figure:: img/turbo_tb_decode.svg
670 Turbo decoding of Code Blocks in mbuf structure
676 The baseband device sample application gives an introduction on how to use the
677 bbdev framework, by giving a sample code performing a loop-back operation with a
678 baseband processor capable of transceiving data packets.
680 The following sample C-like pseudo-code shows the basic steps to encode several
681 buffers using (**sw_trubo**) bbdev PMD.
686 ret = rte_eal_init(argc, argv);
688 rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n");
690 /* Get number of available bbdev devices */
691 nb_bbdevs = rte_bbdev_count();
693 rte_exit(EXIT_FAILURE, "No bbdevs detected!\n");
695 /* Create bbdev op pools */
696 bbdev_op_pool[RTE_BBDEV_OP_TURBO_ENC] =
697 rte_bbdev_op_pool_create("bbdev_op_pool_enc",
698 RTE_BBDEV_OP_TURBO_ENC, NB_MBUF, 128, rte_socket_id());
700 /* Get information for this device */
701 rte_bbdev_info_get(dev_id, &info);
703 /* Setup BBDEV device queues */
704 ret = rte_bbdev_setup_queues(dev_id, qs_nb, info.socket_id);
706 rte_exit(EXIT_FAILURE,
707 "ERROR(%d): BBDEV %u not configured properly\n",
710 /* setup device queues */
711 qconf.socket = info.socket_id;
712 qconf.queue_size = info.drv.queue_size_lim;
713 qconf.op_type = RTE_BBDEV_OP_TURBO_ENC;
715 for (q_id = 0; q_id < qs_nb; q_id++) {
716 /* Configure all queues belonging to this bbdev device */
717 ret = rte_bbdev_queue_configure(dev_id, q_id, &qconf);
719 rte_exit(EXIT_FAILURE,
720 "ERROR(%d): BBDEV %u queue %u not configured properly\n",
724 /* Start bbdev device */
725 ret = rte_bbdev_start(dev_id);
727 /* Create the mbuf mempool for pkts */
728 mbuf_pool = rte_pktmbuf_pool_create("bbdev_mbuf_pool",
729 NB_MBUF, MEMPOOL_CACHE_SIZE, 0,
730 RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id());
731 if (mbuf_pool == NULL)
732 rte_exit(EXIT_FAILURE,
733 "Unable to create '%s' pool\n", pool_name);
735 while (!global_exit_flag) {
737 /* Allocate burst of op structures in preparation for enqueue */
738 if (rte_bbdev_enc_op_alloc_bulk(bbdev_op_pool[RTE_BBDEV_OP_TURBO_ENC],
739 ops_burst, op_num) != 0)
742 /* Allocate input mbuf pkts */
743 ret = rte_pktmbuf_alloc_bulk(mbuf_pool, input_pkts_burst, MAX_PKT_BURST);
747 /* Allocate output mbuf pkts */
748 ret = rte_pktmbuf_alloc_bulk(mbuf_pool, output_pkts_burst, MAX_PKT_BURST);
752 for (j = 0; j < op_num; j++) {
753 /* Append the size of the ethernet header */
754 rte_pktmbuf_append(input_pkts_burst[j],
755 sizeof(struct ether_hdr));
759 ops_burst[j]->turbo_enc.input.offset =
760 sizeof(struct ether_hdr);
762 ops_burst[j]->turbo_enc->input.length =
763 rte_pktmbuf_pkt_len(bbdev_pkts[j]);
765 ops_burst[j]->turbo_enc->input.data =
768 ops_burst[j]->turbo_enc->output.offset =
769 sizeof(struct ether_hdr);
771 ops_burst[j]->turbo_enc->output.data =
772 output_pkts_burst[j];
775 /* Enqueue packets on BBDEV device */
776 op_num = rte_bbdev_enqueue_enc_ops(qconf->bbdev_id,
777 qconf->bbdev_qs[q], ops_burst,
780 /* Dequeue packets from BBDEV device*/
781 op_num = rte_bbdev_dequeue_enc_ops(qconf->bbdev_id,
782 qconf->bbdev_qs[q], ops_burst,
790 The bbdev Library API is described in the *DPDK API Reference* document.