examples/l2fwd-crypto: fix stats refresh rate
[dpdk.git] / examples / l2fwd-crypto / main.c
index 83bbea8..b1e2613 100644 (file)
@@ -181,7 +181,7 @@ struct l2fwd_crypto_params {
        unsigned digest_length;
        unsigned block_size;
 
-       uint16_t cipher_dataunit_len;
+       uint32_t cipher_dataunit_len;
 
        struct l2fwd_iv cipher_iv;
        struct l2fwd_iv auth_iv;
@@ -215,12 +215,11 @@ struct lcore_queue_conf lcore_queue_conf[RTE_MAX_LCORE];
 
 static struct rte_eth_conf port_conf = {
        .rxmode = {
-               .mq_mode = ETH_MQ_RX_NONE,
-               .max_rx_pkt_len = RTE_ETHER_MAX_LEN,
+               .mq_mode = RTE_ETH_MQ_RX_NONE,
                .split_hdr_size = 0,
        },
        .txmode = {
-               .mq_mode = ETH_MQ_TX_NONE,
+               .mq_mode = RTE_ETH_MQ_TX_NONE,
        },
 };
 
@@ -253,11 +252,9 @@ struct l2fwd_port_statistics port_statistics[RTE_MAX_ETHPORTS];
 struct l2fwd_crypto_statistics crypto_statistics[RTE_CRYPTO_MAX_DEVS];
 
 /* A tsc-based timer responsible for triggering statistics printout */
-#define TIMER_MILLISECOND 2000000ULL /* around 1ms at 2 Ghz */
+#define TIMER_MILLISECOND (rte_get_tsc_hz() / 1000)
 #define MAX_TIMER_PERIOD 86400UL /* 1 day max */
-
-/* default period is 10 seconds */
-static int64_t timer_period = 10 * TIMER_MILLISECOND * 1000;
+#define DEFAULT_TIMER_PERIOD 10UL
 
 /* Print out statistics on packets dropped */
 static void
@@ -895,18 +892,17 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options)
                        }
 
                        /* if timer is enabled */
-                       if (timer_period > 0) {
+                       if (options->refresh_period > 0) {
 
                                /* advance the timer */
                                timer_tsc += diff_tsc;
 
                                /* if timer has reached its timeout */
                                if (unlikely(timer_tsc >=
-                                               (uint64_t)timer_period)) {
+                                               options->refresh_period)) {
 
                                        /* do this only on main core */
-                                       if (lcore_id == rte_get_main_lcore()
-                                               && options->refresh_period) {
+                                       if (lcore_id == rte_get_main_lcore()) {
                                                print_stats();
                                                timer_tsc = 0;
                                        }
@@ -1268,9 +1264,9 @@ l2fwd_crypto_parse_args_long_options(struct l2fwd_crypto_options *options,
 
        else if (strcmp(lgopts[option_index].name, "cipher_dataunit_len") == 0) {
                retval = parse_size(&val, optarg);
-               if (retval == 0 && val >= 0 && val <= UINT16_MAX) {
+               if (retval == 0 && val >= 0) {
                        options->cipher_xform.cipher.dataunit_len =
-                                                               (uint16_t)val;
+                                                               (uint32_t)val;
                        return 0;
                } else
                        return -1;
@@ -1482,7 +1478,8 @@ l2fwd_crypto_default_options(struct l2fwd_crypto_options *options)
 {
        options->portmask = 0xffffffff;
        options->nb_ports_per_lcore = 1;
-       options->refresh_period = 10000;
+       options->refresh_period = DEFAULT_TIMER_PERIOD *
+                                       TIMER_MILLISECOND * 1000;
        options->single_lcore = 0;
        options->sessionless = 0;
 
@@ -1808,7 +1805,7 @@ check_all_ports_link_status(uint32_t port_mask)
                                continue;
                        }
                        /* clear all_ports_up flag if any link down */
-                       if (link.link_status == ETH_LINK_DOWN) {
+                       if (link.link_status == RTE_ETH_LINK_DOWN) {
                                all_ports_up = 0;
                                break;
                        }
@@ -2219,6 +2216,11 @@ check_capabilities(struct l2fwd_crypto_options *options, uint8_t cdev_id)
                                                RTE_CRYPTO_CIPHER_DATA_UNIT_LEN_4096_BYTES))
                                                ret = -1;
                                        break;
+                               case 1048576:
+                                       if (!(cap->sym.cipher.dataunit_set &
+                                               RTE_CRYPTO_CIPHER_DATA_UNIT_LEN_1_MEGABYTES))
+                                               ret = -1;
+                                       break;
                                default:
                                        ret = -1;
                                }
@@ -2632,9 +2634,9 @@ initialize_ports(struct l2fwd_crypto_options *options)
                        return retval;
                }
 
-               if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
+               if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE)
                        local_port_conf.txmode.offloads |=
-                               DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+                               RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
                retval = rte_eth_dev_configure(portid, 1, 1, &local_port_conf);
                if (retval < 0) {
                        printf("Cannot configure device: err=%d, port=%u\n",
@@ -2715,7 +2717,7 @@ initialize_ports(struct l2fwd_crypto_options *options)
                        last_portid = portid;
                }
 
-               l2fwd_enabled_port_mask |= (1 << portid);
+               l2fwd_enabled_port_mask |= (1ULL << portid);
                enabled_portcount++;
        }