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

Message ID 20171123121941.144335-16-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/tep_termination/vxlan_setup.c | 37 +++++++++++++++++++++++------
 1 file changed, 30 insertions(+), 7 deletions(-)

Patch

diff --git a/examples/tep_termination/vxlan_setup.c b/examples/tep_termination/vxlan_setup.c
index 1ad4ca3cd..0a955dc06 100644
--- a/examples/tep_termination/vxlan_setup.c
+++ b/examples/tep_termination/vxlan_setup.c
@@ -95,17 +95,22 @@  uint8_t tep_filter_type[] = {RTE_TUNNEL_FILTER_IMAC_TENID,
 			RTE_TUNNEL_FILTER_OMAC_TENID_IMAC,};
 
 /* Options for configuring ethernet port */
-static const struct rte_eth_conf port_conf = {
+static struct rte_eth_conf port_conf = {
 	.rxmode = {
 		.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 */
-		.jumbo_frame    = 0, /**< Jumbo Frame Support disabled */
-		.hw_strip_crc   = 1, /**< CRC stripped by hardware */
+		.ignore_offload_bitfield = 1,
+		.offloads = DEV_RX_OFFLOAD_CRC_STRIP,
 	},
 	.txmode = {
 		.mq_mode = ETH_MQ_TX_NONE,
+		.offloads = (DEV_TX_OFFLOAD_IPV4_CKSUM |
+			     DEV_TX_OFFLOAD_UDP_CKSUM |
+			     DEV_TX_OFFLOAD_TCP_CKSUM |
+			     DEV_TX_OFFLOAD_SCTP_CKSUM |
+			     DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM |
+			     DEV_TX_OFFLOAD_TCP_TSO |
+			     DEV_TX_OFFLOAD_MULTI_SEGS |
+			     DEV_TX_OFFLOAD_VXLAN_TNL_TSO),
 	},
 };
 
@@ -154,7 +159,7 @@  vxlan_port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 
 	rxconf = &dev_info.default_rxconf;
 	txconf = &dev_info.default_txconf;
-	txconf->txq_flags = 0;
+	txconf->txq_flags = ETH_TXQ_FLAGS_IGNORE;
 
 	if (port >= rte_eth_dev_count())
 		return -1;
@@ -162,6 +167,22 @@  vxlan_port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 	rx_rings = nb_devices;
 
 	/* 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)
 		return retval;
@@ -172,6 +193,7 @@  vxlan_port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 		return retval;
 
 	/* 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),
@@ -180,6 +202,7 @@  vxlan_port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 		if (retval < 0)
 			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),