get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 5662,
    "url": "http://patches.dpdk.org/api/patches/5662/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1434991265-20384-8-git-send-email-jijiang.liu@intel.com/",
    "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": "<1434991265-20384-8-git-send-email-jijiang.liu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1434991265-20384-8-git-send-email-jijiang.liu@intel.com",
    "date": "2015-06-22T16:41:02",
    "name": "[dpdk-dev,v5,07/10] examples/tep_termination:add Tx checksum offload configuration for inner header",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "668f74ece101c417ac05087659313a6c5fefd006",
    "submitter": {
        "id": 52,
        "url": "http://patches.dpdk.org/api/people/52/?format=api",
        "name": "Jijiang Liu",
        "email": "jijiang.liu@intel.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1434991265-20384-8-git-send-email-jijiang.liu@intel.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/5662/comments/",
    "check": "pending",
    "checks": "http://patches.dpdk.org/api/patches/5662/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 F252EC7E6;\n\tMon, 22 Jun 2015 18:41:37 +0200 (CEST)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby dpdk.org (Postfix) with ESMTP id ED088C752\n\tfor <dev@dpdk.org>; Mon, 22 Jun 2015 18:41:30 +0200 (CEST)",
            "from orsmga002.jf.intel.com ([10.7.209.21])\n\tby orsmga101.jf.intel.com with ESMTP; 22 Jun 2015 09:41:29 -0700",
            "from shvmail01.sh.intel.com ([10.239.29.42])\n\tby orsmga002.jf.intel.com with ESMTP; 22 Jun 2015 09:41:29 -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 t5MGfR60005620;\n\tTue, 23 Jun 2015 00:41:27 +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 t5MGfOBT020470; Tue, 23 Jun 2015 00:41:26 +0800",
            "(from jijiangl@localhost)\n\tby shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t5MGfNBE020466; \n\tTue, 23 Jun 2015 00:41:23 +0800"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.13,660,1427785200\"; d=\"scan'208\";a=\"751181276\"",
        "From": "Jijiang Liu <jijiang.liu@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Tue, 23 Jun 2015 00:41:02 +0800",
        "Message-Id": "<1434991265-20384-8-git-send-email-jijiang.liu@intel.com>",
        "X-Mailer": "git-send-email 1.7.12.2",
        "In-Reply-To": "<1434991265-20384-1-git-send-email-jijiang.liu@intel.com>",
        "References": "<1434991265-20384-1-git-send-email-jijiang.liu@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v5 07/10] examples/tep_termination:add Tx\n\tchecksum offload configuration for inner header",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "patches and discussions about DPDK <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": "Add Tx checksum offload configuration for inner header.\n\nFor UDP tunneling packet, the inner Tx checksum offload means\ninner IPv4 and inner L4(TCP/UDP/SCTP).\n\nSigned-off-by: Jijiang Liu <jijiang.liu@intel.com>\n---\n examples/tep_termination/main.c  |   19 +++++++++\n examples/tep_termination/vxlan.c |   81 ++++++++++++++++++++++++++++++++++++++\n examples/tep_termination/vxlan.h |    1 +\n 3 files changed, 101 insertions(+), 0 deletions(-)",
    "diff": "diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c\nindex 4119d30..2c3bc9d 100644\n--- a/examples/tep_termination/main.c\n+++ b/examples/tep_termination/main.c\n@@ -113,6 +113,7 @@\n \n #define CMD_LINE_OPT_NB_DEVICES \"nb-devices\"\n #define CMD_LINE_OPT_UDP_PORT \"udp-port\"\n+#define CMD_LINE_OPT_TX_CHECKSUM \"tx-checksum\"\n #define CMD_LINE_OPT_FILTER_TYPE \"filter-type\"\n #define CMD_LINE_OPT_RX_RETRY \"rx-retry\"\n #define CMD_LINE_OPT_RX_RETRY_DELAY \"rx-retry-delay\"\n@@ -141,6 +142,9 @@ struct vpool {\n /* UDP tunneling port */\n uint16_t udp_port;\n \n+/* enable/disable inner TX checksum */\n+uint8_t tx_checksum = 0;\n+\n /* RX filter type for tunneling packet */\n uint8_t filter_idx = 1;\n \n@@ -270,6 +274,7 @@ tep_termination_usage(const char *prgname)\n \tRTE_LOG(INFO, VHOST_CONFIG, \"%s [EAL options] -- -p PORTMASK\\n\"\n \t\"               --udp-port: UDP destination port for VXLAN packet\\n\"\n \t\"\t\t--nb-devices[1-64]: The number of virtIO device\\n\"\n+\t\"               --tx-checksum [0|1]: inner Tx checksum offload\\n\"\n \t\"               --filter-type[1-3]: filter type for tunneling packet\\n\"\n \t\"                   1: Inner MAC and tenent ID\\n\"\n \t\"                   2: Inner MAC and VLAN, and tenent ID\\n\"\n@@ -299,6 +304,7 @@ tep_termination_parse_args(int argc, char **argv)\n \tstatic struct option long_option[] = {\n \t\t{CMD_LINE_OPT_NB_DEVICES, required_argument, NULL, 0},\n \t\t{CMD_LINE_OPT_UDP_PORT, required_argument, NULL, 0},\n+\t\t{CMD_LINE_OPT_TX_CHECKSUM, required_argument, NULL, 0},\n \t\t{CMD_LINE_OPT_FILTER_TYPE, required_argument, NULL, 0},\n \t\t{CMD_LINE_OPT_RX_RETRY, required_argument, NULL, 0},\n \t\t{CMD_LINE_OPT_RX_RETRY_DELAY, required_argument, NULL, 0},\n@@ -393,6 +399,19 @@ tep_termination_parse_args(int argc, char **argv)\n \t\t\t}\n \n \t\t\tif (!strncmp(long_option[option_index].name,\n+\t\t\t\tCMD_LINE_OPT_TX_CHECKSUM,\n+\t\t\t\tsizeof(CMD_LINE_OPT_TX_CHECKSUM))) {\n+\t\t\t\tret = parse_num_opt(optarg, 1);\n+\t\t\t\tif (ret == -1) {\n+\t\t\t\t\tRTE_LOG(INFO, VHOST_CONFIG,\n+\t\t\t\t\t\t\"Invalid argument for tx-checksum [0|1]\\n\");\n+\t\t\t\t\ttep_termination_usage(prgname);\n+\t\t\t\t\treturn -1;\n+\t\t\t\t} else\n+\t\t\t\t\ttx_checksum = ret;\n+\t\t\t}\n+\n+\t\t\tif (!strncmp(long_option[option_index].name,\n \t\t\t\t\tCMD_LINE_OPT_FILTER_TYPE,\n \t\t\t\t\tsizeof(CMD_LINE_OPT_FILTER_TYPE))) {\n \t\t\t\tret = parse_num_opt(optarg, 3);\ndiff --git a/examples/tep_termination/vxlan.c b/examples/tep_termination/vxlan.c\nindex 2f143ac..34851d8 100644\n--- a/examples/tep_termination/vxlan.c\n+++ b/examples/tep_termination/vxlan.c\n@@ -41,6 +41,15 @@\n #include \"main.h\"\n #include \"vxlan.h\"\n \n+static uint16_t\n+get_psd_sum(void *l3_hdr, uint16_t ethertype, uint64_t ol_flags)\n+{\n+\tif (ethertype == ETHER_TYPE_IPv4)\n+\t\treturn rte_ipv4_phdr_cksum(l3_hdr, ol_flags);\n+\telse /* assume ethertype == ETHER_TYPE_IPv6 */\n+\t\treturn rte_ipv6_phdr_cksum(l3_hdr, ol_flags);\n+}\n+\n /**\n  * Parse an ethernet header to fill the ethertype, outer_l2_len, outer_l3_len and\n  * ipproto. This function is able to recognize IPv4/IPv6 with one optional vlan\n@@ -83,6 +92,68 @@ parse_ethernet(struct ether_hdr *eth_hdr, union tunnel_offload_info *info,\n \t}\n }\n \n+/**\n+ * Calculate the checksum of a packet in hardware\n+ */\n+static uint64_t\n+process_inner_cksums(struct ether_hdr *eth_hdr, union tunnel_offload_info *info)\n+{\n+\tvoid *l3_hdr = NULL;\n+\tuint8_t l4_proto;\n+\tuint16_t ethertype;\n+\tstruct ipv4_hdr *ipv4_hdr;\n+\tstruct ipv6_hdr *ipv6_hdr;\n+\tstruct udp_hdr *udp_hdr;\n+\tstruct tcp_hdr *tcp_hdr;\n+\tstruct sctp_hdr *sctp_hdr;\n+\tuint64_t ol_flags = 0;\n+\n+\tinfo->l2_len = sizeof(struct ether_hdr);\n+\tethertype = rte_be_to_cpu_16(eth_hdr->ether_type);\n+\n+\tif (ethertype == ETHER_TYPE_VLAN) {\n+\t\tstruct vlan_hdr *vlan_hdr = (struct vlan_hdr *)(eth_hdr + 1);\n+\t\tinfo->l2_len  += sizeof(struct vlan_hdr);\n+\t\tethertype = rte_be_to_cpu_16(vlan_hdr->eth_proto);\n+\t}\n+\n+\tl3_hdr = (char *)eth_hdr + info->l2_len;\n+\n+\tif (ethertype == ETHER_TYPE_IPv4) {\n+\t\tipv4_hdr = (struct ipv4_hdr *)l3_hdr;\n+\t\tipv4_hdr->hdr_checksum = 0;\n+\t\tol_flags |= PKT_TX_IPV4;\n+\t\tol_flags |= PKT_TX_IP_CKSUM;\n+\t\tinfo->l3_len = sizeof(struct ipv4_hdr);\n+\t\tl4_proto = ipv4_hdr->next_proto_id;\n+\t} else if (ethertype == ETHER_TYPE_IPv6) {\n+\t\tipv6_hdr = (struct ipv6_hdr *)l3_hdr;\n+\t\tinfo->l3_len = sizeof(struct ipv6_hdr);\n+\t\tl4_proto = ipv6_hdr->proto;\n+\t\tol_flags |= PKT_TX_IPV6;\n+\t} else\n+\t\treturn 0; /* packet type not supported, nothing to do */\n+\n+\tif (l4_proto == IPPROTO_UDP) {\n+\t\tudp_hdr = (struct udp_hdr *)((char *)l3_hdr + info->l3_len);\n+\t\tol_flags |= PKT_TX_UDP_CKSUM;\n+\t\tudp_hdr->dgram_cksum = get_psd_sum(l3_hdr,\n+\t\t\t\tethertype, ol_flags);\n+\t} else if (l4_proto == IPPROTO_TCP) {\n+\t\ttcp_hdr = (struct tcp_hdr *)((char *)l3_hdr + info->l3_len);\n+\t\tol_flags |= PKT_TX_TCP_CKSUM;\n+\t\ttcp_hdr->cksum = get_psd_sum(l3_hdr, ethertype,\n+\t\t\t\tol_flags);\n+\n+\t} else if (l4_proto == IPPROTO_SCTP) {\n+\t\tsctp_hdr = (struct sctp_hdr *)((char *)l3_hdr + info->l3_len);\n+\t\tsctp_hdr->cksum = 0;\n+\t\tol_flags |= PKT_TX_SCTP_CKSUM;\n+\t}\n+\n+\treturn ol_flags;\n+}\n+\n int\n decapsulation(struct rte_mbuf *pkt)\n {\n@@ -93,6 +164,7 @@ decapsulation(struct rte_mbuf *pkt)\n \tstruct ether_hdr *phdr = rte_pktmbuf_mtod(pkt, struct ether_hdr *);\n \n \tparse_ethernet(phdr, &info, &l4_proto);\n+\n \tif (l4_proto != IPPROTO_UDP)\n \t\treturn -1;\n \n@@ -120,6 +192,7 @@ encapsulation(struct rte_mbuf *m, uint8_t queue_id)\n \tuint vport_id;\n \tuint64_t ol_flags = 0;\n \tuint32_t old_len = m->pkt_len, hash;\n+\tunion tunnel_offload_info tx_offload = { .data = 0 };\n \tstruct ether_hdr *phdr = rte_pktmbuf_mtod(m, struct ether_hdr *);\n \n \t/*Allocate space for new ethernet, IPv4, UDP and VXLAN headers*/\n@@ -148,6 +221,14 @@ encapsulation(struct rte_mbuf *m, uint8_t queue_id)\n \tol_flags |= PKT_TX_OUTER_IP_CKSUM;\n \tip->hdr_checksum = 0;\n \n+\t/* inner IP checksum offload */\n+\tif (tx_checksum) {\n+\t\tol_flags |= process_inner_cksums(phdr, &tx_offload);\n+\t\tm->l2_len = tx_offload.l2_len;\n+\t\tm->l3_len = tx_offload.l3_len;\n+\t\tm->l2_len += ETHER_VXLAN_HLEN;\n+\t}\n+\n \tm->outer_l2_len = sizeof(struct ether_hdr);\n \tm->outer_l3_len = sizeof(struct ipv4_hdr);\n \ndiff --git a/examples/tep_termination/vxlan.h b/examples/tep_termination/vxlan.h\nindex 502bbaa..090eb48 100644\n--- a/examples/tep_termination/vxlan.h\n+++ b/examples/tep_termination/vxlan.h\n@@ -47,6 +47,7 @@\n \n extern struct ipv4_hdr app_ip_hdr[VXLAN_N_PORTS];\n extern struct ether_hdr app_l2_hdr[VXLAN_N_PORTS];\n+extern uint8_t tx_checksum;\n \n struct vxlan_port {\n \tuint32_t vport_id;           /**< VirtIO port id */\n",
    "prefixes": [
        "dpdk-dev",
        "v5",
        "07/10"
    ]
}