get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 139171,
    "url": "http://patches.dpdk.org/api/patches/139171/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20240405211745.699697-5-stephen@networkplumber.org/",
    "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": "<20240405211745.699697-5-stephen@networkplumber.org>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20240405211745.699697-5-stephen@networkplumber.org",
    "date": "2024-04-05T21:14:56",
    "name": "[v6,4/8] net/tap: validate and setup parameters for BPF RSS",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "ca861aca44359aca4d38dba35a2d9affa77cb35d",
    "submitter": {
        "id": 27,
        "url": "http://patches.dpdk.org/api/people/27/?format=api",
        "name": "Stephen Hemminger",
        "email": "stephen@networkplumber.org"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20240405211745.699697-5-stephen@networkplumber.org/mbox/",
    "series": [
        {
            "id": 31694,
            "url": "http://patches.dpdk.org/api/series/31694/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=31694",
            "date": "2024-04-05T21:14:52",
            "name": "net/tap: cleanup and fix BPF flow support",
            "version": 6,
            "mbox": "http://patches.dpdk.org/series/31694/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/139171/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/139171/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 CB6BA43E0E;\n\tFri,  5 Apr 2024 23:18:31 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 5F71A406BC;\n\tFri,  5 Apr 2024 23:18:03 +0200 (CEST)",
            "from mail-pj1-f48.google.com (mail-pj1-f48.google.com\n [209.85.216.48]) by mails.dpdk.org (Postfix) with ESMTP id CACAC4068A\n for <dev@dpdk.org>; Fri,  5 Apr 2024 23:18:00 +0200 (CEST)",
            "by mail-pj1-f48.google.com with SMTP id\n 98e67ed59e1d1-2a2ec65332fso1527094a91.1\n for <dev@dpdk.org>; Fri, 05 Apr 2024 14:18:00 -0700 (PDT)",
            "from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226])\n by smtp.gmail.com with ESMTPSA id\n r32-20020a17090a43a300b002a2f1e6f50bsm2137521pjg.1.2024.04.05.14.17.59\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Fri, 05 Apr 2024 14:17:59 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1712351880;\n x=1712956680; darn=dpdk.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=QMpE4bJ02MY4VpUrTabgs0S4YJan2oEdqn4ZAnWdaHI=;\n b=iM21nf1ZzDWRZmsAJJMKeXfQ+KSBYNg+be0Enl+7w4kuFzIzEqzJM/67FZuBOcHSIN\n HABuhWRcPGP2ibS6k0N4HfH2RqRBwXzygmUUAisLJMRjJ4LSYxRwf+bgiIiCw80YJkvl\n tsbLIi+TuEls1LHbhWg309OnVI8zhf+g9IKLZztChFhYM6vIo1YWnHccAa4i1CGrVBEj\n JeJnwmIYfWYipn8XIVrRt29HJ7MjK45M/dLj29hwyM8qAlfiVVbpj69KB0prpQkGFM5X\n Rxr0qMnPR58gn7OQaKiCDg0+qSqOWH8O/nfb5agmgMeh3j1qJXZrB9mBDhvr5peq7XtP\n syZg==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1712351880; x=1712956680;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=QMpE4bJ02MY4VpUrTabgs0S4YJan2oEdqn4ZAnWdaHI=;\n b=tyuPA0iCB3f2Z6J6GIen3gBNjomRWAbibEm7s3BvOpBH6St6U6Ivuym84gJUgvyIY3\n 54nI1l2QMH/rsLaxYlvJ4x8ZhhLUbw3C3ZCRZwXrWFCpLxuzq1vKTUGJWUlXLRjMuazk\n YWgWqSqW9fKarTHIvNRUw3wrDR9Xm/Wx0ZKRss4tmFVvWRvrJnqTLmmvRh6qZeJs7tkk\n /m1bW7I5y1LUWLfzIHMmdEo+H+7VyQtuuPTFwOxEudutFeSf4LQF5S4kRIWpCMEEtQFD\n BqV1gwTF9VUfKSKS2V+MKZehQHBRVZ2nikS+odHVwcxAlqPA3F5HsypXZBvKRcp/WBjK\n 2/Tg==",
        "X-Gm-Message-State": "AOJu0YwIgb8ocIg4UAZpg4NUlQhqETWH9B+EMcitZ+I0UtTNNOmJ6w+0\n 22SMpr2wbVzohWriu4GPqf6xRLojkXN6NUgZxbH7aRbWSvGcIAO/shkqSngeZdemVyTraIlV/od\n cnfQYAA==",
        "X-Google-Smtp-Source": "\n AGHT+IGQl6d7fXbzMEdr3YbDjTP1guMT1RmmXEFovgLJfUkqbWFbUWwKd9GndkXEa+YVZDXQYXuBqw==",
        "X-Received": "by 2002:a17:90b:11c6:b0:29c:7537:afbc with SMTP id\n gv6-20020a17090b11c600b0029c7537afbcmr2694684pjb.31.1712351879977;\n Fri, 05 Apr 2024 14:17:59 -0700 (PDT)",
        "From": "Stephen Hemminger <stephen@networkplumber.org>",
        "To": "dev@dpdk.org",
        "Cc": "Stephen Hemminger <stephen@networkplumber.org>",
        "Subject": "[PATCH v6 4/8] net/tap: validate and setup parameters for BPF RSS",
        "Date": "Fri,  5 Apr 2024 14:14:56 -0700",
        "Message-ID": "<20240405211745.699697-5-stephen@networkplumber.org>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20240405211745.699697-1-stephen@networkplumber.org>",
        "References": "<20240130034925.44869-1-stephen@networkplumber.org>\n <20240405211745.699697-1-stephen@networkplumber.org>",
        "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": "The flow RSS support via BPF was not using the key, or\nhash type parameters. Which is good because they were never\nproperly setup.\n\nFix the setup and validate the flow parameters, the BPF\nside gets fixed later.\n\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\n---\n drivers/net/tap/tap_flow.c | 65 +++++++++++++++++++++++++++++++++++---\n drivers/net/tap/tap_rss.h  |  5 ++-\n 2 files changed, 62 insertions(+), 8 deletions(-)",
    "diff": "diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c\nindex 8fccd599f0..8cf64364a7 100644\n--- a/drivers/net/tap/tap_flow.c\n+++ b/drivers/net/tap/tap_flow.c\n@@ -11,9 +11,11 @@\n \n #include <rte_byteorder.h>\n #include <rte_jhash.h>\n+#include <rte_thash.h>\n #include <rte_random.h>\n #include <rte_malloc.h>\n #include <rte_eth_tap.h>\n+\n #include <tap_flow.h>\n #include <tap_autoconf.h>\n #include <tap_tcmsgs.h>\n@@ -2061,6 +2063,21 @@ static int bpf_rss_key(enum bpf_rss_key_e cmd, __u32 *key_idx)\n \treturn err;\n }\n \n+\n+/* Default RSS hash key also used by mlx devices */\n+static const uint8_t rss_hash_default_key[] = {\n+\t0x2c, 0xc6, 0x81, 0xd1,\n+\t0x5b, 0xdb, 0xf4, 0xf7,\n+\t0xfc, 0xa2, 0x83, 0x19,\n+\t0xdb, 0x1a, 0x3e, 0x94,\n+\t0x6b, 0x9e, 0x38, 0xd9,\n+\t0x2c, 0x9c, 0x03, 0xd1,\n+\t0xad, 0x99, 0x44, 0xa7,\n+\t0xd9, 0x56, 0x3d, 0x59,\n+\t0x06, 0x3c, 0x25, 0xf3,\n+\t0xfc, 0x1f, 0xdc, 0x2a,\n+};\n+\n /**\n  * Add RSS hash calculations and queue selection\n  *\n@@ -2079,11 +2096,11 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd,\n \t\t\t   const struct rte_flow_action_rss *rss,\n \t\t\t   struct rte_flow_error *error)\n {\n-\t/* 4096 is the maximum number of instructions for a BPF program */\n+\tstruct rss_key rss_entry = { };\n+\tconst uint8_t *key_in;\n+\tuint32_t hash_type = 0;\n \tunsigned int i;\n \tint err;\n-\tstruct rss_key rss_entry = { .hash_fields = 0,\n-\t\t\t\t     .key_size = 0 };\n \n \t/* Check supported RSS features */\n \tif (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT)\n@@ -2095,6 +2112,41 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd,\n \t\t\t(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,\n \t\t\t \"a nonzero RSS encapsulation level is not supported\");\n \n+\tif (rss->queue_num == 0 || rss->queue_num >= TAP_MAX_QUEUES)\n+\t\treturn rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,\n+\t\t\t\t\t  \"invalid number of queues\");\n+\n+\t/* allow RSS key_len 0 in case of NULL (default) RSS key. */\n+\tif (rss->key_len == 0) {\n+\t\tif (rss->key != NULL)\n+\t\t\treturn rte_flow_error_set(error, ENOTSUP,\n+\t\t\t\t\t\t  RTE_FLOW_ERROR_TYPE_ACTION_CONF,\n+\t\t\t\t\t\t  &rss->key_len, \"RSS hash key length 0\");\n+\t\tkey_in = rss_hash_default_key;\n+\t} else {\n+\t\tif (rss->key_len != TAP_RSS_HASH_KEY_SIZE)\n+\t\t\treturn rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n+\t\t\t\t\t\t  NULL, \"RSS hash invalid key length\");\n+\t\tif (rss->key == NULL)\n+\t\t\treturn rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n+\t\t\t\t\t\t  NULL, \"RSS hash key is NULL\");\n+\t\tkey_in = rss->key;\n+\t}\n+\n+\tif (rss->types & TAP_RSS_HF_MASK)\n+\t\treturn rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n+\t\t\t\t\t  NULL, \"RSS hash type not supported\");\n+\n+\tif (rss->types & (RTE_ETH_RSS_NONFRAG_IPV4_UDP | RTE_ETH_RSS_NONFRAG_IPV4_TCP))\n+\t\thash_type |= RTE_BIT32(HASH_FIELD_IPV4_L3_L4);\n+\telse if (rss->types & (RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_FRAG_IPV4))\n+\t\thash_type |= RTE_BIT32(HASH_FIELD_IPV4_L3);\n+\n+\tif (rss->types & (RTE_ETH_RSS_NONFRAG_IPV6_UDP | RTE_ETH_RSS_NONFRAG_IPV6_TCP))\n+\t\thash_type |= RTE_BIT32(HASH_FIELD_IPV6_L3_L4);\n+\telse if (rss->types & (RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_FRAG_IPV6 | RTE_ETH_RSS_IPV6_EX))\n+\t\thash_type |= RTE_BIT32(HASH_FIELD_IPV6_L3);\n+\n \t/* Get a new map key for a new RSS rule */\n \terr = bpf_rss_key(KEY_CMD_GET, &flow->key_idx);\n \tif (err < 0) {\n@@ -2109,8 +2161,11 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd,\n \trss_entry.nb_queues = rss->queue_num;\n \tfor (i = 0; i < rss->queue_num; i++)\n \t\trss_entry.queues[i] = rss->queue[i];\n-\trss_entry.hash_fields =\n-\t\t(1 << HASH_FIELD_IPV4_L3_L4) | (1 << HASH_FIELD_IPV6_L3_L4);\n+\n+\trss_entry.hash_fields = hash_type;\n+\trte_convert_rss_key((const uint32_t *)key_in, (uint32_t *)rss_entry.key,\n+\t\t\t    TAP_RSS_HASH_KEY_SIZE);\n+\n \n \t/* Add this RSS entry to map */\n \terr = tap_flow_bpf_update_rss_elem(pmd->map_fd,\ndiff --git a/drivers/net/tap/tap_rss.h b/drivers/net/tap/tap_rss.h\nindex 8766ffc244..6009be7031 100644\n--- a/drivers/net/tap/tap_rss.h\n+++ b/drivers/net/tap/tap_rss.h\n@@ -24,11 +24,10 @@ enum hash_field {\n };\n \n struct rss_key {\n-\t __u8 key[128];\n \t__u32 hash_fields;\n-\t__u32 key_size;\n-\t__u32 queues[TAP_MAX_QUEUES];\n+\t__u8 key[TAP_RSS_HASH_KEY_SIZE];\n \t__u32 nb_queues;\n+\t__u32 queues[TAP_MAX_QUEUES];\n } __attribute__((packed));\n \n #endif /* _TAP_RSS_H_ */\n",
    "prefixes": [
        "v6",
        "4/8"
    ]
}