get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 85412,
    "url": "https://patches.dpdk.org/api/patches/85412/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20201218093702.3651867-5-jiawenwu@trustnetic.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": "<20201218093702.3651867-5-jiawenwu@trustnetic.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20201218093702.3651867-5-jiawenwu@trustnetic.com",
    "date": "2020-12-18T09:36:33",
    "name": "[v3,04/33] net/txgbe: parse n-tuple filter",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "44ded7cee44291d338bf242199fe884f41ae1ad8",
    "submitter": {
        "id": 1932,
        "url": "https://patches.dpdk.org/api/people/1932/?format=api",
        "name": "Jiawen Wu",
        "email": "jiawenwu@trustnetic.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/20201218093702.3651867-5-jiawenwu@trustnetic.com/mbox/",
    "series": [
        {
            "id": 14363,
            "url": "https://patches.dpdk.org/api/series/14363/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=14363",
            "date": "2020-12-18T09:36:30",
            "name": "net: add txgbe PMD part 2",
            "version": 3,
            "mbox": "https://patches.dpdk.org/series/14363/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/85412/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/85412/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 dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 59FC3A09F6;\n\tFri, 18 Dec 2020 10:36:05 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id CD9B9CA90;\n\tFri, 18 Dec 2020 10:34:46 +0100 (CET)",
            "from smtpbgau1.qq.com (smtpbgau1.qq.com [54.206.16.166])\n by dpdk.org (Postfix) with ESMTP id 312ECCA56\n for <dev@dpdk.org>; Fri, 18 Dec 2020 10:34:42 +0100 (CET)",
            "from localhost.localdomain.com (unknown [183.129.236.74])\n by esmtp10.qq.com (ESMTP) with\n id ; Fri, 18 Dec 2020 17:34:35 +0800 (CST)"
        ],
        "X-QQ-mid": "bizesmtp28t1608284075tolf5i88",
        "X-QQ-SSF": "01400000002000C0D000B00A0000000",
        "X-QQ-FEAT": "jVkkV+jn8LQKNis5KCTMOKaY5LXIcu2IhWfirmvn4/KKhpiGtHyNQnAjkI7rY\n qRgAr/cDRVZVPuqiUxWjehVYG1PoJVSzeitaB1DGiQ6hI6fMUDfQd8C36HjXmUsJ5RorloD\n o91w9R5o3P9At64WiIPgDbSZEWYZ72ne8rw7WU7UcDOGrDx3umusK+sWG4CwwnTHOrwgDMp\n +491rMoOgBdLfn30qdyWGarAiGHkNI1hFrpYpCQCsHJ7HOGWEl8HGSPEdwBlgcWWHN6xqD9\n 8fYQrlEfHvscgxNd0IwtLH1PmE8Uge/0FssKfVFxjAIUXlIPVDa7Uj1q5UzzKD0H63wOHyq\n +qCsXH1we0EXBPgWVQ=",
        "X-QQ-GoodBg": "2",
        "From": "Jiawen Wu <jiawenwu@trustnetic.com>",
        "To": "dev@dpdk.org",
        "Cc": "Jiawen Wu <jiawenwu@trustnetic.com>",
        "Date": "Fri, 18 Dec 2020 17:36:33 +0800",
        "Message-Id": "<20201218093702.3651867-5-jiawenwu@trustnetic.com>",
        "X-Mailer": "git-send-email 2.27.0",
        "In-Reply-To": "<20201218093702.3651867-1-jiawenwu@trustnetic.com>",
        "References": "<20201218093702.3651867-1-jiawenwu@trustnetic.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-QQ-SENDSIZE": "520",
        "Feedback-ID": "bizesmtp:trustnetic.com:qybgforeign:qybgforeign5",
        "X-QQ-Bgrelay": "1",
        "Subject": "[dpdk-dev] [PATCH v3 04/33] net/txgbe: parse n-tuple filter",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "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",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Check if the rule is a n-tuple rule, and get the n-tuple info.\n\nSigned-off-by: Jiawen Wu <jiawenwu@trustnetic.com>\n---\n drivers/net/txgbe/txgbe_flow.c | 524 +++++++++++++++++++++++++++++++++\n 1 file changed, 524 insertions(+)",
    "diff": "diff --git a/drivers/net/txgbe/txgbe_flow.c b/drivers/net/txgbe/txgbe_flow.c\nindex d39ab6416..f4802d269 100644\n--- a/drivers/net/txgbe/txgbe_flow.c\n+++ b/drivers/net/txgbe/txgbe_flow.c\n@@ -2,11 +2,528 @@\n  * Copyright(c) 2015-2020\n  */\n \n+#include <sys/queue.h>\n #include <rte_flow.h>\n #include <rte_flow_driver.h>\n \n #include \"txgbe_ethdev.h\"\n \n+#define TXGBE_MIN_N_TUPLE_PRIO 1\n+#define TXGBE_MAX_N_TUPLE_PRIO 7\n+\n+/**\n+ * Endless loop will never happen with below assumption\n+ * 1. there is at least one no-void item(END)\n+ * 2. cur is before END.\n+ */\n+static inline\n+const struct rte_flow_item *next_no_void_pattern(\n+\t\tconst struct rte_flow_item pattern[],\n+\t\tconst struct rte_flow_item *cur)\n+{\n+\tconst struct rte_flow_item *next =\n+\t\tcur ? cur + 1 : &pattern[0];\n+\twhile (1) {\n+\t\tif (next->type != RTE_FLOW_ITEM_TYPE_VOID)\n+\t\t\treturn next;\n+\t\tnext++;\n+\t}\n+}\n+\n+static inline\n+const struct rte_flow_action *next_no_void_action(\n+\t\tconst struct rte_flow_action actions[],\n+\t\tconst struct rte_flow_action *cur)\n+{\n+\tconst struct rte_flow_action *next =\n+\t\tcur ? cur + 1 : &actions[0];\n+\twhile (1) {\n+\t\tif (next->type != RTE_FLOW_ACTION_TYPE_VOID)\n+\t\t\treturn next;\n+\t\tnext++;\n+\t}\n+}\n+\n+/**\n+ * Please aware there's an assumption for all the parsers.\n+ * rte_flow_item is using big endian, rte_flow_attr and\n+ * rte_flow_action are using CPU order.\n+ * Because the pattern is used to describe the packets,\n+ * normally the packets should use network order.\n+ */\n+\n+/**\n+ * Parse the rule to see if it is a n-tuple rule.\n+ * And get the n-tuple filter info BTW.\n+ * pattern:\n+ * The first not void item can be ETH or IPV4.\n+ * The second not void item must be IPV4 if the first one is ETH.\n+ * The third not void item must be UDP or TCP.\n+ * The next not void item must be END.\n+ * action:\n+ * The first not void action should be QUEUE.\n+ * The next not void action should be END.\n+ * pattern example:\n+ * ITEM\t\tSpec\t\t\tMask\n+ * ETH\t\tNULL\t\t\tNULL\n+ * IPV4\t\tsrc_addr 192.168.1.20\t0xFFFFFFFF\n+ *\t\tdst_addr 192.167.3.50\t0xFFFFFFFF\n+ *\t\tnext_proto_id\t17\t0xFF\n+ * UDP/TCP/\tsrc_port\t80\t0xFFFF\n+ * SCTP\t\tdst_port\t80\t0xFFFF\n+ * END\n+ * other members in mask and spec should set to 0x00.\n+ * item->last should be NULL.\n+ */\n+static int\n+cons_parse_ntuple_filter(const struct rte_flow_attr *attr,\n+\t\t\t const struct rte_flow_item pattern[],\n+\t\t\t const struct rte_flow_action actions[],\n+\t\t\t struct rte_eth_ntuple_filter *filter,\n+\t\t\t struct rte_flow_error *error)\n+{\n+\tconst struct rte_flow_item *item;\n+\tconst struct rte_flow_action *act;\n+\tconst struct rte_flow_item_ipv4 *ipv4_spec;\n+\tconst struct rte_flow_item_ipv4 *ipv4_mask;\n+\tconst struct rte_flow_item_tcp *tcp_spec;\n+\tconst struct rte_flow_item_tcp *tcp_mask;\n+\tconst struct rte_flow_item_udp *udp_spec;\n+\tconst struct rte_flow_item_udp *udp_mask;\n+\tconst struct rte_flow_item_sctp *sctp_spec;\n+\tconst struct rte_flow_item_sctp *sctp_mask;\n+\tconst struct rte_flow_item_eth *eth_spec;\n+\tconst struct rte_flow_item_eth *eth_mask;\n+\tconst struct rte_flow_item_vlan *vlan_spec;\n+\tconst struct rte_flow_item_vlan *vlan_mask;\n+\tstruct rte_flow_item_eth eth_null;\n+\tstruct rte_flow_item_vlan vlan_null;\n+\n+\tif (!pattern) {\n+\t\trte_flow_error_set(error,\n+\t\t\tEINVAL, RTE_FLOW_ERROR_TYPE_ITEM_NUM,\n+\t\t\tNULL, \"NULL pattern.\");\n+\t\treturn -rte_errno;\n+\t}\n+\n+\tif (!actions) {\n+\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\t   RTE_FLOW_ERROR_TYPE_ACTION_NUM,\n+\t\t\t\t   NULL, \"NULL action.\");\n+\t\treturn -rte_errno;\n+\t}\n+\tif (!attr) {\n+\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\t   RTE_FLOW_ERROR_TYPE_ATTR,\n+\t\t\t\t   NULL, \"NULL attribute.\");\n+\t\treturn -rte_errno;\n+\t}\n+\n+\tmemset(&eth_null, 0, sizeof(struct rte_flow_item_eth));\n+\tmemset(&vlan_null, 0, sizeof(struct rte_flow_item_vlan));\n+\n+\t/* the first not void item can be MAC or IPv4 */\n+\titem = next_no_void_pattern(pattern, NULL);\n+\n+\tif (item->type != RTE_FLOW_ITEM_TYPE_ETH &&\n+\t    item->type != RTE_FLOW_ITEM_TYPE_IPV4) {\n+\t\trte_flow_error_set(error, EINVAL,\n+\t\t\tRTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\titem, \"Not supported by ntuple filter\");\n+\t\treturn -rte_errno;\n+\t}\n+\t/* Skip Ethernet */\n+\tif (item->type == RTE_FLOW_ITEM_TYPE_ETH) {\n+\t\teth_spec = item->spec;\n+\t\teth_mask = item->mask;\n+\t\t/*Not supported last point for range*/\n+\t\tif (item->last) {\n+\t\t\trte_flow_error_set(error,\n+\t\t\t  EINVAL,\n+\t\t\t  RTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n+\t\t\t  item, \"Not supported last point for range\");\n+\t\t\treturn -rte_errno;\n+\t\t}\n+\t\t/* if the first item is MAC, the content should be NULL */\n+\t\tif ((item->spec || item->mask) &&\n+\t\t\t(memcmp(eth_spec, &eth_null,\n+\t\t\t\tsizeof(struct rte_flow_item_eth)) ||\n+\t\t\t memcmp(eth_mask, &eth_null,\n+\t\t\t\tsizeof(struct rte_flow_item_eth)))) {\n+\t\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\tRTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\t\titem, \"Not supported by ntuple filter\");\n+\t\t\treturn -rte_errno;\n+\t\t}\n+\t\t/* check if the next not void item is IPv4 or Vlan */\n+\t\titem = next_no_void_pattern(pattern, item);\n+\t\tif (item->type != RTE_FLOW_ITEM_TYPE_IPV4 &&\n+\t\t\titem->type != RTE_FLOW_ITEM_TYPE_VLAN) {\n+\t\t\trte_flow_error_set(error,\n+\t\t\t\tEINVAL, RTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\t\titem, \"Not supported by ntuple filter\");\n+\t\t\treturn -rte_errno;\n+\t\t}\n+\t}\n+\n+\tif (item->type == RTE_FLOW_ITEM_TYPE_VLAN) {\n+\t\tvlan_spec = item->spec;\n+\t\tvlan_mask = item->mask;\n+\t\t/*Not supported last point for range*/\n+\t\tif (item->last) {\n+\t\t\trte_flow_error_set(error,\n+\t\t\t\tEINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n+\t\t\t\titem, \"Not supported last point for range\");\n+\t\t\treturn -rte_errno;\n+\t\t}\n+\t\t/* the content should be NULL */\n+\t\tif ((item->spec || item->mask) &&\n+\t\t\t(memcmp(vlan_spec, &vlan_null,\n+\t\t\t\tsizeof(struct rte_flow_item_vlan)) ||\n+\t\t\t memcmp(vlan_mask, &vlan_null,\n+\t\t\t\tsizeof(struct rte_flow_item_vlan)))) {\n+\t\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\tRTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\t\titem, \"Not supported by ntuple filter\");\n+\t\t\treturn -rte_errno;\n+\t\t}\n+\t\t/* check if the next not void item is IPv4 */\n+\t\titem = next_no_void_pattern(pattern, item);\n+\t\tif (item->type != RTE_FLOW_ITEM_TYPE_IPV4) {\n+\t\t\trte_flow_error_set(error,\n+\t\t\t  EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\t  item, \"Not supported by ntuple filter\");\n+\t\t\treturn -rte_errno;\n+\t\t}\n+\t}\n+\n+\tif (item->mask) {\n+\t\t/* get the IPv4 info */\n+\t\tif (!item->spec || !item->mask) {\n+\t\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\tRTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\t\titem, \"Invalid ntuple mask\");\n+\t\t\treturn -rte_errno;\n+\t\t}\n+\t\t/*Not supported last point for range*/\n+\t\tif (item->last) {\n+\t\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\tRTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n+\t\t\t\titem, \"Not supported last point for range\");\n+\t\t\treturn -rte_errno;\n+\t\t}\n+\n+\t\tipv4_mask = item->mask;\n+\t\t/**\n+\t\t * Only support src & dst addresses, protocol,\n+\t\t * others should be masked.\n+\t\t */\n+\t\tif (ipv4_mask->hdr.version_ihl ||\n+\t\t    ipv4_mask->hdr.type_of_service ||\n+\t\t    ipv4_mask->hdr.total_length ||\n+\t\t    ipv4_mask->hdr.packet_id ||\n+\t\t    ipv4_mask->hdr.fragment_offset ||\n+\t\t    ipv4_mask->hdr.time_to_live ||\n+\t\t    ipv4_mask->hdr.hdr_checksum) {\n+\t\t\trte_flow_error_set(error,\n+\t\t\t\tEINVAL, RTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\t\titem, \"Not supported by ntuple filter\");\n+\t\t\treturn -rte_errno;\n+\t\t}\n+\t\tif ((ipv4_mask->hdr.src_addr != 0 &&\n+\t\t\tipv4_mask->hdr.src_addr != UINT32_MAX) ||\n+\t\t\t(ipv4_mask->hdr.dst_addr != 0 &&\n+\t\t\tipv4_mask->hdr.dst_addr != UINT32_MAX) ||\n+\t\t\t(ipv4_mask->hdr.next_proto_id != UINT8_MAX &&\n+\t\t\tipv4_mask->hdr.next_proto_id != 0)) {\n+\t\t\trte_flow_error_set(error,\n+\t\t\t\tEINVAL, RTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\t\titem, \"Not supported by ntuple filter\");\n+\t\t\treturn -rte_errno;\n+\t\t}\n+\n+\t\tfilter->dst_ip_mask = ipv4_mask->hdr.dst_addr;\n+\t\tfilter->src_ip_mask = ipv4_mask->hdr.src_addr;\n+\t\tfilter->proto_mask  = ipv4_mask->hdr.next_proto_id;\n+\n+\t\tipv4_spec = item->spec;\n+\t\tfilter->dst_ip = ipv4_spec->hdr.dst_addr;\n+\t\tfilter->src_ip = ipv4_spec->hdr.src_addr;\n+\t\tfilter->proto  = ipv4_spec->hdr.next_proto_id;\n+\t}\n+\n+\t/* check if the next not void item is TCP or UDP */\n+\titem = next_no_void_pattern(pattern, item);\n+\tif (item->type != RTE_FLOW_ITEM_TYPE_TCP &&\n+\t    item->type != RTE_FLOW_ITEM_TYPE_UDP &&\n+\t    item->type != RTE_FLOW_ITEM_TYPE_SCTP &&\n+\t    item->type != RTE_FLOW_ITEM_TYPE_END) {\n+\t\tmemset(filter, 0, sizeof(struct rte_eth_ntuple_filter));\n+\t\trte_flow_error_set(error, EINVAL,\n+\t\t\tRTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\titem, \"Not supported by ntuple filter\");\n+\t\treturn -rte_errno;\n+\t}\n+\n+\tif (item->type != RTE_FLOW_ITEM_TYPE_END &&\n+\t\t(!item->spec && !item->mask)) {\n+\t\tgoto action;\n+\t}\n+\n+\t/* get the TCP/UDP/SCTP info */\n+\tif (item->type != RTE_FLOW_ITEM_TYPE_END &&\n+\t\t(!item->spec || !item->mask)) {\n+\t\tmemset(filter, 0, sizeof(struct rte_eth_ntuple_filter));\n+\t\trte_flow_error_set(error, EINVAL,\n+\t\t\tRTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\titem, \"Invalid ntuple mask\");\n+\t\treturn -rte_errno;\n+\t}\n+\n+\t/*Not supported last point for range*/\n+\tif (item->last) {\n+\t\tmemset(filter, 0, sizeof(struct rte_eth_ntuple_filter));\n+\t\trte_flow_error_set(error, EINVAL,\n+\t\t\tRTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n+\t\t\titem, \"Not supported last point for range\");\n+\t\treturn -rte_errno;\n+\t}\n+\n+\tif (item->type == RTE_FLOW_ITEM_TYPE_TCP) {\n+\t\ttcp_mask = item->mask;\n+\n+\t\t/**\n+\t\t * Only support src & dst ports, tcp flags,\n+\t\t * others should be masked.\n+\t\t */\n+\t\tif (tcp_mask->hdr.sent_seq ||\n+\t\t    tcp_mask->hdr.recv_ack ||\n+\t\t    tcp_mask->hdr.data_off ||\n+\t\t    tcp_mask->hdr.rx_win ||\n+\t\t    tcp_mask->hdr.cksum ||\n+\t\t    tcp_mask->hdr.tcp_urp) {\n+\t\t\tmemset(filter, 0,\n+\t\t\t\tsizeof(struct rte_eth_ntuple_filter));\n+\t\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\tRTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\t\titem, \"Not supported by ntuple filter\");\n+\t\t\treturn -rte_errno;\n+\t\t}\n+\t\tif ((tcp_mask->hdr.src_port != 0 &&\n+\t\t\ttcp_mask->hdr.src_port != UINT16_MAX) ||\n+\t\t\t(tcp_mask->hdr.dst_port != 0 &&\n+\t\t\ttcp_mask->hdr.dst_port != UINT16_MAX)) {\n+\t\t\trte_flow_error_set(error,\n+\t\t\t\tEINVAL, RTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\t\titem, \"Not supported by ntuple filter\");\n+\t\t\treturn -rte_errno;\n+\t\t}\n+\n+\t\tfilter->dst_port_mask  = tcp_mask->hdr.dst_port;\n+\t\tfilter->src_port_mask  = tcp_mask->hdr.src_port;\n+\t\tif (tcp_mask->hdr.tcp_flags == 0xFF) {\n+\t\t\tfilter->flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;\n+\t\t} else if (!tcp_mask->hdr.tcp_flags) {\n+\t\t\tfilter->flags &= ~RTE_NTUPLE_FLAGS_TCP_FLAG;\n+\t\t} else {\n+\t\t\tmemset(filter, 0, sizeof(struct rte_eth_ntuple_filter));\n+\t\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\tRTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\t\titem, \"Not supported by ntuple filter\");\n+\t\t\treturn -rte_errno;\n+\t\t}\n+\n+\t\ttcp_spec = item->spec;\n+\t\tfilter->dst_port  = tcp_spec->hdr.dst_port;\n+\t\tfilter->src_port  = tcp_spec->hdr.src_port;\n+\t\tfilter->tcp_flags = tcp_spec->hdr.tcp_flags;\n+\t} else if (item->type == RTE_FLOW_ITEM_TYPE_UDP) {\n+\t\tudp_mask = item->mask;\n+\n+\t\t/**\n+\t\t * Only support src & dst ports,\n+\t\t * others should be masked.\n+\t\t */\n+\t\tif (udp_mask->hdr.dgram_len ||\n+\t\t    udp_mask->hdr.dgram_cksum) {\n+\t\t\tmemset(filter, 0,\n+\t\t\t\tsizeof(struct rte_eth_ntuple_filter));\n+\t\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\tRTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\t\titem, \"Not supported by ntuple filter\");\n+\t\t\treturn -rte_errno;\n+\t\t}\n+\t\tif ((udp_mask->hdr.src_port != 0 &&\n+\t\t\tudp_mask->hdr.src_port != UINT16_MAX) ||\n+\t\t\t(udp_mask->hdr.dst_port != 0 &&\n+\t\t\tudp_mask->hdr.dst_port != UINT16_MAX)) {\n+\t\t\trte_flow_error_set(error,\n+\t\t\t\tEINVAL, RTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\t\titem, \"Not supported by ntuple filter\");\n+\t\t\treturn -rte_errno;\n+\t\t}\n+\n+\t\tfilter->dst_port_mask = udp_mask->hdr.dst_port;\n+\t\tfilter->src_port_mask = udp_mask->hdr.src_port;\n+\n+\t\tudp_spec = item->spec;\n+\t\tfilter->dst_port = udp_spec->hdr.dst_port;\n+\t\tfilter->src_port = udp_spec->hdr.src_port;\n+\t} else if (item->type == RTE_FLOW_ITEM_TYPE_SCTP) {\n+\t\tsctp_mask = item->mask;\n+\n+\t\t/**\n+\t\t * Only support src & dst ports,\n+\t\t * others should be masked.\n+\t\t */\n+\t\tif (sctp_mask->hdr.tag ||\n+\t\t    sctp_mask->hdr.cksum) {\n+\t\t\tmemset(filter, 0,\n+\t\t\t\tsizeof(struct rte_eth_ntuple_filter));\n+\t\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\tRTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\t\titem, \"Not supported by ntuple filter\");\n+\t\t\treturn -rte_errno;\n+\t\t}\n+\n+\t\tfilter->dst_port_mask = sctp_mask->hdr.dst_port;\n+\t\tfilter->src_port_mask = sctp_mask->hdr.src_port;\n+\n+\t\tsctp_spec = item->spec;\n+\t\tfilter->dst_port = sctp_spec->hdr.dst_port;\n+\t\tfilter->src_port = sctp_spec->hdr.src_port;\n+\t} else {\n+\t\tgoto action;\n+\t}\n+\n+\t/* check if the next not void item is END */\n+\titem = next_no_void_pattern(pattern, item);\n+\tif (item->type != RTE_FLOW_ITEM_TYPE_END) {\n+\t\tmemset(filter, 0, sizeof(struct rte_eth_ntuple_filter));\n+\t\trte_flow_error_set(error, EINVAL,\n+\t\t\tRTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\titem, \"Not supported by ntuple filter\");\n+\t\treturn -rte_errno;\n+\t}\n+\n+action:\n+\n+\t/**\n+\t * n-tuple only supports forwarding,\n+\t * check if the first not void action is QUEUE.\n+\t */\n+\tact = next_no_void_action(actions, NULL);\n+\tif (act->type != RTE_FLOW_ACTION_TYPE_QUEUE) {\n+\t\tmemset(filter, 0, sizeof(struct rte_eth_ntuple_filter));\n+\t\trte_flow_error_set(error, EINVAL,\n+\t\t\tRTE_FLOW_ERROR_TYPE_ACTION,\n+\t\t\titem, \"Not supported action.\");\n+\t\treturn -rte_errno;\n+\t}\n+\tfilter->queue =\n+\t\t((const struct rte_flow_action_queue *)act->conf)->index;\n+\n+\t/* check if the next not void item is END */\n+\tact = next_no_void_action(actions, act);\n+\tif (act->type != RTE_FLOW_ACTION_TYPE_END) {\n+\t\tmemset(filter, 0, sizeof(struct rte_eth_ntuple_filter));\n+\t\trte_flow_error_set(error, EINVAL,\n+\t\t\tRTE_FLOW_ERROR_TYPE_ACTION,\n+\t\t\tact, \"Not supported action.\");\n+\t\treturn -rte_errno;\n+\t}\n+\n+\t/* parse attr */\n+\t/* must be input direction */\n+\tif (!attr->ingress) {\n+\t\tmemset(filter, 0, sizeof(struct rte_eth_ntuple_filter));\n+\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\t   RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,\n+\t\t\t\t   attr, \"Only support ingress.\");\n+\t\treturn -rte_errno;\n+\t}\n+\n+\t/* not supported */\n+\tif (attr->egress) {\n+\t\tmemset(filter, 0, sizeof(struct rte_eth_ntuple_filter));\n+\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\t   RTE_FLOW_ERROR_TYPE_ATTR_EGRESS,\n+\t\t\t\t   attr, \"Not support egress.\");\n+\t\treturn -rte_errno;\n+\t}\n+\n+\t/* not supported */\n+\tif (attr->transfer) {\n+\t\tmemset(filter, 0, sizeof(struct rte_eth_ntuple_filter));\n+\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\t   RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER,\n+\t\t\t\t   attr, \"No support for transfer.\");\n+\t\treturn -rte_errno;\n+\t}\n+\n+\tif (attr->priority > 0xFFFF) {\n+\t\tmemset(filter, 0, sizeof(struct rte_eth_ntuple_filter));\n+\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\t   RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,\n+\t\t\t\t   attr, \"Error priority.\");\n+\t\treturn -rte_errno;\n+\t}\n+\tfilter->priority = (uint16_t)attr->priority;\n+\tif (attr->priority < TXGBE_MIN_N_TUPLE_PRIO ||\n+\t\tattr->priority > TXGBE_MAX_N_TUPLE_PRIO)\n+\t\tfilter->priority = 1;\n+\n+\treturn 0;\n+}\n+\n+/* a specific function for txgbe because the flags is specific */\n+static int\n+txgbe_parse_ntuple_filter(struct rte_eth_dev *dev,\n+\t\t\t  const struct rte_flow_attr *attr,\n+\t\t\t  const struct rte_flow_item pattern[],\n+\t\t\t  const struct rte_flow_action actions[],\n+\t\t\t  struct rte_eth_ntuple_filter *filter,\n+\t\t\t  struct rte_flow_error *error)\n+{\n+\tint ret;\n+\n+\tret = cons_parse_ntuple_filter(attr, pattern, actions, filter, error);\n+\n+\tif (ret)\n+\t\treturn ret;\n+\n+\t/* txgbe doesn't support tcp flags */\n+\tif (filter->flags & RTE_NTUPLE_FLAGS_TCP_FLAG) {\n+\t\tmemset(filter, 0, sizeof(struct rte_eth_ntuple_filter));\n+\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\t   RTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\t\t   NULL, \"Not supported by ntuple filter\");\n+\t\treturn -rte_errno;\n+\t}\n+\n+\t/* txgbe doesn't support many priorities */\n+\tif (filter->priority < TXGBE_MIN_N_TUPLE_PRIO ||\n+\t    filter->priority > TXGBE_MAX_N_TUPLE_PRIO) {\n+\t\tmemset(filter, 0, sizeof(struct rte_eth_ntuple_filter));\n+\t\trte_flow_error_set(error, EINVAL,\n+\t\t\tRTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\tNULL, \"Priority not supported by ntuple filter\");\n+\t\treturn -rte_errno;\n+\t}\n+\n+\tif (filter->queue >= dev->data->nb_rx_queues) {\n+\t\tmemset(filter, 0, sizeof(struct rte_eth_ntuple_filter));\n+\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\t   RTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\t\t   NULL, \"Not supported by ntuple filter\");\n+\t\treturn -rte_errno;\n+\t}\n+\n+\t/* fixed value for txgbe */\n+\tfilter->flags = RTE_5TUPLE_FLAGS;\n+\treturn 0;\n+}\n+\n /**\n  * Create or destroy a flow rule.\n  * Theorically one rule can match more than one filters.\n@@ -36,8 +553,15 @@ txgbe_flow_validate(struct rte_eth_dev *dev,\n \t\tconst struct rte_flow_action actions[],\n \t\tstruct rte_flow_error *error)\n {\n+\tstruct rte_eth_ntuple_filter ntuple_filter;\n \tint ret = 0;\n \n+\tmemset(&ntuple_filter, 0, sizeof(struct rte_eth_ntuple_filter));\n+\tret = txgbe_parse_ntuple_filter(dev, attr, pattern,\n+\t\t\t\tactions, &ntuple_filter, error);\n+\tif (!ret)\n+\t\treturn 0;\n+\n \treturn ret;\n }\n \n",
    "prefixes": [
        "v3",
        "04/33"
    ]
}