xref: /dpdk/examples/l3fwd/l3fwd_em_hlm_sse.h (revision a7c528e5d71ff3f569898d268f9de129fdfc152b)
13998e2a0SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
23998e2a0SBruce Richardson  * Copyright(c) 2016 Intel Corporation
394c54b41STomasz Kulasek  */
494c54b41STomasz Kulasek 
594c54b41STomasz Kulasek #ifndef __L3FWD_EM_HLM_SSE_H__
694c54b41STomasz Kulasek #define __L3FWD_EM_HLM_SSE_H__
794c54b41STomasz Kulasek 
894c54b41STomasz Kulasek #include "l3fwd_sse.h"
994c54b41STomasz Kulasek 
10c0583d98SJerin Jacob static __rte_always_inline void
get_ipv4_5tuple(struct rte_mbuf * m0,__m128i mask0,union ipv4_5tuple_host * key)118ec858abSJianbo Liu get_ipv4_5tuple(struct rte_mbuf *m0, __m128i mask0,
128ec858abSJianbo Liu 		union ipv4_5tuple_host *key)
1394c54b41STomasz Kulasek {
148ec858abSJianbo Liu 	 __m128i tmpdata0 = _mm_loadu_si128(
158ec858abSJianbo Liu 			rte_pktmbuf_mtod_offset(m0, __m128i *,
166d13ea8eSOlivier Matz 				sizeof(struct rte_ether_hdr) +
17*a7c528e5SOlivier Matz 				offsetof(struct rte_ipv4_hdr, time_to_live)));
1894c54b41STomasz Kulasek 
198ec858abSJianbo Liu 	key->xmm = _mm_and_si128(tmpdata0, mask0);
2094c54b41STomasz Kulasek }
2194c54b41STomasz Kulasek 
2294c54b41STomasz Kulasek static inline void
get_ipv6_5tuple(struct rte_mbuf * m0,__m128i mask0,__m128i mask1,union ipv6_5tuple_host * key)2394c54b41STomasz Kulasek get_ipv6_5tuple(struct rte_mbuf *m0, __m128i mask0,
2494c54b41STomasz Kulasek 		__m128i mask1, union ipv6_5tuple_host *key)
2594c54b41STomasz Kulasek {
2694c54b41STomasz Kulasek 	__m128i tmpdata0 = _mm_loadu_si128(
2794c54b41STomasz Kulasek 			rte_pktmbuf_mtod_offset(m0, __m128i *,
286d13ea8eSOlivier Matz 				sizeof(struct rte_ether_hdr) +
29*a7c528e5SOlivier Matz 				offsetof(struct rte_ipv6_hdr, payload_len)));
3094c54b41STomasz Kulasek 
3194c54b41STomasz Kulasek 	__m128i tmpdata1 = _mm_loadu_si128(
3294c54b41STomasz Kulasek 			rte_pktmbuf_mtod_offset(m0, __m128i *,
336d13ea8eSOlivier Matz 				sizeof(struct rte_ether_hdr) +
34*a7c528e5SOlivier Matz 				offsetof(struct rte_ipv6_hdr, payload_len) +
3594c54b41STomasz Kulasek 				sizeof(__m128i)));
3694c54b41STomasz Kulasek 
3794c54b41STomasz Kulasek 	__m128i tmpdata2 = _mm_loadu_si128(
3894c54b41STomasz Kulasek 			rte_pktmbuf_mtod_offset(m0, __m128i *,
396d13ea8eSOlivier Matz 				sizeof(struct rte_ether_hdr) +
40*a7c528e5SOlivier Matz 				offsetof(struct rte_ipv6_hdr, payload_len) +
4194c54b41STomasz Kulasek 				sizeof(__m128i) + sizeof(__m128i)));
4294c54b41STomasz Kulasek 
4394c54b41STomasz Kulasek 	key->xmm[0] = _mm_and_si128(tmpdata0, mask0);
4494c54b41STomasz Kulasek 	key->xmm[1] = tmpdata1;
4594c54b41STomasz Kulasek 	key->xmm[2] = _mm_and_si128(tmpdata2, mask1);
4694c54b41STomasz Kulasek }
4794c54b41STomasz Kulasek #endif /* __L3FWD_EM_SSE_HLM_H__ */
48