get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 112770,
    "url": "https://patches.dpdk.org/api/patches/112770/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20220615125836.391771-7-spiked@nvidia.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": "<20220615125836.391771-7-spiked@nvidia.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20220615125836.391771-7-spiked@nvidia.com",
    "date": "2022-06-15T12:58:36",
    "name": "[v8,6/6] app/testpmd: add Host Shaper command",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "5e906871612ee3c683ed9cd6e67eefbdbea6a395",
    "submitter": {
        "id": 2637,
        "url": "https://patches.dpdk.org/api/people/2637/?format=api",
        "name": "Spike Du",
        "email": "spiked@nvidia.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20220615125836.391771-7-spiked@nvidia.com/mbox/",
    "series": [
        {
            "id": 23538,
            "url": "https://patches.dpdk.org/api/series/23538/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=23538",
            "date": "2022-06-15T12:58:30",
            "name": "introduce per-queue available descriptor threshold and host shaper",
            "version": 8,
            "mbox": "https://patches.dpdk.org/series/23538/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/112770/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/112770/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 E996EA0548;\n\tWed, 15 Jun 2022 15:09:54 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 8819942B88;\n\tWed, 15 Jun 2022 15:09:27 +0200 (CEST)",
            "from NAM12-BN8-obe.outbound.protection.outlook.com\n (mail-bn8nam12on2085.outbound.protection.outlook.com [40.107.237.85])\n by mails.dpdk.org (Postfix) with ESMTP id 19DDE41148\n for <dev@dpdk.org>; Wed, 15 Jun 2022 15:09:26 +0200 (CEST)",
            "from DM5PR19CA0022.namprd19.prod.outlook.com (2603:10b6:3:151::32)\n by PH7PR12MB5618.namprd12.prod.outlook.com (2603:10b6:510:134::14) with\n Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.22; Wed, 15 Jun\n 2022 12:59:16 +0000",
            "from DM6NAM11FT023.eop-nam11.prod.protection.outlook.com\n (2603:10b6:3:151:cafe::d9) by DM5PR19CA0022.outlook.office365.com\n (2603:10b6:3:151::32) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.14 via Frontend\n Transport; Wed, 15 Jun 2022 12:59:15 +0000",
            "from mail.nvidia.com (12.22.5.238) by\n DM6NAM11FT023.mail.protection.outlook.com (10.13.173.96) with Microsoft SMTP\n Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id\n 15.20.5332.12 via Frontend Transport; Wed, 15 Jun 2022 12:59:15 +0000",
            "from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL105.nvidia.com\n (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.32;\n Wed, 15 Jun 2022 12:59:15 +0000",
            "from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com\n (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Wed, 15 Jun\n 2022 05:59:10 -0700"
        ],
        "ARC-Seal": "i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;\n b=ayIwMwY/wvEq6JwvaQYjTQdPn/U/LXgW4/95WwHZ5k2NDCFHr3+7C+XdyYPIQZ9je/LhYm5IN5qVrl5UpNnCjOerMX5NXku9UZAl1GpJSC8cEJUUwKatiLin8/OqQV8s38aqlNQugt6tqdnCTCMofi/2GN1I/l1EGux2Ca3utON0t9qaGPGUv5VGi6luKBeMHHFXBUfaAaGqLCzrlzKo+0aQn+HcVSbtAl4uzpRrcY08JduxJz9QqS0+h0aKDudYTBkQ0QcVfPn3piwBZeEMrLYsgPaOUWLBK9tbJ/OvtPXQo7USuJe8Eygt4Li3xBypBz4I+uP8jLcpDacrEWjP7A==",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n s=arcselector9901;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;\n bh=LhhaG+kqPle2OAEsawO1hUs7HhdBkskic3DLqbyClnk=;\n b=Y1bQHbS7m4zOc5xGGkKEGjtyiqkaSOr+LUgzFu+uqJ0NHJCyORe+4QVUZHqsy+MvPvaf2tvqRqLN9JGjwlTiY8T4mss7knjuk2V4lm5HbkPWs/UvZ2m0ThKX03xGRGuZYrmNafWrVME2mRftyqyAE0My09KdYGAZIBO6e2H7vP7rV2SzSU2p7KkG8M/El7VnGTl/dL+0MTRO2pLETlhNq8Qt+ThY1zklfzBvvFZ6/1Q9qHI6/s9id0qVgFW7p9z/wEGW7N7vkPLIEMq6aM8AtXOW5hDMcV92a9WOuHesFmLZG+R4y+g6l/YylAKsqIa6YD4wwo+ubepxkNNy1s5+2Q==",
        "ARC-Authentication-Results": "i=1; mx.microsoft.com 1; spf=pass (sender ip is\n 12.22.5.238) smtp.rcpttodomain=networkplumber.org smtp.mailfrom=nvidia.com;\n dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com;\n dkim=none (message not signed); arc=none",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com;\n s=selector2;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n bh=LhhaG+kqPle2OAEsawO1hUs7HhdBkskic3DLqbyClnk=;\n b=c7VgNb9sbQXcRJJYCPLSUrCDKx+ioBgEtgSgSF9QK83JIzCVHd/1c6ZK87FlNQjbvmHFF9NPtXoXu7QDPa+cYFXDW2VvbmVq+EPvcg03IuJK2sDUeJauPwgBiE7wM1Zx7DKMubw4wtOhSpP3HJgL1ab//RHAlCWPrmv/cgIuEqQhpqbmTSrpWsam5/VJhOZkL5Z83lQerkrCJOzz+SOH9Ye7eyHyt7wFZ4TZmtd3p9n9XVGHqODfKg4V+2gK27OD/qH63zBJukua9wnCqV2tLIA05+fZK2jIo6ILv0MEeQbdBzlKTqpVN/U9sVVd/S0Zk/7fW7Pr3BaVPzHpojoRMg==",
        "X-MS-Exchange-Authentication-Results": "spf=pass (sender IP is 12.22.5.238)\n smtp.mailfrom=nvidia.com; dkim=none (message not signed)\n header.d=none;dmarc=pass action=none header.from=nvidia.com;",
        "Received-SPF": "Pass (protection.outlook.com: domain of nvidia.com designates\n 12.22.5.238 as permitted sender) receiver=protection.outlook.com;\n client-ip=12.22.5.238; helo=mail.nvidia.com; pr=C",
        "From": "Spike Du <spiked@nvidia.com>",
        "To": "<matan@nvidia.com>, <viacheslavo@nvidia.com>, <orika@nvidia.com>,\n <thomas@monjalon.net>, Wenzhuo Lu <wenzhuo.lu@intel.com>, Beilei Xing\n <beilei.xing@intel.com>, Bernard Iremonger <bernard.iremonger@intel.com>,\n Shahaf Shuler <shahafs@nvidia.com>",
        "CC": "<andrew.rybchenko@oktetlabs.ru>, <stephen@networkplumber.org>,\n <mb@smartsharesystems.com>, <dev@dpdk.org>, <rasland@nvidia.com>",
        "Subject": "[PATCH v8 6/6] app/testpmd: add Host Shaper command",
        "Date": "Wed, 15 Jun 2022 15:58:36 +0300",
        "Message-ID": "<20220615125836.391771-7-spiked@nvidia.com>",
        "X-Mailer": "git-send-email 2.27.0",
        "In-Reply-To": "<20220615125836.391771-1-spiked@nvidia.com>",
        "References": "<20220614120134.1828188-2-spiked@nvidia.com>\n <20220615125836.391771-1-spiked@nvidia.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Originating-IP": "[10.126.230.35]",
        "X-ClientProxiedBy": "rnnvmail202.nvidia.com (10.129.68.7) To\n rnnvmail201.nvidia.com (10.129.68.8)",
        "X-EOPAttributedMessage": "0",
        "X-MS-PublicTrafficType": "Email",
        "X-MS-Office365-Filtering-Correlation-Id": "730a2e09-03b7-4e11-a414-08da4eceda24",
        "X-MS-TrafficTypeDiagnostic": "PH7PR12MB5618:EE_",
        "X-LD-Processed": "43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr",
        "X-Microsoft-Antispam-PRVS": "\n <PH7PR12MB5618EA5F2BC3BA4AA6EF3C90A8AD9@PH7PR12MB5618.namprd12.prod.outlook.com>",
        "X-MS-Exchange-SenderADCheck": "1",
        "X-MS-Exchange-AntiSpam-Relay": "0",
        "X-Microsoft-Antispam": "BCL:0;",
        "X-Microsoft-Antispam-Message-Info": "\n cTxPOhwyTRTP/ONUbvWhdmufZibEtuFOZrn/RhgbXtn9eTmsrLc+u5fThAzfZfD+seyBD163nDKHEFDwfUMSRd7lYFdwRtyS61k7ZnU4XgRKBfnfTCbIAgDdv88VtcyOd0ThC9g8uWJbdsCaQn5vXgK54BocbuI/2a1spWJqkxDXd+dee0odGRmcUKdv16OYY9mOfKeJa7ydwCS9pJ2Fxsr+YrugJR7w80Hd4SpTjxONXhYEvfgei5tHnswpbfYS1DdzQem1VuZ3HSwz4bkIdAD+LYMrni2UPlaUPz+ooQPWOxMjvx6dQyqgJHykl3G7WpSsWJcBEauY1bIrEMyvbTW5bsohs7pXjnwExV1eKd+WInZY78g1lZf2+n1nfakArr+y/kIp2m9SnJJoQEZeWP9cvVm4CLRI7ld/8cSwjIRdoemp6XasmmlDIkFCGfEa2yQcglPvCDvzwDPpjUuj6pAx0EvSi/rGpJrJO6cMB7XVxAi1GBCbl9W6yIzUvGUfOwHgPRieG1gNCZ9Vw7RDU1ZtRoQU9BGC80qBW/QblLCJDtw8kRVUXRwOQSphQZQyeyug9IbhOOiKW/+Ur2+gbsyOUidLFxZDdXDI/jJl0ht/uCZf0HxbICMCuTVGX6D21V6gjVATkoJ1MwuXWs6LvAHXSLTkEsCnDE8wq/r/MP69LTWSZRSkEC/djvjJabN0cKP7N9AF/4ilNMGS+HFKwA==",
        "X-Forefront-Antispam-Report": "CIP:12.22.5.238; CTRY:US; LANG:en; SCL:1; SRV:;\n IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE;\n SFS:(13230016)(4636009)(40470700004)(46966006)(36840700001)(1076003)(110136005)(2616005)(6666004)(47076005)(2906002)(107886003)(70206006)(70586007)(16526019)(186003)(81166007)(55016003)(83380400001)(36860700001)(54906003)(316002)(36756003)(6636002)(336012)(426003)(26005)(7696005)(356005)(6286002)(508600001)(8936002)(5660300002)(8676002)(4326008)(86362001)(82310400005)(40460700003)(30864003)(36900700001);\n DIR:OUT; SFP:1101;",
        "X-OriginatorOrg": "Nvidia.com",
        "X-MS-Exchange-CrossTenant-OriginalArrivalTime": "15 Jun 2022 12:59:15.4691 (UTC)",
        "X-MS-Exchange-CrossTenant-Network-Message-Id": "\n 730a2e09-03b7-4e11-a414-08da4eceda24",
        "X-MS-Exchange-CrossTenant-Id": "43083d15-7273-40c1-b7db-39efd9ccc17a",
        "X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp": "\n TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.238];\n Helo=[mail.nvidia.com]",
        "X-MS-Exchange-CrossTenant-AuthSource": "\n DM6NAM11FT023.eop-nam11.prod.protection.outlook.com",
        "X-MS-Exchange-CrossTenant-AuthAs": "Anonymous",
        "X-MS-Exchange-CrossTenant-FromEntityHeader": "HybridOnPrem",
        "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "PH7PR12MB5618",
        "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": "Add command line options to support host shaper configure.\n- Command syntax:\n  mlx5 set port <port_id> host_shaper avail_thresh_triggered <0|1> rate\n<rate_num>\n\n- Example commands:\nTo enable avail_thresh_triggered on port 1 and disable current host\nshaper:\ntestpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 1 rate 0\n\nTo disable avail_thresh_triggered and current host shaper on port 1:\ntestpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 0 rate 0\n\nThe rate unit is 100Mbps.\nTo disable avail_thresh_triggered and configure a shaper of 5Gbps on\nport 1:\ntestpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 0 rate 50\n\nAdd sample code to handle rxq available descriptor threshold event, it\ndelays a while so that rxq empties, then disables host shaper and\nrearms available descriptor threshold event.\n\nSigned-off-by: Spike Du <spiked@nvidia.com>\n---\n app/test-pmd/testpmd.c          |   7 ++\n doc/guides/nics/mlx5.rst        |  46 +++++++++\n drivers/net/mlx5/meson.build    |   4 +\n drivers/net/mlx5/mlx5_testpmd.c | 205 ++++++++++++++++++++++++++++++++++++++++\n drivers/net/mlx5/mlx5_testpmd.h |  26 +++++\n 5 files changed, 288 insertions(+)\n create mode 100644 drivers/net/mlx5/mlx5_testpmd.c\n create mode 100644 drivers/net/mlx5/mlx5_testpmd.h",
    "diff": "diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c\nindex 33d9b85..b491719 100644\n--- a/app/test-pmd/testpmd.c\n+++ b/app/test-pmd/testpmd.c\n@@ -69,6 +69,9 @@\n #ifdef RTE_NET_BOND\n #include <rte_eth_bond.h>\n #endif\n+#ifdef RTE_NET_MLX5\n+#include \"mlx5_testpmd.h\"\n+#endif\n \n #include \"testpmd.h\"\n \n@@ -3659,6 +3662,10 @@ struct pmd_test_command {\n \t\t\t\tbreak;\n \t\t\tprintf(\"Received avail_thresh event, port:%d rxq_id:%d\\n\",\n \t\t\t       port_id, rxq_id);\n+\n+#ifdef RTE_NET_MLX5\n+\t\t\tmlx5_test_avail_thresh_event_handler(port_id, rxq_id);\n+#endif\n \t\t}\n \t\tbreak;\n \tdefault:\ndiff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst\nindex 5f7b060..64eaddf 100644\n--- a/doc/guides/nics/mlx5.rst\n+++ b/doc/guides/nics/mlx5.rst\n@@ -1727,3 +1727,49 @@ which can be installed from OFED mstflint package.\n Meson detects ``libmtcr_ul`` existence at configure stage.\n If the library is detected, the application must link with ``-lmtcr_ul``,\n as done by the pkg-config file libdpdk.pc.\n+\n+How to use available descriptor threshold and Host Shaper\n+---------------------------------------------------------\n+\n+There is a command to configure available descriptor threshold in testpmd.\n+Testpmd also contains sample logic to handle available descriptor threshold event.\n+The typical workflow is: testpmd configure available descriptor threshold for Rx queues, enable\n+avail_thresh_triggered in host shaper and register a callback, when traffic from host is\n+too high and Rx queue emptiness is below available descriptor threshold, PMD receives an event and\n+firmware configures a 100Mbps shaper on host port automatically, then PMD call\n+the callback registered previously, which will delay a while to let Rx queue\n+empty, then disable host shaper.\n+\n+Let's assume we have a simple BlueField 2 setup: port 0 is uplink, port 1\n+is VF representor. Each port has 2 Rx queues.\n+In order to control traffic from host to ARM, we can enable available descriptor threshold in testpmd by:\n+\n+.. code-block:: console\n+\n+   testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 1 rate 0\n+   testpmd> set port 1 rxq 0 avail_thresh 70\n+   testpmd> set port 1 rxq 1 avail_thresh 70\n+\n+The first command disables current host shaper, and enables available descriptor threshold triggered mode.\n+The other commands configure available descriptor threshold to 70% of Rx queue size for both Rx queues,\n+When traffic from host is too high, you can see testpmd console prints log\n+about available descriptor threshold event receiving, then host shaper is disabled.\n+The traffic rate from host is controlled and less drop happens in Rx queues.\n+\n+The threshold event and shaper can be disabled like this:\n+\n+.. code-block:: console\n+\n+   testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 0 rate 0\n+   testpmd> set port 1 rxq 0 avail_thresh 0\n+   testpmd> set port 1 rxq 1 avail_thresh 0\n+\n+It's recommended an application disables available descriptor threshold and avail_thresh_triggered before exit,\n+if it enables them before.\n+\n+We can also configure the shaper with a value, the rate unit is 100Mbps, below\n+command sets current shaper to 5Gbps and disables avail_thresh_triggered.\n+\n+.. code-block:: console\n+\n+   testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 0 rate 50\ndiff --git a/drivers/net/mlx5/meson.build b/drivers/net/mlx5/meson.build\nindex 99210fd..941642b 100644\n--- a/drivers/net/mlx5/meson.build\n+++ b/drivers/net/mlx5/meson.build\n@@ -68,4 +68,8 @@ if get_option('buildtype').contains('debug')\n else\n     cflags += [ '-UPEDANTIC' ]\n endif\n+\n+testpmd_sources += files('mlx5_testpmd.c')\n+testpmd_drivers_deps += 'net_mlx5'\n+\n subdir(exec_env)\ndiff --git a/drivers/net/mlx5/mlx5_testpmd.c b/drivers/net/mlx5/mlx5_testpmd.c\nnew file mode 100644\nindex 0000000..98bd395\n--- /dev/null\n+++ b/drivers/net/mlx5/mlx5_testpmd.c\n@@ -0,0 +1,205 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright 2021 6WIND S.A.\n+ * Copyright 2021 Mellanox Technologies, Ltd\n+ */\n+\n+#include <stdint.h>\n+#include <string.h>\n+#include <stdlib.h>\n+\n+#include <rte_prefetch.h>\n+#include <rte_common.h>\n+#include <rte_branch_prediction.h>\n+#include <rte_ether.h>\n+#include <rte_alarm.h>\n+#include <rte_pmd_mlx5.h>\n+#include <rte_ethdev.h>\n+#include \"mlx5_testpmd.h\"\n+#include \"testpmd.h\"\n+\n+static uint8_t host_shaper_avail_thresh_triggered[RTE_MAX_ETHPORTS];\n+#define SHAPER_DISABLE_DELAY_US 100000 /* 100ms */\n+\n+/**\n+ * Disable the host shaper and re-arm available descriptor threshold event.\n+ *\n+ * @param[in] args\n+ *   uint32_t integer combining port_id and rxq_id.\n+ */\n+static void\n+mlx5_test_host_shaper_disable(void *args)\n+{\n+\tuint32_t port_rxq_id = (uint32_t)(uintptr_t)args;\n+\tuint16_t port_id = port_rxq_id & 0xffff;\n+\tuint16_t qid = (port_rxq_id >> 16) & 0xffff;\n+\tstruct rte_eth_rxq_info qinfo;\n+\n+\tprintf(\"%s disable shaper\\n\", __func__);\n+\tif (rte_eth_rx_queue_info_get(port_id, qid, &qinfo)) {\n+\t\tprintf(\"rx_queue_info_get returns error\\n\");\n+\t\treturn;\n+\t}\n+\t/* Rearm the available descriptor threshold event. */\n+\tif (rte_eth_rx_avail_thresh_set(port_id, qid, qinfo.avail_thresh)) {\n+\t\tprintf(\"config avail_thresh returns error\\n\");\n+\t\treturn;\n+\t}\n+\t/* Only disable the shaper when avail_thresh_triggered is set. */\n+\tif (host_shaper_avail_thresh_triggered[port_id] &&\n+\t    rte_pmd_mlx5_host_shaper_config(port_id, 0, 0))\n+\t\tprintf(\"%s disable shaper returns error\\n\", __func__);\n+}\n+\n+void\n+mlx5_test_avail_thresh_event_handler(uint16_t port_id, uint16_t rxq_id)\n+{\n+\tstruct rte_eth_dev_info dev_info;\n+\tuint32_t port_rxq_id = port_id | (rxq_id << 16);\n+\n+\t/* Ensure it's MLX5 port. */\n+\tif (rte_eth_dev_info_get(port_id, &dev_info) != 0 ||\n+\t    (strncmp(dev_info.driver_name, \"mlx5\", 4) != 0))\n+\t\treturn;\n+\trte_eal_alarm_set(SHAPER_DISABLE_DELAY_US,\n+\t\t\t  mlx5_test_host_shaper_disable,\n+\t\t\t  (void *)(uintptr_t)port_rxq_id);\n+\tprintf(\"%s port_id:%u rxq_id:%u\\n\", __func__, port_id, rxq_id);\n+}\n+\n+/**\n+ * Configure host shaper's avail_thresh_triggered and current rate.\n+ *\n+ * @param[in] avail_thresh_triggered\n+ *   Disable/enable avail_thresh_triggered.\n+ * @param[in] rate\n+ *   Configure current host shaper rate.\n+ * @return\n+ *   On success, returns 0.\n+ *   On failure, returns < 0.\n+ */\n+static int\n+mlx5_test_set_port_host_shaper(uint16_t port_id, uint16_t avail_thresh_triggered, uint8_t rate)\n+{\n+\tstruct rte_eth_link link;\n+\tbool port_id_valid = false;\n+\tuint16_t pid;\n+\tint ret;\n+\n+\tRTE_ETH_FOREACH_DEV(pid)\n+\t\tif (port_id == pid) {\n+\t\t\tport_id_valid = true;\n+\t\t\tbreak;\n+\t\t}\n+\tif (!port_id_valid)\n+\t\treturn -EINVAL;\n+\tret = rte_eth_link_get_nowait(port_id, &link);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\thost_shaper_avail_thresh_triggered[port_id] = avail_thresh_triggered ? 1 : 0;\n+\tif (!avail_thresh_triggered) {\n+\t\tret = rte_pmd_mlx5_host_shaper_config(port_id, 0,\n+\t\tRTE_BIT32(MLX5_HOST_SHAPER_FLAG_AVAIL_THRESH_TRIGGERED));\n+\t} else {\n+\t\tret = rte_pmd_mlx5_host_shaper_config(port_id, 1,\n+\t\tRTE_BIT32(MLX5_HOST_SHAPER_FLAG_AVAIL_THRESH_TRIGGERED));\n+\t}\n+\tif (ret)\n+\t\treturn ret;\n+\tret = rte_pmd_mlx5_host_shaper_config(port_id, rate, 0);\n+\tif (ret)\n+\t\treturn ret;\n+\treturn 0;\n+}\n+\n+/* *** SET HOST_SHAPER FOR A PORT *** */\n+struct cmd_port_host_shaper_result {\n+\tcmdline_fixed_string_t mlx5;\n+\tcmdline_fixed_string_t set;\n+\tcmdline_fixed_string_t port;\n+\tuint16_t port_num;\n+\tcmdline_fixed_string_t host_shaper;\n+\tcmdline_fixed_string_t avail_thresh_triggered;\n+\tuint16_t fr;\n+\tcmdline_fixed_string_t rate;\n+\tuint8_t rate_num;\n+};\n+\n+static void cmd_port_host_shaper_parsed(void *parsed_result,\n+\t\t__rte_unused struct cmdline *cl,\n+\t\t__rte_unused void *data)\n+{\n+\tstruct cmd_port_host_shaper_result *res = parsed_result;\n+\tint ret = 0;\n+\n+\tif ((strcmp(res->mlx5, \"mlx5\") == 0) &&\n+\t    (strcmp(res->set, \"set\") == 0) &&\n+\t    (strcmp(res->port, \"port\") == 0) &&\n+\t    (strcmp(res->host_shaper, \"host_shaper\") == 0) &&\n+\t    (strcmp(res->avail_thresh_triggered, \"avail_thresh_triggered\") == 0) &&\n+\t    (strcmp(res->rate, \"rate\") == 0))\n+\t\tret = mlx5_test_set_port_host_shaper(res->port_num, res->fr,\n+\t\t\t\t\t   res->rate_num);\n+\tif (ret < 0)\n+\t\tprintf(\"cmd_port_host_shaper error: (%s)\\n\", strerror(-ret));\n+}\n+\n+static cmdline_parse_token_string_t cmd_port_host_shaper_mlx5 =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_port_host_shaper_result,\n+\t\t\t\tmlx5, \"mlx5\");\n+static cmdline_parse_token_string_t cmd_port_host_shaper_set =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_port_host_shaper_result,\n+\t\t\t\tset, \"set\");\n+static cmdline_parse_token_string_t cmd_port_host_shaper_port =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_port_host_shaper_result,\n+\t\t\t\tport, \"port\");\n+static cmdline_parse_token_num_t cmd_port_host_shaper_portnum =\n+\tTOKEN_NUM_INITIALIZER(struct cmd_port_host_shaper_result,\n+\t\t\t\tport_num, RTE_UINT16);\n+static cmdline_parse_token_string_t cmd_port_host_shaper_host_shaper =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_port_host_shaper_result,\n+\t\t\t\t host_shaper, \"host_shaper\");\n+static cmdline_parse_token_string_t cmd_port_host_shaper_avail_thresh_triggered =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_port_host_shaper_result,\n+\t\t\t\t avail_thresh_triggered, \"avail_thresh_triggered\");\n+static cmdline_parse_token_num_t cmd_port_host_shaper_fr =\n+\tTOKEN_NUM_INITIALIZER(struct cmd_port_host_shaper_result,\n+\t\t\t      fr, RTE_UINT16);\n+static cmdline_parse_token_string_t cmd_port_host_shaper_rate =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_port_host_shaper_result,\n+\t\t\t\t rate, \"rate\");\n+static cmdline_parse_token_num_t cmd_port_host_shaper_rate_num =\n+\tTOKEN_NUM_INITIALIZER(struct cmd_port_host_shaper_result,\n+\t\t\t      rate_num, RTE_UINT8);\n+static cmdline_parse_inst_t mlx5_test_cmd_port_host_shaper = {\n+\t.f = cmd_port_host_shaper_parsed,\n+\t.data = (void *)0,\n+\t.help_str = \"mlx5 set port <port_id> host_shaper avail_thresh_triggered <0|1> \"\n+\t\"rate <rate_num>: Set HOST_SHAPER avail_thresh_triggered and rate with port_id\",\n+\t.tokens = {\n+\t\t(void *)&cmd_port_host_shaper_mlx5,\n+\t\t(void *)&cmd_port_host_shaper_set,\n+\t\t(void *)&cmd_port_host_shaper_port,\n+\t\t(void *)&cmd_port_host_shaper_portnum,\n+\t\t(void *)&cmd_port_host_shaper_host_shaper,\n+\t\t(void *)&cmd_port_host_shaper_avail_thresh_triggered,\n+\t\t(void *)&cmd_port_host_shaper_fr,\n+\t\t(void *)&cmd_port_host_shaper_rate,\n+\t\t(void *)&cmd_port_host_shaper_rate_num,\n+\t\tNULL,\n+\t}\n+};\n+\n+static struct testpmd_driver_commands mlx5_driver_cmds = {\n+\t.commands = {\n+\t\t{\n+\t\t\t.ctx = &mlx5_test_cmd_port_host_shaper,\n+\t\t\t.help = \"mlx5 set port (port_id) host_shaper avail_thresh_triggered (on|off)\"\n+\t\t\t\"rate (rate_num):\\n\"\n+\t\t\t\"    Set HOST_SHAPER avail_thresh_triggered and rate with port_id\\n\\n\",\n+\t\t},\n+\t\t{\n+\t\t\t.ctx = NULL,\n+\t\t},\n+\t}\n+};\n+TESTPMD_ADD_DRIVER_COMMANDS(mlx5_driver_cmds);\ndiff --git a/drivers/net/mlx5/mlx5_testpmd.h b/drivers/net/mlx5/mlx5_testpmd.h\nnew file mode 100644\nindex 0000000..7a54658\n--- /dev/null\n+++ b/drivers/net/mlx5/mlx5_testpmd.h\n@@ -0,0 +1,26 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright 2021 6WIND S.A.\n+ * Copyright 2021 Mellanox Technologies, Ltd\n+ */\n+\n+#ifndef RTE_PMD_MLX5_TEST_H_\n+#define RTE_PMD_MLX5_TEST_H_\n+\n+#include <cmdline_parse.h>\n+#include <cmdline_parse_num.h>\n+#include <cmdline_parse_string.h>\n+\n+/**\n+ * RTE_ETH_EVENT_RX_AVAIL_THRESH handler sample code.\n+ * It's called in testpmd, the work flow here is delay a while until\n+ * RX queueu is empty, then disable host shaper.\n+ *\n+ * @param[in] port_id\n+ *   Port identifier.\n+ * @param[in] rxq_id\n+ *   Rx queue identifier.\n+ */\n+void\n+mlx5_test_avail_thresh_event_handler(uint16_t port_id, uint16_t rxq_id);\n+\n+#endif\n",
    "prefixes": [
        "v8",
        "6/6"
    ]
}