examples/load_balancer: update
authorIntel <intel.com>
Wed, 19 Dec 2012 23:00:00 +0000 (00:00 +0100)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Thu, 25 Jul 2013 13:58:01 +0000 (15:58 +0200)
Signed-off-by: Intel
examples/load_balancer/config.c
examples/load_balancer/init.c
examples/load_balancer/main.h
examples/load_balancer/runtime.c

index e82ba86..1e14bed 100644 (file)
@@ -892,7 +892,7 @@ app_get_lcores_worker(void)
 void
 app_print_params(void)
 {
-       uint32_t port, queue, lcore, rule, i, j;
+       unsigned port, queue, lcore, rule, i, j;
 
        /* Print NIC RX configuration */
        printf("NIC RX ports: ");
@@ -927,8 +927,8 @@ app_print_params(void)
                printf("RX ports  ");
                for (i = 0; i < lp->rx.n_nic_queues; i ++) {
                        printf("(%u, %u)  ",
-                               (uint32_t) lp->rx.nic_queues[i].port,
-                               (uint32_t) lp->rx.nic_queues[i].queue);
+                               (unsigned) lp->rx.nic_queues[i].port,
+                               (unsigned) lp->rx.nic_queues[i].queue);
                }
                printf("; ");
 
@@ -950,7 +950,7 @@ app_print_params(void)
                printf("Worker lcore %u (socket %u) ID %u: ",
                        lcore,
                        rte_lcore_to_socket_id(lcore),
-                       lp->worker_id);
+                       (unsigned)lp->worker_id);
 
                printf("Input rings  ");
                for (i = 0; i < lp->n_rings_in; i ++) {
@@ -1009,7 +1009,7 @@ app_print_params(void)
                printf("Worker lcore %u (socket %u) ID %u: \n",
                        lcore,
                        rte_lcore_to_socket_id(lcore),
-                       lp->worker_id);
+                       (unsigned)lp->worker_id);
 
                printf("Output rings per TX port  ");
                for (port = 0; port < APP_MAX_NIC_PORTS; port ++) {
@@ -1030,28 +1030,28 @@ app_print_params(void)
 
                printf("\t%u: %u.%u.%u.%u/%u => %u;\n",
                        rule,
-                       (ip & 0xFF000000) >> 24,
-                       (ip & 0x00FF0000) >> 16,
-                       (ip & 0x0000FF00) >> 8,
-                       ip & 0x000000FF,
-                       (uint32_t) depth,
-                       (uint32_t) if_out
+                       (unsigned) (ip & 0xFF000000) >> 24,
+                       (unsigned) (ip & 0x00FF0000) >> 16,
+                       (unsigned) (ip & 0x0000FF00) >> 8,
+                       (unsigned) ip & 0x000000FF,
+                       (unsigned) depth,
+                       (unsigned) if_out
                );
        }
 
        /* Rings */
        printf("Ring sizes: NIC RX = %u; Worker in = %u; Worker out = %u; NIC TX = %u;\n",
-               app.nic_rx_ring_size,
-               app.ring_rx_size,
-               app.ring_tx_size,
-               app.nic_tx_ring_size);
+               (unsigned) app.nic_rx_ring_size,
+               (unsigned) app.ring_rx_size,
+               (unsigned) app.ring_tx_size,
+               (unsigned) app.nic_tx_ring_size);
 
        /* Bursts */
        printf("Burst sizes: I/O RX (rd = %u, wr = %u); Worker (rd = %u, wr = %u); I/O TX (rd = %u, wr = %u)\n",
-               app.burst_size_io_rx_read,
-               app.burst_size_io_rx_write,
-               app.burst_size_worker_read,
-               app.burst_size_worker_write,
-               app.burst_size_io_tx_read,
-               app.burst_size_io_tx_write);
+               (unsigned) app.burst_size_io_rx_read,
+               (unsigned) app.burst_size_io_rx_write,
+               (unsigned) app.burst_size_worker_read,
+               (unsigned) app.burst_size_worker_write,
+               (unsigned) app.burst_size_io_tx_read,
+               (unsigned) app.burst_size_io_tx_write);
 }
