#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <inttypes.h>
#include <sys/types.h>
#include <sys/unistd.h>
#include <sys/queue.h>
#include <stdarg.h>
#include <ctype.h>
#include <errno.h>
#include <math.h>
#include <assert.h>
#include <getopt.h>
#include <signal.h>
#define LLR_1_BIT 0x81
#define LLR_0_BIT 0x7F
#define MAX_PKT_BURST 32
#define NB_MBUF 8191
#define MEMPOOL_CACHE_SIZE 256
#define K 40
#define NCB (3 * RTE_ALIGN_CEIL(K + 4, 32))
#define CRC_24B_LEN 3
#define RTE_TEST_RX_DESC_DEFAULT 128
#define RTE_TEST_TX_DESC_DEFAULT 512
#define BBDEV_ASSERT(a) do { \
    if (!(a)) { \
        usage(prgname); \
        return -1; \
    } \
} while (0)
        .split_hdr_size = 0,
    },
    .txmode = {
    },
};
    
    .code_block_mode = 1,
    .cb_params = {
        .k = K,
    },
};
struct rte_bbdev_op_turbo_dec def_op_dec = {
    
    .code_block_mode = 1,
    .cb_params = {
        .k = K,
    },
    .rv_index = 0,
    .iter_max = 8,
    .iter_min = 4,
    .ext_scale = 15,
    .num_maps = 0,
};
struct app_config_params {
    
    uint16_t port_id;
    uint16_t bbdev_id;
    uint64_t enc_core_mask;
    uint64_t dec_core_mask;
    
