get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 41220,
    "url": "https://patches.dpdk.org/api/patches/41220/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1529205194-87434-2-git-send-email-jiayu.hu@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": "<1529205194-87434-2-git-send-email-jiayu.hu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1529205194-87434-2-git-send-email-jiayu.hu@intel.com",
    "date": "2018-06-17T03:13:12",
    "name": "[v2,1/3] gso: support UDP/IPv4 fragmentation",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "655467e93b90c10755d50777111c00f3b849d759",
    "submitter": {
        "id": 539,
        "url": "https://patches.dpdk.org/api/people/539/?format=api",
        "name": "Hu, Jiayu",
        "email": "jiayu.hu@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1529205194-87434-2-git-send-email-jiayu.hu@intel.com/mbox/",
    "series": [
        {
            "id": 149,
            "url": "https://patches.dpdk.org/api/series/149/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=149",
            "date": "2018-06-17T03:13:11",
            "name": "Support UDP/IPv4 GSO",
            "version": 2,
            "mbox": "https://patches.dpdk.org/series/149/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/41220/comments/",
    "check": "fail",
    "checks": "https://patches.dpdk.org/api/patches/41220/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 [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id DF4341B4BE;\n\tSun, 17 Jun 2018 05:05:32 +0200 (CEST)",
            "from mga03.intel.com (mga03.intel.com [134.134.136.65])\n\tby dpdk.org (Postfix) with ESMTP id A0DA11B3B6\n\tfor <dev@dpdk.org>; Sun, 17 Jun 2018 05:05:26 +0200 (CEST)",
            "from orsmga008.jf.intel.com ([10.7.209.65])\n\tby orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t16 Jun 2018 20:05:25 -0700",
            "from dpdk15.sh.intel.com ([10.67.111.146])\n\tby orsmga008.jf.intel.com with ESMTP; 16 Jun 2018 20:05:24 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.51,233,1526367600\"; d=\"scan'208\";a=\"49937434\"",
        "From": "Jiayu Hu <jiayu.hu@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "konstantin.ananyev@intel.com, yuwei1.zhang@intel.com,\n\tbernard.iremonger@intel.com, Jiayu Hu <jiayu.hu@intel.com>",
        "Date": "Sun, 17 Jun 2018 11:13:12 +0800",
        "Message-Id": "<1529205194-87434-2-git-send-email-jiayu.hu@intel.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1529205194-87434-1-git-send-email-jiayu.hu@intel.com>",
        "References": "<1527579670-91026-1-git-send-email-jiayu.hu@intel.com>\n\t<1529205194-87434-1-git-send-email-jiayu.hu@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v2 1/3] gso: support UDP/IPv4 fragmentation",
        "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\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "This patch adds GSO support for UDP/IPv4 packets. Supported packets\nmay include a single VLAN tag. UDP/IPv4 GSO doesn't check if input\npackets have correct checksums, and doesn't update checksums for\noutput packets (the responsibility for this lies with the application).\nAdditionally, UDP/IPv4 GSO doesn't process IP fragmented packets.\n\nUDP/IPv4 GSO uses two chained MBUFs, one direct MBUF and one indrect\nMBUF, to organize an output packet. The direct MBUF stores the packet\nheader, while the indirect mbuf simply points to a location within the\noriginal packet's payload. Consequently, use of UDP GSO requires\nmulti-segment MBUF support in the TX functions of the NIC driver.\n\nIf a packet is GSO'd, UDP/IPv4 GSO reduces its MBUF refcnt by 1. As a\nresult, when all of its GSOed segments are freed, the packet is freed\nautomatically.\n\nSigned-off-by: Jiayu Hu <jiayu.hu@intel.com>\n---\n lib/librte_gso/Makefile     |  1 +\n lib/librte_gso/gso_common.h |  3 ++\n lib/librte_gso/gso_udp4.c   | 81 +++++++++++++++++++++++++++++++++++++++++++++\n lib/librte_gso/gso_udp4.h   | 42 +++++++++++++++++++++++\n lib/librte_gso/rte_gso.c    | 24 +++++++++++---\n lib/librte_gso/rte_gso.h    |  6 +++-\n 6 files changed, 151 insertions(+), 6 deletions(-)\n create mode 100644 lib/librte_gso/gso_udp4.c\n create mode 100644 lib/librte_gso/gso_udp4.h",
    "diff": "diff --git a/lib/librte_gso/Makefile b/lib/librte_gso/Makefile\nindex 3648ec0..1fac53a 100644\n--- a/lib/librte_gso/Makefile\n+++ b/lib/librte_gso/Makefile\n@@ -19,6 +19,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_GSO) += rte_gso.c\n SRCS-$(CONFIG_RTE_LIBRTE_GSO) += gso_common.c\n SRCS-$(CONFIG_RTE_LIBRTE_GSO) += gso_tcp4.c\n SRCS-$(CONFIG_RTE_LIBRTE_GSO) += gso_tunnel_tcp4.c\n+SRCS-$(CONFIG_RTE_LIBRTE_GSO) += gso_udp4.c\n \n # install this header file\n SYMLINK-$(CONFIG_RTE_LIBRTE_GSO)-include += rte_gso.h\ndiff --git a/lib/librte_gso/gso_common.h b/lib/librte_gso/gso_common.h\nindex 5ca5974..6cd764f 100644\n--- a/lib/librte_gso/gso_common.h\n+++ b/lib/librte_gso/gso_common.h\n@@ -31,6 +31,9 @@\n \t\t(PKT_TX_TCP_SEG | PKT_TX_IPV4 | PKT_TX_OUTER_IPV4 | \\\n \t\t PKT_TX_TUNNEL_GRE))\n \n+#define IS_IPV4_UDP(flag) (((flag) & (PKT_TX_UDP_SEG | PKT_TX_IPV4)) == \\\n+\t\t(PKT_TX_UDP_SEG | PKT_TX_IPV4))\n+\n /**\n  * Internal function which updates the UDP header of a packet, following\n  * segmentation. This is required to update the header's datagram length field.\ndiff --git a/lib/librte_gso/gso_udp4.c b/lib/librte_gso/gso_udp4.c\nnew file mode 100644\nindex 0000000..a3db329\n--- /dev/null\n+++ b/lib/librte_gso/gso_udp4.c\n@@ -0,0 +1,81 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2018 Intel Corporation\n+ */\n+\n+#include \"gso_common.h\"\n+#include \"gso_udp4.h\"\n+\n+#define IPV4_HDR_MF_BIT (1U << 13)\n+\n+static inline void\n+update_ipv4_udp_headers(struct rte_mbuf *pkt, struct rte_mbuf **segs,\n+\t\tuint16_t nb_segs)\n+{\n+\tstruct ipv4_hdr *ipv4_hdr;\n+\tuint16_t frag_offset = 0, is_mf;\n+\tuint16_t l2_hdrlen = pkt->l2_len, l3_hdrlen = pkt->l3_len;\n+\tuint16_t tail_idx = nb_segs - 1, length, i;\n+\n+\t/*\n+\t * Update IP header fields for output segments. Specifically,\n+\t * keep the same IP id, update fragment offset and total\n+\t * length.\n+\t */\n+\tfor (i = 0; i < nb_segs; i++) {\n+\t\tipv4_hdr = (struct ipv4_hdr *)(rte_pktmbuf_mtod(segs[i],\n+\t\t\t\t\tchar *) + l2_hdrlen);\n+\t\tlength = segs[i]->pkt_len - l2_hdrlen;\n+\t\tipv4_hdr->total_length = rte_cpu_to_be_16(length);\n+\n+\t\tis_mf = i < tail_idx ? IPV4_HDR_MF_BIT : 0;\n+\t\tipv4_hdr->fragment_offset =\n+\t\t\trte_cpu_to_be_16(frag_offset | is_mf);\n+\t\tfrag_offset += ((length - l3_hdrlen) >> 3);\n+\t}\n+}\n+\n+int\n+gso_udp4_segment(struct rte_mbuf *pkt,\n+\t\tuint16_t gso_size,\n+\t\tstruct rte_mempool *direct_pool,\n+\t\tstruct rte_mempool *indirect_pool,\n+\t\tstruct rte_mbuf **pkts_out,\n+\t\tuint16_t nb_pkts_out)\n+{\n+\tstruct ipv4_hdr *ipv4_hdr;\n+\tuint16_t pyld_unit_size, hdr_offset;\n+\tuint16_t frag_off;\n+\tint ret;\n+\n+\t/* Don't process the fragmented packet */\n+\tipv4_hdr = (struct ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +\n+\t\t\tpkt->l2_len);\n+\tfrag_off = rte_be_to_cpu_16(ipv4_hdr->fragment_offset);\n+\tif (unlikely(IS_FRAGMENTED(frag_off))) {\n+\t\tpkts_out[0] = pkt;\n+\t\treturn 1;\n+\t}\n+\n+\t/*\n+\t * UDP fragmentation is the same as IP fragmentation.\n+\t * Except the first one, other output packets just have l2\n+\t * and l3 headers.\n+\t */\n+\thdr_offset = pkt->l2_len + pkt->l3_len;\n+\n+\t/* Don't process the packet without data. */\n+\tif (unlikely(hdr_offset + pkt->l4_len >= pkt->pkt_len)) {\n+\t\tpkts_out[0] = pkt;\n+\t\treturn 1;\n+\t}\n+\n+\tpyld_unit_size = gso_size - hdr_offset;\n+\n+\t/* Segment the payload */\n+\tret = gso_do_segment(pkt, hdr_offset, pyld_unit_size, direct_pool,\n+\t\t\tindirect_pool, pkts_out, nb_pkts_out);\n+\tif (ret > 1)\n+\t\tupdate_ipv4_udp_headers(pkt, pkts_out, ret);\n+\n+\treturn ret;\n+}\ndiff --git a/lib/librte_gso/gso_udp4.h b/lib/librte_gso/gso_udp4.h\nnew file mode 100644\nindex 0000000..b2a2908\n--- /dev/null\n+++ b/lib/librte_gso/gso_udp4.h\n@@ -0,0 +1,42 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2018 Intel Corporation\n+ */\n+\n+#ifndef _GSO_UDP4_H_\n+#define _GSO_UDP4_H_\n+\n+#include <stdint.h>\n+#include <rte_mbuf.h>\n+\n+/**\n+ * Segment an UDP/IPv4 packet. This function doesn't check if the input\n+ * packet has correct checksums, and doesn't update checksums for output\n+ * GSO segments. Furthermore, it doesn't process IP fragment packets.\n+ *\n+ * @param pkt\n+ *  The packet mbuf to segment.\n+ * @param gso_size\n+ *  The max length of a GSO segment, measured in bytes.\n+ * @param direct_pool\n+ *  MBUF pool used for allocating direct buffers for output segments.\n+ * @param indirect_pool\n+ *  MBUF pool used for allocating indirect buffers for output segments.\n+ * @param pkts_out\n+ *  Pointer array used to store the MBUF addresses of output GSO\n+ *  segments, when the function succeeds. If the memory space in\n+ *  pkts_out is insufficient, it fails and returns -EINVAL.\n+ * @param nb_pkts_out\n+ *  The max number of items that 'pkts_out' can keep.\n+ *\n+ * @return\n+ *   - The number of GSO segments filled in pkts_out on success.\n+ *   - Return -ENOMEM if run out of memory in MBUF pools.\n+ *   - Return -EINVAL for invalid parameters.\n+ */\n+int gso_udp4_segment(struct rte_mbuf *pkt,\n+\t\tuint16_t gso_size,\n+\t\tstruct rte_mempool *direct_pool,\n+\t\tstruct rte_mempool *indirect_pool,\n+\t\tstruct rte_mbuf **pkts_out,\n+\t\tuint16_t nb_pkts_out);\n+#endif\ndiff --git a/lib/librte_gso/rte_gso.c b/lib/librte_gso/rte_gso.c\nindex a44e3d4..751b5b6 100644\n--- a/lib/librte_gso/rte_gso.c\n+++ b/lib/librte_gso/rte_gso.c\n@@ -11,6 +11,17 @@\n #include \"gso_common.h\"\n #include \"gso_tcp4.h\"\n #include \"gso_tunnel_tcp4.h\"\n+#include \"gso_udp4.h\"\n+\n+#define ILLEGAL_UDP_GSO_CTX(ctx) \\\n+\t((((ctx)->gso_types & DEV_TX_OFFLOAD_UDP_TSO) == 0) || \\\n+\t (ctx)->gso_size < RTE_GSO_UDP_SEG_SIZE_MIN)\n+\n+#define ILLEGAL_TCP_GSO_CTX(ctx) \\\n+\t((((ctx)->gso_types & (DEV_TX_OFFLOAD_TCP_TSO | \\\n+\t\tDEV_TX_OFFLOAD_VXLAN_TNL_TSO | \\\n+\t\tDEV_TX_OFFLOAD_GRE_TNL_TSO)) == 0) || \\\n+\t\t(ctx)->gso_size < RTE_GSO_SEG_SIZE_MIN)\n \n int\n rte_gso_segment(struct rte_mbuf *pkt,\n@@ -27,14 +38,12 @@ rte_gso_segment(struct rte_mbuf *pkt,\n \n \tif (pkt == NULL || pkts_out == NULL || gso_ctx == NULL ||\n \t\t\tnb_pkts_out < 1 ||\n-\t\t\tgso_ctx->gso_size < RTE_GSO_SEG_SIZE_MIN ||\n-\t\t\t((gso_ctx->gso_types & (DEV_TX_OFFLOAD_TCP_TSO |\n-\t\t\tDEV_TX_OFFLOAD_VXLAN_TNL_TSO |\n-\t\t\tDEV_TX_OFFLOAD_GRE_TNL_TSO)) == 0))\n+\t\t\t(ILLEGAL_UDP_GSO_CTX(gso_ctx) &&\n+\t\t\t ILLEGAL_TCP_GSO_CTX(gso_ctx)))\n \t\treturn -EINVAL;\n \n \tif (gso_ctx->gso_size >= pkt->pkt_len) {\n-\t\tpkt->ol_flags &= (~PKT_TX_TCP_SEG);\n+\t\tpkt->ol_flags &= (~(PKT_TX_TCP_SEG | PKT_TX_UDP_SEG));\n \t\tpkts_out[0] = pkt;\n \t\treturn 1;\n \t}\n@@ -59,6 +68,11 @@ rte_gso_segment(struct rte_mbuf *pkt,\n \t\tret = gso_tcp4_segment(pkt, gso_size, ipid_delta,\n \t\t\t\tdirect_pool, indirect_pool,\n \t\t\t\tpkts_out, nb_pkts_out);\n+\t} else if (IS_IPV4_UDP(pkt->ol_flags) &&\n+\t\t\t(gso_ctx->gso_types & DEV_TX_OFFLOAD_UDP_TSO)) {\n+\t\tpkt->ol_flags &= (~PKT_TX_UDP_SEG);\n+\t\tret = gso_udp4_segment(pkt, gso_size, direct_pool,\n+\t\t\t\tindirect_pool, pkts_out, nb_pkts_out);\n \t} else {\n \t\t/* unsupported packet, skip */\n \t\tpkts_out[0] = pkt;\ndiff --git a/lib/librte_gso/rte_gso.h b/lib/librte_gso/rte_gso.h\nindex f4abd61..a626a11 100644\n--- a/lib/librte_gso/rte_gso.h\n+++ b/lib/librte_gso/rte_gso.h\n@@ -17,10 +17,14 @@ extern \"C\" {\n #include <stdint.h>\n #include <rte_mbuf.h>\n \n-/* Minimum GSO segment size. */\n+/* Minimum GSO segment size for TCP based packets. */\n #define RTE_GSO_SEG_SIZE_MIN (sizeof(struct ether_hdr) + \\\n \t\tsizeof(struct ipv4_hdr) + sizeof(struct tcp_hdr) + 1)\n \n+/* Minimum GSO segment size for UDP based packets. */\n+#define RTE_GSO_UDP_SEG_SIZE_MIN (sizeof(struct ether_hdr) + \\\n+\t\tsizeof(struct ipv4_hdr) + sizeof(struct udp_hdr) + 1)\n+\n /* GSO flags for rte_gso_ctx. */\n #define RTE_GSO_FLAG_IPID_FIXED (1ULL << 0)\n /**< Use fixed IP ids for output GSO segments. Setting\n",
    "prefixes": [
        "v2",
        "1/3"
    ]
}