From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <xuemingl@mellanox.com>
Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])
 by dpdk.org (Postfix) with ESMTP id 3C27F7EE4
 for <dev@dpdk.org>; Thu, 19 Apr 2018 17:48:56 +0200 (CEST)
Received: from Internal Mail-Server by MTLPINE1 (envelope-from
 xuemingl@mellanox.com)
 with ESMTPS (AES256-SHA encrypted); 19 Apr 2018 18:50:15 +0300
Received: from dev-r630-06.mtbc.labs.mlnx (dev-r630-06.mtbc.labs.mlnx
 [10.12.205.180])
 by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w3JFmsoj004508;
 Thu, 19 Apr 2018 18:48:55 +0300
Received: from dev-r630-06.mtbc.labs.mlnx (localhost [127.0.0.1])
 by dev-r630-06.mtbc.labs.mlnx (8.14.7/8.14.7) with ESMTP id w3JFmrQL080062;
 Thu, 19 Apr 2018 23:48:53 +0800
Received: (from xuemingl@localhost)
 by dev-r630-06.mtbc.labs.mlnx (8.14.7/8.14.7/Submit) id w3JFmgVm080051;
 Thu, 19 Apr 2018 23:48:42 +0800
From: Xueming Li <xuemingl@mellanox.com>
To: Shahaf Shuler <shahafs@mellanox.com>,
 Nelio Laranjeiro <notifications@github.com>,
 Wenzhuo Lu <wenzhuo.lu@intel.com>, Jingjing Wu <jingjing.wu@intel.com>,
 Thomas Monjalon <thomas@monjalon.net>,
 Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: Xueming Li <xuemingl@mellanox.com>, dev@dpdk.org
Date: Thu, 19 Apr 2018 23:48:39 +0800
Message-Id: <20180419154840.80006-1-xuemingl@mellanox.com>
X-Mailer: git-send-email 2.13.3
In-Reply-To: <20180409121035.148813-1-xuemingl@mellanox.com>
References: <20180409121035.148813-1-xuemingl@mellanox.com>
Subject: [dpdk-dev] [PATCH v4 1/2] ethdev: add supported hash function check
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Thu, 19 Apr 2018 15:48:56 -0000

Add supported RSS hash function check in device configuration to
have better error verbosity for application developers.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 lib/librte_ether/rte_ethdev.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 3c049ef43..4ac0fadae 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1179,6 +1179,18 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 							ETHER_MAX_LEN;
 	}
 
+	/* Check that device supports requested rss hash functions. */
+	if ((dev_info.flow_type_rss_offloads |
+	     dev_conf->rx_adv_conf.rss_conf.rss_hf) !=
+	    dev_info.flow_type_rss_offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d invalid rss_hf: "
+				    "0x%"PRIx64", valid value: 0x%"PRIx64"\n",
+				    port_id,
+				    dev_conf->rx_adv_conf.rss_conf.rss_hf,
+				    dev_info.flow_type_rss_offloads);
+		return -EINVAL;
+	}
+
 	/*
 	 * Setup new number of RX/TX queues and reconfigure device.
 	 */
@@ -2835,9 +2847,20 @@ rte_eth_dev_rss_hash_update(uint16_t port_id,
 			    struct rte_eth_rss_conf *rss_conf)
 {
 	struct rte_eth_dev *dev;
+	struct rte_eth_dev_info dev_info = {0};
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
+	rte_eth_dev_info_get(port_id, &dev_info);
+	if ((dev_info.flow_type_rss_offloads | rss_conf->rss_hf) !=
+	    dev_info.flow_type_rss_offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d invalid rss_hf: "
+				    "0x%"PRIx64", valid value: 0x%"PRIx64"\n",
+				    port_id,
+				    rss_conf->rss_hf,
+				    dev_info.flow_type_rss_offloads);
+		return -EINVAL;
+	}
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_update, -ENOTSUP);
 	return eth_err(port_id, (*dev->dev_ops->rss_hash_update)(dev,
 								 rss_conf));
-- 
2.13.3