get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 123437,
    "url": "https://patches.dpdk.org/api/patches/123437/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20230208073401.2468579-2-mingxia.liu@intel.com/",
    "project": {
        "id": 1,
        "url": "https://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": "<20230208073401.2468579-2-mingxia.liu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230208073401.2468579-2-mingxia.liu@intel.com",
    "date": "2023-02-08T07:33:56",
    "name": "[v7,1/6] net/idpf: add hw statistics",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "8309bc3305a290295211500d3bab326f816ff191",
    "submitter": {
        "id": 2514,
        "url": "https://patches.dpdk.org/api/people/2514/?format=api",
        "name": "Liu, Mingxia",
        "email": "mingxia.liu@intel.com"
    },
    "delegate": {
        "id": 1540,
        "url": "https://patches.dpdk.org/api/users/1540/?format=api",
        "username": "qzhan15",
        "first_name": "Qi",
        "last_name": "Zhang",
        "email": "qi.z.zhang@intel.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20230208073401.2468579-2-mingxia.liu@intel.com/mbox/",
    "series": [
        {
            "id": 26883,
            "url": "https://patches.dpdk.org/api/series/26883/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=26883",
            "date": "2023-02-08T07:33:55",
            "name": "add idpf pmd enhancement features",
            "version": 7,
            "mbox": "https://patches.dpdk.org/series/26883/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/123437/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/123437/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 721DE41C3C;\n\tWed,  8 Feb 2023 09:31:57 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 7B9C042D40;\n\tWed,  8 Feb 2023 09:31:25 +0100 (CET)",
            "from mga04.intel.com (mga04.intel.com [192.55.52.120])\n by mails.dpdk.org (Postfix) with ESMTP id 1CF3941151\n for <dev@dpdk.org>; Wed,  8 Feb 2023 09:31:22 +0100 (CET)",
            "from orsmga005.jf.intel.com ([10.7.209.41])\n by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 08 Feb 2023 00:31:20 -0800",
            "from dpdk-mingxial-01.sh.intel.com ([10.67.119.167])\n by orsmga005.jf.intel.com with ESMTP; 08 Feb 2023 00:31:14 -0800"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1675845083; x=1707381083;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=QIYpXxiy57CB08hbHYJfQScgdsp5R6Jp5z15tCx4++Q=;\n b=EAlS7r4nKLFmlwZWe7t9ffuoTY/JuKZijc/ZfkjAg2zhNjD8pmcgds4o\n Z8PROPWb70xN3eu2qmOui6yNSofg2CiRJMtJEL/BSXEz8QBERnLXa1HBa\n F7i8L/K5a+1cTFk9r5shnt8aWHQOVnuavOSxh3F1OdUx7Zz72sZvMD4JB\n 5x33YcWC6SKcVdwkfuqoYMTOwLo4MeFYsIn/3vfF4urlvdtLo1qtDe/s2\n c15ZwtTiLGzek/BlePfDi4ListEYzFidPxO5KpYjAnkQL8BecxKk6xFrC\n ctIbnnl0mzb0+bquy8zsrQ4EOnwyf2YDTfKqveahwyVfNRHwB02lhMIlD Q==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6500,9779,10614\"; a=\"328399494\"",
            "E=Sophos;i=\"5.97,280,1669104000\"; d=\"scan'208\";a=\"328399494\"",
            "E=McAfee;i=\"6500,9779,10614\"; a=\"841100148\"",
            "E=Sophos;i=\"5.97,280,1669104000\"; d=\"scan'208\";a=\"841100148\""
        ],
        "X-ExtLoop1": "1",
        "From": "Mingxia Liu <mingxia.liu@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "jingjing.wu@intel.com, beilei.xing@intel.com,\n Mingxia Liu <mingxia.liu@intel.com>",
        "Subject": "[PATCH v7 1/6] net/idpf: add hw statistics",
        "Date": "Wed,  8 Feb 2023 07:33:56 +0000",
        "Message-Id": "<20230208073401.2468579-2-mingxia.liu@intel.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20230208073401.2468579-1-mingxia.liu@intel.com>",
        "References": "<20230207101650.2402452-1-mingxia.liu@intel.com>\n <20230208073401.2468579-1-mingxia.liu@intel.com>",
        "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": "This patch add hardware packets/bytes statistics.\n\nSigned-off-by: Mingxia Liu <mingxia.liu@intel.com>\n---\n drivers/common/idpf/idpf_common_device.c   | 17 +++++\n drivers/common/idpf/idpf_common_device.h   |  4 +\n drivers/common/idpf/idpf_common_virtchnl.c | 27 +++++++\n drivers/common/idpf/idpf_common_virtchnl.h |  3 +\n drivers/common/idpf/version.map            |  2 +\n drivers/net/idpf/idpf_ethdev.c             | 86 ++++++++++++++++++++++\n 6 files changed, 139 insertions(+)",
    "diff": "diff --git a/drivers/common/idpf/idpf_common_device.c b/drivers/common/idpf/idpf_common_device.c\nindex 48b3e3c0dd..5475a3e52c 100644\n--- a/drivers/common/idpf/idpf_common_device.c\n+++ b/drivers/common/idpf/idpf_common_device.c\n@@ -652,4 +652,21 @@ idpf_vport_info_init(struct idpf_vport *vport,\n \treturn 0;\n }\n \n+void\n+idpf_vport_stats_update(struct virtchnl2_vport_stats *oes, struct virtchnl2_vport_stats *nes)\n+{\n+\tnes->rx_bytes = nes->rx_bytes - oes->rx_bytes;\n+\tnes->rx_unicast = nes->rx_unicast - oes->rx_unicast;\n+\tnes->rx_multicast = nes->rx_multicast - oes->rx_multicast;\n+\tnes->rx_broadcast = nes->rx_broadcast - oes->rx_broadcast;\n+\tnes->rx_errors = nes->rx_errors - oes->rx_errors;\n+\tnes->rx_discards = nes->rx_discards - oes->rx_discards;\n+\tnes->tx_bytes = nes->tx_bytes - oes->tx_bytes;\n+\tnes->tx_unicast = nes->tx_unicast - oes->tx_unicast;\n+\tnes->tx_multicast = nes->tx_multicast - oes->tx_multicast;\n+\tnes->tx_broadcast = nes->tx_broadcast - oes->tx_broadcast;\n+\tnes->tx_errors = nes->tx_errors - oes->tx_errors;\n+\tnes->tx_discards = nes->tx_discards - oes->tx_discards;\n+}\n+\n RTE_LOG_REGISTER_SUFFIX(idpf_common_logtype, common, NOTICE);\ndiff --git a/drivers/common/idpf/idpf_common_device.h b/drivers/common/idpf/idpf_common_device.h\nindex 545117df79..1d8e7d405a 100644\n--- a/drivers/common/idpf/idpf_common_device.h\n+++ b/drivers/common/idpf/idpf_common_device.h\n@@ -115,6 +115,8 @@ struct idpf_vport {\n \tbool tx_vec_allowed;\n \tbool rx_use_avx512;\n \tbool tx_use_avx512;\n+\n+\tstruct virtchnl2_vport_stats eth_stats_offset;\n };\n \n /* Message type read in virtual channel from PF */\n@@ -191,5 +193,7 @@ int idpf_vport_irq_unmap_config(struct idpf_vport *vport, uint16_t nb_rx_queues)\n __rte_internal\n int idpf_vport_info_init(struct idpf_vport *vport,\n \t\t\t struct virtchnl2_create_vport *vport_info);\n+__rte_internal\n+void idpf_vport_stats_update(struct virtchnl2_vport_stats *oes, struct virtchnl2_vport_stats *nes);\n \n #endif /* _IDPF_COMMON_DEVICE_H_ */\ndiff --git a/drivers/common/idpf/idpf_common_virtchnl.c b/drivers/common/idpf/idpf_common_virtchnl.c\nindex 31fadefbd3..40cff34c09 100644\n--- a/drivers/common/idpf/idpf_common_virtchnl.c\n+++ b/drivers/common/idpf/idpf_common_virtchnl.c\n@@ -217,6 +217,7 @@ idpf_vc_cmd_execute(struct idpf_adapter *adapter, struct idpf_cmd_info *args)\n \tcase VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR:\n \tcase VIRTCHNL2_OP_ALLOC_VECTORS:\n \tcase VIRTCHNL2_OP_DEALLOC_VECTORS:\n+\tcase VIRTCHNL2_OP_GET_STATS:\n \t\t/* for init virtchnl ops, need to poll the response */\n \t\terr = idpf_vc_one_msg_read(adapter, args->ops, args->out_size, args->out_buffer);\n \t\tclear_cmd(adapter);\n@@ -806,6 +807,32 @@ idpf_vc_ptype_info_query(struct idpf_adapter *adapter)\n \treturn err;\n }\n \n+int\n+idpf_vc_stats_query(struct idpf_vport *vport,\n+\t\tstruct virtchnl2_vport_stats **pstats)\n+{\n+\tstruct idpf_adapter *adapter = vport->adapter;\n+\tstruct virtchnl2_vport_stats vport_stats;\n+\tstruct idpf_cmd_info args;\n+\tint err;\n+\n+\tvport_stats.vport_id = vport->vport_id;\n+\targs.ops = VIRTCHNL2_OP_GET_STATS;\n+\targs.in_args = (u8 *)&vport_stats;\n+\targs.in_args_size = sizeof(vport_stats);\n+\targs.out_buffer = adapter->mbx_resp;\n+\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n+\n+\terr = idpf_vc_cmd_execute(adapter, &args);\n+\tif (err) {\n+\t\tDRV_LOG(ERR, \"Failed to execute command of VIRTCHNL2_OP_GET_STATS\");\n+\t\t*pstats = NULL;\n+\t\treturn err;\n+\t}\n+\t*pstats = (struct virtchnl2_vport_stats *)args.out_buffer;\n+\treturn 0;\n+}\n+\n #define IDPF_RX_BUF_STRIDE\t\t64\n int\n idpf_vc_rxq_config(struct idpf_vport *vport, struct idpf_rx_queue *rxq)\ndiff --git a/drivers/common/idpf/idpf_common_virtchnl.h b/drivers/common/idpf/idpf_common_virtchnl.h\nindex c105f02836..6b94fd5b8f 100644\n--- a/drivers/common/idpf/idpf_common_virtchnl.h\n+++ b/drivers/common/idpf/idpf_common_virtchnl.h\n@@ -49,4 +49,7 @@ __rte_internal\n int idpf_vc_rxq_config(struct idpf_vport *vport, struct idpf_rx_queue *rxq);\n __rte_internal\n int idpf_vc_txq_config(struct idpf_vport *vport, struct idpf_tx_queue *txq);\n+__rte_internal\n+int idpf_vc_stats_query(struct idpf_vport *vport,\n+\t\t\tstruct virtchnl2_vport_stats **pstats);\n #endif /* _IDPF_COMMON_VIRTCHNL_H_ */\ndiff --git a/drivers/common/idpf/version.map b/drivers/common/idpf/version.map\nindex 8b33130bd6..e6a02828ba 100644\n--- a/drivers/common/idpf/version.map\n+++ b/drivers/common/idpf/version.map\n@@ -46,6 +46,7 @@ INTERNAL {\n \tidpf_vc_rss_key_set;\n \tidpf_vc_rss_lut_set;\n \tidpf_vc_rxq_config;\n+\tidpf_vc_stats_query;\n \tidpf_vc_txq_config;\n \tidpf_vc_vectors_alloc;\n \tidpf_vc_vectors_dealloc;\n@@ -59,6 +60,7 @@ INTERNAL {\n \tidpf_vport_irq_map_config;\n \tidpf_vport_irq_unmap_config;\n \tidpf_vport_rss_config;\n+\tidpf_vport_stats_update;\n \n \tlocal: *;\n };\ndiff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c\nindex 33f5e90743..02ddb0330a 100644\n--- a/drivers/net/idpf/idpf_ethdev.c\n+++ b/drivers/net/idpf/idpf_ethdev.c\n@@ -140,6 +140,87 @@ idpf_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused)\n \treturn ptypes;\n }\n \n+static uint64_t\n+idpf_get_mbuf_alloc_failed_stats(struct rte_eth_dev *dev)\n+{\n+\tuint64_t mbuf_alloc_failed = 0;\n+\tstruct idpf_rx_queue *rxq;\n+\tint i = 0;\n+\n+\tfor (i = 0; i < dev->data->nb_rx_queues; i++) {\n+\t\trxq = dev->data->rx_queues[i];\n+\t\tmbuf_alloc_failed += __atomic_load_n(&rxq->rx_stats.mbuf_alloc_failed,\n+\t\t\t\t\t\t     __ATOMIC_RELAXED);\n+\t}\n+\n+\treturn mbuf_alloc_failed;\n+}\n+\n+static int\n+idpf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)\n+{\n+\tstruct idpf_vport *vport =\n+\t\t(struct idpf_vport *)dev->data->dev_private;\n+\tstruct virtchnl2_vport_stats *pstats = NULL;\n+\tint ret;\n+\n+\tret = idpf_vc_stats_query(vport, &pstats);\n+\tif (ret == 0) {\n+\t\tuint8_t crc_stats_len = (dev->data->dev_conf.rxmode.offloads &\n+\t\t\t\t\t RTE_ETH_RX_OFFLOAD_KEEP_CRC) ? 0 :\n+\t\t\t\t\t RTE_ETHER_CRC_LEN;\n+\n+\t\tidpf_vport_stats_update(&vport->eth_stats_offset, pstats);\n+\t\tstats->ipackets = pstats->rx_unicast + pstats->rx_multicast +\n+\t\t\t\tpstats->rx_broadcast - pstats->rx_discards;\n+\t\tstats->opackets = pstats->tx_broadcast + pstats->tx_multicast +\n+\t\t\t\t\t\tpstats->tx_unicast;\n+\t\tstats->imissed = pstats->rx_discards;\n+\t\tstats->oerrors = pstats->tx_errors + pstats->tx_discards;\n+\t\tstats->ibytes = pstats->rx_bytes;\n+\t\tstats->ibytes -= stats->ipackets * crc_stats_len;\n+\t\tstats->obytes = pstats->tx_bytes;\n+\n+\t\tdev->data->rx_mbuf_alloc_failed = idpf_get_mbuf_alloc_failed_stats(dev);\n+\t\tstats->rx_nombuf = dev->data->rx_mbuf_alloc_failed;\n+\t} else {\n+\t\tPMD_DRV_LOG(ERR, \"Get statistics failed\");\n+\t}\n+\treturn ret;\n+}\n+\n+static void\n+idpf_reset_mbuf_alloc_failed_stats(struct rte_eth_dev *dev)\n+{\n+\tstruct idpf_rx_queue *rxq;\n+\tint i;\n+\n+\tfor (i = 0; i < dev->data->nb_rx_queues; i++) {\n+\t\trxq = dev->data->rx_queues[i];\n+\t\t__atomic_store_n(&rxq->rx_stats.mbuf_alloc_failed, 0, __ATOMIC_RELAXED);\n+\t}\n+}\n+\n+static int\n+idpf_dev_stats_reset(struct rte_eth_dev *dev)\n+{\n+\tstruct idpf_vport *vport =\n+\t\t(struct idpf_vport *)dev->data->dev_private;\n+\tstruct virtchnl2_vport_stats *pstats = NULL;\n+\tint ret;\n+\n+\tret = idpf_vc_stats_query(vport, &pstats);\n+\tif (ret != 0)\n+\t\treturn ret;\n+\n+\t/* set stats offset base on current values */\n+\tvport->eth_stats_offset = *pstats;\n+\n+\tidpf_reset_mbuf_alloc_failed_stats(dev);\n+\n+\treturn 0;\n+}\n+\n static int\n idpf_init_rss(struct idpf_vport *vport)\n {\n@@ -327,6 +408,9 @@ idpf_dev_start(struct rte_eth_dev *dev)\n \t\tgoto err_vport;\n \t}\n \n+\tif (idpf_dev_stats_reset(dev))\n+\t\tPMD_DRV_LOG(ERR, \"Failed to reset stats\");\n+\n \tvport->stopped = 0;\n \n \treturn 0;\n@@ -606,6 +690,8 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {\n \t.tx_queue_release\t\t= idpf_dev_tx_queue_release,\n \t.mtu_set\t\t\t= idpf_dev_mtu_set,\n \t.dev_supported_ptypes_get\t= idpf_dev_supported_ptypes_get,\n+\t.stats_get\t\t\t= idpf_dev_stats_get,\n+\t.stats_reset\t\t\t= idpf_dev_stats_reset,\n };\n \n static uint16_t\n",
    "prefixes": [
        "v7",
        "1/6"
    ]
}