X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fload_balancer%2Fconfig.c;h=faf5198305b0169cce6c3992c3a6b65a5d1026a0;hb=4c00cfdc0ea225f2518a35db928ad1ab02b2a724;hp=c5992cc2d63adbc3a78922426dc2e0ca6b1532c9;hpb=1c1d4d7a923d4804f1926fc5264f9ecdd8977b04;p=dpdk.git diff --git a/examples/load_balancer/config.c b/examples/load_balancer/config.c index c5992cc2d6..faf5198305 100644 --- a/examples/load_balancer/config.c +++ b/examples/load_balancer/config.c @@ -1,13 +1,13 @@ /*- * BSD LICENSE - * - * Copyright(c) 2010-2013 Intel Corporation. All rights reserved. + * + * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright @@ -17,7 +17,7 @@ * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -47,10 +47,7 @@ #include #include #include -#include -#include #include -#include #include #include #include @@ -64,7 +61,6 @@ #include #include #include -#include #include #include #include @@ -155,7 +151,7 @@ str_to_unsigned_array( int i, num_splits = 0; /* copy s so we don't modify original string */ - rte_snprintf(str, sizeof(str), "%s", s); + snprintf(str, sizeof(str), "%s", s); num_splits = rte_strsplit(str, sizeof(str), splits, num_vals, separator); errno = 0; @@ -232,7 +228,9 @@ parse_arg_rx(const char *arg) return -7; } lp->type = e_APP_LCORE_IO; - for (i = 0; i < lp->io.rx.n_nic_queues; i ++) { + const size_t n_queues = RTE_MIN(lp->io.rx.n_nic_queues, + RTE_DIM(lp->io.rx.nic_queues)); + for (i = 0; i < n_queues; i ++) { if ((lp->io.rx.nic_queues[i].port == port) && (lp->io.rx.nic_queues[i].queue == queue)) { return -8; @@ -241,7 +239,7 @@ parse_arg_rx(const char *arg) if (lp->io.rx.n_nic_queues >= APP_MAX_NIC_RX_QUEUES_PER_IO_LCORE) { return -9; } - lp->io.rx.nic_queues[lp->io.rx.n_nic_queues].port = (uint8_t) port; + lp->io.rx.nic_queues[lp->io.rx.n_nic_queues].port = port; lp->io.rx.nic_queues[lp->io.rx.n_nic_queues].queue = (uint8_t) queue; lp->io.rx.n_nic_queues ++; @@ -309,7 +307,9 @@ parse_arg_tx(const char *arg) return -7; } lp->type = e_APP_LCORE_IO; - for (i = 0; i < lp->io.tx.n_nic_ports; i ++) { + const size_t n_ports = RTE_MIN(lp->io.tx.n_nic_ports, + RTE_DIM(lp->io.tx.nic_ports)); + for (i = 0; i < n_ports; i ++) { if (lp->io.tx.nic_ports[i] == port) { return -8; } @@ -317,7 +317,7 @@ parse_arg_tx(const char *arg) if (lp->io.tx.n_nic_ports >= APP_MAX_NIC_TX_PORTS_PER_IO_LCORE) { return -9; } - lp->io.tx.nic_ports[lp->io.tx.n_nic_ports] = (uint8_t) port; + lp->io.tx.nic_ports[lp->io.tx.n_nic_ports] = port; lp->io.tx.n_nic_ports ++; n_tuples ++; @@ -487,7 +487,7 @@ app_check_lpm_table(void) static int app_check_every_rx_port_is_tx_enabled(void) { - uint8_t port; + uint16_t port; for (port = 0; port < APP_MAX_NIC_PORTS; port ++) { if ((app_get_nic_rx_queues_per_port(port) > 0) && (app.nic_tx_port_mask[port] == 0)) { @@ -756,12 +756,12 @@ app_parse_args(int argc, char **argv) argv[optind - 1] = prgname; ret = optind - 1; - optind = 0; /* reset getopt lib */ + optind = 1; /* reset getopt lib */ return ret; } int -app_get_nic_rx_queues_per_port(uint8_t port) +app_get_nic_rx_queues_per_port(uint16_t port) { uint32_t i, count; @@ -780,7 +780,7 @@ app_get_nic_rx_queues_per_port(uint8_t port) } int -app_get_lcore_for_nic_rx(uint8_t port, uint8_t queue, uint32_t *lcore_out) +app_get_lcore_for_nic_rx(uint16_t port, uint8_t queue, uint32_t *lcore_out) { uint32_t lcore; @@ -792,7 +792,9 @@ app_get_lcore_for_nic_rx(uint8_t port, uint8_t queue, uint32_t *lcore_out) continue; } - for (i = 0; i < lp->rx.n_nic_queues; i ++) { + const size_t n_queues = RTE_MIN(lp->rx.n_nic_queues, + RTE_DIM(lp->rx.nic_queues)); + for (i = 0; i < n_queues; i ++) { if ((lp->rx.nic_queues[i].port == port) && (lp->rx.nic_queues[i].queue == queue)) { *lcore_out = lcore; @@ -805,7 +807,7 @@ app_get_lcore_for_nic_rx(uint8_t port, uint8_t queue, uint32_t *lcore_out) } int -app_get_lcore_for_nic_tx(uint8_t port, uint32_t *lcore_out) +app_get_lcore_for_nic_tx(uint16_t port, uint32_t *lcore_out) { uint32_t lcore; @@ -817,7 +819,9 @@ app_get_lcore_for_nic_tx(uint8_t port, uint32_t *lcore_out) continue; } - for (i = 0; i < lp->tx.n_nic_ports; i ++) { + const size_t n_ports = RTE_MIN(lp->tx.n_nic_ports, + RTE_DIM(lp->tx.nic_ports)); + for (i = 0; i < n_ports; i ++) { if (lp->tx.nic_ports[i] == port) { *lcore_out = lcore; return 0; @@ -896,7 +900,7 @@ app_print_params(void) /* Print NIC RX configuration */ printf("NIC RX ports: "); for (port = 0; port < APP_MAX_NIC_PORTS; port ++) { - uint32_t n_rx_queues = app_get_nic_rx_queues_per_port((uint8_t) port); + uint32_t n_rx_queues = app_get_nic_rx_queues_per_port(port); if (n_rx_queues == 0) { continue;