Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/60236/?format=api
http://patches.dpdk.org/api/patches/60236/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20190930152721.8029-5-stephen@networkplumber.org/", "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": "<20190930152721.8029-5-stephen@networkplumber.org>", "list_archive_url": "https://inbox.dpdk.org/dev/20190930152721.8029-5-stephen@networkplumber.org", "date": "2019-09-30T15:27:19", "name": "[v2,4/6] mbuf: add a pktmbuf copy routine", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "a6aa7093facefdae502c21c1714d44c27c9d7232", "submitter": { "id": 27, "url": "http://patches.dpdk.org/api/people/27/?format=api", "name": "Stephen Hemminger", "email": "stephen@networkplumber.org" }, "delegate": null, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20190930152721.8029-5-stephen@networkplumber.org/mbox/", "series": [ { "id": 6624, "url": "http://patches.dpdk.org/api/series/6624/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=6624", "date": "2019-09-30T15:27:15", "name": "mbuf copy related enhancements", "version": 2, "mbox": "http://patches.dpdk.org/series/6624/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/60236/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/60236/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 DD9AE1BEDD;\n\tMon, 30 Sep 2019 17:27:41 +0200 (CEST)", "from mail-pf1-f195.google.com (mail-pf1-f195.google.com\n\t[209.85.210.195]) by dpdk.org (Postfix) with ESMTP id E6CA11BEAD\n\tfor <dev@dpdk.org>; Mon, 30 Sep 2019 17:27:34 +0200 (CEST)", "by mail-pf1-f195.google.com with SMTP id y22so5822144pfr.3\n\tfor <dev@dpdk.org>; Mon, 30 Sep 2019 08:27:34 -0700 (PDT)", "from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127])\n\tby smtp.gmail.com with ESMTPSA id\n\tw14sm30521021pge.56.2019.09.30.08.27.32\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 30 Sep 2019 08:27:32 -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=00Vzr/C5heiPvoqwsahNL1dLUjUkGiVfyZ2wgTuDXzo=;\n\tb=QWBm9L/ez/fCcMI2VDE8mdR09PUbtEfmyvAdl+gadccfun6RdBXNdgwnDzpqYvSH4X\n\trcWer+xgjx1/Umj5jCGRBkGl0DzKeYKf+NJcsDXLr1AEhAgutUVbIaHcT/sh4WGuO/Qs\n\tv5TpAxZwEdIwMDbaCv7RnK9SqtgGv6pxND+7ffT2swn1YjX0lNZk7zHxUqMmgrSWpeYO\n\tj3c9moT0VKr/J0Q0vAhlNp9Qqf38SDpaT/Zyc86SKwirgaVVesDtAxZvrdK3+ZgJM1CC\n\t43tZVXX7+ARwWf3NVzlYNuidexb0HBedK3I5rKutNAiKXDo89CKFvuST0QvQ/AVqyj1t\n\tEmfA==", "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=00Vzr/C5heiPvoqwsahNL1dLUjUkGiVfyZ2wgTuDXzo=;\n\tb=Raq/5rrJdaVABQLgfQzVGcQ0ojgXscnJrMGyxWNZy8rXvwEL9cF9FKfxX/oCgwcRlF\n\t2vgaCUrNTEeRYlDkczpj7Df6T/oP/iJKDoLS+zGxmE+d2FaTVzIdUpXvnVdH3kvpAXYx\n\tGkk0QXca3rKN3IT+jmYhPGOQakvlhdPwi9/+xjyFe5aNh/KMjZ2GDcWwByhw6V96dH7z\n\tnAe0n8a+LnQRXfE7kJZrZUlPJJxu6m9Z1FmTwTQZits2gQEtQdG2J3+LiXW6ffxCdpzD\n\tZ4Q0IIxshfXBpbLEPjz+3CyFubJpbywlyqxKWdvz+qrlTOW1iFe4p+Yv3wTNiCIta8pi\n\t34GQ==", "X-Gm-Message-State": "APjAAAV2duovrLoJWXCaYTVKcLnS8gATFHF4fjuuazcr/UeQAaT73sGm\n\t8j6fp+OQGgNOcHzK7OzjGR127sbWtdg=", "X-Google-Smtp-Source": "APXvYqw0Ww2PS22eYiIwf/xbUWyOIjJzP5BIm2KpMewpd5eTdb3wzXadc3FPjGglcDcU5nqtLoT5RA==", "X-Received": "by 2002:a17:90b:903:: with SMTP id\n\tbo3mr27236045pjb.52.1569857253481; \n\tMon, 30 Sep 2019 08:27:33 -0700 (PDT)", "From": "Stephen Hemminger <stephen@networkplumber.org>", "To": "dev@dpdk.org", "Cc": "Stephen Hemminger <stephen@networkplumber.org>", "Date": "Mon, 30 Sep 2019 08:27:19 -0700", "Message-Id": "<20190930152721.8029-5-stephen@networkplumber.org>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20190930152721.8029-1-stephen@networkplumber.org>", "References": "<20190928003758.18489-1-stephen@networkplumber.org>\n\t<20190930152721.8029-1-stephen@networkplumber.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[dpdk-dev] [PATCH v2 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 | 70 ++++++++++++++++++++++++++++\n lib/librte_mbuf/rte_mbuf.h | 26 +++++++++++\n lib/librte_mbuf/rte_mbuf_version.map | 1 +\n 3 files changed, 97 insertions(+)", "diff": "diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c\nindex 12d0258a120d..6888d6bd5dfc 100644\n--- a/lib/librte_mbuf/rte_mbuf.c\n+++ b/lib/librte_mbuf/rte_mbuf.c\n@@ -324,6 +324,76 @@ 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+\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 a6e78e4ea7a6..77266a07c75b 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 aeec3f90f3fe..f471bbcaa2df 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": [ "v2", "4/6" ] }{ "id": 60236, "url": "