[dpdk-dev,v3,15/39] examples/ipsec-secgw: convert to new ethdev offloads API

Message ID 0c4817f6363617a545bc7125ac8ca0a0b1fde4b5.1514280005.git.shahafs@mellanox.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

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

Commit Message

Shahaf Shuler Dec. 26, 2017, 9:23 a.m. UTC
  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/ipsec-secgw/ipsec-secgw.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)
  

Comments

Radu Nicolau Jan. 16, 2018, 11:10 a.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Shahaf Shuler
> Sent: Tuesday, December 26, 2017 9:23 AM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v3 15/39] examples/ipsec-secgw: convert to
> new ethdev offloads API
> 
> 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>
> ---
> 

Acked-by: Radu Nicolau <radu.nicolau@intel.com>
  

Patch

diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
index c98454a90..ff101e98d 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -217,6 +217,8 @@  static struct rte_eth_conf port_conf = {
 	},
 	.txmode = {
 		.mq_mode = ETH_MQ_TX_NONE,
+		.offloads = (DEV_TX_OFFLOAD_IPV4_CKSUM |
+			     DEV_TX_OFFLOAD_MULTI_SEGS),
 	},
 };
 
@@ -1358,6 +1360,7 @@  port_init(uint16_t portid)
 	int32_t ret, socket_id;
 	struct lcore_conf *qconf;
 	struct ether_addr ethaddr;
+	struct rte_eth_conf local_port_conf = port_conf;
 
 	rte_eth_dev_info_get(portid, &dev_info);
 
@@ -1385,17 +1388,19 @@  port_init(uint16_t portid)
 			nb_rx_queue, nb_tx_queue);
 
 	if (frame_size) {
-		port_conf.rxmode.max_rx_pkt_len = frame_size;
-		port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+		local_port_conf.rxmode.max_rx_pkt_len = frame_size;
+		local_port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
 	}
 
 	if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_SECURITY)
-		port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_SECURITY;
+		local_port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_SECURITY;
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SECURITY)
-		port_conf.txmode.offloads |= DEV_TX_OFFLOAD_SECURITY;
-
+		local_port_conf.txmode.offloads |= DEV_TX_OFFLOAD_SECURITY;
+	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
+		local_port_conf.txmode.offloads |=
+			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
 	ret = rte_eth_dev_configure(portid, nb_rx_queue, nb_tx_queue,
-			&port_conf);
+			&local_port_conf);
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Cannot configure device: "
 				"err=%d, port=%d\n", ret, portid);
@@ -1420,7 +1425,8 @@  port_init(uint16_t portid)
 		printf("Setup txq=%u,%d,%d\n", lcore_id, tx_queueid, socket_id);
 
 		txconf = &dev_info.default_txconf;
-		txconf->txq_flags = 0;
+		txconf->txq_flags = ETH_TXQ_FLAGS_IGNORE;
+		txconf->offloads = local_port_conf.txmode.offloads;
 
 		ret = rte_eth_tx_queue_setup(portid, tx_queueid, nb_txd,
 				socket_id, txconf);
@@ -1434,6 +1440,8 @@  port_init(uint16_t portid)
 
 		/* init RX queues */
 		for (queue = 0; queue < qconf->nb_rx_queue; ++queue) {
+			struct rte_eth_rxconf rxq_conf;
+
 			if (portid != qconf->rx_queue_list[queue].port_id)
 				continue;
 
@@ -1442,8 +1450,10 @@  port_init(uint16_t portid)
 			printf("Setup rxq=%d,%d,%d\n", portid, rx_queueid,
 					socket_id);
 
+			rxq_conf = dev_info.default_rxconf;
+			rxq_conf.offloads = local_port_conf.rxmode.offloads;
 			ret = rte_eth_rx_queue_setup(portid, rx_queueid,
-					nb_rxd,	socket_id, NULL,
+					nb_rxd,	socket_id, &rxq_conf,
 					socket_ctx[socket_id].mbuf_pool);
 			if (ret < 0)
 				rte_exit(EXIT_FAILURE,