examples: adjust Rx and Tx descriptors to device limits
[dpdk.git] / examples / l2fwd-keepalive / main.c
index 5fdbdef..3c6a9d3 100644 (file)
@@ -567,6 +567,7 @@ main(int argc, char **argv)
        unsigned lcore_id, rx_lcore_id;
        unsigned nb_ports_in_mask = 0;
        struct sigaction signal_handler;
+       struct rte_keepalive_shm *ka_shm;
 
        memset(&signal_handler, 0, sizeof(signal_handler));
        terminate_signal_received = 0;
@@ -676,6 +677,13 @@ main(int argc, char **argv)
                                "Cannot configure device: err=%d, port=%u\n",
                                ret, (unsigned) portid);
 
+               ret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd,
+                                                      &nb_txd);
+               if (ret < 0)
+                       rte_exit(EXIT_FAILURE,
+                               "Cannot adjust number of descriptors: err=%d, port=%u\n",
+                               ret, (unsigned) portid);
+
                rte_eth_macaddr_get(portid, &l2fwd_ports_eth_addr[portid]);
 
                /* init one RX queue */
@@ -751,9 +759,8 @@ main(int argc, char **argv)
        rte_timer_subsystem_init();
        rte_timer_init(&stats_timer);
 
+       ka_shm = NULL;
        if (check_period > 0) {
-               struct rte_keepalive_shm *ka_shm;
-
                ka_shm = rte_keepalive_shm_create();
                if (ka_shm == NULL)
                        rte_exit(EXIT_FAILURE,
@@ -813,5 +820,7 @@ main(int argc, char **argv)
                        return -1;
        }
 
+       if (ka_shm != NULL)
+               rte_keepalive_shm_cleanup(ka_shm);
        return 0;
 }