examples/tep_term: add bad Rx checksum statistics
authorJijiang Liu <jijiang.liu@intel.com>
Mon, 22 Jun 2015 16:41:04 +0000 (00:41 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 23 Jun 2015 09:35:06 +0000 (11:35 +0200)
Add the bad Rx checksum statistics of inner IP and L4.

The number of packets with bad RX IP and L4 checksum in inner header is recorded.

Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
examples/tep_termination/main.c
examples/tep_termination/main.h
examples/tep_termination/vxlan_setup.c
examples/tep_termination/vxlan_setup.h

index 1673c0f..6c7f44f 100644 (file)
@@ -1058,7 +1058,7 @@ print_stats(void)
 {
        struct virtio_net_data_ll *dev_ll;
        uint64_t tx_dropped, rx_dropped;
-       uint64_t tx, tx_total, rx, rx_total;
+       uint64_t tx, tx_total, rx, rx_total, rx_ip_csum, rx_l4_csum;
        uint32_t device_fh;
        const char clr[] = { 27, '[', '2', 'J', '\0' };
        const char top_left[] = { 27, '[', '1', ';', '1', 'H', '\0' };
@@ -1083,12 +1083,18 @@ print_stats(void)
                        rx = rte_atomic64_read(
                                &dev_statistics[device_fh].rx_atomic);
                        rx_dropped = rx_total - rx;
+                       rx_ip_csum = rte_atomic64_read(
+                               &dev_statistics[device_fh].rx_bad_ip_csum);
+                       rx_l4_csum = rte_atomic64_read(
+                               &dev_statistics[device_fh].rx_bad_l4_csum);
 
                        printf("\nStatistics for device %"PRIu32" ----------"
                                        "\nTX total:            %"PRIu64""
                                        "\nTX dropped:          %"PRIu64""
                                        "\nTX successful:               %"PRIu64""
                                        "\nRX total:            %"PRIu64""
+                                       "\nRX bad IP csum:      %"PRIu64""
+                                       "\nRX bad L4 csum:      %"PRIu64""
                                        "\nRX dropped:          %"PRIu64""
                                        "\nRX successful:               %"PRIu64"",
                                        device_fh,
@@ -1096,6 +1102,8 @@ print_stats(void)
                                        tx_dropped,
                                        tx,
                                        rx_total,
+                                       rx_ip_csum,
+                                       rx_l4_csum,
                                        rx_dropped,
                                        rx);
 
index 20fa5b3..a34301a 100644 (file)
@@ -69,6 +69,10 @@ struct device_statistics {
        uint64_t rx_total;
        uint64_t tx;
        rte_atomic64_t rx_atomic;
+       /**< Bad inner IP csum for tunneling pkt */
+       rte_atomic64_t rx_bad_ip_csum;
+       /**< Bad inner L4 csum for tunneling pkt */
+       rte_atomic64_t rx_bad_l4_csum;
 } __rte_cache_aligned;
 
 /**
index a1cd218..2341f9e 100644 (file)
@@ -427,6 +427,16 @@ vxlan_rx_pkts(struct virtio_net *dev, struct rte_mbuf **pkts_burst,
        struct rte_mbuf *pkts_valid[rx_count];
 
        for (i = 0; i < rx_count; i++) {
+               if (enable_stats) {
+                       rte_atomic64_add(
+                               &dev_statistics[dev->device_fh].rx_bad_ip_csum,
+                               (pkts_burst[i]->ol_flags & PKT_RX_IP_CKSUM_BAD)
+                               != 0);
+                       rte_atomic64_add(
+                               &dev_statistics[dev->device_fh].rx_bad_ip_csum,
+                               (pkts_burst[i]->ol_flags & PKT_RX_L4_CKSUM_BAD)
+                               != 0);
+               }
                ret = vxlan_rx_process(pkts_burst[i]);
                if (unlikely(ret < 0))
                        continue;
index 96442e2..189d491 100644 (file)
@@ -39,6 +39,8 @@ extern uint16_t udp_port;
 extern uint8_t filter_idx;
 extern uint8_t ports[RTE_MAX_ETHPORTS];
 extern struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];
+extern uint32_t enable_stats;
+extern struct device_statistics dev_statistics[MAX_DEVICES];
 
 typedef int (*ol_port_configure_t)(uint8_t port,
                                   struct rte_mempool *mbuf_pool);