X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fdistributor%2Fmain.c;h=02bf91f555f72dadc4cc6b4fdeb26b713116fa30;hb=5729407fa4d612b93ceefacef13f57c1de2ceaa6;hp=81d7ca61d108d601a441776761879da5a4d3c10e;hpb=35b2d13fd6fdcbd191f2a30d74648faeb1186c65;p=dpdk.git diff --git a/examples/distributor/main.c b/examples/distributor/main.c index 81d7ca61d1..02bf91f555 100644 --- a/examples/distributor/main.c +++ b/examples/distributor/main.c @@ -80,16 +80,15 @@ struct app_stats prev_app_stats; static const struct rte_eth_conf port_conf_default = { .rxmode = { - .mq_mode = ETH_MQ_RX_RSS, - .max_rx_pkt_len = RTE_ETHER_MAX_LEN, + .mq_mode = RTE_ETH_MQ_RX_RSS, }, .txmode = { - .mq_mode = ETH_MQ_TX_NONE, + .mq_mode = RTE_ETH_MQ_TX_NONE, }, .rx_adv_conf = { .rss_conf = { - .rss_hf = ETH_RSS_IP | ETH_RSS_UDP | - ETH_RSS_TCP | ETH_RSS_SCTP, + .rss_hf = RTE_ETH_RSS_IP | RTE_ETH_RSS_UDP | + RTE_ETH_RSS_TCP | RTE_ETH_RSS_SCTP, } }, }; @@ -109,7 +108,7 @@ static inline int port_init(uint16_t port, struct rte_mempool *mbuf_pool) { struct rte_eth_conf port_conf = port_conf_default; - const uint16_t rxRings = 1, txRings = rte_lcore_count() - 1; + const uint16_t rxRings = 1, txRings = 1; int retval; uint16_t q; uint16_t nb_rxd = RX_RING_SIZE; @@ -120,10 +119,16 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool) if (!rte_eth_dev_is_valid_port(port)) return -1; - rte_eth_dev_info_get(port, &dev_info); - if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) + retval = rte_eth_dev_info_get(port, &dev_info); + if (retval != 0) { + printf("Error during getting device (port %u) info: %s\n", + port, strerror(-retval)); + return retval; + } + + if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) port_conf.txmode.offloads |= - DEV_TX_OFFLOAD_MBUF_FAST_FREE; + RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE; port_conf.rx_adv_conf.rss_conf.rss_hf &= dev_info.flow_type_rss_offloads; @@ -167,12 +172,18 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool) return retval; struct rte_eth_link link; - rte_eth_link_get_nowait(port, &link); - while (!link.link_status) { + do { + retval = rte_eth_link_get_nowait(port, &link); + if (retval < 0) { + printf("Failed link get (port %u): %s\n", + port, rte_strerror(-retval)); + return retval; + } else if (link.link_status) + break; + printf("Waiting for Link up on port %"PRIu16"\n", port); sleep(1); - rte_eth_link_get_nowait(port, &link); - } + } while (!link.link_status); if (!link.link_status) { printf("Link down on port %"PRIu16"\n", port); @@ -180,15 +191,20 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool) } struct rte_ether_addr addr; - rte_eth_macaddr_get(port, &addr); + retval = rte_eth_macaddr_get(port, &addr); + if (retval < 0) { + printf("Failed to get MAC address (port %u): %s\n", + port, rte_strerror(-retval)); + return retval; + } + printf("Port %u MAC: %02"PRIx8" %02"PRIx8" %02"PRIx8 " %02"PRIx8" %02"PRIx8" %02"PRIx8"\n", - port, - addr.addr_bytes[0], addr.addr_bytes[1], - addr.addr_bytes[2], addr.addr_bytes[3], - addr.addr_bytes[4], addr.addr_bytes[5]); + port, RTE_ETHER_ADDR_BYTES(&addr)); - rte_eth_promiscuous_enable(port); + retval = rte_eth_promiscuous_enable(port); + if (retval != 0) + return retval; return 0; } @@ -592,7 +608,7 @@ static int init_power_library(void) { int ret = 0, lcore_id; - RTE_LCORE_FOREACH_SLAVE(lcore_id) { + RTE_LCORE_FOREACH_WORKER(lcore_id) { /* init power management library */ ret = rte_power_init(lcore_id); if (ret) { @@ -627,10 +643,7 @@ parse_portmask(const char *portmask) /* parse hexadecimal string */ pm = strtoul(portmask, &end, 16); if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0')) - return -1; - - if (pm == 0) - return -1; + return 0; return pm; } @@ -788,7 +801,7 @@ main(int argc, char *argv[]) * available, the higher frequency cores will go to the * distributor first, then rx, then tx. */ - RTE_LCORE_FOREACH_SLAVE(lcore_id) { + RTE_LCORE_FOREACH_WORKER(lcore_id) { rte_power_get_capabilities(lcore_id, &lcore_cap); @@ -821,7 +834,7 @@ main(int argc, char *argv[]) * after the high performing core assignment above, pre-assign * them here. */ - RTE_LCORE_FOREACH_SLAVE(lcore_id) { + RTE_LCORE_FOREACH_WORKER(lcore_id) { if (lcore_id == (unsigned int)distr_core_id || lcore_id == (unsigned int)rx_core_id || lcore_id == (unsigned int)tx_core_id) @@ -852,7 +865,7 @@ main(int argc, char *argv[]) * Kick off all the worker threads first, avoiding the pre-assigned * lcore_ids for tx, rx and distributor workloads. */ - RTE_LCORE_FOREACH_SLAVE(lcore_id) { + RTE_LCORE_FOREACH_WORKER(lcore_id) { if (lcore_id == (unsigned int)distr_core_id || lcore_id == (unsigned int)rx_core_id || lcore_id == (unsigned int)tx_core_id) @@ -905,7 +918,7 @@ main(int argc, char *argv[]) usleep(1000); } - RTE_LCORE_FOREACH_SLAVE(lcore_id) { + RTE_LCORE_FOREACH_WORKER(lcore_id) { if (rte_eal_wait_lcore(lcore_id) < 0) return -1; } @@ -915,5 +928,8 @@ main(int argc, char *argv[]) rte_free(pd); rte_free(pr); + /* clean up the EAL */ + rte_eal_cleanup(); + return 0; }