]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/dpdk/app/test-pmd/macswap.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / dpdk / app / test-pmd / macswap.h
CommitLineData
9f95a23c
TL
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
10static inline void
11do_macswap(struct rte_mbuf *pkts[], uint16_t nb,
12 struct rte_port *txp)
13{
f67539c2 14 struct rte_ether_hdr *eth_hdr;
9f95a23c 15 struct rte_mbuf *mb;
f67539c2 16 struct rte_ether_addr addr;
9f95a23c
TL
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
f67539c2 29 eth_hdr = rte_pktmbuf_mtod(mb, struct rte_ether_hdr *);
9f95a23c
TL
30
31 /* Swap dest and src mac addresses. */
f67539c2
TL
32 rte_ether_addr_copy(&eth_hdr->d_addr, &addr);
33 rte_ether_addr_copy(&eth_hdr->s_addr, &eth_hdr->d_addr);
34 rte_ether_addr_copy(&addr, &eth_hdr->s_addr);
9f95a23c
TL
35
36 mbuf_field_set(mb, ol_flags);
37 }
38}
39
40#endif /* _MACSWAP_H_ */