get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/1.0/patches/140071/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 140071,
    "url": "http://patchwork.dpdk.org/api/1.0/patches/140071/?format=api",
    "project": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/1.0/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk"
    },
    "msgid": "<20240514153845.42489-6-stephen@networkplumber.org>",
    "date": "2024-05-14T15:35:08",
    "name": "[v3,5/7] net/pcap: use generic SW stats",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "b8cda68e499b157a9db33d0b098aa0885fbec2cc",
    "submitter": {
        "id": 27,
        "url": "http://patchwork.dpdk.org/api/1.0/people/27/?format=api",
        "name": "Stephen Hemminger",
        "email": "stephen@networkplumber.org"
    },
    "delegate": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/1.0/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20240514153845.42489-6-stephen@networkplumber.org/mbox/",
    "series": [
        {
            "id": 31926,
            "url": "http://patchwork.dpdk.org/api/1.0/series/31926/?format=api",
            "date": "2024-05-14T15:35:03",
            "name": "Generic SW counters",
            "version": 3,
            "mbox": "http://patchwork.dpdk.org/series/31926/mbox/"
        }
    ],
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/140071/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id C45084401F;\n\tTue, 14 May 2024 17:39:34 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 6DD3B4069F;\n\tTue, 14 May 2024 17:39:06 +0200 (CEST)",
            "from mail-pl1-f176.google.com (mail-pl1-f176.google.com\n [209.85.214.176])\n by mails.dpdk.org (Postfix) with ESMTP id 84B55406B8\n for <dev@dpdk.org>; Tue, 14 May 2024 17:39:02 +0200 (CEST)",
            "by mail-pl1-f176.google.com with SMTP id\n d9443c01a7336-1f05b669b6cso30259065ad.3\n for <dev@dpdk.org>; Tue, 14 May 2024 08:39:02 -0700 (PDT)",
            "from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226])\n by smtp.gmail.com with ESMTPSA id\n d9443c01a7336-1ef0c137f14sm99256415ad.259.2024.05.14.08.39.01\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 14 May 2024 08:39:01 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1715701142;\n x=1716305942; darn=dpdk.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=AxNG1Ahfsh5mUGzqqQYD8sMjy9Y6CWI7ENjvPxua/xw=;\n b=qtSE2GnB9oODTCRH+/g0F6vX5xLUljCkTCx6TykeOGHE7MZ3oja7dbbEHnESkWJ+8j\n 4oZniwYqCcopC4Dx/iE5lp4C6gX2jsWpGW8mDJod34qP5Aw7Iz3w9diq6p38UeC6iS72\n kCy/eZ5WTwL+m9lKCL0vo5P7Adqwj60Z54wljVemuSqeMlqzi8MvA/8oYYcubwV8c2gO\n mevaN+ICtphrAODxdevo8fiaykLBJROXPYf4ryGKNUJQQ4otSwBYDS/kL555x4Rdcq2c\n chHaEvrx7hs6h65m1N5mizWLLT9td7sOQB5JFBuhTgTjLg8pXPjxEtNxjLbct19PpD4f\n dAbQ==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1715701142; x=1716305942;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=AxNG1Ahfsh5mUGzqqQYD8sMjy9Y6CWI7ENjvPxua/xw=;\n b=uOptjhUbm64rEdGAK1VvqG7Tn+AwO7HatjQRchP00hMknfqeTKGJnp9l8x96bftiKx\n 2GB9NZprQyxP6EPEJgmWuXF1sWlKmyikq0G60vK/dH+Qo7Hh1lDcHlo6sOb2dr9hdKJk\n m9MwVEK9mBdX/D0wQ6cw3Gg8ORyY6rLrCUcafG2I3KcYBc5E7cnp3qXcDh5Cp/BYP2Ks\n a9EGy4kXP3SxIQzAXtSBXscwheCk2BWTA9zb8W5UC+Ank0379Q3ed+Ml5ut0PGV2HK0T\n E2VSgRHwTMl3N6YoSZ31PKDwzV3fLdc7QBkWsYWHjwWwcWpllvALQdFy/2+uhRhkk2Vs\n Uk+A==",
        "X-Gm-Message-State": "AOJu0YwfjpVk+JH0xtRzHHIuxFcwu9N3ZusYaxlV1IWKu9tolG2WPvVx\n d5D4I2ny6W7P21EcYe521PpOX4RH/2aHjM5do4QifCnVY9XSyu7OnqX3O3zg/z3v9nAhkRCVWAZ\n jNVg=",
        "X-Google-Smtp-Source": "\n AGHT+IGOeLD4K68a6ZjGH5v0PTblymXIzXi4d5uDzwqJSJT4IgZX2CR7KkhYvgH9tyomBJ3WonCf9g==",
        "X-Received": "by 2002:a17:902:c94b:b0:1e4:9ad5:7537 with SMTP id\n d9443c01a7336-1ef43e2372amr175721395ad.34.1715701141676;\n Tue, 14 May 2024 08:39:01 -0700 (PDT)",
        "From": "Stephen Hemminger <stephen@networkplumber.org>",
        "To": "dev@dpdk.org",
        "Cc": "Stephen Hemminger <stephen@networkplumber.org>",
        "Subject": "[PATCH v3 5/7] net/pcap: use generic SW stats",
        "Date": "Tue, 14 May 2024 08:35:08 -0700",
        "Message-ID": "<20240514153845.42489-6-stephen@networkplumber.org>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20240514153845.42489-1-stephen@networkplumber.org>",
        "References": "<20240510050507.14381-1-stephen@networkplumber.org>\n <20240514153845.42489-1-stephen@networkplumber.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "Use common statistics for SW drivers.\n\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\n---\n drivers/net/pcap/pcap_ethdev.c | 125 +++++++--------------------------\n 1 file changed, 26 insertions(+), 99 deletions(-)",
    "diff": "diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c\nindex bfec085045..b1a983f871 100644\n--- a/drivers/net/pcap/pcap_ethdev.c\n+++ b/drivers/net/pcap/pcap_ethdev.c\n@@ -11,6 +11,7 @@\n \n #include <rte_cycles.h>\n #include <ethdev_driver.h>\n+#include <ethdev_swstats.h>\n #include <ethdev_vdev.h>\n #include <rte_kvargs.h>\n #include <rte_malloc.h>\n@@ -48,13 +49,6 @@ static uint8_t iface_idx;\n static uint64_t timestamp_rx_dynflag;\n static int timestamp_dynfield_offset = -1;\n \n-struct queue_stat {\n-\tvolatile unsigned long pkts;\n-\tvolatile unsigned long bytes;\n-\tvolatile unsigned long err_pkts;\n-\tvolatile unsigned long rx_nombuf;\n-};\n-\n struct queue_missed_stat {\n \t/* last value retrieved from pcap */\n \tunsigned int pcap;\n@@ -68,7 +62,7 @@ struct pcap_rx_queue {\n \tuint16_t port_id;\n \tuint16_t queue_id;\n \tstruct rte_mempool *mb_pool;\n-\tstruct queue_stat rx_stat;\n+\tstruct rte_eth_counters rx_stat;\n \tstruct queue_missed_stat missed_stat;\n \tchar name[PATH_MAX];\n \tchar type[ETH_PCAP_ARG_MAXLEN];\n@@ -80,7 +74,7 @@ struct pcap_rx_queue {\n struct pcap_tx_queue {\n \tuint16_t port_id;\n \tuint16_t queue_id;\n-\tstruct queue_stat tx_stat;\n+\tstruct rte_eth_counters tx_stat;\n \tchar name[PATH_MAX];\n \tchar type[ETH_PCAP_ARG_MAXLEN];\n };\n@@ -238,7 +232,6 @@ eth_pcap_rx_infinite(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)\n {\n \tint i;\n \tstruct pcap_rx_queue *pcap_q = queue;\n-\tuint32_t rx_bytes = 0;\n \n \tif (unlikely(nb_pkts == 0))\n \t\treturn 0;\n@@ -252,39 +245,35 @@ eth_pcap_rx_infinite(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)\n \t\tif (err)\n \t\t\treturn i;\n \n+\t\trte_eth_count_mbuf(&pcap_q->rx_stat, pcap_buf);\n+\n \t\trte_memcpy(rte_pktmbuf_mtod(bufs[i], void *),\n \t\t\t\trte_pktmbuf_mtod(pcap_buf, void *),\n \t\t\t\tpcap_buf->data_len);\n \t\tbufs[i]->data_len = pcap_buf->data_len;\n \t\tbufs[i]->pkt_len = pcap_buf->pkt_len;\n \t\tbufs[i]->port = pcap_q->port_id;\n-\t\trx_bytes += pcap_buf->data_len;\n+\n \n \t\t/* Enqueue packet back on ring to allow infinite rx. */\n \t\trte_ring_enqueue(pcap_q->pkts, pcap_buf);\n \t}\n \n-\tpcap_q->rx_stat.pkts += i;\n-\tpcap_q->rx_stat.bytes += rx_bytes;\n-\n \treturn i;\n }\n \n static uint16_t\n eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)\n {\n+\tstruct pcap_rx_queue *pcap_q = queue;\n+\tstruct rte_eth_dev *dev = &rte_eth_devices[pcap_q->port_id];\n+\tstruct pmd_process_private *pp = dev->process_private;\n+\tpcap_t *pcap = pp->rx_pcap[pcap_q->queue_id];\n \tunsigned int i;\n \tstruct pcap_pkthdr header;\n-\tstruct pmd_process_private *pp;\n \tconst u_char *packet;\n \tstruct rte_mbuf *mbuf;\n-\tstruct pcap_rx_queue *pcap_q = queue;\n \tuint16_t num_rx = 0;\n-\tuint32_t rx_bytes = 0;\n-\tpcap_t *pcap;\n-\n-\tpp = rte_eth_devices[pcap_q->port_id].process_private;\n-\tpcap = pp->rx_pcap[pcap_q->queue_id];\n \n \tif (unlikely(pcap == NULL || nb_pkts == 0))\n \t\treturn 0;\n@@ -300,7 +289,7 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)\n \n \t\tmbuf = rte_pktmbuf_alloc(pcap_q->mb_pool);\n \t\tif (unlikely(mbuf == NULL)) {\n-\t\t\tpcap_q->rx_stat.rx_nombuf++;\n+\t\t\t++dev->data->rx_mbuf_alloc_failed;\n \t\t\tbreak;\n \t\t}\n \n@@ -315,7 +304,7 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)\n \t\t\t\t\t\t       mbuf,\n \t\t\t\t\t\t       packet,\n \t\t\t\t\t\t       header.caplen) == -1)) {\n-\t\t\t\tpcap_q->rx_stat.err_pkts++;\n+\t\t\t\trte_eth_count_error(&pcap_q->rx_stat);\n \t\t\t\trte_pktmbuf_free(mbuf);\n \t\t\t\tbreak;\n \t\t\t}\n@@ -329,11 +318,10 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)\n \t\tmbuf->ol_flags |= timestamp_rx_dynflag;\n \t\tmbuf->port = pcap_q->port_id;\n \t\tbufs[num_rx] = mbuf;\n+\n+\t\trte_eth_count_mbuf(&pcap_q->rx_stat, mbuf);\n \t\tnum_rx++;\n-\t\trx_bytes += header.caplen;\n \t}\n-\tpcap_q->rx_stat.pkts += num_rx;\n-\tpcap_q->rx_stat.bytes += rx_bytes;\n \n \treturn num_rx;\n }\n@@ -379,8 +367,6 @@ eth_pcap_tx_dumper(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)\n \tstruct rte_mbuf *mbuf;\n \tstruct pmd_process_private *pp;\n \tstruct pcap_tx_queue *dumper_q = queue;\n-\tuint16_t num_tx = 0;\n-\tuint32_t tx_bytes = 0;\n \tstruct pcap_pkthdr header;\n \tpcap_dumper_t *dumper;\n \tunsigned char temp_data[RTE_ETH_PCAP_SNAPLEN];\n@@ -412,8 +398,7 @@ eth_pcap_tx_dumper(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)\n \t\tpcap_dump((u_char *)dumper, &header,\n \t\t\trte_pktmbuf_read(mbuf, 0, caplen, temp_data));\n \n-\t\tnum_tx++;\n-\t\ttx_bytes += caplen;\n+\t\trte_eth_count_mbuf(&dumper_q->tx_stat, mbuf);\n \t\trte_pktmbuf_free(mbuf);\n \t}\n \n@@ -423,9 +408,6 @@ eth_pcap_tx_dumper(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)\n \t * we flush the pcap dumper within each burst.\n \t */\n \tpcap_dump_flush(dumper);\n-\tdumper_q->tx_stat.pkts += num_tx;\n-\tdumper_q->tx_stat.bytes += tx_bytes;\n-\tdumper_q->tx_stat.err_pkts += nb_pkts - num_tx;\n \n \treturn nb_pkts;\n }\n@@ -437,20 +419,16 @@ static uint16_t\n eth_tx_drop(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)\n {\n \tunsigned int i;\n-\tuint32_t tx_bytes = 0;\n \tstruct pcap_tx_queue *tx_queue = queue;\n \n \tif (unlikely(nb_pkts == 0))\n \t\treturn 0;\n \n \tfor (i = 0; i < nb_pkts; i++) {\n-\t\ttx_bytes += bufs[i]->pkt_len;\n+\t\trte_eth_count_mbuf(&tx_queue->tx_stat, bufs[i]);\n \t\trte_pktmbuf_free(bufs[i]);\n \t}\n \n-\ttx_queue->tx_stat.pkts += nb_pkts;\n-\ttx_queue->tx_stat.bytes += tx_bytes;\n-\n \treturn i;\n }\n \n@@ -465,8 +443,6 @@ eth_pcap_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)\n \tstruct rte_mbuf *mbuf;\n \tstruct pmd_process_private *pp;\n \tstruct pcap_tx_queue *tx_queue = queue;\n-\tuint16_t num_tx = 0;\n-\tuint32_t tx_bytes = 0;\n \tpcap_t *pcap;\n \tunsigned char temp_data[RTE_ETH_PCAP_SNAPLEN];\n \tsize_t len;\n@@ -497,15 +473,11 @@ eth_pcap_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)\n \t\t\trte_pktmbuf_read(mbuf, 0, len, temp_data), len);\n \t\tif (unlikely(ret != 0))\n \t\t\tbreak;\n-\t\tnum_tx++;\n-\t\ttx_bytes += len;\n+\n+\t\trte_eth_count_mbuf(&tx_queue->tx_stat, mbuf);\n \t\trte_pktmbuf_free(mbuf);\n \t}\n \n-\ttx_queue->tx_stat.pkts += num_tx;\n-\ttx_queue->tx_stat.bytes += tx_bytes;\n-\ttx_queue->tx_stat.err_pkts += i - num_tx;\n-\n \treturn i;\n }\n \n@@ -746,41 +718,12 @@ static int\n eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)\n {\n \tunsigned int i;\n-\tunsigned long rx_packets_total = 0, rx_bytes_total = 0;\n-\tunsigned long rx_missed_total = 0;\n-\tunsigned long rx_nombuf_total = 0, rx_err_total = 0;\n-\tunsigned long tx_packets_total = 0, tx_bytes_total = 0;\n-\tunsigned long tx_packets_err_total = 0;\n-\tconst struct pmd_internals *internal = dev->data->dev_private;\n-\n-\tfor (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&\n-\t\t\ti < dev->data->nb_rx_queues; i++) {\n-\t\tstats->q_ipackets[i] = internal->rx_queue[i].rx_stat.pkts;\n-\t\tstats->q_ibytes[i] = internal->rx_queue[i].rx_stat.bytes;\n-\t\trx_nombuf_total += internal->rx_queue[i].rx_stat.rx_nombuf;\n-\t\trx_err_total += internal->rx_queue[i].rx_stat.err_pkts;\n-\t\trx_packets_total += stats->q_ipackets[i];\n-\t\trx_bytes_total += stats->q_ibytes[i];\n-\t\trx_missed_total += queue_missed_stat_get(dev, i);\n-\t}\n \n-\tfor (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&\n-\t\t\ti < dev->data->nb_tx_queues; i++) {\n-\t\tstats->q_opackets[i] = internal->tx_queue[i].tx_stat.pkts;\n-\t\tstats->q_obytes[i] = internal->tx_queue[i].tx_stat.bytes;\n-\t\ttx_packets_total += stats->q_opackets[i];\n-\t\ttx_bytes_total += stats->q_obytes[i];\n-\t\ttx_packets_err_total += internal->tx_queue[i].tx_stat.err_pkts;\n-\t}\n+\trte_eth_counters_stats_get(dev, offsetof(struct pcap_tx_queue, tx_stat),\n+\t\t\t\t   offsetof(struct pcap_rx_queue, rx_stat), stats);\n \n-\tstats->ipackets = rx_packets_total;\n-\tstats->ibytes = rx_bytes_total;\n-\tstats->imissed = rx_missed_total;\n-\tstats->ierrors = rx_err_total;\n-\tstats->rx_nombuf = rx_nombuf_total;\n-\tstats->opackets = tx_packets_total;\n-\tstats->obytes = tx_bytes_total;\n-\tstats->oerrors = tx_packets_err_total;\n+\tfor (i = 0; i < dev->data->nb_rx_queues; i++)\n+\t\tstats->imissed += queue_missed_stat_get(dev, i);\n \n \treturn 0;\n }\n@@ -789,21 +732,12 @@ static int\n eth_stats_reset(struct rte_eth_dev *dev)\n {\n \tunsigned int i;\n-\tstruct pmd_internals *internal = dev->data->dev_private;\n \n-\tfor (i = 0; i < dev->data->nb_rx_queues; i++) {\n-\t\tinternal->rx_queue[i].rx_stat.pkts = 0;\n-\t\tinternal->rx_queue[i].rx_stat.bytes = 0;\n-\t\tinternal->rx_queue[i].rx_stat.err_pkts = 0;\n-\t\tinternal->rx_queue[i].rx_stat.rx_nombuf = 0;\n-\t\tqueue_missed_stat_reset(dev, i);\n-\t}\n+\trte_eth_counters_reset(dev, offsetof(struct pcap_tx_queue, tx_stat),\n+\t\t\t       offsetof(struct pcap_rx_queue, rx_stat));\n \n-\tfor (i = 0; i < dev->data->nb_tx_queues; i++) {\n-\t\tinternal->tx_queue[i].tx_stat.pkts = 0;\n-\t\tinternal->tx_queue[i].tx_stat.bytes = 0;\n-\t\tinternal->tx_queue[i].tx_stat.err_pkts = 0;\n-\t}\n+\tfor (i = 0; i < dev->data->nb_rx_queues; i++)\n+\t\tqueue_missed_stat_reset(dev, i);\n \n \treturn 0;\n }\n@@ -929,13 +863,6 @@ eth_rx_queue_setup(struct rte_eth_dev *dev,\n \t\t\t\tpcap_pkt_count);\n \t\t\treturn -EINVAL;\n \t\t}\n-\n-\t\t/*\n-\t\t * Reset the stats for this queue since eth_pcap_rx calls above\n-\t\t * didn't result in the application receiving packets.\n-\t\t */\n-\t\tpcap_q->rx_stat.pkts = 0;\n-\t\tpcap_q->rx_stat.bytes = 0;\n \t}\n \n \treturn 0;\n",
    "prefixes": [
        "v3",
        "5/7"
    ]
}