[dpdk-dev,26/39] examples/vhost: convert to new ethdev offloads API

Message ID 20171123121941.144335-17-shahafs@mellanox.com
State Superseded, archived
Headers show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Shahaf Shuler Nov. 23, 2017, 12:19 p.m.
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@mellanox.com>
---
 examples/vhost/main.c | 42 +++++++++++++++++++++++++++++++-----------
 1 file changed, 31 insertions(+), 11 deletions(-)

Patch

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 89a61f0e5..aeb6f5e5d 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -145,21 +145,23 @@  static struct rte_eth_conf vmdq_conf_default = {
 	.rxmode = {
 		.mq_mode        = ETH_MQ_RX_VMDQ_ONLY,
 		.split_hdr_size = 0,
-		.header_split   = 0, /**< Header Split disabled */
-		.hw_ip_checksum = 0, /**< IP checksum offload disabled */
-		.hw_vlan_filter = 0, /**< VLAN filtering disabled */
+		.ignore_offload_bitfield = 1,
 		/*
-		 * It is necessary for 1G NIC such as I350,
+		 * VLAN strip is necessary for 1G NIC such as I350,
 		 * this fixes bug of ipv4 forwarding in guest can't
 		 * forward pakets from one virtio dev to another virtio dev.
 		 */
-		.hw_vlan_strip  = 1, /**< VLAN strip enabled. */
-		.jumbo_frame    = 0, /**< Jumbo Frame Support disabled */
-		.hw_strip_crc   = 1, /**< CRC stripped by hardware */
+		.offloads = (DEV_RX_OFFLOAD_CRC_STRIP |
+			     DEV_RX_OFFLOAD_VLAN_STRIP),
 	},
 
 	.txmode = {
 		.mq_mode = ETH_MQ_TX_NONE,
+		.offloads = (DEV_TX_OFFLOAD_IPV4_CKSUM |
+			     DEV_TX_OFFLOAD_TCP_CKSUM |
+			     DEV_TX_OFFLOAD_VLAN_INSERT |
+			     DEV_TX_OFFLOAD_MULTI_SEGS |
+			     DEV_TX_OFFLOAD_TCP_TSO),
 	},
 	.rx_adv_conf = {
 		/*
@@ -176,6 +178,7 @@  static struct rte_eth_conf vmdq_conf_default = {
 	},
 };
 
+
 static unsigned lcore_ids[RTE_MAX_LCORE];
 static uint16_t ports[RTE_MAX_ETHPORTS];
 static unsigned num_ports = 0; /**< The number of ports specified in command line */
@@ -288,9 +291,7 @@  port_init(uint16_t port)
 	rxconf = &dev_info.default_rxconf;
 	txconf = &dev_info.default_txconf;
 	rxconf->rx_drop_en = 1;
-
-	/* Enable vlan offload */
-	txconf->txq_flags &= ~ETH_TXQ_FLAGS_NOVLANOFFL;
+	txconf->txq_flags = ETH_TXQ_FLAGS_IGNORE;
 
 	/*configure the number of supported virtio devices based on VMDQ limits */
 	num_devices = dev_info.max_vmdq_pools;
@@ -332,6 +333,22 @@  port_init(uint16_t port)
 
 	rx_rings = (uint16_t)dev_info.max_rx_queues;
 	/* Configure ethernet device. */
+	if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+	    port_conf.rxmode.offloads) {
+		printf("Some Rx offloads are not supported "
+		       "by port %d: requested 0x%lx supported 0x%lx\n",
+		       port, port_conf.rxmode.offloads,
+		       dev_info.rx_offload_capa);
+		port_conf.rxmode.offloads &= dev_info.rx_offload_capa;
+	}
+	if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+			port_conf.txmode.offloads) {
+		printf("Some Tx offloads are not supported "
+		       "by port %d: requested 0x%lx supported 0x%lx\n",
+		       port, port_conf.txmode.offloads,
+		       dev_info.tx_offload_capa);
+		port_conf.txmode.offloads &= dev_info.tx_offload_capa;
+	}
 	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
 	if (retval != 0) {
 		RTE_LOG(ERR, VHOST_PORT, "Failed to configure port %u: %s.\n",
@@ -353,6 +370,7 @@  port_init(uint16_t port)
 	}
 
 	/* Setup the queues. */
+	rxconf->offloads = port_conf.rxmode.offloads;
 	for (q = 0; q < rx_rings; q ++) {
 		retval = rte_eth_rx_queue_setup(port, q, rx_ring_size,
 						rte_eth_dev_socket_id(port),
@@ -365,6 +383,7 @@  port_init(uint16_t port)
 			return retval;
 		}
 	}
+	txconf->offloads = port_conf.txmode.offloads;
 	for (q = 0; q < tx_rings; q ++) {
 		retval = rte_eth_tx_queue_setup(port, q, tx_ring_size,
 						rte_eth_dev_socket_id(port),
@@ -624,7 +643,8 @@  us_vhost_parse_args(int argc, char **argv)
 				} else {
 					mergeable = !!ret;
 					if (ret) {
-						vmdq_conf_default.rxmode.jumbo_frame = 1;
+						vmdq_conf_default.rxmode.offloads |=
+							DEV_RX_OFFLOAD_JUMBO_FRAME;
 						vmdq_conf_default.rxmode.max_rx_pkt_len
 							= JUMBO_FRAME_MAX_SIZE;
 					}