summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorCyril Chemparathy <cchemparathy@ezchip.com>2015-06-22 11:34:23 -0700
committerThomas Monjalon <thomas.monjalon@6wind.com>2015-06-24 12:01:14 +0200
commit82be8d544253a4b5c49b778babf717e5e63f3dc1 (patch)
tree1d9c9300f80d01bdee7b53e944ac9aeb816d6090 /lib
parent3790a7fcf0c3a7548b95927b566240738e2df7ce (diff)
downloaddpdk-82be8d544253a4b5c49b778babf717e5e63f3dc1.zip
dpdk-82be8d544253a4b5c49b778babf717e5e63f3dc1.tar.gz
dpdk-82be8d544253a4b5c49b778babf717e5e63f3dc1.tar.xz
mbuf: use offset macro
This patch simply applies the transform previously committed in scripts/cocci/mtod-offset.cocci. No other modifications have been made here. Signed-off-by: Cyril Chemparathy <cchemparathy@ezchip.com> Acked-by: Olivier Matz <olivier.matz@6wind.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/librte_ip_frag/rte_ipv4_reassembly.c3
-rw-r--r--lib/librte_ip_frag/rte_ipv6_reassembly.c5
-rw-r--r--lib/librte_port/rte_port_ras.c6
-rw-r--r--lib/librte_vhost/vhost_rxtx.c6
4 files changed, 8 insertions, 12 deletions
diff --git a/lib/librte_ip_frag/rte_ipv4_reassembly.c b/lib/librte_ip_frag/rte_ipv4_reassembly.c
index dc4d036..5d24843 100644
--- a/lib/librte_ip_frag/rte_ipv4_reassembly.c
+++ b/lib/librte_ip_frag/rte_ipv4_reassembly.c
@@ -85,8 +85,7 @@ ipv4_frag_reassemble(const struct ip_frag_pkt *fp)
m->ol_flags |= PKT_TX_IP_CKSUM;
/* update ipv4 header for the reassmebled packet */
- ip_hdr = (struct ipv4_hdr*)(rte_pktmbuf_mtod(m, uint8_t *) +
- m->l2_len);
+ ip_hdr = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *, m->l2_len);
ip_hdr->total_length = rte_cpu_to_be_16((uint16_t)(fp->total_size +
m->l3_len));
diff --git a/lib/librte_ip_frag/rte_ipv6_reassembly.c b/lib/librte_ip_frag/rte_ipv6_reassembly.c
index 71cf721..1f1c172 100644
--- a/lib/librte_ip_frag/rte_ipv6_reassembly.c
+++ b/lib/librte_ip_frag/rte_ipv6_reassembly.c
@@ -108,8 +108,7 @@ ipv6_frag_reassemble(const struct ip_frag_pkt *fp)
m->ol_flags |= PKT_TX_IP_CKSUM;
/* update ipv6 header for the reassembled datagram */
- ip_hdr = (struct ipv6_hdr *) (rte_pktmbuf_mtod(m, uint8_t *) +
- m->l2_len);
+ ip_hdr = rte_pktmbuf_mtod_offset(m, struct ipv6_hdr *, m->l2_len);
ip_hdr->payload_len = rte_cpu_to_be_16(payload_len);
@@ -124,7 +123,7 @@ ipv6_frag_reassemble(const struct ip_frag_pkt *fp)
frag_hdr = (struct ipv6_extension_fragment *) (ip_hdr + 1);
ip_hdr->proto = frag_hdr->next_header;
- ip_frag_memmove(rte_pktmbuf_mtod(m, char*) + sizeof(*frag_hdr),
+ ip_frag_memmove(rte_pktmbuf_mtod_offset(m, char *, sizeof(*frag_hdr)),
rte_pktmbuf_mtod(m, char*), move_len);
rte_pktmbuf_adj(m, sizeof(*frag_hdr));
diff --git a/lib/librte_port/rte_port_ras.c b/lib/librte_port/rte_port_ras.c
index 2c1822a..6bd0f8c 100644
--- a/lib/librte_port/rte_port_ras.c
+++ b/lib/librte_port/rte_port_ras.c
@@ -180,8 +180,7 @@ static void
process_ipv4(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt)
{
/* Assume there is no ethernet header */
- struct ipv4_hdr *pkt_hdr = (struct ipv4_hdr *)
- (rte_pktmbuf_mtod(pkt, unsigned char *));
+ struct ipv4_hdr *pkt_hdr = rte_pktmbuf_mtod(pkt, struct ipv4_hdr *);
/* Get "Do not fragment" flag and fragment offset */
uint16_t frag_field = rte_be_to_cpu_16(pkt_hdr->fragment_offset);
@@ -210,8 +209,7 @@ static void
process_ipv6(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt)
{
/* Assume there is no ethernet header */
- struct ipv6_hdr *pkt_hdr = (struct ipv6_hdr *)
- (rte_pktmbuf_mtod(pkt, unsigned char *));
+ struct ipv6_hdr *pkt_hdr = rte_pktmbuf_mtod(pkt, struct ipv6_hdr *);
struct ipv6_extension_fragment *frag_hdr;
frag_hdr = rte_ipv6_frag_get_ipv6_fragment_header(pkt_hdr);
diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c
index 151d781..0d07338 100644
--- a/lib/librte_vhost/vhost_rxtx.c
+++ b/lib/librte_vhost/vhost_rxtx.c
@@ -152,7 +152,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,
while (total_copied < pkt_len) {
/* Copy mbuf data to buffer */
rte_memcpy((void *)(uintptr_t)(buff_addr + vb_offset),
- (const void *)(rte_pktmbuf_mtod(buff, const char *) + offset),
+ rte_pktmbuf_mtod_offset(buff, const void *, offset),
len_to_cpy);
PRINT_PACKET(dev, (uintptr_t)(buff_addr + vb_offset),
len_to_cpy, 0);
@@ -318,7 +318,7 @@ copy_from_mbuf_to_vring(struct virtio_net *dev, uint16_t res_base_idx,
while (cpy_len > 0) {
/* Copy mbuf data to vring buffer */
rte_memcpy((void *)(uintptr_t)(vb_addr + vb_offset),
- (const void *)(rte_pktmbuf_mtod(pkt, char*) + seg_offset),
+ rte_pktmbuf_mtod_offset(pkt, const void *, seg_offset),
cpy_len);
PRINT_PACKET(dev,
@@ -648,7 +648,7 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,
cur = m;
prev = m;
while (cpy_len != 0) {
- rte_memcpy((void *)(rte_pktmbuf_mtod(cur, char *) + seg_offset),
+ rte_memcpy(rte_pktmbuf_mtod_offset(cur, void *, seg_offset),
(void *)((uintptr_t)(vb_addr + vb_offset)),
cpy_len);