Skip to contentSkip to conversation

examples: fix RSS hash function configuration

PATCH Superseded Ferruh Yigit 6 participants 18 messages Jun 20, 2018 – Jul 5, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 examples: fix RSS hash function configuration

ethdev layer introduced checks for application requested RSS hash functions and returns error for ones unsupported by hardware

This check breaks some sample applications which blindly configures RSS hash functions without checking underlying hardware support.

Updated examples to mask out unsupported RSS has functions during device configuration.
Prints a log if configuration values updated by this check.

Fixes aa1a6d87f15d ("ethdev: force RSS offload rules again")

---
Return error added in this release, so no need to backport the fix to previous versions.

Cc David Hunt <[email protected]>
Cc Liang Ma <[email protected]>
Cc Xueming Li <[email protected]>
---
 examples/bond/main.c                          | 12 ++++++++++
 examples/distributor/main.c                   | 11 ++++++++++
 examples/eventdev_pipeline/main.c             | 11 ++++++++++
 examples/ip_pipeline/link.c                   |  8 +++++--
 examples/ip_reassembly/main.c                 | 12 ++++++++++
 examples/ipsec-secgw/ipsec-secgw.c            | 12 ++++++++++
 examples/l3fwd-acl/main.c                     | 12 ++++++++++
 examples/l3fwd-power/main.c                   | 14 ++++++++++--
 examples/l3fwd-vf/main.c                      | 12 ++++++++++
 examples/l3fwd/main.c                         | 12 ++++++++++
 examples/load_balancer/init.c                 | 12 ++++++++++
 examples/multi_process/symmetric_mp/main.c    | 12 ++++++++++
 .../performance-thread/l3fwd-thread/main.c    | 12 ++++++++++
 examples/qos_meter/main.c                     | 22 +++++++++++++++++++
 examples/vmdq_dcb/main.c                      | 13 +++++++++++
 15 files changed, 183 insertions(+), 4 deletions(-)
examples/bond/main.c +12 -0
index 65e0edd25..7d506feb2 100644
@@ -154,6 +154,18 @@ slave_port_init(uint16_t portid, struct rte_mempool *mbuf_pool)
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		local_port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			portid,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	retval = rte_eth_dev_configure(portid, 1, 1, &local_port_conf);
 	if (retval != 0)
 		rte_exit(EXIT_FAILURE, "port %u: configuration failed (res=%d)\n",
examples/distributor/main.c +11 -0
index 2c5936489..4dd69faab 100644
@@ -124,6 +124,17 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 		port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
 
+	port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	retval = rte_eth_dev_configure(port, rxRings, txRings, &port_conf);
 	if (retval != 0)
 		return retval;
examples/eventdev_pipeline/main.c +11 -0
index b698e4ca2..2af430206 100644
@@ -293,6 +293,17 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
 		port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
 
+	port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	/* Configure the Ethernet device. */
 	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
 	if (retval != 0)
examples/ip_pipeline/link.c +6 -2
index b8a431f3e..31d8cd332 100644
@@ -161,8 +161,12 @@ link_create(const char *name, struct link_params *params)
 	memcpy(&port_conf, &port_conf_default, sizeof(port_conf));
 	if (rss) {
 		port_conf.rxmode.mq_mode = ETH_MQ_RX_RSS;
-		port_conf.rx_adv_conf.rss_conf.rss_hf =
-			ETH_RSS_IPV4 | ETH_RSS_IPV6;
+		if (port_info.flow_type_rss_offloads & ETH_RSS_IPV4)
+			port_conf.rx_adv_conf.rss_conf.rss_hf |=
+				ETH_RSS_IPV4;
+		if (port_info.flow_type_rss_offloads & ETH_RSS_IPV6)
+			port_conf.rx_adv_conf.rss_conf.rss_hf |=
+				ETH_RSS_IPV6;
 	}
 
 	cpu_id = (uint32_t) rte_eth_dev_socket_id(port_id);
examples/ip_reassembly/main.c +12 -0
index 3e8e79c21..ccef5a6af 100644
@@ -1083,6 +1083,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, 1, (uint16_t)n_tx_queue,
 					    &local_port_conf);
 		if (ret < 0) {
examples/ipsec-secgw/ipsec-secgw.c +12 -0
index a5da8b280..8bd38882e 100644
@@ -1566,6 +1566,18 @@ port_init(uint16_t portid)
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		local_port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			portid,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	ret = rte_eth_dev_configure(portid, nb_rx_queue, nb_tx_queue,
 			&local_port_conf);
 	if (ret < 0)
examples/l3fwd-acl/main.c +12 -0
index 33ad467d3..fa12bb894 100644
@@ -1926,6 +1926,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					(uint16_t)n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/l3fwd-power/main.c +12 -2
index 596d64548..e1c2e4ae0 100644
@@ -185,8 +185,6 @@ static struct rte_eth_conf port_conf = {
 		.max_rx_pkt_len = ETHER_MAX_LEN,
 		.split_hdr_size = 0,
 		.ignore_offload_bitfield = 1,
-		.offloads = (DEV_RX_OFFLOAD_CRC_STRIP |
-			     DEV_RX_OFFLOAD_CHECKSUM),
 	},
 	.rx_adv_conf = {
 		.rss_conf = {
@@ -1693,6 +1691,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					(uint16_t)n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/l3fwd-vf/main.c +12 -0
index aaafb7bc2..a01f70cb5 100644
@@ -981,6 +981,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					    n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/l3fwd/main.c +12 -0
index bf7dbd814..2ca0fcdaa 100644
@@ -861,6 +861,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					(uint16_t)n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/load_balancer/init.c +12 -0
index 8d8dbe61e..7d019da30 100644
@@ -417,6 +417,18 @@ app_init_nics(void)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				port,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(
 			port,
 			(uint8_t) n_rx_queues,
examples/multi_process/symmetric_mp/main.c +12 -0
index 16f21a187..2ea3e7a7a 100644
@@ -200,6 +200,7 @@ smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool,
 	uint16_t q;
 	uint16_t nb_rxd = RX_RING_SIZE;
 	uint16_t nb_txd = TX_RING_SIZE;
+	uint64_t rss_hf_tmp;
 
 	if (rte_eal_process_type() == RTE_PROC_SECONDARY)
 		return 0;
@@ -216,6 +217,17 @@ smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool,
 	if (info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	rss_hf_tmp = port_conf.rx_adv_conf.rss_conf.rss_hf;
+	port_conf.rx_adv_conf.rss_conf.rss_hf &= info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf != rss_hf_tmp) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			rss_hf_tmp,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
 	if (retval < 0)
 		return retval;
examples/performance-thread/l3fwd-thread/main.c +12 -0
index 40d807239..1b13d25db 100644
@@ -3551,6 +3551,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					(uint16_t)n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/qos_meter/main.c +22 -0
index 42cf4b29f..2122bd1dd 100644
@@ -333,6 +333,17 @@ main(int argc, char **argv)
 	rte_eth_dev_info_get(port_rx, &dev_info);
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	conf.rx_adv_conf.rss_conf.rss_hf &= dev_info.flow_type_rss_offloads;
+	if (conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port_rx,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	ret = rte_eth_dev_configure(port_rx, 1, 1, &conf);
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Port %d configuration error (%d)\n", port_rx, ret);
@@ -363,6 +374,17 @@ main(int argc, char **argv)
 	rte_eth_dev_info_get(port_tx, &dev_info);
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	conf.rx_adv_conf.rss_conf.rss_hf &= dev_info.flow_type_rss_offloads;
+	if (conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port_tx,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	ret = rte_eth_dev_configure(port_tx, 1, 1, &conf);
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Port %d configuration error (%d)\n", port_tx, ret);
examples/vmdq_dcb/main.c +13 -0
index 2626a2f19..49bf84001 100644
@@ -197,6 +197,7 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 	uint16_t queues_per_pool;
 	uint32_t max_nb_pools;
 	struct rte_eth_txconf txq_conf;
+	uint64_t rss_hf_tmp;
 
 	/*
 	 * The max pool number from dev_info will be used to validate the pool
@@ -257,6 +258,18 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	rss_hf_tmp = port_conf.rx_adv_conf.rss_conf.rss_hf;
+	port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf != rss_hf_tmp) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			rss_hf_tmp,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	/*
 	 * Though in this example, all queues including pf queues are setup.
 	 * This is because VMDQ queues doesn't always start from zero, and the
Signature · 1 line
2.17.1
#1 lore raw

Hi Ferruh,

Quoted 29 lines · Ferruh Yigit

ethdev layer introduced checks for application requested RSS hash functions and returns error for ones unsupported by hardware

This check breaks some sample applications which blindly configures RSS hash functions without checking underlying hardware support.

Updated examples to mask out unsupported RSS has functions during device configuration.
Prints a log if configuration values updated by this check.

Fixes aa1a6d87f15d ("ethdev: force RSS offload rules again")

---
Return error added in this release, so no need to backport the fix to previous versions.

Cc David Hunt <[email protected]>
Cc Liang Ma <[email protected]>
Cc Xueming Li <[email protected]>
---
  examples/bond/main.c                          | 12 ++++++++++
  examples/distributor/main.c                   | 11 ++++++++++
  examples/eventdev_pipeline/main.c             | 11 ++++++++++
  examples/ip_pipeline/link.c                   |  8 +++++--
  examples/ip_reassembly/main.c                 | 12 ++++++++++
  examples/ipsec-secgw/ipsec-secgw.c            | 12 ++++++++++
  examples/l3fwd-acl/main.c                     | 12 ++++++++++
  examples/l3fwd-power/main.c                   | 14 ++++++++++--
Quoted 10 lines
  examples/l3fwd-vf/main.c                      | 12 ++++++++++
  examples/l3fwd/main.c                         | 12 ++++++++++
  examples/load_balancer/init.c                 | 12 ++++++++++
  examples/multi_process/symmetric_mp/main.c    | 12 ++++++++++
  .../performance-thread/l3fwd-thread/main.c    | 12 ++++++++++
  examples/qos_meter/main.c                     | 22 +++++++++++++++++++
  examples/vmdq_dcb/main.c                      | 13 +++++++++++
  15 files changed, 183 insertions(+), 4 deletions(-)

--snip--

I tested distributor_app, l3-fwd and l3-fwd-power, they all started OK, giving the additional message that some flags were not available on my hardware. Looks good.

Regards,
Dave.

#2 lore raw

Hi Ferruh,

Thanks for this.. I had started working on a patch to do this as well because I got bit by this error.

Shouldn't all of the example applications also add the code to strip the unsupported Tx and Rx offload bits as well? It would help new users (like me!) to understand that this is a requirement for all callers of rte_eth_dev_configure().

    rte_eth_dev_info_get(port_id, &dev_info);

    /* Only set the offload bits which are actually supported */
    port_conf.txmode.offloads &= dev_info.tx_offload_capa;
    port_conf.rxmode.offloads &= dev_info.rx_offload_capa;

thanks
dan

Quoted 23 lines · David

Hi Ferruh,

Quoted 21 lines · Ferruh Yigit

ethdev layer introduced checks for application requested RSS hash functions and returns error for ones unsupported by hardware

This check breaks some sample applications which blindly configures RSS hash functions without checking underlying hardware support.

Updated examples to mask out unsupported RSS has functions during device configuration.
Prints a log if configuration values updated by this check.

Fixes aa1a6d87f15d ("ethdev: force RSS offload rules again")

---
Return error added in this release, so no need to backport the fix to previous versions.

Cc David Hunt <[email protected]>
Cc Liang Ma <[email protected]>
Cc Xueming Li <[email protected]>
#3 lore raw

Hi Ferruh,

The documentation for rte_eth_dev_configure() should get updated as well to document this requirement to strip the unsupported RSS hash function bits. The current documentation only refers to the tx/rx offload bits:

 *     -  Any offloading set in eth_conf->[rt]xmode.offloads must be within
 *        the [rt]x_offload_capa returned from rte_eth_dev_infos_get().
 *        Any type of device supported offloading set in the input argument
 *        eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is enabled
 *        on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup().

thanks
dan

Quoted 18 lines · Dan Gora

Hi Ferruh,

Thanks for this.. I had started working on a patch to do this as well because I got bit by this error.

Shouldn't all of the example applications also add the code to strip the unsupported Tx and Rx offload bits as well? It would help new users (like me!) to understand that this is a requirement for all callers of rte_eth_dev_configure().

    rte_eth_dev_info_get(port_id, &dev_info);

    /* Only set the offload bits which are actually supported */
    port_conf.txmode.offloads &= dev_info.tx_offload_capa;
    port_conf.rxmode.offloads &= dev_info.rx_offload_capa;

thanks
dan

#7 lore raw
In reply to Dan Gora
Quoted 10 lines · Dan Gora

Hi Ferruh,

Thanks for this.. I had started working on a patch to do this as well because I got bit by this error.

Shouldn't all of the example applications also add the code to strip the unsupported Tx and Rx offload bits as well? It would help new users (like me!) to understand that this is a requirement for all callers of rte_eth_dev_configure().

Quoted 5 lines
    rte_eth_dev_info_get(port_id, &dev_info);

    /* Only set the offload bits which are actually supported */
    port_conf.txmode.offloads &= dev_info.tx_offload_capa;
    port_conf.rxmode.offloads &= dev_info.rx_offload_capa;

Yes similar thing required for offloads but not in this patch. There will be already a patch to remove old offload API, perhaps this can be part of that patch.

Quoted 29 lines

thanks
dan

Quoted 23 lines · David

Hi Ferruh,

Quoted 21 lines · Ferruh Yigit

ethdev layer introduced checks for application requested RSS hash functions and returns error for ones unsupported by hardware

This check breaks some sample applications which blindly configures RSS hash functions without checking underlying hardware support.

Updated examples to mask out unsupported RSS has functions during device configuration.
Prints a log if configuration values updated by this check.

Fixes aa1a6d87f15d ("ethdev: force RSS offload rules again")

---
Return error added in this release, so no need to backport the fix to previous versions.

Cc David Hunt <[email protected]>
Cc Liang Ma <[email protected]>
Cc Xueming Li <[email protected]>
#4 lore raw
In reply to Dan Gora
Quoted 7 lines · Dan Gora

Hi Ferruh,

The documentation for rte_eth_dev_configure() should get updated as well to document this requirement to strip the unsupported RSS hash function bits. The current documentation only refers to the tx/rx offload bits:

Quoted 5 lines
 *     -  Any offloading set in eth_conf->[rt]xmode.offloads must be within
 *        the [rt]x_offload_capa returned from rte_eth_dev_infos_get().
 *        Any type of device supported offloading set in the input argument
 *        eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is enabled
 *        on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup().

Agreed, will update the patch according.

Quoted 24 lines

thanks
dan

Quoted 18 lines · Dan Gora

Hi Ferruh,

Thanks for this.. I had started working on a patch to do this as well because I got bit by this error.

Shouldn't all of the example applications also add the code to strip the unsupported Tx and Rx offload bits as well? It would help new users (like me!) to understand that this is a requirement for all callers of rte_eth_dev_configure().

    rte_eth_dev_info_get(port_id, &dev_info);

    /* Only set the offload bits which are actually supported */
    port_conf.txmode.offloads &= dev_info.tx_offload_capa;
    port_conf.rxmode.offloads &= dev_info.rx_offload_capa;

thanks
dan

#8 lore raw
In reply to Ferruh Yigit

Hi Ferruh,

Quoted 29 lines · Ferruh Yigit

ethdev layer introduced checks for application requested RSS hash functions and returns error for ones unsupported by hardware

This check breaks some sample applications which blindly configures RSS hash functions without checking underlying hardware support.

Updated examples to mask out unsupported RSS has functions during device configuration.
Prints a log if configuration values updated by this check.

Fixes aa1a6d87f15d ("ethdev: force RSS offload rules again")

---
Return error added in this release, so no need to backport the fix to previous versions.

Cc David Hunt <[email protected]>
Cc Liang Ma <[email protected]>
Cc Xueming Li <[email protected]>
---
 examples/bond/main.c                          | 12 ++++++++++
 examples/distributor/main.c                   | 11 ++++++++++
 examples/eventdev_pipeline/main.c             | 11 ++++++++++
 examples/ip_pipeline/link.c                   |  8 +++++--
 examples/ip_reassembly/main.c                 | 12 ++++++++++
 examples/ipsec-secgw/ipsec-secgw.c            | 12 ++++++++++
 examples/l3fwd-acl/main.c                     | 12 ++++++++++
 examples/l3fwd-power/main.c                   | 14 ++++++++++--
Quoted 9 lines
 examples/l3fwd-vf/main.c                      | 12 ++++++++++
 examples/l3fwd/main.c                         | 12 ++++++++++
 examples/load_balancer/init.c                 | 12 ++++++++++
 examples/multi_process/symmetric_mp/main.c    | 12 ++++++++++
 .../performance-thread/l3fwd-thread/main.c    | 12 ++++++++++
 examples/qos_meter/main.c                     | 22 +++++++++++++++++++
 examples/vmdq_dcb/main.c                      | 13 +++++++++++
 15 files changed, 183 insertions(+), 4 deletions(-)

As we are fixing it for examples can we include fix for app/test-eventdev too?

app/test-eventdev/test_perf_common.c +6 -0
index d00f91802..79d755b6f 100644
@@ -706,6 +706,12 @@ perf_ethdev_setup(struct evt_test *test, struct evt_options *opt)
        }
 
        RTE_ETH_FOREACH_DEV(i) {
+               struct rte_eth_dev_info dev_info;
+
+               memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));
+               rte_eth_dev_info_get(i, &dev_info);
+               port_conf.rx_adv_conf.rss_conf.rss_hf &=
+                       dev_info.flow_type_rss_offloads;
 
                if (rte_eth_dev_configure(i, 1, 1,
                                        &port_conf)
app/test-eventdev/test_pipeline_common.c +3 -0
index 719518ff3..386ba14d1 100644
@@ -249,6 +249,9 @@ pipeline_ethdev_setup(struct evt_test *test, struct evt_options *opt)
                rx_conf = dev_info.default_rxconf;
                rx_conf.offloads = port_conf.rxmode.offloads;
 
+               port_conf.rx_adv_conf.rss_conf.rss_hf &=
+                       dev_info.flow_type_rss_offloads;
+
                if (rte_eth_dev_configure(i, nb_queues, nb_queues,
                                        &port_conf)
                                < 0) {

Thanks,
Pavan

#9 lore raw
Quoted 42 lines · Pavan Nikhilesh

Hi Ferruh,

Quoted 29 lines · Ferruh Yigit

ethdev layer introduced checks for application requested RSS hash functions and returns error for ones unsupported by hardware

This check breaks some sample applications which blindly configures RSS hash functions without checking underlying hardware support.

Updated examples to mask out unsupported RSS has functions during device configuration.
Prints a log if configuration values updated by this check.

Fixes aa1a6d87f15d ("ethdev: force RSS offload rules again")

---
Return error added in this release, so no need to backport the fix to previous versions.

Cc David Hunt <[email protected]>
Cc Liang Ma <[email protected]>
Cc Xueming Li <[email protected]>
---
 examples/bond/main.c                          | 12 ++++++++++
 examples/distributor/main.c                   | 11 ++++++++++
 examples/eventdev_pipeline/main.c             | 11 ++++++++++
 examples/ip_pipeline/link.c                   |  8 +++++--
 examples/ip_reassembly/main.c                 | 12 ++++++++++
 examples/ipsec-secgw/ipsec-secgw.c            | 12 ++++++++++
 examples/l3fwd-acl/main.c                     | 12 ++++++++++
 examples/l3fwd-power/main.c                   | 14 ++++++++++--
Quoted 9 lines
 examples/l3fwd-vf/main.c                      | 12 ++++++++++
 examples/l3fwd/main.c                         | 12 ++++++++++
 examples/load_balancer/init.c                 | 12 ++++++++++
 examples/multi_process/symmetric_mp/main.c    | 12 ++++++++++
 .../performance-thread/l3fwd-thread/main.c    | 12 ++++++++++
 examples/qos_meter/main.c                     | 22 +++++++++++++++++++
 examples/vmdq_dcb/main.c                      | 13 +++++++++++
 15 files changed, 183 insertions(+), 4 deletions(-)
Quoted 1 line

As we are fixing it for examples can we include fix for app/test-eventdev too?

Yes we should, thanks for reminding, I will update the patch to include below.

Quoted 37 lines
app/test-eventdev/test_perf_common.c +6 -0
index d00f91802..79d755b6f 100644
@@ -706,6 +706,12 @@ perf_ethdev_setup(struct evt_test *test, struct evt_options *opt)
        }
 
        RTE_ETH_FOREACH_DEV(i) {
+               struct rte_eth_dev_info dev_info;
+
+               memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));
+               rte_eth_dev_info_get(i, &dev_info);
+               port_conf.rx_adv_conf.rss_conf.rss_hf &=
+                       dev_info.flow_type_rss_offloads;
 
                if (rte_eth_dev_configure(i, 1, 1,
                                        &port_conf)
app/test-eventdev/test_pipeline_common.c +3 -0
index 719518ff3..386ba14d1 100644
@@ -249,6 +249,9 @@ pipeline_ethdev_setup(struct evt_test *test, struct evt_options *opt)
                rx_conf = dev_info.default_rxconf;
                rx_conf.offloads = port_conf.rxmode.offloads;
 
+               port_conf.rx_adv_conf.rss_conf.rss_hf &=
+                       dev_info.flow_type_rss_offloads;
+
                if (rte_eth_dev_configure(i, nb_queues, nb_queues,
                                        &port_conf)
                                < 0) {

Thanks,
Pavan

#10 lore raw

PATCH v2 1/1 examples: fix RSS hash function configuration

In reply to Ferruh Yigit

ethdev layer introduced checks for application requested RSS hash functions and returns error for ones unsupported by hardware

This check breaks some sample applications which blindly configures RSS hash functions without checking underlying hardware support.

Updated examples to mask out unsupported RSS has functions during device configuration.
Prints a log if configuration values updated by this check.

Fixes aa1a6d87f15d ("ethdev: force RSS offload rules again")

---
Return error added in this release, so no need to backport the fix to previous versions.

Cc David Hunt <[email protected]>
Cc Liang Ma <[email protected]>
Cc Xueming Li <[email protected]>

v2:
Cc: Remy Horton <[email protected]>
* add app/test-eventdev
Cc: Pavan Nikhilesh <[email protected]>

---
 app/test-eventdev/test_perf_common.c          | 19 +++++++++++++---
 app/test-eventdev/test_pipeline_common.c      | 15 +++++++++++--
 examples/bond/main.c                          | 12 ++++++++++
 examples/distributor/main.c                   | 11 ++++++++++
 examples/eventdev_pipeline/main.c             | 11 ++++++++++
 examples/ip_pipeline/link.c                   |  8 +++++--
 examples/ip_reassembly/main.c                 | 12 ++++++++++
 examples/ipsec-secgw/ipsec-secgw.c            | 12 ++++++++++
 examples/l3fwd-acl/main.c                     | 12 ++++++++++
 examples/l3fwd-power/main.c                   | 14 ++++++++++--
 examples/l3fwd-vf/main.c                      | 12 ++++++++++
 examples/l3fwd/main.c                         | 12 ++++++++++
 examples/load_balancer/init.c                 | 12 ++++++++++
 examples/multi_process/symmetric_mp/main.c    | 12 ++++++++++
 .../performance-thread/l3fwd-thread/main.c    | 12 ++++++++++
 examples/qos_meter/main.c                     | 22 +++++++++++++++++++
 examples/vmdq_dcb/main.c                      | 13 +++++++++++
 17 files changed, 212 insertions(+), 9 deletions(-)
app/test-eventdev/test_perf_common.c +16 -3
index d00f91802..86b759502 100644
@@ -706,10 +706,23 @@ perf_ethdev_setup(struct evt_test *test, struct evt_options *opt)
 	}
 
 	RTE_ETH_FOREACH_DEV(i) {
+		struct rte_eth_dev_info dev_info;
+		struct rte_eth_conf local_port_conf = port_conf;
+
+		rte_eth_dev_info_get(i, &dev_info);
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			evt_info("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				i,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
 
-		if (rte_eth_dev_configure(i, 1, 1,
-					&port_conf)
-				< 0) {
+		if (rte_eth_dev_configure(i, 1, 1, &local_port_conf) < 0) {
 			evt_err("Failed to configure eth port [%d]", i);
 			return -EINVAL;
 		}
app/test-eventdev/test_pipeline_common.c +13 -2
index 719518ff3..136e091f9 100644
@@ -241,16 +241,27 @@ pipeline_ethdev_setup(struct evt_test *test, struct evt_options *opt)
 
 	RTE_ETH_FOREACH_DEV(i) {
 		struct rte_eth_dev_info dev_info;
+		struct rte_eth_conf local_port_conf = port_conf;
 
-		memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));
 		rte_eth_dev_info_get(i, &dev_info);
 		mt_state = !(dev_info.tx_offload_capa &
 				DEV_TX_OFFLOAD_MT_LOCKFREE);
 		rx_conf = dev_info.default_rxconf;
 		rx_conf.offloads = port_conf.rxmode.offloads;
 
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			evt_info("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				i,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		if (rte_eth_dev_configure(i, nb_queues, nb_queues,
-					&port_conf)
+					&local_port_conf)
 				< 0) {
 			evt_err("Failed to configure eth port [%d]\n", i);
 			return -EINVAL;
examples/bond/main.c +12 -0
index 65e0edd25..7d506feb2 100644
@@ -154,6 +154,18 @@ slave_port_init(uint16_t portid, struct rte_mempool *mbuf_pool)
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		local_port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			portid,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	retval = rte_eth_dev_configure(portid, 1, 1, &local_port_conf);
 	if (retval != 0)
 		rte_exit(EXIT_FAILURE, "port %u: configuration failed (res=%d)\n",
examples/distributor/main.c +11 -0
index 2c5936489..4dd69faab 100644
@@ -124,6 +124,17 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 		port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
 
+	port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	retval = rte_eth_dev_configure(port, rxRings, txRings, &port_conf);
 	if (retval != 0)
 		return retval;
examples/eventdev_pipeline/main.c +11 -0
index b698e4ca2..2af430206 100644
@@ -293,6 +293,17 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
 		port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
 
+	port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	/* Configure the Ethernet device. */
 	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
 	if (retval != 0)
examples/ip_pipeline/link.c +6 -2
index b8a431f3e..31d8cd332 100644
@@ -161,8 +161,12 @@ link_create(const char *name, struct link_params *params)
 	memcpy(&port_conf, &port_conf_default, sizeof(port_conf));
 	if (rss) {
 		port_conf.rxmode.mq_mode = ETH_MQ_RX_RSS;
-		port_conf.rx_adv_conf.rss_conf.rss_hf =
-			ETH_RSS_IPV4 | ETH_RSS_IPV6;
+		if (port_info.flow_type_rss_offloads & ETH_RSS_IPV4)
+			port_conf.rx_adv_conf.rss_conf.rss_hf |=
+				ETH_RSS_IPV4;
+		if (port_info.flow_type_rss_offloads & ETH_RSS_IPV6)
+			port_conf.rx_adv_conf.rss_conf.rss_hf |=
+				ETH_RSS_IPV6;
 	}
 
 	cpu_id = (uint32_t) rte_eth_dev_socket_id(port_id);
examples/ip_reassembly/main.c +12 -0
index 3e8e79c21..ccef5a6af 100644
@@ -1083,6 +1083,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, 1, (uint16_t)n_tx_queue,
 					    &local_port_conf);
 		if (ret < 0) {
examples/ipsec-secgw/ipsec-secgw.c +12 -0
index a5da8b280..8bd38882e 100644
@@ -1566,6 +1566,18 @@ port_init(uint16_t portid)
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		local_port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			portid,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	ret = rte_eth_dev_configure(portid, nb_rx_queue, nb_tx_queue,
 			&local_port_conf);
 	if (ret < 0)
examples/l3fwd-acl/main.c +12 -0
index 33ad467d3..fa12bb894 100644
@@ -1926,6 +1926,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					(uint16_t)n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/l3fwd-power/main.c +12 -2
index 596d64548..e1c2e4ae0 100644
@@ -185,8 +185,6 @@ static struct rte_eth_conf port_conf = {
 		.max_rx_pkt_len = ETHER_MAX_LEN,
 		.split_hdr_size = 0,
 		.ignore_offload_bitfield = 1,
-		.offloads = (DEV_RX_OFFLOAD_CRC_STRIP |
-			     DEV_RX_OFFLOAD_CHECKSUM),
 	},
 	.rx_adv_conf = {
 		.rss_conf = {
@@ -1693,6 +1691,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					(uint16_t)n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/l3fwd-vf/main.c +12 -0
index aaafb7bc2..a01f70cb5 100644
@@ -981,6 +981,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					    n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/l3fwd/main.c +12 -0
index bf7dbd814..2ca0fcdaa 100644
@@ -861,6 +861,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					(uint16_t)n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/load_balancer/init.c +12 -0
index 8d8dbe61e..7d019da30 100644
@@ -417,6 +417,18 @@ app_init_nics(void)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				port,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(
 			port,
 			(uint8_t) n_rx_queues,
examples/multi_process/symmetric_mp/main.c +12 -0
index 16f21a187..2ea3e7a7a 100644
@@ -200,6 +200,7 @@ smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool,
 	uint16_t q;
 	uint16_t nb_rxd = RX_RING_SIZE;
 	uint16_t nb_txd = TX_RING_SIZE;
+	uint64_t rss_hf_tmp;
 
 	if (rte_eal_process_type() == RTE_PROC_SECONDARY)
 		return 0;
@@ -216,6 +217,17 @@ smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool,
 	if (info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	rss_hf_tmp = port_conf.rx_adv_conf.rss_conf.rss_hf;
+	port_conf.rx_adv_conf.rss_conf.rss_hf &= info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf != rss_hf_tmp) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			rss_hf_tmp,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
 	if (retval < 0)
 		return retval;
examples/performance-thread/l3fwd-thread/main.c +12 -0
index 40d807239..1b13d25db 100644
@@ -3551,6 +3551,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					(uint16_t)n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/qos_meter/main.c +22 -0
index 42cf4b29f..2122bd1dd 100644
@@ -333,6 +333,17 @@ main(int argc, char **argv)
 	rte_eth_dev_info_get(port_rx, &dev_info);
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	conf.rx_adv_conf.rss_conf.rss_hf &= dev_info.flow_type_rss_offloads;
+	if (conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port_rx,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	ret = rte_eth_dev_configure(port_rx, 1, 1, &conf);
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Port %d configuration error (%d)\n", port_rx, ret);
@@ -363,6 +374,17 @@ main(int argc, char **argv)
 	rte_eth_dev_info_get(port_tx, &dev_info);
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	conf.rx_adv_conf.rss_conf.rss_hf &= dev_info.flow_type_rss_offloads;
+	if (conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port_tx,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	ret = rte_eth_dev_configure(port_tx, 1, 1, &conf);
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Port %d configuration error (%d)\n", port_tx, ret);
examples/vmdq_dcb/main.c +13 -0
index 2626a2f19..49bf84001 100644
@@ -197,6 +197,7 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 	uint16_t queues_per_pool;
 	uint32_t max_nb_pools;
 	struct rte_eth_txconf txq_conf;
+	uint64_t rss_hf_tmp;
 
 	/*
 	 * The max pool number from dev_info will be used to validate the pool
@@ -257,6 +258,18 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	rss_hf_tmp = port_conf.rx_adv_conf.rss_conf.rss_hf;
+	port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf != rss_hf_tmp) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			rss_hf_tmp,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	/*
 	 * Though in this example, all queues including pf queues are setup.
 	 * This is because VMDQ queues doesn't always start from zero, and the
Signature · 1 line
2.17.1
#5 lore raw
In reply to Ferruh Yigit

20/06/2018 19:15, Ferruh Yigit:

Quoted 8 lines · Dan Gora
Quoted 7 lines

Hi Ferruh,

The documentation for rte_eth_dev_configure() should get updated as well to document this requirement to strip the unsupported RSS hash function bits. The current documentation only refers to the tx/rx offload bits:

Quoted 7 lines
Quoted 5 lines
 *     -  Any offloading set in eth_conf->[rt]xmode.offloads must be within
 *        the [rt]x_offload_capa returned from rte_eth_dev_infos_get().
 *        Any type of device supported offloading set in the input argument
 *        eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is enabled
 *        on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup().

Agreed, will update the patch according.

I don't see the doc updated in your v2.

#6 lore raw
Quoted 15 lines · Thomas Monjalon

20/06/2018 19:15, Ferruh Yigit:

Quoted 14 lines · Dan Gora
Quoted 12 lines

Hi Ferruh,

The documentation for rte_eth_dev_configure() should get updated as well to document this requirement to strip the unsupported RSS hash function bits. The current documentation only refers to the tx/rx offload bits:

 *     -  Any offloading set in eth_conf->[rt]xmode.offloads must be within
 *        the [rt]x_offload_capa returned from rte_eth_dev_infos_get().
 *        Any type of device supported offloading set in the input argument
 *        eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is enabled
 *        on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup().
Quoted 3 lines
Quoted 1 line

Agreed, will update the patch according.

I don't see the doc updated in your v2.

I have missed it, sending new version with the update.

#11 lore raw

PATCH v3 1/1 examples: fix RSS hash function configuration

In reply to Ferruh Yigit

ethdev layer introduced checks for application requested RSS hash functions and returns error for ones unsupported by hardware

This check breaks some sample applications which blindly configures RSS hash functions without checking underlying hardware support.

Updated examples to mask out unsupported RSS has functions during device configuration.
Prints a log if configuration values updated by this check.

Fixes aa1a6d87f15d ("ethdev: force RSS offload rules again")

---
Return error added in this release, so no need to backport the fix to previous versions.

Cc David Hunt <[email protected]>
Cc Liang Ma <[email protected]>
Cc Xueming Li <[email protected]>

v2:
Cc: Remy Horton <[email protected]>
* add app/test-eventdev
Cc: Pavan Nikhilesh <[email protected]>

v3:
* document rte_eth_dev_configure() API rss_hf restriction

---
 app/test-eventdev/test_perf_common.c          | 19 +++++++++++++---
 app/test-eventdev/test_pipeline_common.c      | 15 +++++++++++--
 examples/bond/main.c                          | 12 ++++++++++
 examples/distributor/main.c                   | 11 ++++++++++
 examples/eventdev_pipeline/main.c             | 11 ++++++++++
 examples/ip_pipeline/link.c                   |  8 +++++--
 examples/ip_reassembly/main.c                 | 12 ++++++++++
 examples/ipsec-secgw/ipsec-secgw.c            | 12 ++++++++++
 examples/l3fwd-acl/main.c                     | 12 ++++++++++
 examples/l3fwd-power/main.c                   | 14 ++++++++++--
 examples/l3fwd-vf/main.c                      | 12 ++++++++++
 examples/l3fwd/main.c                         | 12 ++++++++++
 examples/load_balancer/init.c                 | 12 ++++++++++
 examples/multi_process/symmetric_mp/main.c    | 12 ++++++++++
 .../performance-thread/l3fwd-thread/main.c    | 12 ++++++++++
 examples/qos_meter/main.c                     | 22 +++++++++++++++++++
 examples/vmdq_dcb/main.c                      | 13 +++++++++++
 lib/librte_ethdev/rte_ethdev.h                |  8 ++++---
 18 files changed, 217 insertions(+), 12 deletions(-)
app/test-eventdev/test_perf_common.c +16 -3
index d00f91802..86b759502 100644
@@ -706,10 +706,23 @@ perf_ethdev_setup(struct evt_test *test, struct evt_options *opt)
 	}
 
 	RTE_ETH_FOREACH_DEV(i) {
+		struct rte_eth_dev_info dev_info;
+		struct rte_eth_conf local_port_conf = port_conf;
+
+		rte_eth_dev_info_get(i, &dev_info);
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			evt_info("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				i,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
 
-		if (rte_eth_dev_configure(i, 1, 1,
-					&port_conf)
-				< 0) {
+		if (rte_eth_dev_configure(i, 1, 1, &local_port_conf) < 0) {
 			evt_err("Failed to configure eth port [%d]", i);
 			return -EINVAL;
 		}
app/test-eventdev/test_pipeline_common.c +13 -2
index 719518ff3..136e091f9 100644
@@ -241,16 +241,27 @@ pipeline_ethdev_setup(struct evt_test *test, struct evt_options *opt)
 
 	RTE_ETH_FOREACH_DEV(i) {
 		struct rte_eth_dev_info dev_info;
+		struct rte_eth_conf local_port_conf = port_conf;
 
-		memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));
 		rte_eth_dev_info_get(i, &dev_info);
 		mt_state = !(dev_info.tx_offload_capa &
 				DEV_TX_OFFLOAD_MT_LOCKFREE);
 		rx_conf = dev_info.default_rxconf;
 		rx_conf.offloads = port_conf.rxmode.offloads;
 
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			evt_info("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				i,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		if (rte_eth_dev_configure(i, nb_queues, nb_queues,
-					&port_conf)
+					&local_port_conf)
 				< 0) {
 			evt_err("Failed to configure eth port [%d]\n", i);
 			return -EINVAL;
examples/bond/main.c +12 -0
index 65e0edd25..7d506feb2 100644
@@ -154,6 +154,18 @@ slave_port_init(uint16_t portid, struct rte_mempool *mbuf_pool)
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		local_port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			portid,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	retval = rte_eth_dev_configure(portid, 1, 1, &local_port_conf);
 	if (retval != 0)
 		rte_exit(EXIT_FAILURE, "port %u: configuration failed (res=%d)\n",
examples/distributor/main.c +11 -0
index 2c5936489..4dd69faab 100644
@@ -124,6 +124,17 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 		port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
 
+	port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	retval = rte_eth_dev_configure(port, rxRings, txRings, &port_conf);
 	if (retval != 0)
 		return retval;
examples/eventdev_pipeline/main.c +11 -0
index b698e4ca2..2af430206 100644
@@ -293,6 +293,17 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
 		port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
 
+	port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	/* Configure the Ethernet device. */
 	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
 	if (retval != 0)
examples/ip_pipeline/link.c +6 -2
index b8a431f3e..31d8cd332 100644
@@ -161,8 +161,12 @@ link_create(const char *name, struct link_params *params)
 	memcpy(&port_conf, &port_conf_default, sizeof(port_conf));
 	if (rss) {
 		port_conf.rxmode.mq_mode = ETH_MQ_RX_RSS;
-		port_conf.rx_adv_conf.rss_conf.rss_hf =
-			ETH_RSS_IPV4 | ETH_RSS_IPV6;
+		if (port_info.flow_type_rss_offloads & ETH_RSS_IPV4)
+			port_conf.rx_adv_conf.rss_conf.rss_hf |=
+				ETH_RSS_IPV4;
+		if (port_info.flow_type_rss_offloads & ETH_RSS_IPV6)
+			port_conf.rx_adv_conf.rss_conf.rss_hf |=
+				ETH_RSS_IPV6;
 	}
 
 	cpu_id = (uint32_t) rte_eth_dev_socket_id(port_id);
examples/ip_reassembly/main.c +12 -0
index 3e8e79c21..ccef5a6af 100644
@@ -1083,6 +1083,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, 1, (uint16_t)n_tx_queue,
 					    &local_port_conf);
 		if (ret < 0) {
examples/ipsec-secgw/ipsec-secgw.c +12 -0
index a5da8b280..8bd38882e 100644
@@ -1566,6 +1566,18 @@ port_init(uint16_t portid)
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		local_port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			portid,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	ret = rte_eth_dev_configure(portid, nb_rx_queue, nb_tx_queue,
 			&local_port_conf);
 	if (ret < 0)
examples/l3fwd-acl/main.c +12 -0
index 33ad467d3..fa12bb894 100644
@@ -1926,6 +1926,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					(uint16_t)n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/l3fwd-power/main.c +12 -2
index 596d64548..e1c2e4ae0 100644
@@ -185,8 +185,6 @@ static struct rte_eth_conf port_conf = {
 		.max_rx_pkt_len = ETHER_MAX_LEN,
 		.split_hdr_size = 0,
 		.ignore_offload_bitfield = 1,
-		.offloads = (DEV_RX_OFFLOAD_CRC_STRIP |
-			     DEV_RX_OFFLOAD_CHECKSUM),
 	},
 	.rx_adv_conf = {
 		.rss_conf = {
@@ -1693,6 +1691,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					(uint16_t)n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/l3fwd-vf/main.c +12 -0
index aaafb7bc2..a01f70cb5 100644
@@ -981,6 +981,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					    n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/l3fwd/main.c +12 -0
index bf7dbd814..2ca0fcdaa 100644
@@ -861,6 +861,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					(uint16_t)n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/load_balancer/init.c +12 -0
index 8d8dbe61e..7d019da30 100644
@@ -417,6 +417,18 @@ app_init_nics(void)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				port,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(
 			port,
 			(uint8_t) n_rx_queues,
examples/multi_process/symmetric_mp/main.c +12 -0
index 16f21a187..2ea3e7a7a 100644
@@ -200,6 +200,7 @@ smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool,
 	uint16_t q;
 	uint16_t nb_rxd = RX_RING_SIZE;
 	uint16_t nb_txd = TX_RING_SIZE;
+	uint64_t rss_hf_tmp;
 
 	if (rte_eal_process_type() == RTE_PROC_SECONDARY)
 		return 0;
@@ -216,6 +217,17 @@ smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool,
 	if (info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	rss_hf_tmp = port_conf.rx_adv_conf.rss_conf.rss_hf;
+	port_conf.rx_adv_conf.rss_conf.rss_hf &= info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf != rss_hf_tmp) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			rss_hf_tmp,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
 	if (retval < 0)
 		return retval;
examples/performance-thread/l3fwd-thread/main.c +12 -0
index 40d807239..1b13d25db 100644
@@ -3551,6 +3551,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					(uint16_t)n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/qos_meter/main.c +22 -0
index 42cf4b29f..2122bd1dd 100644
@@ -333,6 +333,17 @@ main(int argc, char **argv)
 	rte_eth_dev_info_get(port_rx, &dev_info);
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	conf.rx_adv_conf.rss_conf.rss_hf &= dev_info.flow_type_rss_offloads;
+	if (conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port_rx,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	ret = rte_eth_dev_configure(port_rx, 1, 1, &conf);
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Port %d configuration error (%d)\n", port_rx, ret);
@@ -363,6 +374,17 @@ main(int argc, char **argv)
 	rte_eth_dev_info_get(port_tx, &dev_info);
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	conf.rx_adv_conf.rss_conf.rss_hf &= dev_info.flow_type_rss_offloads;
+	if (conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port_tx,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	ret = rte_eth_dev_configure(port_tx, 1, 1, &conf);
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Port %d configuration error (%d)\n", port_tx, ret);
examples/vmdq_dcb/main.c +13 -0
index 2626a2f19..49bf84001 100644
@@ -197,6 +197,7 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 	uint16_t queues_per_pool;
 	uint32_t max_nb_pools;
 	struct rte_eth_txconf txq_conf;
+	uint64_t rss_hf_tmp;
 
 	/*
 	 * The max pool number from dev_info will be used to validate the pool
@@ -257,6 +258,18 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	rss_hf_tmp = port_conf.rx_adv_conf.rss_conf.rss_hf;
+	port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf != rss_hf_tmp) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			rss_hf_tmp,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	/*
 	 * Though in this example, all queues including pf queues are setup.
 	 * This is because VMDQ queues doesn't always start from zero, and the
lib/librte_ethdev/rte_ethdev.h +5 -3
index 5760f45d3..fa0f330ec 100644
@@ -1559,9 +1559,11 @@ const char * __rte_experimental rte_eth_dev_tx_offload_name(uint64_t offload);
  *        the [rt]x_offload_capa returned from rte_eth_dev_infos_get().
  *        Any type of device supported offloading set in the input argument
  *        eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is enabled
- *        on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup().
- *     - the Receive Side Scaling (RSS) configuration when using multiple RX
- *         queues per port.
+ *        on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup()
+ *     -  the Receive Side Scaling (RSS) configuration when using multiple RX
+ *        queues per port. Any RSS hash function set in eth_conf->rss_conf.rss_hf
+ *        must be within the flow_type_rss_offloads provided by drivers via
+ *        rte_eth_dev_infos_get() API.
  *
  *   Embedding all configuration information in a single data structure
  *   is the more flexible method that allows the addition of new features
Signature · 1 line
2.17.1
#12 lore raw

PATCH v4 1/1 examples: fix RSS hash function configuration

ethdev layer introduced checks for application requested RSS hash functions and returns error for ones unsupported by hardware

This check breaks some sample applications which blindly configures RSS hash functions without checking underlying hardware support.

Updated examples to mask out unsupported RSS has functions during device configuration.
Prints a log if configuration values updated by this check.

Fixes aa1a6d87f15d ("ethdev: force RSS offload rules again")

---
Return error added in this release, so no need to backport the fix to previous versions.

Cc David Hunt <[email protected]>
Cc Liang Ma <[email protected]>
Cc Xueming Li <[email protected]>

v2:
Cc: Remy Horton <[email protected]>
* add app/test-eventdev
Cc: Pavan Nikhilesh <[email protected]>

v3:
* document rte_eth_dev_configure() API rss_hf restriction

v4:
* Flex tespmd "port config all rss xxx" command to mask out unsupported values and print a log about the modification done to requested config

---
 app/test-eventdev/test_perf_common.c          | 19 +++++++++++++---
 app/test-eventdev/test_pipeline_common.c      | 15 +++++++++++--
 app/test-pmd/cmdline.c                        | 14 ++++++++++--
 examples/bond/main.c                          | 12 ++++++++++
 examples/distributor/main.c                   | 11 ++++++++++
 examples/eventdev_pipeline/main.c             | 11 ++++++++++
 examples/ip_pipeline/link.c                   |  8 +++++--
 examples/ip_reassembly/main.c                 | 12 ++++++++++
 examples/ipsec-secgw/ipsec-secgw.c            | 12 ++++++++++
 examples/l3fwd-acl/main.c                     | 12 ++++++++++
 examples/l3fwd-power/main.c                   | 14 ++++++++++--
 examples/l3fwd-vf/main.c                      | 12 ++++++++++
 examples/l3fwd/main.c                         | 12 ++++++++++
 examples/load_balancer/init.c                 | 12 ++++++++++
 examples/multi_process/symmetric_mp/main.c    | 12 ++++++++++
 .../performance-thread/l3fwd-thread/main.c    | 12 ++++++++++
 examples/qos_meter/main.c                     | 22 +++++++++++++++++++
 examples/vmdq_dcb/main.c                      | 13 +++++++++++
 lib/librte_ethdev/rte_ethdev.h                |  8 ++++---
 19 files changed, 229 insertions(+), 14 deletions(-)
app/test-eventdev/test_perf_common.c +16 -3
index d00f91802..86b759502 100644
@@ -706,10 +706,23 @@ perf_ethdev_setup(struct evt_test *test, struct evt_options *opt)
 	}
 
 	RTE_ETH_FOREACH_DEV(i) {
+		struct rte_eth_dev_info dev_info;
+		struct rte_eth_conf local_port_conf = port_conf;
+
+		rte_eth_dev_info_get(i, &dev_info);
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			evt_info("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				i,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
 
-		if (rte_eth_dev_configure(i, 1, 1,
-					&port_conf)
-				< 0) {
+		if (rte_eth_dev_configure(i, 1, 1, &local_port_conf) < 0) {
 			evt_err("Failed to configure eth port [%d]", i);
 			return -EINVAL;
 		}
app/test-eventdev/test_pipeline_common.c +13 -2
index 719518ff3..136e091f9 100644
@@ -241,16 +241,27 @@ pipeline_ethdev_setup(struct evt_test *test, struct evt_options *opt)
 
 	RTE_ETH_FOREACH_DEV(i) {
 		struct rte_eth_dev_info dev_info;
+		struct rte_eth_conf local_port_conf = port_conf;
 
-		memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));
 		rte_eth_dev_info_get(i, &dev_info);
 		mt_state = !(dev_info.tx_offload_capa &
 				DEV_TX_OFFLOAD_MT_LOCKFREE);
 		rx_conf = dev_info.default_rxconf;
 		rx_conf.offloads = port_conf.rxmode.offloads;
 
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			evt_info("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				i,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		if (rte_eth_dev_configure(i, nb_queues, nb_queues,
-					&port_conf)
+					&local_port_conf)
 				< 0) {
 			evt_err("Failed to configure eth port [%d]\n", i);
 			return -EINVAL;
app/test-pmd/cmdline.c +12 -2
index 27e2aa8c8..bc86896e6 100644
@@ -2058,10 +2058,20 @@ cmd_config_rss_parsed(void *parsed_result,
 	rss_conf.rss_key = NULL;
 	/* Update global configuration for RSS types. */
 	RTE_ETH_FOREACH_DEV(i) {
-		if (use_default) {
-			rte_eth_dev_info_get(i, &dev_info);
+		uint64_t local_rss_hf;
+
+		rte_eth_dev_info_get(i, &dev_info);
+		if (use_default)
 			rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
+
+		local_rss_hf = rss_conf.rss_hf & dev_info.flow_type_rss_offloads;
+		if (local_rss_hf != rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				i, rss_conf.rss_hf, local_rss_hf);
+			rss_conf.rss_hf = local_rss_hf;
 		}
+
 		diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
 		if (diag < 0) {
 			all_updated = 0;
examples/bond/main.c +12 -0
index 65e0edd25..7d506feb2 100644
@@ -154,6 +154,18 @@ slave_port_init(uint16_t portid, struct rte_mempool *mbuf_pool)
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		local_port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			portid,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	retval = rte_eth_dev_configure(portid, 1, 1, &local_port_conf);
 	if (retval != 0)
 		rte_exit(EXIT_FAILURE, "port %u: configuration failed (res=%d)\n",
examples/distributor/main.c +11 -0
index 2c5936489..4dd69faab 100644
@@ -124,6 +124,17 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 		port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
 
+	port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	retval = rte_eth_dev_configure(port, rxRings, txRings, &port_conf);
 	if (retval != 0)
 		return retval;
examples/eventdev_pipeline/main.c +11 -0
index b698e4ca2..2af430206 100644
@@ -293,6 +293,17 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
 		port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
 
+	port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	/* Configure the Ethernet device. */
 	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
 	if (retval != 0)
examples/ip_pipeline/link.c +6 -2
index b8a431f3e..31d8cd332 100644
@@ -161,8 +161,12 @@ link_create(const char *name, struct link_params *params)
 	memcpy(&port_conf, &port_conf_default, sizeof(port_conf));
 	if (rss) {
 		port_conf.rxmode.mq_mode = ETH_MQ_RX_RSS;
-		port_conf.rx_adv_conf.rss_conf.rss_hf =
-			ETH_RSS_IPV4 | ETH_RSS_IPV6;
+		if (port_info.flow_type_rss_offloads & ETH_RSS_IPV4)
+			port_conf.rx_adv_conf.rss_conf.rss_hf |=
+				ETH_RSS_IPV4;
+		if (port_info.flow_type_rss_offloads & ETH_RSS_IPV6)
+			port_conf.rx_adv_conf.rss_conf.rss_hf |=
+				ETH_RSS_IPV6;
 	}
 
 	cpu_id = (uint32_t) rte_eth_dev_socket_id(port_id);
examples/ip_reassembly/main.c +12 -0
index 3e8e79c21..ccef5a6af 100644
@@ -1083,6 +1083,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, 1, (uint16_t)n_tx_queue,
 					    &local_port_conf);
 		if (ret < 0) {
examples/ipsec-secgw/ipsec-secgw.c +12 -0
index a5da8b280..8bd38882e 100644
@@ -1566,6 +1566,18 @@ port_init(uint16_t portid)
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		local_port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			portid,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	ret = rte_eth_dev_configure(portid, nb_rx_queue, nb_tx_queue,
 			&local_port_conf);
 	if (ret < 0)
examples/l3fwd-acl/main.c +12 -0
index 33ad467d3..fa12bb894 100644
@@ -1926,6 +1926,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					(uint16_t)n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/l3fwd-power/main.c +12 -2
index 596d64548..e1c2e4ae0 100644
@@ -185,8 +185,6 @@ static struct rte_eth_conf port_conf = {
 		.max_rx_pkt_len = ETHER_MAX_LEN,
 		.split_hdr_size = 0,
 		.ignore_offload_bitfield = 1,
-		.offloads = (DEV_RX_OFFLOAD_CRC_STRIP |
-			     DEV_RX_OFFLOAD_CHECKSUM),
 	},
 	.rx_adv_conf = {
 		.rss_conf = {
@@ -1693,6 +1691,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					(uint16_t)n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/l3fwd-vf/main.c +12 -0
index aaafb7bc2..a01f70cb5 100644
@@ -981,6 +981,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					    n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/l3fwd/main.c +12 -0
index bf7dbd814..2ca0fcdaa 100644
@@ -861,6 +861,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					(uint16_t)n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/load_balancer/init.c +12 -0
index 8d8dbe61e..7d019da30 100644
@@ -417,6 +417,18 @@ app_init_nics(void)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				port,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(
 			port,
 			(uint8_t) n_rx_queues,
examples/multi_process/symmetric_mp/main.c +12 -0
index 16f21a187..2ea3e7a7a 100644
@@ -200,6 +200,7 @@ smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool,
 	uint16_t q;
 	uint16_t nb_rxd = RX_RING_SIZE;
 	uint16_t nb_txd = TX_RING_SIZE;
+	uint64_t rss_hf_tmp;
 
 	if (rte_eal_process_type() == RTE_PROC_SECONDARY)
 		return 0;
@@ -216,6 +217,17 @@ smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool,
 	if (info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	rss_hf_tmp = port_conf.rx_adv_conf.rss_conf.rss_hf;
+	port_conf.rx_adv_conf.rss_conf.rss_hf &= info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf != rss_hf_tmp) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			rss_hf_tmp,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
 	if (retval < 0)
 		return retval;
examples/performance-thread/l3fwd-thread/main.c +12 -0
index 40d807239..1b13d25db 100644
@@ -3551,6 +3551,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					(uint16_t)n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/qos_meter/main.c +22 -0
index 42cf4b29f..2122bd1dd 100644
@@ -333,6 +333,17 @@ main(int argc, char **argv)
 	rte_eth_dev_info_get(port_rx, &dev_info);
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	conf.rx_adv_conf.rss_conf.rss_hf &= dev_info.flow_type_rss_offloads;
+	if (conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port_rx,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	ret = rte_eth_dev_configure(port_rx, 1, 1, &conf);
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Port %d configuration error (%d)\n", port_rx, ret);
@@ -363,6 +374,17 @@ main(int argc, char **argv)
 	rte_eth_dev_info_get(port_tx, &dev_info);
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	conf.rx_adv_conf.rss_conf.rss_hf &= dev_info.flow_type_rss_offloads;
+	if (conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port_tx,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	ret = rte_eth_dev_configure(port_tx, 1, 1, &conf);
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Port %d configuration error (%d)\n", port_tx, ret);
examples/vmdq_dcb/main.c +13 -0
index 2626a2f19..49bf84001 100644
@@ -197,6 +197,7 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 	uint16_t queues_per_pool;
 	uint32_t max_nb_pools;
 	struct rte_eth_txconf txq_conf;
+	uint64_t rss_hf_tmp;
 
 	/*
 	 * The max pool number from dev_info will be used to validate the pool
@@ -257,6 +258,18 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	rss_hf_tmp = port_conf.rx_adv_conf.rss_conf.rss_hf;
+	port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf != rss_hf_tmp) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			rss_hf_tmp,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	/*
 	 * Though in this example, all queues including pf queues are setup.
 	 * This is because VMDQ queues doesn't always start from zero, and the
lib/librte_ethdev/rte_ethdev.h +5 -3
index aa991da62..b4b2e77b2 100644
@@ -1565,9 +1565,11 @@ const char * __rte_experimental rte_eth_dev_tx_offload_name(uint64_t offload);
  *        the [rt]x_offload_capa returned from rte_eth_dev_infos_get().
  *        Any type of device supported offloading set in the input argument
  *        eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is enabled
- *        on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup().
- *     - the Receive Side Scaling (RSS) configuration when using multiple RX
- *         queues per port.
+ *        on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup()
+ *     -  the Receive Side Scaling (RSS) configuration when using multiple RX
+ *        queues per port. Any RSS hash function set in eth_conf->rss_conf.rss_hf
+ *        must be within the flow_type_rss_offloads provided by drivers via
+ *        rte_eth_dev_infos_get() API.
  *
  *   Embedding all configuration information in a single data structure
  *   is the more flexible method that allows the addition of new features
Signature · 1 line
2.17.1
#13 lore raw

PATCH v5 1/1 examples: fix RSS hash function configuration

ethdev layer introduced checks for application requested RSS hash functions and returns error for ones unsupported by hardware

This check breaks some sample applications which blindly configures RSS hash functions without checking underlying hardware support.

Updated examples to mask out unsupported RSS has functions during device configuration.
Prints a log if configuration values updated by this check.

Fixes aa1a6d87f15d ("ethdev: force RSS offload rules again")

---
Return error added in this release, so no need to backport the fix to previous versions.

Cc David Hunt <[email protected]>
Cc Liang Ma <[email protected]>
Cc Xueming Li <[email protected]>

v2:
Cc: Remy Horton <[email protected]>
* add app/test-eventdev
Cc: Pavan Nikhilesh <[email protected]>

v3:
* document rte_eth_dev_configure() API rss_hf restriction

v4:
* Flex tespmd "port config all rss xxx" command to mask out unsupported values and print a log about the modification done to requested config

v5:
* fix local_rss_hf logic in testpmd (the one added in v4)

---
 app/test-eventdev/test_perf_common.c          | 19 +++++++++++++---
 app/test-eventdev/test_pipeline_common.c      | 15 +++++++++++--
 app/test-pmd/cmdline.c                        | 16 +++++++++++---
 examples/bond/main.c                          | 12 ++++++++++
 examples/distributor/main.c                   | 11 ++++++++++
 examples/eventdev_pipeline/main.c             | 11 ++++++++++
 examples/ip_pipeline/link.c                   |  8 +++++--
 examples/ip_reassembly/main.c                 | 12 ++++++++++
 examples/ipsec-secgw/ipsec-secgw.c            | 12 ++++++++++
 examples/l3fwd-acl/main.c                     | 12 ++++++++++
 examples/l3fwd-power/main.c                   | 14 ++++++++++--
 examples/l3fwd-vf/main.c                      | 12 ++++++++++
 examples/l3fwd/main.c                         | 12 ++++++++++
 examples/load_balancer/init.c                 | 12 ++++++++++
 examples/multi_process/symmetric_mp/main.c    | 12 ++++++++++
 .../performance-thread/l3fwd-thread/main.c    | 12 ++++++++++
 examples/qos_meter/main.c                     | 22 +++++++++++++++++++
 examples/vmdq_dcb/main.c                      | 13 +++++++++++
 lib/librte_ethdev/rte_ethdev.h                |  8 ++++---
 19 files changed, 230 insertions(+), 15 deletions(-)
app/test-eventdev/test_perf_common.c +16 -3
index d00f91802..86b759502 100644
@@ -706,10 +706,23 @@ perf_ethdev_setup(struct evt_test *test, struct evt_options *opt)
 	}
 
 	RTE_ETH_FOREACH_DEV(i) {
+		struct rte_eth_dev_info dev_info;
+		struct rte_eth_conf local_port_conf = port_conf;
+
+		rte_eth_dev_info_get(i, &dev_info);
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			evt_info("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				i,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
 
-		if (rte_eth_dev_configure(i, 1, 1,
-					&port_conf)
-				< 0) {
+		if (rte_eth_dev_configure(i, 1, 1, &local_port_conf) < 0) {
 			evt_err("Failed to configure eth port [%d]", i);
 			return -EINVAL;
 		}
app/test-eventdev/test_pipeline_common.c +13 -2
index 719518ff3..136e091f9 100644
@@ -241,16 +241,27 @@ pipeline_ethdev_setup(struct evt_test *test, struct evt_options *opt)
 
 	RTE_ETH_FOREACH_DEV(i) {
 		struct rte_eth_dev_info dev_info;
+		struct rte_eth_conf local_port_conf = port_conf;
 
-		memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));
 		rte_eth_dev_info_get(i, &dev_info);
 		mt_state = !(dev_info.tx_offload_capa &
 				DEV_TX_OFFLOAD_MT_LOCKFREE);
 		rx_conf = dev_info.default_rxconf;
 		rx_conf.offloads = port_conf.rxmode.offloads;
 
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			evt_info("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				i,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		if (rte_eth_dev_configure(i, nb_queues, nb_queues,
-					&port_conf)
+					&local_port_conf)
 				< 0) {
 			evt_err("Failed to configure eth port [%d]\n", i);
 			return -EINVAL;
app/test-pmd/cmdline.c +13 -3
index 27e2aa8c8..74a8cd99e 100644
@@ -2058,11 +2058,21 @@ cmd_config_rss_parsed(void *parsed_result,
 	rss_conf.rss_key = NULL;
 	/* Update global configuration for RSS types. */
 	RTE_ETH_FOREACH_DEV(i) {
-		if (use_default) {
-			rte_eth_dev_info_get(i, &dev_info);
+		struct rte_eth_rss_conf local_rss_conf;
+
+		rte_eth_dev_info_get(i, &dev_info);
+		if (use_default)
 			rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
+
+		local_rss_conf = rss_conf;
+		local_rss_conf.rss_hf = rss_conf.rss_hf &
+			dev_info.flow_type_rss_offloads;
+		if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				i, rss_conf.rss_hf, local_rss_conf.rss_hf);
 		}
-		diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
+		diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
 		if (diag < 0) {
 			all_updated = 0;
 			printf("Configuration of RSS hash at ethernet port %d "
examples/bond/main.c +12 -0
index 65e0edd25..7d506feb2 100644
@@ -154,6 +154,18 @@ slave_port_init(uint16_t portid, struct rte_mempool *mbuf_pool)
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		local_port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			portid,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	retval = rte_eth_dev_configure(portid, 1, 1, &local_port_conf);
 	if (retval != 0)
 		rte_exit(EXIT_FAILURE, "port %u: configuration failed (res=%d)\n",
examples/distributor/main.c +11 -0
index 2c5936489..4dd69faab 100644
@@ -124,6 +124,17 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 		port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
 
+	port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	retval = rte_eth_dev_configure(port, rxRings, txRings, &port_conf);
 	if (retval != 0)
 		return retval;
examples/eventdev_pipeline/main.c +11 -0
index b698e4ca2..2af430206 100644
@@ -293,6 +293,17 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
 		port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
 
+	port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	/* Configure the Ethernet device. */
 	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
 	if (retval != 0)
examples/ip_pipeline/link.c +6 -2
index b8a431f3e..31d8cd332 100644
@@ -161,8 +161,12 @@ link_create(const char *name, struct link_params *params)
 	memcpy(&port_conf, &port_conf_default, sizeof(port_conf));
 	if (rss) {
 		port_conf.rxmode.mq_mode = ETH_MQ_RX_RSS;
-		port_conf.rx_adv_conf.rss_conf.rss_hf =
-			ETH_RSS_IPV4 | ETH_RSS_IPV6;
+		if (port_info.flow_type_rss_offloads & ETH_RSS_IPV4)
+			port_conf.rx_adv_conf.rss_conf.rss_hf |=
+				ETH_RSS_IPV4;
+		if (port_info.flow_type_rss_offloads & ETH_RSS_IPV6)
+			port_conf.rx_adv_conf.rss_conf.rss_hf |=
+				ETH_RSS_IPV6;
 	}
 
 	cpu_id = (uint32_t) rte_eth_dev_socket_id(port_id);
examples/ip_reassembly/main.c +12 -0
index 3e8e79c21..ccef5a6af 100644
@@ -1083,6 +1083,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, 1, (uint16_t)n_tx_queue,
 					    &local_port_conf);
 		if (ret < 0) {
examples/ipsec-secgw/ipsec-secgw.c +12 -0
index a5da8b280..8bd38882e 100644
@@ -1566,6 +1566,18 @@ port_init(uint16_t portid)
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		local_port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			portid,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	ret = rte_eth_dev_configure(portid, nb_rx_queue, nb_tx_queue,
 			&local_port_conf);
 	if (ret < 0)
examples/l3fwd-acl/main.c +12 -0
index 33ad467d3..fa12bb894 100644
@@ -1926,6 +1926,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					(uint16_t)n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/l3fwd-power/main.c +12 -2
index 596d64548..e1c2e4ae0 100644
@@ -185,8 +185,6 @@ static struct rte_eth_conf port_conf = {
 		.max_rx_pkt_len = ETHER_MAX_LEN,
 		.split_hdr_size = 0,
 		.ignore_offload_bitfield = 1,
-		.offloads = (DEV_RX_OFFLOAD_CRC_STRIP |
-			     DEV_RX_OFFLOAD_CHECKSUM),
 	},
 	.rx_adv_conf = {
 		.rss_conf = {
@@ -1693,6 +1691,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					(uint16_t)n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/l3fwd-vf/main.c +12 -0
index aaafb7bc2..a01f70cb5 100644
@@ -981,6 +981,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					    n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/l3fwd/main.c +12 -0
index bf7dbd814..2ca0fcdaa 100644
@@ -861,6 +861,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					(uint16_t)n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/load_balancer/init.c +12 -0
index 8d8dbe61e..7d019da30 100644
@@ -417,6 +417,18 @@ app_init_nics(void)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				port,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(
 			port,
 			(uint8_t) n_rx_queues,
examples/multi_process/symmetric_mp/main.c +12 -0
index 16f21a187..2ea3e7a7a 100644
@@ -200,6 +200,7 @@ smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool,
 	uint16_t q;
 	uint16_t nb_rxd = RX_RING_SIZE;
 	uint16_t nb_txd = TX_RING_SIZE;
+	uint64_t rss_hf_tmp;
 
 	if (rte_eal_process_type() == RTE_PROC_SECONDARY)
 		return 0;
@@ -216,6 +217,17 @@ smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool,
 	if (info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	rss_hf_tmp = port_conf.rx_adv_conf.rss_conf.rss_hf;
+	port_conf.rx_adv_conf.rss_conf.rss_hf &= info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf != rss_hf_tmp) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			rss_hf_tmp,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
 	if (retval < 0)
 		return retval;
examples/performance-thread/l3fwd-thread/main.c +12 -0
index 40d807239..1b13d25db 100644
@@ -3551,6 +3551,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					(uint16_t)n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/qos_meter/main.c +22 -0
index 42cf4b29f..2122bd1dd 100644
@@ -333,6 +333,17 @@ main(int argc, char **argv)
 	rte_eth_dev_info_get(port_rx, &dev_info);
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	conf.rx_adv_conf.rss_conf.rss_hf &= dev_info.flow_type_rss_offloads;
+	if (conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port_rx,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	ret = rte_eth_dev_configure(port_rx, 1, 1, &conf);
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Port %d configuration error (%d)\n", port_rx, ret);
@@ -363,6 +374,17 @@ main(int argc, char **argv)
 	rte_eth_dev_info_get(port_tx, &dev_info);
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	conf.rx_adv_conf.rss_conf.rss_hf &= dev_info.flow_type_rss_offloads;
+	if (conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port_tx,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	ret = rte_eth_dev_configure(port_tx, 1, 1, &conf);
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Port %d configuration error (%d)\n", port_tx, ret);
examples/vmdq_dcb/main.c +13 -0
index 2626a2f19..49bf84001 100644
@@ -197,6 +197,7 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 	uint16_t queues_per_pool;
 	uint32_t max_nb_pools;
 	struct rte_eth_txconf txq_conf;
+	uint64_t rss_hf_tmp;
 
 	/*
 	 * The max pool number from dev_info will be used to validate the pool
@@ -257,6 +258,18 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	rss_hf_tmp = port_conf.rx_adv_conf.rss_conf.rss_hf;
+	port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf != rss_hf_tmp) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			rss_hf_tmp,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	/*
 	 * Though in this example, all queues including pf queues are setup.
 	 * This is because VMDQ queues doesn't always start from zero, and the
lib/librte_ethdev/rte_ethdev.h +5 -3
index aa991da62..b4b2e77b2 100644
@@ -1565,9 +1565,11 @@ const char * __rte_experimental rte_eth_dev_tx_offload_name(uint64_t offload);
  *        the [rt]x_offload_capa returned from rte_eth_dev_infos_get().
  *        Any type of device supported offloading set in the input argument
  *        eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is enabled
- *        on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup().
- *     - the Receive Side Scaling (RSS) configuration when using multiple RX
- *         queues per port.
+ *        on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup()
+ *     -  the Receive Side Scaling (RSS) configuration when using multiple RX
+ *        queues per port. Any RSS hash function set in eth_conf->rss_conf.rss_hf
+ *        must be within the flow_type_rss_offloads provided by drivers via
+ *        rte_eth_dev_infos_get() API.
  *
  *   Embedding all configuration information in a single data structure
  *   is the more flexible method that allows the addition of new features
Signature · 1 line
2.17.1
#14 lore raw

PATCH v6 1/1 examples: fix RSS hash function configuration

ethdev layer introduced checks for application requested RSS hash functions and returns error for ones unsupported by hardware

This check breaks some sample applications which blindly configures RSS hash functions without checking underlying hardware support.

Updated examples to mask out unsupported RSS has functions during device configuration.
Prints a log if configuration values updated by this check.

Fixes aa1a6d87f15d ("ethdev: force RSS offload rules again")

---
Return error added in this release, so no need to backport the fix to previous versions.

Cc David Hunt <[email protected]>
Cc Liang Ma <[email protected]>
Cc Xueming Li <[email protected]>

v2:
Cc: Remy Horton <[email protected]>
* add app/test-eventdev
Cc: Pavan Nikhilesh <[email protected]>

v3:
* document rte_eth_dev_configure() API rss_hf restriction

v4:
* Flex tespmd "port config all rss xxx" command to mask out unsupported values and print a log about the modification done to requested config

v5:
* fix local_rss_hf logic in testpmd (the one added in v4)

v6:
* don't remove offload flags from l3fwd-power
* rebase

---
 app/test-eventdev/test_perf_common.c          | 19 +++++++++++++---
 app/test-eventdev/test_pipeline_common.c      | 15 +++++++++++--
 app/test-pmd/cmdline.c                        | 16 +++++++++++---
 examples/bond/main.c                          | 12 ++++++++++
 examples/distributor/main.c                   | 11 ++++++++++
 examples/eventdev_pipeline/main.c             | 11 ++++++++++
 examples/ip_pipeline/link.c                   |  8 +++++--
 examples/ip_reassembly/main.c                 | 12 ++++++++++
 examples/ipsec-secgw/ipsec-secgw.c            | 12 ++++++++++
 examples/l3fwd-acl/main.c                     | 12 ++++++++++
 examples/l3fwd-power/main.c                   | 12 ++++++++++
 examples/l3fwd-vf/main.c                      | 12 ++++++++++
 examples/l3fwd/main.c                         | 12 ++++++++++
 examples/load_balancer/init.c                 | 12 ++++++++++
 examples/multi_process/symmetric_mp/main.c    | 12 ++++++++++
 .../performance-thread/l3fwd-thread/main.c    | 12 ++++++++++
 examples/qos_meter/main.c                     | 22 +++++++++++++++++++
 examples/vmdq_dcb/main.c                      | 13 +++++++++++
 lib/librte_ethdev/rte_ethdev.h                |  8 ++++---
 19 files changed, 230 insertions(+), 13 deletions(-)
app/test-eventdev/test_perf_common.c +16 -3
index eed80d1b1..d0d835d5e 100644
@@ -700,10 +700,23 @@ perf_ethdev_setup(struct evt_test *test, struct evt_options *opt)
 	}
 
 	RTE_ETH_FOREACH_DEV(i) {
+		struct rte_eth_dev_info dev_info;
+		struct rte_eth_conf local_port_conf = port_conf;
+
+		rte_eth_dev_info_get(i, &dev_info);
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			evt_info("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				i,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
 
-		if (rte_eth_dev_configure(i, 1, 1,
-					&port_conf)
-				< 0) {
+		if (rte_eth_dev_configure(i, 1, 1, &local_port_conf) < 0) {
 			evt_err("Failed to configure eth port [%d]", i);
 			return -EINVAL;
 		}
app/test-eventdev/test_pipeline_common.c +13 -2
index 3bc9d513d..239c953e6 100644
@@ -240,16 +240,27 @@ pipeline_ethdev_setup(struct evt_test *test, struct evt_options *opt)
 
 	RTE_ETH_FOREACH_DEV(i) {
 		struct rte_eth_dev_info dev_info;
+		struct rte_eth_conf local_port_conf = port_conf;
 
-		memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));
 		rte_eth_dev_info_get(i, &dev_info);
 		mt_state = !(dev_info.tx_offload_capa &
 				DEV_TX_OFFLOAD_MT_LOCKFREE);
 		rx_conf = dev_info.default_rxconf;
 		rx_conf.offloads = port_conf.rxmode.offloads;
 
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			evt_info("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				i,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		if (rte_eth_dev_configure(i, nb_queues, nb_queues,
-					&port_conf)
+					&local_port_conf)
 				< 0) {
 			evt_err("Failed to configure eth port [%d]\n", i);
 			return -EINVAL;
app/test-pmd/cmdline.c +13 -3
index 27e2aa8c8..74a8cd99e 100644
@@ -2058,11 +2058,21 @@ cmd_config_rss_parsed(void *parsed_result,
 	rss_conf.rss_key = NULL;
 	/* Update global configuration for RSS types. */
 	RTE_ETH_FOREACH_DEV(i) {
-		if (use_default) {
-			rte_eth_dev_info_get(i, &dev_info);
+		struct rte_eth_rss_conf local_rss_conf;
+
+		rte_eth_dev_info_get(i, &dev_info);
+		if (use_default)
 			rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
+
+		local_rss_conf = rss_conf;
+		local_rss_conf.rss_hf = rss_conf.rss_hf &
+			dev_info.flow_type_rss_offloads;
+		if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				i, rss_conf.rss_hf, local_rss_conf.rss_hf);
 		}
-		diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
+		diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
 		if (diag < 0) {
 			all_updated = 0;
 			printf("Configuration of RSS hash at ethernet port %d "
examples/bond/main.c +12 -0
index 98415d66d..23d0981ab 100644
@@ -153,6 +153,18 @@ slave_port_init(uint16_t portid, struct rte_mempool *mbuf_pool)
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		local_port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			portid,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	retval = rte_eth_dev_configure(portid, 1, 1, &local_port_conf);
 	if (retval != 0)
 		rte_exit(EXIT_FAILURE, "port %u: configuration failed (res=%d)\n",
examples/distributor/main.c +11 -0
index 85881a2e8..03a05e3d9 100644
@@ -123,6 +123,17 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 		port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
 
+	port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	retval = rte_eth_dev_configure(port, rxRings, txRings, &port_conf);
 	if (retval != 0)
 		return retval;
examples/eventdev_pipeline/main.c +11 -0
index 7bc294946..700bc696f 100644
@@ -292,6 +292,17 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
 		port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
 
+	port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	/* Configure the Ethernet device. */
 	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
 	if (retval != 0)
examples/ip_pipeline/link.c +6 -2
index 181c31f9c..805c2eb95 100644
@@ -152,8 +152,12 @@ link_create(const char *name, struct link_params *params)
 	memcpy(&port_conf, &port_conf_default, sizeof(port_conf));
 	if (rss) {
 		port_conf.rxmode.mq_mode = ETH_MQ_RX_RSS;
-		port_conf.rx_adv_conf.rss_conf.rss_hf =
-			ETH_RSS_IPV4 | ETH_RSS_IPV6;
+		if (port_info.flow_type_rss_offloads & ETH_RSS_IPV4)
+			port_conf.rx_adv_conf.rss_conf.rss_hf |=
+				ETH_RSS_IPV4;
+		if (port_info.flow_type_rss_offloads & ETH_RSS_IPV6)
+			port_conf.rx_adv_conf.rss_conf.rss_hf |=
+				ETH_RSS_IPV6;
 	}
 
 	cpu_id = (uint32_t) rte_eth_dev_socket_id(port_id);
examples/ip_reassembly/main.c +12 -0
index 94e63fc6a..b830f67a5 100644
@@ -1082,6 +1082,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, 1, (uint16_t)n_tx_queue,
 					    &local_port_conf);
 		if (ret < 0) {
examples/ipsec-secgw/ipsec-secgw.c +12 -0
index 199bae51b..68b346502 100644
@@ -1565,6 +1565,18 @@ port_init(uint16_t portid)
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		local_port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			portid,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	ret = rte_eth_dev_configure(portid, nb_rx_queue, nb_tx_queue,
 			&local_port_conf);
 	if (ret < 0)
examples/l3fwd-acl/main.c +12 -0
index 55a5a69e5..7c063a8d0 100644
@@ -1925,6 +1925,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					(uint16_t)n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/l3fwd-power/main.c +12 -0
index 710b76d12..f6fabd95f 100644
@@ -1692,6 +1692,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					(uint16_t)n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/l3fwd-vf/main.c +12 -0
index 43e629828..5edd91a78 100644
@@ -980,6 +980,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					    n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/l3fwd/main.c +12 -0
index faef9f1ac..ab019b9e4 100644
@@ -860,6 +860,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					(uint16_t)n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/load_balancer/init.c +12 -0
index 6aa079c69..f2045f235 100644
@@ -416,6 +416,18 @@ app_init_nics(void)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				port,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(
 			port,
 			(uint8_t) n_rx_queues,
examples/multi_process/symmetric_mp/main.c +12 -0
index c36326917..c6c6a537f 100644
@@ -199,6 +199,7 @@ smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool,
 	uint16_t q;
 	uint16_t nb_rxd = RX_RING_SIZE;
 	uint16_t nb_txd = TX_RING_SIZE;
+	uint64_t rss_hf_tmp;
 
 	if (rte_eal_process_type() == RTE_PROC_SECONDARY)
 		return 0;
@@ -215,6 +216,17 @@ smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool,
 	if (info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	rss_hf_tmp = port_conf.rx_adv_conf.rss_conf.rss_hf;
+	port_conf.rx_adv_conf.rss_conf.rss_hf &= info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf != rss_hf_tmp) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			rss_hf_tmp,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
 	if (retval < 0)
 		return retval;
examples/performance-thread/l3fwd-thread/main.c +12 -0
index d1e4a1880..5392fcea8 100644
@@ -3550,6 +3550,18 @@ main(int argc, char **argv)
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
 		ret = rte_eth_dev_configure(portid, nb_rx_queue,
 					(uint16_t)n_tx_queue, &local_port_conf);
 		if (ret < 0)
examples/qos_meter/main.c +22 -0
index ca0e9e863..5cf4e9dfa 100644
@@ -332,6 +332,17 @@ main(int argc, char **argv)
 	rte_eth_dev_info_get(port_rx, &dev_info);
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	conf.rx_adv_conf.rss_conf.rss_hf &= dev_info.flow_type_rss_offloads;
+	if (conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port_rx,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	ret = rte_eth_dev_configure(port_rx, 1, 1, &conf);
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Port %d configuration error (%d)\n", port_rx, ret);
@@ -361,6 +372,17 @@ main(int argc, char **argv)
 	rte_eth_dev_info_get(port_tx, &dev_info);
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	conf.rx_adv_conf.rss_conf.rss_hf &= dev_info.flow_type_rss_offloads;
+	if (conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port_tx,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	ret = rte_eth_dev_configure(port_tx, 1, 1, &conf);
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Port %d configuration error (%d)\n", port_tx, ret);
examples/vmdq_dcb/main.c +13 -0
index 5a0463c58..646368395 100644
@@ -196,6 +196,7 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 	uint16_t queues_per_pool;
 	uint32_t max_nb_pools;
 	struct rte_eth_txconf txq_conf;
+	uint64_t rss_hf_tmp;
 
 	/*
 	 * The max pool number from dev_info will be used to validate the pool
@@ -256,6 +257,18 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 		port_conf.txmode.offloads |=
 			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	rss_hf_tmp = port_conf.rx_adv_conf.rss_conf.rss_hf;
+	port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf != rss_hf_tmp) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			rss_hf_tmp,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
 	/*
 	 * Though in this example, all queues including pf queues are setup.
 	 * This is because VMDQ queues doesn't always start from zero, and the
lib/librte_ethdev/rte_ethdev.h +5 -3
index 6d4caff6b..f5f593b31 100644
@@ -1515,9 +1515,11 @@ const char * __rte_experimental rte_eth_dev_tx_offload_name(uint64_t offload);
  *        the [rt]x_offload_capa returned from rte_eth_dev_infos_get().
  *        Any type of device supported offloading set in the input argument
  *        eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is enabled
- *        on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup().
- *     - the Receive Side Scaling (RSS) configuration when using multiple RX
- *         queues per port.
+ *        on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup()
+ *     -  the Receive Side Scaling (RSS) configuration when using multiple RX
+ *        queues per port. Any RSS hash function set in eth_conf->rss_conf.rss_hf
+ *        must be within the flow_type_rss_offloads provided by drivers via
+ *        rte_eth_dev_infos_get() API.
  *
  *   Embedding all configuration information in a single data structure
  *   is the more flexible method that allows the addition of new features
Signature · 1 line
2.17.1
Tested-by on v6 1/1
#15 lore raw

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ferruh Yigit
Sent: Thursday, July 5, 2018 4:02 AM
To: Jerin Jacob <[email protected]>; Lu, Wenzhuo <[email protected]>; Wu, Jingjing <[email protected]>; Iremonger, Bernard <[email protected]>; Doherty, Declan <[email protected]>; Chas Williams <[email protected]>; Richardson, Bruce <[email protected]>; Hunt, David <[email protected]>; Van Haaren, Harry <[email protected]>; Dumitrescu, Cristian <[email protected]>; Ananyev, Konstantin <[email protected]>; Horton, Remy <[email protected]>; Ori Kam <[email protected]>; De Lara Guarch, Pablo <[email protected]>; Nicolau, Radu <[email protected]>; Akhil Goyal <[email protected]>; Kantecki, Tomasz <[email protected]>; Burakov, Anatoly <[email protected]>; Mcnamara, John <[email protected]>; Li, Xiaoyun <[email protected]>; Thomas Monjalon <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Yigit, Ferruh <[email protected]>; Ma, Liang J <[email protected]>; Xueming Li <[email protected]>; Pavan Nikhilesh <[email protected]>
Subject: [dpdk-dev] [PATCH v6] examples: fix RSS hash function configuration

ethdev layer introduced checks for application requested RSS hash functions and returns error for ones unsupported by hardware

This check breaks some sample applications which blindly configures RSS hash functions without checking underlying hardware support.

Updated examples to mask out unsupported RSS has functions during device configuration. Prints a log if configuration values updated by this check.

Fixes aa1a6d87f15d ("ethdev: force RSS offload rules again")
Acked-by David Hunt on v6 1/1
#16 lore raw
In reply to Ferruh Yigit

Hi Ferruh,

Quoted 535 lines · Ferruh Yigit

ethdev layer introduced checks for application requested RSS hash functions and returns error for ones unsupported by hardware

This check breaks some sample applications which blindly configures RSS hash functions without checking underlying hardware support.

Updated examples to mask out unsupported RSS has functions during device configuration.
Prints a log if configuration values updated by this check.

Fixes aa1a6d87f15d ("ethdev: force RSS offload rules again")

---
Return error added in this release, so no need to backport the fix to previous versions.

Cc David Hunt <[email protected]>
Cc Liang Ma <[email protected]>
Cc Xueming Li <[email protected]>

v2:
Cc: Remy Horton <[email protected]>
* add app/test-eventdev
Cc: Pavan Nikhilesh <[email protected]>

v3:
* document rte_eth_dev_configure() API rss_hf restriction

v4:
* Flex tespmd "port config all rss xxx" command to mask out unsupported values and print a log about the modification done to requested config

v5:
* fix local_rss_hf logic in testpmd (the one added in v4)

v6:
* don't remove offload flags from l3fwd-power
* rebase

---
  app/test-eventdev/test_perf_common.c          | 19 +++++++++++++---
  app/test-eventdev/test_pipeline_common.c      | 15 +++++++++++--
  app/test-pmd/cmdline.c                        | 16 +++++++++++---
  examples/bond/main.c                          | 12 ++++++++++
  examples/distributor/main.c                   | 11 ++++++++++
  examples/eventdev_pipeline/main.c             | 11 ++++++++++
  examples/ip_pipeline/link.c                   |  8 +++++--
  examples/ip_reassembly/main.c                 | 12 ++++++++++
  examples/ipsec-secgw/ipsec-secgw.c            | 12 ++++++++++
  examples/l3fwd-acl/main.c                     | 12 ++++++++++
  examples/l3fwd-power/main.c                   | 12 ++++++++++
  examples/l3fwd-vf/main.c                      | 12 ++++++++++
  examples/l3fwd/main.c                         | 12 ++++++++++
  examples/load_balancer/init.c                 | 12 ++++++++++
  examples/multi_process/symmetric_mp/main.c    | 12 ++++++++++
  .../performance-thread/l3fwd-thread/main.c    | 12 ++++++++++
  examples/qos_meter/main.c                     | 22 +++++++++++++++++++
  examples/vmdq_dcb/main.c                      | 13 +++++++++++
  lib/librte_ethdev/rte_ethdev.h                |  8 ++++---
  19 files changed, 230 insertions(+), 13 deletions(-)
app/test-eventdev/test_perf_common.c +16 -3
index eed80d1b1..d0d835d5e 100644
@@ -700,10 +700,23 @@ perf_ethdev_setup(struct evt_test *test, struct evt_options *opt)
  	}
 
  	RTE_ETH_FOREACH_DEV(i) {
+		struct rte_eth_dev_info dev_info;
+		struct rte_eth_conf local_port_conf = port_conf;
+
+		rte_eth_dev_info_get(i, &dev_info);
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			evt_info("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				i,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
 
-		if (rte_eth_dev_configure(i, 1, 1,
-					&port_conf)
-				< 0) {
+		if (rte_eth_dev_configure(i, 1, 1, &local_port_conf) < 0) {
  			evt_err("Failed to configure eth port [%d]", i);
  			return -EINVAL;
  		}
app/test-eventdev/test_pipeline_common.c +13 -2
index 3bc9d513d..239c953e6 100644
@@ -240,16 +240,27 @@ pipeline_ethdev_setup(struct evt_test *test, struct evt_options *opt)
 
  	RTE_ETH_FOREACH_DEV(i) {
  		struct rte_eth_dev_info dev_info;
+		struct rte_eth_conf local_port_conf = port_conf;
 
-		memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));
  		rte_eth_dev_info_get(i, &dev_info);
  		mt_state = !(dev_info.tx_offload_capa &
  				DEV_TX_OFFLOAD_MT_LOCKFREE);
  		rx_conf = dev_info.default_rxconf;
  		rx_conf.offloads = port_conf.rxmode.offloads;
 
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			evt_info("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				i,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
  		if (rte_eth_dev_configure(i, nb_queues, nb_queues,
-					&port_conf)
+					&local_port_conf)
  				< 0) {
  			evt_err("Failed to configure eth port [%d]\n", i);
  			return -EINVAL;
app/test-pmd/cmdline.c +13 -3
index 27e2aa8c8..74a8cd99e 100644
@@ -2058,11 +2058,21 @@ cmd_config_rss_parsed(void *parsed_result,
  	rss_conf.rss_key = NULL;
  	/* Update global configuration for RSS types. */
  	RTE_ETH_FOREACH_DEV(i) {
-		if (use_default) {
-			rte_eth_dev_info_get(i, &dev_info);
+		struct rte_eth_rss_conf local_rss_conf;
+
+		rte_eth_dev_info_get(i, &dev_info);
+		if (use_default)
  			rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
+
+		local_rss_conf = rss_conf;
+		local_rss_conf.rss_hf = rss_conf.rss_hf &
+			dev_info.flow_type_rss_offloads;
+		if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				i, rss_conf.rss_hf, local_rss_conf.rss_hf);
  		}
-		diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
+		diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
  		if (diag < 0) {
  			all_updated = 0;
  			printf("Configuration of RSS hash at ethernet port %d "
examples/bond/main.c +12 -0
index 98415d66d..23d0981ab 100644
@@ -153,6 +153,18 @@ slave_port_init(uint16_t portid, struct rte_mempool *mbuf_pool)
  	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
  		local_port_conf.txmode.offloads |=
  			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			portid,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
  	retval = rte_eth_dev_configure(portid, 1, 1, &local_port_conf);
  	if (retval != 0)
  		rte_exit(EXIT_FAILURE, "port %u: configuration failed (res=%d)\n",
examples/distributor/main.c +11 -0
index 85881a2e8..03a05e3d9 100644
@@ -123,6 +123,17 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
  		port_conf.txmode.offloads |=
  			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
 
+	port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
  	retval = rte_eth_dev_configure(port, rxRings, txRings, &port_conf);
  	if (retval != 0)
  		return retval;
examples/eventdev_pipeline/main.c +11 -0
index 7bc294946..700bc696f 100644
@@ -292,6 +292,17 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
  		port_conf.txmode.offloads |=
  			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
 
+	port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			port_conf_default.rx_adv_conf.rss_conf.rss_hf,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
  	/* Configure the Ethernet device. */
  	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
  	if (retval != 0)
examples/ip_pipeline/link.c +6 -2
index 181c31f9c..805c2eb95 100644
@@ -152,8 +152,12 @@ link_create(const char *name, struct link_params *params)
  	memcpy(&port_conf, &port_conf_default, sizeof(port_conf));
  	if (rss) {
  		port_conf.rxmode.mq_mode = ETH_MQ_RX_RSS;
-		port_conf.rx_adv_conf.rss_conf.rss_hf =
-			ETH_RSS_IPV4 | ETH_RSS_IPV6;
+		if (port_info.flow_type_rss_offloads & ETH_RSS_IPV4)
+			port_conf.rx_adv_conf.rss_conf.rss_hf |=
+				ETH_RSS_IPV4;
+		if (port_info.flow_type_rss_offloads & ETH_RSS_IPV6)
+			port_conf.rx_adv_conf.rss_conf.rss_hf |=
+				ETH_RSS_IPV6;
  	}
 
  	cpu_id = (uint32_t) rte_eth_dev_socket_id(port_id);
examples/ip_reassembly/main.c +12 -0
index 94e63fc6a..b830f67a5 100644
@@ -1082,6 +1082,18 @@ main(int argc, char **argv)
  		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
  			local_port_conf.txmode.offloads |=
  				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
  		ret = rte_eth_dev_configure(portid, 1, (uint16_t)n_tx_queue,
  					    &local_port_conf);
  		if (ret < 0) {
examples/ipsec-secgw/ipsec-secgw.c +12 -0
index 199bae51b..68b346502 100644
@@ -1565,6 +1565,18 @@ port_init(uint16_t portid)
  	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
  		local_port_conf.txmode.offloads |=
  			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			portid,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
  	ret = rte_eth_dev_configure(portid, nb_rx_queue, nb_tx_queue,
  			&local_port_conf);
  	if (ret < 0)
examples/l3fwd-acl/main.c +12 -0
index 55a5a69e5..7c063a8d0 100644
@@ -1925,6 +1925,18 @@ main(int argc, char **argv)
  		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
  			local_port_conf.txmode.offloads |=
  				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
  		ret = rte_eth_dev_configure(portid, nb_rx_queue,
  					(uint16_t)n_tx_queue, &local_port_conf);
  		if (ret < 0)
examples/l3fwd-power/main.c +12 -0
index 710b76d12..f6fabd95f 100644
@@ -1692,6 +1692,18 @@ main(int argc, char **argv)
  		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
  			local_port_conf.txmode.offloads |=
  				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
  		ret = rte_eth_dev_configure(portid, nb_rx_queue,
  					(uint16_t)n_tx_queue, &local_port_conf);
  		if (ret < 0)
examples/l3fwd-vf/main.c +12 -0
index 43e629828..5edd91a78 100644
@@ -980,6 +980,18 @@ main(int argc, char **argv)
  		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
  			local_port_conf.txmode.offloads |=
  				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
  		ret = rte_eth_dev_configure(portid, nb_rx_queue,
  					    n_tx_queue, &local_port_conf);
  		if (ret < 0)
examples/l3fwd/main.c +12 -0
index faef9f1ac..ab019b9e4 100644
@@ -860,6 +860,18 @@ main(int argc, char **argv)
  		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
  			local_port_conf.txmode.offloads |=
  				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
  		ret = rte_eth_dev_configure(portid, nb_rx_queue,
  					(uint16_t)n_tx_queue, &local_port_conf);
  		if (ret < 0)
examples/load_balancer/init.c +12 -0
index 6aa079c69..f2045f235 100644
@@ -416,6 +416,18 @@ app_init_nics(void)
  		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
  			local_port_conf.txmode.offloads |=
  				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				port,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
  		ret = rte_eth_dev_configure(
  			port,
  			(uint8_t) n_rx_queues,
examples/multi_process/symmetric_mp/main.c +12 -0
index c36326917..c6c6a537f 100644
@@ -199,6 +199,7 @@ smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool,
  	uint16_t q;
  	uint16_t nb_rxd = RX_RING_SIZE;
  	uint16_t nb_txd = TX_RING_SIZE;
+	uint64_t rss_hf_tmp;
 
  	if (rte_eal_process_type() == RTE_PROC_SECONDARY)
  		return 0;
@@ -215,6 +216,17 @@ smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool,
  	if (info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
  		port_conf.txmode.offloads |=
  			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	rss_hf_tmp = port_conf.rx_adv_conf.rss_conf.rss_hf;
+	port_conf.rx_adv_conf.rss_conf.rss_hf &= info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf != rss_hf_tmp) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			rss_hf_tmp,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
  	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
  	if (retval < 0)
  		return retval;
examples/performance-thread/l3fwd-thread/main.c +12 -0
index d1e4a1880..5392fcea8 100644
@@ -3550,6 +3550,18 @@ main(int argc, char **argv)
  		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
  			local_port_conf.txmode.offloads |=
  				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+			dev_info.flow_type_rss_offloads;
+		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+				port_conf.rx_adv_conf.rss_conf.rss_hf) {
+			printf("Port %u modified RSS hash function based on hardware support,"
+				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+				portid,
+				port_conf.rx_adv_conf.rss_conf.rss_hf,
+				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+		}
+
  		ret = rte_eth_dev_configure(portid, nb_rx_queue,
  					(uint16_t)n_tx_queue, &local_port_conf);
  		if (ret < 0)
examples/qos_meter/main.c +22 -0
index ca0e9e863..5cf4e9dfa 100644
@@ -332,6 +332,17 @@ main(int argc, char **argv)
  	rte_eth_dev_info_get(port_rx, &dev_info);
  	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
  		conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	conf.rx_adv_conf.rss_conf.rss_hf &= dev_info.flow_type_rss_offloads;
+	if (conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port_rx,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
  	ret = rte_eth_dev_configure(port_rx, 1, 1, &conf);
  	if (ret < 0)
  		rte_exit(EXIT_FAILURE, "Port %d configuration error (%d)\n", port_rx, ret);
@@ -361,6 +372,17 @@ main(int argc, char **argv)
  	rte_eth_dev_info_get(port_tx, &dev_info);
  	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
  		conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	conf.rx_adv_conf.rss_conf.rss_hf &= dev_info.flow_type_rss_offloads;
+	if (conf.rx_adv_conf.rss_conf.rss_hf !=
+			port_conf.rx_adv_conf.rss_conf.rss_hf) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port_tx,
+			port_conf.rx_adv_conf.rss_conf.rss_hf,
+			conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
  	ret = rte_eth_dev_configure(port_tx, 1, 1, &conf);
  	if (ret < 0)
  		rte_exit(EXIT_FAILURE, "Port %d configuration error (%d)\n", port_tx, ret);
examples/vmdq_dcb/main.c +13 -0
index 5a0463c58..646368395 100644
@@ -196,6 +196,7 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
  	uint16_t queues_per_pool;
  	uint32_t max_nb_pools;
  	struct rte_eth_txconf txq_conf;
+	uint64_t rss_hf_tmp;
 
  	/*
  	 * The max pool number from dev_info will be used to validate the pool
@@ -256,6 +257,18 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
  	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
  		port_conf.txmode.offloads |=
  			DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	rss_hf_tmp = port_conf.rx_adv_conf.rss_conf.rss_hf;
+	port_conf.rx_adv_conf.rss_conf.rss_hf &=
+		dev_info.flow_type_rss_offloads;
+	if (port_conf.rx_adv_conf.rss_conf.rss_hf != rss_hf_tmp) {
+		printf("Port %u modified RSS hash function based on hardware support,"
+			"requested:%#"PRIx64" configured:%#"PRIx64"\n",
+			port,
+			rss_hf_tmp,
+			port_conf.rx_adv_conf.rss_conf.rss_hf);
+	}
+
  	/*
  	 * Though in this example, all queues including pf queues are setup.
  	 * This is because VMDQ queues doesn't always start from zero, and the
lib/librte_ethdev/rte_ethdev.h +0 -1
index 6d4caff6b..f5f593b31 100644
@@ -1515,9 +1515,11 @@ const char * __rte_experimental rte_eth_dev_tx_offload_name(uint64_t offload);
   *        the [rt]x_offload_capa returned from rte_eth_dev_infos_get().
   *        Any type of device supported offloading set in the input argument
   *        eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is enabled
- *        on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup().

lib/librte_ethdev/rte_ethdev.h const char * __rte_experimental rte_eth_dev_tx_offload_name(uint64_t offload); · line 1525

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +5 -2
- *     - the Receive Side Scaling (RSS) configuration when using multiple RX
- *         queues per port.
+ *        on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup()
+ *     -  the Receive Side Scaling (RSS) configuration when using multiple RX
+ *        queues per port. Any RSS hash function set in eth_conf->rss_conf.rss_hf
+ *        must be within the flow_type_rss_offloads provided by drivers via
+ *        rte_eth_dev_infos_get() API.
   *
   *   Embedding all configuration information in a single data structure
   *   is the more flexible method that allows the addition of new features

Looks good to me.

Acked-by David Hunt <[email protected] <mailto:[email protected]>>
author Tested-by Yingya Han Applied
#17 lore raw
Quoted 17 lines · David

Hi Ferruh,

Quoted 13 lines · Ferruh Yigit

ethdev layer introduced checks for application requested RSS hash functions and returns error for ones unsupported by hardware

This check breaks some sample applications which blindly configures RSS hash functions without checking underlying hardware support.

Updated examples to mask out unsupported RSS has functions during device configuration.
Prints a log if configuration values updated by this check.

Fixes aa1a6d87f15d ("ethdev: force RSS offload rules again")
Quoted 1 line

Applied to dpdk-next-net/master, thanks.