X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=VNFs%2FDPPD-PROX%2Fhandle_lb_5tuple.c;h=d320ca9dccc86fad0bf435245de2987277189d03;hb=1f50af6cc73dd820b7a2a9bc12d1d365bfe8dfd9;hp=ae973f1cbf0a3ecfa3bd75ad95c922f2f6d95ea7;hpb=cb94e0036256c6a3fb0aadb682a04d8ad30ddd2a;p=samplevnf.git diff --git a/VNFs/DPPD-PROX/handle_lb_5tuple.c b/VNFs/DPPD-PROX/handle_lb_5tuple.c index ae973f1c..d320ca9d 100644 --- a/VNFs/DPPD-PROX/handle_lb_5tuple.c +++ b/VNFs/DPPD-PROX/handle_lb_5tuple.c @@ -39,8 +39,9 @@ #include "quit.h" #define BYTE_VALUE_MAX 256 -#define ALL_32_BITS 0xffffffff -#define BIT_8_TO_15 0x0000ff00 +#define BIT_8_TO_10 0x0000e000 // for protocol field +#define BIT_27_TO_31 0x1f000000 // for IP addresses +#define BIT_12_TO_16_27_TO_31 0x1f001f00 // for ports #define HASH_MAX_SIZE 4*8*1024*1024 @@ -57,10 +58,10 @@ static inline uint8_t get_ipv4_dst_port(struct task_lb_5tuple *task, void *ipv4_ 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(prox_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 */ - key.xmm = _mm_and_si128(data, mask0); + key.xmm = _mm_and_si128(data, mask0); /* Get 5 tuple: dst port, src port, dst IP address, src IP address and protocol */ /* @@ -75,15 +76,15 @@ static inline uint8_t get_ipv4_dst_port(struct task_lb_5tuple *task, void *ipv4_ static inline uint8_t handle_lb_5tuple(struct task_lb_5tuple *task, struct rte_mbuf *mbuf) { - struct ether_hdr *eth_hdr; - struct ipv4_hdr *ipv4_hdr; + prox_rte_ether_hdr *eth_hdr; + prox_rte_ipv4_hdr *ipv4_hdr; - eth_hdr = rte_pktmbuf_mtod(mbuf, struct ether_hdr *); + eth_hdr = rte_pktmbuf_mtod(mbuf, prox_rte_ether_hdr *); switch (eth_hdr->ether_type) { case ETYPE_IPv4: /* Handle IPv4 headers.*/ - ipv4_hdr = (struct ipv4_hdr *) (eth_hdr + 1); + ipv4_hdr = (prox_rte_ipv4_hdr *) (eth_hdr + 1); return get_ipv4_dst_port(task, ipv4_hdr, OUT_DISCARD, task->lookup_hash); default: return OUT_DISCARD; @@ -120,8 +121,7 @@ static void init_task_lb_5tuple(struct task_base *tbase, struct task_args *targ) struct task_lb_5tuple *task = (struct task_lb_5tuple *)tbase; const int socket_id = rte_lcore_to_socket_id(targ->lconf->id); - mask0 = _mm_set_epi32(ALL_32_BITS, ALL_32_BITS, ALL_32_BITS, BIT_8_TO_15); - + mask0 = _mm_set_epi32(BIT_12_TO_16_27_TO_31, BIT_27_TO_31, BIT_27_TO_31, BIT_8_TO_10); uint8_t *out_table = task->out_if; int ret = lua_to_tuples(prox_lua(), GLOBAL, "tuples", socket_id, &task->lookup_hash, &out_table); PROX_PANIC(ret, "Failed to read tuples from config\n");