add dpdk dummy
This commit is contained in:
parent
ed977be2fd
commit
f5eadcfb78
32
test/dpdk_dummy/rte_branch_prediction.h
Normal file
32
test/dpdk_dummy/rte_branch_prediction.h
Normal file
@ -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_ */
|
62
test/dpdk_dummy/rte_byteorder.h
Normal file
62
test/dpdk_dummy/rte_byteorder.h
Normal file
@ -0,0 +1,62 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#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;
|
||||
}
|
14
test/dpdk_dummy/rte_common.h
Normal file
14
test/dpdk_dummy/rte_common.h
Normal file
@ -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
|
3
test/dpdk_dummy/rte_config.h
Normal file
3
test/dpdk_dummy/rte_config.h
Normal file
@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define RTE_PKTMBUF_HEADROOM 128
|
14
test/dpdk_dummy/rte_cycles.h
Normal file
14
test/dpdk_dummy/rte_cycles.h
Normal file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
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;
|
||||
}
|
1
test/dpdk_dummy/rte_eal.h
Normal file
1
test/dpdk_dummy/rte_eal.h
Normal file
@ -0,0 +1 @@
|
||||
#pragma once
|
44
test/dpdk_dummy/rte_ethdev.h
Normal file
44
test/dpdk_dummy/rte_ethdev.h
Normal file
@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include <rte_mbuf.h>
|
||||
#include <stdint.h>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
22
test/dpdk_dummy/rte_ether.h
Normal file
22
test/dpdk_dummy/rte_ether.h
Normal file
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <rte_byteorder.h>
|
||||
#include <rte_common.h>
|
||||
|
||||
#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__));
|
12
test/dpdk_dummy/rte_icmp.h
Normal file
12
test/dpdk_dummy/rte_icmp.h
Normal file
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <rte_byteorder.h>
|
||||
#include <stdint.h>
|
||||
|
||||
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__));
|
139
test/dpdk_dummy/rte_ip.h
Normal file
139
test/dpdk_dummy/rte_ip.h
Normal file
@ -0,0 +1,139 @@
|
||||
#pragma once
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <rte_byteorder.h>
|
||||
#include <rte_mbuf_core.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#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;
|
||||
}
|
3
test/dpdk_dummy/rte_lcore.h
Normal file
3
test/dpdk_dummy/rte_lcore.h
Normal file
@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
static unsigned int rte_lcore_id() { return 1; }
|
119
test/dpdk_dummy/rte_mbuf.h
Normal file
119
test/dpdk_dummy/rte_mbuf.h
Normal file
@ -0,0 +1,119 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <rte_branch_prediction.h>
|
||||
#include <rte_common.h>
|
||||
#include <rte_config.h>
|
||||
#include <rte_mbuf_core.h>
|
||||
#include <rte_mempool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#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<uint16_t>(m->data_off - len);
|
||||
m->data_len = static_cast<uint16_t>(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;
|
||||
}
|
183
test/dpdk_dummy/rte_mbuf_core.h
Normal file
183
test/dpdk_dummy/rte_mbuf_core.h
Normal file
@ -0,0 +1,183 @@
|
||||
#pragma once
|
||||
|
||||
#include <rte_common.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#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; */
|
||||
};
|
||||
};
|
||||
};
|
3
test/dpdk_dummy/rte_mempool.h
Normal file
3
test/dpdk_dummy/rte_mempool.h
Normal file
@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
struct rte_mempool {};
|
3
test/dpdk_dummy/rte_ring_core.h
Normal file
3
test/dpdk_dummy/rte_ring_core.h
Normal file
@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
struct rte_ring {};
|
0
test/dpdk_dummy/rte_ring_elem.h
Normal file
0
test/dpdk_dummy/rte_ring_elem.h
Normal file
16
test/dpdk_dummy/rte_tcp.h
Normal file
16
test/dpdk_dummy/rte_tcp.h
Normal file
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <rte_byteorder.h>
|
||||
#include <stdint.h>
|
||||
|
||||
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__));
|
10
test/dpdk_dummy/rte_udp.h
Normal file
10
test/dpdk_dummy/rte_udp.h
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <rte_byteorder.h>
|
||||
|
||||
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__));
|
Loading…
Reference in New Issue
Block a user