examples: adjust Rx and Tx descriptors to device limits
[dpdk.git] / examples / l3fwd-acl / main.c
index 621872f..1563884 100644 (file)
@@ -63,7 +63,6 @@
 #include <rte_debug.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
-#include <rte_ring.h>
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_ip.h>
@@ -72,6 +71,9 @@
 #include <rte_string_fns.h>
 #include <rte_acl.h>
 
+#if RTE_LOG_LEVEL >= RTE_LOG_DEBUG
+#define L3FWDACL_DEBUG
+#endif
 #define DO_RFC_1812_CHECKS
 
 #define RTE_LOGTYPE_L3FWD RTE_LOGTYPE_USER1
  */
 
 #define NB_MBUF        RTE_MAX(\
-       (nb_ports * nb_rx_queue*RTE_TEST_RX_DESC_DEFAULT +      \
-       nb_ports * nb_lcores * MAX_PKT_BURST +                  \
-       nb_ports * n_tx_queue * RTE_TEST_TX_DESC_DEFAULT +      \
-       nb_lcores * MEMPOOL_CACHE_SIZE),                        \
+       (nb_ports * nb_rx_queue * nb_rxd +      \
+       nb_ports * nb_lcores * MAX_PKT_BURST +  \
+       nb_ports * n_tx_queue * nb_txd +        \
+       nb_lcores * MEMPOOL_CACHE_SIZE),        \
        (unsigned)8192)
 
 #define MAX_PKT_BURST 32
@@ -161,7 +163,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 = {
@@ -1774,7 +1776,7 @@ 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;
 }
 
@@ -1893,7 +1895,6 @@ main(int argc, char **argv)
        unsigned lcore_id;
        uint32_t n_tx_queue, nb_lcores;
        uint8_t portid, nb_rx_queue, queue, socketid;
-       uint8_t nb_tx_port;
 
        /* init EAL */
        ret = rte_eal_init(argc, argv);
@@ -1915,8 +1916,6 @@ main(int argc, char **argv)
                rte_exit(EXIT_FAILURE, "init_lcore_rx_queues failed\n");
 
        nb_ports = rte_eth_dev_count();
-       if (nb_ports > RTE_MAX_ETHPORTS)
-               nb_ports = RTE_MAX_ETHPORTS;
 
        if (check_port_config(nb_ports) < 0)
                rte_exit(EXIT_FAILURE, "check_port_config failed\n");
@@ -1926,7 +1925,6 @@ main(int argc, char **argv)
                rte_exit(EXIT_FAILURE, "app_acl_init failed\n");
 
        nb_lcores = rte_lcore_count();
-       nb_tx_port = 0;
 
        /* initialize all ports */
        for (portid = 0; portid < nb_ports; portid++) {
@@ -1953,6 +1951,13 @@ main(int argc, char **argv)
                                "Cannot configure device: err=%d, port=%d\n",
                                ret, portid);
 
+               ret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd,
+                                                      &nb_txd);
+               if (ret < 0)
+                       rte_exit(EXIT_FAILURE,
+                               "rte_eth_dev_adjust_nb_rx_tx_desc: err=%d, port=%d\n",
+                               ret, portid);
+
                rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
                print_ethaddr(" Address:", &ports_eth_addr[portid]);
                printf(", ");
@@ -2008,12 +2013,10 @@ main(int argc, char **argv)
                        qconf->tx_queue_id[portid] = queueid;
                        queueid++;
 
-                       qconf->n_tx_port = nb_tx_port;
                        qconf->tx_port_id[qconf->n_tx_port] = portid;
+                       qconf->n_tx_port++;
                }
                printf("\n");
-
-               nb_tx_port++;
        }
 
        for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {