diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /src/spdk/dpdk/app/test-pmd/macswap_common.h | |
parent | Initial commit. (diff) | |
download | ceph-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_common.h')
-rw-r--r-- | src/spdk/dpdk/app/test-pmd/macswap_common.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/spdk/dpdk/app/test-pmd/macswap_common.h b/src/spdk/dpdk/app/test-pmd/macswap_common.h new file mode 100644 index 000000000..7e9a3590a --- /dev/null +++ b/src/spdk/dpdk/app/test-pmd/macswap_common.h @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 Intel Corporation + */ + +#ifndef _MACSWAP_COMMON_H_ +#define _MACSWAP_COMMON_H_ + +static inline uint64_t +ol_flags_init(uint64_t tx_offload) +{ + uint64_t ol_flags = 0; + + ol_flags |= (tx_offload & DEV_TX_OFFLOAD_VLAN_INSERT) ? + PKT_TX_VLAN : 0; + ol_flags |= (tx_offload & DEV_TX_OFFLOAD_QINQ_INSERT) ? + PKT_TX_QINQ : 0; + ol_flags |= (tx_offload & DEV_TX_OFFLOAD_MACSEC_INSERT) ? + PKT_TX_MACSEC : 0; + + return ol_flags; +} + +static inline void +vlan_qinq_set(struct rte_mbuf *pkts[], uint16_t nb, + uint64_t ol_flags, uint16_t vlan, uint16_t outer_vlan) +{ + int i; + + if (ol_flags & PKT_TX_VLAN) + for (i = 0; i < nb; i++) + pkts[i]->vlan_tci = vlan; + if (ol_flags & PKT_TX_QINQ) + for (i = 0; i < nb; i++) + pkts[i]->vlan_tci_outer = outer_vlan; +} + +static inline void +mbuf_field_set(struct rte_mbuf *mb, uint64_t ol_flags) +{ + mb->ol_flags &= IND_ATTACHED_MBUF | EXT_ATTACHED_MBUF; + mb->ol_flags |= ol_flags; + mb->l2_len = sizeof(struct rte_ether_hdr); + mb->l3_len = sizeof(struct rte_ipv4_hdr); +} + +#endif /* _MACSWAP_COMMON_H_ */ |