From 1e6d12a09fc093ce4caa0cde01a8384ebde5009e Mon Sep 17 00:00:00 2001 From: "M. Asim Jamshed" Date: Tue, 15 Jan 2019 18:39:30 -0800 Subject: [PATCH] - Upgraded support of mTCP-DPDK to dpdk-18.11 --- .gitmodules | 3 ++- mtcp/src/dpdk_module.c | 23 +++++++++++++++++++---- mtcp/src/io_module.c | 13 ++++++++++++- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/.gitmodules b/.gitmodules index a5a2d96..85f3bc5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,5 +2,6 @@ path = dpdk url = https://dpdk.org/git/dpdk branch = devel - commit = 92924b207b124c156f7b6dff75110d6af83d971f + commit = ac5a5eac11e4008f48f992ea2d6fafc0b9b74f34 +# commit = 92924b207b124c156f7b6dff75110d6af83d971f \ No newline at end of file diff --git a/mtcp/src/dpdk_module.c b/mtcp/src/dpdk_module.c index 90b577c..7a31d76 100644 --- a/mtcp/src/dpdk_module.c +++ b/mtcp/src/dpdk_module.c @@ -34,6 +34,8 @@ #endif /* for ioctl funcs */ #include +/* for retrieving rte version(s) */ +#include /*----------------------------------------------------------------------------*/ /* Essential macros */ #define MAX_RX_QUEUE_PER_LCORE MAX_CPUS @@ -112,11 +114,13 @@ static struct rte_eth_conf port_conf = { #endif ), .split_hdr_size = 0, +#if (RTE_VER_YEAR <= 18) && (RTE_VER_MONTH <= 02) .header_split = 0, /**< Header Split disabled */ .hw_ip_checksum = 1, /**< IP checksum offload enabled */ .hw_vlan_filter = 0, /**< VLAN filtering disabled */ .jumbo_frame = 0, /**< Jumbo Frame Support disabled */ .hw_strip_crc = 1, /**< CRC stripped by hardware */ +#endif #ifdef ENABLELRO .enable_lro = 1, /**< Enable LRO */ #endif @@ -130,6 +134,11 @@ static struct rte_eth_conf port_conf = { }, .txmode = { .mq_mode = ETH_MQ_TX_NONE, +#if (RTE_VER_YEAR >= 18) && (RTE_VER_MONTH > 02) + .offloads = (DEV_TX_OFFLOAD_IPV4_CKSUM | + DEV_TX_OFFLOAD_UDP_CKSUM | + DEV_TX_OFFLOAD_TCP_CKSUM) +#endif }, }; @@ -150,11 +159,13 @@ static const struct rte_eth_txconf tx_conf = { }, .tx_free_thresh = 0, /* Use PMD default values */ .tx_rs_thresh = 0, /* Use PMD default values */ +#if (RTE_VER_YEAR <= 18) && (RTE_VER_MONTH <= 02) /* * As the example won't handle mult-segments and offload cases, * set the flag by default. */ .txq_flags = 0x0, +#endif }; struct mbuf_table { @@ -677,21 +688,25 @@ dpdk_load_module(void) /* get portid form the index of attached devices */ portid = devices_attached[i]; + /* check port capabilities */ + rte_eth_dev_info_get(portid, &dev_info[portid]); +#if (RTE_VER_YEAR >= 18) && (RTE_VER_MONTH > 02) + /* re-adjust rss_hf */ + port_conf.rx_adv_conf.rss_conf.rss_hf &= dev_info[portid].flow_type_rss_offloads; +#endif /* init port */ printf("Initializing port %u... ", (unsigned) portid); fflush(stdout); ret = rte_eth_dev_configure(portid, CONFIG.num_cores, CONFIG.num_cores, &port_conf); if (ret < 0) - rte_exit(EXIT_FAILURE, "Cannot configure device: err=%d, port=%u\n", - ret, (unsigned) portid); + rte_exit(EXIT_FAILURE, "Cannot configure device: err=%d, port=%u, cores: %d\n", + ret, (unsigned) portid, CONFIG.num_cores); /* init one RX queue per CPU */ fflush(stdout); #ifdef DEBUG rte_eth_macaddr_get(portid, &ports_eth_addr[portid]); #endif - /* check port capabilities */ - rte_eth_dev_info_get(portid, &dev_info[portid]); for (rxlcore_id = 0; rxlcore_id < CONFIG.num_cores; rxlcore_id++) { ret = rte_eth_rx_queue_setup(portid, rxlcore_id, nb_rxd, diff --git a/mtcp/src/io_module.c b/mtcp/src/io_module.c index 4df4bbe..9ae2949 100644 --- a/mtcp/src/io_module.c +++ b/mtcp/src/io_module.c @@ -19,7 +19,9 @@ #include /* for ceil func */ #include -#endif +/* for retrieving rte version(s) */ +#include +#endif /* DISABLE_DPDK */ /* for TRACE_* */ #include "debug.h" /* for inet_* */ @@ -333,6 +335,11 @@ SetNetEnv(char *dev_name_list, char *port_stat_list) */ optind = 0; +#ifdef DEBUG + /* print argv's */ + for (i = 0; i < argc; i++) + TRACE_INFO("argv[%d]: %s\n", i, argv[i]); +#endif /* initialize the dpdk eal env */ ret = rte_eal_init(argc, argv); if (ret < 0) { @@ -340,7 +347,11 @@ SetNetEnv(char *dev_name_list, char *port_stat_list) exit(EXIT_FAILURE); } /* give me the count of 'detected' ethernet ports */ +#if (RTE_VER_YEAR <= 18) && (RTE_VER_MONTH <= 02) num_devices = rte_eth_dev_count(); +#else + num_devices = rte_eth_dev_count_avail(); +#endif if (num_devices == 0) { TRACE_ERROR("No Ethernet port!\n"); exit(EXIT_FAILURE);