1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2018 Intel Corporation 3 */ 4 5 #ifndef _MACSWAP_H_ 6 #define _MACSWAP_H_ 7 8 #include "macswap_common.h" 9 10 static inline void 11 do_macswap(struct rte_mbuf *pkts[], uint16_t nb, 12 struct rte_port *txp) 13 { 14 struct rte_ether_hdr *eth_hdr; 15 struct rte_mbuf *mb; 16 struct rte_ether_addr addr; 17 uint64_t ol_flags; 18 int i; 19 20 ol_flags = ol_flags_init(txp->dev_conf.txmode.offloads); 21 vlan_qinq_set(pkts, nb, ol_flags, 22 txp->tx_vlan_id, txp->tx_vlan_id_outer); 23 24 for (i = 0; i < nb; i++) { 25 if (likely(i < nb - 1)) 26 rte_prefetch0(rte_pktmbuf_mtod(pkts[i+1], void *)); 27 mb = pkts[i]; 28 29 eth_hdr = rte_pktmbuf_mtod(mb, struct rte_ether_hdr *); 30 31 /* Swap dest and src mac addresses. */ 32 rte_ether_addr_copy(ð_hdr->dst_addr, &addr); 33 rte_ether_addr_copy(ð_hdr->src_addr, ð_hdr->dst_addr); 34 rte_ether_addr_copy(&addr, ð_hdr->src_addr); 35 36 mbuf_field_set(mb, ol_flags); 37 } 38 } 39 40 #endif /* _MACSWAP_H_ */ 41