From: Ido Goshen <ido@cgstowernetworks.com>
To: ferruh.yigit@xilinx.com, stephen@networkplumber.org
Cc: dev@dpdk.org, Ido Goshen <ido@cgstowernetworks.com>
Subject: [PATCH v7 3/3] pcap: support MTU set for linux interfaces count ierrors
Date: Sun, 19 Jun 2022 12:30:34 +0300 [thread overview]
Message-ID: <20220619093034.26891-4-ido@cgstowernetworks.com> (raw)
In-Reply-To: <20220619093034.26891-1-ido@cgstowernetworks.com>
Count oversized packets that are dropped by the interface
Signed-off-by: Ido Goshen <ido@cgstowernetworks.com>
---
drivers/net/pcap/pcap_ethdev.c | 74 +++++++++++++++++++++-------------
1 file changed, 45 insertions(+), 29 deletions(-)
diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c
index ff98762058..46f18e9b10 100644
--- a/drivers/net/pcap/pcap_ethdev.c
+++ b/drivers/net/pcap/pcap_ethdev.c
@@ -54,7 +54,7 @@ struct queue_stat {
volatile unsigned long rx_nombuf;
};
-struct queue_missed_stat {
+struct queue_pcap_stat {
/* last value retrieved from pcap */
unsigned int pcap;
/* stores values lost by pcap stop or rollover */
@@ -63,12 +63,19 @@ struct queue_missed_stat {
unsigned long reset;
};
+enum {
+ QUEUE_PCAP_STAT_FIRST = 0,
+ QUEUE_PCAP_STAT_MISSED = QUEUE_PCAP_STAT_FIRST,
+ QUEUE_PCAP_STAT_ERROR,
+ QUEUE_PCAP_STAT_NUM
+};
+
struct pcap_rx_queue {
uint16_t port_id;
uint16_t queue_id;
struct rte_mempool *mb_pool;
struct queue_stat rx_stat;
- struct queue_missed_stat missed_stat;
+ struct queue_pcap_stat queue_pcap_stat[QUEUE_PCAP_STAT_NUM];
char name[PATH_MAX];
char type[ETH_PCAP_ARG_MAXLEN];
@@ -144,54 +151,62 @@ static struct rte_eth_link pmd_link = {
RTE_LOG_REGISTER_DEFAULT(eth_pcap_logtype, NOTICE);
-static struct queue_missed_stat*
-queue_missed_stat_update(struct rte_eth_dev *dev, unsigned int qid)
+static struct queue_pcap_stat*
+queue_pcap_stat_update(struct rte_eth_dev *dev, unsigned int qid, int type)
{
struct pmd_internals *internals = dev->data->dev_private;
- struct queue_missed_stat *missed_stat =
- &internals->rx_queue[qid].missed_stat;
+ struct queue_pcap_stat *queue_pcap_stat =
+ &internals->rx_queue[qid].queue_pcap_stat[type];
const struct pmd_process_private *pp = dev->process_private;
pcap_t *pcap = pp->rx_pcap[qid];
struct pcap_stat stat;
+ u_int value;
if (!pcap || (pcap_stats(pcap, &stat) != 0))
- return missed_stat;
+ return queue_pcap_stat;
+ value = (type == QUEUE_PCAP_STAT_ERROR) ? stat.ps_ifdrop : stat.ps_drop;
/* rollover check - best effort fixup assuming single rollover */
- if (stat.ps_drop < missed_stat->pcap)
- missed_stat->mnemonic += UINT_MAX;
- missed_stat->pcap = stat.ps_drop;
+ if (value < queue_pcap_stat->pcap)
+ queue_pcap_stat->mnemonic += UINT_MAX;
+ queue_pcap_stat->pcap = value;
- return missed_stat;
+ return queue_pcap_stat;
}
static void
-queue_missed_stat_on_stop_update(struct rte_eth_dev *dev, unsigned int qid)
+queue_pcap_stat_on_stop_update(struct rte_eth_dev *dev, unsigned int qid)
{
- struct queue_missed_stat *missed_stat =
- queue_missed_stat_update(dev, qid);
+ int type;
+ struct queue_pcap_stat *queue_pcap_stat;
- missed_stat->mnemonic += missed_stat->pcap;
- missed_stat->pcap = 0;
+ for (type = QUEUE_PCAP_STAT_FIRST; type < QUEUE_PCAP_STAT_NUM; type++) {
+ queue_pcap_stat = queue_pcap_stat_update(dev, qid, type);
+ queue_pcap_stat->mnemonic += queue_pcap_stat->pcap;
+ queue_pcap_stat->pcap = 0;
+ }
}
static void
-queue_missed_stat_reset(struct rte_eth_dev *dev, unsigned int qid)
+queue_pcap_stat_reset(struct rte_eth_dev *dev, unsigned int qid)
{
- struct queue_missed_stat *missed_stat =
- queue_missed_stat_update(dev, qid);
+ int type;
+ struct queue_pcap_stat *queue_pcap_stat;
- missed_stat->reset = missed_stat->pcap;
- missed_stat->mnemonic = 0;
+ for (type = QUEUE_PCAP_STAT_FIRST; type < QUEUE_PCAP_STAT_NUM; type++) {
+ queue_pcap_stat = queue_pcap_stat_update(dev, qid, type);
+ queue_pcap_stat->reset = queue_pcap_stat->pcap;
+ queue_pcap_stat->mnemonic = 0;
+ }
}
static unsigned long
-queue_missed_stat_get(struct rte_eth_dev *dev, unsigned int qid)
+queue_pcap_stat_get(struct rte_eth_dev *dev, unsigned int qid, int type)
{
- const struct queue_missed_stat *missed_stat =
- queue_missed_stat_update(dev, qid);
+ const struct queue_pcap_stat *queue_pcap_stat =
+ queue_pcap_stat_update(dev, qid, type);
- return missed_stat->pcap + missed_stat->mnemonic - missed_stat->reset;
+ return queue_pcap_stat->pcap + queue_pcap_stat->mnemonic - queue_pcap_stat->reset;
}
static int
@@ -684,7 +699,7 @@ eth_dev_stop(struct rte_eth_dev *dev)
/* Special iface case. Single pcap is open and shared between tx/rx. */
if (internals->single_iface) {
- queue_missed_stat_on_stop_update(dev, 0);
+ queue_pcap_stat_on_stop_update(dev, 0);
if (pp->tx_pcap[0] != NULL) {
pcap_close(pp->tx_pcap[0]);
pp->tx_pcap[0] = NULL;
@@ -707,7 +722,7 @@ eth_dev_stop(struct rte_eth_dev *dev)
for (i = 0; i < dev->data->nb_rx_queues; i++) {
if (pp->rx_pcap[i] != NULL) {
- queue_missed_stat_on_stop_update(dev, i);
+ queue_pcap_stat_on_stop_update(dev, i);
pcap_close(pp->rx_pcap[i]);
pp->rx_pcap[i] = NULL;
}
@@ -766,7 +781,8 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
rx_err_total += internal->rx_queue[i].rx_stat.err_pkts;
rx_packets_total += stats->q_ipackets[i];
rx_bytes_total += stats->q_ibytes[i];
- rx_missed_total += queue_missed_stat_get(dev, i);
+ rx_missed_total += queue_pcap_stat_get(dev, i, QUEUE_PCAP_STAT_MISSED);
+ rx_err_total += queue_pcap_stat_get(dev, i, QUEUE_PCAP_STAT_ERROR);
}
for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&
@@ -801,7 +817,7 @@ eth_stats_reset(struct rte_eth_dev *dev)
internal->rx_queue[i].rx_stat.bytes = 0;
internal->rx_queue[i].rx_stat.err_pkts = 0;
internal->rx_queue[i].rx_stat.rx_nombuf = 0;
- queue_missed_stat_reset(dev, i);
+ queue_pcap_stat_reset(dev, i);
}
for (i = 0; i < dev->data->nb_tx_queues; i++) {
--
2.17.1
next prev parent reply other threads:[~2022-06-19 9:31 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-17 17:43 [PATCH] net/pcap: support MTU set ido g
2022-03-17 18:20 ` Stephen Hemminger
2022-03-17 19:11 ` Ido Goshen
2022-03-22 13:02 ` Ido Goshen
2022-04-26 17:03 ` Ferruh Yigit
2022-04-27 18:21 ` Ido Goshen
2022-04-27 19:14 ` Stephen Hemminger
2022-05-23 7:48 ` Ido Goshen
2022-05-30 10:36 ` [PATCH v3] pcap: " Ido Goshen
2022-05-30 18:05 ` Ferruh Yigit
2022-05-31 13:12 ` Ido Goshen
2022-06-06 9:40 ` Ido Goshen
2022-06-06 16:21 ` [PATCH v4] " Ido Goshen
2022-06-06 17:10 ` Stephen Hemminger
2022-06-06 19:07 ` Ido Goshen
2022-06-07 6:27 ` [PATCH v5] pcap: support MTU set for linux interafces Ido Goshen
2022-06-08 16:04 ` [PATCH v6] " Ido Goshen
2022-06-08 16:23 ` Stephen Hemminger
2022-06-19 9:30 ` [PATCH v7 0/3] pcap: support MTU set for linux interfaces Ido Goshen
2022-06-19 9:30 ` [PATCH v7 1/3] " Ido Goshen
2022-06-19 9:30 ` [PATCH v7 2/3] pcap: support MTU set for linux interfaces TX enhancment Ido Goshen
2022-06-20 22:52 ` Stephen Hemminger
2022-06-21 9:07 ` Ido Goshen
2022-06-19 9:30 ` Ido Goshen [this message]
2022-06-20 8:39 ` [PATCH v8 0/3] pcap: support MTU set for linux interfaces Ido Goshen
2022-06-20 8:39 ` [PATCH v8 1/3] " Ido Goshen
2022-06-20 8:39 ` [PATCH v8 2/3] pcap: support MTU set for linux interfaces TX enhancment Ido Goshen
2022-06-20 8:39 ` [PATCH v8 3/3] pcap: support MTU set for linux interfaces count ierrors Ido Goshen
2023-07-04 17:43 ` [PATCH] pcap: support MTU set Stephen Hemminger
2023-07-04 21:02 ` [PATCH v2] " Stephen Hemminger
2023-07-05 11:37 ` Ferruh Yigit
2023-07-05 15:18 ` Stephen Hemminger
2023-07-06 10:45 ` Ido Goshen
2023-07-10 16:45 ` [PATCH] net/pcap: " Stephen Hemminger
2023-07-10 17:46 ` Ferruh Yigit
2023-07-11 9:41 ` Ido Goshen
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=20220619093034.26891-4-ido@cgstowernetworks.com \
--to=ido@cgstowernetworks.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@xilinx.com \
--cc=stephen@networkplumber.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).