From patchwork Thu Apr 19 15:48:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 38562 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E8F638E58; Thu, 19 Apr 2018 17:48:57 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 3C27F7EE4 for ; 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 To: Shahaf Shuler , Nelio Laranjeiro , Wenzhuo Lu , Jingjing Wu , Thomas Monjalon , Adrien Mazarguil Cc: Xueming Li , 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add supported RSS hash function check in device configuration to have better error verbosity for application developers. Signed-off-by: Xueming Li Acked-by: Adrien Mazarguil --- 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));