Show a patch.

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

{
    "id": 146,
    "url": "https://patches.dpdk.org/api/patches/146/",
    "web_url": "https://patches.dpdk.org/patch/146/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/",
        "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"
    },
    "msgid": "<1407813127-10991-3-git-send-email-jijiang.liu@intel.com>",
    "date": "2014-08-12T03:12:03",
    "name": "[dpdk-dev,2/6] app/test-pmd:test vxlan packet identification",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "8807d9ec1ce4748ce98de32dd6352bf5f966edc7",
    "submitter": {
        "id": 52,
        "url": "https://patches.dpdk.org/api/people/52/",
        "name": "Jijiang Liu",
        "email": "jijiang.liu@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/patch/146/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/146/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/146/checks/",
    "tags": {},
    "headers": {
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Date": "Tue, 12 Aug 2014 11:12:03 +0800",
        "In-Reply-To": "<1407813127-10991-1-git-send-email-jijiang.liu@intel.com>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "X-BeenThere": "dev@dpdk.org",
        "References": "<1407813127-10991-1-git-send-email-jijiang.liu@intel.com>",
        "X-Mailer": "git-send-email 1.7.0.7",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "To": "dev@dpdk.org",
        "Received": [
            "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n\tby dpdk.org (Postfix) with ESMTP id 35653B397\n\tfor <dev@dpdk.org>; Tue, 12 Aug 2014 05:09:33 +0200 (CEST)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby fmsmga103.fm.intel.com with ESMTP; 11 Aug 2014 20:05:02 -0700",
            "from shvmail01.sh.intel.com ([10.239.29.42])\n\tby fmsmga001.fm.intel.com with ESMTP; 11 Aug 2014 20:12:24 -0700",
            "from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com\n\t[10.239.29.89])\n\tby shvmail01.sh.intel.com with ESMTP id s7C3CMMW012541;\n\tTue, 12 Aug 2014 11:12:22 +0800",
            "from shecgisg004.sh.intel.com (localhost [127.0.0.1])\n\tby shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP\n\tid s7C3CJ9D011117; Tue, 12 Aug 2014 11:12:21 +0800",
            "(from jijiangl@localhost)\n\tby shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s7C3CJJE011113; \n\tTue, 12 Aug 2014 11:12:19 +0800"
        ],
        "From": "Jijiang Liu <jijiang.liu@intel.com>",
        "Precedence": "list",
        "X-ExtLoop1": "1",
        "Message-Id": "<1407813127-10991-3-git-send-email-jijiang.liu@intel.com>",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "Subject": "[dpdk-dev] [PATCH 2/6]app/test-pmd:test vxlan packet identification",
        "X-List-Received-Date": "Tue, 12 Aug 2014 03:09:34 -0000",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "Return-Path": "<jijiangl@shecgisg004.sh.intel.com>",
        "X-IronPort-AV": "E=Sophos;i=\"5.01,846,1400050800\"; d=\"scan'208\";a=\"575329708\"",
        "List-Post": "<mailto:dev@dpdk.org>",
        "X-Mailman-Version": "2.1.15"
    },
    "content": "Add commands to test receive vxlan packet identification, which include\n - use command to add/delete VxLAN UDP port.\n - use rxonly mode to receive VxLAN packet.\n\nSigned-off-by: jijiangl <jijiang.liu@intel.com>\nAcked-by: Helin Zhang <helin.zhang@intel.com>\nAcked-by: Jingjing Wu <jingjing.wu@intel.com>\nAcked-by: Jing Chen <jing.d.chen@intel.com>\n---\n app/test-pmd/cmdline.c    |   78 ++++++++++++++++++++++++++++++++++++++++++--\n app/test-pmd/parameters.c |   13 +++++++\n app/test-pmd/rxonly.c     |   49 ++++++++++++++++++++++++++++\n app/test-pmd/testpmd.c    |    8 +++++\n app/test-pmd/testpmd.h    |    9 +++++\n 5 files changed, 153 insertions(+), 4 deletions(-)",
    "diff": "diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c\nindex 345be11..67cf63e 100644\n--- a/app/test-pmd/cmdline.c\n+++ b/app/test-pmd/cmdline.c\n@@ -285,6 +285,12 @@ static void cmd_help_long_parsed(void *parsed_result,\n \t\t\t\"    Set the outer VLAN TPID for Packet Filtering on\"\n \t\t\t\" a port\\n\\n\"\n \n+\t\t\t\"rx_vxlan_port add (udp_port) (port_id)\\n\"\n+\t\t\t\"    Add an UDP port for VxLAN packet filter on a port\\n\\n\"\n+\n+\t\t\t\"rx_vxlan_port rm (udp_port) (port_id)\\n\"\n+\t\t\t\"    Remove an UDP port for VxLAN packet filter on a port\\n\\n\"\n+\n \t\t\t\"tx_vlan set vlan_id (port_id)\\n\"\n \t\t\t\"    Set hardware insertion of VLAN ID in packets sent\"\n \t\t\t\" on a port.\\n\\n\"\n@@ -296,13 +302,17 @@ static void cmd_help_long_parsed(void *parsed_result,\n \t\t\t\"    Disable hardware insertion of a VLAN header in\"\n \t\t\t\" packets sent on a port.\\n\\n\"\n \n-\t\t\t\"tx_checksum set mask (port_id)\\n\"\n+\t\t\t\"tx_checksum set (mask) (port_id)\\n\"\n \t\t\t\"    Enable hardware insertion of checksum offload with\"\n-\t\t\t\" the 4-bit mask, 0~0xf, in packets sent on a port.\\n\"\n+\t\t\t\" the 8-bit mask, 0~0xff, in packets sent on a port.\\n\"\n \t\t\t\"        bit 0 - insert ip   checksum offload if set\\n\"\n \t\t\t\"        bit 1 - insert udp  checksum offload if set\\n\"\n \t\t\t\"        bit 2 - insert tcp  checksum offload if set\\n\"\n \t\t\t\"        bit 3 - insert sctp checksum offload if set\\n\"\n+\t\t\t\"        bit 4 - insert inner ip  checksum offload if set\\n\"\n+\t\t\t\"        bit 5 - insert inner udp checksum offload if set\\n\"\n+\t\t\t\"        bit 6 - insert inner tcp checksum offload if set\\n\"\n+\t\t\t\"        bit 7 - insert inner sctp checksum offload if set\\n\"\n \t\t\t\"    Please check the NIC datasheet for HW limits.\\n\\n\"\n \n \t\t\t\"set fwd (%s)\\n\"\n@@ -2646,8 +2656,9 @@ cmdline_parse_inst_t cmd_tx_cksum_set = {\n \t.f = cmd_tx_cksum_set_parsed,\n \t.data = NULL,\n \t.help_str = \"enable hardware insertion of L3/L4checksum with a given \"\n-\t\"mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip\"\n-\t\"Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP\",\n+\t\"mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip \"\n+\t\"Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP, Bit 4 for inner ip \"\n+\t\"Bit 5 for inner UDP, Bit 6 for inner TCP, Bit 7 for inner SCTP\",\n \t.tokens = {\n \t\t(void *)&cmd_tx_cksum_set_tx_cksum,\n \t\t(void *)&cmd_tx_cksum_set_set,\n@@ -6112,6 +6123,64 @@ cmdline_parse_inst_t cmd_vf_rate_limit = {\n \t},\n };\n \n+/* *** CONFIGURE TUNNEL UDP PORT *** */\n+struct cmd_tunnel_udp_config {\n+\tcmdline_fixed_string_t cmd;\n+\tcmdline_fixed_string_t what;\n+\tuint16_t udp_port;\n+\tuint8_t port_id;\n+};\n+\n+static void\n+cmd_tunnel_udp_config_parsed(void *parsed_result,\n+\t\t\t  __attribute__((unused)) struct cmdline *cl,\n+\t\t\t  __attribute__((unused)) void *data)\n+{\n+\tstruct cmd_tunnel_udp_config *res = parsed_result;\n+\tstruct rte_eth_udp_tunnel tunnel_udp;\n+\tint ret;\n+\n+\ttunnel_udp.udp_port = res->udp_port;\n+\n+\tif (!strcmp(res->cmd, \"rx_vxlan_port\"))\n+\t\ttunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;\n+\n+\tif (!strcmp(res->what, \"add\"))\n+\t\tret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp, 1);\n+\telse\n+\t\tret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp, 1);\n+\n+\tif (ret < 0)\n+\t\tprintf(\"udp tunneling add error: (%s)\\n\", strerror(-ret));\n+}\n+\n+cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,\n+\t\t\t\tcmd, \"rx_vxlan_port\");\n+cmdline_parse_token_string_t cmd_tunnel_udp_config_what =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,\n+\t\t\t\twhat, \"add#rm\");\n+cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =\n+\tTOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,\n+\t\t\t\tudp_port, UINT16);\n+cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =\n+\tTOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,\n+\t\t\t\tport_id, UINT8);\n+\n+cmdline_parse_inst_t cmd_tunnel_udp_config = {\n+\t.f = cmd_tunnel_udp_config_parsed,\n+\t.data = (void *)0,\n+\t.help_str = \"add/rm an UDP tunneling port filter: \"\n+\t\t\t\"rx_vxlan_port add udp_port port_id\",\n+\t.tokens = {\n+\t\t(void *)&cmd_tunnel_udp_config_cmd,\n+\t\t(void *)&cmd_tunnel_udp_config_what,\n+\t\t(void *)&cmd_tunnel_udp_config_udp_port,\n+\t\t(void *)&cmd_tunnel_udp_config_port_id,\n+\t\tNULL,\n+\t},\n+};\n+\n /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */\n struct cmd_set_mirror_mask_result {\n \tcmdline_fixed_string_t set;\n@@ -7406,6 +7475,7 @@ cmdline_parse_ctx_t main_ctx[] = {\n \t(cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,\n \t(cmdline_parse_inst_t *)&cmd_queue_rate_limit,\n \t(cmdline_parse_inst_t *)&cmd_vf_rate_limit,\n+\t(cmdline_parse_inst_t *)&cmd_tunnel_udp_config,\n \t(cmdline_parse_inst_t *)&cmd_set_mirror_mask,\n \t(cmdline_parse_inst_t *)&cmd_set_mirror_link,\n \t(cmdline_parse_inst_t *)&cmd_reset_mirror_rule,\ndiff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c\nindex 9573a43..fda8c1d 100644\n--- a/app/test-pmd/parameters.c\n+++ b/app/test-pmd/parameters.c\n@@ -202,6 +202,10 @@ usage(char* progname)\n \tprintf(\"  --txpkts=X[,Y]*: set TX segment sizes.\\n\");\n \tprintf(\"  --disable-link-check: disable check on link status when \"\n \t       \"starting/stopping ports.\\n\");\n+\tprintf(\"  --tunnel-type=N: set tunneling packet type \"\n+\t       \"(0 <= N <= 4).(0:non-tunneling packet;1:VxLAN; \"\n+\t       \"2:GENEVE;3: TEREDO;4: NVGRE)\\n\");\n+\n }\n \n #ifdef RTE_LIBRTE_CMDLINE\n@@ -600,6 +604,7 @@ launch_args_parse(int argc, char** argv)\n \t\t{ \"no-flush-rx\",\t0, 0, 0 },\n \t\t{ \"txpkts\",\t\t\t1, 0, 0 },\n \t\t{ \"disable-link-check\",\t\t0, 0, 0 },\n+\t\t{ \"tunnel-type\",                1, 0, 0 },\n \t\t{ 0, 0, 0, 0 },\n \t};\n \n@@ -1032,6 +1037,14 @@ launch_args_parse(int argc, char** argv)\n \t\t\t\telse\n \t\t\t\t\trte_exit(EXIT_FAILURE, \"rxfreet must be >= 0\\n\");\n \t\t\t}\n+\t\t\tif (!strcmp(lgopts[opt_idx].name, \"tunnel-type\")) {\n+\t\t\t\tn = atoi(optarg);\n+\t\t\t\tif ((n >= 0) && (n < RTE_TUNNEL_TYPE_MAX))\n+\t\t\t\t\trx_tunnel_type = (uint16_t)n;\n+\t\t\t\telse\n+\t\t\t\t\trte_exit(EXIT_FAILURE, \"tunnel-type must be 0-%d\\n\",\n+\t\t\t\t\t\tRTE_TUNNEL_TYPE_MAX);\n+\t\t\t}\n \t\t\tif (!strcmp(lgopts[opt_idx].name, \"tx-queue-stats-mapping\")) {\n \t\t\t\tif (parse_queue_stats_mapping_config(optarg, TX)) {\n \t\t\t\t\trte_exit(EXIT_FAILURE,\ndiff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c\nindex 5f21a3e..4f529f6 100644\n--- a/app/test-pmd/rxonly.c\n+++ b/app/test-pmd/rxonly.c\n@@ -66,6 +66,8 @@\n #include <rte_ether.h>\n #include <rte_ethdev.h>\n #include <rte_string_fns.h>\n+#include <rte_ip.h>\n+#include <rte_udp.h>\n \n #include \"testpmd.h\"\n \n@@ -112,6 +114,9 @@ pkt_burst_receive(struct fwd_stream *fs)\n \tuint16_t ol_flags;\n \tuint16_t nb_rx;\n \tuint16_t i;\n+\tuint8_t ptype;\n+\tuint8_t is_encapsulation;\n+\n #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES\n \tuint64_t start_tsc;\n \tuint64_t end_tsc;\n@@ -152,6 +157,11 @@ pkt_burst_receive(struct fwd_stream *fs)\n \t\teth_hdr = (struct ether_hdr *) mb->pkt.data;\n \t\teth_type = RTE_BE_TO_CPU_16(eth_hdr->ether_type);\n \t\tol_flags = mb->ol_flags;\n+\t\tptype = mb->reserved;\n+\n+\t\tis_encapsulation = IS_ETH_IPV4_TUNNEL(ptype) |\n+\t\t\t\t\tIS_ETH_IPV6_TUNNEL(ptype);\n+\n \t\tprint_ether_addr(\"  src=\", &eth_hdr->s_addr);\n \t\tprint_ether_addr(\" - dst=\", &eth_hdr->d_addr);\n \t\tprintf(\" - type=0x%04x - length=%u - nb_segs=%d\",\n@@ -167,6 +177,45 @@ pkt_burst_receive(struct fwd_stream *fs)\n \t\tif (ol_flags & PKT_RX_VLAN_PKT)\n \t\t\tprintf(\" - VLAN tci=0x%x\",\n \t\t\t\tmb->pkt.vlan_macip.f.vlan_tci);\n+\t\tif (is_encapsulation) {\n+\t\t\tstruct ipv4_hdr *ipv4_hdr;\n+\t\t\tstruct ipv6_hdr *ipv6_hdr;\n+\t\t\tstruct udp_hdr *udp_hdr;\n+\t\t\tuint8_t l2_len;\n+\t\t\tuint8_t l3_len;\n+\t\t\tuint8_t l4_len;\n+\t\t\tuint8_t l4_proto;\n+\t\t\tstruct  vxlan_hdr *vxlan_hdr;\n+\n+\t\t\tl2_len  = sizeof(struct ether_hdr);\n+\n+\t\t\t /* Do not support ipv4 option field */\n+\t\t\tif (IS_ETH_IPV4_TUNNEL(ptype)) {\n+\t\t\t\tl3_len = sizeof(struct ipv4_hdr);\n+\t\t\t\tipv4_hdr = (struct ipv4_hdr *) (rte_pktmbuf_mtod(mb,\n+\t\t\t\t\t\tunsigned char *) + l2_len);\n+\t\t\t\tl4_proto = ipv4_hdr->next_proto_id;\n+\t\t\t} else {\n+\t\t\t\tl3_len = sizeof(struct ipv6_hdr);\n+\t\t\t\tipv6_hdr = (struct ipv6_hdr *) (rte_pktmbuf_mtod(mb,\n+\t\t\t\t\t\tunsigned char *) + l2_len);\n+\t\t\t\tl4_proto = ipv6_hdr->proto;\n+\t\t\t}\n+\t\t\tif (l4_proto == IPPROTO_UDP) {\n+\t\t\t\tudp_hdr = (struct udp_hdr *) (rte_pktmbuf_mtod(mb,\n+\t\t\t\t\t\tunsigned char *) + l2_len + l3_len);\n+\t\t\t\tl4_len = sizeof(struct udp_hdr);\n+\t\t\t\tvxlan_hdr = (struct vxlan_hdr *) (rte_pktmbuf_mtod(mb,\n+\t\t\t\t\t\tunsigned char *) + l2_len + l3_len\n+\t\t\t\t\t\t + l4_len);\n+\n+\t\t\t\tprintf(\" - VxLAN packet: packet type =%d, \"\n+\t\t\t\t\t\"Destination UDP port =%d, VNI = %d\",\n+\t\t\t\t\tptype, RTE_BE_TO_CPU_16(udp_hdr->dst_port),\n+\t\t\t\t\trte_be_to_cpu_32(vxlan_hdr->vx_vni) >> 8);\n+\t\t\t}\n+\t\t}\n+\t\tprintf(\" - Receive queue=0x%x\", (unsigned) fs->rx_queue);\n \t\tprintf(\"\\n\");\n \t\tif (ol_flags != 0) {\n \t\t\tint rxf;\ndiff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c\nindex e8a4b45..daa8f41 100644\n--- a/app/test-pmd/testpmd.c\n+++ b/app/test-pmd/testpmd.c\n@@ -243,6 +243,12 @@ uint16_t tx_free_thresh = 0; /* Use default values. */\n uint16_t tx_rs_thresh = 0; /* Use default values. */\n \n /*\n+ * Configurable value of tunnel type.\n+ */\n+\n+uint8_t rx_tunnel_type = 0; /* Use default values. */\n+\n+/*\n  * Configurable value of TX queue flags.\n  */\n uint32_t txq_flags = 0; /* No flags set. */\n@@ -1676,6 +1682,8 @@ init_port_config(void)\n \t\tport = &ports[pid];\n \t\tport->dev_conf.rxmode = rx_mode;\n \t\tport->dev_conf.fdir_conf = fdir_conf;\n+\t\tif (rx_tunnel_type == 1)\n+\t\t\tport->dev_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;\n \t\tif (nb_rxq > 1) {\n \t\t\tport->dev_conf.rx_adv_conf.rss_conf.rss_key = NULL;\n \t\t\tport->dev_conf.rx_adv_conf.rss_conf.rss_hf = rss_hf;\ndiff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h\nindex ac86bfe..a304c47 100644\n--- a/app/test-pmd/testpmd.h\n+++ b/app/test-pmd/testpmd.h\n@@ -80,6 +80,10 @@ typedef uint16_t streamid_t;\n \n #define MAX_QUEUE_ID ((1 << (sizeof(queueid_t) * 8)) - 1)\n \n+/* For FVL NIC */\n+#define IS_ETH_IPV4_TUNNEL(ptype) ((ptype > 58) && (ptype < 87))\n+#define IS_ETH_IPV6_TUNNEL(ptype) ((ptype > 124) && (ptype < 153))\n+\n enum {\n \tPORT_TOPOLOGY_PAIRED,\n \tPORT_TOPOLOGY_CHAINED,\n@@ -130,6 +134,10 @@ struct fwd_stream {\n  *   Bit  1: Insert UDP checksum\n  *   Bit  2: Insert TCP checksum\n  *   Bit  3: Insert SCTP checksum\n+ *   Bit  4: Insert inner IP checksum\n+ *   Bit  5: Insert inner UDP checksum\n+ *   Bit  6: Insert inner TCP checksum\n+ *   Bit  7: Insert inner SCTP checksum\n  *   Bit 11: Insert VLAN Label\n  */\n struct rte_port {\n@@ -342,6 +350,7 @@ extern uint8_t rx_drop_en;\n extern uint16_t tx_free_thresh;\n extern uint16_t tx_rs_thresh;\n extern uint32_t txq_flags;\n+extern uint8_t rx_tunnel_type;\n \n extern uint8_t dcb_config;\n extern uint8_t dcb_test;\n",
    "prefixes": [
        "dpdk-dev",
        "2/6"
    ]
}