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 042A48D28 for ; Wed, 18 Apr 2018 13:06:55 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@mellanox.com) with ESMTPS (AES256-SHA encrypted); 18 Apr 2018 14:08:14 +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 w3IB6sN5017178; Wed, 18 Apr 2018 14:06: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 w3IB6rl3022930; Wed, 18 Apr 2018 19:06:53 +0800 Received: (from xuemingl@localhost) by dev-r630-06.mtbc.labs.mlnx (8.14.7/8.14.7/Submit) id w3IB6pEE022928; Wed, 18 Apr 2018 19:06:51 +0800 From: Xueming Li To: Shahaf Shuler , Nelio Laranjeiro , Wenzhuo Lu , Jingjing Wu , Thomas Monjalon Cc: Xueming Li , dev@dpdk.org Date: Wed, 18 Apr 2018 19:06:47 +0800 Message-Id: <20180418110648.22883-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 v3 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: Wed, 18 Apr 2018 11:06:56 -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 | 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