DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tero Aho <tero.aho@coriant.com>
To: <dev@dpdk.org>
Subject: [dpdk-dev] [PATCH 3/3] pcap: add byte and error counters into statistics
Date: Fri, 27 Feb 2015 15:42:40 +0200	[thread overview]
Message-ID: <1425044560-23397-4-git-send-email-tero.aho@coriant.com> (raw)
In-Reply-To: <1425044560-23397-1-git-send-email-tero.aho@coriant.com>

Added input/ouput byte counters into pcap interface statistics,
also calls pcap_stats to add dropped packets into input errors.

Signed-off-by: Tero Aho <tero.aho@coriant.com>
---
 lib/librte_pmd_pcap/rte_eth_pcap.c | 37 +++++++++++++++++++++++++++++--------
 1 file changed, 29 insertions(+), 8 deletions(-)

diff --git a/lib/librte_pmd_pcap/rte_eth_pcap.c b/lib/librte_pmd_pcap/rte_eth_pcap.c
index 3f23f0a..1c472ac 100644
--- a/lib/librte_pmd_pcap/rte_eth_pcap.c
+++ b/lib/librte_pmd_pcap/rte_eth_pcap.c
@@ -71,6 +71,7 @@ struct pcap_rx_queue {
        uint8_t in_port;
        struct rte_mempool *mb_pool;
        volatile unsigned long rx_pkts;
+       volatile unsigned long rx_octs;
        volatile unsigned long err_pkts;
        const char *name;
        const char *type;
@@ -80,6 +81,7 @@ struct pcap_tx_queue {
        pcap_dumper_t *dumper;
        pcap_t *pcap;
        volatile unsigned long tx_pkts;
+       volatile unsigned long tx_octs;
        volatile unsigned long err_pkts;
        const char *name;
        const char *type;
@@ -218,6 +220,7 @@ eth_pcap_rx(void *queue,
                                break;
                        }
                }
+               pcap_q->rx_octs += header.len;
                mbuf->pkt_len = (uint16_t)header.len;
                mbuf->port = pcap_q->in_port;
                bufs[num_rx] = mbuf;
@@ -261,6 +264,7 @@ eth_pcap_tx_dumper(void *queue,
                calculate_timestamp(&header.ts);
                header.len = mbuf->data_len;
                header.caplen = header.len;
+               dumper_q->tx_octs += header.len;
                pcap_dump((u_char *)dumper_q->dumper, &header,
                                rte_pktmbuf_mtod(mbuf, void*));
                rte_pktmbuf_free(mbuf);
@@ -324,9 +328,11 @@ eth_pcap_tx(void *queue,
                                              mbuf->data_len);
                else
                        ret = eth_pcap_tx_jumbo(tx_queue->pcap, mbuf);
+
                if (unlikely(ret != 0))
                        break;
                num_tx++;
+               tx_queue->tx_octs += mbuf->pkt_len;
                rte_pktmbuf_free(mbuf);
        }

@@ -471,26 +477,38 @@ eth_stats_get(struct rte_eth_dev *dev,
                struct rte_eth_stats *igb_stats)
 {
        unsigned i;
-       unsigned long rx_total = 0, tx_total = 0, tx_err_total = 0;
+       struct pcap_stat ps;
+       unsigned long ipackets = 0, ibytes = 0, ierrors = 0;
+       unsigned long opackets = 0, obytes = 0, oerrors = 0;
        const struct pmd_internals *internal = dev->data->dev_private;

        for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS && i < internal->nb_rx_queues;
                        i++) {
                igb_stats->q_ipackets[i] = internal->rx_queue[i].rx_pkts;
-               rx_total += igb_stats->q_ipackets[i];
+               igb_stats->q_ibytes[i] = internal->rx_queue[i].rx_octs;
+               if (!pcap_stats(internal->rx_queue[i].pcap, &ps))
+                       igb_stats->q_errors[i] = ps.ps_drop;
+               ipackets += igb_stats->q_ipackets[i];
+               ibytes += igb_stats->q_ibytes[i];
+               ierrors += igb_stats->q_errors[i];
        }

        for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS && i < internal->nb_tx_queues;
                        i++) {
                igb_stats->q_opackets[i] = internal->tx_queue[i].tx_pkts;
+               igb_stats->q_obytes[i] = internal->tx_queue[i].tx_octs;
                igb_stats->q_errors[i] = internal->tx_queue[i].err_pkts;
-               tx_total += igb_stats->q_opackets[i];
-               tx_err_total += igb_stats->q_errors[i];
+               opackets += igb_stats->q_opackets[i];
+               obytes += igb_stats->q_obytes[i];
+               oerrors += igb_stats->q_errors[i];
        }

-       igb_stats->ipackets = rx_total;
-       igb_stats->opackets = tx_total;
-       igb_stats->oerrors = tx_err_total;
+       igb_stats->ipackets = ipackets;
+       igb_stats->ibytes = ibytes;
+       igb_stats->ierrors = ierrors;
+       igb_stats->opackets = opackets;
+       igb_stats->obytes = obytes;
+       igb_stats->oerrors = oerrors;
 }

 static void
@@ -498,10 +516,13 @@ eth_stats_reset(struct rte_eth_dev *dev)
 {
        unsigned i;
        struct pmd_internals *internal = dev->data->dev_private;
-       for (i = 0; i < internal->nb_rx_queues; i++)
+       for (i = 0; i < internal->nb_rx_queues; i++) {
                internal->rx_queue[i].rx_pkts = 0;
+               internal->rx_queue[i].rx_octs = 0;
+       }
        for (i = 0; i < internal->nb_tx_queues; i++) {
                internal->tx_queue[i].tx_pkts = 0;
+               internal->tx_queue[i].tx_octs = 0;
                internal->tx_queue[i].err_pkts = 0;
        }
 }
--
1.9.1


============================================================
The information contained in this message may be privileged
and confidential and protected from disclosure. If the reader
of this message is not the intended recipient, or an employee
or agent responsible for delivering this message to the
intended recipient, you are hereby notified that any reproduction,
dissemination or distribution of this communication is strictly
prohibited. If you have received this communication in error,
please notify us immediately by replying to the message and
deleting it from your computer. Thank you. Coriant-Tellabs
============================================================

  parent reply	other threads:[~2015-02-27 13:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-27 13:42 [dpdk-dev] [PATCH 0/3] pcap pmd improvements Tero Aho
2015-02-27 13:42 ` [dpdk-dev] [PATCH 1/3] pcap: utilize underlying real interface properties Tero Aho
2015-04-28 13:49   ` Mcnamara, John
2015-02-27 13:42 ` [dpdk-dev] [PATCH 2/3] pcap: add support for jumbo frames Tero Aho
2015-04-28 13:52   ` Mcnamara, John
2015-06-10  9:08   ` [dpdk-dev] [dpdk-dev,2/3] " Maxim Uvarov
2015-06-10  9:43     ` Mcnamara, John
2015-02-27 13:42 ` Tero Aho [this message]
2015-04-28 14:00   ` [dpdk-dev] [PATCH 3/3] pcap: add byte and error counters into statistics Mcnamara, John
2015-02-27 13:50 ` [dpdk-dev] [PATCH 0/3] pcap pmd improvements Thomas Monjalon
2015-04-28 10:09 ` Thomas Monjalon
2015-04-28 12:09   ` Mcnamara, John
2015-04-29  8:29     ` Nicolas Pernas Maradei
2015-04-28 12:27 ` Mcnamara, John

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1425044560-23397-4-git-send-email-tero.aho@coriant.com \
    --to=tero.aho@coriant.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).