DPDK  24.07.0
rte_ip.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 1982, 1986, 1990, 1993
3  * The Regents of the University of California.
4  * Copyright(c) 2010-2014 Intel Corporation.
5  * Copyright(c) 2014 6WIND S.A.
6  * All rights reserved.
7  */
8 
9 #ifndef _RTE_IP_H_
10 #define _RTE_IP_H_
11 
18 #include <stdint.h>
19 
20 #ifdef RTE_EXEC_ENV_WINDOWS
21 #include <ws2tcpip.h>
22 #else
23 #include <sys/socket.h>
24 #include <sys/types.h>
25 #include <netinet/in.h>
26 #include <arpa/inet.h>
27 #include <netinet/ip.h>
28 #include <netinet/ip6.h>
29 #endif
30 
31 #include <rte_byteorder.h>
32 #include <rte_mbuf.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
41 struct rte_ipv4_hdr {
42  __extension__
43  union {
44  uint8_t version_ihl;
45  struct {
46 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
47  uint8_t ihl:4;
48  uint8_t version:4;
49 #elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
50  uint8_t version:4;
51  uint8_t ihl:4;
52 #endif
53  };
54  };
55  uint8_t type_of_service;
59  uint8_t time_to_live;
60  uint8_t next_proto_id;
64 } __rte_packed;
65 
67 #define RTE_IPV4(a, b, c, d) ((uint32_t)(((a) & 0xff) << 24) | \
68  (((b) & 0xff) << 16) | \
69  (((c) & 0xff) << 8) | \
70  ((d) & 0xff))
71 
73 #define RTE_IPV4_MAX_PKT_LEN 65535
74 
76 #define RTE_IPV4_HDR_IHL_MASK (0x0f)
77 
81 #define RTE_IPV4_IHL_MULTIPLIER (4)
82 
83 /* Type of Service fields */
84 #define RTE_IPV4_HDR_DSCP_MASK (0xfc)
85 #define RTE_IPV4_HDR_ECN_MASK (0x03)
86 #define RTE_IPV4_HDR_ECN_CE RTE_IPV4_HDR_ECN_MASK
87 
88 /* Fragment Offset * Flags. */
89 #define RTE_IPV4_HDR_DF_SHIFT 14
90 #define RTE_IPV4_HDR_MF_SHIFT 13
91 #define RTE_IPV4_HDR_FO_SHIFT 3
92 
93 #define RTE_IPV4_HDR_DF_FLAG (1 << RTE_IPV4_HDR_DF_SHIFT)
94 #define RTE_IPV4_HDR_MF_FLAG (1 << RTE_IPV4_HDR_MF_SHIFT)
95 
96 #define RTE_IPV4_HDR_OFFSET_MASK ((1 << RTE_IPV4_HDR_MF_SHIFT) - 1)
97 
98 #define RTE_IPV4_HDR_OFFSET_UNITS 8
99 
100 /* IPv4 options */
101 #define RTE_IPV4_HDR_OPT_EOL 0
102 #define RTE_IPV4_HDR_OPT_NOP 1
103 #define RTE_IPV4_HDR_OPT_COPIED(v) ((v) & 0x80)
104 #define RTE_IPV4_HDR_OPT_MAX_LEN 40
105 
106 /*
107  * IPv4 address types
108  */
109 #define RTE_IPV4_ANY ((uint32_t)0x00000000)
110 #define RTE_IPV4_LOOPBACK ((uint32_t)0x7f000001)
111 #define RTE_IPV4_BROADCAST ((uint32_t)0xe0000000)
112 #define RTE_IPV4_ALLHOSTS_GROUP ((uint32_t)0xe0000001)
113 #define RTE_IPV4_ALLRTRS_GROUP ((uint32_t)0xe0000002)
114 #define RTE_IPV4_MAX_LOCAL_GROUP ((uint32_t)0xe00000ff)
116 /*
117  * IPv4 Multicast-related macros
118  */
119 #define RTE_IPV4_MIN_MCAST \
120  RTE_IPV4(224, 0, 0, 0)
121 #define RTE_IPV4_MAX_MCAST \
122  RTE_IPV4(239, 255, 255, 255)
124 #define RTE_IS_IPV4_MCAST(x) \
125  ((x) >= RTE_IPV4_MIN_MCAST && (x) <= RTE_IPV4_MAX_MCAST)
126 
128 /* IPv4 default fields values */
129 #define RTE_IPV4_MIN_IHL (0x5)
130 #define RTE_IPV4_VHL_DEF ((IPVERSION << 4) | RTE_IPV4_MIN_IHL)
131 
140 static inline uint8_t
141 rte_ipv4_hdr_len(const struct rte_ipv4_hdr *ipv4_hdr)
142 {
143  return (uint8_t)((ipv4_hdr->version_ihl & RTE_IPV4_HDR_IHL_MASK) *
145 }
146 
160 static inline uint32_t
161 __rte_raw_cksum(const void *buf, size_t len, uint32_t sum)
162 {
163  const void *end;
164 
165  for (end = RTE_PTR_ADD(buf, RTE_ALIGN_FLOOR(len, sizeof(uint16_t)));
166  buf != end; buf = RTE_PTR_ADD(buf, sizeof(uint16_t))) {
167  uint16_t v;
168 
169  memcpy(&v, buf, sizeof(uint16_t));
170  sum += v;
171  }
172 
173  /* if length is odd, keeping it byte order independent */
174  if (unlikely(len % 2)) {
175  uint16_t left = 0;
176 
177  memcpy(&left, end, 1);
178  sum += left;
179  }
180 
181  return sum;
182 }
183 
193 static inline uint16_t
194 __rte_raw_cksum_reduce(uint32_t sum)
195 {
196  sum = ((sum & 0xffff0000) >> 16) + (sum & 0xffff);
197  sum = ((sum & 0xffff0000) >> 16) + (sum & 0xffff);
198  return (uint16_t)sum;
199 }
200 
211 static inline uint16_t
212 rte_raw_cksum(const void *buf, size_t len)
213 {
214  uint32_t sum;
215 
216  sum = __rte_raw_cksum(buf, len, 0);
217  return __rte_raw_cksum_reduce(sum);
218 }
219 
234 static inline int
235 rte_raw_cksum_mbuf(const struct rte_mbuf *m, uint32_t off, uint32_t len,
236  uint16_t *cksum)
237 {
238  const struct rte_mbuf *seg;
239  const char *buf;
240  uint32_t sum, tmp;
241  uint32_t seglen, done;
242 
243  /* easy case: all data in the first segment */
244  if (off + len <= rte_pktmbuf_data_len(m)) {
246  const char *, off), len);
247  return 0;
248  }
249 
250  if (unlikely(off + len > rte_pktmbuf_pkt_len(m)))
251  return -1; /* invalid params, return a dummy value */
252 
253  /* else browse the segment to find offset */
254  seglen = 0;
255  for (seg = m; seg != NULL; seg = seg->next) {
256  seglen = rte_pktmbuf_data_len(seg);
257  if (off < seglen)
258  break;
259  off -= seglen;
260  }
261  RTE_ASSERT(seg != NULL);
262  if (seg == NULL)
263  return -1;
264  seglen -= off;
265  buf = rte_pktmbuf_mtod_offset(seg, const char *, off);
266  if (seglen >= len) {
267  /* all in one segment */
268  *cksum = rte_raw_cksum(buf, len);
269  return 0;
270  }
271 
272  /* hard case: process checksum of several segments */
273  sum = 0;
274  done = 0;
275  for (;;) {
276  tmp = __rte_raw_cksum(buf, seglen, 0);
277  if (done & 1)
278  tmp = rte_bswap16((uint16_t)tmp);
279  sum += tmp;
280  done += seglen;
281  if (done == len)
282  break;
283  seg = seg->next;
284  buf = rte_pktmbuf_mtod(seg, const char *);
285  seglen = rte_pktmbuf_data_len(seg);
286  if (seglen > len - done)
287  seglen = len - done;
288  }
289 
290  *cksum = __rte_raw_cksum_reduce(sum);
291  return 0;
292 }
293 
304 static inline uint16_t
305 rte_ipv4_cksum(const struct rte_ipv4_hdr *ipv4_hdr)
306 {
307  uint16_t cksum;
308  cksum = rte_raw_cksum(ipv4_hdr, rte_ipv4_hdr_len(ipv4_hdr));
309  return (uint16_t)~cksum;
310 }
311 
330 static inline uint16_t
331 rte_ipv4_phdr_cksum(const struct rte_ipv4_hdr *ipv4_hdr, uint64_t ol_flags)
332 {
333  struct ipv4_psd_header {
334  uint32_t src_addr; /* IP address of source host. */
335  uint32_t dst_addr; /* IP address of destination host. */
336  uint8_t zero; /* zero. */
337  uint8_t proto; /* L4 protocol type. */
338  uint16_t len; /* L4 length. */
339  } psd_hdr;
340 
341  uint32_t l3_len;
342 
343  psd_hdr.src_addr = ipv4_hdr->src_addr;
344  psd_hdr.dst_addr = ipv4_hdr->dst_addr;
345  psd_hdr.zero = 0;
346  psd_hdr.proto = ipv4_hdr->next_proto_id;
347  if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG)) {
348  psd_hdr.len = 0;
349  } else {
350  l3_len = rte_be_to_cpu_16(ipv4_hdr->total_length);
351  psd_hdr.len = rte_cpu_to_be_16((uint16_t)(l3_len -
352  rte_ipv4_hdr_len(ipv4_hdr)));
353  }
354  return rte_raw_cksum(&psd_hdr, sizeof(psd_hdr));
355 }
356 
360 static inline uint16_t
361 __rte_ipv4_udptcp_cksum(const struct rte_ipv4_hdr *ipv4_hdr, const void *l4_hdr)
362 {
363  uint32_t cksum;
364  uint32_t l3_len, l4_len;
365  uint8_t ip_hdr_len;
366 
367  ip_hdr_len = rte_ipv4_hdr_len(ipv4_hdr);
368  l3_len = rte_be_to_cpu_16(ipv4_hdr->total_length);
369  if (l3_len < ip_hdr_len)
370  return 0;
371 
372  l4_len = l3_len - ip_hdr_len;
373 
374  cksum = rte_raw_cksum(l4_hdr, l4_len);
375  cksum += rte_ipv4_phdr_cksum(ipv4_hdr, 0);
376 
377  cksum = ((cksum & 0xffff0000) >> 16) + (cksum & 0xffff);
378 
379  return (uint16_t)cksum;
380 }
381 
394 static inline uint16_t
395 rte_ipv4_udptcp_cksum(const struct rte_ipv4_hdr *ipv4_hdr, const void *l4_hdr)
396 {
397  uint16_t cksum = __rte_ipv4_udptcp_cksum(ipv4_hdr, l4_hdr);
398 
399  cksum = ~cksum;
400 
401  /*
402  * Per RFC 768: If the computed checksum is zero for UDP,
403  * it is transmitted as all ones
404  * (the equivalent in one's complement arithmetic).
405  */
406  if (cksum == 0 && ipv4_hdr->next_proto_id == IPPROTO_UDP)
407  cksum = 0xffff;
408 
409  return cksum;
410 }
411 
415 static inline uint16_t
416 __rte_ipv4_udptcp_cksum_mbuf(const struct rte_mbuf *m,
417  const struct rte_ipv4_hdr *ipv4_hdr,
418  uint16_t l4_off)
419 {
420  uint16_t raw_cksum;
421  uint32_t cksum;
422  uint16_t len;
423 
424  if (unlikely(l4_off > m->pkt_len))
425  return 0; /* invalid params, return a dummy value */
426 
427  len = rte_be_to_cpu_16(ipv4_hdr->total_length) - (uint16_t)rte_ipv4_hdr_len(ipv4_hdr);
428 
429  if (rte_raw_cksum_mbuf(m, l4_off, len, &raw_cksum))
430  return 0;
431 
432  cksum = raw_cksum + rte_ipv4_phdr_cksum(ipv4_hdr, 0);
433 
434  cksum = ((cksum & 0xffff0000) >> 16) + (cksum & 0xffff);
435 
436  return (uint16_t)cksum;
437 }
438 
451 static inline uint16_t
452 rte_ipv4_udptcp_cksum_mbuf(const struct rte_mbuf *m,
453  const struct rte_ipv4_hdr *ipv4_hdr, uint16_t l4_off)
454 {
455  uint16_t cksum = __rte_ipv4_udptcp_cksum_mbuf(m, ipv4_hdr, l4_off);
456 
457  cksum = ~cksum;
458 
459  /*
460  * Per RFC 768: If the computed checksum is zero for UDP,
461  * it is transmitted as all ones
462  * (the equivalent in one's complement arithmetic).
463  */
464  if (cksum == 0 && ipv4_hdr->next_proto_id == IPPROTO_UDP)
465  cksum = 0xffff;
466 
467  return cksum;
468 }
469 
483 static inline int
484 rte_ipv4_udptcp_cksum_verify(const struct rte_ipv4_hdr *ipv4_hdr,
485  const void *l4_hdr)
486 {
487  uint16_t cksum = __rte_ipv4_udptcp_cksum(ipv4_hdr, l4_hdr);
488 
489  if (cksum != 0xffff)
490  return -1;
491 
492  return 0;
493 }
494 
510 static inline int
512  const struct rte_ipv4_hdr *ipv4_hdr,
513  uint16_t l4_off)
514 {
515  uint16_t cksum = __rte_ipv4_udptcp_cksum_mbuf(m, ipv4_hdr, l4_off);
516 
517  if (cksum != 0xffff)
518  return -1;
519 
520  return 0;
521 }
522 
526 struct rte_ipv6_hdr {
527  rte_be32_t vtc_flow;
528  rte_be16_t payload_len;
529  uint8_t proto;
530  uint8_t hop_limits;
531  uint8_t src_addr[16];
532  uint8_t dst_addr[16];
535 /* IPv6 routing extension type definition. */
536 #define RTE_IPV6_SRCRT_TYPE_4 4
537 
541 struct rte_ipv6_routing_ext {
542  uint8_t next_hdr;
543  uint8_t hdr_len;
544  uint8_t type;
545  uint8_t segments_left;
546  __extension__
547  union {
548  rte_be32_t flags;
549  struct {
550  uint8_t last_entry;
551  uint8_t flag;
553  };
554  };
555  /* Next are 128-bit IPv6 address fields to describe segments. */
556 } __rte_packed;
557 
558 /* IPv6 vtc_flow: IPv / TC / flow_label */
559 #define RTE_IPV6_HDR_FL_SHIFT 0
560 #define RTE_IPV6_HDR_TC_SHIFT 20
561 #define RTE_IPV6_HDR_FL_MASK ((1u << RTE_IPV6_HDR_TC_SHIFT) - 1)
562 #define RTE_IPV6_HDR_TC_MASK (0xff << RTE_IPV6_HDR_TC_SHIFT)
563 #define RTE_IPV6_HDR_DSCP_MASK (0xfc << RTE_IPV6_HDR_TC_SHIFT)
564 #define RTE_IPV6_HDR_ECN_MASK (0x03 << RTE_IPV6_HDR_TC_SHIFT)
565 #define RTE_IPV6_HDR_ECN_CE RTE_IPV6_HDR_ECN_MASK
566 
567 #define RTE_IPV6_MIN_MTU 1280
585 static inline uint16_t
586 rte_ipv6_phdr_cksum(const struct rte_ipv6_hdr *ipv6_hdr, uint64_t ol_flags)
587 {
588  uint32_t sum;
589  struct {
590  rte_be32_t len; /* L4 length. */
591  rte_be32_t proto; /* L4 protocol - top 3 bytes must be zero */
592  } psd_hdr;
593 
594  psd_hdr.proto = (uint32_t)(ipv6_hdr->proto << 24);
595  if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG)) {
596  psd_hdr.len = 0;
597  } else {
598  psd_hdr.len = ipv6_hdr->payload_len;
599  }
600 
601  sum = __rte_raw_cksum(ipv6_hdr->src_addr,
602  sizeof(ipv6_hdr->src_addr) + sizeof(ipv6_hdr->dst_addr),
603  0);
604  sum = __rte_raw_cksum(&psd_hdr, sizeof(psd_hdr), sum);
605  return __rte_raw_cksum_reduce(sum);
606 }
607 
611 static inline uint16_t
612 __rte_ipv6_udptcp_cksum(const struct rte_ipv6_hdr *ipv6_hdr, const void *l4_hdr)
613 {
614  uint32_t cksum;
615  uint32_t l4_len;
616 
617  l4_len = rte_be_to_cpu_16(ipv6_hdr->payload_len);
618 
619  cksum = rte_raw_cksum(l4_hdr, l4_len);
620  cksum += rte_ipv6_phdr_cksum(ipv6_hdr, 0);
621 
622  cksum = ((cksum & 0xffff0000) >> 16) + (cksum & 0xffff);
623 
624  return (uint16_t)cksum;
625 }
626 
640 static inline uint16_t
641 rte_ipv6_udptcp_cksum(const struct rte_ipv6_hdr *ipv6_hdr, const void *l4_hdr)
642 {
643  uint16_t cksum = __rte_ipv6_udptcp_cksum(ipv6_hdr, l4_hdr);
644 
645  cksum = ~cksum;
646 
647  /*
648  * Per RFC 768: If the computed checksum is zero for UDP,
649  * it is transmitted as all ones
650  * (the equivalent in one's complement arithmetic).
651  */
652  if (cksum == 0 && ipv6_hdr->proto == IPPROTO_UDP)
653  cksum = 0xffff;
654 
655  return cksum;
656 }
657 
661 static inline uint16_t
662 __rte_ipv6_udptcp_cksum_mbuf(const struct rte_mbuf *m,
663  const struct rte_ipv6_hdr *ipv6_hdr,
664  uint16_t l4_off)
665 {
666  uint16_t raw_cksum;
667  uint32_t cksum;
668 
669  if (unlikely(l4_off > m->pkt_len))
670  return 0; /* invalid params, return a dummy value */
671 
672  if (rte_raw_cksum_mbuf(m, l4_off, rte_be_to_cpu_16(ipv6_hdr->payload_len), &raw_cksum))
673  return 0;
674 
675  cksum = raw_cksum + rte_ipv6_phdr_cksum(ipv6_hdr, 0);
676 
677  cksum = ((cksum & 0xffff0000) >> 16) + (cksum & 0xffff);
678 
679  return (uint16_t)cksum;
680 }
681 
697 static inline uint16_t
698 rte_ipv6_udptcp_cksum_mbuf(const struct rte_mbuf *m,
699  const struct rte_ipv6_hdr *ipv6_hdr, uint16_t l4_off)
700 {
701  uint16_t cksum = __rte_ipv6_udptcp_cksum_mbuf(m, ipv6_hdr, l4_off);
702 
703  cksum = ~cksum;
704 
705  /*
706  * Per RFC 768: If the computed checksum is zero for UDP,
707  * it is transmitted as all ones
708  * (the equivalent in one's complement arithmetic).
709  */
710  if (cksum == 0 && ipv6_hdr->proto == IPPROTO_UDP)
711  cksum = 0xffff;
712 
713  return cksum;
714 }
715 
730 static inline int
731 rte_ipv6_udptcp_cksum_verify(const struct rte_ipv6_hdr *ipv6_hdr,
732  const void *l4_hdr)
733 {
734  uint16_t cksum = __rte_ipv6_udptcp_cksum(ipv6_hdr, l4_hdr);
735 
736  if (cksum != 0xffff)
737  return -1;
738 
739  return 0;
740 }
741 
758 static inline int
760  const struct rte_ipv6_hdr *ipv6_hdr,
761  uint16_t l4_off)
762 {
763  uint16_t cksum = __rte_ipv6_udptcp_cksum_mbuf(m, ipv6_hdr, l4_off);
764 
765  if (cksum != 0xffff)
766  return -1;
767 
768  return 0;
769 }
770 
772 #define RTE_IPV6_EHDR_MF_SHIFT 0
773 #define RTE_IPV6_EHDR_MF_MASK 1
774 #define RTE_IPV6_EHDR_FO_SHIFT 3
775 #define RTE_IPV6_EHDR_FO_MASK (~((1 << RTE_IPV6_EHDR_FO_SHIFT) - 1))
776 #define RTE_IPV6_EHDR_FO_ALIGN (1 << RTE_IPV6_EHDR_FO_SHIFT)
777 
778 #define RTE_IPV6_FRAG_USED_MASK (RTE_IPV6_EHDR_MF_MASK | RTE_IPV6_EHDR_FO_MASK)
779 
780 #define RTE_IPV6_GET_MF(x) ((x) & RTE_IPV6_EHDR_MF_MASK)
781 #define RTE_IPV6_GET_FO(x) ((x) >> RTE_IPV6_EHDR_FO_SHIFT)
782 
783 #define RTE_IPV6_SET_FRAG_DATA(fo, mf) \
784  (((fo) & RTE_IPV6_EHDR_FO_MASK) | ((mf) & RTE_IPV6_EHDR_MF_MASK))
785 
786 struct rte_ipv6_fragment_ext {
787  uint8_t next_header;
788  uint8_t reserved;
789  rte_be16_t frag_data;
790  rte_be32_t id;
791 } __rte_packed;
792 
793 /* IPv6 fragment extension header size */
794 #define RTE_IPV6_FRAG_HDR_SIZE sizeof(struct rte_ipv6_fragment_ext)
795 
812 static inline int
813 rte_ipv6_get_next_ext(const uint8_t *p, int proto, size_t *ext_len)
814 {
815  int next_proto;
816 
817  switch (proto) {
818  case IPPROTO_AH:
819  next_proto = *p++;
820  *ext_len = (*p + 2) * sizeof(uint32_t);
821  break;
822 
823  case IPPROTO_HOPOPTS:
824  case IPPROTO_ROUTING:
825  case IPPROTO_DSTOPTS:
826  next_proto = *p++;
827  *ext_len = (*p + 1) * sizeof(uint64_t);
828  break;
829 
830  case IPPROTO_FRAGMENT:
831  next_proto = *p;
832  *ext_len = RTE_IPV6_FRAG_HDR_SIZE;
833  break;
834 
835  default:
836  return -EINVAL;
837  }
838 
839  return next_proto;
840 }
841 
842 #ifdef __cplusplus
843 }
844 #endif
845 
846 #endif /* _RTE_IP_H_ */
static uint8_t rte_ipv4_hdr_len(const struct rte_ipv4_hdr *ipv4_hdr)
Definition: rte_ip.h:143
struct rte_mbuf * next
static int rte_ipv6_get_next_ext(const uint8_t *p, int proto, size_t *ext_len)
Definition: rte_ip.h:815
static int rte_raw_cksum_mbuf(const struct rte_mbuf *m, uint32_t off, uint32_t len, uint16_t *cksum)
Definition: rte_ip.h:237
#define RTE_ALIGN_FLOOR(val, align)
Definition: rte_common.h:448
static uint16_t rte_ipv4_udptcp_cksum(const struct rte_ipv4_hdr *ipv4_hdr, const void *l4_hdr)
Definition: rte_ip.h:397
static int rte_ipv6_udptcp_cksum_mbuf_verify(const struct rte_mbuf *m, const struct rte_ipv6_hdr *ipv6_hdr, uint16_t l4_off)
Definition: rte_ip.h:761
uint32_t rte_be32_t
static int rte_ipv4_udptcp_cksum_mbuf_verify(const struct rte_mbuf *m, const struct rte_ipv4_hdr *ipv4_hdr, uint16_t l4_off)
Definition: rte_ip.h:513
uint8_t dst_addr[16]
Definition: rte_ip.h:534
rte_be16_t fragment_offset
Definition: rte_ip.h:58
static int rte_ipv6_udptcp_cksum_verify(const struct rte_ipv6_hdr *ipv6_hdr, const void *l4_hdr)
Definition: rte_ip.h:733
uint8_t version_ihl
Definition: rte_ip.h:44
static uint16_t rte_bswap16(uint16_t _x)
rte_be32_t dst_addr
Definition: rte_ip.h:63
rte_be32_t src_addr
Definition: rte_ip.h:62
#define RTE_MBUF_F_TX_UDP_SEG
uint8_t src_addr[16]
Definition: rte_ip.h:533
#define __rte_packed
Definition: rte_common.h:108
static uint16_t rte_ipv6_udptcp_cksum_mbuf(const struct rte_mbuf *m, const struct rte_ipv6_hdr *ipv6_hdr, uint16_t l4_off)
Definition: rte_ip.h:700
#define rte_pktmbuf_mtod_offset(m, t, o)
#define RTE_PTR_ADD(ptr, x)
Definition: rte_common.h:410
static rte_be16_t rte_cpu_to_be_16(uint16_t x)
#define unlikely(x)
static int rte_ipv4_udptcp_cksum_verify(const struct rte_ipv4_hdr *ipv4_hdr, const void *l4_hdr)
Definition: rte_ip.h:486
static uint16_t rte_ipv4_phdr_cksum(const struct rte_ipv4_hdr *ipv4_hdr, uint64_t ol_flags)
Definition: rte_ip.h:333
static uint16_t rte_ipv6_phdr_cksum(const struct rte_ipv6_hdr *ipv6_hdr, uint64_t ol_flags)
Definition: rte_ip.h:588
#define rte_pktmbuf_mtod(m, t)
#define rte_pktmbuf_pkt_len(m)
Definition: rte_mbuf.h:1558
uint8_t type_of_service
Definition: rte_ip.h:55
uint8_t time_to_live
Definition: rte_ip.h:59
uint8_t proto
Definition: rte_ip.h:531
rte_be16_t packet_id
Definition: rte_ip.h:57
static uint16_t rte_raw_cksum(const void *buf, size_t len)
Definition: rte_ip.h:214
uint64_t ol_flags
uint32_t pkt_len
#define rte_pktmbuf_data_len(m)
Definition: rte_mbuf.h:1568
static uint16_t rte_ipv4_udptcp_cksum_mbuf(const struct rte_mbuf *m, const struct rte_ipv4_hdr *ipv4_hdr, uint16_t l4_off)
Definition: rte_ip.h:454
#define RTE_MBUF_F_TX_TCP_SEG
uint8_t next_proto_id
Definition: rte_ip.h:60
rte_be16_t payload_len
Definition: rte_ip.h:530
rte_be16_t total_length
Definition: rte_ip.h:56
uint8_t ihl
Definition: rte_ip.h:47
uint16_t rte_be16_t
#define RTE_IPV4_HDR_IHL_MASK
Definition: rte_ip.h:76
static uint16_t rte_be_to_cpu_16(rte_be16_t x)
rte_be16_t hdr_checksum
Definition: rte_ip.h:61
static uint16_t rte_ipv4_cksum(const struct rte_ipv4_hdr *ipv4_hdr)
Definition: rte_ip.h:307
uint8_t version
Definition: rte_ip.h:48
static uint16_t rte_ipv6_udptcp_cksum(const struct rte_ipv6_hdr *ipv6_hdr, const void *l4_hdr)
Definition: rte_ip.h:643
#define RTE_IPV4_IHL_MULTIPLIER
Definition: rte_ip.h:81