Skip to content

Commit 1dd9131

Browse files
qingmin-liuQingmin Liu
authored andcommitted
mtcp: add dpdk 19.11 support.
- dpdk 19.11 added rte_ to some variables and struct. - change it to support this.
1 parent 0feda65 commit 1dd9131

File tree

5 files changed

+43
-15
lines changed

5 files changed

+43
-15
lines changed

dpdk-iface-kmod/dpdk_iface_main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
typedef struct {
2323
PciDevice pd;
2424
struct rte_eth_dev_info dev_details;
25+
#if RTE_VERSION < RTE_VERSION_NUM(19, 8, 0, 0)
2526
struct ether_addr ports_eth_addr;
27+
#else
28+
struct rte_ether_addr ports_eth_addr;
29+
#endif
2630
} DevInfo;
2731

2832
static DevInfo di[RTE_MAX_ETHPORTS];

mtcp/src/dpdk_module.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787

8888
#define ETHER_IFG 12
8989
#define ETHER_PREAMBLE 8
90-
#define ETHER_OVR (ETHER_CRC_LEN + ETHER_PREAMBLE + ETHER_IFG)
90+
#define ETHER_OVR (MTCP_ETHER_CRC_LEN + ETHER_PREAMBLE + ETHER_IFG)
9191

9292
static const uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT;
9393
static const uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT;
@@ -98,15 +98,15 @@ static struct rte_mempool *pktmbuf_pool[MAX_CPUS] = {NULL};
9898
//#define DEBUG 1
9999
#ifdef DEBUG
100100
/* ethernet addresses of ports */
101-
static struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];
101+
static MTCP_ETHER_ADDR ports_eth_addr[RTE_MAX_ETHPORTS];
102102
#endif
103103

104104
static struct rte_eth_dev_info dev_info[RTE_MAX_ETHPORTS];
105105