index b95b8a3..ae36d5e 100644 (file)
@@ -87,7 +87,7 @@ static struct rte_eth_conf port_conf = {
        .rx_adv_conf = {
                .rss_conf = {
                        .rss_key = NULL,
-                       .rss_hf = ETH_RSS_IPV4,
+                       .rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6,
                },
        },
        .txmode = {
@@ -102,6 +102,7 @@ static struct rte_eth_rxconf rx_conf = {
                .wthresh = APP_DEFAULT_NIC_RX_WTHRESH,
        },
        .rx_free_thresh = APP_DEFAULT_NIC_RX_FREE_THRESH,
+       .rx_drop_en = APP_DEFAULT_NIC_RX_DROP_EN,
 };
 
 static struct rte_eth_txconf tx_conf = {
@@ -136,7 +137,7 @@ app_assign_worker_ids(void)
 static void
 app_init_mbuf_pools(void)
 {
-       uint32_t socket, lcore;
+       unsigned socket, lcore;
 
        /* Init the buffer pools */
        for (socket = 0; socket < APP_MAX_SOCKETS; socket ++) {
@@ -175,7 +176,7 @@ app_init_mbuf_pools(void)
 static void
 app_init_lpm_tables(void)
 {
-       uint32_t socket, lcore;
+       unsigned socket, lcore;
 
        /* Init the LPM tables */
        for (socket = 0; socket < APP_MAX_SOCKETS; socket ++) {
@@ -207,9 +208,10 @@ app_init_lpm_tables(void)
 
                        if (ret < 0) {
                                rte_panic("Unable to add entry %u (%x/%u => %u) to the LPM table on socket %u (%d)\n",
-                                       rule, app.lpm_rules[rule].ip,
-                                       (uint32_t) app.lpm_rules[rule].depth,
-                                       (uint32_t) app.lpm_rules[rule].if_out,
+                                       (unsigned) rule,
+                                       (unsigned) app.lpm_rules[rule].ip,
+                                       (unsigned) app.lpm_rules[rule].depth,
+                                       (unsigned) app.lpm_rules[rule].if_out,
                                        socket,
                                        ret);
                        }
@@ -230,12 +232,12 @@ app_init_lpm_tables(void)
 static void
 app_init_rings_rx(void)
 {
-       uint32_t lcore;
+       unsigned lcore;
 
        /* Initialize the rings for the RX side */
        for (lcore = 0; lcore < APP_MAX_LCORES; lcore ++) {
                struct app_lcore_params_io *lp_io = &app.lcore_params[lcore].io;
-               uint32_t socket_io, lcore_worker;
+               unsigned socket_io, lcore_worker;
 
                if ((app.lcore_params[lcore].type != e_APP_LCORE_IO) ||
                    (lp_io->rx.n_nic_queues == 0)) {
@@ -309,12 +311,12 @@ app_init_rings_rx(void)
 static void
 app_init_rings_tx(void)
 {
-       uint32_t lcore;
+       unsigned lcore;
 
        /* Initialize the rings for the TX side */
        for (lcore = 0; lcore < APP_MAX_LCORES; lcore ++) {
                struct app_lcore_params_worker *lp_worker = &app.lcore_params[lcore].worker;
-               uint32_t port;
+               unsigned port;
 
                if (app.lcore_params[lcore].type != e_APP_LCORE_WORKER) {
                        continue;
@@ -339,7 +341,7 @@ app_init_rings_tx(void)
                        socket_io = rte_lcore_to_socket_id(lcore_io);
 
                        printf("Creating ring to connect worker lcore %u with TX port %u (through I/O lcore %u) (socket %u) ...\n",
-                               lcore, port, lcore_io, socket_io);
+                               lcore, port, (unsigned)lcore_io, (unsigned)socket_io);
                        rte_snprintf(name, sizeof(name), "app_ring_tx_s%u_w%u_p%u", socket_io, lcore, port);
                        ring = rte_ring_create(
                                name,
@@ -359,7 +361,7 @@ app_init_rings_tx(void)
 
        for (lcore = 0; lcore < APP_MAX_LCORES; lcore ++) {
                struct app_lcore_params_io *lp_io = &app.lcore_params[lcore].io;
-               uint32_t i;
+               unsigned i;
 
                if ((app.lcore_params[lcore].type != e_APP_LCORE_IO) ||
                    (lp_io->tx.n_nic_ports == 0)) {
@@ -367,7 +369,7 @@ app_init_rings_tx(void)
                }
 
                for (i = 0; i < lp_io->tx.n_nic_ports; i ++){
-                       uint32_t port, j;
+                       unsigned port, j;
 
                        port = lp_io->tx.nic_ports[i];
                        for (j = 0; j < app_get_lcores_worker(); j ++) {
@@ -442,9 +444,11 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 static void
 app_init_nics(void)
 {
-       uint32_t socket, lcore;
-       uint8_t port, queue;
+       unsigned socket;
+       uint32_t lcore;
+       uint8_t port, queue;
        int ret;
+       uint32_t n_rx_queues, n_tx_queues;
 
        /* Init driver */
        printf("Initializing the PMD driver ...\n");
@@ -459,7 +463,6 @@ app_init_nics(void)
        /* Init NIC ports and queues, then start the ports */
        for (port = 0; port < APP_MAX_NIC_PORTS; port ++) {
                struct rte_mempool *pool;
-               uint32_t n_rx_queues, n_tx_queues;
 
                n_rx_queues = app_get_nic_rx_queues_per_port(port);
                n_tx_queues = app.nic_tx_port_mask[port];
@@ -469,14 +472,14 @@ app_init_nics(void)
                }
 
                /* Init port */
-               printf("Initializing NIC port %u ...\n", (uint32_t) port);
+               printf("Initializing NIC port %u ...\n", (unsigned) 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", (uint32_t) port, ret);
+                       rte_panic("Cannot init NIC port %u (%d)\n", (unsigned) port, ret);
                }
                rte_eth_promiscuous_enable(port);
 
@@ -491,8 +494,8 @@ app_init_nics(void)
                        pool = app.lcore_params[lcore].pool;
 
                        printf("Initializing NIC port %u RX queue %u ...\n",
-                               (uint32_t) port,
-                               (uint32_t) queue);
+                               (unsigned) port,
+                               (unsigned) queue);
                        ret = rte_eth_rx_queue_setup(
                                port,
                                queue,
@@ -502,8 +505,8 @@ app_init_nics(void)
                                pool);
                        if (ret < 0) {
                                rte_panic("Cannot init RX queue %u for port %u (%d)\n",
-                                       (uint32_t) queue,
-                                       (uint32_t) port,
+                                       (unsigned) queue,
+                                       (unsigned) port,
                                        ret);
                        }
                }
@@ -513,7 +516,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",
-                               (uint32_t) port);
+                               (unsigned) port);
                        ret = rte_eth_tx_queue_setup(
                                port,
                                0,
index a1bca7e..bf59614 100644 (file)
@@ -88,7 +88,7 @@
 #endif
 
 #ifndef APP_DEFAULT_MEMPOOL_BUFFERS
-#define APP_DEFAULT_MEMPOOL_BUFFERS   8192
+#define APP_DEFAULT_MEMPOOL_BUFFERS   8192 * 4
 #endif
 
 #ifndef APP_DEFAULT_MEMPOOL_CACHE_SIZE
 #define APP_DEFAULT_NIC_RX_FREE_THRESH  64
 #endif
 
+#ifndef APP_DEFAULT_NIC_RX_DROP_EN
+#define APP_DEFAULT_NIC_RX_DROP_EN 0
+#endif
+
 /* NIC TX */
 #ifndef APP_DEFAULT_NIC_TX_RING_SIZE
 #define APP_DEFAULT_NIC_TX_RING_SIZE 1024
index df3a3a0..8ee6e26 100644 (file)
@@ -165,11 +165,11 @@ app_lcore_io_rx_buffer_to_send (
                lp->rx.rings_count[worker] ++;
        }
        if (unlikely(lp->rx.rings_iters[worker] == APP_STATS)) {
-               uint32_t lcore = rte_lcore_id();
+               unsigned lcore = rte_lcore_id();
 
                printf("\tI/O RX %u out (worker %u): enq success rate = %.2f\n",
                        lcore,
-                       worker,
+                       (unsigned)worker,
                        ((double) lp->rx.rings_count[worker]) / ((double) lp->rx.rings_iters[worker]));
                lp->rx.rings_iters[worker] = 0;
                lp->rx.rings_count[worker] = 0;
@@ -186,7 +186,7 @@ app_lcore_io_rx(
        uint8_t pos_lb)
 {
        struct rte_mbuf *mbuf_1_0, *mbuf_1_1, *mbuf_2_0, *mbuf_2_1;
-       uint8_t *data_1_0, *data_1_1;
+       uint8_t *data_1_0, *data_1_1 = NULL;
        uint32_t i;
 
        for (i = 0; i < lp->rx.n_nic_queues; i ++) {
@@ -209,13 +209,13 @@ app_lcore_io_rx(
                lp->rx.nic_queues_count[i] += n_mbufs;
                if (unlikely(lp->rx.nic_queues_iters[i] == APP_STATS)) {
                        struct rte_eth_stats stats;
-                       uint32_t lcore = rte_lcore_id();
+                       unsigned lcore = rte_lcore_id();
 
                        rte_eth_stats_get(port, &stats);
 
                        printf("I/O RX %u in (NIC port %u): NIC drop ratio = %.2f avg burst size = %.2f\n",
                                lcore,
-                               (uint32_t) port,
+                               (unsigned) port,
                                (double) stats.ierrors / (double) (stats.ierrors + stats.ipackets),
                                ((double) lp->rx.nic_queues_count[i]) / ((double) lp->rx.nic_queues_iters[i]));
                        lp->rx.nic_queues_iters[i] = 0;
@@ -392,11 +392,11 @@ app_lcore_io_tx(
                        lp->tx.nic_ports_iters[port] ++;
                        lp->tx.nic_ports_count[port] += n_pkts;
                        if (unlikely(lp->tx.nic_ports_iters[port] == APP_STATS)) {
-                               uint32_t lcore = rte_lcore_id();
+                               unsigned lcore = rte_lcore_id();
 
                                printf("\t\t\tI/O TX %u out (port %u): avg burst size = %.2f\n",
                                        lcore,
-                                       (uint32_t) port,
+                                       (unsigned) port,
                                        ((double) lp->tx.nic_ports_count[port]) / ((double) lp->tx.nic_ports_iters[port]));
                                lp->tx.nic_ports_iters[port] = 0;
                                lp->tx.nic_ports_count[port] = 0;
@@ -564,8 +564,8 @@ app_lcore_worker(
                        }
                        if (lp->rings_out_iters[port] == APP_STATS){
                                printf("\t\tWorker %u out (NIC port %u): enq success rate = %.2f\n",
-                                       lp->worker_id,
-                                       (uint32_t) port,
+                                       (unsigned) lp->worker_id,
+                                       (unsigned) port,
                                        ((double) lp->rings_out_count[port]) / ((double) lp->rings_out_iters[port]));
                                lp->rings_out_iters[port] = 0;
                                lp->rings_out_count[port] = 0;
@@ -647,7 +647,7 @@ int
 app_lcore_main_loop(__attribute__((unused)) void *arg)
 {
        struct app_lcore_params *lp;
-       uint32_t lcore;
+       unsigned lcore;
 
        lcore = rte_lcore_id();
        lp = &app.lcore_params[lcore];
@@ -660,7 +660,7 @@ app_lcore_main_loop(__attribute__((unused)) void *arg)
        if (lp->type == e_APP_LCORE_WORKER) {
                printf("Logical core %u (worker %u) main loop.\n",
                        lcore,
-                       lp->worker.worker_id);
+                       (unsigned) lp->worker.worker_id);
                app_lcore_main_loop_worker();
        }