X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=examples%2Ftep_termination%2Fvxlan.c;h=0ba6b8be8bcc1fa3c62059cc6f15521584a4f59f;hb=1d049dc7623e4c0506c9c34dbb168ad9530daae0;hp=cc171fbbc09f148fb88c746ea518055f95d4a961;hpb=35b2d13fd6fdcbd191f2a30d74648faeb1186c65;p=dpdk.git diff --git a/examples/tep_termination/vxlan.c b/examples/tep_termination/vxlan.c index cc171fbbc0..0ba6b8be8b 100644 --- a/examples/tep_termination/vxlan.c +++ b/examples/tep_termination/vxlan.c @@ -16,9 +16,9 @@ static uint16_t get_psd_sum(void *l3_hdr, uint16_t ethertype, uint64_t ol_flags) { - if (ethertype == RTE_ETHER_TYPE_IPv4) + if (ethertype == RTE_ETHER_TYPE_IPV4) return rte_ipv4_phdr_cksum(l3_hdr, ol_flags); - else /* assume ethertype == RTE_ETHER_TYPE_IPv6 */ + else /* assume ethertype == RTE_ETHER_TYPE_IPV6 */ return rte_ipv6_phdr_cksum(l3_hdr, ol_flags); } @@ -31,8 +31,8 @@ static void parse_ethernet(struct rte_ether_hdr *eth_hdr, union tunnel_offload_info *info, uint8_t *l4_proto) { - struct ipv4_hdr *ipv4_hdr; - struct ipv6_hdr *ipv6_hdr; + struct rte_ipv4_hdr *ipv4_hdr; + struct rte_ipv6_hdr *ipv6_hdr; uint16_t ethertype; info->outer_l2_len = sizeof(struct rte_ether_hdr); @@ -46,16 +46,16 @@ parse_ethernet(struct rte_ether_hdr *eth_hdr, union tunnel_offload_info *info, } switch (ethertype) { - case RTE_ETHER_TYPE_IPv4: - ipv4_hdr = (struct ipv4_hdr *) + case RTE_ETHER_TYPE_IPV4: + ipv4_hdr = (struct rte_ipv4_hdr *) ((char *)eth_hdr + info->outer_l2_len); - info->outer_l3_len = sizeof(struct ipv4_hdr); + info->outer_l3_len = sizeof(struct rte_ipv4_hdr); *l4_proto = ipv4_hdr->next_proto_id; break; - case RTE_ETHER_TYPE_IPv6: - ipv6_hdr = (struct ipv6_hdr *) + case RTE_ETHER_TYPE_IPV6: + ipv6_hdr = (struct rte_ipv6_hdr *) ((char *)eth_hdr + info->outer_l2_len); - info->outer_l3_len = sizeof(struct ipv6_hdr); + info->outer_l3_len = sizeof(struct rte_ipv6_hdr); *l4_proto = ipv6_hdr->proto; break; default: @@ -75,11 +75,11 @@ process_inner_cksums(struct rte_ether_hdr *eth_hdr, void *l3_hdr = NULL; uint8_t l4_proto; uint16_t ethertype; - struct ipv4_hdr *ipv4_hdr; - struct ipv6_hdr *ipv6_hdr; - struct udp_hdr *udp_hdr; - struct tcp_hdr *tcp_hdr; - struct sctp_hdr *sctp_hdr; + struct rte_ipv4_hdr *ipv4_hdr; + struct rte_ipv6_hdr *ipv6_hdr; + struct rte_udp_hdr *udp_hdr; + struct rte_tcp_hdr *tcp_hdr; + struct rte_sctp_hdr *sctp_hdr; uint64_t ol_flags = 0; info->l2_len = sizeof(struct rte_ether_hdr); @@ -94,28 +94,28 @@ process_inner_cksums(struct rte_ether_hdr *eth_hdr, l3_hdr = (char *)eth_hdr + info->l2_len; - if (ethertype == RTE_ETHER_TYPE_IPv4) { - ipv4_hdr = (struct ipv4_hdr *)l3_hdr; + if (ethertype == RTE_ETHER_TYPE_IPV4) { + ipv4_hdr = (struct rte_ipv4_hdr *)l3_hdr; ipv4_hdr->hdr_checksum = 0; ol_flags |= PKT_TX_IPV4; ol_flags |= PKT_TX_IP_CKSUM; - info->l3_len = sizeof(struct ipv4_hdr); + info->l3_len = sizeof(struct rte_ipv4_hdr); l4_proto = ipv4_hdr->next_proto_id; - } else if (ethertype == RTE_ETHER_TYPE_IPv6) { - ipv6_hdr = (struct ipv6_hdr *)l3_hdr; - info->l3_len = sizeof(struct ipv6_hdr); + } else if (ethertype == RTE_ETHER_TYPE_IPV6) { + ipv6_hdr = (struct rte_ipv6_hdr *)l3_hdr; + info->l3_len = sizeof(struct rte_ipv6_hdr); l4_proto = ipv6_hdr->proto; ol_flags |= PKT_TX_IPV6; } else return 0; /* packet type not supported, nothing to do */ if (l4_proto == IPPROTO_UDP) { - udp_hdr = (struct udp_hdr *)((char *)l3_hdr + info->l3_len); + udp_hdr = (struct rte_udp_hdr *)((char *)l3_hdr + info->l3_len); ol_flags |= PKT_TX_UDP_CKSUM; udp_hdr->dgram_cksum = get_psd_sum(l3_hdr, ethertype, ol_flags); } else if (l4_proto == IPPROTO_TCP) { - tcp_hdr = (struct tcp_hdr *)((char *)l3_hdr + info->l3_len); + tcp_hdr = (struct rte_tcp_hdr *)((char *)l3_hdr + info->l3_len); /* Put PKT_TX_TCP_SEG bit setting before get_psd_sum(), because * it depends on PKT_TX_TCP_SEG to calculate pseudo-header * checksum. @@ -129,7 +129,8 @@ process_inner_cksums(struct rte_ether_hdr *eth_hdr, tcp_hdr->cksum = get_psd_sum(l3_hdr, ethertype, ol_flags); } else if (l4_proto == IPPROTO_SCTP) { - sctp_hdr = (struct sctp_hdr *)((char *)l3_hdr + info->l3_len); + sctp_hdr = (struct rte_sctp_hdr *) + ((char *)l3_hdr + info->l3_len); sctp_hdr->cksum = 0; ol_flags |= PKT_TX_SCTP_CKSUM; } @@ -142,7 +143,7 @@ decapsulation(struct rte_mbuf *pkt) { uint8_t l4_proto = 0; uint16_t outer_header_len; - struct udp_hdr *udp_hdr; + struct rte_udp_hdr *udp_hdr; union tunnel_offload_info info = { .data = 0 }; struct rte_ether_hdr *phdr = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *); @@ -152,17 +153,17 @@ decapsulation(struct rte_mbuf *pkt) if (l4_proto != IPPROTO_UDP) return -1; - udp_hdr = (struct udp_hdr *)((char *)phdr + + udp_hdr = (struct rte_udp_hdr *)((char *)phdr + info.outer_l2_len + info.outer_l3_len); /** check udp destination port, 4789 is the default vxlan port * (rfc7348) or that the rx offload flag is set (i40e only * currently)*/ - if (udp_hdr->dst_port != rte_cpu_to_be_16(DEFAULT_VXLAN_PORT) && + if (udp_hdr->dst_port != rte_cpu_to_be_16(RTE_VXLAN_DEFAULT_PORT) && (pkt->packet_type & RTE_PTYPE_TUNNEL_MASK) == 0) return -1; outer_header_len = info.outer_l2_len + info.outer_l3_len - + sizeof(struct udp_hdr) + sizeof(struct rte_vxlan_hdr); + + sizeof(struct rte_udp_hdr) + sizeof(struct rte_vxlan_hdr); rte_pktmbuf_adj(pkt, outer_header_len); @@ -182,11 +183,11 @@ encapsulation(struct rte_mbuf *m, uint8_t queue_id) /*Allocate space for new ethernet, IPv4, UDP and VXLAN headers*/ struct rte_ether_hdr *pneth = (struct rte_ether_hdr *) rte_pktmbuf_prepend(m, - sizeof(struct rte_ether_hdr) + sizeof(struct ipv4_hdr) - + sizeof(struct udp_hdr) + sizeof(struct rte_vxlan_hdr)); + sizeof(struct rte_ether_hdr) + sizeof(struct rte_ipv4_hdr) + + sizeof(struct rte_udp_hdr) + sizeof(struct rte_vxlan_hdr)); - struct ipv4_hdr *ip = (struct ipv4_hdr *) &pneth[1]; - struct udp_hdr *udp = (struct udp_hdr *) &ip[1]; + struct rte_ipv4_hdr *ip = (struct rte_ipv4_hdr *) &pneth[1]; + struct rte_udp_hdr *udp = (struct rte_udp_hdr *) &ip[1]; struct rte_vxlan_hdr *vxlan = (struct rte_vxlan_hdr *) &udp[1]; /* convert TX queue ID to vport ID */ @@ -198,7 +199,7 @@ encapsulation(struct rte_mbuf *m, uint8_t queue_id) /* copy in IP header */ ip = rte_memcpy(ip, &app_ip_hdr[vport_id], - sizeof(struct ipv4_hdr)); + sizeof(struct rte_ipv4_hdr)); ip->total_length = rte_cpu_to_be_16(m->pkt_len - sizeof(struct rte_ether_hdr)); @@ -216,7 +217,7 @@ encapsulation(struct rte_mbuf *m, uint8_t queue_id) } m->outer_l2_len = sizeof(struct rte_ether_hdr); - m->outer_l3_len = sizeof(struct ipv4_hdr); + m->outer_l3_len = sizeof(struct rte_ipv4_hdr); ol_flags |= PKT_TX_TUNNEL_VXLAN; @@ -230,7 +231,7 @@ encapsulation(struct rte_mbuf *m, uint8_t queue_id) /*UDP HEADER*/ udp->dgram_cksum = 0; udp->dgram_len = rte_cpu_to_be_16(old_len - + sizeof(struct udp_hdr) + + sizeof(struct rte_udp_hdr) + sizeof(struct rte_vxlan_hdr)); udp->dst_port = rte_cpu_to_be_16(vxdev.dst_port);