[dpdk-dev] [PATCH v2 20/39] examples/netmap_compat: convert to new ethdev offloads API

Shahaf Shuler shahafs at mellanox.com
Tue Dec 12 13:26:37 CET 2017


Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler <shahafs at mellanox.com>
---
 examples/netmap_compat/bridge/bridge.c     |  8 +++-----
 examples/netmap_compat/lib/compat_netmap.c | 27 +++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/examples/netmap_compat/bridge/bridge.c b/examples/netmap_compat/bridge/bridge.c
index 2f2b6ba..ec969e1 100644
--- a/examples/netmap_compat/bridge/bridge.c
+++ b/examples/netmap_compat/bridge/bridge.c
@@ -55,14 +55,12 @@
 struct rte_eth_conf eth_conf = {
 	.rxmode = {
 		.split_hdr_size = 0,
-		.header_split   = 0,
-		.hw_ip_checksum = 0,
-		.hw_vlan_filter = 0,
-		.jumbo_frame    = 0,
-		.hw_strip_crc   = 1,
+		.ignore_offload_bitfield = 1,
+		.offloads = DEV_RX_OFFLOAD_CRC_STRIP,
 	},
 	.txmode = {
 		.mq_mode = ETH_MQ_TX_NONE,
+		.offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
 	},
 };
 
diff --git a/examples/netmap_compat/lib/compat_netmap.c b/examples/netmap_compat/lib/compat_netmap.c
index 12b3fcb..f145019 100644
--- a/examples/netmap_compat/lib/compat_netmap.c
+++ b/examples/netmap_compat/lib/compat_netmap.c
@@ -690,6 +690,9 @@ struct netmap_state {
 	int32_t ret;
 	uint16_t i;
 	uint16_t rx_slots, tx_slots;
+	struct rte_eth_rxconf rxq_conf;
+	struct rte_eth_txconf txq_conf;
+	struct rte_eth_dev_info dev_info;
 
 	if (conf == NULL ||
 			portid >= RTE_DIM(ports) ||
@@ -710,6 +713,21 @@ struct netmap_state {
 		return -EINVAL;
 	}
 
+	rte_eth_dev_info_get(portid, &dev_info);
+	if ((dev_info.rx_offload_capa & conf->eth_conf->rxmode.offloads) !=
+	    conf->eth_conf->rxmode.offloads) {
+		printf("Some Rx offloads are not supported "
+		       "by port %d: requested 0x%lx supported 0x%lx\n",
+		       portid, conf->eth_conf->rxmode.offloads,
+		       dev_info.rx_offload_capa);
+	}
+	if ((dev_info.tx_offload_capa & conf->eth_conf->txmode.offloads) !=
+	    conf->eth_conf->txmode.offloads) {
+		printf("Some Tx offloads are not supported "
+		       "by port %d: requested 0x%lx supported 0x%lx\n",
+		       portid, conf->eth_conf->txmode.offloads,
+		       dev_info.tx_offload_capa);
+	}
 	ret = rte_eth_dev_configure(portid, conf->nr_rx_rings,
 		conf->nr_tx_rings, conf->eth_conf);
 
@@ -727,9 +745,14 @@ struct netmap_state {
 		return ret;
 	}
 
+	rxq_conf = dev_info.default_rxconf;
+	rxq_conf.offloads = conf->eth_conf->rxmode.offloads;
+	txq_conf = dev_info.default_txconf;
+	txq_conf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
+	txq_conf.offloads = conf->eth_conf->txmode.offloads;
 	for (i = 0; i < conf->nr_tx_rings; i++) {
 		ret = rte_eth_tx_queue_setup(portid, i, tx_slots,
-			conf->socket_id, NULL);
+			conf->socket_id, &txq_conf);
 
 		if (ret < 0) {
 			RTE_LOG(ERR, USER1,
@@ -739,7 +762,7 @@ struct netmap_state {
 		}
 
 		ret = rte_eth_rx_queue_setup(portid, i, rx_slots,
-			conf->socket_id, NULL, conf->pool);
+			conf->socket_id, &rxq_conf, conf->pool);
 
 		if (ret < 0) {
 			RTE_LOG(ERR, USER1,
-- 
1.8.3.1



More information about the dev mailing list