2018-12-16 00:58:33 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
* Copyright(c) 2018 Intel Corporation
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _MACSWAP_H_
|
|
|
|
#define _MACSWAP_H_
|
|
|
|
|
|
|
|
#include "macswap_common.h"
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
do_macswap(struct rte_mbuf *pkts[], uint16_t nb,
|
|
|
|
struct rte_port *txp)
|
|
|
|
{
|
2019-05-21 16:13:03 +00:00
|
|
|
struct rte_ether_hdr *eth_hdr;
|
2018-12-16 00:58:33 +00:00
|
|
|
struct rte_mbuf *mb;
|
2019-05-21 16:13:03 +00:00
|
|
|
struct rte_ether_addr addr;
|
2018-12-16 00:58:33 +00:00
|
|
|
uint64_t ol_flags;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
ol_flags = ol_flags_init(txp->dev_conf.txmode.offloads);
|
|
|
|
vlan_qinq_set(pkts, nb, ol_flags,
|
|
|
|
txp->tx_vlan_id, txp->tx_vlan_id_outer);
|
|
|
|
|
|
|
|
for (i = 0; i < nb; i++) {
|
|
|
|
if (likely(i < nb - 1))
|
|
|
|
rte_prefetch0(rte_pktmbuf_mtod(pkts[i+1], void *));
|
|
|
|
mb = pkts[i];
|
|
|
|
|
2019-05-21 16:13:03 +00:00
|
|
|
eth_hdr = rte_pktmbuf_mtod(mb, struct rte_ether_hdr *);
|
2018-12-16 00:58:33 +00:00
|
|
|
|
|
|
|
/* Swap dest and src mac addresses. */
|
2019-05-21 16:13:04 +00:00
|
|
|
rte_ether_addr_copy(ð_hdr->d_addr, &addr);
|
|
|
|
rte_ether_addr_copy(ð_hdr->s_addr, ð_hdr->d_addr);
|
|
|
|
rte_ether_addr_copy(&addr, ð_hdr->s_addr);
|
2018-12-16 00:58:33 +00:00
|
|
|
|
|
|
|
mbuf_field_set(mb, ol_flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* _MACSWAP_H_ */
|