Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/5640/?format=api
https://patches.dpdk.org/api/patches/5640/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1434740232-10954-9-git-send-email-cchemparathy@ezchip.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": "<1434740232-10954-9-git-send-email-cchemparathy@ezchip.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1434740232-10954-9-git-send-email-cchemparathy@ezchip.com", "date": "2015-06-19T18:57:10", "name": "[dpdk-dev,v3,08/10] librte_mbuf: Add rte_pktmbuf_mtod_offset()", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "e2152b8a1724668542dbac9ae585b01b279a7ced", "submitter": { "id": 132, "url": "https://patches.dpdk.org/api/people/132/?format=api", "name": "Cyril Chemparathy", "email": "cchemparathy@ezchip.com" }, "delegate": null, "mbox": "https://patches.dpdk.org/project/dpdk/patch/1434740232-10954-9-git-send-email-cchemparathy@ezchip.com/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/5640/comments/", "check": "pending", "checks": "https://patches.dpdk.org/api/patches/5640/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 D120BC974;\n\tFri, 19 Jun 2015 20:57:45 +0200 (CEST)", "from sclab-apps-2.localdomain (sc-fw1.tilera.com [12.218.212.162])\n\tby dpdk.org (Postfix) with ESMTP id A9ED0C8FC\n\tfor <dev@dpdk.org>; Fri, 19 Jun 2015 20:57:29 +0200 (CEST)", "by sclab-apps-2.localdomain (Postfix, from userid 1318)\n\tid 3CDF02204AA; Fri, 19 Jun 2015 11:57:18 -0700 (PDT)" ], "X-CheckPoint": "{55846619-2-A3D4DA0C-C0000002}", "From": "Cyril Chemparathy <cchemparathy@ezchip.com>", "To": "dev@dpdk.org", "Date": "Fri, 19 Jun 2015 11:57:10 -0700", "Message-Id": "<1434740232-10954-9-git-send-email-cchemparathy@ezchip.com>", "X-Mailer": "git-send-email 2.1.2", "In-Reply-To": "<1434740232-10954-1-git-send-email-cchemparathy@ezchip.com>", "References": "<1434740232-10954-1-git-send-email-cchemparathy@ezchip.com>", "Subject": "[dpdk-dev] [PATCH v3 08/10] librte_mbuf: Add\n\trte_pktmbuf_mtod_offset()", "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": "There are a number of instances in the code where rte_pktmbuf_mtod()\nis used to get the mbuf data pointer, only to add an offset before\ncasting the result to some other header type. This patch adds a new\nrte_pktmbuf_mtod_offset() macro to eliminate these awful double cast\nsituations.\n\nSigned-off-by: Cyril Chemparathy <cchemparathy@ezchip.com>\n---\n lib/librte_mbuf/rte_mbuf.h | 24 +++++++++++++++++++++---\n 1 file changed, 21 insertions(+), 3 deletions(-)", "diff": "diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h\nindex 6efd2b5..396963c 100644\n--- a/lib/librte_mbuf/rte_mbuf.h\n+++ b/lib/librte_mbuf/rte_mbuf.h\n@@ -54,6 +54,7 @@\n */\n \n #include <stdint.h>\n+#include <rte_common.h>\n #include <rte_mempool.h>\n #include <rte_memory.h>\n #include <rte_atomic.h>\n@@ -1080,18 +1081,35 @@ static inline struct rte_mbuf *rte_pktmbuf_lastseg(struct rte_mbuf *m)\n }\n \n /**\n+ * A macro that points to an offset into the data in the mbuf.\n+ *\n+ * The returned pointer is cast to type t. Before using this\n+ * function, the user must ensure that the first segment is large\n+ * enough to accomodate its data.\n+ *\n+ * @param m\n+ * The packet mbuf.\n+ * @param o\n+ * The offset into the mbuf data.\n+ * @param t\n+ * The type to cast the result into.\n+ */\n+#define rte_pktmbuf_mtod_offset(m, t, o)\t\\\n+\t((t)((char *)(m)->buf_addr + (m)->data_off + (o)))\n+\n+/**\n * A macro that points to the start of the data in the mbuf.\n *\n * The returned pointer is cast to type t. Before using this\n- * function, the user must ensure that m_headlen(m) is large enough to\n- * read its data.\n+ * function, the user must ensure that the first segment is large\n+ * enough to accomodate its data.\n *\n * @param m\n * The packet mbuf.\n * @param t\n * The type to cast the result into.\n */\n-#define rte_pktmbuf_mtod(m, t) ((t)((char *)(m)->buf_addr + (m)->data_off))\n+#define rte_pktmbuf_mtod(m, t) rte_pktmbuf_mtod_offset(m, t, 0)\n \n /**\n * A macro that returns the length of the packet.\n", "prefixes": [ "dpdk-dev", "v3", "08/10" ] }{ "id": 5640, "url": "