X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fload_balancer%2Finit.c;h=08f9cc6eb263702672acf84ac63efd1bf35df26e;hb=89ce4b02c6af3c3f2b3635c35387711f7aeeeb5a;hp=aeff5ca6d81328bb0cad94fb39868eb7ff4b9f2e;hpb=81f7ecd934372fc9f592d1322f8eff86350fa4f5;p=dpdk.git diff --git a/examples/load_balancer/init.c b/examples/load_balancer/init.c index aeff5ca6d8..08f9cc6eb2 100644 --- a/examples/load_balancer/init.c +++ b/examples/load_balancer/init.c @@ -47,10 +47,7 @@ #include #include #include -#include -#include #include -#include #include #include #include @@ -82,7 +79,7 @@ static struct rte_eth_conf port_conf = { .hw_ip_checksum = 1, /**< IP checksum offload enabled */ .hw_vlan_filter = 0, /**< VLAN filtering disabled */ .jumbo_frame = 0, /**< Jumbo Frame Support disabled */ - .hw_strip_crc = 0, /**< CRC stripped by hardware */ + .hw_strip_crc = 1, /**< CRC stripped by hardware */ }, .rx_adv_conf = { .rss_conf = { @@ -128,16 +125,10 @@ app_init_mbuf_pools(void) snprintf(name, sizeof(name), "mbuf_pool_%u", socket); printf("Creating the mbuf pool for socket %u ...\n", socket); - app.pools[socket] = rte_mempool_create( - name, - APP_DEFAULT_MEMPOOL_BUFFERS, - APP_DEFAULT_MBUF_SIZE, + app.pools[socket] = rte_pktmbuf_pool_create( + name, APP_DEFAULT_MEMPOOL_BUFFERS, APP_DEFAULT_MEMPOOL_CACHE_SIZE, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - socket, - 0); + 0, APP_DEFAULT_MBUF_DATA_SIZE, socket); if (app.pools[socket] == NULL) { rte_panic("Cannot create mbuf pool on socket %u\n", socket); } @@ -167,13 +158,17 @@ app_init_lpm_tables(void) continue; } + struct rte_lpm_config lpm_config; + + lpm_config.max_rules = APP_MAX_LPM_RULES; + lpm_config.number_tbl8s = 256; + lpm_config.flags = 0; snprintf(name, sizeof(name), "lpm_table_%u", socket); printf("Creating the LPM table for socket %u ...\n", socket); app.lpm_tables[socket] = rte_lpm_create( name, socket, - APP_MAX_LPM_RULES, - 0); + &lpm_config); if (app.lpm_tables[socket] == NULL) { rte_panic("Unable to create LPM table on socket %u\n", socket); } @@ -312,7 +307,7 @@ app_init_rings_tx(void) continue; } - if (app_get_lcore_for_nic_tx((uint8_t) port, &lcore_io) < 0) { + if (app_get_lcore_for_nic_tx(port, &lcore_io) < 0) { rte_panic("Algorithmic error (no I/O core to handle TX of port %u)\n", port); } @@ -363,11 +358,12 @@ app_init_rings_tx(void) /* Check the link status of all ports in up to 9s, and print them finally */ static void -check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) +check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) { #define CHECK_INTERVAL 100 /* 100ms */ #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */ - uint8_t portid, count, all_ports_up, print_flag = 0; + uint16_t portid; + uint8_t count, all_ports_up, print_flag = 0; struct rte_eth_link link; uint32_t n_rx_queues, n_tx_queues; @@ -387,18 +383,17 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) /* print link status if flag set */ if (print_flag == 1) { if (link.link_status) - printf("Port %d Link Up - speed %u " - "Mbps - %s\n", (uint8_t)portid, - (unsigned)link.link_speed, + printf( + "Port%d Link Up - speed %uMbps - %s\n", + portid, link.link_speed, (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex\n")); else - printf("Port %d Link Down\n", - (uint8_t)portid); + printf("Port %d Link Down\n", portid); continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == 0) { + if (link.link_status == ETH_LINK_DOWN) { all_ports_up = 0; break; } @@ -426,13 +421,16 @@ app_init_nics(void) { unsigned socket; uint32_t lcore; - uint8_t port, queue; + uint16_t port; + uint8_t queue; int ret; uint32_t n_rx_queues, n_tx_queues; /* Init NIC ports and queues, then start the ports */ for (port = 0; port < APP_MAX_NIC_PORTS; port ++) { struct rte_mempool *pool; + uint16_t nic_rx_ring_size; + uint16_t nic_tx_ring_size; n_rx_queues = app_get_nic_rx_queues_per_port(port); n_tx_queues = app.nic_tx_port_mask[port]; @@ -442,17 +440,28 @@ app_init_nics(void) } /* Init port */ - printf("Initializing NIC port %u ...\n", (unsigned) port); + printf("Initializing NIC port %u ...\n", port); ret = rte_eth_dev_configure( port, (uint8_t) n_rx_queues, (uint8_t) n_tx_queues, &port_conf); if (ret < 0) { - rte_panic("Cannot init NIC port %u (%d)\n", (unsigned) port, ret); + rte_panic("Cannot init NIC port %u (%d)\n", port, ret); } rte_eth_promiscuous_enable(port); + nic_rx_ring_size = app.nic_rx_ring_size; + nic_tx_ring_size = app.nic_tx_ring_size; + ret = rte_eth_dev_adjust_nb_rx_tx_desc( + port, &nic_rx_ring_size, &nic_tx_ring_size); + if (ret < 0) { + rte_panic("Cannot adjust number of descriptors for port %u (%d)\n", + port, ret); + } + app.nic_rx_ring_size = nic_rx_ring_size; + app.nic_tx_ring_size = nic_tx_ring_size; + /* Init RX queues */ for (queue = 0; queue < APP_MAX_RX_QUEUES_PER_NIC_PORT; queue ++) { if (app.nic_rx_queue_mask[port][queue] == 0) { @@ -464,8 +473,7 @@ app_init_nics(void) pool = app.lcore_params[lcore].pool; printf("Initializing NIC port %u RX queue %u ...\n", - (unsigned) port, - (unsigned) queue); + port, queue); ret = rte_eth_rx_queue_setup( port, queue, @@ -475,9 +483,7 @@ app_init_nics(void) pool); if (ret < 0) { rte_panic("Cannot init RX queue %u for port %u (%d)\n", - (unsigned) queue, - (unsigned) port, - ret); + queue, port, ret); } } @@ -486,7 +492,7 @@ app_init_nics(void) app_get_lcore_for_nic_tx(port, &lcore); socket = rte_lcore_to_socket_id(lcore); printf("Initializing NIC port %u TX queue 0 ...\n", - (unsigned) port); + port); ret = rte_eth_tx_queue_setup( port, 0,