get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 5675,
    "url": "https://patches.dpdk.org/api/patches/5675/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1434998063-15739-10-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": "<1434998063-15739-10-git-send-email-cchemparathy@ezchip.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1434998063-15739-10-git-send-email-cchemparathy@ezchip.com",
    "date": "2015-06-22T18:34:23",
    "name": "[dpdk-dev,v4,9/9] librte_mbuf: Apply mtod-offset.cocci transform",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "0e1cdca3322ecfbf91516222f389b20fcf2e48ea",
    "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/1434998063-15739-10-git-send-email-cchemparathy@ezchip.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/5675/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/5675/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 63076C984;\n\tMon, 22 Jun 2015 20:34:58 +0200 (CEST)",
            "from sclab-apps-2.localdomain (sc-fw1.tilera.com [12.218.212.162])\n\tby dpdk.org (Postfix) with ESMTP id 8341EC87A\n\tfor <dev@dpdk.org>; Mon, 22 Jun 2015 20:34:44 +0200 (CEST)",
            "by sclab-apps-2.localdomain (Postfix, from userid 1318)\n\tid CC131220503; Mon, 22 Jun 2015 11:34:29 -0700 (PDT)"
        ],
        "X-CheckPoint": "{55885543-0-A3D4DA0C-C0000002}",
        "From": "Cyril Chemparathy <cchemparathy@ezchip.com>",
        "To": "dev@dpdk.org",
        "Date": "Mon, 22 Jun 2015 11:34:23 -0700",
        "Message-Id": "<1434998063-15739-10-git-send-email-cchemparathy@ezchip.com>",
        "X-Mailer": "git-send-email 2.1.2",
        "In-Reply-To": "<1434998063-15739-1-git-send-email-cchemparathy@ezchip.com>",
        "References": "<1434998063-15739-1-git-send-email-cchemparathy@ezchip.com>",
        "Subject": "[dpdk-dev] [PATCH v4 9/9] librte_mbuf: Apply mtod-offset.cocci\n\ttransform",
        "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": "This patch simply applies the transform previously committed in\nscripts/cocci/mtod-offset.cocci.  No other modifications have been\nmade here.\n\nThis patch applies on commit 960e8a22fc6d9373e37dd1454131e91f082bb8bc.\nThis patch may need to be regenerated by rerunning scripts/cocci.sh\ninstead of simply merging in the change.\n\nAcked-by: Olivier Matz <olivier.matz@6wind.com>\nChange-Id: I1cdc4fe6f7954cebb520e495a9454cb586cace54\nSigned-off-by: Cyril Chemparathy <cchemparathy@ezchip.com>\n---\n app/test-pmd/ieee1588fwd.c               |  4 +-\n app/test-pmd/rxonly.c                    | 21 ++++++----\n app/test-pmd/txonly.c                    |  4 +-\n app/test/packet_burst_generator.c        |  5 ++-\n drivers/net/mlx4/mlx4.c                  |  9 ++--\n examples/dpdk_qat/crypto.c               |  8 ++--\n examples/dpdk_qat/main.c                 |  5 ++-\n examples/l3fwd-acl/main.c                | 20 ++++-----\n examples/l3fwd-power/main.c              |  8 ++--\n examples/l3fwd-vf/main.c                 |  4 +-\n examples/l3fwd/main.c                    | 71 ++++++++++++++------------------\n examples/load_balancer/runtime.c         |  4 +-\n examples/vhost_xen/main.c                |  4 +-\n lib/librte_ip_frag/rte_ipv4_reassembly.c |  3 +-\n lib/librte_ip_frag/rte_ipv6_reassembly.c |  5 +--\n lib/librte_port/rte_port_ras.c           |  6 +--\n lib/librte_vhost/vhost_rxtx.c            |  6 +--\n 17 files changed, 90 insertions(+), 97 deletions(-)",
    "diff": "diff --git a/app/test-pmd/ieee1588fwd.c b/app/test-pmd/ieee1588fwd.c\nindex 84237c1..dfbb185 100644\n--- a/app/test-pmd/ieee1588fwd.c\n+++ b/app/test-pmd/ieee1588fwd.c\n@@ -573,8 +573,8 @@ ieee1588_packet_fwd(struct fwd_stream *fs)\n \t * Check that the received PTP packet is a PTP V2 packet of type\n \t * PTP_SYNC_MESSAGE.\n \t */\n-\tptp_hdr = (struct ptpv2_msg *) (rte_pktmbuf_mtod(mb, char *) +\n-\t\t\t\t\tsizeof(struct ether_hdr));\n+\tptp_hdr = rte_pktmbuf_mtod_offset(mb, struct ptpv2_msg *,\n+\t\t\t\t\t  sizeof(struct ether_hdr));\n \tif (ptp_hdr->version != 0x02) {\n \t\tprintf(\"Port %u Received PTP V2 Ethernet frame with wrong PTP\"\n \t\t       \" protocol version 0x%x (should be 0x02)\\n\",\ndiff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c\nindex ac56090..b8e35ab 100644\n--- a/app/test-pmd/rxonly.c\n+++ b/app/test-pmd/rxonly.c\n@@ -175,22 +175,25 @@ pkt_burst_receive(struct fwd_stream *fs)\n \t\t\t /* Do not support ipv4 option field */\n \t\t\tif (ol_flags & PKT_RX_TUNNEL_IPV4_HDR) {\n \t\t\t\tl3_len = sizeof(struct ipv4_hdr);\n-\t\t\t\tipv4_hdr = (struct ipv4_hdr *) (rte_pktmbuf_mtod(mb,\n-\t\t\t\t\t\tunsigned char *) + l2_len);\n+\t\t\t\tipv4_hdr = rte_pktmbuf_mtod_offset(mb,\n+\t\t\t\t\t\t\t\t   struct ipv4_hdr *,\n+\t\t\t\t\t\t\t\t   l2_len);\n \t\t\t\tl4_proto = ipv4_hdr->next_proto_id;\n \t\t\t} else {\n \t\t\t\tl3_len = sizeof(struct ipv6_hdr);\n-\t\t\t\tipv6_hdr = (struct ipv6_hdr *) (rte_pktmbuf_mtod(mb,\n-\t\t\t\t\t\tunsigned char *) + l2_len);\n+\t\t\t\tipv6_hdr = rte_pktmbuf_mtod_offset(mb,\n+\t\t\t\t\t\t\t\t   struct ipv6_hdr *,\n+\t\t\t\t\t\t\t\t   l2_len);\n \t\t\t\tl4_proto = ipv6_hdr->proto;\n \t\t\t}\n \t\t\tif (l4_proto == IPPROTO_UDP) {\n-\t\t\t\tudp_hdr = (struct udp_hdr *) (rte_pktmbuf_mtod(mb,\n-\t\t\t\t\t\tunsigned char *) + l2_len + l3_len);\n+\t\t\t\tudp_hdr = rte_pktmbuf_mtod_offset(mb,\n+\t\t\t\t\t\t\t\t  struct udp_hdr *,\n+\t\t\t\t\t\t\t\t  l2_len + l3_len);\n \t\t\t\tl4_len = sizeof(struct udp_hdr);\n-\t\t\t\tvxlan_hdr = (struct vxlan_hdr *) (rte_pktmbuf_mtod(mb,\n-\t\t\t\t\t\tunsigned char *) + l2_len + l3_len\n-\t\t\t\t\t\t + l4_len);\n+\t\t\t\tvxlan_hdr = rte_pktmbuf_mtod_offset(mb,\n+\t\t\t\t\t\t\t\t    struct vxlan_hdr *,\n+\t\t\t\t\t\t\t\t    l2_len + l3_len + l4_len);\n \n \t\t\t\tprintf(\" - VXLAN packet: packet type =%d, \"\n \t\t\t\t\t\"Destination UDP port =%d, VNI = %d\",\ndiff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c\nindex 9e66552..f8027f1 100644\n--- a/app/test-pmd/txonly.c\n+++ b/app/test-pmd/txonly.c\n@@ -110,7 +110,7 @@ copy_buf_to_pkt_segs(void* buf, unsigned len, struct rte_mbuf *pkt,\n \t\tseg = seg->next;\n \t}\n \tcopy_len = seg->data_len - offset;\n-\tseg_buf = (rte_pktmbuf_mtod(seg, char *) + offset);\n+\tseg_buf = rte_pktmbuf_mtod_offset(seg, char *, offset);\n \twhile (len > copy_len) {\n \t\trte_memcpy(seg_buf, buf, (size_t) copy_len);\n \t\tlen -= copy_len;\n@@ -125,7 +125,7 @@ static inline void\n copy_buf_to_pkt(void* buf, unsigned len, struct rte_mbuf *pkt, unsigned offset)\n {\n \tif (offset + len <= pkt->data_len) {\n-\t\trte_memcpy((rte_pktmbuf_mtod(pkt, char *) + offset),\n+\t\trte_memcpy(rte_pktmbuf_mtod_offset(pkt, char *, offset),\n \t\t\tbuf, (size_t) len);\n \t\treturn;\n \t}\ndiff --git a/app/test/packet_burst_generator.c b/app/test/packet_burst_generator.c\nindex 06762c6..28d9e25 100644\n--- a/app/test/packet_burst_generator.c\n+++ b/app/test/packet_burst_generator.c\n@@ -59,7 +59,7 @@ copy_buf_to_pkt_segs(void *buf, unsigned len, struct rte_mbuf *pkt,\n \t\tseg = seg->next;\n \t}\n \tcopy_len = seg->data_len - offset;\n-\tseg_buf = rte_pktmbuf_mtod(seg, char *) + offset;\n+\tseg_buf = rte_pktmbuf_mtod_offset(seg, char *, offset);\n \twhile (len > copy_len) {\n \t\trte_memcpy(seg_buf, buf, (size_t) copy_len);\n \t\tlen -= copy_len;\n@@ -74,7 +74,8 @@ static inline void\n copy_buf_to_pkt(void *buf, unsigned len, struct rte_mbuf *pkt, unsigned offset)\n {\n \tif (offset + len <= pkt->data_len) {\n-\t\trte_memcpy(rte_pktmbuf_mtod(pkt, char *) + offset, buf, (size_t) len);\n+\t\trte_memcpy(rte_pktmbuf_mtod_offset(pkt, char *, offset), buf,\n+\t\t\t   (size_t) len);\n \t\treturn;\n \t}\n \tcopy_buf_to_pkt_segs(buf, len, pkt, offset);\ndiff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c\nindex fde23e1..5391b7a 100644\n--- a/drivers/net/mlx4/mlx4.c\n+++ b/drivers/net/mlx4/mlx4.c\n@@ -1104,10 +1104,10 @@ mlx4_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)\n \t\t\tlinearize = 1;\n \t\t}\n \t\t/* Set WR fields. */\n-\t\tassert(((uintptr_t)rte_pktmbuf_mtod(buf, char *) -\n+\t\tassert((rte_pktmbuf_mtod(buf, uintptr_t) -\n \t\t\t(uintptr_t)buf) <= 0xffff);\n \t\tWR_ID(wr->wr_id).offset =\n-\t\t\t((uintptr_t)rte_pktmbuf_mtod(buf, char *) -\n+\t\t\t(rte_pktmbuf_mtod(buf, uintptr_t) -\n \t\t\t (uintptr_t)buf);\n \t\twr->num_sge = segs;\n \t\t/* Register segments as SGEs. */\n@@ -1142,7 +1142,7 @@ mlx4_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)\n \t\t\tassert(sge->length == 0);\n \t\t\tassert(sge->lkey == 0);\n \t\t\t/* Update SGE. */\n-\t\t\tsge->addr = (uintptr_t)rte_pktmbuf_mtod(buf, char *);\n+\t\t\tsge->addr = rte_pktmbuf_mtod(buf, uintptr_t);\n \t\t\tif (txq->priv->vf)\n \t\t\t\trte_prefetch0((volatile void *)\n \t\t\t\t\t(uintptr_t)sge->addr);\n@@ -1593,8 +1593,7 @@ rxq_alloc_elts_sp(struct rxq *rxq, unsigned int elts_n,\n \t\t\tassert(sizeof(sge->addr) >= sizeof(uintptr_t));\n \t\t\tif (j == 0) {\n \t\t\t\t/* The first SGE keeps its headroom. */\n-\t\t\t\tsge->addr = (uintptr_t)rte_pktmbuf_mtod(buf,\n-\t\t\t\t\t\t\t\t\tchar *);\n+\t\t\t\tsge->addr = rte_pktmbuf_mtod(buf, uintptr_t);\n \t\t\t\tsge->length = (buf->buf_len -\n \t\t\t\t\t       RTE_PKTMBUF_HEADROOM);\n \t\t\t} else {\ndiff --git a/examples/dpdk_qat/crypto.c b/examples/dpdk_qat/crypto.c\nindex 00e0eb5..c03ea78 100644\n--- a/examples/dpdk_qat/crypto.c\n+++ b/examples/dpdk_qat/crypto.c\n@@ -772,8 +772,8 @@ enum crypto_result\n crypto_encrypt(struct rte_mbuf *rte_buff, enum cipher_alg c, enum hash_alg h)\n {\n \tCpaCySymDpOpData *opData =\n-\t\t\t(CpaCySymDpOpData *) (rte_pktmbuf_mtod(rte_buff, char *)\n-\t\t\t\t\t+ CRYPTO_OFFSET_TO_OPDATA);\n+\t\t\trte_pktmbuf_mtod_offset(rte_buff, CpaCySymDpOpData *,\n+\t\t\t\t\t\tCRYPTO_OFFSET_TO_OPDATA);\n \tuint32_t lcore_id;\n \n \tif (unlikely(c >= NUM_CRYPTO || h >= NUM_HMAC))\n@@ -847,8 +847,8 @@ enum crypto_result\n crypto_decrypt(struct rte_mbuf *rte_buff, enum cipher_alg c, enum hash_alg h)\n {\n \n-\tCpaCySymDpOpData *opData = (void*) (rte_pktmbuf_mtod(rte_buff, char *)\n-\t\t\t+ CRYPTO_OFFSET_TO_OPDATA);\n+\tCpaCySymDpOpData *opData = rte_pktmbuf_mtod_offset(rte_buff, void *,\n+\t\t\t\t\t\t\t   CRYPTO_OFFSET_TO_OPDATA);\n \tuint32_t lcore_id;\n \n \tif (unlikely(c >= NUM_CRYPTO || h >= NUM_HMAC))\ndiff --git a/examples/dpdk_qat/main.c b/examples/dpdk_qat/main.c\nindex c66a8cc..dc68989 100644\n--- a/examples/dpdk_qat/main.c\n+++ b/examples/dpdk_qat/main.c\n@@ -325,8 +325,9 @@ main_loop(__attribute__((unused)) void *dummy)\n \t\t\tcontinue;\n \t\t/* Send packet to either QAT encrypt, QAT decrypt or NIC TX */\n \t\tif (pkt_from_nic_rx) {\n-\t\t\tstruct ipv4_hdr *ip  = (struct ipv4_hdr *) (rte_pktmbuf_mtod(pkt, unsigned char *) +\n-\t\t\t\t\tsizeof(struct ether_hdr));\n+\t\t\tstruct ipv4_hdr *ip  = rte_pktmbuf_mtod_offset(pkt,\n+\t\t\t\t\t\t\t\t       struct ipv4_hdr *,\n+\t\t\t\t\t\t\t\t       sizeof(struct ether_hdr));\n \t\t\tif (ip->src_addr & rte_cpu_to_be_32(ACTION_ENCRYPT)) {\n \t\t\t\tif (CRYPTO_RESULT_FAIL == crypto_encrypt(pkt,\n \t\t\t\t\t(enum cipher_alg)((ip->src_addr >> 16) & 0xFF),\ndiff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c\nindex a5d4f25..29cb25e 100644\n--- a/examples/l3fwd-acl/main.c\n+++ b/examples/l3fwd-acl/main.c\n@@ -216,9 +216,9 @@ send_single_packet(struct rte_mbuf *m, uint8_t port);\n #define OFF_IPV42PROTO (offsetof(struct ipv4_hdr, next_proto_id))\n #define OFF_IPV62PROTO (offsetof(struct ipv6_hdr, proto))\n #define MBUF_IPV4_2PROTO(m)\t\\\n-\t(rte_pktmbuf_mtod((m), uint8_t *) + OFF_ETHHEAD + OFF_IPV42PROTO)\n+\trte_pktmbuf_mtod_offset((m), uint8_t *, OFF_ETHHEAD + OFF_IPV42PROTO)\n #define MBUF_IPV6_2PROTO(m)\t\\\n-\t(rte_pktmbuf_mtod((m), uint8_t *) + OFF_ETHHEAD + OFF_IPV62PROTO)\n+\trte_pktmbuf_mtod_offset((m), uint8_t *, OFF_ETHHEAD + OFF_IPV62PROTO)\n \n #define GET_CB_FIELD(in, fd, base, lim, dlm)\tdo {            \\\n \tunsigned long val;                                      \\\n@@ -564,9 +564,9 @@ dump_acl4_rule(struct rte_mbuf *m, uint32_t sig)\n {\n \tuint32_t offset = sig & ~ACL_DENY_SIGNATURE;\n \tunsigned char a, b, c, d;\n-\tstruct ipv4_hdr *ipv4_hdr = (struct ipv4_hdr *)\n-\t\t\t\t\t(rte_pktmbuf_mtod(m, unsigned char *) +\n-\t\t\t\t\tsizeof(struct ether_hdr));\n+\tstruct ipv4_hdr *ipv4_hdr = rte_pktmbuf_mtod_offset(m,\n+\t\t\t\t\t\t\t    struct ipv4_hdr *,\n+\t\t\t\t\t\t\t    sizeof(struct ether_hdr));\n \n \tuint32_t_to_char(rte_bswap32(ipv4_hdr->src_addr), &a, &b, &c, &d);\n \tprintf(\"Packet Src:%hhu.%hhu.%hhu.%hhu \", a, b, c, d);\n@@ -588,9 +588,9 @@ dump_acl6_rule(struct rte_mbuf *m, uint32_t sig)\n {\n \tunsigned i;\n \tuint32_t offset = sig & ~ACL_DENY_SIGNATURE;\n-\tstruct ipv6_hdr *ipv6_hdr = (struct ipv6_hdr *)\n-\t\t\t\t\t(rte_pktmbuf_mtod(m, unsigned char *) +\n-\t\t\t\t\tsizeof(struct ether_hdr));\n+\tstruct ipv6_hdr *ipv6_hdr = rte_pktmbuf_mtod_offset(m,\n+\t\t\t\t\t\t\t    struct ipv6_hdr *,\n+\t\t\t\t\t\t\t    sizeof(struct ether_hdr));\n \n \tprintf(\"Packet Src\");\n \tfor (i = 0; i < RTE_DIM(ipv6_hdr->src_addr); i += sizeof(uint16_t))\n@@ -649,8 +649,8 @@ prepare_one_packet(struct rte_mbuf **pkts_in, struct acl_search_t *acl,\n \n \tif (type == PKT_RX_IPV4_HDR) {\n \n-\t\tipv4_hdr = (struct ipv4_hdr *)(rte_pktmbuf_mtod(pkt,\n-\t\t\tunsigned char *) + sizeof(struct ether_hdr));\n+\t\tipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct ipv4_hdr *,\n+\t\t\t\t\t\t   sizeof(struct ether_hdr));\n \n \t\t/* Check to make sure the packet is valid (RFC1812) */\n \t\tif (is_valid_ipv4_pkt(ipv4_hdr, pkt->pkt_len) >= 0) {\ndiff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c\nindex 6057059..d4eba1a 100644\n--- a/examples/l3fwd-power/main.c\n+++ b/examples/l3fwd-power/main.c\n@@ -638,8 +638,8 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid,\n \tif (m->ol_flags & PKT_RX_IPV4_HDR) {\n \t\t/* Handle IPv4 headers.*/\n \t\tipv4_hdr =\n-\t\t\t(struct ipv4_hdr *)(rte_pktmbuf_mtod(m, unsigned char*)\n-\t\t\t\t\t\t+ sizeof(struct ether_hdr));\n+\t\t\trte_pktmbuf_mtod_offset(m, struct ipv4_hdr *,\n+\t\t\t\t\t\tsizeof(struct ether_hdr));\n \n #ifdef DO_RFC_1812_CHECKS\n \t\t/* Check to make sure the packet is valid (RFC1812) */\n@@ -677,8 +677,8 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid,\n \t\tstruct ipv6_hdr *ipv6_hdr;\n \n \t\tipv6_hdr =\n-\t\t\t(struct ipv6_hdr *)(rte_pktmbuf_mtod(m, unsigned char*)\n-\t\t\t\t\t\t+ sizeof(struct ether_hdr));\n+\t\t\trte_pktmbuf_mtod_offset(m, struct ipv6_hdr *,\n+\t\t\t\t\t\tsizeof(struct ether_hdr));\n \n \t\tdst_port = get_ipv6_dst_port(ipv6_hdr, portid,\n \t\t\t\t\tqconf->ipv6_lookup_struct);\ndiff --git a/examples/l3fwd-vf/main.c b/examples/l3fwd-vf/main.c\nindex 6e56cfb..ccbb02f 100644\n--- a/examples/l3fwd-vf/main.c\n+++ b/examples/l3fwd-vf/main.c\n@@ -459,8 +459,8 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid, lookup_struct_t * l3fwd\n \n \teth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);\n \n-\tipv4_hdr = (struct ipv4_hdr *)(rte_pktmbuf_mtod(m, unsigned char *) +\n-\t\t\t\tsizeof(struct ether_hdr));\n+\tipv4_hdr = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *,\n+\t\t\t\t\t   sizeof(struct ether_hdr));\n \n #ifdef DO_RFC_1812_CHECKS\n \t/* Check to make sure the packet is valid (RFC1812) */\ndiff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c\nindex 7e4bbfd..5c22ed1 100644\n--- a/examples/l3fwd/main.c\n+++ b/examples/l3fwd/main.c\n@@ -753,14 +753,14 @@ simple_ipv4_fwd_4pkts(struct rte_mbuf* m[4], uint8_t portid, struct lcore_conf *\n \teth_hdr[3] = rte_pktmbuf_mtod(m[3], struct ether_hdr *);\n \n \t/* Handle IPv4 headers.*/\n-\tipv4_hdr[0] = (struct ipv4_hdr *)(rte_pktmbuf_mtod(m[0], unsigned char *) +\n-\t\t\tsizeof(struct ether_hdr));\n-\tipv4_hdr[1] = (struct ipv4_hdr *)(rte_pktmbuf_mtod(m[1], unsigned char *) +\n-\t\t\tsizeof(struct ether_hdr));\n-\tipv4_hdr[2] = (struct ipv4_hdr *)(rte_pktmbuf_mtod(m[2], unsigned char *) +\n-\t\t\tsizeof(struct ether_hdr));\n-\tipv4_hdr[3] = (struct ipv4_hdr *)(rte_pktmbuf_mtod(m[3], unsigned char *) +\n-\t\t\tsizeof(struct ether_hdr));\n+\tipv4_hdr[0] = rte_pktmbuf_mtod_offset(m[0], struct ipv4_hdr *,\n+\t\t\t\t\t      sizeof(struct ether_hdr));\n+\tipv4_hdr[1] = rte_pktmbuf_mtod_offset(m[1], struct ipv4_hdr *,\n+\t\t\t\t\t      sizeof(struct ether_hdr));\n+\tipv4_hdr[2] = rte_pktmbuf_mtod_offset(m[2], struct ipv4_hdr *,\n+\t\t\t\t\t      sizeof(struct ether_hdr));\n+\tipv4_hdr[3] = rte_pktmbuf_mtod_offset(m[3], struct ipv4_hdr *,\n+\t\t\t\t\t      sizeof(struct ether_hdr));\n \n #ifdef DO_RFC_1812_CHECKS\n \t/* Check to make sure the packet is valid (RFC1812) */\n@@ -796,14 +796,10 @@ simple_ipv4_fwd_4pkts(struct rte_mbuf* m[4], uint8_t portid, struct lcore_conf *\n \t}\n #endif // End of #ifdef DO_RFC_1812_CHECKS\n \n-\tdata[0] = _mm_loadu_si128((__m128i*)(rte_pktmbuf_mtod(m[0], unsigned char *) +\n-\t\tsizeof(struct ether_hdr) + offsetof(struct ipv4_hdr, time_to_live)));\n-\tdata[1] = _mm_loadu_si128((__m128i*)(rte_pktmbuf_mtod(m[1], unsigned char *) +\n-\t\tsizeof(struct ether_hdr) + offsetof(struct ipv4_hdr, time_to_live)));\n-\tdata[2] = _mm_loadu_si128((__m128i*)(rte_pktmbuf_mtod(m[2], unsigned char *) +\n-\t\tsizeof(struct ether_hdr) + offsetof(struct ipv4_hdr, time_to_live)));\n-\tdata[3] = _mm_loadu_si128((__m128i*)(rte_pktmbuf_mtod(m[3], unsigned char *) +\n-\t\tsizeof(struct ether_hdr) + offsetof(struct ipv4_hdr, time_to_live)));\n+\tdata[0] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[0], __m128i *, sizeof(struct ether_hdr) + offsetof(struct ipv4_hdr, time_to_live)));\n+\tdata[1] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[1], __m128i *, sizeof(struct ether_hdr) + offsetof(struct ipv4_hdr, time_to_live)));\n+\tdata[2] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[2], __m128i *, sizeof(struct ether_hdr) + offsetof(struct ipv4_hdr, time_to_live)));\n+\tdata[3] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[3], __m128i *, sizeof(struct ether_hdr) + offsetof(struct ipv4_hdr, time_to_live)));\n \n \tkey[0].xmm = _mm_and_si128(data[0], mask0);\n \tkey[1].xmm = _mm_and_si128(data[1], mask0);\n@@ -860,14 +856,9 @@ simple_ipv4_fwd_4pkts(struct rte_mbuf* m[4], uint8_t portid, struct lcore_conf *\n static inline void get_ipv6_5tuple(struct rte_mbuf* m0, __m128i mask0, __m128i mask1,\n \t\t\t\t union ipv6_5tuple_host * key)\n {\n-        __m128i tmpdata0 = _mm_loadu_si128((__m128i*)(rte_pktmbuf_mtod(m0, unsigned char *)\n-\t\t\t+ sizeof(struct ether_hdr) + offsetof(struct ipv6_hdr, payload_len)));\n-        __m128i tmpdata1 = _mm_loadu_si128((__m128i*)(rte_pktmbuf_mtod(m0, unsigned char *)\n-\t\t\t+ sizeof(struct ether_hdr) + offsetof(struct ipv6_hdr, payload_len)\n-\t\t\t+  sizeof(__m128i)));\n-        __m128i tmpdata2 = _mm_loadu_si128((__m128i*)(rte_pktmbuf_mtod(m0, unsigned char *)\n-\t\t\t+ sizeof(struct ether_hdr) + offsetof(struct ipv6_hdr, payload_len)\n-\t\t\t+ sizeof(__m128i) + sizeof(__m128i)));\n+        __m128i tmpdata0 = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m0, __m128i *, sizeof(struct ether_hdr) + offsetof(struct ipv6_hdr, payload_len)));\n+        __m128i tmpdata1 = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m0, __m128i *, sizeof(struct ether_hdr) + offsetof(struct ipv6_hdr, payload_len) + sizeof(__m128i)));\n+        __m128i tmpdata2 = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m0, __m128i *, sizeof(struct ether_hdr) + offsetof(struct ipv6_hdr, payload_len) + sizeof(__m128i) + sizeof(__m128i)));\n         key->xmm[0] = _mm_and_si128(tmpdata0, mask0);\n         key->xmm[1] = tmpdata1;\n         key->xmm[2] = _mm_and_si128(tmpdata2, mask1);\n@@ -889,14 +880,14 @@ simple_ipv6_fwd_4pkts(struct rte_mbuf* m[4], uint8_t portid, struct lcore_conf *\n \teth_hdr[3] = rte_pktmbuf_mtod(m[3], struct ether_hdr *);\n \n \t/* Handle IPv6 headers.*/\n-\tipv6_hdr[0] = (struct ipv6_hdr *)(rte_pktmbuf_mtod(m[0], unsigned char *) +\n-\t\t\tsizeof(struct ether_hdr));\n-\tipv6_hdr[1] = (struct ipv6_hdr *)(rte_pktmbuf_mtod(m[1], unsigned char *) +\n-\t\t\tsizeof(struct ether_hdr));\n-\tipv6_hdr[2] = (struct ipv6_hdr *)(rte_pktmbuf_mtod(m[2], unsigned char *) +\n-\t\t\tsizeof(struct ether_hdr));\n-\tipv6_hdr[3] = (struct ipv6_hdr *)(rte_pktmbuf_mtod(m[3], unsigned char *) +\n-\t\t\tsizeof(struct ether_hdr));\n+\tipv6_hdr[0] = rte_pktmbuf_mtod_offset(m[0], struct ipv6_hdr *,\n+\t\t\t\t\t      sizeof(struct ether_hdr));\n+\tipv6_hdr[1] = rte_pktmbuf_mtod_offset(m[1], struct ipv6_hdr *,\n+\t\t\t\t\t      sizeof(struct ether_hdr));\n+\tipv6_hdr[2] = rte_pktmbuf_mtod_offset(m[2], struct ipv6_hdr *,\n+\t\t\t\t\t      sizeof(struct ether_hdr));\n+\tipv6_hdr[3] = rte_pktmbuf_mtod_offset(m[3], struct ipv6_hdr *,\n+\t\t\t\t\t      sizeof(struct ether_hdr));\n \n \tget_ipv6_5tuple(m[0], mask1, mask2, &key[0]);\n \tget_ipv6_5tuple(m[1], mask1, mask2, &key[1]);\n@@ -950,8 +941,8 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid, struct lcore_conf *qcon\n \n \tif (m->ol_flags & PKT_RX_IPV4_HDR) {\n \t\t/* Handle IPv4 headers.*/\n-\t\tipv4_hdr = (struct ipv4_hdr *)(rte_pktmbuf_mtod(m, unsigned char *) +\n-\t\t\t\tsizeof(struct ether_hdr));\n+\t\tipv4_hdr = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *,\n+\t\t\t\t\t\t   sizeof(struct ether_hdr));\n \n #ifdef DO_RFC_1812_CHECKS\n \t\t/* Check to make sure the packet is valid (RFC1812) */\n@@ -984,8 +975,8 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid, struct lcore_conf *qcon\n \t\t/* Handle IPv6 headers.*/\n \t\tstruct ipv6_hdr *ipv6_hdr;\n \n-\t\tipv6_hdr = (struct ipv6_hdr *)(rte_pktmbuf_mtod(m, unsigned char *) +\n-\t\t\t\tsizeof(struct ether_hdr));\n+\t\tipv6_hdr = rte_pktmbuf_mtod_offset(m, struct ipv6_hdr *,\n+\t\t\t\t\t\t   sizeof(struct ether_hdr));\n \n \t\tdst_port = get_ipv6_dst_port(ipv6_hdr, portid, qconf->ipv6_lookup_struct);\n \n@@ -1174,10 +1165,10 @@ processx4_step3(struct rte_mbuf *pkt[FWDSTEP], uint16_t dst_port[FWDSTEP])\n \t__m128i ve[FWDSTEP];\n \t__m128i *p[FWDSTEP];\n \n-\tp[0] = (rte_pktmbuf_mtod(pkt[0], __m128i *));\n-\tp[1] = (rte_pktmbuf_mtod(pkt[1], __m128i *));\n-\tp[2] = (rte_pktmbuf_mtod(pkt[2], __m128i *));\n-\tp[3] = (rte_pktmbuf_mtod(pkt[3], __m128i *));\n+\tp[0] = rte_pktmbuf_mtod(pkt[0], __m128i *);\n+\tp[1] = rte_pktmbuf_mtod(pkt[1], __m128i *);\n+\tp[2] = rte_pktmbuf_mtod(pkt[2], __m128i *);\n+\tp[3] = rte_pktmbuf_mtod(pkt[3], __m128i *);\n \n \tve[0] = val_eth[dst_port[0]];\n \tte[0] = _mm_load_si128(p[0]);\ndiff --git a/examples/load_balancer/runtime.c b/examples/load_balancer/runtime.c\nindex adec4ba..2b265c2 100644\n--- a/examples/load_balancer/runtime.c\n+++ b/examples/load_balancer/runtime.c\n@@ -535,7 +535,9 @@ app_lcore_worker(\n \t\t\t}\n \n \t\t\tpkt = lp->mbuf_in.array[j];\n-\t\t\tipv4_hdr = (struct ipv4_hdr *)(rte_pktmbuf_mtod(pkt, unsigned char *) + sizeof(struct ether_hdr));\n+\t\t\tipv4_hdr = rte_pktmbuf_mtod_offset(pkt,\n+\t\t\t\t\t\t\t   struct ipv4_hdr *,\n+\t\t\t\t\t\t\t   sizeof(struct ether_hdr));\n \t\t\tipv4_dst = rte_be_to_cpu_32(ipv4_hdr->dst_addr);\n \n \t\t\tif (unlikely(rte_lpm_lookup(lp->lpm_table, ipv4_dst, &port) != 0)) {\ndiff --git a/examples/vhost_xen/main.c b/examples/vhost_xen/main.c\nindex 9e6f18e..5d20700 100644\n--- a/examples/vhost_xen/main.c\n+++ b/examples/vhost_xen/main.c\n@@ -873,8 +873,8 @@ virtio_tx_route(struct virtio_net* dev, struct rte_mbuf *m, struct rte_mempool *\n \tvlan_hdr->h_vlan_TCI = htons(vlan_tag);\n \n \t/* Copy the remaining packet contents to the mbuf. */\n-\trte_memcpy((void *)(rte_pktmbuf_mtod(mbuf, uint8_t *) + VLAN_ETH_HLEN),\n-\t\t(const void *)(rte_pktmbuf_mtod(m, uint8_t *) + ETH_HLEN),\n+\trte_memcpy(rte_pktmbuf_mtod_offset(mbuf, void *, VLAN_ETH_HLEN),\n+\t\trte_pktmbuf_mtod_offset(m, const void *, ETH_HLEN),\n \t\t(m->data_len - ETH_HLEN));\n \ttx_q->m_table[len] = mbuf;\n \tlen++;\ndiff --git a/lib/librte_ip_frag/rte_ipv4_reassembly.c b/lib/librte_ip_frag/rte_ipv4_reassembly.c\nindex 279be6c..14bab91 100644\n--- a/lib/librte_ip_frag/rte_ipv4_reassembly.c\n+++ b/lib/librte_ip_frag/rte_ipv4_reassembly.c\n@@ -85,8 +85,7 @@ ipv4_frag_reassemble(const struct ip_frag_pkt *fp)\n \tm->ol_flags |= PKT_TX_IP_CKSUM;\n \n \t/* update ipv4 header for the reassmebled packet */\n-\tip_hdr = (struct ipv4_hdr*)(rte_pktmbuf_mtod(m, uint8_t *) +\n-\t\tm->l2_len);\n+\tip_hdr = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *, m->l2_len);\n \n \tip_hdr->total_length = rte_cpu_to_be_16((uint16_t)(fp->total_size +\n \t\tm->l3_len));\ndiff --git a/lib/librte_ip_frag/rte_ipv6_reassembly.c b/lib/librte_ip_frag/rte_ipv6_reassembly.c\nindex 71cf721..1f1c172 100644\n--- a/lib/librte_ip_frag/rte_ipv6_reassembly.c\n+++ b/lib/librte_ip_frag/rte_ipv6_reassembly.c\n@@ -108,8 +108,7 @@ ipv6_frag_reassemble(const struct ip_frag_pkt *fp)\n \tm->ol_flags |= PKT_TX_IP_CKSUM;\n \n \t/* update ipv6 header for the reassembled datagram */\n-\tip_hdr = (struct ipv6_hdr *) (rte_pktmbuf_mtod(m, uint8_t *) +\n-\t\t\t\t\t\t\t\t  m->l2_len);\n+\tip_hdr = rte_pktmbuf_mtod_offset(m, struct ipv6_hdr *, m->l2_len);\n \n \tip_hdr->payload_len = rte_cpu_to_be_16(payload_len);\n \n@@ -124,7 +123,7 @@ ipv6_frag_reassemble(const struct ip_frag_pkt *fp)\n \tfrag_hdr = (struct ipv6_extension_fragment *) (ip_hdr + 1);\n \tip_hdr->proto = frag_hdr->next_header;\n \n-\tip_frag_memmove(rte_pktmbuf_mtod(m, char*) + sizeof(*frag_hdr),\n+\tip_frag_memmove(rte_pktmbuf_mtod_offset(m, char *, sizeof(*frag_hdr)),\n \t\t\trte_pktmbuf_mtod(m, char*), move_len);\n \n \trte_pktmbuf_adj(m, sizeof(*frag_hdr));\ndiff --git a/lib/librte_port/rte_port_ras.c b/lib/librte_port/rte_port_ras.c\nindex 5eb627a..d2edc6a 100644\n--- a/lib/librte_port/rte_port_ras.c\n+++ b/lib/librte_port/rte_port_ras.c\n@@ -163,8 +163,7 @@ static void\n process_ipv4(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt)\n {\n \t/* Assume there is no ethernet header */\n-\tstruct ipv4_hdr *pkt_hdr = (struct ipv4_hdr *)\n-\t\t\t(rte_pktmbuf_mtod(pkt, unsigned char *));\n+\tstruct ipv4_hdr *pkt_hdr = rte_pktmbuf_mtod(pkt, struct ipv4_hdr *);\n \n \t/* Get \"Do not fragment\" flag and fragment offset */\n \tuint16_t frag_field = rte_be_to_cpu_16(pkt_hdr->fragment_offset);\n@@ -193,8 +192,7 @@ static void\n process_ipv6(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt)\n {\n \t/* Assume there is no ethernet header */\n-\tstruct ipv6_hdr *pkt_hdr = (struct ipv6_hdr *)\n-\t\t\t(rte_pktmbuf_mtod(pkt, unsigned char *));\n+\tstruct ipv6_hdr *pkt_hdr = rte_pktmbuf_mtod(pkt, struct ipv6_hdr *);\n \n \tstruct ipv6_extension_fragment *frag_hdr;\n \tfrag_hdr = rte_ipv6_frag_get_ipv6_fragment_header(pkt_hdr);\ndiff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c\nindex 151d781..0d07338 100644\n--- a/lib/librte_vhost/vhost_rxtx.c\n+++ b/lib/librte_vhost/vhost_rxtx.c\n@@ -152,7 +152,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,\n \t\twhile (total_copied < pkt_len) {\n \t\t\t/* Copy mbuf data to buffer */\n \t\t\trte_memcpy((void *)(uintptr_t)(buff_addr + vb_offset),\n-\t\t\t\t(const void *)(rte_pktmbuf_mtod(buff, const char *) + offset),\n+\t\t\t\trte_pktmbuf_mtod_offset(buff, const void *, offset),\n \t\t\t\tlen_to_cpy);\n \t\t\tPRINT_PACKET(dev, (uintptr_t)(buff_addr + vb_offset),\n \t\t\t\tlen_to_cpy, 0);\n@@ -318,7 +318,7 @@ copy_from_mbuf_to_vring(struct virtio_net *dev, uint16_t res_base_idx,\n \twhile (cpy_len > 0) {\n \t\t/* Copy mbuf data to vring buffer */\n \t\trte_memcpy((void *)(uintptr_t)(vb_addr + vb_offset),\n-\t\t\t(const void *)(rte_pktmbuf_mtod(pkt, char*) + seg_offset),\n+\t\t\trte_pktmbuf_mtod_offset(pkt, const void *, seg_offset),\n \t\t\tcpy_len);\n \n \t\tPRINT_PACKET(dev,\n@@ -648,7 +648,7 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,\n \t\tcur = m;\n \t\tprev = m;\n \t\twhile (cpy_len != 0) {\n-\t\t\trte_memcpy((void *)(rte_pktmbuf_mtod(cur, char *) + seg_offset),\n+\t\t\trte_memcpy(rte_pktmbuf_mtod_offset(cur, void *, seg_offset),\n \t\t\t\t(void *)((uintptr_t)(vb_addr + vb_offset)),\n \t\t\t\tcpy_len);\n \n",
    "prefixes": [
        "dpdk-dev",
        "v4",
        "9/9"
    ]
}