get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 17226,
    "url": "https://patches.dpdk.org/api/patches/17226/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1479977798-13417-4-git-send-email-olivier.matz@6wind.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": "<1479977798-13417-4-git-send-email-olivier.matz@6wind.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1479977798-13417-4-git-send-email-olivier.matz@6wind.com",
    "date": "2016-11-24T08:56:36",
    "name": "[dpdk-dev,3/5] mbuf: new helper to write data in a mbuf chain",
    "commit_ref": null,
    "pull_url": null,
    "state": "rejected",
    "archived": true,
    "hash": "b6d07a58d2a18d65fd7e7eaa27f0fad3c40805ae",
    "submitter": {
        "id": 8,
        "url": "https://patches.dpdk.org/api/people/8/?format=api",
        "name": "Olivier Matz",
        "email": "olivier.matz@6wind.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/1479977798-13417-4-git-send-email-olivier.matz@6wind.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/17226/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/17226/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 48C424A59;\n\tThu, 24 Nov 2016 09:56:59 +0100 (CET)",
            "from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com\n\t[62.23.145.76]) by dpdk.org (Postfix) with ESMTP id 3BB942BA7\n\tfor <dev@dpdk.org>; Thu, 24 Nov 2016 09:56:57 +0100 (CET)",
            "from glumotte.dev.6wind.com (unknown [10.16.0.195])\n\tby proxy.6wind.com (Postfix) with ESMTP id 97B6C26D1C;\n\tThu, 24 Nov 2016 09:56:52 +0100 (CET)"
        ],
        "From": "Olivier Matz <olivier.matz@6wind.com>",
        "To": "dev@dpdk.org,\n\tyuanhan.liu@linux.intel.com",
        "Cc": "maxime.coquelin@redhat.com, huawei.xie@intel.com,\n\tstephen@networkplumber.org",
        "Date": "Thu, 24 Nov 2016 09:56:36 +0100",
        "Message-Id": "<1479977798-13417-4-git-send-email-olivier.matz@6wind.com>",
        "X-Mailer": "git-send-email 2.8.1",
        "In-Reply-To": "<1479977798-13417-1-git-send-email-olivier.matz@6wind.com>",
        "References": "<1479977798-13417-1-git-send-email-olivier.matz@6wind.com>",
        "Subject": "[dpdk-dev] [PATCH 3/5] mbuf: new helper to write data in a mbuf\n\tchain",
        "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": "Introduce a new helper to write data in a chain of mbufs,\nspreading it in the segments.\n\nSigned-off-by: Olivier Matz <olivier.matz@6wind.com>\n---\n app/test/test_mbuf.c                 | 21 +++++++++++++++\n lib/librte_mbuf/rte_mbuf.c           | 44 +++++++++++++++++++++++++++++++\n lib/librte_mbuf/rte_mbuf.h           | 50 ++++++++++++++++++++++++++++++++++++\n lib/librte_mbuf/rte_mbuf_version.map |  6 +++++\n 4 files changed, 121 insertions(+)",
    "diff": "diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c\nindex 7656a4d..5f1bc5d 100644\n--- a/app/test/test_mbuf.c\n+++ b/app/test/test_mbuf.c\n@@ -335,6 +335,10 @@ testclone_testupdate_testdetach(void)\n \tstruct rte_mbuf *clone2 = NULL;\n \tstruct rte_mbuf *m2 = NULL;\n \tunaligned_uint32_t *data;\n+\tuint32_t magic = MAGIC_DATA;\n+\tuint32_t check_data[2];\n+\n+\tmemset(check_data, 0, sizeof(check_data));\n \n \t/* alloc a mbuf */\n \tm = rte_pktmbuf_alloc(pktmbuf_pool);\n@@ -421,6 +425,8 @@ testclone_testupdate_testdetach(void)\n \tif (m2 == NULL)\n \t\tGOTO_FAIL(\"cannot allocate m2\");\n \trte_pktmbuf_append(m2, sizeof(uint32_t));\n+\tif (rte_pktmbuf_write(m2, 0, sizeof(uint32_t), &magic) < 0)\n+\t\tGOTO_FAIL(\"cannot write data in m2\");\n \trte_pktmbuf_chain(m2, clone);\n \tclone = NULL;\n \n@@ -430,6 +436,21 @@ testclone_testupdate_testdetach(void)\n \t\t\trte_pktmbuf_pkt_len(m2) - sizeof(uint32_t)) == 0)\n \t\tGOTO_FAIL(\"m2 data should be marked as shared\");\n \n+\t/* check data content */\n+\tdata = rte_pktmbuf_read(m2, 0, sizeof(uint32_t), check_data);\n+\tif (data == NULL)\n+\t\tGOTO_FAIL(\"cannot read data\");\n+\tif (*data != MAGIC_DATA)\n+\t\tGOTO_FAIL(\"invalid data\");\n+\tif (data == check_data)\n+\t\tGOTO_FAIL(\"data should not have been copied\");\n+\tdata = rte_pktmbuf_read(m2, 0, sizeof(uint32_t) * 2, check_data);\n+\tif (data == NULL)\n+\t\tGOTO_FAIL(\"cannot read data\");\n+\tif (data[0] != MAGIC_DATA || data[1] != MAGIC_DATA)\n+\t\tGOTO_FAIL(\"invalid data\");\n+\tif (data != check_data)\n+\t\tGOTO_FAIL(\"data should have been copied\");\n \t/* free mbuf */\n \trte_pktmbuf_free(m);\n \tm = NULL;\ndiff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c\nindex b31958e..ed56193 100644\n--- a/lib/librte_mbuf/rte_mbuf.c\n+++ b/lib/librte_mbuf/rte_mbuf.c\n@@ -298,6 +298,50 @@ void *__rte_pktmbuf_read(const struct rte_mbuf *m, uint32_t off,\n \treturn buf;\n }\n \n+/* write len data bytes in a mbuf at specified offset (internal) */\n+int\n+__rte_pktmbuf_write(const struct rte_mbuf *m, uint32_t off,\n+\tuint32_t len, const void *buf)\n+{\n+\tconst struct rte_mbuf *seg = m;\n+\tuint32_t buf_off = 0, copy_len;\n+\tchar *dst;\n+\n+\tif (off + len > rte_pktmbuf_pkt_len(m))\n+\t\treturn -1;\n+\n+\twhile (off >= rte_pktmbuf_data_len(seg)) {\n+\t\toff -= rte_pktmbuf_data_len(seg);\n+\t\tseg = seg->next;\n+\t}\n+\n+\tdst = rte_pktmbuf_mtod_offset(seg, char *, off);\n+\tif (buf == dst)\n+\t\treturn 0;\n+\n+\tif (off + len <= rte_pktmbuf_data_len(seg)) {\n+\t\tRTE_ASSERT(!rte_pktmbuf_is_shared(seg));\n+\t\trte_memcpy(dst, buf, len);\n+\t\treturn 0;\n+\t}\n+\n+\t/* copy data in several segments */\n+\twhile (len > 0) {\n+\t\tRTE_ASSERT(!rte_pktmbuf_is_shared(seg));\n+\t\tcopy_len = rte_pktmbuf_data_len(seg) - off;\n+\t\tif (copy_len > len)\n+\t\t\tcopy_len = len;\n+\t\tdst = rte_pktmbuf_mtod_offset(seg, char *, off);\n+\t\trte_memcpy(dst, (const char *)buf + buf_off, copy_len);\n+\t\toff = 0;\n+\t\tbuf_off += copy_len;\n+\t\tlen -= copy_len;\n+\t\tseg = seg->next;\n+\t}\n+\n+\treturn 0;\n+}\n+\n /*\n  * Get the name of a RX offload flag. Must be kept synchronized with flag\n  * definitions in rte_mbuf.h.\ndiff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h\nindex cd77a56..e898d25 100644\n--- a/lib/librte_mbuf/rte_mbuf.h\n+++ b/lib/librte_mbuf/rte_mbuf.h\n@@ -1678,6 +1678,56 @@ static inline void *rte_pktmbuf_read(const struct rte_mbuf *m,\n }\n \n /**\n+ * @internal used by rte_pktmbuf_write().\n+ */\n+int __rte_pktmbuf_write(const struct rte_mbuf *m, uint32_t off,\n+\tuint32_t len, const void *buf);\n+\n+/**\n+ * Write len data bytes in a mbuf at specified offset.\n+ *\n+ * If the mbuf is contiguous between off and off+len, rte_memcpy() is\n+ * called. Else, it will split the data in the segments.\n+ *\n+ * The caller must ensure that all destination segments are writable\n+ * (not shared).\n+ *\n+ * If the destination pointer in the mbuf is the same than the source\n+ * buffer, the function do nothing and is successful.\n+ *\n+ * If the mbuf is too small, the function fails.\n+ *\n+ * @param m\n+ *   The pointer to the mbuf.\n+ * @param off\n+ *   The offset of the data in the mbuf.\n+ * @param len\n+ *   The amount of bytes to read.\n+ * @param buf\n+ *   The buffer where data is copied if it is not contiguous in mbuf\n+ *   data. Its length should be at least equal to the len parameter.\n+ * @return\n+ *   - (0) on success (data is updated in the mbuf)\n+ *   - (-1) on error: mbuf is too small or not writable\n+ */\n+static inline int rte_pktmbuf_write(const struct rte_mbuf *m,\n+\tuint32_t off, uint32_t len, const void *buf)\n+{\n+\tchar *dst = rte_pktmbuf_mtod_offset(m, char *, off);\n+\n+\tif (buf == dst)\n+\t\treturn 0;\n+\n+\tif (off + len <= rte_pktmbuf_data_len(m)) {\n+\t\tRTE_ASSERT(!rte_pktmbuf_is_shared(m));\n+\t\trte_memcpy(dst, buf, len);\n+\t\treturn 0;\n+\t}\n+\n+\treturn __rte_pktmbuf_write(m, off, len, buf);\n+}\n+\n+/**\n  * Chain an mbuf to another, thereby creating a segmented packet.\n  *\n  * Note: The implementation will do a linear walk over the segments to find\ndiff --git a/lib/librte_mbuf/rte_mbuf_version.map b/lib/librte_mbuf/rte_mbuf_version.map\nindex 6e2ea84..b2c057e 100644\n--- a/lib/librte_mbuf/rte_mbuf_version.map\n+++ b/lib/librte_mbuf/rte_mbuf_version.map\n@@ -35,3 +35,9 @@ DPDK_16.11 {\n \trte_get_tx_ol_flag_list;\n \n } DPDK_2.1;\n+\n+DPDK_17.02 {\n+\tglobal:\n+\n+\t__rte_pktmbuf_write;\n+} DPDK_16.11;\n",
    "prefixes": [
        "dpdk-dev",
        "3/5"
    ]
}