    uint16_t enc_queue_ids[RTE_MAX_LCORE];
    uint16_t dec_queue_ids[RTE_MAX_LCORE];
    uint16_t num_enc_cores;
    uint16_t num_dec_cores;
};
struct lcore_statistics {
    unsigned int enqueued;
    unsigned int dequeued;
    unsigned int rx_lost_packets;
    unsigned int enc_to_dec_lost_packets;
    unsigned int tx_lost_packets;
struct lcore_conf {
    uint64_t core_type;
    unsigned int port_id;
    unsigned int rx_queue_id;
    unsigned int tx_queue_id;
    unsigned int bbdev_id;
    unsigned int enc_queue_id;
    unsigned int dec_queue_id;
    uint8_t llr_temp_buf[NCB];
    struct lcore_statistics *lcore_stats;
struct stats_lcore_params {
    struct lcore_conf *lconf;
    struct app_config_params *app_params;
};
static const struct app_config_params def_app_config = {
    .port_id = 0,
    .bbdev_id = 0,
    .enc_core_mask = 0x2,
    .dec_core_mask = 0x4,
    .num_enc_cores = 1,
    .num_dec_cores = 1,
};
static inline void
usage(const char *prgname)
{
    printf("%s [EAL options] "
            "  --\n"
            "  --enc_cores - number of encoding cores (default = 0x2)\n"
            "  --dec_cores - number of decoding cores (default = 0x4)\n"
            "  --port_id - Ethernet port ID (default = 0)\n"
            "  --bbdev_id - BBDev ID (default = 0)\n"
            "\n", prgname);
}
static inline
uint16_t bbdev_parse_mask(const char *mask)
{
    char *end = NULL;
    unsigned long pm;
    
    pm = strtoul(mask, &end, 16);
    if ((mask[0] == '\0') || (end == NULL) || (*end != '\0'))
        return 0;
    return pm;
}
static inline
uint16_t bbdev_parse_number(const char *mask)
{
    char *end = NULL;
    unsigned long pm;
    
    pm = strtoul(mask, &end, 10);
    if ((mask[0] == '\0') || (end == NULL) || (*end != '\0'))
        return 0;
    return pm;
}
static int
bbdev_parse_args(int argc, char **argv,
        struct app_config_params *app_params)
{
    int optind = 0;
    int opt;
    int opt_indx = 0;
    char *prgname = argv[0];
    static struct option lgopts[] = {
        { "enc_core_mask", required_argument, 0, 'e' },
        { "dec_core_mask", required_argument, 0, 'd' },
        { "port_id", required_argument, 0, 'p' },
        { "bbdev_id", required_argument, 0, 'b' },
        { NULL, 0, 0, 0 }
    };
    BBDEV_ASSERT(argc != 0);
    BBDEV_ASSERT(argv != NULL);
    BBDEV_ASSERT(app_params != NULL);
    while ((opt = getopt_long(argc, argv, "e:d:p:b:", lgopts, &opt_indx)) !=
        EOF) {
        switch (opt) {
        case 'e':
            app_params->enc_core_mask =
                bbdev_parse_mask(optarg);
            if (app_params->enc_core_mask == 0) {
                usage(prgname);
                return -1;
            }
            app_params->num_enc_cores =
                __builtin_popcount(app_params->enc_core_mask);
            break;
        case 'd':
            app_params->dec_core_mask =
                bbdev_parse_mask(optarg);
            if (app_params->dec_core_mask == 0) {
                usage(prgname);
                return -1;
            }
            app_params->num_dec_cores =
                __builtin_popcount(app_params->dec_core_mask);
            break;
        case 'p':
            app_params->port_id = bbdev_parse_number(optarg);
            break;
        case 'b':
            app_params->bbdev_id = bbdev_parse_number(optarg);
            break;
        default:
            usage(prgname);
            return -1;
        }
    }
    optind = 0;
    return optind;
}
static void
signal_handler(int signum)
{
    printf("\nSignal %d received\n", signum);
}
static void
print_mac(
unsigned int portid, 
struct ether_addr *bbdev_ports_eth_address)
{
    printf("Port %u, MAC address: %02X:%02X:%02X:%02X:%02X:%02X\n\n",
            (unsigned int) portid,
}
static inline void
pktmbuf_free_bulk(
struct rte_mbuf **mbufs, 
unsigned int nb_to_free)
{
    unsigned int i;
    for (i = 0; i < nb_to_free; ++i)
}
static inline void
pktmbuf_userdata_free_bulk(
struct rte_mbuf **mbufs, 
unsigned int nb_to_free)
{
    unsigned int i;
    for (i = 0; i < nb_to_free; ++i) {
    }
}
static int
check_port_link_status(uint16_t port_id)
{
#define CHECK_INTERVAL 100 
#define MAX_CHECK_TIME 90 
    uint8_t count;
    printf("\nChecking link status.");
    fflush(stdout);
    for (count = 0; count <= MAX_CHECK_TIME &&
        memset(&link, 0, sizeof(link));
        if (link.link_status) {
            const char *dp = (link.link_duplex ==
                "full-duplex" : "half-duplex";
            printf("\nPort %u Link Up - speed %u Mbps - %s\n",
                port_id, link.link_speed, dp);
            return 0;
        }
        printf(".");
        fflush(stdout);
    }
    printf("\nPort %d Link Down\n", port_id);
    return 0;
}
static inline void
{
    
}
static inline void
add_awgn(
struct rte_mbuf **mbufs, uint16_t num_pkts)
{
}
static inline void
transform_enc_out_dec_in(
struct rte_mbuf **mbufs, uint8_t *temp_buf,
        uint16_t num_pkts, uint16_t k)
{
    uint16_t i, l, j;
    uint16_t start_bit_idx;
    uint16_t out_idx;
    uint16_t d = k + 4;
    uint16_t nd = kpi - d;
    uint16_t ncb = 3 * kpi;
    for (i = 0; i < num_pkts; ++i) {
        
        if (pkt_data_len < ncb) {
                    ncb - pkt_data_len);
            if (data == NULL)
                printf(
                    "Not enough space in decoder input packet");
        }
        
        start_bit_idx = 0;
        out_idx = 0;
        for (j = 0; j < 3; ++j) {
            for (l = start_bit_idx; l < start_bit_idx + d; ++l) {
                    mbufs[i], uint8_t *,
                if (*data & (0x80 >> (l & 7)))
                    temp_buf[out_idx] = LLR_1_BIT;
                else
                    temp_buf[out_idx] = LLR_0_BIT;
                ++out_idx;
            }
            
            memset(&temp_buf[out_idx], 0, nd);
            out_idx += nd;
            start_bit_idx += d;
        }
    }
}
static inline void
verify_data(
struct rte_mbuf **mbufs, uint16_t num_pkts)
{
    uint16_t i;
    for (i = 0; i < num_pkts; ++i) {
                K / 8 - CRC_24B_LEN))
            printf("Input and output buffers are not equal!\n");
    }
}
static int
initialize_ports(struct app_config_params *app_params,
{
    int ret;
    uint16_t port_id = app_params->port_id;
    uint16_t q;
    
    
    printf("\nInitializing port %u...\n", app_params->port_id);
        app_params->num_dec_cores, &port_conf);
    if (ret < 0) {
        printf("Cannot configure device: err=%d, port=%u\n",
            ret, port_id);
        return -1;
    }
    
    for (q = 0; q < app_params->num_enc_cores; q++) {
            RTE_TEST_RX_DESC_DEFAULT,
            NULL, ethdev_mbuf_mempool);
        if (ret < 0) {
            printf("rte_eth_rx_queue_setup: err=%d, queue=%u\n",
                ret, q);
            return -1;
        }
    }
    
