X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=VNFs%2FDPPD-PROX%2Fhandle_nsh.c;h=6d67f99d8b35b28a16aec962bea78cd05e1c3b47;hb=4fa870ba4647271b11ae7927ead2696e13dad7e4;hp=65a80c3d85ce1703ffc703353660ed3aa104d945;hpb=a0eb3c45ca8a89220caaefa43665a7a1eb6c1933;p=samplevnf.git diff --git a/VNFs/DPPD-PROX/handle_nsh.c b/VNFs/DPPD-PROX/handle_nsh.c index 65a80c3d..6d67f99d 100644 --- a/VNFs/DPPD-PROX/handle_nsh.c +++ b/VNFs/DPPD-PROX/handle_nsh.c @@ -18,6 +18,10 @@ #include #include #include +#include +#if RTE_VERSION >= RTE_VERSION_NUM(19,11,0,0) +#include +#endif #include "vxlangpe_nsh.h" #include "task_base.h" @@ -27,7 +31,7 @@ #include "prefetch.h" #include "log.h" -#define VXLAN_GPE_HDR_SZ sizeof(struct ether_hdr) + sizeof(struct ipv4_hdr) + sizeof(struct udp_hdr) + sizeof(struct vxlan_gpe_hdr) + sizeof(struct nsh_hdr) +#define VXLAN_GPE_HDR_SZ sizeof(prox_rte_ether_hdr) + sizeof(prox_rte_ipv4_hdr) + sizeof(prox_rte_udp_hdr) + sizeof(prox_rte_vxlan_gpe_hdr) + sizeof(struct nsh_hdr) #define ETHER_NSH_TYPE 0x4F89 /* 0x894F in little endian */ #define VXLAN_GPE_NSH_TYPE 0xB612 /* 4790 in little endian */ #define VXLAN_GPE_NP 0x4 @@ -51,15 +55,15 @@ static void init_task_decap_nsh(__attribute__((unused)) struct task_base *tbase, static inline uint8_t handle_decap_nsh(__attribute__((unused)) struct task_decap_nsh *task, struct rte_mbuf *mbuf) { - struct ether_hdr *eth_hdr = NULL; - struct udp_hdr *udp_hdr = NULL; - struct vxlan_gpe_hdr *vxlan_gpe_hdr = NULL; + prox_rte_ether_hdr *eth_hdr = NULL; + prox_rte_udp_hdr *udp_hdr = NULL; + prox_rte_vxlan_gpe_hdr *vxlan_gpe_hdr = NULL; uint16_t hdr_len; - eth_hdr = rte_pktmbuf_mtod(mbuf, struct ether_hdr *); + eth_hdr = rte_pktmbuf_mtod(mbuf, prox_rte_ether_hdr *); if (eth_hdr->ether_type == ETHER_NSH_TYPE) { /* "decapsulate" Ethernet + NSH header by moving packet pointer */ - hdr_len = sizeof(struct ether_hdr) + sizeof(struct nsh_hdr); + hdr_len = sizeof(prox_rte_ether_hdr) + sizeof(struct nsh_hdr); mbuf->data_len = (uint16_t)(mbuf->data_len - hdr_len); mbuf->data_off += hdr_len; @@ -74,15 +78,15 @@ static inline uint8_t handle_decap_nsh(__attribute__((unused)) struct task_decap } /* check the UDP destination port */ - udp_hdr = (struct udp_hdr *)(((unsigned char *)eth_hdr) + sizeof(struct ether_hdr) + sizeof(struct ipv4_hdr)); + udp_hdr = (prox_rte_udp_hdr *)(((unsigned char *)eth_hdr) + sizeof(prox_rte_ether_hdr) + sizeof(prox_rte_ipv4_hdr)); if (udp_hdr->dst_port != VXLAN_GPE_NSH_TYPE) { mbuf->udata64 = 0; return 0; } /* check the Next Protocol field in VxLAN-GPE header */ - vxlan_gpe_hdr = (struct vxlan_gpe_hdr *)(((unsigned char *)eth_hdr) + sizeof(struct ether_hdr) + sizeof(struct ipv4_hdr) + sizeof(struct udp_hdr)); - if (vxlan_gpe_hdr->next_proto != VXLAN_GPE_NP) { + vxlan_gpe_hdr = (prox_rte_vxlan_gpe_hdr *)(((unsigned char *)eth_hdr) + sizeof(prox_rte_ether_hdr) + sizeof(prox_rte_ipv4_hdr) + sizeof(prox_rte_udp_hdr)); + if (vxlan_gpe_hdr->proto != VXLAN_GPE_NP) { mbuf->udata64 = 0; return 0; } @@ -131,10 +135,10 @@ static void init_task_encap_nsh(__attribute__((unused)) struct task_base *tbase, static inline uint8_t handle_encap_nsh(__attribute__((unused)) struct task_encap_nsh *task, struct rte_mbuf *mbuf) { - struct ether_hdr *eth_hdr = NULL; + prox_rte_ether_hdr *eth_hdr = NULL; struct nsh_hdr *nsh_hdr = NULL; - struct udp_hdr *udp_hdr = NULL; - struct vxlan_gpe_hdr *vxlan_gpe_hdr = NULL; + prox_rte_udp_hdr *udp_hdr = NULL; + prox_rte_vxlan_gpe_hdr *vxlan_gpe_hdr = NULL; uint16_t hdr_len; if (mbuf == NULL) @@ -148,9 +152,9 @@ static inline uint8_t handle_encap_nsh(__attribute__((unused)) struct task_encap mbuf->data_off -= mbuf->udata64; mbuf->pkt_len = (uint32_t)(mbuf->pkt_len + mbuf->udata64); - eth_hdr = rte_pktmbuf_mtod(mbuf, struct ether_hdr *); + eth_hdr = rte_pktmbuf_mtod(mbuf, prox_rte_ether_hdr *); if (eth_hdr->ether_type == ETHER_NSH_TYPE) { - nsh_hdr = (struct nsh_hdr *) (((unsigned char *)eth_hdr) + sizeof(struct ether_hdr)); + nsh_hdr = (struct nsh_hdr *) (((unsigned char *)eth_hdr) + sizeof(prox_rte_ether_hdr)); /* decrement Service Index in NSH header */ if (nsh_hdr->sf_index > 0) @@ -162,17 +166,17 @@ static inline uint8_t handle_encap_nsh(__attribute__((unused)) struct task_encap return 0; /* check the UDP destination port */ - udp_hdr = (struct udp_hdr *)(((unsigned char *)eth_hdr) + sizeof(struct ether_hdr) + sizeof(struct ipv4_hdr)); + udp_hdr = (prox_rte_udp_hdr *)(((unsigned char *)eth_hdr) + sizeof(prox_rte_ether_hdr) + sizeof(prox_rte_ipv4_hdr)); if (udp_hdr->dst_port != VXLAN_GPE_NSH_TYPE) return 0; /* check the Next Protocol field in VxLAN-GPE header */ - vxlan_gpe_hdr = (struct vxlan_gpe_hdr *)(((unsigned char *)eth_hdr) + sizeof(struct ether_hdr) + sizeof(struct ipv4_hdr) + sizeof(struct udp_hdr)); - if (vxlan_gpe_hdr->next_proto != VXLAN_GPE_NP) + vxlan_gpe_hdr = (prox_rte_vxlan_gpe_hdr *)(((unsigned char *)eth_hdr) + sizeof(prox_rte_ether_hdr) + sizeof(prox_rte_ipv4_hdr) + sizeof(prox_rte_udp_hdr)); + if (vxlan_gpe_hdr->proto != VXLAN_GPE_NP) return 0; /* decrement Service Index in NSH header */ - nsh_hdr = (struct nsh_hdr *)(((unsigned char *)vxlan_gpe_hdr) + sizeof(struct vxlan_gpe_hdr)); + nsh_hdr = (struct nsh_hdr *)(((unsigned char *)vxlan_gpe_hdr) + sizeof(prox_rte_vxlan_gpe_hdr)); if (nsh_hdr->sf_index > 0) nsh_hdr->sf_index -= 1; }