* [dpdk-dev] [memnic PATCH 4/5] pmd: account statistics
@ 2014-03-11 5:39 Hiroshi Shimamoto
2014-03-25 15:01 ` Thomas Monjalon
0 siblings, 1 reply; 2+ messages in thread
From: Hiroshi Shimamoto @ 2014-03-11 5:39 UTC (permalink / raw)
To: dev; +Cc: Hayato Momma
From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Implement packet accounting of MEMNIC on TX/RX.
Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Reviewed-by: Hayato Momma <h-momma@ce.jp.nec.com>
---
pmd/pmd_memnic.c | 37 +++++++++++++++++++++++++++++++++++--
1 file changed, 35 insertions(+), 2 deletions(-)
diff --git a/pmd/pmd_memnic.c b/pmd/pmd_memnic.c
index fc2d990..abfd437 100644
--- a/pmd/pmd_memnic.c
+++ b/pmd/pmd_memnic.c
@@ -255,18 +255,23 @@ static uint16_t memnic_recv_pkts(void *rx_queue,
struct memnic_packet *p;
struct rte_mbuf *mb;
uint16_t nr;
+ uint64_t pkts, bytes, errs;
int idx;
+ struct rte_eth_stats *st = &adapter->stats[rte_lcore_id()];
if (!adapter->nic->hdr.valid)
return 0;
+ pkts = bytes = errs = 0;
idx = adapter->up_idx;
for (nr = 0; nr < nb_pkts; nr++) {
p = &data->packets[idx];
if (p->status != MEMNIC_PKT_ST_FILLED)
break;
- if (p->len > MEMNIC_MAX_FRAME_LEN)
+ if (p->len > MEMNIC_MAX_FRAME_LEN) {
+ errs++;
goto drop;
+ }
mb = rte_pktmbuf_alloc(adapter->mp);
if (!mb)
break;
@@ -279,6 +284,9 @@ static uint16_t memnic_recv_pkts(void *rx_queue,
mb->pkt.data_len = p->len;
rx_pkts[nr] = mb;
+ pkts++;
+ bytes += p->len;
+
drop:
rte_mb();
p->status = MEMNIC_PKT_ST_FREE;
@@ -288,6 +296,13 @@ drop:
}
adapter->up_idx = idx;
+ /* stats */
+ st->ipackets += pkts;
+ st->ibytes += bytes;
+ st->ierrors += errs;
+ st->q_ipackets[0] += pkts;
+ st->q_ibytes[0] += bytes;
+
return nr;
}
@@ -300,14 +315,21 @@ static uint16_t memnic_xmit_pkts(void *tx_queue,
struct memnic_packet *p;
uint16_t nr;
int idx, old;
+ struct rte_eth_stats *st = &adapter->stats[rte_lcore_id()];
+ uint64_t pkts, bytes, errs;
if (!adapter->nic->hdr.valid)
return 0;
+ pkts = bytes = errs = 0;
+
for (nr = 0; nr < nb_pkts; nr++) {
int len = rte_pktmbuf_data_len(tx_pkts[nr]);
- if (len > MEMNIC_MAX_FRAME_LEN)
+
+ if (len > MEMNIC_MAX_FRAME_LEN) {
+ errs++;
break;
+ }
retry:
idx = ACCESS_ONCE(adapter->down_idx);
p = &data->packets[idx];
@@ -315,6 +337,7 @@ retry:
if (old != MEMNIC_PKT_ST_FREE) {
if (old == MEMNIC_PKT_ST_FILLED &&
idx == ACCESS_ONCE(adapter->down_idx)) {
+ errs++;
break;
}
goto retry;
@@ -337,12 +360,22 @@ retry:
rte_memcpy(p->data, rte_pktmbuf_mtod(tx_pkts[nr], void *), len);
+ pkts++;
+ bytes += len;
+
rte_mb();
p->status = MEMNIC_PKT_ST_FILLED;
rte_pktmbuf_free(tx_pkts[nr]);
}
+ /* stats */
+ st->opackets += pkts;
+ st->obytes += bytes;
+ st->oerrors += errs;
+ st->q_opackets[0] += pkts;
+ st->q_obytes[0] += bytes;
+
return nr;
}
--
1.8.4
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dpdk-dev] [memnic PATCH 4/5] pmd: account statistics
2014-03-11 5:39 [dpdk-dev] [memnic PATCH 4/5] pmd: account statistics Hiroshi Shimamoto
@ 2014-03-25 15:01 ` Thomas Monjalon
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2014-03-25 15:01 UTC (permalink / raw)
To: Hiroshi Shimamoto; +Cc: dev, Hayato Momma
11/03/2014 05:39, Hiroshi Shimamoto:
> From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
>
> Implement packet accounting of MEMNIC on TX/RX.
>
> Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
> Reviewed-by: Hayato Momma <h-momma@ce.jp.nec.com>
Acked and applied.
Thank you
--
Thomas
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-03-25 15:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-11 5:39 [dpdk-dev] [memnic PATCH 4/5] pmd: account statistics Hiroshi Shimamoto
2014-03-25 15:01 ` Thomas Monjalon
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).