#ifdef DO_RFC_1812_CHECKS
static inline int
-is_valid_ipv4_pkt(struct ipv4_hdr *pkt, uint32_t link_len)
+is_valid_ipv4_pkt(struct rte_ipv4_hdr *pkt, uint32_t link_len)
{
/* From http://www.rfc-editor.org/rfc/rfc1812.txt section 5.2.2 */
/*
* 1. The packet length reported by the Link Layer must be large
* enough to hold the minimum length legal IP datagram (20 bytes).
*/
- if (link_len < sizeof(struct ipv4_hdr))
+ if (link_len < sizeof(struct rte_ipv4_hdr))
return -1;
/* 2. The IP checksum must be correct. */
* datagram header, whose length is specified in the IP header length
* field.
*/
- if (rte_cpu_to_be_16(pkt->total_length) < sizeof(struct ipv4_hdr))
+ if (rte_cpu_to_be_16(pkt->total_length) < sizeof(struct rte_ipv4_hdr))
return -5;
return 0;
int ret = 0;
union ipv4_5tuple_host key;
- ipv4_hdr = (uint8_t *)ipv4_hdr + offsetof(struct ipv4_hdr, time_to_live);
+ ipv4_hdr = (uint8_t *)ipv4_hdr + offsetof(struct rte_ipv4_hdr, time_to_live);
__m128i data = _mm_loadu_si128((__m128i *)(ipv4_hdr));
/* Get 5 tuple: dst port, src port, dst IP address, src IP address and
protocol */
uint32_t next_hop;
return ((rte_lpm_lookup(ipv4_l3fwd_lookup_struct,
- rte_be_to_cpu_32(((struct ipv4_hdr *)ipv4_hdr)->dst_addr),
+ rte_be_to_cpu_32(((struct rte_ipv4_hdr *)ipv4_hdr)->dst_addr),
&next_hop) == 0) ? next_hop : portid);
}
simple_ipv4_fwd_8pkts(struct rte_mbuf *m[8], uint16_t portid)
{
struct rte_ether_hdr *eth_hdr[8];
- struct ipv4_hdr *ipv4_hdr[8];
+ struct rte_ipv4_hdr *ipv4_hdr[8];
uint16_t dst_port[8];
int32_t ret[8];
union ipv4_5tuple_host key[8];
eth_hdr[7] = rte_pktmbuf_mtod(m[7], struct rte_ether_hdr *);
/* Handle IPv4 headers.*/
- ipv4_hdr[0] = rte_pktmbuf_mtod_offset(m[0], struct ipv4_hdr *,
+ ipv4_hdr[0] = rte_pktmbuf_mtod_offset(m[0], struct rte_ipv4_hdr *,
sizeof(struct rte_ether_hdr));
- ipv4_hdr[1] = rte_pktmbuf_mtod_offset(m[1], struct ipv4_hdr *,
+ ipv4_hdr[1] = rte_pktmbuf_mtod_offset(m[1], struct rte_ipv4_hdr *,
sizeof(struct rte_ether_hdr));
- ipv4_hdr[2] = rte_pktmbuf_mtod_offset(m[2], struct ipv4_hdr *,
+ ipv4_hdr[2] = rte_pktmbuf_mtod_offset(m[2], struct rte_ipv4_hdr *,
sizeof(struct rte_ether_hdr));
- ipv4_hdr[3] = rte_pktmbuf_mtod_offset(m[3], struct ipv4_hdr *,
+ ipv4_hdr[3] = rte_pktmbuf_mtod_offset(m[3], struct rte_ipv4_hdr *,
sizeof(struct rte_ether_hdr));
- ipv4_hdr[4] = rte_pktmbuf_mtod_offset(m[4], struct ipv4_hdr *,
+ ipv4_hdr[4] = rte_pktmbuf_mtod_offset(m[4], struct rte_ipv4_hdr *,
sizeof(struct rte_ether_hdr));
- ipv4_hdr[5] = rte_pktmbuf_mtod_offset(m[5], struct ipv4_hdr *,
+ ipv4_hdr[5] = rte_pktmbuf_mtod_offset(m[5], struct rte_ipv4_hdr *,
sizeof(struct rte_ether_hdr));
- ipv4_hdr[6] = rte_pktmbuf_mtod_offset(m[6], struct ipv4_hdr *,
+ ipv4_hdr[6] = rte_pktmbuf_mtod_offset(m[6], struct rte_ipv4_hdr *,
sizeof(struct rte_ether_hdr));
- ipv4_hdr[7] = rte_pktmbuf_mtod_offset(m[7], struct ipv4_hdr *,
+ ipv4_hdr[7] = rte_pktmbuf_mtod_offset(m[7], struct rte_ipv4_hdr *,
sizeof(struct rte_ether_hdr));
#ifdef DO_RFC_1812_CHECKS
data[0] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[0], __m128i *,
sizeof(struct rte_ether_hdr) +
- offsetof(struct ipv4_hdr, time_to_live)));
+ offsetof(struct rte_ipv4_hdr, time_to_live)));
data[1] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[1], __m128i *,
sizeof(struct rte_ether_hdr) +
- offsetof(struct ipv4_hdr, time_to_live)));
+ offsetof(struct rte_ipv4_hdr, time_to_live)));
data[2] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[2], __m128i *,
sizeof(struct rte_ether_hdr) +
- offsetof(struct ipv4_hdr, time_to_live)));
+ offsetof(struct rte_ipv4_hdr, time_to_live)));
data[3] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[3], __m128i *,
sizeof(struct rte_ether_hdr) +
- offsetof(struct ipv4_hdr, time_to_live)));
+ offsetof(struct rte_ipv4_hdr, time_to_live)));
data[4] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[4], __m128i *,
sizeof(struct rte_ether_hdr) +
- offsetof(struct ipv4_hdr, time_to_live)));
+ offsetof(struct rte_ipv4_hdr, time_to_live)));
data[5] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[5], __m128i *,
sizeof(struct rte_ether_hdr) +
- offsetof(struct ipv4_hdr, time_to_live)));
+ offsetof(struct rte_ipv4_hdr, time_to_live)));
data[6] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[6], __m128i *,
sizeof(struct rte_ether_hdr) +
- offsetof(struct ipv4_hdr, time_to_live)));
+ offsetof(struct rte_ipv4_hdr, time_to_live)));
data[7] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[7], __m128i *,
sizeof(struct rte_ether_hdr) +
- offsetof(struct ipv4_hdr, time_to_live)));
+ offsetof(struct rte_ipv4_hdr, time_to_live)));
key[0].xmm = _mm_and_si128(data[0], mask0);
key[1].xmm = _mm_and_si128(data[1], mask0);
l3fwd_simple_forward(struct rte_mbuf *m, uint16_t portid)
{
struct rte_ether_hdr *eth_hdr;
- struct ipv4_hdr *ipv4_hdr;
+ struct rte_ipv4_hdr *ipv4_hdr;
uint16_t dst_port;
eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
if (RTE_ETH_IS_IPV4_HDR(m->packet_type)) {
/* Handle IPv4 headers.*/
- ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *,
+ ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,
sizeof(struct rte_ether_hdr));
#ifdef DO_RFC_1812_CHECKS
#define IPV4_MAX_VER_IHL_DIFF (IPV4_MAX_VER_IHL - IPV4_MIN_VER_IHL)
/* Minimum value of IPV4 total length (20B) in network byte order. */
-#define IPV4_MIN_LEN_BE (sizeof(struct ipv4_hdr) << 8)
+#define IPV4_MIN_LEN_BE (sizeof(struct rte_ipv4_hdr) << 8)
/*
* From http://www.rfc-editor.org/rfc/rfc1812.txt section 5.2.2:
* to BAD_PORT value.
*/
static __rte_always_inline void
-rfc1812_process(struct ipv4_hdr *ipv4_hdr, uint16_t *dp, uint32_t ptype)
+rfc1812_process(struct rte_ipv4_hdr *ipv4_hdr, uint16_t *dp, uint32_t ptype)
{
uint8_t ihl;
process_packet(struct rte_mbuf *pkt, uint16_t *dst_port, uint16_t portid)
{
struct rte_ether_hdr *eth_hdr;
- struct ipv4_hdr *ipv4_hdr;
+ struct rte_ipv4_hdr *ipv4_hdr;
uint32_t dst_ipv4;
uint16_t dp;
__m128i te, ve;
eth_hdr = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *);
- ipv4_hdr = (struct ipv4_hdr *)(eth_hdr + 1);
+ ipv4_hdr = (struct rte_ipv4_hdr *)(eth_hdr + 1);
dst_ipv4 = ipv4_hdr->dst_addr;
dst_ipv4 = rte_be_to_cpu_32(dst_ipv4);
__m128i *dip,
uint32_t *ipv4_flag)
{
- struct ipv4_hdr *ipv4_hdr;
+ struct rte_ipv4_hdr *ipv4_hdr;
struct rte_ether_hdr *eth_hdr;
uint32_t x0, x1, x2, x3;
eth_hdr = rte_pktmbuf_mtod(pkt[0], struct rte_ether_hdr *);
- ipv4_hdr = (struct ipv4_hdr *)(eth_hdr + 1);
+ ipv4_hdr = (struct rte_ipv4_hdr *)(eth_hdr + 1);
x0 = ipv4_hdr->dst_addr;
ipv4_flag[0] = pkt[0]->packet_type & RTE_PTYPE_L3_IPV4;
eth_hdr = rte_pktmbuf_mtod(pkt[1], struct rte_ether_hdr *);
- ipv4_hdr = (struct ipv4_hdr *)(eth_hdr + 1);
+ ipv4_hdr = (struct rte_ipv4_hdr *)(eth_hdr + 1);
x1 = ipv4_hdr->dst_addr;
ipv4_flag[0] &= pkt[1]->packet_type;
eth_hdr = rte_pktmbuf_mtod(pkt[2], struct rte_ether_hdr *);
- ipv4_hdr = (struct ipv4_hdr *)(eth_hdr + 1);
+ ipv4_hdr = (struct rte_ipv4_hdr *)(eth_hdr + 1);
x2 = ipv4_hdr->dst_addr;
ipv4_flag[0] &= pkt[2]->packet_type;
eth_hdr = rte_pktmbuf_mtod(pkt[3], struct rte_ether_hdr *);
- ipv4_hdr = (struct ipv4_hdr *)(eth_hdr + 1);
+ ipv4_hdr = (struct rte_ipv4_hdr *)(eth_hdr + 1);
x3 = ipv4_hdr->dst_addr;
ipv4_flag[0] &= pkt[3]->packet_type;
_mm_store_si128(p[2], te[2]);
_mm_store_si128(p[3], te[3]);
- rfc1812_process((struct ipv4_hdr *)((struct rte_ether_hdr *)p[0] + 1),
+ rfc1812_process((struct rte_ipv4_hdr *)((struct rte_ether_hdr *)p[0] + 1),
&dst_port[0], pkt[0]->packet_type);
- rfc1812_process((struct ipv4_hdr *)((struct rte_ether_hdr *)p[1] + 1),
+ rfc1812_process((struct rte_ipv4_hdr *)((struct rte_ether_hdr *)p[1] + 1),
&dst_port[1], pkt[1]->packet_type);
- rfc1812_process((struct ipv4_hdr *)((struct rte_ether_hdr *)p[2] + 1),
+ rfc1812_process((struct rte_ipv4_hdr *)((struct rte_ether_hdr *)p[2] + 1),
&dst_port[2], pkt[2]->packet_type);
- rfc1812_process((struct ipv4_hdr *)((struct rte_ether_hdr *)p[3] + 1),
+ rfc1812_process((struct rte_ipv4_hdr *)((struct rte_ether_hdr *)p[3] + 1),
&dst_port[3], pkt[3]->packet_type);
}