#include <stdint.h>
#include "main.h"
#include "vxlan.h"
static uint16_t
get_psd_sum(void *l3_hdr, uint16_t ethertype, uint64_t ol_flags)
{
else
}
static void
parse_ethernet(
struct rte_ether_hdr *eth_hdr,
union tunnel_offload_info *info,
uint8_t *l4_proto)
{
uint16_t ethertype;
}
switch (ethertype) {
((char *)eth_hdr + info->outer_l2_len);
break;
((char *)eth_hdr + info->outer_l2_len);
*l4_proto = ipv6_hdr->
proto;
break;
default:
info->outer_l3_len = 0;
*l4_proto = 0;
break;
}
}
static uint64_t
union tunnel_offload_info *info)
{
void *l3_hdr = NULL;
uint8_t l4_proto;
uint16_t ethertype;
uint64_t ol_flags = 0;
}
l3_hdr = (char *)eth_hdr + info->l2_len;
l4_proto = ipv6_hdr->
proto;
} else
return 0;
if (l4_proto == IPPROTO_UDP) {
udp_hdr = (
struct rte_udp_hdr *)((
char *)l3_hdr + info->l3_len);
ethertype, ol_flags);
} else if (l4_proto == IPPROTO_TCP) {
tcp_hdr = (
struct rte_tcp_hdr *)((
char *)l3_hdr + info->l3_len);
if (tso_segsz != 0) {
info->tso_segsz = tso_segsz;
info->l4_len = (tcp_hdr->
data_off & 0xf0) >> 2;
}
tcp_hdr->
cksum = get_psd_sum(l3_hdr, ethertype, ol_flags);
} else if (l4_proto == IPPROTO_SCTP) {
((char *)l3_hdr + info->l3_len);
}
return ol_flags;
}
int
{
uint8_t l4_proto = 0;
uint16_t outer_header_len;
union tunnel_offload_info info = { .data = 0 };
parse_ethernet(phdr, &info, &l4_proto);
if (l4_proto != IPPROTO_UDP)
return -1;
info.outer_l2_len + info.outer_l3_len);
return -1;
outer_header_len = info.outer_l2_len + info.outer_l3_len
+
sizeof(
struct rte_udp_hdr) + sizeof(struct rte_vxlan_hdr);
return 0;
}
void
encapsulation(
struct rte_mbuf *m, uint8_t queue_id)
{
uint vport_id;
uint64_t ol_flags = 0;
uint32_t old_len = m->
pkt_len, hash;
union tunnel_offload_info tx_offload = { .data = 0 };
+ sizeof(struct rte_udp_hdr) + sizeof(struct rte_vxlan_hdr));
struct rte_udp_hdr *udp = (struct rte_udp_hdr *) &ip[1];
struct rte_vxlan_hdr *vxlan = (struct rte_vxlan_hdr *) &udp[1];
vport_id = queue_id - 1;
if (tx_checksum) {
ol_flags |= process_inner_cksums(phdr, &tx_offload);
m->
l2_len = tx_offload.l2_len;
m->
l3_len = tx_offload.l3_len;
m->
l4_len = tx_offload.l4_len;
}
+ sizeof(struct rte_udp_hdr)
+ sizeof(struct rte_vxlan_hdr));
+ PORT_MIN);
return;
}