summaryrefslogtreecommitdiffstats
path: root/src/spdk/dpdk/app/test-pmd/macswap.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /src/spdk/dpdk/app/test-pmd/macswap.h
parentInitial commit. (diff)
downloadceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz
ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/spdk/dpdk/app/test-pmd/macswap.h')
-rw-r--r--src/spdk/dpdk/app/test-pmd/macswap.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/spdk/dpdk/app/test-pmd/macswap.h b/src/spdk/dpdk/app/test-pmd/macswap.h
new file mode 100644
index 000000000..013844156
--- /dev/null
+++ b/src/spdk/dpdk/app/test-pmd/macswap.h
@@ -0,0 +1,40 @@
+/* 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)
+{
+ struct rte_ether_hdr *eth_hdr;
+ struct rte_mbuf *mb;
+ struct rte_ether_addr addr;
+ 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];
+
+ eth_hdr = rte_pktmbuf_mtod(mb, struct rte_ether_hdr *);
+
+ /* Swap dest and src mac addresses. */
+ rte_ether_addr_copy(&eth_hdr->d_addr, &addr);
+ rte_ether_addr_copy(&eth_hdr->s_addr, &eth_hdr->d_addr);
+ rte_ether_addr_copy(&addr, &eth_hdr->s_addr);
+
+ mbuf_field_set(mb, ol_flags);
+ }
+}
+
+#endif /* _MACSWAP_H_ */