    for (q = 0; q < app_params->num_dec_cores; q++) {
            RTE_TEST_TX_DESC_DEFAULT,
        if (ret < 0) {
            printf("rte_eth_tx_queue_setup: err=%d, queue=%u\n",
                ret, q);
            return -1;
        }
    }
    print_mac(port_id, &bbdev_port_eth_addr);
    return 0;
}
static void
lcore_conf_init(struct app_config_params *app_params,
        struct lcore_conf *lcore_conf,
        struct lcore_statistics *lcore_stats)
{
    unsigned int lcore_id;
    struct lcore_conf *lconf;
    uint16_t rx_queue_id = 0;
    uint16_t tx_queue_id = 0;
    uint16_t enc_q_id = 0;
    uint16_t dec_q_id = 0;
    
    for (lcore_id = 0; lcore_id < 8 * sizeof(uint64_t); ++lcore_id) {
        lconf = &lcore_conf[lcore_id];
        lconf->core_type = 0;
        if ((1ULL << lcore_id) & app_params->enc_core_mask) {
            lconf->rx_queue_id = rx_queue_id++;
            lconf->enc_queue_id =
                    app_params->enc_queue_ids[enc_q_id++];
        }
        if ((1ULL << lcore_id) & app_params->dec_core_mask) {
            lconf->tx_queue_id = tx_queue_id++;
            lconf->dec_queue_id =
                    app_params->dec_queue_ids[dec_q_id++];
        }
        lconf->bbdev_enc_op_pool =
        lconf->bbdev_dec_op_pool =
        lconf->bbdev_id = app_params->bbdev_id;
        lconf->port_id = app_params->port_id;
        lconf->enc_out_pool = bbdev_mbuf_mempool;
        lconf->enc_to_dec_ring = enc_to_dec_ring;
        lconf->lcore_stats = &lcore_stats[lcore_id];
    }
}
static void
print_lcore_stats(struct lcore_statistics *lstats, unsigned int lcore_id)
{
    static const char *stats_border = "_______";
    printf("\nLcore %d: %s enqueued count:\t\t%u\n",
            lcore_id, stats_border, lstats->enqueued);
    printf("Lcore %d: %s dequeued count:\t\t%u\n",
            lcore_id, stats_border, lstats->dequeued);
    printf("Lcore %d: %s RX lost packets count:\t\t%u\n",
            lcore_id, stats_border, lstats->rx_lost_packets);
    printf("Lcore %d: %s encoder-to-decoder lost count:\t%u\n",
            lcore_id, stats_border,
            lstats->enc_to_dec_lost_packets);
    printf("Lcore %d: %s TX lost packets count:\t\t%u\n",
            lcore_id, stats_border, lstats->tx_lost_packets);
}
static void
print_stats(struct stats_lcore_params *stats_lcore)
{
    unsigned int l_id;
    unsigned int bbdev_id = stats_lcore->app_params->bbdev_id;
    unsigned int port_id = stats_lcore->app_params->port_id;
    int len, ret, i;
    static const char *stats_border = "_______";
    const char clr[] = { 27, '[', '2', 'J', '\0' };
    const char topLeft[] = { 27, '[', '1', ';', '1', 'H', '\0' };
    
    printf("%s%s", clr, topLeft);
    printf("PORT STATISTICS:\n================\n");
    if (len < 0)
                "rte_eth_xstats_get(%u) failed: %d", port_id,
                len);
    xstats = calloc(len, sizeof(*xstats));
    if (xstats == NULL)
                "Failed to calloc memory for xstats");
    if (ret < 0 || ret > len) {
        free(xstats);
                "rte_eth_xstats_get(%u) len%i failed: %d",
                port_id, len, ret);
    }
    xstats_names = calloc(len, sizeof(*xstats_names));
    if (xstats_names == NULL) {
        free(xstats);
                "Failed to calloc memory for xstats_names");
    }
    if (ret < 0 || ret > len) {
        free(xstats);
        free(xstats_names);
                "rte_eth_xstats_get_names(%u) len%i failed: %d",
                port_id, len, ret);
    }
    for (i = 0; i < len; i++) {
        if (xstats[i].value > 0)
            printf("Port %u: %s %s:\t\t%"PRIu64"\n",
                    port_id, stats_border,
                    xstats_names[i].name,
                    xstats[i].value);
    }
    if (ret < 0) {
        free(xstats);
        free(xstats_names);
                "ERROR(%d): Failure to get BBDEV %u statistics\n",
                ret, bbdev_id);
    }
    printf("\nBBDEV STATISTICS:\n=================\n");
    printf("BBDEV %u: %s enqueue count:\t\t%"PRIu64"\n",
            bbdev_id, stats_border,
            bbstats.enqueued_count);
    printf("BBDEV %u: %s dequeue count:\t\t%"PRIu64"\n",
            bbdev_id, stats_border,
            bbstats.dequeued_count);
    printf("BBDEV %u: %s enqueue error count:\t\t%"PRIu64"\n",
            bbdev_id, stats_border,
            bbstats.enqueue_err_count);
    printf("BBDEV %u: %s dequeue error count:\t\t%"PRIu64"\n\n",
            bbdev_id, stats_border,
            bbstats.dequeue_err_count);
    printf("LCORE STATISTICS:\n=================\n");
    for (l_id = 0; l_id < RTE_MAX_LCORE; ++l_id) {
        if (stats_lcore->lconf[l_id].core_type == 0)
            continue;
        print_lcore_stats(stats_lcore->lconf[l_id].lcore_stats, l_id);
    }
    fflush(stdout);
    free(xstats);
    free(xstats_names);
}
static int
stats_loop(void *arg)
{
    struct stats_lcore_params *stats_lcore = arg;
        print_stats(stats_lcore);
    }
    return 0;
}
static inline void
run_encoding(struct lcore_conf *lcore_conf)
{
    uint16_t i;
    uint16_t port_id, rx_queue_id;
    uint16_t bbdev_id, enc_queue_id;
    uint16_t nb_rx, nb_enq, nb_deq, nb_sent;
    struct rte_mbuf *rx_pkts_burst[MAX_PKT_BURST];
 
    struct rte_mbuf *enc_out_pkts[MAX_PKT_BURST];
 
    struct lcore_statistics *lcore_stats;
    const int in_data_len = (def_op_enc.
cb_params.k / 8) - CRC_24B_LEN;
 
    lcore_stats = lcore_conf->lcore_stats;
    port_id = lcore_conf->port_id;
    rx_queue_id = lcore_conf->rx_queue_id;
    bbdev_id = lcore_conf->bbdev_id;
    enc_queue_id = lcore_conf->enc_queue_id;
    bbdev_op_pool = lcore_conf->bbdev_enc_op_pool;
    enc_out_pool = lcore_conf->enc_out_pool;
    enc_to_dec_ring = lcore_conf->enc_to_dec_ring;
    
            MAX_PKT_BURST);
    if (!nb_rx)
        return;
            nb_rx) != 0)) {
        pktmbuf_free_bulk(rx_pkts_burst, nb_rx);
        lcore_stats->rx_lost_packets += nb_rx;
        return;
    }
            nb_rx) != 0)) {
        pktmbuf_free_bulk(enc_out_pkts, nb_rx);
        pktmbuf_free_bulk(rx_pkts_burst, nb_rx);
        lcore_stats->rx_lost_packets += nb_rx;
        return;
    }
    for (i = 0; i < nb_rx; i++) {
        char *data;
        const uint16_t pkt_data_len =
        
        enc_out_pkts[i]->
userdata = rx_pkts_burst[i];
        
        rte_pktmbuf_reset(enc_out_pkts[i]);
        if (data == NULL) {
            printf(
                "Not enough space for ethernet header in encoder output mbuf\n");
            continue;
        }
        add_ether_hdr(rx_pkts_burst[i], enc_out_pkts[i]);
        
                rx_pkts_burst[i];
        
        if (in_data_len < pkt_data_len)
                    in_data_len);
        else if (in_data_len > pkt_data_len) {
                    in_data_len - pkt_data_len);
            if (data == NULL)
                printf(
                    "Not enough storage in mbuf to perform the encoding\n");
        }
                enc_out_pkts[i];
        bbdev_ops_burst[i]->
