DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] lib/librte_ether: bypass code cleanup
@ 2016-07-11  6:21 Wenzhuo Lu
  2016-07-11  7:11 ` Thomas Monjalon
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Wenzhuo Lu @ 2016-07-11  6:21 UTC (permalink / raw)
  To: dev; +Cc: thomas.monjalon, Wenzhuo Lu

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 <wenzhuo.lu@intel.com>
---
 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 <rte_pci_dev_ids.h>
 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-07-11 13:18 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-11  6:21 [dpdk-dev] [PATCH] lib/librte_ether: bypass code cleanup Wenzhuo Lu
2016-07-11  7:11 ` Thomas Monjalon
2016-07-11  8:09   ` Lu, Wenzhuo
2016-07-11  8:18   ` Ananyev, Konstantin
2016-07-11  9:19     ` Thomas Monjalon
2016-07-11  9:56       ` Ananyev, Konstantin
2016-07-11 10:19         ` [dpdk-dev] specific driver API - was " Thomas Monjalon
2016-07-11 10:39           ` Ananyev, Konstantin
2016-07-11  7:50 ` [dpdk-dev] [PATCH] lib/librte_ether: " Wu, Jingjing
2016-07-11  8:09   ` Lu, Wenzhuo
2016-07-11  8:29 ` [dpdk-dev] [PATCH v2] app/testpmd: " Wenzhuo Lu
2016-07-11 13:18   ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).