X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fbbdev_app%2Fmain.c;h=68a46050c048791563cecde9e05337408c42f962;hb=11159dd669c043412dfa43708f1c4b7f4f47037a;hp=e779db281955f11996f3fce440289fbf97d46654;hpb=2a5aa6e7a528b16db7da507c975ce3d169d232d4;p=dpdk.git diff --git a/examples/bbdev_app/main.c b/examples/bbdev_app/main.c index e779db2819..68a46050c0 100644 --- a/examples/bbdev_app/main.c +++ b/examples/bbdev_app/main.c @@ -62,13 +62,8 @@ static const struct rte_eth_conf port_conf = { .rxmode = { .mq_mode = ETH_MQ_RX_NONE, - .max_rx_pkt_len = ETHER_MAX_LEN, + .max_rx_pkt_len = RTE_ETHER_MAX_LEN, .split_hdr_size = 0, - .header_split = 0, /**< Header Split disabled */ - .hw_ip_checksum = 0, /**< IP checksum offload disabled */ - .hw_vlan_filter = 0, /**< VLAN filtering disabled */ - .jumbo_frame = 0, /**< Jumbo Frame Support disabled */ - .hw_strip_crc = 0, /**< CRC stripped by hardware */ }, .txmode = { .mq_mode = ETH_MQ_TX_NONE, @@ -278,7 +273,7 @@ signal_handler(int signum) } static void -print_mac(unsigned int portid, struct ether_addr *bbdev_ports_eth_address) +print_mac(unsigned int portid, struct rte_ether_addr *bbdev_ports_eth_address) { printf("Port %u, MAC address: %02X:%02X:%02X:%02X:%02X:%02X\n\n", (unsigned int) portid, @@ -317,6 +312,7 @@ check_port_link_status(uint16_t port_id) #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */ uint8_t count; struct rte_eth_link link; + int link_get_err = -EINVAL; printf("\nChecking link status."); fflush(stdout); @@ -324,9 +320,9 @@ check_port_link_status(uint16_t port_id) for (count = 0; count <= MAX_CHECK_TIME && !rte_atomic16_read(&global_exit_flag); count++) { memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(port_id, &link); + link_get_err = rte_eth_link_get_nowait(port_id, &link); - if (link.link_status) { + if (link_get_err >= 0 && link.link_status) { const char *dp = (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? "full-duplex" : "half-duplex"; @@ -339,21 +335,26 @@ check_port_link_status(uint16_t port_id) rte_delay_ms(CHECK_INTERVAL); } - printf("\nPort %d Link Down\n", port_id); + if (link_get_err >= 0) + printf("\nPort %d Link Down\n", port_id); + else + printf("\nGet link failed (port %d): %s\n", port_id, + rte_strerror(-link_get_err)); + return 0; } static inline void add_ether_hdr(struct rte_mbuf *pkt_src, struct rte_mbuf *pkt_dst) { - struct ether_hdr *eth_from; - struct ether_hdr *eth_to; + struct rte_ether_hdr *eth_from; + struct rte_ether_hdr *eth_to; - eth_from = rte_pktmbuf_mtod(pkt_src, struct ether_hdr *); - eth_to = rte_pktmbuf_mtod(pkt_dst, struct ether_hdr *); + eth_from = rte_pktmbuf_mtod(pkt_src, struct rte_ether_hdr *); + eth_to = rte_pktmbuf_mtod(pkt_dst, struct rte_ether_hdr *); /* copy header */ - rte_memcpy(eth_to, eth_from, sizeof(struct ether_hdr)); + rte_memcpy(eth_to, eth_from, sizeof(struct rte_ether_hdr)); } static inline void @@ -382,7 +383,7 @@ transform_enc_out_dec_in(struct rte_mbuf **mbufs, uint8_t *temp_buf, for (i = 0; i < num_pkts; ++i) { uint16_t pkt_data_len = rte_pktmbuf_data_len(mbufs[i]) - - sizeof(struct ether_hdr); + sizeof(struct rte_ether_hdr); /* Resize the packet if needed */ if (pkt_data_len < ncb) { @@ -400,7 +401,8 @@ transform_enc_out_dec_in(struct rte_mbuf **mbufs, uint8_t *temp_buf, for (l = start_bit_idx; l < start_bit_idx + d; ++l) { uint8_t *data = rte_pktmbuf_mtod_offset( mbufs[i], uint8_t *, - sizeof(struct ether_hdr) + (l >> 3)); + sizeof(struct rte_ether_hdr) + + (l >> 3)); if (*data & (0x80 >> (l & 7))) temp_buf[out_idx] = LLR_1_BIT; else @@ -415,7 +417,7 @@ transform_enc_out_dec_in(struct rte_mbuf **mbufs, uint8_t *temp_buf, } rte_memcpy(rte_pktmbuf_mtod_offset(mbufs[i], uint8_t *, - sizeof(struct ether_hdr)), temp_buf, ncb); + sizeof(struct rte_ether_hdr)), temp_buf, ncb); } } @@ -428,9 +430,9 @@ verify_data(struct rte_mbuf **mbufs, uint16_t num_pkts) struct rte_mbuf *in = out->userdata; if (memcmp(rte_pktmbuf_mtod_offset(in, uint8_t *, - sizeof(struct ether_hdr)), + sizeof(struct rte_ether_hdr)), rte_pktmbuf_mtod_offset(out, uint8_t *, - sizeof(struct ether_hdr)), + sizeof(struct rte_ether_hdr)), K / 8 - CRC_24B_LEN)) printf("Input and output buffers are not equal!\n"); } @@ -444,7 +446,7 @@ initialize_ports(struct app_config_params *app_params, uint16_t port_id = app_params->port_id; uint16_t q; /* ethernet addresses of ports */ - struct ether_addr bbdev_port_eth_addr; + struct rte_ether_addr bbdev_port_eth_addr; /* initialize ports */ printf("\nInitializing port %u...\n", app_params->port_id); @@ -481,9 +483,20 @@ initialize_ports(struct app_config_params *app_params, } } - rte_eth_promiscuous_enable(port_id); + ret = rte_eth_promiscuous_enable(port_id); + if (ret != 0) { + printf("Cannot enable promiscuous mode: err=%s, port=%u\n", + rte_strerror(-ret), port_id); + return ret; + } + + ret = rte_eth_macaddr_get(port_id, &bbdev_port_eth_addr); + if (ret < 0) { + printf("rte_eth_macaddr_get: err=%d, queue=%u\n", + ret, q); + return -1; + } - rte_eth_macaddr_get(port_id, &bbdev_port_eth_addr); print_mac(port_id, &bbdev_port_eth_addr); return 0; @@ -616,8 +629,16 @@ print_stats(struct stats_lcore_params *stats_lcore) xstats[i].value); } + ret = rte_bbdev_stats_get(bbdev_id, &bbstats); + if (ret < 0) { + free(xstats); + free(xstats_names); + rte_exit(EXIT_FAILURE, + "ERROR(%d): Failure to get BBDEV %u statistics\n", + ret, bbdev_id); + } + printf("\nBBDEV STATISTICS:\n=================\n"); - rte_bbdev_stats_get(bbdev_id, &bbstats); printf("BBDEV %u: %s enqueue count:\t\t%"PRIu64"\n", bbdev_id, stats_border, bbstats.enqueued_count); @@ -638,6 +659,8 @@ print_stats(struct stats_lcore_params *stats_lcore) print_lcore_stats(stats_lcore->lconf[l_id].lcore_stats, l_id); } + fflush(stdout); + free(xstats); free(xstats_names); } @@ -704,14 +727,14 @@ run_encoding(struct lcore_conf *lcore_conf) char *data; const uint16_t pkt_data_len = rte_pktmbuf_data_len(rx_pkts_burst[i]) - - sizeof(struct ether_hdr); + sizeof(struct rte_ether_hdr); /* save input mbuf pointer for later comparison */ enc_out_pkts[i]->userdata = rx_pkts_burst[i]; /* copy ethernet header */ rte_pktmbuf_reset(enc_out_pkts[i]); data = rte_pktmbuf_append(enc_out_pkts[i], - sizeof(struct ether_hdr)); + sizeof(struct rte_ether_hdr)); if (data == NULL) { printf( "Not enough space for ethernet header in encoder output mbuf\n"); @@ -725,7 +748,7 @@ run_encoding(struct lcore_conf *lcore_conf) bbdev_ops_burst[i]->turbo_enc.input.data = rx_pkts_burst[i]; bbdev_ops_burst[i]->turbo_enc.input.offset = - sizeof(struct ether_hdr); + sizeof(struct rte_ether_hdr); /* Encoder will attach the CRC24B, adjust the length */ bbdev_ops_burst[i]->turbo_enc.input.length = in_data_len; @@ -743,7 +766,7 @@ run_encoding(struct lcore_conf *lcore_conf) bbdev_ops_burst[i]->turbo_enc.output.data = enc_out_pkts[i]; bbdev_ops_burst[i]->turbo_enc.output.offset = - sizeof(struct ether_hdr); + sizeof(struct rte_ether_hdr); } /* Enqueue packets on BBDevice */ @@ -831,15 +854,15 @@ run_decoding(struct lcore_conf *lcore_conf) bbdev_ops_burst[i]->turbo_dec.input.data = recv_pkts_burst[i]; bbdev_ops_burst[i]->turbo_dec.input.offset = - sizeof(struct ether_hdr); + sizeof(struct rte_ether_hdr); bbdev_ops_burst[i]->turbo_dec.input.length = rte_pktmbuf_data_len(recv_pkts_burst[i]) - - sizeof(struct ether_hdr); + - sizeof(struct rte_ether_hdr); bbdev_ops_burst[i]->turbo_dec.hard_output.data = recv_pkts_burst[i]; bbdev_ops_burst[i]->turbo_dec.hard_output.offset = - sizeof(struct ether_hdr); + sizeof(struct rte_ether_hdr); } /* Enqueue packets on BBDevice */ @@ -1009,7 +1032,7 @@ int main(int argc, char **argv) { int ret; - unsigned int nb_bbdevs, nb_ports, flags, lcore_id; + 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; @@ -1071,12 +1094,10 @@ main(int argc, char **argv) nb_bbdevs, app_params.bbdev_id); printf("Number of bbdevs detected: %d\n", nb_bbdevs); - /* Get the number of available ethdev devices */ - nb_ports = rte_eth_dev_count(); - if (nb_ports <= app_params.port_id) + if (!rte_eth_dev_is_valid_port(app_params.port_id)) rte_exit(EXIT_FAILURE, - "%u ports detected, cannot use port with ID %u!\n", - nb_ports, app_params.port_id); + "cannot use port with ID %u!\n", + app_params.port_id); /* create the mbuf mempool for ethdev pkts */ ethdev_mbuf_mempool = rte_pktmbuf_pool_create("ethdev_mbuf_pool",