turbo_enc.output.offset =
    }
    
            bbdev_ops_burst, nb_rx);
        pktmbuf_userdata_free_bulk(&enc_out_pkts[nb_enq],
                nb_rx - nb_enq);
                nb_rx - nb_enq);
        lcore_stats->rx_lost_packets += nb_rx - nb_enq;
        if (!nb_enq)
            return;
    }
    lcore_stats->enqueued += nb_enq;
    
    nb_deq = 0;
    do {
                &bbdev_ops_burst[nb_deq], nb_enq - nb_deq);
    lcore_stats->dequeued += nb_deq;
    
    add_awgn(enc_out_pkts, nb_deq);
    
            nb_deq, NULL);
        pktmbuf_userdata_free_bulk(&enc_out_pkts[nb_sent],
                nb_deq - nb_sent);
        lcore_stats->enc_to_dec_lost_packets += nb_deq - nb_sent;
    }
}
static void
run_decoding(struct lcore_conf *lcore_conf)
{
    uint16_t i;
    uint16_t port_id, tx_queue_id;
    uint16_t bbdev_id, bbdev_queue_id;
    uint16_t nb_recv, nb_enq, nb_deq, nb_tx;
    uint8_t *llr_temp_buf;
    struct rte_mbuf *recv_pkts_burst[MAX_PKT_BURST];
 
    struct lcore_statistics *lcore_stats;
    lcore_stats = lcore_conf->lcore_stats;
    port_id = lcore_conf->port_id;
    tx_queue_id = lcore_conf->tx_queue_id;
    bbdev_id = lcore_conf->bbdev_id;
    bbdev_queue_id = lcore_conf->dec_queue_id;
    bbdev_op_pool = lcore_conf->bbdev_dec_op_pool;
    enc_to_dec_ring = lcore_conf->enc_to_dec_ring;
    llr_temp_buf = lcore_conf->llr_temp_buf;
    
            (void **)recv_pkts_burst, MAX_PKT_BURST, NULL);
    if (!nb_recv)
        return;
            nb_recv) != 0)) {
        pktmbuf_userdata_free_bulk(recv_pkts_burst, nb_recv);
        lcore_stats->rx_lost_packets += nb_recv;
        return;
    }
    transform_enc_out_dec_in(recv_pkts_burst, llr_temp_buf, nb_recv,
            def_op_dec.cb_params.k);
    for (i = 0; i < nb_recv; i++) {
        
        bbdev_ops_burst[i]->
turbo_dec = def_op_dec;
        bbdev_ops_burst[i]->turbo_dec.input.data = recv_pkts_burst[i];
        bbdev_ops_burst[i]->turbo_dec.input.offset =
        bbdev_ops_burst[i]->turbo_dec.input.length =
        bbdev_ops_burst[i]->turbo_dec.hard_output.data =
                recv_pkts_burst[i];
        bbdev_ops_burst[i]->turbo_dec.hard_output.offset =
    }
    
            bbdev_ops_burst, nb_recv);
        pktmbuf_userdata_free_bulk(&recv_pkts_burst[nb_enq],
                nb_recv - nb_enq);
                nb_recv - nb_enq);
        lcore_stats->rx_lost_packets += nb_recv - nb_enq;
        if (!nb_enq)
            return;
    }
    lcore_stats->enqueued += nb_enq;
    
    nb_deq = 0;
    do {
                &bbdev_ops_burst[nb_deq], nb_enq - nb_deq);
    lcore_stats->dequeued += nb_deq;
    verify_data(recv_pkts_burst, nb_deq);
    
    for (i = 0; i < nb_deq; ++i)
    
        pktmbuf_userdata_free_bulk(&recv_pkts_burst[nb_tx],
                nb_deq - nb_tx);
        lcore_stats->tx_lost_packets += nb_deq - nb_tx;
    }
}
static int
processing_loop(void *arg)
{
    struct lcore_conf *lcore_conf = arg;
    const bool run_encoder = (lcore_conf->core_type &
    const bool run_decoder = (lcore_conf->core_type &
        if (run_encoder)
            run_encoding(lcore_conf);
        if (run_decoder)
            run_decoding(lcore_conf);
    }
    return 0;
}
static int
prepare_bbdev_device(
unsigned int dev_id, 
struct rte_bbdev_info *info,
        struct app_config_params *app_params)
{
    int ret;
    unsigned int q_id, dec_q_id, enc_q_id;
    uint16_t dec_qs_nb = app_params->num_dec_cores;
    uint16_t enc_qs_nb = app_params->num_enc_cores;
    uint16_t tot_qs = dec_qs_nb + enc_qs_nb;
    if (ret < 0)
                "ERROR(%d): BBDEV %u not configured properly\n",
                ret, dev_id);
    
    for (q_id = 0, dec_q_id = 0; q_id < dec_qs_nb; q_id++) {
        if (ret < 0)
                    "ERROR(%d): BBDEV %u DEC queue %u not configured properly\n",
                    ret, dev_id, q_id);
        app_params->dec_queue_ids[dec_q_id++] = q_id;
    }
    
    for (q_id = dec_qs_nb, enc_q_id = 0; q_id < tot_qs; q_id++) {
        if (ret < 0)
                    "ERROR(%d): BBDEV %u ENC queue %u not configured properly\n",
                    ret, dev_id, q_id);
        app_params->enc_queue_ids[enc_q_id++] = q_id;
    }
    if (ret != 0)
        rte_exit(EXIT_FAILURE, 
"ERROR(%d): BBDEV %u not started\n",
 
            ret, dev_id);
    printf("BBdev %u started\n", dev_id);
    return 0;
}
static inline bool
check_matching_capabilities(uint64_t mask, uint64_t required_mask)
{
    return (mask & required_mask) == required_mask;
}
static void
enable_bbdev(struct app_config_params *app_params)
{
    const struct rte_bbdev_op_cap *op_cap;
    uint16_t bbdev_id = app_params->bbdev_id;
    bool encoder_capable = false;
    bool decoder_capable = false;
    op_cap = dev_info.drv.capabilities;
            if (check_matching_capabilities(
                    op_cap->cap.turbo_enc.capability_flags,
                encoder_capable = true;
        }
            if (check_matching_capabilities(
                    op_cap->cap.turbo_dec.capability_flags,
                    def_op_dec.op_flags))
                decoder_capable = true;
        }
        op_cap++;
    }
    if (encoder_capable == false)
            "The specified BBDev %u doesn't have required encoder capabilities!\n",
            bbdev_id);
    if (decoder_capable == false)
            "The specified BBDev %u doesn't have required decoder capabilities!\n",
            bbdev_id);
    prepare_bbdev_device(bbdev_id, &dev_info, app_params);
}
int
main(int argc, char **argv)
{
    int ret;
    unsigned int nb_bbdevs, flags, lcore_id;
    void *sigret;
    struct app_config_params app_params = def_app_config;
    struct rte_mempool *ethdev_mbuf_mempool, *bbdev_mbuf_mempool;
 
    struct lcore_conf lcore_conf[RTE_MAX_LCORE] = { {0} };
    struct lcore_statistics lcore_stats[RTE_MAX_LCORE] = { {0} };
    struct stats_lcore_params stats_lcore;
    bool stats_thread_started = false;
    sigret = signal(SIGTERM, signal_handler);
    if (sigret == SIG_ERR)
        rte_exit(EXIT_FAILURE, 
"signal(%d, ...) failed", SIGTERM);
 
    sigret = signal(SIGINT, signal_handler);
    if (sigret == SIG_ERR)
        rte_exit(EXIT_FAILURE, 
"signal(%d, ...) failed", SIGINT);
 
    if (ret < 0)
        rte_exit(EXIT_FAILURE, 
"Invalid EAL arguments\n");
 
    argc -= ret;
    argv += ret;
    
    ret = bbdev_parse_args(argc, argv, &app_params);
    if (ret < 0)
        rte_exit(EXIT_FAILURE, 
"Invalid BBDEV arguments\n");
 
    
        rte_exit(EXIT_FAILURE, 
"Cannot create bbdev op pools\n");
 
    
    if (app_params.num_dec_cores == 1)
    
    if (nb_bbdevs <= app_params.bbdev_id)
                "%u BBDevs detected, cannot use BBDev with ID %u!\n",
                nb_bbdevs, app_params.bbdev_id);
    printf("Number of bbdevs detected: %d\n", nb_bbdevs);
                "cannot use port with ID %u!\n",
                app_params.port_id);
    
            NB_MBUF, MEMPOOL_CACHE_SIZE, 0,
    if (ethdev_mbuf_mempool == NULL)
        rte_exit(EXIT_FAILURE, 
"Cannot create ethdev mbuf mempool\n");
 
    
            NB_MBUF, MEMPOOL_CACHE_SIZE, 0,
    if (bbdev_mbuf_mempool == NULL)
        rte_exit(EXIT_FAILURE, 
"Cannot create ethdev mbuf mempool\n");
 
    
    ret = initialize_ports(&app_params, ethdev_mbuf_mempool);
    
    for (lcore_id = 0; lcore_id < 8 * sizeof(uint64_t); ++lcore_id)
        if (((1ULL << lcore_id) & app_params.enc_core_mask) ||
                ((1ULL << lcore_id) & app_params.dec_core_mask))
                        "Requested lcore_id %u is not enabled!\n",
                        lcore_id);
    
    if (ret < 0)
        rte_exit(EXIT_FAILURE, 
"rte_eth_dev_start:err=%d, port=%u\n",
 
                ret, app_params.port_id);
    ret = check_port_link_status(app_params.port_id);
    if (ret < 0)
        exit(EXIT_FAILURE);
    
    enable_bbdev(&app_params);
    
    lcore_conf_init(&app_params, lcore_conf, bbdev_op_pools,
            bbdev_mbuf_mempool, enc_to_dec_ring, lcore_stats);
    stats_lcore.app_params = &app_params;
    stats_lcore.lconf = lcore_conf;
        if (lcore_conf[lcore_id].core_type != 0)
            
                    &lcore_conf[lcore_id], lcore_id);
        else if (!stats_thread_started) {
            
                    lcore_id);
            stats_thread_started = true;
        }
    }
    if (!stats_thread_started &&
            lcore_conf[master_lcore_id].core_type != 0)
                "Not enough lcores to run the statistics printing loop!");
    else if (lcore_conf[master_lcore_id].core_type != 0)
        processing_loop(&lcore_conf[master_lcore_id]);
    else if (!stats_thread_started)
        stats_loop(&stats_lcore);
    }
    return ret;
}