Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/139740/?format=api
http://patches.dpdk.org/api/patches/139740/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20240430154129.7347-1-stephen@networkplumber.org/", "project": { "id": 1, "url": "http://patches.dpdk.org/api/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", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20240430154129.7347-1-stephen@networkplumber.org>", "list_archive_url": "https://inbox.dpdk.org/dev/20240430154129.7347-1-stephen@networkplumber.org", "date": "2024-04-30T15:39:46", "name": "net/af_packet: fix statistics", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "bcb1e82eba993e3b3f4f2b35fe13676dfb3771c3", "submitter": { "id": 27, "url": "http://patches.dpdk.org/api/people/27/?format=api", "name": "Stephen Hemminger", "email": "stephen@networkplumber.org" }, "delegate": { "id": 319, "url": "http://patches.dpdk.org/api/users/319/?format=api", "username": "fyigit", "first_name": "Ferruh", "last_name": "Yigit", "email": "ferruh.yigit@amd.com" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20240430154129.7347-1-stephen@networkplumber.org/mbox/", "series": [ { "id": 31845, "url": "http://patches.dpdk.org/api/series/31845/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=31845", "date": "2024-04-30T15:39:46", "name": "net/af_packet: fix statistics", "version": 1, "mbox": "http://patches.dpdk.org/series/31845/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/139740/comments/", "check": "fail", "checks": "http://patches.dpdk.org/api/patches/139740/checks/", "tags": {}, "related": [], "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 6C67943F05;\n\tTue, 30 Apr 2024 17:41:42 +0200 (CEST)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id E87F14025C;\n\tTue, 30 Apr 2024 17:41:41 +0200 (CEST)", "from mail-pj1-f46.google.com (mail-pj1-f46.google.com\n [209.85.216.46]) by mails.dpdk.org (Postfix) with ESMTP id 287D1400EF\n for <dev@dpdk.org>; Tue, 30 Apr 2024 17:41:40 +0200 (CEST)", "by mail-pj1-f46.google.com with SMTP id\n 98e67ed59e1d1-2a2d82537efso4062483a91.2\n for <dev@dpdk.org>; Tue, 30 Apr 2024 08:41:40 -0700 (PDT)", "from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226])\n by smtp.gmail.com with ESMTPSA id\n z3-20020a170903018300b001ec38cdc133sm1724057plg.260.2024.04.30.08.41.38\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 30 Apr 2024 08:41:38 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1714491699;\n x=1715096499; darn=dpdk.org;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:from:to:cc:subject:date:message-id:reply-to;\n bh=q8hJBGVhtgF1yQH3NG2ZqTJNslHUE9K+DYFcGr0nXnM=;\n b=lq6ISv4U/oJSyIwKWNIbSKIIxfFOyaiyGAR1uK0Qu8FJax0nmKEp7ZBiIFrSMrL8pA\n ANCKCDXQ+moEA/NZ4sbV9cNQAVUHBWn47H/QdUHeSKOahL7rq7fts054C1mw5zzR8AC2\n Hfz2xPU37yTbtop5DL8ipylP6ioLTDusrOxvOvr3PxLsp5H6oeJuUc6pqgGH1xAYNDgA\n B0QKGvqHAl3xXgIPYHHasXvym9UKBJzo43uHzYHGOpQOK3M3nKHyiXaexHiCetv09H6A\n 1bPFmT4deK05h0y6KH5i1RlF/X3g2r81zgbeqsKA1Tio+bx/sDoLp926fXLhJWWCI8sc\n 44iQ==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1714491699; x=1715096499;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:x-gm-message-state:from:to:cc:subject:date:message-id\n :reply-to;\n bh=q8hJBGVhtgF1yQH3NG2ZqTJNslHUE9K+DYFcGr0nXnM=;\n b=VrxwAm7cdwV5PmAv609O9RD1gNKPUdpwBWxrJ65t1a1HX9WenZ4h0Fm/cKSNbYX4Ok\n RavllBq98mpLXPFz4Jr6jBJfiNV3kDml2OMaE2oE3N5MmX6WylhmI0J6msA8hk8Nwp+n\n xhNLkfwvFoji6Do92f4uZNvJfdvNql0nX83YZs3xfamykaZAkn4sSgIUu5659KxGZ41o\n 5DTQr08UZIkE+doPY7zJQqyoGVg8sTUXc7hY3UNtTGmW/0jvcUif1XqSA6t92u0rC+r9\n cL9ar6/M6CwE48mLuu8hqaZNfWw/2rBmYiKf1NS/pjLRcrO4JSSO4ILNyLXtiPZLtNpL\n 3IQg==", "X-Gm-Message-State": "AOJu0YzsIBgrAxxCeTOfeYxn4wZaiaSKO378O6wZzbHRTLfqvUsOAFu6\n bduhttMhzHViIMv0y/NAX9P2VHWXFTq8c4KtEm26vycaz/oBsnt92zkplio1drrHE2pMuldAXtO\n R", "X-Google-Smtp-Source": "\n AGHT+IFLLWn6F8a5w60iJh1BZBoj2aoC99FEZwGKX1XgVgu0LQX+xWXE9lbzY+HkqA0tdA6niM6ywg==", "X-Received": "by 2002:a17:90a:654c:b0:2ac:dbec:2d6f with SMTP id\n f12-20020a17090a654c00b002acdbec2d6fmr13731171pjs.39.1714491699103;\n Tue, 30 Apr 2024 08:41:39 -0700 (PDT)", "From": "Stephen Hemminger <stephen@networkplumber.org>", "To": "dev@dpdk.org", "Cc": "Stephen Hemminger <stephen@networkplumber.org>,\n \"John W. Linville\" <linville@tuxdriver.com>", "Subject": "[PATCH] net/af_packet: fix statistics", "Date": "Tue, 30 Apr 2024 08:39:46 -0700", "Message-ID": "<20240430154129.7347-1-stephen@networkplumber.org>", "X-Mailer": "git-send-email 2.43.0", "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": "The statistics in af_packet driver do not follow the standard\npractice of other drivers:\n\n - Statistics should be maintained as 64 bit even on 32 bit.\n\n - Remove the tx_error counter since it was not correct.\n When transmit ring is full it is not an error and\n the driver correctly returns only the number sent.\n\n - Query kernel to find the number of packets missed.\n\n - Do not mark statistics as volatile.\n Instead, READ_ONCE() where necessary.\n\nAlso, the variable namge igb_stats looks like a copy/paste leftover\n\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\n---\n drivers/net/af_packet/rte_eth_af_packet.c | 82 +++++++++++++----------\n 1 file changed, 48 insertions(+), 34 deletions(-)", "diff": "diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c\nindex 397a32db58..0313aee482 100644\n--- a/drivers/net/af_packet/rte_eth_af_packet.c\n+++ b/drivers/net/af_packet/rte_eth_af_packet.c\n@@ -39,6 +39,10 @@\n #define DFLT_FRAME_SIZE\t\t(1 << 11)\n #define DFLT_FRAME_COUNT\t(1 << 9)\n \n+#ifndef READ_ONCE\n+#define READ_ONCE(var) (*((volatile typeof(var) *)(&(var))))\n+#endif\n+\n struct pkt_rx_queue {\n \tint sockfd;\n \n@@ -51,8 +55,8 @@ struct pkt_rx_queue {\n \tuint16_t in_port;\n \tuint8_t vlan_strip;\n \n-\tvolatile unsigned long rx_pkts;\n-\tvolatile unsigned long rx_bytes;\n+\tuint64_t rx_pkts;\n+\tuint64_t rx_bytes;\n };\n \n struct pkt_tx_queue {\n@@ -64,9 +68,8 @@ struct pkt_tx_queue {\n \tunsigned int framecount;\n \tunsigned int framenum;\n \n-\tvolatile unsigned long tx_pkts;\n-\tvolatile unsigned long err_pkts;\n-\tvolatile unsigned long tx_bytes;\n+\tuint64_t tx_pkts;\n+\tuint64_t tx_bytes;\n };\n \n struct pmd_internals {\n@@ -305,7 +308,6 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)\n \n \tpkt_q->framenum = framenum;\n \tpkt_q->tx_pkts += num_tx;\n-\tpkt_q->err_pkts += i - num_tx;\n \tpkt_q->tx_bytes += num_tx_bytes;\n \treturn i;\n }\n@@ -386,54 +388,66 @@ eth_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)\n }\n \n static int\n-eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats)\n+eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)\n {\n-\tunsigned i, imax;\n-\tunsigned long rx_total = 0, tx_total = 0, tx_err_total = 0;\n-\tunsigned long rx_bytes_total = 0, tx_bytes_total = 0;\n+\tunsigned int i;\n \tconst struct pmd_internals *internal = dev->data->dev_private;\n+\tuint64_t bytes, packets;\n+\n+\tfor (i = 0; i < internal->nb_queues; i++) {\n+\t\tconst struct pkt_rx_queue *rxq = &internal->rx_queue[i];\n+\t\tstruct tpacket_stats pkt_stats;\n+\t\tsocklen_t optlen = sizeof(pkt_stats);\n+\t\tint fd = rxq->sockfd;\n+\n+\t\tbytes = READ_ONCE(rxq->rx_bytes);\n+\t\tpackets = READ_ONCE(rxq->rx_pkts);\n \n-\timax = (internal->nb_queues < RTE_ETHDEV_QUEUE_STAT_CNTRS ?\n-\t internal->nb_queues : RTE_ETHDEV_QUEUE_STAT_CNTRS);\n-\tfor (i = 0; i < imax; i++) {\n-\t\tigb_stats->q_ipackets[i] = internal->rx_queue[i].rx_pkts;\n-\t\tigb_stats->q_ibytes[i] = internal->rx_queue[i].rx_bytes;\n-\t\trx_total += igb_stats->q_ipackets[i];\n-\t\trx_bytes_total += igb_stats->q_ibytes[i];\n+\t\tstats->ipackets += packets;\n+\t\tstats->ibytes += bytes;\n+\n+\t\tif (i < RTE_ETHDEV_QUEUE_STAT_CNTRS) {\n+\t\t\tstats->q_ipackets[i] = packets;\n+\t\t\tstats->q_ibytes[i] = bytes;\n+\t\t}\n+\n+\t\tif (getsockopt(fd, SOL_PACKET, PACKET_STATISTICS, &pkt_stats, &optlen) < 0) {\n+\t\t\tPMD_LOG_ERRNO(ERR, \"could not getet PACKET_STATISTICS on AF_PACKET socket\");\n+\t\t\treturn -1;\n+\t\t}\n+\t\tstats->imissed = pkt_stats.tp_drops;\n \t}\n \n-\timax = (internal->nb_queues < RTE_ETHDEV_QUEUE_STAT_CNTRS ?\n-\t internal->nb_queues : RTE_ETHDEV_QUEUE_STAT_CNTRS);\n-\tfor (i = 0; i < imax; i++) {\n-\t\tigb_stats->q_opackets[i] = internal->tx_queue[i].tx_pkts;\n-\t\tigb_stats->q_obytes[i] = internal->tx_queue[i].tx_bytes;\n-\t\ttx_total += igb_stats->q_opackets[i];\n-\t\ttx_err_total += internal->tx_queue[i].err_pkts;\n-\t\ttx_bytes_total += igb_stats->q_obytes[i];\n+\tfor (i = 0; i < internal->nb_queues; i++) {\n+\t\tconst struct pkt_tx_queue *txq = &internal->tx_queue[i];\n+\n+\t\tbytes = READ_ONCE(txq->tx_bytes);\n+\t\tpackets = READ_ONCE(txq->tx_pkts);\n+\n+\t\tstats->opackets += packets;\n+\t\tstats->obytes += bytes;\n+\n+\t\tif (i < RTE_ETHDEV_QUEUE_STAT_CNTRS) {\n+\t\t\tstats->q_opackets[i] = packets;\n+\t\t\tstats->q_obytes[i] = bytes;\n+\t\t}\n \t}\n \n-\tigb_stats->ipackets = rx_total;\n-\tigb_stats->ibytes = rx_bytes_total;\n-\tigb_stats->opackets = tx_total;\n-\tigb_stats->oerrors = tx_err_total;\n-\tigb_stats->obytes = tx_bytes_total;\n+\n \treturn 0;\n }\n \n static int\n eth_stats_reset(struct rte_eth_dev *dev)\n {\n-\tunsigned i;\n+\tunsigned int i;\n \tstruct pmd_internals *internal = dev->data->dev_private;\n \n \tfor (i = 0; i < internal->nb_queues; i++) {\n \t\tinternal->rx_queue[i].rx_pkts = 0;\n \t\tinternal->rx_queue[i].rx_bytes = 0;\n-\t}\n \n-\tfor (i = 0; i < internal->nb_queues; i++) {\n \t\tinternal->tx_queue[i].tx_pkts = 0;\n-\t\tinternal->tx_queue[i].err_pkts = 0;\n \t\tinternal->tx_queue[i].tx_bytes = 0;\n \t}\n \n", "prefixes": [] }{ "id": 139740, "url": "