106106
static struct rte_eth_conf port_conf = {
107107
.rxmode = {
108108
.mq_mode = ETH_MQ_RX_RSS,
109-
.max_rx_pkt_len = ETHER_MAX_LEN,
109+
.max_rx_pkt_len = MTCP_ETHER_MAX_LEN,
110110
#if RTE_VERSION > RTE_VERSION_NUM(17, 8, 0, 0)
111111
.offloads = (
112112
#if RTE_VERSION < RTE_VERSION_NUM(18, 5, 0, 0)
@@ -412,7 +412,7 @@ dpdk_get_wptr(struct mtcp_thread_context *ctxt, int ifidx, uint16_t pktsize)
412412
m = dpc->wmbufs[ifidx].m_table[len_of_mbuf];
413413

414414
/* retrieve the right write offset */
415-
ptr = (void *)rte_pktmbuf_mtod(m, struct ether_hdr *);
415+
ptr = (void *)rte_pktmbuf_mtod(m, MTCP_ETHER_HDR *);
416416
m->pkt_len = m->data_len = pktsize;
417417
m->nb_segs = 1;
418418
m->next = NULL;
@@ -467,16 +467,16 @@ dpdk_recv_pkts(struct mtcp_thread_context *ctxt, int ifidx)
467467
struct rte_mbuf *
468468
ip_reassemble(struct dpdk_private_context *dpc, struct rte_mbuf *m)
469469
{
470-
struct ether_hdr *eth_hdr;
470+
MTCP_ETHER_HDR *eth_hdr;
471471
struct rte_ip_frag_tbl *tbl;
472472
struct rte_ip_frag_death_row *dr;
473473

474474
/* if packet is IPv4 */
475475
if (RTE_ETH_IS_IPV4_HDR(m->packet_type)) {
476-
struct ipv4_hdr *ip_hdr;
476+
MTCP_IPV4_HDR *ip_hdr;
477477

478-
eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);
479-
ip_hdr = (struct ipv4_hdr *)(eth_hdr + 1);
478+
eth_hdr = rte_pktmbuf_mtod(m, MTCP_ETHER_HDR *);
479+
ip_hdr = (MTCP_IPV4_HDR *)(eth_hdr + 1);
480480

481481
/* if it is a fragmented packet, then try to reassemble. */
482482
if (rte_ipv4_frag_pkt_is_fragmented(ip_hdr)) {
@@ -826,7 +826,7 @@ dpdk_dev_ioctl(struct mtcp_thread_context *ctx, int nif, int cmd, void *argp)
826826
goto dev_ioctl_err;
827827
m = dpc->wmbufs[eidx].m_table[len_of_mbuf - 1];
828828
m->ol_flags = PKT_TX_IP_CKSUM | PKT_TX_IPV4;
829-
m->l2_len = sizeof(struct ether_hdr);
829+
m->l2_len = sizeof(MTCP_ETHER_HDR);
830830
m->l3_len = (iph->ihl<<2);
831831
break;
832832
case PKT_TX_TCP_CSUM:
@@ -835,19 +835,19 @@ dpdk_dev_ioctl(struct mtcp_thread_context *ctx, int nif, int cmd, void *argp)
835835
m = dpc->wmbufs[eidx].m_table[len_of_mbuf - 1];
836836
tcph = (struct tcphdr *)((unsigned char *)iph + (iph->ihl<<2));
837837
m->ol_flags |= PKT_TX_TCP_CKSUM;
838-
tcph->check = rte_ipv4_phdr_cksum((struct ipv4_hdr *)iph, m->ol_flags);
838+
tcph->check = rte_ipv4_phdr_cksum((MTCP_IPV4_HDR *)iph, m->ol_flags);
839839
break;
840840
#ifdef ENABLELRO
841841
case PKT_RX_TCP_LROSEG:
842842
m = dpc->cur_rx_m;
843843
//if (m->next != NULL)
844844
// rte_prefetch0(rte_pktmbuf_mtod(m->next, void *));
845-
iph = rte_pktmbuf_mtod_offset(m, struct iphdr *, sizeof(struct ether_hdr));
845+
iph = rte_pktmbuf_mtod_offset(m, struct iphdr *, sizeof(MTCP_ETHER_HDR));
846846
tcph = (struct tcphdr *)((u_char *)iph + (iph->ihl << 2));
847847
payload = (uint8_t *)tcph + (tcph->doff << 2);
848848

849849
seg_off = m->data_len -
850-
sizeof(struct ether_hdr) - (iph->ihl << 2) -
850+
sizeof(MTCP_ETHER_HDR) - (iph->ihl << 2) -
851851
(tcph->doff << 2);
852852

853853
to = (uint8_t *) argp;
@@ -870,13 +870,13 @@ dpdk_dev_ioctl(struct mtcp_thread_context *ctx, int nif, int cmd, void *argp)
870870
if ((dev_info[nif].tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0)
871871
goto dev_ioctl_err;
872872
m = dpc->wmbufs[eidx].m_table[len_of_mbuf - 1];
873-
iph = rte_pktmbuf_mtod_offset(m, struct iphdr *, sizeof(struct ether_hdr));
873+
iph = rte_pktmbuf_mtod_offset(m, struct iphdr *, sizeof(MTCP_ETHER_HDR));
874874
tcph = (struct tcphdr *)((uint8_t *)iph + (iph->ihl<<2));
875-
m->l2_len = sizeof(struct ether_hdr);
875+
m->l2_len = sizeof(MTCP_ETHER_HDR);
876876
m->l3_len = (iph->ihl<<2);
877877
m->l4_len = (tcph->doff<<2);
878878
m->ol_flags = PKT_TX_TCP_CKSUM | PKT_TX_IP_CKSUM | PKT_TX_IPV4;
879-
tcph->check = rte_ipv4_phdr_cksum((struct ipv4_hdr *)iph, m->ol_flags);
879+
tcph->check = rte_ipv4_phdr_cksum((MTCP_IPV4_HDR *)iph, m->ol_flags);
880880
break;
881881
case PKT_RX_IP_CSUM:
882882
if ((dev_info[nif].rx_offload_capa & DEV_RX_OFFLOAD_IPV4_CKSUM) == 0)

mtcp/src/include/mtcp.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@
3939
#define ERROR (-1)
4040
#endif
4141

42+
#if RTE_VERSION < RTE_VERSION_NUM(19, 8, 0, 0)
43+
typedef struct ether_addr MTCP_ETHER_ADDR;
44+
typedef struct ipv4_hdr MTCP_IPV4_HDR;
45+
typedef struct ether_hdr MTCP_ETHER_HDR;
46+
47+
#define MTCP_ETHER_MAX_LEN ETHER_MAX_LEN
48+
#define MTCP_ETHER_CRC_LEN ETHER_CRC_LEN
49+
#else
50+
typedef struct rte_ether_addr MTCP_ETHER_ADDR;
51+
typedef struct rte_ipv4_hdr MTCP_IPV4_HDR;
52+
typedef struct rte_ether_hdr MTCP_ETHER_HDR;
53+
54+
#define MTCP_ETHER_MAX_LEN RTE_ETHER_MAX_LEN
55+
#define MTCP_ETHER_CRC_LEN RTE_ETHER_CRC_LEN
56+
#endif
57+
4258
#define ETHERNET_HEADER_LEN 14 // sizeof(struct ethhdr)
4359
#define IP_HEADER_LEN 20 // sizeof(struct iphdr)
4460
#define TCP_HEADER_LEN 20 // sizeof(struct tcphdr)

mtcp/src/io_module.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,11 @@ SetNetEnv(char *dev_name_list, char *port_stat_list)
260260
char socket_mem_str[32] = "";
261261
// int i;
262262
int ret, socket_mem;
263+
#if RTE_VERSION < RTE_VERSION_NUM(19, 8, 0, 0)
263264
static struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];
265+
#else
266+
static struct rte_ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];
267+
#endif
264268

265269
/* STEP 1: first determine CPU mask */
266270
mpz_init(_cpumask);

mtcp/src/onvm_module.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ static struct rte_mempool *pktmbuf_pool = NULL;
6363
//#define DEBUG 1
6464
#ifdef DEBUG
6565
/* ethernet addresses of ports */
66+
#if RTE_VERSION < RTE_VERSION_NUM(19, 8, 0, 0)
6667
static struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];
68+
#else
69+
static struct rte_ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];
70+
#endif
6771
#endif
6872

6973
static struct rte_eth_dev_info dev_info[RTE_MAX_ETHPORTS];

0 commit comments

Comments
 (0)