From f5eadcfb782bf40f19aea42bc6712a2c33c4a3a1 Mon Sep 17 00:00:00 2001 From: Robert Jeutter Date: Sun, 24 Oct 2021 12:52:34 +0200 Subject: [PATCH] add dpdk dummy --- test/dpdk_dummy/rte_branch_prediction.h | 32 +++++ test/dpdk_dummy/rte_byteorder.h | 62 ++++++++ test/dpdk_dummy/rte_common.h | 14 ++ test/dpdk_dummy/rte_config.h | 3 + test/dpdk_dummy/rte_cycles.h | 14 ++ test/dpdk_dummy/rte_eal.h | 1 + test/dpdk_dummy/rte_ethdev.h | 44 ++++++ test/dpdk_dummy/rte_ether.h | 22 +++ test/dpdk_dummy/rte_icmp.h | 12 ++ test/dpdk_dummy/rte_ip.h | 139 ++++++++++++++++++ test/dpdk_dummy/rte_lcore.h | 3 + test/dpdk_dummy/rte_mbuf.h | 119 +++++++++++++++ test/dpdk_dummy/rte_mbuf_core.h | 183 ++++++++++++++++++++++++ test/dpdk_dummy/rte_mempool.h | 3 + test/dpdk_dummy/rte_ring_core.h | 3 + test/dpdk_dummy/rte_ring_elem.h | 0 test/dpdk_dummy/rte_tcp.h | 16 +++ test/dpdk_dummy/rte_udp.h | 10 ++ 18 files changed, 680 insertions(+) create mode 100644 test/dpdk_dummy/rte_branch_prediction.h create mode 100644 test/dpdk_dummy/rte_byteorder.h create mode 100644 test/dpdk_dummy/rte_common.h create mode 100644 test/dpdk_dummy/rte_config.h create mode 100644 test/dpdk_dummy/rte_cycles.h create mode 100644 test/dpdk_dummy/rte_eal.h create mode 100644 test/dpdk_dummy/rte_ethdev.h create mode 100644 test/dpdk_dummy/rte_ether.h create mode 100644 test/dpdk_dummy/rte_icmp.h create mode 100644 test/dpdk_dummy/rte_ip.h create mode 100644 test/dpdk_dummy/rte_lcore.h create mode 100644 test/dpdk_dummy/rte_mbuf.h create mode 100644 test/dpdk_dummy/rte_mbuf_core.h create mode 100644 test/dpdk_dummy/rte_mempool.h create mode 100644 test/dpdk_dummy/rte_ring_core.h create mode 100644 test/dpdk_dummy/rte_ring_elem.h create mode 100644 test/dpdk_dummy/rte_tcp.h create mode 100644 test/dpdk_dummy/rte_udp.h diff --git a/test/dpdk_dummy/rte_branch_prediction.h b/test/dpdk_dummy/rte_branch_prediction.h new file mode 100644 index 0000000..2a4f94b --- /dev/null +++ b/test/dpdk_dummy/rte_branch_prediction.h @@ -0,0 +1,32 @@ +#ifndef _RTE_BRANCH_PREDICTION_H_ +#define _RTE_BRANCH_PREDICTION_H_ + +/** + * Check if a branch is likely to be taken. + * + * This compiler builtin allows the developer to indicate if a branch is + * likely to be taken. Example: + * + * if (likely(x > 1)) + * do_stuff(); + * + */ +#ifndef likely +#define likely(x) __builtin_expect(!!(x), 1) +#endif /* likely */ + +/** + * Check if a branch is unlikely to be taken. + * + * This compiler builtin allows the developer to indicate if a branch is + * unlikely to be taken. Example: + * + * if (unlikely(x < 1)) + * do_stuff(); + * + */ +#ifndef unlikely +#define unlikely(x) __builtin_expect(!!(x), 0) +#endif /* unlikely */ + +#endif /* _RTE_BRANCH_PREDICTION_H_ */ diff --git a/test/dpdk_dummy/rte_byteorder.h b/test/dpdk_dummy/rte_byteorder.h new file mode 100644 index 0000000..d0b3673 --- /dev/null +++ b/test/dpdk_dummy/rte_byteorder.h @@ -0,0 +1,62 @@ +#pragma once + +#include + +#define rte_cpu_to_be_16(x) rte_bswap16(x) +#define rte_be_to_cpu_16(x) rte_bswap16(x) + +#define rte_cpu_to_be_32(x) rte_bswap32(x) +#define rte_be_to_cpu_32(x) rte_bswap32(x) + +#define rte_bswap16(x) \ + ((uint16_t)(__builtin_constant_p(x) ? rte_constant_bswap16(x) \ + : rte_arch_bswap16(x))) + +#define rte_bswap32(x) \ + ((uint32_t)(__builtin_constant_p(x) ? rte_constant_bswap32(x) \ + : rte_arch_bswap32(x))) + +typedef uint16_t rte_be16_t; + +typedef uint32_t rte_be32_t; + +/** + * An internal function to swap bytes in a + * 16-bit value. + * + * It is used by rte_bswap16() when the + * value is constant. Do not use this + * function directly; rte_bswap16() is + * preferred. + */ +static inline uint16_t rte_constant_bswap16(uint16_t x) { + return (uint16_t)(((x & 0x00ffU) << 8) | ((x & 0xff00U) >> 8)); +} + +/** + * An internal function to swap bytes in a 32-bit value. + * + * It is used by rte_bswap32() when the value is constant. Do not use + * this function directly; rte_bswap32() is preferred. + */ +static inline uint32_t rte_constant_bswap32(uint32_t x) { + return ((x & 0x000000ffUL) << 24) | ((x & 0x0000ff00UL) << 8) | + ((x & 0x00ff0000UL) >> 8) | ((x & 0xff000000UL) >> 24); +} + +static inline uint16_t rte_arch_bswap16(uint16_t _x) { + uint16_t x = _x; + asm volatile("xchgb %b[x1],%h[x2]" : [ x1 ] "=Q"(x) : [ x2 ] "0"(x)); + return x; +} + +/* + * An architecture-optimized byte swap for a 32-bit value. + * + * Do not use this function directly. The preferred function is rte_bswap32(). + */ +static inline uint32_t rte_arch_bswap32(uint32_t _x) { + uint32_t x = _x; + asm volatile("bswap %[x]" : [ x ] "+r"(x)); + return x; +} \ No newline at end of file diff --git a/test/dpdk_dummy/rte_common.h b/test/dpdk_dummy/rte_common.h new file mode 100644 index 0000000..5d14482 --- /dev/null +++ b/test/dpdk_dummy/rte_common.h @@ -0,0 +1,14 @@ +#pragma once + +#define RTE_MIN(a, b) \ + __extension__({ \ + typeof(a) _a = (a); \ + typeof(b) _b = (b); \ + _a < _b ? _a : _b; \ + }) + +#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L +#define RTE_STD_C11 __extension__ +#else +#define RTE_STD_C11 +#endif \ No newline at end of file diff --git a/test/dpdk_dummy/rte_config.h b/test/dpdk_dummy/rte_config.h new file mode 100644 index 0000000..50a447d --- /dev/null +++ b/test/dpdk_dummy/rte_config.h @@ -0,0 +1,3 @@ +#pragma once + +#define RTE_PKTMBUF_HEADROOM 128 \ No newline at end of file diff --git a/test/dpdk_dummy/rte_cycles.h b/test/dpdk_dummy/rte_cycles.h new file mode 100644 index 0000000..f9457af --- /dev/null +++ b/test/dpdk_dummy/rte_cycles.h @@ -0,0 +1,14 @@ +#pragma once + +#include + +uint64_t rte_get_tsc_cycles() { + unsigned int lo, hi; + __asm__ __volatile__("rdtsc" : "=a"(lo), "=d"(hi)); + return ((uint64_t)hi << 32) | lo; +} + +uint64_t rte_get_tsc_hz() { + // 1.8 GHz + return 1800000000; +} diff --git a/test/dpdk_dummy/rte_eal.h b/test/dpdk_dummy/rte_eal.h new file mode 100644 index 0000000..7b9637e --- /dev/null +++ b/test/dpdk_dummy/rte_eal.h @@ -0,0 +1 @@ +#pragma once \ No newline at end of file diff --git a/test/dpdk_dummy/rte_ethdev.h b/test/dpdk_dummy/rte_ethdev.h new file mode 100644 index 0000000..9d92bf4 --- /dev/null +++ b/test/dpdk_dummy/rte_ethdev.h @@ -0,0 +1,44 @@ +#pragma once + +#include +#include + +struct rte_eth_conf { + /* + uint32_t link_speeds; + struct rte_eth_rxmode rxmode; + struct rte_eth_txmode txmode; + uint32_t lpbk_mode; + struct { + struct rte_eth_rss_conf rss_conf; + struct rte_eth_vmdq_dcb_conf vmdq_dcb_conf; + struct rte_eth_dcb_rx_conf dcb_rx_conf; + struct rte_eth_vmdq_rx_conf vmdq_rx_conf; + } rx_adv_conf; + union { + struct rte_eth_vmdq_dcb_tx_conf vmdq_dcb_tx_conf; + struct rte_eth_dcb_tx_conf dcb_tx_conf; + struct rte_eth_vmdq_tx_conf vmdq_tx_conf; + } tx_adv_conf; + uint32_t dcb_capability_en; + struct rte_fdir_conf fdir_conf; + struct rte_intr_conf intr_conf; + */ +}; + +static inline uint16_t rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id, + struct rte_mbuf** tx_pkts, + uint16_t nb_pkts) { + for (int i = 0; i < nb_pkts; ++i) { + rte_pktmbuf_free(tx_pkts[i]); + } +} + +static inline uint16_t rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id, + struct rte_mbuf** rx_pkts, + const uint16_t nb_pkts) { + rte_mempool* mp; + for (int i = 0; i < nb_pkts; ++i) { + rx_pkts[i] = rte_pktmbuf_alloc(mp); + } +} \ No newline at end of file diff --git a/test/dpdk_dummy/rte_ether.h b/test/dpdk_dummy/rte_ether.h new file mode 100644 index 0000000..cb04a87 --- /dev/null +++ b/test/dpdk_dummy/rte_ether.h @@ -0,0 +1,22 @@ +#pragma once + +#include +#include + +#define RTE_ETHER_ADDR_LEN 6 + +struct rte_ether_addr { + uint8_t addr_bytes[RTE_ETHER_ADDR_LEN]; +} __attribute__((__packed__)); + +struct rte_ether_hdr { + struct rte_ether_addr d_addr; + RTE_STD_C11 + union { + struct rte_ether_addr s_addr; + struct { + struct rte_ether_addr S_addr; + } S_un; + }; + rte_be16_t ether_type; +} __attribute__((__packed__)); diff --git a/test/dpdk_dummy/rte_icmp.h b/test/dpdk_dummy/rte_icmp.h new file mode 100644 index 0000000..bfaa24e --- /dev/null +++ b/test/dpdk_dummy/rte_icmp.h @@ -0,0 +1,12 @@ +#pragma once + +#include +#include + +struct rte_icmp_hdr { + uint8_t icmp_type; /* ICMP packet type. */ + uint8_t icmp_code; /* ICMP packet code. */ + rte_be16_t icmp_cksum; /* ICMP packet checksum. */ + rte_be16_t icmp_ident; /* ICMP packet identifier. */ + rte_be16_t icmp_seq_nb; /* ICMP packet sequence number. */ +} __attribute__((__packed__)); \ No newline at end of file diff --git a/test/dpdk_dummy/rte_ip.h b/test/dpdk_dummy/rte_ip.h new file mode 100644 index 0000000..386c94f --- /dev/null +++ b/test/dpdk_dummy/rte_ip.h @@ -0,0 +1,139 @@ +#pragma once + +#include +#include +#include +#include + +#define RTE_IPV4_HDR_IHL_MASK (0x0f) +#define RTE_IPV4_IHL_MULTIPLIER (4) +#define IPPROTO_UDP IPPROTO_UDP + +struct rte_ipv4_hdr { + uint8_t version_ihl; + uint8_t type_of_service; + rte_be16_t total_length; + rte_be16_t packet_id; + rte_be16_t fragment_offset; + uint8_t time_to_live; + uint8_t next_proto_id; + rte_be16_t hdr_checksum; + rte_be32_t src_addr; + rte_be32_t dst_addr; +} __attribute__((__packed__)); + +struct rte_ipv6_hdr { + rte_be32_t vtc_flow; + rte_be16_t payload_len; + uint8_t proto; + uint8_t hop_limits; + uint8_t src_addr[16]; + uint8_t dst_addr[16]; +} __attribute__((__packed__)); + +static inline uint8_t rte_ipv4_hdr_len(const struct rte_ipv4_hdr* ipv4_hdr) { + return (uint8_t)((ipv4_hdr->version_ihl & RTE_IPV4_HDR_IHL_MASK) * + RTE_IPV4_IHL_MULTIPLIER); +} + +static inline uint16_t __rte_raw_cksum_reduce(uint32_t sum) { + sum = ((sum & 0xffff0000) >> 16) + (sum & 0xffff); + sum = ((sum & 0xffff0000) >> 16) + (sum & 0xffff); + return (uint16_t)sum; +} + +static inline uint32_t __rte_raw_cksum(const void* buf, size_t len, + uint32_t sum) { + /* workaround gcc strict-aliasing warning */ + uintptr_t ptr = (uintptr_t)buf; + typedef uint16_t __attribute__((__may_alias__)) u16_p; + const u16_p* u16_buf = (const u16_p*)ptr; + + while (len >= (sizeof(*u16_buf) * 4)) { + sum += u16_buf[0]; + sum += u16_buf[1]; + sum += u16_buf[2]; + sum += u16_buf[3]; + len -= sizeof(*u16_buf) * 4; + u16_buf += 4; + } + while (len >= sizeof(*u16_buf)) { + sum += *u16_buf; + len -= sizeof(*u16_buf); + u16_buf += 1; + } + + /* if length is in odd bytes */ + if (len == 1) + sum += *((const uint8_t*)u16_buf); + + return sum; +} + +static inline uint16_t rte_raw_cksum(const void* buf, size_t len) { + uint32_t sum; + + sum = __rte_raw_cksum(buf, len, 0); + return __rte_raw_cksum_reduce(sum); +} + +static inline uint16_t rte_ipv4_cksum(const struct rte_ipv4_hdr* ipv4_hdr) { + uint16_t cksum; + cksum = rte_raw_cksum(ipv4_hdr, rte_ipv4_hdr_len(ipv4_hdr)); + return (uint16_t)~cksum; +} + +static inline uint16_t rte_ipv4_phdr_cksum(const struct rte_ipv4_hdr* ipv4_hdr, + uint64_t ol_flags) { + struct ipv4_psd_header { + uint32_t src_addr; /* IP address of source host. */ + uint32_t dst_addr; /* IP address of destination host. */ + uint8_t zero; /* zero. */ + uint8_t proto; /* L4 protocol type. */ + uint16_t len; /* L4 length. */ + } psd_hdr; + + psd_hdr.src_addr = ipv4_hdr->src_addr; + psd_hdr.dst_addr = ipv4_hdr->dst_addr; + psd_hdr.zero = 0; + psd_hdr.proto = ipv4_hdr->next_proto_id; + + if (ol_flags & PKT_TX_TCP_SEG) { + psd_hdr.len = 0; + } else { + psd_hdr.len = rte_cpu_to_be_16( + (uint16_t)(rte_be_to_cpu_16(ipv4_hdr->total_length) - + sizeof(struct rte_ipv4_hdr))); + } + + return rte_raw_cksum(&psd_hdr, sizeof(psd_hdr)); +} + +static inline uint16_t +rte_ipv4_udptcp_cksum(const struct rte_ipv4_hdr* ipv4_hdr, const void* l4_hdr) { + uint32_t cksum; + uint32_t l3_len, l4_len; + uint8_t ip_hdr_len; + + ip_hdr_len = rte_ipv4_hdr_len(ipv4_hdr); + l3_len = rte_be_to_cpu_16(ipv4_hdr->total_length); + if (l3_len < ip_hdr_len) + return 0; + + l4_len = l3_len - ip_hdr_len; + + cksum = rte_raw_cksum(l4_hdr, l4_len); + cksum += rte_ipv4_phdr_cksum(ipv4_hdr, 0); + + cksum = ((cksum & 0xffff0000) >> 16) + (cksum & 0xffff); + cksum = (~cksum) & 0xffff; + /* + * Per RFC 768:If the computed checksum is zero for UDP, + * it is transmitted as all ones + * (the equivalent in one's complement arithmetic). + */ + if (cksum == 0 && ipv4_hdr->next_proto_id == IPPROTO_UDP) + cksum = 0xffff; + + return (uint16_t)cksum; +} \ No newline at end of file diff --git a/test/dpdk_dummy/rte_lcore.h b/test/dpdk_dummy/rte_lcore.h new file mode 100644 index 0000000..1ed53f8 --- /dev/null +++ b/test/dpdk_dummy/rte_lcore.h @@ -0,0 +1,3 @@ +#pragma once + +static unsigned int rte_lcore_id() { return 1; } \ No newline at end of file diff --git a/test/dpdk_dummy/rte_mbuf.h b/test/dpdk_dummy/rte_mbuf.h new file mode 100644 index 0000000..675776f --- /dev/null +++ b/test/dpdk_dummy/rte_mbuf.h @@ -0,0 +1,119 @@ +#pragma once + +#include + +#include +#include +#include +#include +#include +#include + +#define __rte_mbuf_sanity_check(m, is_h) \ + do { \ + } while (0) + +static inline uint16_t rte_pktmbuf_headroom(const struct rte_mbuf* m) { + __rte_mbuf_sanity_check(m, 0); + return m->data_off; +} + +static inline void rte_pktmbuf_reset_headroom(struct rte_mbuf* m) { + m->data_off = (uint16_t)RTE_PKTMBUF_HEADROOM; + //(uint16_t)RTE_MIN((uint16_t)RTE_PKTMBUF_HEADROOM, (uint16_t)m->buf_len); +} + +static inline void rte_pktmbuf_reset(struct rte_mbuf* m) { + m->next = NULL; + m->pkt_len = 0; + m->tx_offload = 0; + m->vlan_tci = 0; + m->vlan_tci_outer = 0; + m->nb_segs = 1; + m->port = UINT16_MAX; + + m->ol_flags &= (1ULL << 61); + m->packet_type = 0; + rte_pktmbuf_reset_headroom(m); + + m->data_len = 0; + __rte_mbuf_sanity_check(m, 1); +} + +static struct rte_mbuf* rte_pktmbuf_alloc(struct rte_mempool* mp) { + + struct rte_mbuf* m = NULL; + m = new struct rte_mbuf; + if (m != NULL) { + m->refcnt = 1; + m->nb_segs = 1; + m->next = NULL; + rte_pktmbuf_reset(m); + + m->buf_addr = new uint8_t[2000]; + m->buf_len = 0; + } + + return m; +} + +static inline void rte_pktmbuf_free(struct rte_mbuf* m) { + struct rte_mbuf* m_next; + + if (m != NULL) + __rte_mbuf_sanity_check(m, 1); + + delete[] m->buf_addr; + m->buf_addr = nullptr; + + while (m != NULL) { + m_next = m->next; + delete m; + m = m_next; + } +} + +static inline char* rte_pktmbuf_prepend(struct rte_mbuf* m, uint16_t len) { + __rte_mbuf_sanity_check(m, 1); + + if (unlikely(len > rte_pktmbuf_headroom(m))) { + return NULL; + } + + /* NB: elaborating the subtraction like this instead of using + * -= allows us to ensure the result type is uint16_t + * avoiding compiler warnings on gcc 8.1 at least */ + m->data_off = static_cast(m->data_off - len); + m->data_len = static_cast(m->data_len + len); + m->pkt_len = (m->pkt_len + len); + + return (char*)m->buf_addr + m->data_off; +} + +static inline uint16_t rte_pktmbuf_tailroom(const struct rte_mbuf* m) { + __rte_mbuf_sanity_check(m, 0); + return (uint16_t)(m->buf_len - rte_pktmbuf_headroom(m) - m->data_len); +} + +static inline struct rte_mbuf* rte_pktmbuf_lastseg(struct rte_mbuf* m) { + __rte_mbuf_sanity_check(m, 1); + while (m->next != NULL) + m = m->next; + return m; +} + +static inline char* rte_pktmbuf_append(struct rte_mbuf* m, uint16_t len) { + void* tail; + struct rte_mbuf* m_last; + + __rte_mbuf_sanity_check(m, 1); + + m_last = rte_pktmbuf_lastseg(m); + if (unlikely(len > rte_pktmbuf_tailroom(m_last))) + return NULL; + + tail = (char*)m_last->buf_addr + m_last->data_off + m_last->data_len; + m_last->data_len = (uint16_t)(m_last->data_len + len); + m->pkt_len = (m->pkt_len + len); + return (char*)tail; +} diff --git a/test/dpdk_dummy/rte_mbuf_core.h b/test/dpdk_dummy/rte_mbuf_core.h new file mode 100644 index 0000000..dcf93d2 --- /dev/null +++ b/test/dpdk_dummy/rte_mbuf_core.h @@ -0,0 +1,183 @@ +#pragma once + +#include +#include + +#define rte_pktmbuf_mtod_offset(m, t, o) \ + ((t)((char*)(m)->buf_addr + (m)->data_off + (o))) + +#define rte_pktmbuf_mtod(m, t) rte_pktmbuf_mtod_offset(m, t, 0) + +#define PKT_RX_VLAN (1ULL << 0) + +#define PKT_RX_RSS_HASH (1ULL << 1) + +#define PKT_RX_FDIR (1ULL << 2) + +#define PKT_RX_L4_CKSUM_BAD (1ULL << 3) + +#define PKT_RX_IP_CKSUM_BAD (1ULL << 4) + +#define PKT_RX_OUTER_IP_CKSUM_BAD (1ULL << 5) + +#define PKT_RX_EIP_CKSUM_BAD \ + RTE_DEPRECATED(PKT_RX_EIP_CKSUM_BAD) PKT_RX_OUTER_IP_CKSUM_BAD + +#define PKT_RX_VLAN_STRIPPED (1ULL << 6) + +#define PKT_RX_IP_CKSUM_MASK ((1ULL << 4) | (1ULL << 7)) + +#define PKT_RX_IP_CKSUM_UNKNOWN 0 +#define PKT_RX_IP_CKSUM_BAD (1ULL << 4) +#define PKT_RX_IP_CKSUM_GOOD (1ULL << 7) +#define PKT_RX_IP_CKSUM_NONE ((1ULL << 4) | (1ULL << 7)) + +#define PKT_RX_L4_CKSUM_MASK ((1ULL << 3) | (1ULL << 8)) + +#define PKT_RX_L4_CKSUM_UNKNOWN 0 +#define PKT_RX_L4_CKSUM_BAD (1ULL << 3) +#define PKT_RX_L4_CKSUM_GOOD (1ULL << 8) +#define PKT_RX_L4_CKSUM_NONE ((1ULL << 3) | (1ULL << 8)) + +#define PKT_RX_IEEE1588_PTP (1ULL << 9) + +#define PKT_RX_IEEE1588_TMST (1ULL << 10) + +#define PKT_RX_FDIR_ID (1ULL << 13) + +#define PKT_RX_FDIR_FLX (1ULL << 14) + +#define PKT_RX_QINQ_STRIPPED (1ULL << 15) + +#define PKT_RX_LRO (1ULL << 16) + +/* There is no flag defined at offset 17. It is free for any future use. */ + +#define PKT_RX_SEC_OFFLOAD (1ULL << 18) + +#define PKT_RX_SEC_OFFLOAD_FAILED (1ULL << 19) + +#define PKT_RX_QINQ (1ULL << 20) + +#define PKT_RX_OUTER_L4_CKSUM_MASK ((1ULL << 21) | (1ULL << 22)) + +#define PKT_RX_OUTER_L4_CKSUM_UNKNOWN 0 +#define PKT_RX_OUTER_L4_CKSUM_BAD (1ULL << 21) +#define PKT_RX_OUTER_L4_CKSUM_GOOD (1ULL << 22) +#define PKT_RX_OUTER_L4_CKSUM_INVALID ((1ULL << 21) | (1ULL << 22)) + +/* add new RX flags here, don't forget to update PKT_FIRST_FREE */ + +#define PKT_FIRST_FREE (1ULL << 23) +#define PKT_LAST_FREE (1ULL << 40) + +/* add new TX flags here, don't forget to update PKT_LAST_FREE */ + +#define PKT_TX_OUTER_UDP_CKSUM (1ULL << 41) + +#define PKT_TX_UDP_SEG (1ULL << 42) + +#define PKT_TX_SEC_OFFLOAD (1ULL << 43) + +#define PKT_TX_MACSEC (1ULL << 44) + +#define PKT_TX_TUNNEL_VXLAN (0x1ULL << 45) +#define PKT_TX_TUNNEL_GRE (0x2ULL << 45) +#define PKT_TX_TUNNEL_IPIP (0x3ULL << 45) +#define PKT_TX_TUNNEL_GENEVE (0x4ULL << 45) + +#define PKT_TX_TUNNEL_MPLSINUDP (0x5ULL << 45) +#define PKT_TX_TUNNEL_VXLAN_GPE (0x6ULL << 45) +#define PKT_TX_TUNNEL_GTP (0x7ULL << 45) + +#define PKT_TX_TUNNEL_IP (0xDULL << 45) + +#define PKT_TX_TUNNEL_UDP (0xEULL << 45) +/* add new TX TUNNEL type here */ +#define PKT_TX_TUNNEL_MASK (0xFULL << 45) + +#define PKT_TX_QINQ (1ULL << 49) + +#define PKT_TX_QINQ_PKT PKT_TX_QINQ + +#define PKT_TX_TCP_SEG (1ULL << 50) + +#define PKT_TX_IEEE1588_TMST (1ULL << 51) + +#define PKT_TX_L4_NO_CKSUM (0ULL << 52) +#define PKT_TX_TCP_CKSUM (1ULL << 52) + +#define PKT_TX_SCTP_CKSUM (2ULL << 52) + +#define PKT_TX_UDP_CKSUM (3ULL << 52) + +#define PKT_TX_L4_MASK (3ULL << 52) + +#define PKT_TX_IP_CKSUM (1ULL << 54) + +#define PKT_TX_IPV4 (1ULL << 55) + +#define PKT_TX_IPV6 (1ULL << 56) + +#define PKT_TX_VLAN (1ULL << 57) +/* this old name is deprecated */ +#define PKT_TX_VLAN_PKT PKT_TX_VLAN + +#define PKT_TX_OUTER_IP_CKSUM (1ULL << 58) + +#define PKT_TX_OUTER_IPV4 (1ULL << 59) + +#define PKT_TX_OUTER_IPV6 (1ULL << 60) + +enum { + RTE_MBUF_L2_LEN_BITS = 7, + RTE_MBUF_L3_LEN_BITS = 9, + RTE_MBUF_L4_LEN_BITS = 8, + RTE_MBUF_TSO_SEGSZ_BITS = 16, + RTE_MBUF_OUTL3_LEN_BITS = 9, + RTE_MBUF_OUTL2_LEN_BITS = 7 +}; + +struct rte_mbuf { + void* buf_addr; + uint16_t buf_len; + + struct rte_mbuf* next; + uint32_t pkt_len; + uint16_t vlan_tci; + uint16_t vlan_tci_outer; + uint16_t nb_segs; + uint16_t port; + uint64_t ol_flags; + uint32_t packet_type; + uint16_t data_len; + uint16_t data_off; + uint16_t refcnt; + + /* fields to support TX offloads */ + RTE_STD_C11 + union { + uint64_t tx_offload; + __extension__ struct { + uint64_t l2_len : RTE_MBUF_L2_LEN_BITS; + uint64_t l3_len : RTE_MBUF_L3_LEN_BITS; + uint64_t l4_len : RTE_MBUF_L4_LEN_BITS; + uint64_t tso_segsz : RTE_MBUF_TSO_SEGSZ_BITS; + /* + * Fields for Tx offloading of tunnels. + * These are undefined for packets which don't request + * any tunnel offloads (outer IP or UDP checksum, + * tunnel TSO). + * + * PMDs should not use these fields unconditionally + * when calculating offsets. + * + * Applications are expected to set appropriate tunnel + * offload flags when they fill in these fields. + */ + uint64_t outer_l3_len : RTE_MBUF_OUTL3_LEN_BITS; + uint64_t outer_l2_len : RTE_MBUF_OUTL2_LEN_BITS; + /* uint64_t unused:RTE_MBUF_TXOFLD_UNUSED_BITS; */ + }; + }; +}; diff --git a/test/dpdk_dummy/rte_mempool.h b/test/dpdk_dummy/rte_mempool.h new file mode 100644 index 0000000..bd48e2a --- /dev/null +++ b/test/dpdk_dummy/rte_mempool.h @@ -0,0 +1,3 @@ +#pragma once + +struct rte_mempool {}; \ No newline at end of file diff --git a/test/dpdk_dummy/rte_ring_core.h b/test/dpdk_dummy/rte_ring_core.h new file mode 100644 index 0000000..e77c3b3 --- /dev/null +++ b/test/dpdk_dummy/rte_ring_core.h @@ -0,0 +1,3 @@ +#pragma once + +struct rte_ring {}; \ No newline at end of file diff --git a/test/dpdk_dummy/rte_ring_elem.h b/test/dpdk_dummy/rte_ring_elem.h new file mode 100644 index 0000000..e69de29 diff --git a/test/dpdk_dummy/rte_tcp.h b/test/dpdk_dummy/rte_tcp.h new file mode 100644 index 0000000..f65cf86 --- /dev/null +++ b/test/dpdk_dummy/rte_tcp.h @@ -0,0 +1,16 @@ +#pragma once + +#include +#include + +struct rte_tcp_hdr { + rte_be16_t src_port; + rte_be16_t dst_port; + rte_be32_t sent_seq; + rte_be32_t recv_ack; + uint8_t data_off; + uint8_t tcp_flags; + rte_be16_t rx_win; + rte_be16_t cksum; + rte_be16_t tcp_urp; +} __attribute__((__packed__)); \ No newline at end of file diff --git a/test/dpdk_dummy/rte_udp.h b/test/dpdk_dummy/rte_udp.h new file mode 100644 index 0000000..4a6b4f7 --- /dev/null +++ b/test/dpdk_dummy/rte_udp.h @@ -0,0 +1,10 @@ +#pragma once + +#include + +struct rte_udp_hdr { + rte_be16_t src_port; + rte_be16_t dst_port; + rte_be16_t dgram_len; + rte_be16_t dgram_cksum; +} __attribute__((__packed__)); \ No newline at end of file