summaryrefslogtreecommitdiff
path: root/lib/librte_ip_frag
diff options
context:
space:
mode:
authorOlivier Matz <olivier.matz@6wind.com>2014-09-11 14:15:35 +0100
committerThomas Monjalon <thomas.monjalon@6wind.com>2014-09-17 18:53:40 +0200
commit08b563ffb19d8baf59dd84200f25bc85031d18a7 (patch)
tree3255773d53c7dc983b33936dd3970c0b95137935 /lib/librte_ip_frag
parent7869536f3f8edace05043be6f322b835702b201c (diff)
downloaddpdk-08b563ffb19d8baf59dd84200f25bc85031d18a7.zip
dpdk-08b563ffb19d8baf59dd84200f25bc85031d18a7.tar.gz
dpdk-08b563ffb19d8baf59dd84200f25bc85031d18a7.tar.xz
mbuf: replace data pointer by an offset
The mbuf structure already contains a pointer to the beginning of the buffer (m->buf_addr). It is not needed to use 8 bytes again to store another pointer to the beginning of the data. Using a 16 bits unsigned integer is enough as we know that a mbuf is never longer than 64KB. We gain 6 bytes in the structure thanks to this modification. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> * Updated to apply to latest on mainline. * Disabled vector PMD in config as it relies heavily on the mbuf layout This will be re-enabled in a subsequent commit once vPMD has been reworked to take account of mbuf changes. Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> Acked-by: Olivier Matz <olivier.matz@6wind.com>
Diffstat (limited to 'lib/librte_ip_frag')
-rw-r--r--lib/librte_ip_frag/rte_ipv4_fragmentation.c6
-rw-r--r--lib/librte_ip_frag/rte_ipv6_fragmentation.c6
2 files changed, 6 insertions, 6 deletions
diff --git a/lib/librte_ip_frag/rte_ipv4_fragmentation.c b/lib/librte_ip_frag/rte_ipv4_fragmentation.c
index 6b9f07d..a4ed923 100644
--- a/lib/librte_ip_frag/rte_ipv4_fragmentation.c
+++ b/lib/librte_ip_frag/rte_ipv4_fragmentation.c
@@ -109,7 +109,7 @@ rte_ipv4_fragment_packet(struct rte_mbuf *pkt_in,
/* Fragment size should be a multiply of 8. */
IP_FRAG_ASSERT((frag_size & IPV4_HDR_FO_MASK) == 0);
- in_hdr = (struct ipv4_hdr *) pkt_in->data;
+ in_hdr = rte_pktmbuf_mtod(pkt_in, struct ipv4_hdr *);
flag_offset = rte_cpu_to_be_16(in_hdr->fragment_offset);
/* If Don't Fragment flag is set */
@@ -165,7 +165,7 @@ rte_ipv4_fragment_packet(struct rte_mbuf *pkt_in,
if (len > (in_seg->data_len - in_seg_data_pos)) {
len = in_seg->data_len - in_seg_data_pos;
}
- out_seg->data = (char*) in_seg->data + (uint16_t)in_seg_data_pos;
+ out_seg->data_off = in_seg->data_off + in_seg_data_pos;
out_seg->data_len = (uint16_t)len;
out_pkt->pkt_len = (uint16_t)(len +
out_pkt->pkt_len);
@@ -188,7 +188,7 @@ rte_ipv4_fragment_packet(struct rte_mbuf *pkt_in,
/* Build the IP header */
- out_hdr = (struct ipv4_hdr*) out_pkt->data;
+ out_hdr = rte_pktmbuf_mtod(out_pkt, struct ipv4_hdr *);
__fill_ipv4hdr_frag(out_hdr, in_hdr,
(uint16_t)out_pkt->pkt_len,
diff --git a/lib/librte_ip_frag/rte_ipv6_fragmentation.c b/lib/librte_ip_frag/rte_ipv6_fragmentation.c
index e007662..4ffcc7c 100644
--- a/lib/librte_ip_frag/rte_ipv6_fragmentation.c
+++ b/lib/librte_ip_frag/rte_ipv6_fragmentation.c
@@ -125,7 +125,7 @@ rte_ipv6_fragment_packet(struct rte_mbuf *pkt_in,
(uint16_t)(pkt_in->pkt_len - sizeof (struct ipv6_hdr))))
return (-EINVAL);
- in_hdr = (struct ipv6_hdr *) pkt_in->data;
+ in_hdr = rte_pktmbuf_mtod(pkt_in, struct ipv6_hdr *);
in_seg = pkt_in;
in_seg_data_pos = sizeof(struct ipv6_hdr);
@@ -171,7 +171,7 @@ rte_ipv6_fragment_packet(struct rte_mbuf *pkt_in,
if (len > (in_seg->data_len - in_seg_data_pos)) {
len = in_seg->data_len - in_seg_data_pos;
}
- out_seg->data = (char *) in_seg->data + (uint16_t) in_seg_data_pos;
+ out_seg->data_off = in_seg->data_off + in_seg_data_pos;
out_seg->data_len = (uint16_t)len;
out_pkt->pkt_len = (uint16_t)(len +
out_pkt->pkt_len);
@@ -196,7 +196,7 @@ rte_ipv6_fragment_packet(struct rte_mbuf *pkt_in,
/* Build the IP header */
- out_hdr = (struct ipv6_hdr *) out_pkt->data;
+ out_hdr = rte_pktmbuf_mtod(out_pkt, struct ipv6_hdr *);
__fill_ipv6hdr_frag(out_hdr, in_hdr,
(uint16_t) out_pkt->pkt_len - sizeof(struct ipv6_hdr),