get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 60252,
    "url": "https://patches.dpdk.org/api/patches/60252/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20190930192056.26828-5-stephen@networkplumber.org/",
    "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": "<20190930192056.26828-5-stephen@networkplumber.org>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20190930192056.26828-5-stephen@networkplumber.org",
    "date": "2019-09-30T19:20:54",
    "name": "[v3,4/6] mbuf: add a pktmbuf copy routine",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "2158be7a9d41f4f1687f4ede89370fa3b968d129",
    "submitter": {
        "id": 27,
        "url": "https://patches.dpdk.org/api/people/27/?format=api",
        "name": "Stephen Hemminger",
        "email": "stephen@networkplumber.org"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20190930192056.26828-5-stephen@networkplumber.org/mbox/",
    "series": [
        {
            "id": 6631,
            "url": "https://patches.dpdk.org/api/series/6631/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=6631",
            "date": "2019-09-30T19:20:50",
            "name": "mbuf copy/cloning enhancements",
            "version": 3,
            "mbox": "https://patches.dpdk.org/series/6631/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/60252/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/60252/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 BD5DA1BEA5;\n\tMon, 30 Sep 2019 21:21:13 +0200 (CEST)",
            "from mail-pf1-f194.google.com (mail-pf1-f194.google.com\n\t[209.85.210.194]) by dpdk.org (Postfix) with ESMTP id 460BC1BE81\n\tfor <dev@dpdk.org>; Mon, 30 Sep 2019 21:21:06 +0200 (CEST)",
            "by mail-pf1-f194.google.com with SMTP id 205so6156766pfw.2\n\tfor <dev@dpdk.org>; Mon, 30 Sep 2019 12:21:06 -0700 (PDT)",
            "from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127])\n\tby smtp.gmail.com with ESMTPSA id\n\tc64sm14788304pfc.19.2019.09.30.12.21.03\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 30 Sep 2019 12:21:03 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=networkplumber-org.20150623.gappssmtp.com; s=20150623;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=Gtm1zzy1GlSRdxte2W0/vd1Jy7ccpq73UopKgcsU4nI=;\n\tb=TPYehffRMmWBHFn1Ypvvc9RTZ7wtmK9EYCLaLZNcNo+IfaZE7C3rmo0H1epvUI2hWj\n\tS9MXV6WjS7owUtFfGK9cdmn/Wxvb2uAVCsE748XHMscnJ/9zU96Z4BTjNttspx5SnDY8\n\t16KArChiBA6xdcFbzC4qG0Ea7vJ5HEebwU/q/zCB0bbmr8ZjGy8fxKZljH3QGMvDXkFy\n\td71R5HLrK1kgA8It56t9us0lcyN5hPBIUD/s+ngMuB6+WoCAwq4H6JKu/9YZx3V+Hd31\n\t9u2bYyNeN5prymrOT2GjyormY4UsM3gRKrfScPc3CIfgo7ZBPpxPjkWtV27zS3VfWogI\n\tsTNw==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=Gtm1zzy1GlSRdxte2W0/vd1Jy7ccpq73UopKgcsU4nI=;\n\tb=sjFadNF2gjkZcOJtGq+37INeCtfmE0Mwty6WE+HiNIZhkowVR2+9Kv0RgHFyFHqmNk\n\tjKhGYvfw6SsJM9k8u06ug8LnCY9koyZs8kBRE5aGzkbvLMhtMocoPmF9cy8ecGfqMXHZ\n\t/WmGkVBGk8YmeLkvpOxhMM7VoPvamEKz/MR3lSqvxFLCRit+HtWim1FTIGWVMtGLCmsI\n\tN9TVszfOO21kdbs85scZFbB6Wnrq0r8PIRHigdtK4BrIQHDgIQRZ5o13kgZTMPl2F/cg\n\t4PAeNlMRV0HwtDY0N3jAsjW1tSpPjcEIZufLZf4aEh5JN6otj4B0xkIhvG/FHIi+hi3E\n\t5eMg==",
        "X-Gm-Message-State": "APjAAAU5G8FtdtU2y/oRrhCw2ibEih8FBdQAlKIKL83aY8ibuJsGUx7T\n\tTR6uA00AOEXZ+zpY4K8Ns9tj7MGvprAUtw==",
        "X-Google-Smtp-Source": "APXvYqy+lFFTtLxoA5PaHZr443gCeMjfts95owjFwtc/V/CDvOyHsdICJvDT/nzE5M8HLgLksvJ++w==",
        "X-Received": "by 2002:a62:aa0f:: with SMTP id\n\te15mr22580834pff.160.1569871265033; \n\tMon, 30 Sep 2019 12:21:05 -0700 (PDT)",
        "From": "Stephen Hemminger <stephen@networkplumber.org>",
        "To": "dev@dpdk.org",
        "Cc": "Stephen Hemminger <stephen@networkplumber.org>",
        "Date": "Mon, 30 Sep 2019 12:20:54 -0700",
        "Message-Id": "<20190930192056.26828-5-stephen@networkplumber.org>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20190930192056.26828-1-stephen@networkplumber.org>",
        "References": "<20190928003758.18489-1-stephen@networkplumber.org>\n\t<20190930192056.26828-1-stephen@networkplumber.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v3 4/6] mbuf: add a pktmbuf copy routine",
        "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 is a commonly used operation that surprisingly the\nDPDK has not supported. The new rte_pktmbuf_copy does a\ndeep copy of packet. This is a complete copy including\nmeta-data.\n\nIt handles the case where the source mbuf comes from a pool\nwith larger data area than the destination pool. The routine\nalso has options for skipping data, or truncating at a fixed\nlength.\n\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\n---\n lib/librte_mbuf/rte_mbuf.c           | 74 ++++++++++++++++++++++++++++\n lib/librte_mbuf/rte_mbuf.h           | 26 ++++++++++\n lib/librte_mbuf/rte_mbuf_version.map |  1 +\n 3 files changed, 101 insertions(+)",
    "diff": "diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c\nindex 9a1a1b5f9468..901df0192d2e 100644\n--- a/lib/librte_mbuf/rte_mbuf.c\n+++ b/lib/librte_mbuf/rte_mbuf.c\n@@ -321,6 +321,80 @@ __rte_pktmbuf_linearize(struct rte_mbuf *mbuf)\n \treturn 0;\n }\n \n+/* Create a deep copy of mbuf */\n+struct rte_mbuf *\n+rte_pktmbuf_copy(const struct rte_mbuf *m, struct rte_mempool *mp,\n+\t\t uint32_t off, uint32_t len)\n+{\n+\tconst struct rte_mbuf *seg = m;\n+\tstruct rte_mbuf *mc, *m_last, **prev;\n+\n+\tif (unlikely(off >= m->pkt_len))\n+\t\treturn NULL;\n+\n+\tmc = rte_pktmbuf_alloc(mp);\n+\tif (unlikely(mc == NULL))\n+\t\treturn NULL;\n+\n+\tif (len > m->pkt_len - off)\n+\t\tlen = m->pkt_len - off;\n+\n+\t/* clone meta data from original */\n+\tmc->port = m->port;\n+\tmc->vlan_tci = m->vlan_tci;\n+\tmc->vlan_tci_outer = m->vlan_tci_outer;\n+\tmc->tx_offload = m->tx_offload;\n+\tmc->hash = m->hash;\n+\tmc->packet_type = m->packet_type;\n+\tmc->timestamp = m->timestamp;\n+\n+\t/* copy private data (if any) */\n+\trte_memcpy(mc + 1, m + 1,\n+\t\t   rte_pktmbuf_priv_size(mp));\n+\n+\tprev = &mc->next;\n+\tm_last = mc;\n+\twhile (len > 0) {\n+\t\tuint32_t copy_len;\n+\n+\t\twhile (off >= seg->data_len) {\n+\t\t\toff -= seg->data_len;\n+\t\t\tseg = seg->next;\n+\t\t}\n+\n+\t\t/* current buffer is full, chain a new one */\n+\t\tif (rte_pktmbuf_tailroom(m_last) == 0) {\n+\t\t\tm_last = rte_pktmbuf_alloc(mp);\n+\t\t\tif (unlikely(m_last == NULL)) {\n+\t\t\t\trte_pktmbuf_free(mc);\n+\t\t\t\treturn NULL;\n+\t\t\t}\n+\t\t\t++mc->nb_segs;\n+\t\t\t*prev = m_last;\n+\t\t\tprev = &m_last->next;\n+\t\t}\n+\n+\t\tcopy_len = RTE_MIN(seg->data_len - off, len);\n+\t\tif (copy_len > rte_pktmbuf_tailroom(m_last))\n+\t\t\tcopy_len = rte_pktmbuf_tailroom(m_last);\n+\n+\t\t/* append from seg to m_last */\n+\t\trte_memcpy(rte_pktmbuf_mtod_offset(m_last, char *,\n+\t\t\t\t\t\t   m_last->data_len),\n+\t\t\t   rte_pktmbuf_mtod_offset(seg, char *,\n+\t\t\t\t\t\t   off),\n+\t\t\t   copy_len);\n+\n+\t\tm_last->data_len += copy_len;\n+\t\tmc->pkt_len += copy_len;\n+\t\toff += copy_len;\n+\t\tlen -= copy_len;\n+\t}\n+\n+\t__rte_mbuf_sanity_check(mc, 1);\n+\treturn mc;\n+}\n+\n /* dump a mbuf on console */\n void\n rte_pktmbuf_dump(FILE *f, const struct rte_mbuf *m, unsigned dump_len)\ndiff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h\nindex 6133f12172ae..b860d570ef20 100644\n--- a/lib/librte_mbuf/rte_mbuf.h\n+++ b/lib/librte_mbuf/rte_mbuf.h\n@@ -1927,6 +1927,32 @@ static inline void rte_pktmbuf_free(struct rte_mbuf *m)\n struct rte_mbuf *\n rte_pktmbuf_clone(struct rte_mbuf *md, struct rte_mempool *mp);\n \n+/**\n+ * Creates a full copy of a given packet mbuf.\n+ *\n+ * Copies all the data from a given packet mbuf to a newly allocated\n+ * set of mbufs.\n+ *\n+ * @param m\n+ *   The packet mbuf to be cloned.\n+ * @param mp\n+ *   The mempool from which the \"clone\" mbufs are allocated.\n+ * @param offset\n+ *   The number of bytes to skip before copying.\n+ *   If the mbuf does not have that many bytes, it is an error\n+ *   and NULL is returned.\n+ * @param length\n+ *   The upper limit on bytes to copy.  Passing UINT32_MAX\n+ *   means all data (after offset).\n+ * @return\n+ *   - The pointer to the new \"clone\" mbuf on success.\n+ *   - NULL if allocation fails.\n+ */\n+__rte_experimental\n+struct rte_mbuf *\n+rte_pktmbuf_copy(const struct rte_mbuf *m, struct rte_mempool *mp,\n+\t\t uint32_t offset, uint32_t length);\n+\n /**\n  * Adds given value to the refcnt of all packet mbuf segments.\n  *\ndiff --git a/lib/librte_mbuf/rte_mbuf_version.map b/lib/librte_mbuf/rte_mbuf_version.map\nindex ff5c18a5559b..a50dcb6db9ec 100644\n--- a/lib/librte_mbuf/rte_mbuf_version.map\n+++ b/lib/librte_mbuf/rte_mbuf_version.map\n@@ -57,4 +57,5 @@ EXPERIMENTAL {\n \tglobal:\n \n \trte_mbuf_check;\n+\trte_pktmbuf_copy;\n } DPDK_18.08;\n",
    "prefixes": [
        "v3",
        "4/6"
    ]
}