X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fntb%2Fntb_fwd.c;h=54b7f08964067d4f13368d787ac949ac14fd2a92;hb=a011555fb85bbf65a1578dce7383ef1bd630be79;hp=c914256dd4ca1f571ad7a292f0e1239f885f98f8;hpb=39a19ae03d8fe6210f3e7919b29378bd3223621c;p=dpdk.git diff --git a/examples/ntb/ntb_fwd.c b/examples/ntb/ntb_fwd.c index c914256dd4..54b7f08964 100644 --- a/examples/ntb/ntb_fwd.c +++ b/examples/ntb/ntb_fwd.c @@ -19,6 +19,7 @@ #include #include #include +#include /* Per-port statistics struct */ struct ntb_port_statistics { @@ -108,9 +109,9 @@ struct cmd_help_result { }; static void -cmd_help_parsed(__attribute__((unused)) void *parsed_result, +cmd_help_parsed(__rte_unused void *parsed_result, struct cmdline *cl, - __attribute__((unused)) void *data) + __rte_unused void *data) { cmdline_printf( cl, @@ -153,15 +154,15 @@ struct cmd_quit_result { }; static void -cmd_quit_parsed(__attribute__((unused)) void *parsed_result, +cmd_quit_parsed(__rte_unused void *parsed_result, struct cmdline *cl, - __attribute__((unused)) void *data) + __rte_unused void *data) { struct ntb_fwd_lcore_conf *conf; uint32_t lcore_id; /* Stop transmission first. */ - RTE_LCORE_FOREACH_SLAVE(lcore_id) { + RTE_LCORE_FOREACH_WORKER(lcore_id) { conf = &fwd_lcore_conf[lcore_id]; if (!conf->nb_stream) @@ -208,8 +209,8 @@ struct cmd_sendfile_result { static void cmd_sendfile_parsed(void *parsed_result, - __attribute__((unused)) struct cmdline *cl, - __attribute__((unused)) void *data) + __rte_unused struct cmdline *cl, + __rte_unused void *data) { struct cmd_sendfile_result *res = parsed_result; struct rte_rawdev_buf *pkts_send[NTB_MAX_PKT_BURST]; @@ -667,7 +668,7 @@ assign_stream_to_lcores(void) uint8_t lcore_num, nb_extra; lcore_num = rte_lcore_count(); - /* Exclude master core */ + /* Exclude main core */ lcore_num--; nb_streams = (fwd_mode == IOFWD) ? num_queues * 2 : num_queues; @@ -677,7 +678,7 @@ assign_stream_to_lcores(void) sm_id = 0; i = 0; - RTE_LCORE_FOREACH_SLAVE(lcore_id) { + RTE_LCORE_FOREACH_WORKER(lcore_id) { conf = &fwd_lcore_conf[lcore_id]; if (i < nb_extra) { @@ -696,7 +697,7 @@ assign_stream_to_lcores(void) } /* Print packet forwading config. */ - RTE_LCORE_FOREACH_SLAVE(lcore_id) { + RTE_LCORE_FOREACH_WORKER(lcore_id) { conf = &fwd_lcore_conf[lcore_id]; if (!conf->nb_stream) @@ -728,6 +729,7 @@ start_pkt_fwd(void) struct rte_eth_link eth_link; uint32_t lcore_id; int ret, i; + char link_status_text[RTE_ETH_LINK_MAX_STR_LEN]; ret = ntb_fwd_config_setup(); if (ret < 0) { @@ -746,11 +748,11 @@ start_pkt_fwd(void) return; } if (eth_link.link_status) { - printf("Eth%u Link Up. Speed %u Mbps - %s\n", - eth_port_id, eth_link.link_speed, - (eth_link.link_duplex == - ETH_LINK_FULL_DUPLEX) ? - ("full-duplex") : ("half-duplex")); + rte_eth_link_to_str(link_status_text, + sizeof(link_status_text), + ð_link); + printf("Eth%u %s\n", eth_port_id, + link_status_text); break; } } @@ -764,7 +766,7 @@ start_pkt_fwd(void) assign_stream_to_lcores(); in_test = 1; - RTE_LCORE_FOREACH_SLAVE(lcore_id) { + RTE_LCORE_FOREACH_WORKER(lcore_id) { conf = &fwd_lcore_conf[lcore_id]; if (!conf->nb_stream) @@ -792,9 +794,9 @@ struct cmd_start_result { }; static void -cmd_start_parsed(__attribute__((unused)) void *parsed_result, - __attribute__((unused)) struct cmdline *cl, - __attribute__((unused)) void *data) +cmd_start_parsed(__rte_unused void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) { start_pkt_fwd(); } @@ -818,14 +820,14 @@ struct cmd_stop_result { }; static void -cmd_stop_parsed(__attribute__((unused)) void *parsed_result, - __attribute__((unused)) struct cmdline *cl, - __attribute__((unused)) void *data) +cmd_stop_parsed(__rte_unused void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) { struct ntb_fwd_lcore_conf *conf; uint32_t lcore_id; - RTE_LCORE_FOREACH_SLAVE(lcore_id) { + RTE_LCORE_FOREACH_WORKER(lcore_id) { conf = &fwd_lcore_conf[lcore_id]; if (!conf->nb_stream) @@ -982,8 +984,8 @@ struct cmd_stats_result { static void cmd_stats_parsed(void *parsed_result, - __attribute__((unused)) struct cmdline *cl, - __attribute__((unused)) void *data) + __rte_unused struct cmdline *cl, + __rte_unused void *data) { struct cmd_stats_result *res = parsed_result; if (!strcmp(res->show, "clear")) @@ -1020,9 +1022,9 @@ struct cmd_set_fwd_mode_result { }; static void -cmd_set_fwd_mode_parsed(__attribute__((unused)) void *parsed_result, - __attribute__((unused)) struct cmdline *cl, - __attribute__((unused)) void *data) +cmd_set_fwd_mode_parsed(__rte_unused void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) { struct cmd_set_fwd_mode_result *res = parsed_result; int i; @@ -1073,7 +1075,7 @@ cmdline_parse_ctx_t main_ctx[] = { NULL, }; -/* prompt function, called from main on MASTER lcore */ +/* prompt function, called from main on MAIN lcore */ static void prompt(void) { @@ -1256,6 +1258,11 @@ ntb_mbuf_pool_create(uint16_t mbuf_seg_size, uint32_t nb_mbuf, if (mp == NULL) return NULL; + if (rte_mempool_set_ops_byname(mp, rte_mbuf_best_mempool_ops(), NULL)) { + printf("error setting mempool handler\n"); + goto fail; + } + memset(&mbp_priv, 0, sizeof(mbp_priv)); mbp_priv.mbuf_data_room_size = mbuf_seg_size; mbp_priv.mbuf_priv_size = 0; @@ -1313,7 +1320,7 @@ ntb_mbuf_pool_create(uint16_t mbuf_seg_size, uint32_t nb_mbuf, mz->len - ntb_info.ntb_hdr_size, ntb_mempool_mz_free, (void *)(uintptr_t)mz); - if (ret < 0) { + if (ret <= 0) { rte_memzone_free(mz); rte_mempool_free(mp); return NULL; @@ -1383,7 +1390,7 @@ main(int argc, char **argv) rte_rawdev_set_attr(dev_id, NTB_QUEUE_NUM_NAME, num_queues); printf("Set queue number as %u.\n", num_queues); ntb_rawdev_info.dev_private = (rte_rawdev_obj_t)(&ntb_info); - rte_rawdev_info_get(dev_id, &ntb_rawdev_info); + rte_rawdev_info_get(dev_id, &ntb_rawdev_info, sizeof(ntb_info)); nb_mbuf = nb_desc * num_queues * 2 * 2 + rte_lcore_count() * MEMPOOL_CACHE_SIZE; @@ -1395,7 +1402,7 @@ main(int argc, char **argv) ntb_conf.num_queues = num_queues; ntb_conf.queue_size = nb_desc; ntb_rawdev_conf.dev_private = (rte_rawdev_obj_t)(&ntb_conf); - ret = rte_rawdev_configure(dev_id, &ntb_rawdev_conf); + ret = rte_rawdev_configure(dev_id, &ntb_rawdev_conf, sizeof(ntb_conf)); if (ret) rte_exit(EXIT_FAILURE, "Can't config ntb dev: err=%d, " "port=%u\n", ret, dev_id); @@ -1405,7 +1412,8 @@ main(int argc, char **argv) ntb_q_conf.rx_mp = mbuf_pool; for (i = 0; i < num_queues; i++) { /* Setup rawdev queue */ - ret = rte_rawdev_queue_setup(dev_id, i, &ntb_q_conf); + ret = rte_rawdev_queue_setup(dev_id, i, &ntb_q_conf, + sizeof(ntb_q_conf)); if (ret < 0) rte_exit(EXIT_FAILURE, "Failed to setup ntb queue %u.\n", i);