void
initialize_eth_header(struct ether_hdr *eth_hdr, struct ether_addr *src_mac,
- struct ether_addr *dst_mac, uint8_t vlan_enabled, uint16_t van_id)
+ struct ether_addr *dst_mac, uint8_t ipv4, uint8_t vlan_enabled,
+ uint16_t van_id)
{
ether_addr_copy(dst_mac, ð_hdr->d_addr);
ether_addr_copy(src_mac, ð_hdr->s_addr);
eth_hdr->ether_type = rte_cpu_to_be_16(ETHER_TYPE_VLAN);
- vhdr->eth_proto = rte_cpu_to_be_16(ETHER_TYPE_IPv4);
+ if (ipv4)
+ vhdr->eth_proto = rte_cpu_to_be_16(ETHER_TYPE_IPv4);
+ else
+ vhdr->eth_proto = rte_cpu_to_be_16(ETHER_TYPE_IPv6);
+
vhdr->vlan_tci = van_id;
} else {
- eth_hdr->ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4);
+ if (ipv4)
+ eth_hdr->ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4);
+ else
+ eth_hdr->ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv6);
}
}
if (ipv4) {
pkt->vlan_tci = ETHER_TYPE_IPv4;
pkt->l3_len = sizeof(struct ipv4_hdr);
-
- if (vlan_enabled)
- pkt->ol_flags = PKT_RX_IPV4_HDR | PKT_RX_VLAN_PKT;
- else
- pkt->ol_flags = PKT_RX_IPV4_HDR;
} else {
pkt->vlan_tci = ETHER_TYPE_IPv6;
pkt->l3_len = sizeof(struct ipv6_hdr);
-
- if (vlan_enabled)
- pkt->ol_flags = PKT_RX_IPV6_HDR | PKT_RX_VLAN_PKT;
- else
- pkt->ol_flags = PKT_RX_IPV6_HDR;
}
pkts_burst[nb_pkt] = pkt;
void
initialize_eth_header(struct ether_hdr *eth_hdr, struct ether_addr *src_mac,
- struct ether_addr *dst_mac, uint8_t vlan_enabled, uint16_t van_id);
+ struct ether_addr *dst_mac, uint8_t ipv4, uint8_t vlan_enabled,
+ uint16_t van_id);
uint16_t
initialize_udp_header(struct udp_hdr *udp_hdr, uint16_t src_port,
if (toggle_dst_mac)
initialize_eth_header(test_params->pkt_eth_hdr,
(struct ether_addr *)src_mac, (struct ether_addr *)dst_mac_1,
- vlan, vlan_id);
+ ipv4, vlan, vlan_id);
else
initialize_eth_header(test_params->pkt_eth_hdr,
(struct ether_addr *)src_mac, (struct ether_addr *)dst_mac_0,
- vlan, vlan_id);
+ ipv4, vlan, vlan_id);
if (toggle_udp_port)
"Failed to initialize bonded device with slaves");
initialize_eth_header(test_params->pkt_eth_hdr,
- (struct ether_addr *)src_mac, (struct ether_addr *)dst_mac_0, 0, 0);
+ (struct ether_addr *)src_mac, (struct ether_addr *)dst_mac_0, 1, 0, 0);
pktlen = initialize_udp_header(test_params->pkt_udp_hdr, src_port,
dst_port_0, 16);
pktlen = initialize_ipv4_header(test_params->pkt_ipv4_hdr, src_addr,
"Failed to set balance xmit policy.");
initialize_eth_header(test_params->pkt_eth_hdr,
- (struct ether_addr *)src_mac, (struct ether_addr *)dst_mac_0, 0, 0);
+ (struct ether_addr *)src_mac, (struct ether_addr *)dst_mac_0, 1, 0, 0);
pktlen = initialize_udp_header(test_params->pkt_udp_hdr, src_port,
dst_port_0, 16);
pktlen = initialize_ipv4_header(test_params->pkt_ipv4_hdr, src_addr,
"failed to generate packet burst");
initialize_eth_header(test_params->pkt_eth_hdr,
- (struct ether_addr *)src_mac, (struct ether_addr *)dst_mac_1, 0, 0);
+ (struct ether_addr *)src_mac, (struct ether_addr *)dst_mac_1, 1, 0, 0);
/* Generate a burst 2 of packets to transmit */
TEST_ASSERT_EQUAL(generate_packet_burst(test_params->mbuf_pool, &pkts_burst[1][0],
"Failed to intialise bonded device");
initialize_eth_header(test_params->pkt_eth_hdr,
- (struct ether_addr *)src_mac, (struct ether_addr *)dst_mac_0, 0, 0);
+ (struct ether_addr *)src_mac, (struct ether_addr *)dst_mac_0, 1, 0, 0);
pktlen = initialize_udp_header(test_params->pkt_udp_hdr, src_port,
dst_port_0, 16);
if (i % 2 == 0) {
initialize_eth_header(test_params->pkt_eth_hdr,
(struct ether_addr *)src_mac,
- (struct ether_addr *)dst_mac_0, 0, 0);
+ (struct ether_addr *)dst_mac_0, 1, 0, 0);
} else {
initialize_eth_header(test_params->pkt_eth_hdr,
(struct ether_addr *)test_params->default_slave_mac,
- (struct ether_addr *)dst_mac_0, 0, 0);
+ (struct ether_addr *)dst_mac_0, 1, 0, 0);
}
pktlen = initialize_udp_header(test_params->pkt_udp_hdr, src_port,
dst_port_0, 16);
initialize_eth_header(&pkt_eth_hdr,
(struct ether_addr *)src_mac,
- (struct ether_addr *)dst_mac, 0, 0);
+ (struct ether_addr *)dst_mac, 1, 0, 0);
pkt_eth_hdr.ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4);
pktlen = initialize_ipv4_header(&pkt_ipv4_hdr,
}
static inline size_t
-get_vlan_offset(struct ether_hdr *eth_hdr)
+get_vlan_offset(struct ether_hdr *eth_hdr, uint16_t *proto)
{
size_t vlan_offset = 0;
- /* Calculate VLAN offset */
- if (rte_cpu_to_be_16(ETHER_TYPE_VLAN) == eth_hdr->ether_type) {
+ if (rte_cpu_to_be_16(ETHER_TYPE_VLAN) == *proto) {
struct vlan_hdr *vlan_hdr = (struct vlan_hdr *)(eth_hdr + 1);
vlan_offset = sizeof(struct vlan_hdr);
+ *proto = vlan_hdr->eth_proto;
- while (rte_cpu_to_be_16(ETHER_TYPE_VLAN) ==
- vlan_hdr->eth_proto) {
+ if (rte_cpu_to_be_16(ETHER_TYPE_VLAN) == *proto) {
vlan_hdr = vlan_hdr + 1;
+
+ *proto = vlan_hdr->eth_proto;
vlan_offset += sizeof(struct vlan_hdr);
}
}
xmit_l23_hash(const struct rte_mbuf *buf, uint8_t slave_count)
{
struct ether_hdr *eth_hdr = rte_pktmbuf_mtod(buf, struct ether_hdr *);
- size_t vlan_offset = get_vlan_offset(eth_hdr);
+ uint16_t proto = eth_hdr->ether_type;
+ size_t vlan_offset = get_vlan_offset(eth_hdr, &proto);
uint32_t hash, l3hash = 0;
hash = ether_hash(eth_hdr);
- if (buf->ol_flags & PKT_RX_IPV4_HDR) {
+ if (rte_cpu_to_be_16(ETHER_TYPE_IPv4) == proto) {
struct ipv4_hdr *ipv4_hdr = (struct ipv4_hdr *)
((char *)(eth_hdr + 1) + vlan_offset);
l3hash = ipv4_hash(ipv4_hdr);
- } else if (buf->ol_flags & PKT_RX_IPV6_HDR) {
+ } else if (rte_cpu_to_be_16(ETHER_TYPE_IPv6) == proto) {
struct ipv6_hdr *ipv6_hdr = (struct ipv6_hdr *)
((char *)(eth_hdr + 1) + vlan_offset);
l3hash = ipv6_hash(ipv6_hdr);
xmit_l34_hash(const struct rte_mbuf *buf, uint8_t slave_count)
{
struct ether_hdr *eth_hdr = rte_pktmbuf_mtod(buf, struct ether_hdr *);
- size_t vlan_offset = get_vlan_offset(eth_hdr);
+ uint16_t proto = eth_hdr->ether_type;
+ size_t vlan_offset = get_vlan_offset(eth_hdr, &proto);
+
struct udp_hdr *udp_hdr = NULL;
struct tcp_hdr *tcp_hdr = NULL;
uint32_t hash, l3hash = 0, l4hash = 0;
- if (buf->ol_flags & PKT_RX_IPV4_HDR) {
+ if (rte_cpu_to_be_16(ETHER_TYPE_IPv4) == proto) {
struct ipv4_hdr *ipv4_hdr = (struct ipv4_hdr *)
((char *)(eth_hdr + 1) + vlan_offset);
size_t ip_hdr_offset;
ip_hdr_offset);
l4hash = HASH_L4_PORTS(udp_hdr);
}
- } else if (buf->ol_flags & PKT_RX_IPV6_HDR) {
+ } else if (rte_cpu_to_be_16(ETHER_TYPE_IPv6) == proto) {
struct ipv6_hdr *ipv6_hdr = (struct ipv6_hdr *)
((char *)(eth_hdr + 1) + vlan_offset);
l3hash = ipv6_hash(ipv6_hdr);