get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 121810,
    "url": "https://patches.dpdk.org/api/patches/121810/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20230111071545.504706-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": "<20230111071545.504706-2-mingxia.liu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230111071545.504706-2-mingxia.liu@intel.com",
    "date": "2023-01-11T07:15:40",
    "name": "[v2,1/6] common/idpf: add hw statistics",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "28bc467d24cfd4f64ae805a5a5779d2165494c59",
    "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/20230111071545.504706-2-mingxia.liu@intel.com/mbox/",
    "series": [
        {
            "id": 26469,
            "url": "https://patches.dpdk.org/api/series/26469/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=26469",
            "date": "2023-01-11T07:15:39",
            "name": "add idpf pmd enhancement features",
            "version": 1,
            "mbox": "https://patches.dpdk.org/series/26469/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/121810/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/121810/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 095D7423AA;\n\tWed, 11 Jan 2023 09:13:05 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 2DB9F42D1F;\n\tWed, 11 Jan 2023 09:13:03 +0100 (CET)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n by mails.dpdk.org (Postfix) with ESMTP id 7363F41611\n for <dev@dpdk.org>; Wed, 11 Jan 2023 09:13:00 +0100 (CET)",
            "from orsmga005.jf.intel.com ([10.7.209.41])\n by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 11 Jan 2023 00:13:00 -0800",
            "from dpdk-mingxial-01.sh.intel.com ([10.67.119.112])\n by orsmga005.jf.intel.com with ESMTP; 11 Jan 2023 00:12:58 -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=1673424780; x=1704960780;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=ErbpORnGNFqL8iHqzyES7MIFC9bilyJzYYBJGsrQobg=;\n b=E0O/dSUGYBHx7SH8aoujhvp22XuebssGULFJvgmg6CVnZoFYLm3oRWcI\n Ipqf8HkWnmQyPI+XKqpzZX9m+ALk1xxpHY85eb/yF3INIAiTaH1cZRyPy\n zDeQDQzFA/KdrFJ7EXbe+7Y0F20zB9sbpFjRwyrLSMAtH/DI568asNxf7\n z2wPVjm70YbD+kAi2AwJdwzmygTg6aD97Ed7ZS8Q2RWxKAQgOVQ7WsF8p\n XsjilMq2EYzEc+TB3MNDr/qW6sZY5mB6oeryc68hCsOvRqLPXz/RCpCXN\n 2LD07rSPqRyY9AMhxYBMr+7u9InXyhizo/rMdxPErjko723Dbp7VkJWK5 Q==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6500,9779,10586\"; a=\"311167467\"",
            "E=Sophos;i=\"5.96,315,1665471600\"; d=\"scan'208\";a=\"311167467\"",
            "E=McAfee;i=\"6500,9779,10586\"; a=\"831271375\"",
            "E=Sophos;i=\"5.96,315,1665471600\"; d=\"scan'208\";a=\"831271375\""
        ],
        "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 v2 1/6] common/idpf: add hw statistics",
        "Date": "Wed, 11 Jan 2023 07:15:40 +0000",
        "Message-Id": "<20230111071545.504706-2-mingxia.liu@intel.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20230111071545.504706-1-mingxia.liu@intel.com>",
        "References": "<20221216093706.2453812-1-mingxia.liu@intel.com>\n <20230111071545.504706-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 4e257a68fd..4adbb6f399 100644\n--- a/drivers/common/idpf/idpf_common_device.c\n+++ b/drivers/common/idpf/idpf_common_device.c\n@@ -661,4 +661,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 ee2dec7c7c..e8bb097c78 100644\n--- a/drivers/net/idpf/idpf_ethdev.c\n+++ b/drivers/net/idpf/idpf_ethdev.c\n@@ -140,6 +140,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 += rte_atomic64_read(&(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\trte_atomic64_set(&(rxq->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@@ -327,6 +407,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 \tvport->stopped = 0;\n \n \treturn 0;\n@@ -606,6 +691,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": [
        "v2",
        "1/6"
    ]
}