get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 28438,
    "url": "https://patches.dpdk.org/api/patches/28438/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1504783263-20575-5-git-send-email-beilei.xing@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": "<1504783263-20575-5-git-send-email-beilei.xing@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1504783263-20575-5-git-send-email-beilei.xing@intel.com",
    "date": "2017-09-07T11:21:01",
    "name": "[dpdk-dev,v2,4/6] net/i40e: add FDIR support for GTP-C and GTP-U",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "3cbb1d962c78a5267c50159cba0004a50ba59aad",
    "submitter": {
        "id": 410,
        "url": "https://patches.dpdk.org/api/people/410/?format=api",
        "name": "Xing, Beilei",
        "email": "beilei.xing@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1504783263-20575-5-git-send-email-beilei.xing@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/28438/comments/",
    "check": "fail",
    "checks": "https://patches.dpdk.org/api/patches/28438/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 75710199C6;\n\tThu,  7 Sep 2017 13:21:10 +0200 (CEST)",
            "from mga05.intel.com (mga05.intel.com [192.55.52.43])\n\tby dpdk.org (Postfix) with ESMTP id 90CF0199B8\n\tfor <dev@dpdk.org>; Thu,  7 Sep 2017 13:21:06 +0200 (CEST)",
            "from orsmga005.jf.intel.com ([10.7.209.41])\n\tby fmsmga105.fm.intel.com with ESMTP; 07 Sep 2017 04:21:05 -0700",
            "from unknown (HELO dpdk9.sh.intel.com) ([10.67.118.52])\n\tby orsmga005.jf.intel.com with ESMTP; 07 Sep 2017 04:21:04 -0700"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.42,358,1500966000\"; d=\"scan'208\";a=\"146527084\"",
        "From": "Beilei Xing <beilei.xing@intel.com>",
        "To": "jingjing.wu@intel.com",
        "Cc": "andrey.chilikin@intel.com,\n\tdev@dpdk.org",
        "Date": "Thu,  7 Sep 2017 19:21:01 +0800",
        "Message-Id": "<1504783263-20575-5-git-send-email-beilei.xing@intel.com>",
        "X-Mailer": "git-send-email 2.5.5",
        "In-Reply-To": "<1504783263-20575-1-git-send-email-beilei.xing@intel.com>",
        "References": "<1503647430-93905-2-git-send-email-beilei.xing@intel.com>\n\t<1504783263-20575-1-git-send-email-beilei.xing@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v2 4/6] net/i40e: add FDIR support for GTP-C and\n\tGTP-U",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "This patch adds FDIR support for GTP-C and GTP-U.\n\nSigned-off-by: Beilei Xing <beilei.xing@intel.com>\n---\n drivers/net/i40e/i40e_ethdev.c |   1 +\n drivers/net/i40e/i40e_ethdev.h |  11 +++\n drivers/net/i40e/i40e_fdir.c   | 170 +++++++++++++++++++++++++++--------------\n drivers/net/i40e/i40e_flow.c   | 165 ++++++++++++++++++++++++++++++---------\n 4 files changed, 255 insertions(+), 92 deletions(-)",
    "diff": "diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c\nindex 5483622..18b3d8c 100644\n--- a/drivers/net/i40e/i40e_ethdev.c\n+++ b/drivers/net/i40e/i40e_ethdev.c\n@@ -1051,6 +1051,7 @@ i40e_init_customer_pctype(struct i40e_pf *pf)\n \t\t\trte_memcpy(pf->new_pctype[i].name, \"GTPU\",\n \t\t\t\t   sizeof(\"GTPU\"));\n \t}\n+\tpf->new_pctype_used = false;\n }\n \n static int\ndiff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h\nindex ca8d201..9fff85f 100644\n--- a/drivers/net/i40e/i40e_ethdev.h\n+++ b/drivers/net/i40e/i40e_ethdev.h\n@@ -233,6 +233,7 @@ enum i40e_flxpld_layer_idx {\n #define I40E_INSET_TUNNEL_SRC_PORT       0x0000000800000000ULL\n #define I40E_INSET_TUNNEL_DST_PORT       0x0000001000000000ULL\n #define I40E_INSET_TUNNEL_ID             0x0000002000000000ULL\n+#define I40E_INSET_GTP_TEID              0x0000004000000000ULL\n \n /* bit 48 ~ bit 55 */\n #define I40E_INSET_LAST_ETHER_TYPE 0x0001000000000000ULL\n@@ -461,6 +462,14 @@ struct i40e_vmdq_info {\n #define I40E_FDIR_IPv6_TC_OFFSET\t20\n \n /**\n+ * A structure used to define the input for IPV4 GTP flow\n+ */\n+struct i40e_gtpv4_flow {\n+\tstruct rte_eth_udpv4_flow udp; /**< IPv4 UDP fields to match. */\n+\tuint32_t teid;                 /**< TEID in big endian. */\n+};\n+\n+/**\n  * A union contains the inputs for all types of flow\n  * Items in flows need to be in big endian\n  */\n@@ -474,6 +483,7 @@ union i40e_fdir_flow {\n \tstruct rte_eth_tcpv6_flow  tcp6_flow;\n \tstruct rte_eth_sctpv6_flow sctp6_flow;\n \tstruct rte_eth_ipv6_flow   ipv6_flow;\n+\tstruct i40e_gtpv4_flow     gtpv4_flow;\n };\n \n /**\n@@ -888,6 +898,7 @@ struct i40e_pf {\n \tstruct i40e_tm_conf tm_conf;\n \t/* customer personalized pctype */\n \tstruct i40e_personalized_pctype new_pctype[I40E_PERSONALIZED_MAX];\n+\tbool new_pctype_used; /* Check if new PCTYPE is used for FDIR */\n };\n \n enum pending_msg {\ndiff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c\nindex b0ba819..25a9c7d 100644\n--- a/drivers/net/i40e/i40e_fdir.c\n+++ b/drivers/net/i40e/i40e_fdir.c\n@@ -71,6 +71,7 @@\n #define I40E_FDIR_IPv6_DEFAULT_HOP_LIMITS   0xFF\n #define I40E_FDIR_IPv6_PAYLOAD_LEN          380\n #define I40E_FDIR_UDP_DEFAULT_LEN           400\n+#define I40E_FDIR_GTP_DEFAULT_LEN           384\n \n /* Wait time for fdir filter programming */\n #define I40E_FDIR_MAX_WAIT_US 10000\n@@ -939,16 +940,33 @@ i40e_fdir_construct_pkt(struct i40e_pf *pf,\n \treturn 0;\n }\n \n+static struct i40e_personalized_pctype *\n+i40e_flow_fdir_check_new_pctype(struct i40e_pf *pf, uint8_t pctype)\n+{\n+\tstruct i40e_personalized_pctype *cus_pctype;\n+\tenum i40e_new_proto i = I40E_PERSONALIZED_GTPC;\n+\n+\tfor (; i < I40E_PERSONALIZED_MAX; i++) {\n+\t\tcus_pctype = &pf->new_pctype[i];\n+\t\tif (pctype == cus_pctype->pctype)\n+\t\t\treturn cus_pctype;\n+\t}\n+\treturn NULL;\n+}\n+\n static inline int\n-i40e_flow_fdir_fill_eth_ip_head(const struct i40e_fdir_input *fdir_input,\n+i40e_flow_fdir_fill_eth_ip_head(struct i40e_pf *pf,\n+\t\t\t\tconst struct i40e_fdir_input *fdir_input,\n \t\t\t\tunsigned char *raw_pkt,\n \t\t\t\tbool vlan)\n {\n+\tstruct i40e_personalized_pctype *cus_pctype;\n \tstatic uint8_t vlan_frame[] = {0x81, 0, 0, 0};\n \tuint16_t *ether_type;\n \tuint8_t len = 2 * sizeof(struct ether_addr);\n \tstruct ipv4_hdr *ip;\n \tstruct ipv6_hdr *ip6;\n+\tuint8_t pctype = fdir_input->pctype;\n \tstatic const uint8_t next_proto[] = {\n \t\t[I40E_FILTER_PCTYPE_FRAG_IPV4] = IPPROTO_IP,\n \t\t[I40E_FILTER_PCTYPE_NONF_IPV4_TCP] = IPPROTO_TCP,\n@@ -975,15 +993,13 @@ i40e_flow_fdir_fill_eth_ip_head(const struct i40e_fdir_input *fdir_input,\n \traw_pkt += sizeof(uint16_t);\n \tlen += sizeof(uint16_t);\n \n-\tswitch (fdir_input->pctype) {\n-\tcase I40E_FILTER_PCTYPE_L2_PAYLOAD:\n+\tif (pctype == I40E_FILTER_PCTYPE_L2_PAYLOAD)\n \t\t*ether_type = fdir_input->flow.l2_flow.ether_type;\n-\t\tbreak;\n-\tcase I40E_FILTER_PCTYPE_NONF_IPV4_TCP:\n-\tcase I40E_FILTER_PCTYPE_NONF_IPV4_UDP:\n-\tcase I40E_FILTER_PCTYPE_NONF_IPV4_SCTP:\n-\tcase I40E_FILTER_PCTYPE_NONF_IPV4_OTHER:\n-\tcase I40E_FILTER_PCTYPE_FRAG_IPV4:\n+\telse if (pctype == I40E_FILTER_PCTYPE_NONF_IPV4_TCP ||\n+\t\t pctype == I40E_FILTER_PCTYPE_NONF_IPV4_UDP ||\n+\t\t pctype == I40E_FILTER_PCTYPE_NONF_IPV4_SCTP ||\n+\t\t pctype == I40E_FILTER_PCTYPE_NONF_IPV4_OTHER ||\n+\t\t pctype == I40E_FILTER_PCTYPE_FRAG_IPV4) {\n \t\tip = (struct ipv4_hdr *)raw_pkt;\n \n \t\t*ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4);\n@@ -991,11 +1007,11 @@ i40e_flow_fdir_fill_eth_ip_head(const struct i40e_fdir_input *fdir_input,\n \t\t/* set len to by default */\n \t\tip->total_length = rte_cpu_to_be_16(I40E_FDIR_IP_DEFAULT_LEN);\n \t\tip->next_proto_id = fdir_input->flow.ip4_flow.proto ?\n-\t\t\t\t\tfdir_input->flow.ip4_flow.proto :\n-\t\t\t\t\tnext_proto[fdir_input->pctype];\n+\t\t\tfdir_input->flow.ip4_flow.proto :\n+\t\t\tnext_proto[fdir_input->pctype];\n \t\tip->time_to_live = fdir_input->flow.ip4_flow.ttl ?\n-\t\t\t\t\tfdir_input->flow.ip4_flow.ttl :\n-\t\t\t\t\tI40E_FDIR_IP_DEFAULT_TTL;\n+\t\t\tfdir_input->flow.ip4_flow.ttl :\n+\t\t\tI40E_FDIR_IP_DEFAULT_TTL;\n \t\tip->type_of_service = fdir_input->flow.ip4_flow.tos;\n \t\t/**\n \t\t * The source and destination fields in the transmitted packet\n@@ -1005,12 +1021,11 @@ i40e_flow_fdir_fill_eth_ip_head(const struct i40e_fdir_input *fdir_input,\n \t\tip->src_addr = fdir_input->flow.ip4_flow.dst_ip;\n \t\tip->dst_addr = fdir_input->flow.ip4_flow.src_ip;\n \t\tlen += sizeof(struct ipv4_hdr);\n-\t\tbreak;\n-\tcase I40E_FILTER_PCTYPE_NONF_IPV6_TCP:\n-\tcase I40E_FILTER_PCTYPE_NONF_IPV6_UDP:\n-\tcase I40E_FILTER_PCTYPE_NONF_IPV6_SCTP:\n-\tcase I40E_FILTER_PCTYPE_NONF_IPV6_OTHER:\n-\tcase I40E_FILTER_PCTYPE_FRAG_IPV6:\n+\t} else if (pctype == I40E_FILTER_PCTYPE_NONF_IPV6_TCP ||\n+\t\t   pctype == I40E_FILTER_PCTYPE_NONF_IPV6_UDP ||\n+\t\t   pctype == I40E_FILTER_PCTYPE_NONF_IPV6_SCTP ||\n+\t\t   pctype == I40E_FILTER_PCTYPE_NONF_IPV6_OTHER ||\n+\t\t   pctype == I40E_FILTER_PCTYPE_FRAG_IPV6) {\n \t\tip6 = (struct ipv6_hdr *)raw_pkt;\n \n \t\t*ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv6);\n@@ -1021,11 +1036,11 @@ i40e_flow_fdir_fill_eth_ip_head(const struct i40e_fdir_input *fdir_input,\n \t\tip6->payload_len =\n \t\t\trte_cpu_to_be_16(I40E_FDIR_IPv6_PAYLOAD_LEN);\n \t\tip6->proto = fdir_input->flow.ipv6_flow.proto ?\n-\t\t\t\t\tfdir_input->flow.ipv6_flow.proto :\n-\t\t\t\t\tnext_proto[fdir_input->pctype];\n+\t\t\tfdir_input->flow.ipv6_flow.proto :\n+\t\t\tnext_proto[fdir_input->pctype];\n \t\tip6->hop_limits = fdir_input->flow.ipv6_flow.hop_limits ?\n-\t\t\t\t\tfdir_input->flow.ipv6_flow.hop_limits :\n-\t\t\t\t\tI40E_FDIR_IPv6_DEFAULT_HOP_LIMITS;\n+\t\t\tfdir_input->flow.ipv6_flow.hop_limits :\n+\t\t\tI40E_FDIR_IPv6_DEFAULT_HOP_LIMITS;\n \t\t/**\n \t\t * The source and destination fields in the transmitted packet\n \t\t * need to be presented in a reversed order with respect\n@@ -1038,12 +1053,39 @@ i40e_flow_fdir_fill_eth_ip_head(const struct i40e_fdir_input *fdir_input,\n \t\t\t   &fdir_input->flow.ipv6_flow.src_ip,\n \t\t\t   IPV6_ADDR_LEN);\n \t\tlen += sizeof(struct ipv6_hdr);\n-\t\tbreak;\n-\tdefault:\n+\t} else if (pf->new_pctype_used) {\n+\t\tcus_pctype = i40e_flow_fdir_check_new_pctype(pf, pctype);\n+\t\tip = (struct ipv4_hdr *)raw_pkt;\n+\n+\t\t*ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4);\n+\t\tip->version_ihl = I40E_FDIR_IP_DEFAULT_VERSION_IHL;\n+\t\t/* set len to by default */\n+\t\tip->total_length = rte_cpu_to_be_16(I40E_FDIR_IP_DEFAULT_LEN);\n+\t\tip->next_proto_id = fdir_input->flow.ip4_flow.proto ?\n+\t\t\tfdir_input->flow.ip4_flow.proto :\n+\t\t\tnext_proto[fdir_input->pctype];\n+\t\tip->time_to_live = fdir_input->flow.ip4_flow.ttl ?\n+\t\t\tfdir_input->flow.ip4_flow.ttl :\n+\t\t\tI40E_FDIR_IP_DEFAULT_TTL;\n+\t\tip->type_of_service = fdir_input->flow.ip4_flow.tos;\n+\n+\t\tif (!memcmp(cus_pctype->name, \"GTPC\", sizeof(\"GTPC\")) ||\n+\t\t    !memcmp(cus_pctype->name, \"GTPU\", sizeof(\"GTPU\")))\n+\t\t\tip->next_proto_id = IPPROTO_UDP;\n+\t\t/**\n+\t\t * The source and destination fields in the transmitted packet\n+\t\t * need to be presented in a reversed order with respect\n+\t\t * to the expected received packets.\n+\t\t */\n+\t\tip->src_addr = fdir_input->flow.ip4_flow.dst_ip;\n+\t\tip->dst_addr = fdir_input->flow.ip4_flow.src_ip;\n+\t\tlen += sizeof(struct ipv4_hdr);\n+\t} else {\n \t\tPMD_DRV_LOG(ERR, \"unknown pctype %u.\",\n \t\t\t    fdir_input->pctype);\n \t\treturn -1;\n \t}\n+\n \treturn len;\n }\n \n@@ -1058,23 +1100,26 @@ i40e_flow_fdir_construct_pkt(struct i40e_pf *pf,\n \t\t\t     const struct i40e_fdir_input *fdir_input,\n \t\t\t     unsigned char *raw_pkt)\n {\n-\tunsigned char *payload, *ptr;\n+\tunsigned char *payload = NULL;\n+\tunsigned char *ptr;\n \tstruct udp_hdr *udp;\n \tstruct tcp_hdr *tcp;\n \tstruct sctp_hdr *sctp;\n+\tstruct rte_flow_item_gtp *gtp;\n \tuint8_t size, dst = 0;\n \tuint8_t i, pit_idx, set_idx = I40E_FLXPLD_L4_IDX; /* use l4 by default*/\n \tint len;\n+\tuint8_t pctype = fdir_input->pctype;\n+\tstruct i40e_personalized_pctype *cus_pctype;\n \n \t/* fill the ethernet and IP head */\n-\tlen = i40e_flow_fdir_fill_eth_ip_head(fdir_input, raw_pkt,\n+\tlen = i40e_flow_fdir_fill_eth_ip_head(pf, fdir_input, raw_pkt,\n \t\t\t\t\t      !!fdir_input->flow_ext.vlan_tci);\n \tif (len < 0)\n \t\treturn -EINVAL;\n \n \t/* fill the L4 head */\n-\tswitch (fdir_input->pctype) {\n-\tcase I40E_FILTER_PCTYPE_NONF_IPV4_UDP:\n+\tif (pctype == I40E_FILTER_PCTYPE_NONF_IPV4_UDP) {\n \t\tudp = (struct udp_hdr *)(raw_pkt + len);\n \t\tpayload = (unsigned char *)udp + sizeof(struct udp_hdr);\n \t\t/**\n@@ -1085,9 +1130,7 @@ i40e_flow_fdir_construct_pkt(struct i40e_pf *pf,\n \t\tudp->src_port = fdir_input->flow.udp4_flow.dst_port;\n \t\tudp->dst_port = fdir_input->flow.udp4_flow.src_port;\n \t\tudp->dgram_len = rte_cpu_to_be_16(I40E_FDIR_UDP_DEFAULT_LEN);\n-\t\tbreak;\n-\n-\tcase I40E_FILTER_PCTYPE_NONF_IPV4_TCP:\n+\t} else if (pctype == I40E_FILTER_PCTYPE_NONF_IPV4_TCP) {\n \t\ttcp = (struct tcp_hdr *)(raw_pkt + len);\n \t\tpayload = (unsigned char *)tcp + sizeof(struct tcp_hdr);\n \t\t/**\n@@ -1098,9 +1141,7 @@ i40e_flow_fdir_construct_pkt(struct i40e_pf *pf,\n \t\ttcp->src_port = fdir_input->flow.tcp4_flow.dst_port;\n \t\ttcp->dst_port = fdir_input->flow.tcp4_flow.src_port;\n \t\ttcp->data_off = I40E_FDIR_TCP_DEFAULT_DATAOFF;\n-\t\tbreak;\n-\n-\tcase I40E_FILTER_PCTYPE_NONF_IPV4_SCTP:\n+\t} else if (pctype == I40E_FILTER_PCTYPE_NONF_IPV4_SCTP) {\n \t\tsctp = (struct sctp_hdr *)(raw_pkt + len);\n \t\tpayload = (unsigned char *)sctp + sizeof(struct sctp_hdr);\n \t\t/**\n@@ -1111,15 +1152,11 @@ i40e_flow_fdir_construct_pkt(struct i40e_pf *pf,\n \t\tsctp->src_port = fdir_input->flow.sctp4_flow.dst_port;\n \t\tsctp->dst_port = fdir_input->flow.sctp4_flow.src_port;\n \t\tsctp->tag = fdir_input->flow.sctp4_flow.verify_tag;\n-\t\tbreak;\n-\n-\tcase I40E_FILTER_PCTYPE_NONF_IPV4_OTHER:\n-\tcase I40E_FILTER_PCTYPE_FRAG_IPV4:\n+\t} else if (pctype == I40E_FILTER_PCTYPE_NONF_IPV4_OTHER ||\n+\t\t   pctype == I40E_FILTER_PCTYPE_FRAG_IPV4) {\n \t\tpayload = raw_pkt + len;\n \t\tset_idx = I40E_FLXPLD_L3_IDX;\n-\t\tbreak;\n-\n-\tcase I40E_FILTER_PCTYPE_NONF_IPV6_UDP:\n+\t} else if (pctype == I40E_FILTER_PCTYPE_NONF_IPV6_UDP) {\n \t\tudp = (struct udp_hdr *)(raw_pkt + len);\n \t\tpayload = (unsigned char *)udp + sizeof(struct udp_hdr);\n \t\t/**\n@@ -1130,9 +1167,7 @@ i40e_flow_fdir_construct_pkt(struct i40e_pf *pf,\n \t\tudp->src_port = fdir_input->flow.udp6_flow.dst_port;\n \t\tudp->dst_port = fdir_input->flow.udp6_flow.src_port;\n \t\tudp->dgram_len = rte_cpu_to_be_16(I40E_FDIR_IPv6_PAYLOAD_LEN);\n-\t\tbreak;\n-\n-\tcase I40E_FILTER_PCTYPE_NONF_IPV6_TCP:\n+\t} else if (pctype == I40E_FILTER_PCTYPE_NONF_IPV6_TCP) {\n \t\ttcp = (struct tcp_hdr *)(raw_pkt + len);\n \t\tpayload = (unsigned char *)tcp + sizeof(struct tcp_hdr);\n \t\t/**\n@@ -1143,9 +1178,7 @@ i40e_flow_fdir_construct_pkt(struct i40e_pf *pf,\n \t\ttcp->data_off = I40E_FDIR_TCP_DEFAULT_DATAOFF;\n \t\ttcp->src_port = fdir_input->flow.udp6_flow.dst_port;\n \t\ttcp->dst_port = fdir_input->flow.udp6_flow.src_port;\n-\t\tbreak;\n-\n-\tcase I40E_FILTER_PCTYPE_NONF_IPV6_SCTP:\n+\t} else if (pctype == I40E_FILTER_PCTYPE_NONF_IPV6_SCTP) {\n \t\tsctp = (struct sctp_hdr *)(raw_pkt + len);\n \t\tpayload = (unsigned char *)sctp + sizeof(struct sctp_hdr);\n \t\t/**\n@@ -1156,14 +1189,11 @@ i40e_flow_fdir_construct_pkt(struct i40e_pf *pf,\n \t\tsctp->src_port = fdir_input->flow.sctp6_flow.dst_port;\n \t\tsctp->dst_port = fdir_input->flow.sctp6_flow.src_port;\n \t\tsctp->tag = fdir_input->flow.sctp6_flow.verify_tag;\n-\t\tbreak;\n-\n-\tcase I40E_FILTER_PCTYPE_NONF_IPV6_OTHER:\n-\tcase I40E_FILTER_PCTYPE_FRAG_IPV6:\n+\t} else if (pctype == I40E_FILTER_PCTYPE_NONF_IPV6_OTHER ||\n+\t\t   pctype == I40E_FILTER_PCTYPE_FRAG_IPV6) {\n \t\tpayload = raw_pkt + len;\n \t\tset_idx = I40E_FLXPLD_L3_IDX;\n-\t\tbreak;\n-\tcase I40E_FILTER_PCTYPE_L2_PAYLOAD:\n+\t} else if (pctype == I40E_FILTER_PCTYPE_L2_PAYLOAD) {\n \t\tpayload = raw_pkt + len;\n \t\t/**\n \t\t * ARP packet is a special case on which the payload\n@@ -1173,10 +1203,34 @@ i40e_flow_fdir_construct_pkt(struct i40e_pf *pf,\n \t\t\t\trte_cpu_to_be_16(ETHER_TYPE_ARP))\n \t\t\tpayload += sizeof(struct arp_hdr);\n \t\tset_idx = I40E_FLXPLD_L2_IDX;\n-\t\tbreak;\n-\tdefault:\n-\t\tPMD_DRV_LOG(ERR, \"unknown pctype %u.\", fdir_input->pctype);\n-\t\treturn -EINVAL;\n+\t} else if (pf->new_pctype_used) {\n+\t\tcus_pctype = i40e_flow_fdir_check_new_pctype(pf, pctype);\n+\t\tif (!memcmp(cus_pctype->name, \"GTPC\", sizeof(\"GTPC\")) ||\n+\t\t    !memcmp(cus_pctype->name, \"GTPU\", sizeof(\"GTPU\"))) {\n+\t\t\tudp = (struct udp_hdr *)(raw_pkt + len);\n+\t\t\tudp->dgram_len =\n+\t\t\t\trte_cpu_to_be_16(I40E_FDIR_UDP_DEFAULT_LEN);\n+\n+\t\t\tgtp = (struct rte_flow_item_gtp *)\n+\t\t\t\t((unsigned char *)udp + sizeof(struct udp_hdr));\n+\t\t\tgtp->v_pt_rsv_flags = 0x30;\n+\t\t\tgtp->msg_len =\n+\t\t\t\trte_cpu_to_be_16(I40E_FDIR_GTP_DEFAULT_LEN);\n+\t\t\tgtp->teid = fdir_input->flow.gtpv4_flow.teid;\n+\t\t\tgtp->msg_type = 0x1;\n+\n+\t\t\tif (!memcmp(cus_pctype->name, \"GTPC\", sizeof(\"GTPC\")))\n+\t\t\t\tudp->dst_port = rte_cpu_to_be_16(2123);\n+\t\t\telse\n+\t\t\t\tudp->dst_port = rte_cpu_to_be_16(2152);\n+\n+\t\t\tpayload = (unsigned char *)gtp +\n+\t\t\t\tsizeof(struct rte_flow_item_gtp);\n+\t\t}\n+\t} else {\n+\t\tPMD_DRV_LOG(ERR, \"unknown pctype %u.\",\n+\t\t\t    fdir_input->pctype);\n+\t\treturn -1;\n \t}\n \n \t/* fill the flexbytes to payload */\ndiff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c\nindex 73af7fd..6716855 100644\n--- a/drivers/net/i40e/i40e_flow.c\n+++ b/drivers/net/i40e/i40e_flow.c\n@@ -189,6 +189,22 @@ static enum rte_flow_item_type pattern_fdir_ipv4_sctp[] = {\n \tRTE_FLOW_ITEM_TYPE_END,\n };\n \n+static enum rte_flow_item_type pattern_fdir_ipv4_gtpc[] = {\n+\tRTE_FLOW_ITEM_TYPE_ETH,\n+\tRTE_FLOW_ITEM_TYPE_IPV4,\n+\tRTE_FLOW_ITEM_TYPE_UDP,\n+\tRTE_FLOW_ITEM_TYPE_GTPC,\n+\tRTE_FLOW_ITEM_TYPE_END,\n+};\n+\n+static enum rte_flow_item_type pattern_fdir_ipv4_gtpu[] = {\n+\tRTE_FLOW_ITEM_TYPE_ETH,\n+\tRTE_FLOW_ITEM_TYPE_IPV4,\n+\tRTE_FLOW_ITEM_TYPE_UDP,\n+\tRTE_FLOW_ITEM_TYPE_GTPU,\n+\tRTE_FLOW_ITEM_TYPE_END,\n+};\n+\n static enum rte_flow_item_type pattern_fdir_ipv6[] = {\n \tRTE_FLOW_ITEM_TYPE_ETH,\n \tRTE_FLOW_ITEM_TYPE_IPV6,\n@@ -216,6 +232,22 @@ static enum rte_flow_item_type pattern_fdir_ipv6_sctp[] = {\n \tRTE_FLOW_ITEM_TYPE_END,\n };\n \n+static enum rte_flow_item_type pattern_fdir_ipv6_gtpc[] = {\n+\tRTE_FLOW_ITEM_TYPE_ETH,\n+\tRTE_FLOW_ITEM_TYPE_IPV6,\n+\tRTE_FLOW_ITEM_TYPE_UDP,\n+\tRTE_FLOW_ITEM_TYPE_GTPC,\n+\tRTE_FLOW_ITEM_TYPE_END,\n+};\n+\n+static enum rte_flow_item_type pattern_fdir_ipv6_gtpu[] = {\n+\tRTE_FLOW_ITEM_TYPE_ETH,\n+\tRTE_FLOW_ITEM_TYPE_IPV6,\n+\tRTE_FLOW_ITEM_TYPE_UDP,\n+\tRTE_FLOW_ITEM_TYPE_GTPU,\n+\tRTE_FLOW_ITEM_TYPE_END,\n+};\n+\n static enum rte_flow_item_type pattern_fdir_ethertype_raw_1[] = {\n \tRTE_FLOW_ITEM_TYPE_ETH,\n \tRTE_FLOW_ITEM_TYPE_RAW,\n@@ -1576,10 +1608,14 @@ static struct i40e_valid_pattern i40e_supported_patterns[] = {\n \t{ pattern_fdir_ipv4_udp, i40e_flow_parse_fdir_filter },\n \t{ pattern_fdir_ipv4_tcp, i40e_flow_parse_fdir_filter },\n \t{ pattern_fdir_ipv4_sctp, i40e_flow_parse_fdir_filter },\n+\t{ pattern_fdir_ipv4_gtpc, i40e_flow_parse_fdir_filter },\n+\t{ pattern_fdir_ipv4_gtpu, i40e_flow_parse_fdir_filter },\n \t{ pattern_fdir_ipv6, i40e_flow_parse_fdir_filter },\n \t{ pattern_fdir_ipv6_udp, i40e_flow_parse_fdir_filter },\n \t{ pattern_fdir_ipv6_tcp, i40e_flow_parse_fdir_filter },\n \t{ pattern_fdir_ipv6_sctp, i40e_flow_parse_fdir_filter },\n+\t{ pattern_fdir_ipv6_gtpc, i40e_flow_parse_fdir_filter },\n+\t{ pattern_fdir_ipv6_gtpu, i40e_flow_parse_fdir_filter },\n \t/* FDIR - support default flow type with flexible payload */\n \t{ pattern_fdir_ethertype_raw_1, i40e_flow_parse_fdir_filter },\n \t{ pattern_fdir_ethertype_raw_2, i40e_flow_parse_fdir_filter },\n@@ -2302,6 +2338,32 @@ i40e_flow_set_fdir_inset(struct i40e_pf *pf,\n \treturn 0;\n }\n \n+static int\n+i40e_flow_find_new_pctype(struct i40e_pf *pf,\n+\t\t\t  enum rte_flow_item_type item_type)\n+{\n+\tstruct i40e_personalized_pctype *cus_pctype;\n+\n+\tswitch (item_type) {\n+\tcase RTE_FLOW_ITEM_TYPE_GTPC:\n+\t\tcus_pctype = i40e_find_personalized_pctype(pf,\n+\t\t\t\t\t\t   I40E_PERSONALIZED_GTPC);\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_GTPU:\n+\t\tcus_pctype = i40e_find_personalized_pctype(pf,\n+\t\t\t\t\t\t   I40E_PERSONALIZED_GTPU);\n+\t\tbreak;\n+\tdefault:\n+\t\tPMD_DRV_LOG(ERR, \"Unsupported item type\");\n+\t\tbreak;\n+\t}\n+\n+\tif (cus_pctype)\n+\t\treturn cus_pctype->pctype;\n+\n+\treturn I40E_INVALID_PCTYPE;\n+}\n+\n /* 1. Last in item should be NULL as range is not supported.\n  * 2. Supported patterns: refer to array i40e_supported_patterns.\n  * 3. Supported flow type and input set: refer to array\n@@ -2326,10 +2388,11 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,\n \tconst struct rte_flow_item_tcp *tcp_spec, *tcp_mask;\n \tconst struct rte_flow_item_udp *udp_spec, *udp_mask;\n \tconst struct rte_flow_item_sctp *sctp_spec, *sctp_mask;\n+\tconst struct rte_flow_item_gtp *gtp_spec, *gtp_mask;\n \tconst struct rte_flow_item_raw *raw_spec, *raw_mask;\n \tconst struct rte_flow_item_vf *vf_spec;\n \n-\tenum i40e_filter_pctype pctype = 0;\n+\tint pctype = 0;\n \tuint64_t input_set = I40E_INSET_NONE;\n \tuint16_t frag_off;\n \tenum rte_flow_item_type item_type;\n@@ -2636,6 +2699,38 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,\n \t\t\tlayer_idx = I40E_FLXPLD_L4_IDX;\n \n \t\t\tbreak;\n+\t\tcase RTE_FLOW_ITEM_TYPE_GTPC:\n+\t\tcase RTE_FLOW_ITEM_TYPE_GTPU:\n+\t\t\tgtp_spec = (const struct rte_flow_item_gtp *)item->spec;\n+\t\t\tgtp_mask = (const struct rte_flow_item_gtp *)item->mask;\n+\n+\t\t\tpctype = i40e_flow_find_new_pctype(pf, item_type);\n+\t\t\tif (pctype == I40E_INVALID_PCTYPE) {\n+\t\t\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\t\t\t   RTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\t\t\t\t   item,\n+\t\t\t\t\t\t   \"Unsupported protocol\");\n+\t\t\t\treturn -rte_errno;\n+\t\t\t}\n+\n+\t\t\tif (gtp_spec && gtp_mask) {\n+\t\t\t\tif (gtp_mask->v_pt_rsv_flags ||\n+\t\t\t\t    gtp_mask->msg_type ||\n+\t\t\t\t    gtp_mask->msg_len ||\n+\t\t\t\t    gtp_mask->teid != UINT32_MAX) {\n+\t\t\t\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\t\t\t   RTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\t\t\t\t   item,\n+\t\t\t\t\t\t   \"Invalid GTP mask\");\n+\t\t\t\t\treturn -rte_errno;\n+\t\t\t\t}\n+\n+\t\t\t\tpf->new_pctype_used = true;\n+\t\t\t\tinput_set |= I40E_INSET_GTP_TEID;\n+\t\t\t\tfilter->input.flow.gtpv4_flow.teid =\n+\t\t\t\t\tgtp_spec->teid;\n+\t\t\t}\n+\t\t\tbreak;\n \t\tcase RTE_FLOW_ITEM_TYPE_SCTP:\n \t\t\tsctp_spec =\n \t\t\t\t(const struct rte_flow_item_sctp *)item->spec;\n@@ -2774,43 +2869,45 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,\n \t\t}\n \t}\n \n-\tret = i40e_flow_set_fdir_inset(pf, pctype, input_set);\n-\tif (ret == -1) {\n-\t\trte_flow_error_set(error, EINVAL,\n-\t\t\t\t   RTE_FLOW_ERROR_TYPE_ITEM, item,\n-\t\t\t\t   \"Conflict with the first rule's input set.\");\n-\t\treturn -rte_errno;\n-\t} else if (ret == -EINVAL) {\n-\t\trte_flow_error_set(error, EINVAL,\n-\t\t\t\t   RTE_FLOW_ERROR_TYPE_ITEM, item,\n-\t\t\t\t   \"Invalid pattern mask.\");\n-\t\treturn -rte_errno;\n-\t}\n+\tif (!pf->new_pctype_used) {\n+\t\tret = i40e_flow_set_fdir_inset(pf, pctype, input_set);\n+\t\tif (ret == -1) {\n+\t\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\t\t   RTE_FLOW_ERROR_TYPE_ITEM, item,\n+\t\t\t\t\t   \"Conflict with the first rule's input set.\");\n+\t\t\treturn -rte_errno;\n+\t\t} else if (ret == -EINVAL) {\n+\t\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\t\t   RTE_FLOW_ERROR_TYPE_ITEM, item,\n+\t\t\t\t\t   \"Invalid pattern mask.\");\n+\t\t\treturn -rte_errno;\n+\t\t}\n \n-\tfilter->input.pctype = pctype;\n+\t\t/* Store flex mask to SW */\n+\t\tret = i40e_flow_store_flex_mask(pf, pctype, flex_mask);\n+\t\tif (ret == -1) {\n+\t\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\t\t   RTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\t\t\t   item,\n+\t\t\t\t\t   \"Exceed maximal number of bitmasks\");\n+\t\t\treturn -rte_errno;\n+\t\t} else if (ret == -2) {\n+\t\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\t\t   RTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\t\t\t   item,\n+\t\t\t\t\t   \"Conflict with the first flexible rule\");\n+\t\t\treturn -rte_errno;\n+\t\t} else if (ret > 0)\n+\t\t\tcfg_flex_msk = false;\n \n-\t/* Store flex mask to SW */\n-\tret = i40e_flow_store_flex_mask(pf, pctype, flex_mask);\n-\tif (ret == -1) {\n-\t\trte_flow_error_set(error, EINVAL,\n-\t\t\t\t   RTE_FLOW_ERROR_TYPE_ITEM,\n-\t\t\t\t   item,\n-\t\t\t\t   \"Exceed maximal number of bitmasks\");\n-\t\treturn -rte_errno;\n-\t} else if (ret == -2) {\n-\t\trte_flow_error_set(error, EINVAL,\n-\t\t\t\t   RTE_FLOW_ERROR_TYPE_ITEM,\n-\t\t\t\t   item,\n-\t\t\t\t   \"Conflict with the first flexible rule\");\n-\t\treturn -rte_errno;\n-\t} else if (ret > 0)\n-\t\tcfg_flex_msk = false;\n+\t\tif (cfg_flex_pit)\n+\t\t\ti40e_flow_set_fdir_flex_pit(pf, layer_idx, raw_id);\n \n-\tif (cfg_flex_pit)\n-\t\ti40e_flow_set_fdir_flex_pit(pf, layer_idx, raw_id);\n+\t\tif (cfg_flex_msk)\n+\t\t\ti40e_flow_set_fdir_flex_msk(pf, pctype);\n+\t}\n \n-\tif (cfg_flex_msk)\n-\t\ti40e_flow_set_fdir_flex_msk(pf, pctype);\n+\tfilter->input.pctype = pctype;\n \n \treturn 0;\n }\n",
    "prefixes": [
        "dpdk-dev",
        "v2",
        "4/6"
    ]
}