From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id C34FD3F9 for ; Mon, 11 Jul 2016 08:21:35 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 10 Jul 2016 23:21:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,345,1464678000"; d="scan'208";a="992640245" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 10 Jul 2016 23:21:33 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id u6B6LWCQ012943; Mon, 11 Jul 2016 14:21:32 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id u6B6LSHU008098; Mon, 11 Jul 2016 14:21:30 +0800 Received: (from wenzhuol@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id u6B6LLEe008094; Mon, 11 Jul 2016 14:21:21 +0800 From: Wenzhuo Lu To: dev@dpdk.org Cc: thomas.monjalon@6wind.com, Wenzhuo Lu Date: Mon, 11 Jul 2016 14:21:19 +0800 Message-Id: <1468218079-8064-1-git-send-email-wenzhuo.lu@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dpdk-dev] [PATCH] lib/librte_ether: bypass code cleanup X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jul 2016 06:21:36 -0000 In testpmd code, device id is used directly to check if bypass is supported. But APP should not know the details of HW, the NIC specific info should not be exposed here. This patch adds a new rte API to check if bypass is supported. Signed-off-by: Wenzhuo Lu --- app/test-pmd/cmdline.c | 10 +--------- drivers/net/ixgbe/ixgbe_bypass.c | 9 +++++++++ drivers/net/ixgbe/ixgbe_bypass.h | 1 + drivers/net/ixgbe/ixgbe_ethdev.c | 1 + lib/librte_ether/rte_ethdev.c | 11 +++++++++++ lib/librte_ether/rte_ethdev.h | 16 +++++++++++++++- 6 files changed, 38 insertions(+), 10 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index b6b61ad..eb57329 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -10802,22 +10802,14 @@ cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue) } #ifdef RTE_NIC_BYPASS -#include uint8_t bypass_is_supported(portid_t port_id) { - struct rte_port *port; - struct rte_pci_id *pci_id; - if (port_id_is_invalid(port_id, ENABLED_WARN)) return 0; - /* Get the device id. */ - port = &ports[port_id]; - pci_id = &port->dev_info.pci_dev->id; - /* Check if NIC supports bypass. */ - if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) { + if (rte_eth_dev_bypass_supported(port_id)) { return 1; } else { diff --git a/drivers/net/ixgbe/ixgbe_bypass.c b/drivers/net/ixgbe/ixgbe_bypass.c index 7006928..6142083 100644 --- a/drivers/net/ixgbe/ixgbe_bypass.c +++ b/drivers/net/ixgbe/ixgbe_bypass.c @@ -412,3 +412,12 @@ ixgbe_bypass_wd_reset(struct rte_eth_dev *dev) return ret_val; } + +s32 +ixgbe_bypass_supported(struct rte_eth_dev *dev) +{ + if (dev->pci_dev->id.device_id == IXGBE_DEV_ID_82599_BYPASS) + return 0; + else + return -ENOTSUP; +} diff --git a/drivers/net/ixgbe/ixgbe_bypass.h b/drivers/net/ixgbe/ixgbe_bypass.h index 5f5c63e..787ae61 100644 --- a/drivers/net/ixgbe/ixgbe_bypass.h +++ b/drivers/net/ixgbe/ixgbe_bypass.h @@ -50,6 +50,7 @@ struct ixgbe_bypass_info { struct rte_eth_dev; +s32 ixgbe_bypass_supported(struct rte_eth_dev *dev); void ixgbe_bypass_init(struct rte_eth_dev *dev); s32 ixgbe_bypass_state_show(struct rte_eth_dev *dev, u32 *state); s32 ixgbe_bypass_state_store(struct rte_eth_dev *dev, u32 *new_state); diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index d478a15..7b7b4ee 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -518,6 +518,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = { .reta_update = ixgbe_dev_rss_reta_update, .reta_query = ixgbe_dev_rss_reta_query, #ifdef RTE_NIC_BYPASS + .bypass_supported = ixgbe_bypass_supported, .bypass_init = ixgbe_bypass_init, .bypass_state_set = ixgbe_bypass_state_store, .bypass_state_show = ixgbe_bypass_state_show, diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 0a6e3f1..c2e7ff0 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -2827,6 +2827,17 @@ rte_eth_dev_rx_intr_disable(uint8_t port_id, } #ifdef RTE_NIC_BYPASS +int rte_eth_dev_bypass_supported(uint8_t port_id) +{ + struct rte_eth_dev *dev; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + + dev = &rte_eth_devices[port_id]; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_supported, -ENOTSUP); + return (*dev->dev_ops->bypass_supported)(dev); +} + int rte_eth_dev_bypass_init(uint8_t port_id) { struct rte_eth_dev *dev; diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 4dac364..45a035a 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1390,6 +1390,7 @@ enum { ((x) == RTE_BYPASS_TMT_OFF || \ ((x) > RTE_BYPASS_TMT_OFF && (x) < RTE_BYPASS_TMT_NUM)) +typedef int32_t (*bypass_supported_t)(struct rte_eth_dev *dev); typedef void (*bypass_init_t)(struct rte_eth_dev *dev); typedef int32_t (*bypass_state_set_t)(struct rte_eth_dev *dev, uint32_t *new_state); typedef int32_t (*bypass_state_show_t)(struct rte_eth_dev *dev, uint32_t *state); @@ -1494,6 +1495,7 @@ struct eth_dev_ops { /**< Set eeprom */ /* bypass control */ #ifdef RTE_NIC_BYPASS + bypass_supported_t bypass_supported; bypass_init_t bypass_init; bypass_state_set_t bypass_state_set; bypass_state_show_t bypass_state_show; @@ -3576,8 +3578,20 @@ int rte_eth_set_vf_rate_limit(uint8_t port_id, uint16_t vf, uint16_t tx_rate, uint64_t q_msk); /** + * Check if the bypass functions is supported by a specific device. + * + * @param port + * The port identifier of the Ethernet device. + * @return + * - (0) if supported. + * - (-ENOTSUP) if hardware doesn't support. + * - (-EINVAL) if bad parameter. + */ +int rte_eth_dev_bypass_supported(uint8_t port); + +/** * Initialize bypass logic. This function needs to be called before - * executing any other bypass API. + * executing any other bypass API except rte_eth_dev_bypass_supported. * * @param port * The port identifier of the Ethernet device. -- 1.9.3