get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 131963,
    "url": "https://patches.dpdk.org/api/patches/131963/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20230926113753.28765-1-orika@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": "<20230926113753.28765-1-orika@nvidia.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230926113753.28765-1-orika@nvidia.com",
    "date": "2023-09-26T11:37:52",
    "name": "ethdev: add calculate hash function",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "c0c3e635276df583fa6328c4a9a6d16b54f9512c",
    "submitter": {
        "id": 1869,
        "url": "https://patches.dpdk.org/api/people/1869/?format=api",
        "name": "Ori Kam",
        "email": "orika@nvidia.com"
    },
    "delegate": {
        "id": 319,
        "url": "https://patches.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20230926113753.28765-1-orika@nvidia.com/mbox/",
    "series": [
        {
            "id": 29636,
            "url": "https://patches.dpdk.org/api/series/29636/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=29636",
            "date": "2023-09-26T11:37:52",
            "name": "ethdev: add calculate hash function",
            "version": 1,
            "mbox": "https://patches.dpdk.org/series/29636/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/131963/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/131963/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 CF56A42642;\n\tTue, 26 Sep 2023 13:39:05 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 5CF49402CA;\n\tTue, 26 Sep 2023 13:39:05 +0200 (CEST)",
            "from NAM11-DM6-obe.outbound.protection.outlook.com\n (mail-dm6nam11on2062.outbound.protection.outlook.com [40.107.223.62])\n by mails.dpdk.org (Postfix) with ESMTP id 3E9FD402AA\n for <dev@dpdk.org>; Tue, 26 Sep 2023 13:39:04 +0200 (CEST)",
            "from MN2PR03CA0023.namprd03.prod.outlook.com (2603:10b6:208:23a::28)\n by SA1PR12MB8946.namprd12.prod.outlook.com (2603:10b6:806:375::19)\n with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Tue, 26 Sep\n 2023 11:39:01 +0000",
            "from BL02EPF0001A106.namprd05.prod.outlook.com\n (2603:10b6:208:23a:cafe::94) by MN2PR03CA0023.outlook.office365.com\n (2603:10b6:208:23a::28) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.35 via Frontend\n Transport; Tue, 26 Sep 2023 11:39:01 +0000",
            "from mail.nvidia.com (216.228.117.160) by\n BL02EPF0001A106.mail.protection.outlook.com (10.167.241.139) with Microsoft\n SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n 15.20.6838.14 via Frontend Transport; Tue, 26 Sep 2023 11:39:01 +0000",
            "from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com\n (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 26 Sep\n 2023 04:38:45 -0700",
            "from nvidia.com (10.126.231.35) by rnnvmail202.nvidia.com\n (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 26 Sep\n 2023 04:38:42 -0700"
        ],
        "ARC-Seal": "i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;\n b=YZDpaHyedCGcSbq4xd4ce4fmvZuztNLnG0BIPXrhWuo/+VBqwNDlw11FDtMRM/92w4K5mz6PQChzZGO+c9/aiDBe7RVknIfSLZjxchtFQQHTygW2Al0jO76JgGAFL/SRBsZz+O1i1IEP/tO0iCP91GiBb+k/+2dzhjj327dD6/XQPwWGpLxZvCjwA8RoR7IQVmJNGiKmekAOLaXfR3FSNkm0IUV6nUCbogHZ8kVTPcVywFOfym1Yd7T4rWfzviAjhWfXTHn17vkFzJ7NqSph84NwcvLX45bOJ2S0GWx+2U7TCu6f8SlVo7HEOGq9Um3SoOTiJCWrOvcjWqvP5M93IA==",
        "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=pyQgQApHZ+g7rE0Lq1OQgpwEo5mrXPaUZ5EhU918jpw=;\n b=BxPc4TZ5SnLWsXtBj6kqw3yyq2KtuDEUNJstoJMKOMpGHZ03JrtIu+py0sKUXTCANTf8/TQiZmpN9Gsb46eHCHXYNzK0qsrLiEMe23pWo4pST9bfGhDjAofGT8EIknHgmPsTwmeb+raL0nute5HgK/iCJMBgF5tDJ1UBIuQ6VorDX6xEm7LYdq3p5kDorhWgDufipq2Z2tXCmzv57mNoa1WzvffJ2lGXuUuGGcSXMW5au4fGhfSvXvC9WhprQTbRUr1nKlUXj5S5NWsOl5hqmRqgADbWhArq3U+wADYcuRbmsb2u1xMVqLw7OqGHzJ0YkdHW0ZeCf7Kn4yWAVlfXAQ==",
        "ARC-Authentication-Results": "i=1; mx.microsoft.com 1; spf=pass (sender ip is\n 216.228.117.160) smtp.rcpttodomain=intel.com 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=pyQgQApHZ+g7rE0Lq1OQgpwEo5mrXPaUZ5EhU918jpw=;\n b=LwYTxxhTOrWmpEfQPn8q/9blABbdPc0lfuG4adtV6r7iyu33G1x1qZjbQThD192MNjSlGvJG9+9NCI/FdSA9qSOpS7qhTXHkl2quNL28J/0bMORkfFvZ3pufQ1wxwE+Kejg0jm2rNzKTavveeivwTDPSNDM3NyOcY4k+8GW8tJ0D2nugugsh2UjXDrcmnN+WeGancuQGNOSI53WPDeYWzeIHku2iW3nTY9hTAnjPcPrOpFbdo5s1YPWq0/kh0WrMtzoWY1bhSll5IIts6DXTmPt7jL5eXj8nfEw59pDByyeNlAeBj78A2ZIhC7dWu/v7yz8IICUXIlgvTdx0n8o/SQ==",
        "X-MS-Exchange-Authentication-Results": "spf=pass (sender IP is 216.228.117.160)\n smtp.mailfrom=nvidia.com;\n 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 216.228.117.160 as permitted sender) receiver=protection.outlook.com;\n client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C",
        "From": "Ori Kam <orika@nvidia.com>",
        "To": "<cristian.dumitrescu@intel.com>, Aman Singh <aman.deep.singh@intel.com>,\n Yuying Zhang <yuying.zhang@intel.com>, Thomas Monjalon <thomas@monjalon.net>,\n Ferruh Yigit <ferruh.yigit@amd.com>, Andrew Rybchenko\n <andrew.rybchenko@oktetlabs.ru>",
        "CC": "<dev@dpdk.org>, <orika@nvidia.com>, <rasland@nvidia.com>",
        "Subject": "[PATCH] ethdev: add calculate hash function",
        "Date": "Tue, 26 Sep 2023 14:37:52 +0300",
        "Message-ID": "<20230926113753.28765-1-orika@nvidia.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Originating-IP": "[10.126.231.35]",
        "X-ClientProxiedBy": "rnnvmail202.nvidia.com (10.129.68.7) To\n rnnvmail202.nvidia.com (10.129.68.7)",
        "X-EOPAttributedMessage": "0",
        "X-MS-PublicTrafficType": "Email",
        "X-MS-TrafficTypeDiagnostic": "BL02EPF0001A106:EE_|SA1PR12MB8946:EE_",
        "X-MS-Office365-Filtering-Correlation-Id": "7027c355-19e6-4191-8c8f-08dbbe852de9",
        "X-LD-Processed": "43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr",
        "X-MS-Exchange-SenderADCheck": "1",
        "X-MS-Exchange-AntiSpam-Relay": "0",
        "X-Microsoft-Antispam": "BCL:0;",
        "X-Microsoft-Antispam-Message-Info": "\n VVVzsx6QHc31+5xa77CS2s+4jYOIZzl6xqQQLUm2KwGas2N7HogidUl2n+QipRfJKdlDdccOuctbPDdlYmnWIKxPBaLkbYU5BrhrBK+fchqPKcICRMmap6FaGSERR+aArYue84JqIaIspi/2iQgnJazDTC7tDpxtTlAxPrgY4uqgatyp/DI0W+mwQK0HvKWGELUFdeBshEhsaGQcECZ99BSv1/dclssXLfLTMjUyJsX38qxbqDbaYCWafYnooWsHdJzFUWObiJWLxYNSqYVqgwFMjmp5AlD5Ax5aj57QhtmCBsQlN9X+8si0asoSR5MnRciA+Ua4+ryEL1P1RXzZuDFiRG+jaP5PUl6QuYKA8Fa3YhoPmRdqZA5tKClrNwrztPNBe+cMGPyuhkL1lPPI2vtU6HCa4bvmAeGr97LqdJluZSs4O43UhNPboPIPavGH4mC5XeAAUGQgeduGeUqUfjG4LNFCs+yKjFbdOTKIZ3TiAQbIs9kyfn3sU8fvRMEJEAKhPXKPB10ktKiN27fXpTvs9DIgOLV/hanDhQ6VsmYEjPB1R8MnCdliFMXRGb39phVOhn1ATwIILo3VGwTb6wBfI1DWiWg4cggZX0SBTUR0xyd2lhAjtLyXul/L5b13FSCF+lcSC646vPr2xfCQCB56oVxBs9g/4USoHoaCVuExsKeSNEdbUR+tB0i+6lHTXmEUIpB8PUZtIFu+BmAKXry4v3Gq6vUO6FYzUjnn3Ld7wGJxPSbzs9qBYkVXn2B6xrqT1GT3D+hNY+e48GO46Q==",
        "X-Forefront-Antispam-Report": "CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1;\n SRV:;\n IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE;\n SFS:(13230031)(4636009)(39860400002)(136003)(346002)(396003)(376002)(230922051799003)(82310400011)(186009)(1800799009)(451199024)(36840700001)(46966006)(40470700004)(36756003)(86362001)(30864003)(40480700001)(55016003)(5660300002)(7696005)(2906002)(2616005)(70586007)(70206006)(110136005)(41300700001)(478600001)(54906003)(316002)(6666004)(966005)(47076005)(40460700003)(426003)(83380400001)(4326008)(356005)(36860700001)(7636003)(8676002)(8936002)(82740400003)(16526019)(107886003)(336012)(1076003)(6286002)(26005);\n DIR:OUT; SFP:1101;",
        "X-OriginatorOrg": "Nvidia.com",
        "X-MS-Exchange-CrossTenant-OriginalArrivalTime": "26 Sep 2023 11:39:01.1234 (UTC)",
        "X-MS-Exchange-CrossTenant-Network-Message-Id": "\n 7027c355-19e6-4191-8c8f-08dbbe852de9",
        "X-MS-Exchange-CrossTenant-Id": "43083d15-7273-40c1-b7db-39efd9ccc17a",
        "X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp": "\n TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160];\n Helo=[mail.nvidia.com]",
        "X-MS-Exchange-CrossTenant-AuthSource": "\n BL02EPF0001A106.namprd05.prod.outlook.com",
        "X-MS-Exchange-CrossTenant-AuthAs": "Anonymous",
        "X-MS-Exchange-CrossTenant-FromEntityHeader": "HybridOnPrem",
        "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "SA1PR12MB8946",
        "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": "rte_flow supports insert by index table[1].\n\nUsing the above table, the application can create rules\nthat are based on hash.\nFor example application can create the following logic in order\nto create load balancing:\n1. Create insert by index table with 2 rules, that hashes based on dmac\n2. Insert to index 0 a rule that sends the traffic to port A.\n3. Insert to index 1 a rule that sends the traffic to port B.\n\nLet's also assume that before this table, there is a 5 tuple\nmatch table that jumps to the above table.\n\nSo each packet that matches one of the 5 tuple rules is RSSed\nto port A or B, based on dmac hash.\n\nThe issue arises when there is a miss on the 5 tuple table,\nwhich resulted due to the packet being the first packet of this flow, or\nfragmented packet or any other reason.\nIn this case, the application must calculate what would be the\nhash calculated by the HW so it can send the packet to the correct\nport.\n\nThis new API allows applications to calculate the hash value of a given\npacket for a given table.\n\n[1] - http://patches.dpdk.org/project/dpdk/patch/20230208030624.78465-2-akozyrev@nvidia.com/\n\nSigned-off-by: Ori Kam <orika@nvidia.com>\n---\n app/test-pmd/cmdline_flow.c  | 86 +++++++++++++++++++++++++++++++++++-\n app/test-pmd/config.c        | 54 ++++++++++++++++++++++\n app/test-pmd/testpmd.h       |  2 +\n lib/ethdev/rte_flow.c        | 21 +++++++++\n lib/ethdev/rte_flow.h        | 32 ++++++++++++++\n lib/ethdev/rte_flow_driver.h |  5 +++\n lib/ethdev/version.map       |  1 +\n 7 files changed, 200 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c\nindex 94827bcc4a..e1e4bb49fa 100644\n--- a/app/test-pmd/cmdline_flow.c\n+++ b/app/test-pmd/cmdline_flow.c\n@@ -101,6 +101,7 @@ enum index {\n \tQUEUE,\n \tPUSH,\n \tPULL,\n+\tHASH,\n \n \t/* Flex arguments */\n \tFLEX_ITEM_INIT,\n@@ -206,6 +207,11 @@ enum index {\n \tTABLE_PATTERN_TEMPLATE,\n \tTABLE_ACTIONS_TEMPLATE,\n \n+\t/* Hash calculation arguments. */\n+\tHASH_CALC_TABLE,\n+\tHASH_CALC_PATTERN_INDEX,\n+\tHASH_CALC_PATTERN,\n+\n \t/* Tunnel arguments. */\n \tTUNNEL_CREATE,\n \tTUNNEL_CREATE_TYPE,\n@@ -2678,6 +2684,9 @@ static int parse_push(struct context *, const struct token *,\n static int parse_pull(struct context *, const struct token *,\n \t\t      const char *, unsigned int,\n \t\t      void *, unsigned int);\n+static int parse_hash(struct context *, const struct token *,\n+\t\t      const char *, unsigned int,\n+\t\t      void *, unsigned int);\n static int parse_tunnel(struct context *, const struct token *,\n \t\t\tconst char *, unsigned int,\n \t\t\tvoid *, unsigned int);\n@@ -3035,7 +3044,8 @@ static const struct token token_list[] = {\n \t\t\t      FLEX,\n \t\t\t      QUEUE,\n \t\t\t      PUSH,\n-\t\t\t      PULL)),\n+\t\t\t      PULL,\n+\t\t\t      HASH)),\n \t\t.call = parse_init,\n \t},\n \t/* Top-level command. */\n@@ -3680,6 +3690,33 @@ static const struct token token_list[] = {\n \t\t.args = ARGS(ARGS_ENTRY(struct buffer, queue)),\n \t},\n \t/* Top-level command. */\n+\t[HASH] = {\n+\t\t.name = \"hash\",\n+\t\t.help = \"calculate hash for a given pattern in a given template table\",\n+\t\t.next = NEXT(NEXT_ENTRY(HASH_CALC_TABLE), NEXT_ENTRY(COMMON_PORT_ID)),\n+\t\t.args = ARGS(ARGS_ENTRY(struct buffer, port)),\n+\t\t.call = parse_hash,\n+\t},\n+\t/* Sub-level commands. */\n+\t[HASH_CALC_TABLE] = {\n+\t\t.name = \"template_table\",\n+\t\t.help = \"specify table id\",\n+\t\t.next = NEXT(NEXT_ENTRY(HASH_CALC_PATTERN_INDEX),\n+\t\t\t     NEXT_ENTRY(COMMON_TABLE_ID)),\n+\t\t.args = ARGS(ARGS_ENTRY(struct buffer,\n+\t\t\t\t\targs.vc.table_id)),\n+\t\t.call = parse_hash,\n+\t},\n+\t[HASH_CALC_PATTERN_INDEX] = {\n+\t\t.name = \"pattern_template\",\n+\t\t.help = \"specify pattern template id\",\n+\t\t.next = NEXT(NEXT_ENTRY(ITEM_PATTERN),\n+\t\t\t     NEXT_ENTRY(COMMON_UNSIGNED)),\n+\t\t.args = ARGS(ARGS_ENTRY(struct buffer,\n+\t\t\t\t\targs.vc.pat_templ_id)),\n+\t\t.call = parse_hash,\n+\t},\n+\t/* Top-level command. */\n \t[INDIRECT_ACTION] = {\n \t\t.name = \"indirect_action\",\n \t\t.type = \"{command} {port_id} [{arg} [...]]\",\n@@ -10449,6 +10486,48 @@ parse_pull(struct context *ctx, const struct token *token,\n \treturn len;\n }\n \n+/** Parse tokens for hash calculation commands. */\n+static int\n+parse_hash(struct context *ctx, const struct token *token,\n+\t const char *str, unsigned int len,\n+\t void *buf, unsigned int size)\n+{\n+\tstruct buffer *out = buf;\n+\n+\t/* Token name must match. */\n+\tif (parse_default(ctx, token, str, len, NULL, 0) < 0)\n+\t\treturn -1;\n+\t/* Nothing else to do if there is no buffer. */\n+\tif (!out)\n+\t\treturn len;\n+\tif (!out->command) {\n+\t\tif (ctx->curr != HASH)\n+\t\t\treturn -1;\n+\t\tif (sizeof(*out) > size)\n+\t\t\treturn -1;\n+\t\tout->command = ctx->curr;\n+\t\tctx->objdata = 0;\n+\t\tctx->object = out;\n+\t\tctx->objmask = NULL;\n+\t\tout->args.vc.data = (uint8_t *)out + size;\n+\t\treturn len;\n+\t}\n+\tswitch (ctx->curr) {\n+\tcase HASH_CALC_TABLE:\n+\tcase HASH_CALC_PATTERN_INDEX:\n+\t\treturn len;\n+\tcase ITEM_PATTERN:\n+\t\tout->args.vc.pattern =\n+\t\t\t(void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),\n+\t\t\t\t\t       sizeof(double));\n+\t\tctx->object = out->args.vc.pattern;\n+\t\tctx->objmask = NULL;\n+\t\treturn len;\n+\tdefault:\n+\t\treturn -1;\n+\t}\n+}\n+\n static int\n parse_flex(struct context *ctx, const struct token *token,\n \t     const char *str, unsigned int len,\n@@ -12351,6 +12430,11 @@ cmd_flow_parsed(const struct buffer *in)\n \tcase PULL:\n \t\tport_queue_flow_pull(in->port, in->queue);\n \t\tbreak;\n+\tcase HASH:\n+\t\tport_flow_hash_calc(in->port, in->args.vc.table_id,\n+\t\t\t\t    in->args.vc.pat_templ_id,\n+\t\t\t\t    in->args.vc.pattern);\n+\t\tbreak;\n \tcase QUEUE_AGED:\n \t\tport_queue_flow_aged(in->port, in->queue,\n \t\t\t\t     in->args.aged.destroy);\ndiff --git a/app/test-pmd/config.c b/app/test-pmd/config.c\nindex 11f3a22048..c244f1a071 100644\n--- a/app/test-pmd/config.c\n+++ b/app/test-pmd/config.c\n@@ -6,6 +6,7 @@\n #include <ctype.h>\n #include <stdarg.h>\n #include <errno.h>\n+#include <stdbool.h>\n #include <stdio.h>\n #include <stdlib.h>\n #include <string.h>\n@@ -3301,6 +3302,59 @@ port_queue_flow_push(portid_t port_id, queueid_t queue_id)\n \treturn ret;\n }\n \n+/** Calculate the hash result for a given pattern in a given table. */\n+int\n+port_flow_hash_calc(portid_t port_id, uint32_t table_id,\n+\t\t    uint8_t pattern_template_index, const struct rte_flow_item pattern[])\n+{\n+\tuint32_t hash;\n+\tbool found;\n+\tstruct port_table *pt;\n+\tstruct rte_port *port;\n+\tstruct rte_flow_error error;\n+\tint ret = 0;\n+\n+\tif (port_id_is_invalid(port_id, ENABLED_WARN) ||\n+\t    port_id == (portid_t)RTE_PORT_ALL)\n+\t\treturn -EINVAL;\n+\tport = &ports[port_id];\n+\n+\tfound = false;\n+\tpt = port->table_list;\n+\twhile (pt) {\n+\t\tif (table_id == pt->id) {\n+\t\t\tfound = true;\n+\t\t\tbreak;\n+\t\t}\n+\t\tpt = pt->next;\n+\t}\n+\tif (!found) {\n+\t\tprintf(\"Table #%u is invalid\\n\", table_id);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tmemset(&error, 0x55, sizeof(error));\n+\tret = rte_flow_calc_table_hash(port_id, pt->table, pattern,\n+\t\t\t\t       pattern_template_index, &hash, &error);\n+\tif (ret < 0) {\n+\t\tprintf(\"Failed to calculate hash \");\n+\t\tswitch (abs(ret)) {\n+\t\tcase ENODEV:\n+\t\t\tprintf(\"no such device\\n\");\n+\t\t\tbreak;\n+\t\tcase ENOTSUP:\n+\t\t\tprintf(\"device doesn't support this operation\\n\");\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tprintf(\"\\n\");\n+\t\t\tbreak;\n+\t\t}\n+\t\treturn ret;\n+\t}\n+\tprintf(\"Hash results 0x%x\\n\", hash);\n+\treturn 0;\n+}\n+\n /** Pull queue operation results from the queue. */\n static int\n port_queue_aged_flow_destroy(portid_t port_id, queueid_t queue_id,\ndiff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h\nindex f1df6a8faf..4637a47c06 100644\n--- a/app/test-pmd/testpmd.h\n+++ b/app/test-pmd/testpmd.h\n@@ -1009,6 +1009,8 @@ port_queue_action_handle_query_update(portid_t port_id,\n \t\t\t\t      const struct rte_flow_action *action);\n int port_queue_flow_push(portid_t port_id, queueid_t queue_id);\n int port_queue_flow_pull(portid_t port_id, queueid_t queue_id);\n+int port_flow_hash_calc(portid_t port_id, uint32_t table_id,\n+\t\t\tuint8_t pattern_template_index, const struct rte_flow_item pattern[]);\n void port_queue_flow_aged(portid_t port_id, uint32_t queue_id, uint8_t destroy);\n int port_flow_validate(portid_t port_id,\n \t\t       const struct rte_flow_attr *attr,\ndiff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c\nindex 271d854f78..5f7dcdfdad 100644\n--- a/lib/ethdev/rte_flow.c\n+++ b/lib/ethdev/rte_flow.c\n@@ -2431,3 +2431,24 @@ rte_flow_async_action_list_handle_query_update(uint16_t port_id, uint32_t queue_\n \t\t\t\t\t\t\t     ret);\n \treturn ret;\n }\n+\n+int\n+rte_flow_calc_table_hash(uint16_t port_id, const struct rte_flow_template_table *table,\n+\t\t\t const struct rte_flow_item pattern[], uint8_t pattern_template_index,\n+\t\t\t uint32_t *hash, struct rte_flow_error *error)\n+{\n+\tint ret;\n+\tstruct rte_eth_dev *dev;\n+\tconst struct rte_flow_ops *ops;\n+\n+\tRTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);\n+\tops = rte_flow_ops_get(port_id, error);\n+\tif (!ops || !ops->flow_calc_table_hash)\n+\t\treturn rte_flow_error_set(error, ENOTSUP,\n+\t\t\t\t\t  RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,\n+\t\t\t\t\t  \"action_list async query_update not supported\");\n+\tdev = &rte_eth_devices[port_id];\n+\tret = ops->flow_calc_table_hash(dev, table, pattern, pattern_template_index,\n+\t\t\t\t\thash, error);\n+\treturn flow_err(port_id, ret, error);\n+}\ndiff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h\nindex 23addb4382..b8c28394a1 100644\n--- a/lib/ethdev/rte_flow.h\n+++ b/lib/ethdev/rte_flow.h\n@@ -6624,6 +6624,38 @@ rte_flow_async_action_list_handle_query_update(uint16_t port_id, uint32_t queue_\n \t\t\t\t\t  void *user_data,\n \t\t\t\t\t  struct rte_flow_error *error);\n \n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Calculate the hash for a given pattern in a given table as\n+ * calculated by the HW.\n+ *\n+ * @param port_id\n+ *   Port identifier of Ethernet device.\n+ * @param table\n+ *   The table the SW wishes to simulate.\n+ * @param pattern\n+ *   The values to be used in the hash calculation.\n+ * @param pattern_template_index\n+ *   The pattern index in the table to be used for the calculation.\n+ * @param hash\n+ *   Used to return the calculated hash.\n+ * @param error\n+ *   Perform verbose error reporting if not NULL.\n+ *   PMDs initialize this structure in case of error only.\n+ *\n+ * @return\n+ *   - (0) if success.\n+ *   - (-ENODEV) if *port_id* invalid.\n+ *   - (-ENOTSUP) if underlying device does not support this functionality.\n+ */\n+__rte_experimental\n+int\n+rte_flow_calc_table_hash(uint16_t port_id, const struct rte_flow_template_table *table,\n+\t\t\t const struct rte_flow_item pattern[], uint8_t pattern_template_index,\n+\t\t\t uint32_t *hash, struct rte_flow_error *error);\n+\n #ifdef __cplusplus\n }\n #endif\ndiff --git a/lib/ethdev/rte_flow_driver.h b/lib/ethdev/rte_flow_driver.h\nindex f9fb01b8a2..aa8635b1a8 100644\n--- a/lib/ethdev/rte_flow_driver.h\n+++ b/lib/ethdev/rte_flow_driver.h\n@@ -358,6 +358,11 @@ struct rte_flow_ops {\n \t\t const void **update, void **query,\n \t\t enum rte_flow_query_update_mode mode,\n \t\t void *user_data, struct rte_flow_error *error);\n+\t/** @see rte_flow_calc_table_hash() */\n+\tint (*flow_calc_table_hash)\n+\t\t(struct rte_eth_dev *dev, const struct rte_flow_template_table *table,\n+\t\t const struct rte_flow_item pattern[], uint8_t pattern_template_index,\n+\t\t uint32_t *hash, struct rte_flow_error *error);\n };\n \n /**\ndiff --git a/lib/ethdev/version.map b/lib/ethdev/version.map\nindex b965d6aa52..1496d8caa6 100644\n--- a/lib/ethdev/version.map\n+++ b/lib/ethdev/version.map\n@@ -312,6 +312,7 @@ EXPERIMENTAL {\n \trte_flow_async_action_list_handle_query_update;\n \trte_flow_async_actions_update;\n \trte_flow_restore_info_dynflag;\n+\trte_flow_calc_table_hash;\n };\n \n INTERNAL {\n",
    "prefixes": []
}