From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from emea01-db3-obe.outbound.protection.outlook.com (mail-db3on0095.outbound.protection.outlook.com [157.55.234.95]) by dpdk.org (Postfix) with ESMTP id F0F7A5A6F for ; Fri, 27 Feb 2015 14:46:08 +0100 (CET) Received: from DB4PR04CA0024.eurprd04.prod.outlook.com (25.160.41.34) by DB5PR04MB1095.eurprd04.prod.outlook.com (25.161.199.20) with Microsoft SMTP Server (TLS) id 15.1.93.16; Fri, 27 Feb 2015 13:42:58 +0000 Received: from AM1FFO11FD053.protection.gbl (2a01:111:f400:7e00::121) by DB4PR04CA0024.outlook.office365.com (2a01:111:e400:9852::34) with Microsoft SMTP Server (TLS) id 15.1.99.14 via Frontend Transport; Fri, 27 Feb 2015 13:42:58 +0000 Received: from usnvwwmspedge01.tellabs-west.tellabsinc.net (204.154.129.192) by AM1FFO11FD053.mail.protection.outlook.com (10.174.65.72) with Microsoft SMTP Server (TLS) id 15.1.99.6 via Frontend Transport; Fri, 27 Feb 2015 13:42:58 +0000 Received: from usnvwwmspht02.tellabs-west.tellabsinc.net (172.23.211.70) by usnvwwmspedge01.tellabs-west.tellabsinc.net (204.154.131.192) with Microsoft SMTP Server (TLS) id 8.3.377.0; Fri, 27 Feb 2015 07:41:44 -0600 Received: from T430.tellabs-east.tellabsinc.net (172.23.229.50) by usnvwwmspht02.tellabs-west.tellabsinc.net (172.23.211.70) with Microsoft SMTP Server id 8.3.298.1; Fri, 27 Feb 2015 07:42:56 -0600 From: Tero Aho To: Date: Fri, 27 Feb 2015 15:42:40 +0200 Message-ID: <1425044560-23397-4-git-send-email-tero.aho@coriant.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1425044560-23397-1-git-send-email-tero.aho@coriant.com> References: <1425044560-23397-1-git-send-email-tero.aho@coriant.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 Received-SPF: Pass (protection.outlook.com: domain of coriant.com designates 204.154.129.192 as permitted sender) receiver=protection.outlook.com; client-ip=204.154.129.192; helo=usnvwwmspedge01.tellabs-west.tellabsinc.net; Authentication-Results: spf=pass (sender IP is 204.154.129.192) smtp.mailfrom=Tero.Aho@coriant.com; dpdk.org; dkim=none (message not signed) header.d=none; X-Forefront-Antispam-Report: CIP:204.154.129.192; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(438002)(6806004)(19580405001)(76176999)(110136001)(229853001)(106466001)(62966003)(575784001)(86362001)(46102003)(2351001)(92566002)(450100001)(19580395003)(2950100001)(77096005)(16796002)(47776003)(33646002)(87936001)(50226001)(50986999)(107886001)(77156002)(48376002)(50466002)(36756003); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR04MB1095; H:usnvwwmspedge01.tellabs-west.tellabsinc.net; FPR:; SPF:Pass; MLV:sfv; LANG:en; X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:DB5PR04MB1095; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006); SRVR:DB5PR04MB1095; X-Forefront-PRVS: 05009853EF X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:;SRVR:DB5PR04MB1095; X-OriginatorOrg: coriant.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2015 13:42:58.3724 (UTC) X-MS-Exchange-CrossTenant-Id: 76595477-907e-4695-988b-a6b39087332d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=76595477-907e-4695-988b-a6b39087332d; Ip=[204.154.129.192] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR04MB1095 Subject: [dpdk-dev] [PATCH 3/3] pcap: add byte and error counters into statistics X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Feb 2015 13:46:09 -0000 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 --- 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_e= th_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 +=3D header.len; mbuf->pkt_len =3D (uint16_t)header.len; mbuf->port =3D pcap_q->in_port; bufs[num_rx] =3D mbuf; @@ -261,6 +264,7 @@ eth_pcap_tx_dumper(void *queue, calculate_timestamp(&header.ts); header.len =3D mbuf->data_len; header.caplen =3D header.len; + dumper_q->tx_octs +=3D 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 =3D eth_pcap_tx_jumbo(tx_queue->pcap, mbuf); + if (unlikely(ret !=3D 0)) break; num_tx++; + tx_queue->tx_octs +=3D 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 =3D 0, tx_total =3D 0, tx_err_total =3D 0; + struct pcap_stat ps; + unsigned long ipackets =3D 0, ibytes =3D 0, ierrors =3D 0; + unsigned long opackets =3D 0, obytes =3D 0, oerrors =3D 0; const struct pmd_internals *internal =3D dev->data->dev_private; for (i =3D 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS && i < internal->nb_r= x_queues; i++) { igb_stats->q_ipackets[i] =3D internal->rx_queue[i].rx_pkts; - rx_total +=3D igb_stats->q_ipackets[i]; + igb_stats->q_ibytes[i] =3D internal->rx_queue[i].rx_octs; + if (!pcap_stats(internal->rx_queue[i].pcap, &ps)) + igb_stats->q_errors[i] =3D ps.ps_drop; + ipackets +=3D igb_stats->q_ipackets[i]; + ibytes +=3D igb_stats->q_ibytes[i]; + ierrors +=3D igb_stats->q_errors[i]; } for (i =3D 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS && i < internal->nb_t= x_queues; i++) { igb_stats->q_opackets[i] =3D internal->tx_queue[i].tx_pkts; + igb_stats->q_obytes[i] =3D internal->tx_queue[i].tx_octs; igb_stats->q_errors[i] =3D internal->tx_queue[i].err_pkts; - tx_total +=3D igb_stats->q_opackets[i]; - tx_err_total +=3D igb_stats->q_errors[i]; + opackets +=3D igb_stats->q_opackets[i]; + obytes +=3D igb_stats->q_obytes[i]; + oerrors +=3D igb_stats->q_errors[i]; } - igb_stats->ipackets =3D rx_total; - igb_stats->opackets =3D tx_total; - igb_stats->oerrors =3D tx_err_total; + igb_stats->ipackets =3D ipackets; + igb_stats->ibytes =3D ibytes; + igb_stats->ierrors =3D ierrors; + igb_stats->opackets =3D opackets; + igb_stats->obytes =3D obytes; + igb_stats->oerrors =3D oerrors; } static void @@ -498,10 +516,13 @@ eth_stats_reset(struct rte_eth_dev *dev) { unsigned i; struct pmd_internals *internal =3D dev->data->dev_private; - for (i =3D 0; i < internal->nb_rx_queues; i++) + for (i =3D 0; i < internal->nb_rx_queues; i++) { internal->rx_queue[i].rx_pkts =3D 0; + internal->rx_queue[i].rx_octs =3D 0; + } for (i =3D 0; i < internal->nb_tx_queues; i++) { internal->tx_queue[i].tx_pkts =3D 0; + internal->tx_queue[i].tx_octs =3D 0; internal->tx_queue[i].err_pkts =3D 0; } } -- 1.9.1 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D