1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation
5 #ifndef _MACSWAP_SSE_H_
6 #define _MACSWAP_SSE_H_
8 #include "macswap_common.h"
11 do_macswap(struct rte_mbuf *pkts[], uint16_t nb,
14 struct ether_hdr *eth_hdr;
20 * shuffle mask be used to shuffle the 16 bytes.
21 * byte 0-5 wills be swapped with byte 6-11.
22 * byte 12-15 will keep unchanged.
24 __m128i shfl_msk = _mm_set_epi8(15, 14, 13, 12,
29 ol_flags = ol_flags_init(txp->dev_conf.txmode.offloads);
30 vlan_qinq_set(pkts, nb, ol_flags,
31 txp->tx_vlan_id, txp->tx_vlan_id_outer);
33 for (i = 0; i < nb; i++) {
34 if (likely(i < nb - 1))
35 rte_prefetch0(rte_pktmbuf_mtod(pkts[i+1], void *));
38 eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);
40 /* Swap dest and src mac addresses. */
41 addr = _mm_loadu_si128((__m128i *)eth_hdr);
42 addr = _mm_shuffle_epi8(addr, shfl_msk);
43 _mm_storeu_si128((__m128i *)eth_hdr, addr);
45 mbuf_field_set(mb, ol_flags);
49 #endif /* _MACSWAP_SSE_H_ */