get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 120977,
    "url": "http://patches.dpdk.org/api/patches/120977/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20221216093706.2453812-2-mingxia.liu@intel.com/",
    "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": "<20221216093706.2453812-2-mingxia.liu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20221216093706.2453812-2-mingxia.liu@intel.com",
    "date": "2022-12-16T09:37:00",
    "name": "[1/7] common/idpf: add hw statistics",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "92368aa4ddb72075b7616e129a90423e73319b3a",
    "submitter": {
        "id": 2514,
        "url": "http://patches.dpdk.org/api/people/2514/?format=api",
        "name": "Liu, Mingxia",
        "email": "mingxia.liu@intel.com"
    },
    "delegate": {
        "id": 1540,
        "url": "http://patches.dpdk.org/api/users/1540/?format=api",
        "username": "qzhan15",
        "first_name": "Qi",
        "last_name": "Zhang",
        "email": "qi.z.zhang@intel.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20221216093706.2453812-2-mingxia.liu@intel.com/mbox/",
    "series": [
        {
            "id": 26162,
            "url": "http://patches.dpdk.org/api/series/26162/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=26162",
            "date": "2022-12-16T09:36:59",
            "name": "add idpf pmd enhancement features",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/26162/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/120977/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/120977/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 A6E00A0093;\n\tFri, 16 Dec 2022 11:32:48 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id E8E2842D27;\n\tFri, 16 Dec 2022 11:32:47 +0100 (CET)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n by mails.dpdk.org (Postfix) with ESMTP id ECCE242D23\n for <dev@dpdk.org>; Fri, 16 Dec 2022 11:32:44 +0100 (CET)",
            "from fmsmga008.fm.intel.com ([10.253.24.58])\n by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 16 Dec 2022 02:32:21 -0800",
            "from dpdk-mingxial-01.sh.intel.com ([10.67.119.112])\n by fmsmga008.fm.intel.com with ESMTP; 16 Dec 2022 02:32:19 -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=1671186766; x=1702722766;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=Qe1AwK9ljszNLmhsv1e8MLwx4jtzMhCuReOIaGiTItE=;\n b=VHWrDKjD6Xij9RXxmV1vhbeZLMtjfO/PUdeX9KUEjDXyEozCUS9gveVe\n D7N6/nbZZFFdJ9nNwbltmN0qoWDLT+bQ7rRT/GknqM68vtXdJrLd4m6Oy\n SaZYA0TwxbXjv36gkH7+NKJJzCUhHXXniyTT0slSyCqDSg7yak5qUF1Um\n 01HnOsXre1wLuPr2B8lhQMu2+2ntMvOcV2jbfHgcWzG9aEM8b1CRyrrrt\n QkHO3O93aX0xkzKLgIiB9DBRU2hyznSpufxh6JxU9F5vjxXRQkOChaEtz\n F7r0aguOlnLuWZ1VieW7u6LNUZ8BtOtcQE4brOkUv+mfWs2KTUmw6WAkr w==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6500,9779,10562\"; a=\"306616599\"",
            "E=Sophos;i=\"5.96,249,1665471600\"; d=\"scan'208\";a=\"306616599\"",
            "E=McAfee;i=\"6500,9779,10562\"; a=\"713230843\"",
            "E=Sophos;i=\"5.96,249,1665471600\"; d=\"scan'208\";a=\"713230843\""
        ],
        "X-ExtLoop1": "1",
        "From": "Mingxia Liu <mingxia.liu@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "jingjing.wu@intel.com, beilei.xing@intel.com, qi.z.zhang@intel.com,\n Mingxia Liu <mingxia.liu@intel.com>",
        "Subject": "[PATCH 1/7] common/idpf: add hw statistics",
        "Date": "Fri, 16 Dec 2022 09:37:00 +0000",
        "Message-Id": "<20221216093706.2453812-2-mingxia.liu@intel.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20221216093706.2453812-1-mingxia.liu@intel.com>",
        "References": "<20221216093706.2453812-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   |  5 +-\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             | 87 ++++++++++++++++++++++\n 6 files changed, 140 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/drivers/common/idpf/idpf_common_device.c b/drivers/common/idpf/idpf_common_device.c\nindex 3580028dce..49ed778831 100644\n--- a/drivers/common/idpf/idpf_common_device.c\n+++ b/drivers/common/idpf/idpf_common_device.c\n@@ -672,4 +672,21 @@ idpf_create_vport_info_init(struct idpf_vport *vport,\n \treturn 0;\n }\n \n+void\n+idpf_update_stats(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 6c9a65ae3b..5184dcee9f 100644\n--- a/drivers/common/idpf/idpf_common_device.h\n+++ b/drivers/common/idpf/idpf_common_device.h\n@@ -112,6 +112,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@@ -188,5 +190,6 @@ int idpf_config_irq_unmap(struct idpf_vport *vport, uint16_t nb_rx_queues);\n __rte_internal\n int idpf_create_vport_info_init(struct idpf_vport *vport,\n \t\t\t\tstruct virtchnl2_create_vport *vport_info);\n-\n+__rte_internal\n+void idpf_update_stats(struct virtchnl2_vport_stats *oes, struct virtchnl2_vport_stats *nes);\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 324214caa1..80351d15de 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_execute_vc_cmd(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_read_one_msg(adapter, args->ops, args->out_size, args->out_buffer);\n \t\tclear_cmd(adapter);\n@@ -806,6 +807,32 @@ idpf_vc_query_ptype_info(struct idpf_adapter *adapter)\n \treturn err;\n }\n \n+int\n+idpf_query_stats(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_execute_vc_cmd(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_config_rxq(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 d16b6b66f4..60347fe571 100644\n--- a/drivers/common/idpf/idpf_common_virtchnl.h\n+++ b/drivers/common/idpf/idpf_common_virtchnl.h\n@@ -38,4 +38,7 @@ __rte_internal\n int idpf_vc_config_rxq(struct idpf_vport *vport, struct idpf_rx_queue *rxq);\n __rte_internal\n int idpf_vc_config_txq(struct idpf_vport *vport, struct idpf_tx_queue *txq);\n+__rte_internal\n+int idpf_query_stats(struct idpf_vport *vport,\n+\t\t     struct 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 7018a1d695..6a1dc13302 100644\n--- a/drivers/common/idpf/version.map\n+++ b/drivers/common/idpf/version.map\n@@ -50,6 +50,8 @@ INTERNAL {\n \tidpf_splitq_recv_pkts_avx512;\n \tidpf_singleq_xmit_pkts_avx512;\n \tidpf_splitq_xmit_pkts_avx512;\n+\tidpf_update_stats;\n+\tidpf_query_stats;\n \n \tlocal: *;\n };\ndiff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c\nindex a70ae65558..1b1b0f30fd 100644\n--- a/drivers/net/idpf/idpf_ethdev.c\n+++ b/drivers/net/idpf/idpf_ethdev.c\n@@ -131,6 +131,86 @@ 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 += rxq->rx_stats.mbuf_alloc_failed;\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_query_stats(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_update_stats(&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\trxq->rx_stats.mbuf_alloc_failed = 0;\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_query_stats(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@@ -324,6 +404,11 @@ 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+\t\tgoto err_vport;\n+\t}\n+\n \treturn 0;\n \n err_vport:\n@@ -597,6 +682,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": [
        "1/7"
    ]
}