From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 7D3D67EE4 for ; Tue, 17 Apr 2018 16:24:39 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@mellanox.com) with ESMTPS (AES256-SHA encrypted); 17 Apr 2018 17:25:56 +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 w3HEObNi032509; Tue, 17 Apr 2018 17:24:38 +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 w3HEOakh159425; Tue, 17 Apr 2018 22:24:36 +0800 Received: (from xuemingl@localhost) by dev-r630-06.mtbc.labs.mlnx (8.14.7/8.14.7/Submit) id w3HEOTwP159423; Tue, 17 Apr 2018 22:24:29 +0800 From: Xueming Li To: Shahaf Shuler , Nelio Laranjeiro , Wenzhuo Lu , Jingjing Wu , Thomas Monjalon Cc: Xueming Li , dev@dpdk.org Date: Tue, 17 Apr 2018 22:24:24 +0800 Message-Id: <20180417142425.159378-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 v2 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: , X-List-Received-Date: Tue, 17 Apr 2018 14:24:39 -0000 Add supported RSS hash function check in device configuration to have better error verbosity for application developers. Signed-off-by: Xueming Li --- lib/librte_ether/rte_ethdev.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 209796d46..a8e122781 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -1179,6 +1179,17 @@ 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%lx, valid value: 0x%lx\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. */ @@ -2832,9 +2843,19 @@ 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%lx, valid value: 0x%lx\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