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>
This commit is contained in:
parent
3790a7fcf0
commit
82be8d5442
@ -573,8 +573,8 @@ ieee1588_packet_fwd(struct fwd_stream *fs)
|
||||
* Check that the received PTP packet is a PTP V2 packet of type
|
||||
* PTP_SYNC_MESSAGE.
|
||||
*/
|
||||
ptp_hdr = (struct ptpv2_msg *) (rte_pktmbuf_mtod(mb, char *) +
|
||||
sizeof(struct ether_hdr));
|
||||
ptp_hdr = rte_pktmbuf_mtod_offset(mb, struct ptpv2_msg *,
|
||||
sizeof(struct ether_hdr));
|
||||
if (ptp_hdr->version != 0x02) {
|
||||
printf("Port %u Received PTP V2 Ethernet frame with wrong PTP"
|
||||
" protocol version 0x%x (should be 0x02)\n",
|
||||
|
@ -175,22 +175,25 @@ pkt_burst_receive(struct fwd_stream *fs)
|
||||
/* Do not support ipv4 option field */
|
||||
if (ol_flags & PKT_RX_TUNNEL_IPV4_HDR) {
|
||||
l3_len = sizeof(struct ipv4_hdr);
|
||||
ipv4_hdr = (struct ipv4_hdr *) (rte_pktmbuf_mtod(mb,
|
||||
unsigned char *) + l2_len);
|
||||
ipv4_hdr = rte_pktmbuf_mtod_offset(mb,
|
||||
struct ipv4_hdr *,
|
||||
l2_len);
|
||||
l4_proto = ipv4_hdr->next_proto_id;
|
||||
} else {
|
||||
l3_len = sizeof(struct ipv6_hdr);
|
||||
ipv6_hdr = (struct ipv6_hdr *) (rte_pktmbuf_mtod(mb,
|
||||
unsigned char *) + l2_len);
|
||||
ipv6_hdr = rte_pktmbuf_mtod_offset(mb,
|
||||
struct ipv6_hdr *,
|
||||
l2_len);
|
||||
l4_proto = ipv6_hdr->proto;
|
||||
}
|
||||
if (l4_proto == IPPROTO_UDP) {
|
||||
udp_hdr = (struct udp_hdr *) (rte_pktmbuf_mtod(mb,
|
||||
unsigned char *) + l2_len + l3_len);
|
||||
udp_hdr = rte_pktmbuf_mtod_offset(mb,
|
||||
struct udp_hdr *,
|
||||
l2_len + l3_len);
|
||||
l4_len = sizeof(struct udp_hdr);
|
||||
vxlan_hdr = (struct vxlan_hdr *) (rte_pktmbuf_mtod(mb,
|
||||
unsigned char *) + l2_len + l3_len
|
||||
+ l4_len);
|
||||
vxlan_hdr = rte_pktmbuf_mtod_offset(mb,
|
||||
struct vxlan_hdr *,
|
||||
l2_len + l3_len + l4_len);
|
||||
|
||||
printf(" - VXLAN packet: packet type =%d, "
|
||||
"Destination UDP port =%d, VNI = %d",
|
||||
|
@ -110,7 +110,7 @@ copy_buf_to_pkt_segs(void* buf, unsigned len, struct rte_mbuf *pkt,
|
||||
seg = seg->next;
|
||||
}
|
||||
copy_len = seg->data_len - offset;
|
||||
seg_buf = (rte_pktmbuf_mtod(seg, char *) + offset);
|
||||
seg_buf = rte_pktmbuf_mtod_offset(seg, char *, offset);
|
||||
while (len > copy_len) {
|
||||
rte_memcpy(seg_buf, buf, (size_t) copy_len);
|
||||
len -= copy_len;
|
||||
@ -125,7 +125,7 @@ static inline void
|
||||
copy_buf_to_pkt(void* buf, unsigned len, struct rte_mbuf *pkt, unsigned offset)
|
||||
{
|
||||
if (offset + len <= pkt->data_len) {
|
||||
rte_memcpy((rte_pktmbuf_mtod(pkt, char *) + offset),
|
||||
rte_memcpy(rte_pktmbuf_mtod_offset(pkt, char *, offset),
|
||||
buf, (size_t) len);
|
||||
return;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ copy_buf_to_pkt_segs(void *buf, unsigned len, struct rte_mbuf *pkt,
|
||||
seg = seg->next;
|
||||
}
|
||||
copy_len = seg->data_len - offset;
|
||||
seg_buf = rte_pktmbuf_mtod(seg, char *) + offset;
|
||||
seg_buf = rte_pktmbuf_mtod_offset(seg, char *, offset);
|
||||
while (len > copy_len) {
|
||||
rte_memcpy(seg_buf, buf, (size_t) copy_len);
|
||||
len -= copy_len;
|
||||
@ -74,7 +74,8 @@ static inline void
|
||||
copy_buf_to_pkt(void *buf, unsigned len, struct rte_mbuf *pkt, unsigned offset)
|
||||
{
|
||||
if (offset + len <= pkt->data_len) {
|
||||
rte_memcpy(rte_pktmbuf_mtod(pkt, char *) + offset, buf, (size_t) len);
|
||||
rte_memcpy(rte_pktmbuf_mtod_offset(pkt, char *, offset), buf,
|
||||
(size_t) len);
|
||||
return;
|
||||
}
|
||||
copy_buf_to_pkt_segs(buf, len, pkt, offset);
|
||||
|
@ -1104,10 +1104,10 @@ mlx4_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
|
||||
linearize = 1;
|
||||
}
|
||||
/* Set WR fields. */
|
||||
assert(((uintptr_t)rte_pktmbuf_mtod(buf, char *) -
|
||||
assert((rte_pktmbuf_mtod(buf, uintptr_t) -
|
||||
(uintptr_t)buf) <= 0xffff);
|
||||
WR_ID(wr->wr_id).offset =
|
||||
((uintptr_t)rte_pktmbuf_mtod(buf, char *) -
|
||||
(rte_pktmbuf_mtod(buf, uintptr_t) -
|
||||
(uintptr_t)buf);
|
||||
wr->num_sge = segs;
|
||||
/* Register segments as SGEs. */
|
||||
@ -1142,7 +1142,7 @@ mlx4_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
|
||||
assert(sge->length == 0);
|
||||
assert(sge->lkey == 0);
|
||||
/* Update SGE. */
|
||||
sge->addr = (uintptr_t)rte_pktmbuf_mtod(buf, char *);
|
||||
sge->addr = rte_pktmbuf_mtod(buf, uintptr_t);
|
||||
if (txq->priv->vf)
|
||||
rte_prefetch0((volatile void *)
|
||||
(uintptr_t)sge->addr);
|
||||
@ -1593,8 +1593,7 @@ rxq_alloc_elts_sp(struct rxq *rxq, unsigned int elts_n,
|
||||
assert(sizeof(sge->addr) >= sizeof(uintptr_t));
|
||||
if (j == 0) {
|
||||
/* The first SGE keeps its headroom. */
|
||||
sge->addr = (uintptr_t)rte_pktmbuf_mtod(buf,
|
||||
char *);
|
||||
sge->addr = rte_pktmbuf_mtod(buf, uintptr_t);
|
||||
sge->length = (buf->buf_len -
|
||||
RTE_PKTMBUF_HEADROOM);
|
||||
} else {
|
||||
|
@ -772,8 +772,8 @@ enum crypto_result
|
||||
crypto_encrypt(struct rte_mbuf *rte_buff, enum cipher_alg c, enum hash_alg h)
|
||||
{
|
||||
CpaCySymDpOpData *opData =
|
||||
(CpaCySymDpOpData *) (rte_pktmbuf_mtod(rte_buff, char *)
|
||||
+ CRYPTO_OFFSET_TO_OPDATA);
|
||||
rte_pktmbuf_mtod_offset(rte_buff, CpaCySymDpOpData *,
|
||||
CRYPTO_OFFSET_TO_OPDATA);
|
||||
uint32_t lcore_id;
|
||||
|
||||
if (unlikely(c >= NUM_CRYPTO || h >= NUM_HMAC))
|
||||
@ -847,8 +847,8 @@ enum crypto_result
|
||||
crypto_decrypt(struct rte_mbuf *rte_buff, enum cipher_alg c, enum hash_alg h)
|
||||
{
|
||||
|
||||
CpaCySymDpOpData *opData = (void*) (rte_pktmbuf_mtod(rte_buff, char *)
|
||||
+ CRYPTO_OFFSET_TO_OPDATA);
|
||||
CpaCySymDpOpData *opData = rte_pktmbuf_mtod_offset(rte_buff, void *,
|
||||
CRYPTO_OFFSET_TO_OPDATA);
|
||||
uint32_t lcore_id;
|
||||
|
||||
if (unlikely(c >= NUM_CRYPTO || h >= NUM_HMAC))
|
||||
|
@ -325,8 +325,9 @@ main_loop(__attribute__((unused)) void *dummy)
|
||||
continue;
|
||||
/* Send packet to either QAT encrypt, QAT decrypt or NIC TX */
|
||||
if (pkt_from_nic_rx) {
|
||||
struct ipv4_hdr *ip = (struct ipv4_hdr *) (rte_pktmbuf_mtod(pkt, unsigned char *) +
|
||||
sizeof(struct ether_hdr));
|
||||
struct ipv4_hdr *ip = rte_pktmbuf_mtod_offset(pkt,
|
||||
struct ipv4_hdr *,
|
||||
sizeof(struct ether_hdr));
|
||||
if (ip->src_addr & rte_cpu_to_be_32(ACTION_ENCRYPT)) {
|
||||
if (CRYPTO_RESULT_FAIL == crypto_encrypt(pkt,
|
||||
(enum cipher_alg)((ip->src_addr >> 16) & 0xFF),
|
||||
|
@ -216,9 +216,9 @@ send_single_packet(struct rte_mbuf *m, uint8_t port);
|
||||
#define OFF_IPV42PROTO (offsetof(struct ipv4_hdr, next_proto_id))
|
||||
#define OFF_IPV62PROTO (offsetof(struct ipv6_hdr, proto))
|
||||
#define MBUF_IPV4_2PROTO(m) \
|
||||
(rte_pktmbuf_mtod((m), uint8_t *) + OFF_ETHHEAD + OFF_IPV42PROTO)
|
||||
rte_pktmbuf_mtod_offset((m), uint8_t *, OFF_ETHHEAD + OFF_IPV42PROTO)
|
||||
#define MBUF_IPV6_2PROTO(m) \
|
||||
(rte_pktmbuf_mtod((m), uint8_t *) + OFF_ETHHEAD + OFF_IPV62PROTO)
|
||||
rte_pktmbuf_mtod_offset((m), uint8_t *, OFF_ETHHEAD + OFF_IPV62PROTO)
|
||||
|
||||
#define GET_CB_FIELD(in, fd, base, lim, dlm) do { \
|
||||
unsigned long val; \
|
||||
@ -564,9 +564,9 @@ dump_acl4_rule(struct rte_mbuf *m, uint32_t sig)
|
||||
{
|
||||
uint32_t offset = sig & ~ACL_DENY_SIGNATURE;
|
||||
unsigned char a, b, c, d;
|
||||
struct ipv4_hdr *ipv4_hdr = (struct ipv4_hdr *)
|
||||
(rte_pktmbuf_mtod(m, unsigned char *) +
|
||||
sizeof(struct ether_hdr));
|
||||
struct ipv4_hdr *ipv4_hdr = rte_pktmbuf_mtod_offset(m,
|
||||
struct ipv4_hdr *,
|
||||
sizeof(struct ether_hdr));
|
||||
|
||||
uint32_t_to_char(rte_bswap32(ipv4_hdr->src_addr), &a, &b, &c, &d);
|
||||
printf("Packet Src:%hhu.%hhu.%hhu.%hhu ", a, b, c, d);
|
||||
@ -588,9 +588,9 @@ dump_acl6_rule(struct rte_mbuf *m, uint32_t sig)
|
||||
{
|
||||
unsigned i;
|
||||
uint32_t offset = sig & ~ACL_DENY_SIGNATURE;
|
||||
struct ipv6_hdr *ipv6_hdr = (struct ipv6_hdr *)
|
||||
(rte_pktmbuf_mtod(m, unsigned char *) +
|
||||
sizeof(struct ether_hdr));
|
||||
struct ipv6_hdr *ipv6_hdr = rte_pktmbuf_mtod_offset(m,
|
||||
struct ipv6_hdr *,
|
||||
sizeof(struct ether_hdr));
|
||||
|
||||
printf("Packet Src");
|
||||
for (i = 0; i < RTE_DIM(ipv6_hdr->src_addr); i += sizeof(uint16_t))
|
||||
@ -649,8 +649,8 @@ prepare_one_packet(struct rte_mbuf **pkts_in, struct acl_search_t *acl,
|
||||
|
||||
if (type == PKT_RX_IPV4_HDR) {
|
||||
|
||||
ipv4_hdr = (struct ipv4_hdr *)(rte_pktmbuf_mtod(pkt,
|
||||
unsigned char *) + sizeof(struct ether_hdr));
|
||||
ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct ipv4_hdr *,
|
||||
sizeof(struct ether_hdr));
|
||||
|
||||
/* Check to make sure the packet is valid (RFC1812) */
|
||||
if (is_valid_ipv4_pkt(ipv4_hdr, pkt->pkt_len) >= 0) {
|
||||
|
@ -638,8 +638,8 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid,
|
||||
if (m->ol_flags & PKT_RX_IPV4_HDR) {
|
||||
/* Handle IPv4 headers.*/
|
||||
ipv4_hdr =
|
||||
(struct ipv4_hdr *)(rte_pktmbuf_mtod(m, unsigned char*)
|
||||
+ sizeof(struct ether_hdr));
|
||||
rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *,
|
||||
sizeof(struct ether_hdr));
|
||||
|
||||
#ifdef DO_RFC_1812_CHECKS
|
||||
/* Check to make sure the packet is valid (RFC1812) */
|
||||
@ -677,8 +677,8 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid,
|
||||
struct ipv6_hdr *ipv6_hdr;
|
||||
|
||||
ipv6_hdr =
|
||||
(struct ipv6_hdr *)(rte_pktmbuf_mtod(m, unsigned char*)
|
||||
+ sizeof(struct ether_hdr));
|
||||
rte_pktmbuf_mtod_offset(m, struct ipv6_hdr *,
|
||||
sizeof(struct ether_hdr));
|
||||
|
||||
dst_port = get_ipv6_dst_port(ipv6_hdr, portid,
|
||||
qconf->ipv6_lookup_struct);
|
||||
|
@ -459,8 +459,8 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid, lookup_struct_t * l3fwd
|
||||
|
||||
eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);
|
||||
|
||||
ipv4_hdr = (struct ipv4_hdr *)(rte_pktmbuf_mtod(m, unsigned char *) +
|
||||
sizeof(struct ether_hdr));
|
||||
ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *,
|
||||
sizeof(struct ether_hdr));
|
||||
|
||||
#ifdef DO_RFC_1812_CHECKS
|
||||
/* Check to make sure the packet is valid (RFC1812) */
|
||||
|
@ -753,14 +753,14 @@ simple_ipv4_fwd_4pkts(struct rte_mbuf* m[4], uint8_t portid, struct lcore_conf *
|
||||
eth_hdr[3] = rte_pktmbuf_mtod(m[3], struct ether_hdr *);
|
||||
|
||||
/* Handle IPv4 headers.*/
|
||||
ipv4_hdr[0] = (struct ipv4_hdr *)(rte_pktmbuf_mtod(m[0], unsigned char *) +
|
||||
sizeof(struct ether_hdr));
|
||||
ipv4_hdr[1] = (struct ipv4_hdr *)(rte_pktmbuf_mtod(m[1], unsigned char *) +
|
||||
sizeof(struct ether_hdr));
|
||||
ipv4_hdr[2] = (struct ipv4_hdr *)(rte_pktmbuf_mtod(m[2], unsigned char *) +
|
||||
sizeof(struct ether_hdr));
|
||||
ipv4_hdr[3] = (struct ipv4_hdr *)(rte_pktmbuf_mtod(m[3], unsigned char *) +
|
||||
sizeof(struct ether_hdr));
|
||||
ipv4_hdr[0] = rte_pktmbuf_mtod_offset(m[0], struct ipv4_hdr *,
|
||||
sizeof(struct ether_hdr));
|
||||
ipv4_hdr[1] = rte_pktmbuf_mtod_offset(m[1], struct ipv4_hdr *,
|
||||
sizeof(struct ether_hdr));
|
||||
ipv4_hdr[2] = rte_pktmbuf_mtod_offset(m[2], struct ipv4_hdr *,
|
||||
sizeof(struct ether_hdr));
|
||||
ipv4_hdr[3] = rte_pktmbuf_mtod_offset(m[3], struct ipv4_hdr *,
|
||||
sizeof(struct ether_hdr));
|
||||
|
||||
#ifdef DO_RFC_1812_CHECKS
|
||||
/* Check to make sure the packet is valid (RFC1812) */
|
||||
@ -796,14 +796,10 @@ simple_ipv4_fwd_4pkts(struct rte_mbuf* m[4], uint8_t portid, struct lcore_conf *
|
||||
}
|
||||
#endif // End of #ifdef DO_RFC_1812_CHECKS
|
||||
|
||||
data[0] = _mm_loadu_si128((__m128i*)(rte_pktmbuf_mtod(m[0], unsigned char *) +
|
||||
sizeof(struct ether_hdr) + offsetof(struct ipv4_hdr, time_to_live)));
|
||||
data[1] = _mm_loadu_si128((__m128i*)(rte_pktmbuf_mtod(m[1], unsigned char *) +
|
||||
sizeof(struct ether_hdr) + offsetof(struct ipv4_hdr, time_to_live)));
|
||||
data[2] = _mm_loadu_si128((__m128i*)(rte_pktmbuf_mtod(m[2], unsigned char *) +
|
||||
sizeof(struct ether_hdr) + offsetof(struct ipv4_hdr, time_to_live)));
|
||||
data[3] = _mm_loadu_si128((__m128i*)(rte_pktmbuf_mtod(m[3], unsigned char *) +
|
||||
sizeof(struct ether_hdr) + offsetof(struct ipv4_hdr, time_to_live)));
|
||||
data[0] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[0], __m128i *, sizeof(struct ether_hdr) + offsetof(struct ipv4_hdr, time_to_live)));
|
||||
data[1] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[1], __m128i *, sizeof(struct ether_hdr) + offsetof(struct ipv4_hdr, time_to_live)));
|
||||
data[2] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[2], __m128i *, sizeof(struct ether_hdr) + offsetof(struct ipv4_hdr, time_to_live)));
|
||||
data[3] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[3], __m128i *, sizeof(struct ether_hdr) + offsetof(struct ipv4_hdr, time_to_live)));
|
||||
|
||||
key[0].xmm = _mm_and_si128(data[0], mask0);
|
||||
key[1].xmm = _mm_and_si128(data[1], mask0);
|
||||
@ -860,14 +856,9 @@ simple_ipv4_fwd_4pkts(struct rte_mbuf* m[4], uint8_t portid, struct lcore_conf *
|
||||
static inline void get_ipv6_5tuple(struct rte_mbuf* m0, __m128i mask0, __m128i mask1,
|
||||
union ipv6_5tuple_host * key)
|
||||
{
|
||||
__m128i tmpdata0 = _mm_loadu_si128((__m128i*)(rte_pktmbuf_mtod(m0, unsigned char *)
|
||||
+ sizeof(struct ether_hdr) + offsetof(struct ipv6_hdr, payload_len)));
|
||||
__m128i tmpdata1 = _mm_loadu_si128((__m128i*)(rte_pktmbuf_mtod(m0, unsigned char *)
|
||||
+ sizeof(struct ether_hdr) + offsetof(struct ipv6_hdr, payload_len)
|
||||
+ sizeof(__m128i)));
|
||||
__m128i tmpdata2 = _mm_loadu_si128((__m128i*)(rte_pktmbuf_mtod(m0, unsigned char *)
|
||||
+ sizeof(struct ether_hdr) + offsetof(struct ipv6_hdr, payload_len)
|
||||
+ sizeof(__m128i) + sizeof(__m128i)));
|
||||
__m128i tmpdata0 = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m0, __m128i *, sizeof(struct ether_hdr) + offsetof(struct ipv6_hdr, payload_len)));
|
||||
__m128i tmpdata1 = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m0, __m128i *, sizeof(struct ether_hdr) + offsetof(struct ipv6_hdr, payload_len) + sizeof(__m128i)));
|
||||
__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)));
|
||||
key->xmm[0] = _mm_and_si128(tmpdata0, mask0);
|
||||
key->xmm[1] = tmpdata1;
|
||||
key->xmm[2] = _mm_and_si128(tmpdata2, mask1);
|
||||
@ -889,14 +880,14 @@ simple_ipv6_fwd_4pkts(struct rte_mbuf* m[4], uint8_t portid, struct lcore_conf *
|
||||
eth_hdr[3] = rte_pktmbuf_mtod(m[3], struct ether_hdr *);
|
||||
|
||||
/* Handle IPv6 headers.*/
|
||||
ipv6_hdr[0] = (struct ipv6_hdr *)(rte_pktmbuf_mtod(m[0], unsigned char *) +
|
||||
sizeof(struct ether_hdr));
|
||||
ipv6_hdr[1] = (struct ipv6_hdr *)(rte_pktmbuf_mtod(m[1], unsigned char *) +
|
||||
sizeof(struct ether_hdr));
|
||||
ipv6_hdr[2] = (struct ipv6_hdr *)(rte_pktmbuf_mtod(m[2], unsigned char *) +
|
||||
sizeof(struct ether_hdr));
|
||||
ipv6_hdr[3] = (struct ipv6_hdr *)(rte_pktmbuf_mtod(m[3], unsigned char *) +
|
||||
sizeof(struct ether_hdr));
|
||||
ipv6_hdr[0] = rte_pktmbuf_mtod_offset(m[0], struct ipv6_hdr *,
|
||||
sizeof(struct ether_hdr));
|
||||
ipv6_hdr[1] = rte_pktmbuf_mtod_offset(m[1], struct ipv6_hdr *,
|
||||
sizeof(struct ether_hdr));
|
||||
ipv6_hdr[2] = rte_pktmbuf_mtod_offset(m[2], struct ipv6_hdr *,
|
||||
sizeof(struct ether_hdr));
|
||||
ipv6_hdr[3] = rte_pktmbuf_mtod_offset(m[3], struct ipv6_hdr *,
|
||||
sizeof(struct ether_hdr));
|
||||
|
||||
get_ipv6_5tuple(m[0], mask1, mask2, &key[0]);
|
||||
get_ipv6_5tuple(m[1], mask1, mask2, &key[1]);
|
||||
@ -950,8 +941,8 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid, struct lcore_conf *qcon
|
||||
|
||||
if (m->ol_flags & PKT_RX_IPV4_HDR) {
|
||||
/* Handle IPv4 headers.*/
|
||||
ipv4_hdr = (struct ipv4_hdr *)(rte_pktmbuf_mtod(m, unsigned char *) +
|
||||
sizeof(struct ether_hdr));
|
||||
ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *,
|
||||
sizeof(struct ether_hdr));
|
||||
|
||||
#ifdef DO_RFC_1812_CHECKS
|
||||
/* Check to make sure the packet is valid (RFC1812) */
|
||||
@ -984,8 +975,8 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid, struct lcore_conf *qcon
|
||||
/* Handle IPv6 headers.*/
|
||||
struct ipv6_hdr *ipv6_hdr;
|
||||
|
||||
ipv6_hdr = (struct ipv6_hdr *)(rte_pktmbuf_mtod(m, unsigned char *) +
|
||||
sizeof(struct ether_hdr));
|
||||
ipv6_hdr = rte_pktmbuf_mtod_offset(m, struct ipv6_hdr *,
|
||||
sizeof(struct ether_hdr));
|
||||
|
||||
dst_port = get_ipv6_dst_port(ipv6_hdr, portid, qconf->ipv6_lookup_struct);
|
||||
|
||||
@ -1174,10 +1165,10 @@ processx4_step3(struct rte_mbuf *pkt[FWDSTEP], uint16_t dst_port[FWDSTEP])
|
||||
__m128i ve[FWDSTEP];
|
||||
__m128i *p[FWDSTEP];
|
||||
|
||||
p[0] = (rte_pktmbuf_mtod(pkt[0], __m128i *));
|
||||
p[1] = (rte_pktmbuf_mtod(pkt[1], __m128i *));
|
||||
p[2] = (rte_pktmbuf_mtod(pkt[2], __m128i *));
|
||||
p[3] = (rte_pktmbuf_mtod(pkt[3], __m128i *));
|
||||
p[0] = rte_pktmbuf_mtod(pkt[0], __m128i *);
|
||||
p[1] = rte_pktmbuf_mtod(pkt[1], __m128i *);
|
||||
p[2] = rte_pktmbuf_mtod(pkt[2], __m128i *);
|
||||
p[3] = rte_pktmbuf_mtod(pkt[3], __m128i *);
|
||||
|
||||
ve[0] = val_eth[dst_port[0]];
|
||||
te[0] = _mm_load_si128(p[0]);
|
||||
|
@ -535,7 +535,9 @@ app_lcore_worker(
|
||||
}
|
||||
|
||||
pkt = lp->mbuf_in.array[j];
|
||||
ipv4_hdr = (struct ipv4_hdr *)(rte_pktmbuf_mtod(pkt, unsigned char *) + sizeof(struct ether_hdr));
|
||||
ipv4_hdr = rte_pktmbuf_mtod_offset(pkt,
|
||||
struct ipv4_hdr *,
|
||||
sizeof(struct ether_hdr));
|
||||
ipv4_dst = rte_be_to_cpu_32(ipv4_hdr->dst_addr);
|
||||
|
||||
if (unlikely(rte_lpm_lookup(lp->lpm_table, ipv4_dst, &port) != 0)) {
|
||||
|
@ -873,8 +873,8 @@ virtio_tx_route(struct virtio_net* dev, struct rte_mbuf *m, struct rte_mempool *
|
||||
vlan_hdr->h_vlan_TCI = htons(vlan_tag);
|
||||
|
||||
/* Copy the remaining packet contents to the mbuf. */
|
||||
rte_memcpy((void *)(rte_pktmbuf_mtod(mbuf, uint8_t *) + VLAN_ETH_HLEN),
|
||||
(const void *)(rte_pktmbuf_mtod(m, uint8_t *) + ETH_HLEN),
|
||||
rte_memcpy(rte_pktmbuf_mtod_offset(mbuf, void *, VLAN_ETH_HLEN),
|
||||
rte_pktmbuf_mtod_offset(m, const void *, ETH_HLEN),
|
||||
(m->data_len - ETH_HLEN));
|
||||
tx_q->m_table[len] = mbuf;
|
||||
len++;
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user