DPDK patches and discussions
 help / color / mirror / Atom feed
From: Hemant Agrawal <hemant.agrawal@nxp.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@intel.com>, <shreyansh.jain@nxp.com>
Subject: [dpdk-dev] [PATCH v3 15/20] net/dpaa2: add link status config support
Date: Mon, 22 May 2017 15:09:24 +0530	[thread overview]
Message-ID: <1495445969-29199-16-git-send-email-hemant.agrawal@nxp.com> (raw)
In-Reply-To: <1495445969-29199-1-git-send-email-hemant.agrawal@nxp.com>

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/net/dpaa2/dpaa2_ethdev.c | 118 +++++++++++++++++++++++++++++++++++++++
 drivers/net/dpaa2/dpaa2_ethdev.h |   2 +-
 drivers/net/dpaa2/dpaa2_rxtx.c   |  25 +++++++++
 3 files changed, 144 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 46532b2..fa9db17 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -55,6 +55,8 @@
 
 static struct rte_dpaa2_driver rte_dpaa2_pmd;
 static int dpaa2_dev_uninit(struct rte_eth_dev *eth_dev);
+static int dpaa2_dev_set_link_up(struct rte_eth_dev *dev);
+static int dpaa2_dev_set_link_down(struct rte_eth_dev *dev);
 
 /**
  * Atomically reads the link status information from global
@@ -530,6 +532,9 @@
 		return ret;
 	}
 
+	/* Power up the phy. Needed to make the link go Up */
+	dpaa2_dev_set_link_up(dev);
+
 	ret = dpni_get_qdid(dpni, CMD_PRI_LOW, priv->token,
 			    DPNI_QUEUE_TX, &qdid);
 	if (ret) {
@@ -613,6 +618,8 @@
 
 	PMD_INIT_FUNC_TRACE();
 
+	dpaa2_dev_set_link_down(dev);
+
 	ret = dpni_disable(dpni, CMD_PRI_LOW, priv->token);
 	if (ret) {
 		PMD_INIT_LOG(ERR, "Failure (ret %d) in disabling dpni %d dev\n",
@@ -632,6 +639,7 @@
 	struct dpaa2_dev_priv *priv = dev->data->dev_private;
 	struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
 	int i, ret;
+	struct rte_eth_link link;
 	struct dpaa2_queue *dpaa2_q;
 
 	PMD_INIT_FUNC_TRACE();
@@ -651,6 +659,9 @@
 			     " error code %d\n", ret);
 		return;
 	}
+
+	memset(&link, 0, sizeof(link));
+	dpaa2_dev_atomic_write_link_status(dev, &link);
 }
 
 static void
@@ -989,6 +1000,111 @@ void dpaa2_dev_stats_reset(struct rte_eth_dev *dev)
 	return 0;
 }
 
+/**
+ * Toggle the DPNI to enable, if not already enabled.
+ * This is not strictly PHY up/down - it is more of logical toggling.
+ */
+static int
+dpaa2_dev_set_link_up(struct rte_eth_dev *dev)
+{
+	int ret = -EINVAL;
+	struct dpaa2_dev_priv *priv;
+	struct fsl_mc_io *dpni;
+	int en = 0;
+
+	PMD_INIT_FUNC_TRACE();
+
+	priv = dev->data->dev_private;
+	dpni = (struct fsl_mc_io *)priv->hw;
+
+	if (dpni == NULL) {
+		RTE_LOG(ERR, PMD, "Device has not yet been configured");
+		return ret;
+	}
+
+	/* Check if DPNI is currently enabled */
+	ret = dpni_is_enabled(dpni, CMD_PRI_LOW, priv->token, &en);
+	if (ret) {
+		/* Unable to obtain dpni status; Not continuing */
+		PMD_DRV_LOG(ERR, "Interface Link UP failed (%d)", ret);
+		return -EINVAL;
+	}
+
+	/* Enable link if not already enabled */
+	if (!en) {
+		ret = dpni_enable(dpni, CMD_PRI_LOW, priv->token);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "Interface Link UP failed (%d)", ret);
+			return -EINVAL;
+		}
+	}
+	/* changing tx burst function to start enqueues */
+	dev->tx_pkt_burst = dpaa2_dev_tx;
+	dev->data->dev_link.link_status = 1;
+
+	PMD_DRV_LOG(INFO, "Port %d Link UP successful", dev->data->port_id);
+	return ret;
+}
+
+/**
+ * Toggle the DPNI to disable, if not already disabled.
+ * This is not strictly PHY up/down - it is more of logical toggling.
+ */
+static int
+dpaa2_dev_set_link_down(struct rte_eth_dev *dev)
+{
+	int ret = -EINVAL;
+	struct dpaa2_dev_priv *priv;
+	struct fsl_mc_io *dpni;
+	int dpni_enabled = 0;
+	int retries = 10;
+
+	PMD_INIT_FUNC_TRACE();
+
+	priv = dev->data->dev_private;
+	dpni = (struct fsl_mc_io *)priv->hw;
+
+	if (dpni == NULL) {
+		RTE_LOG(ERR, PMD, "Device has not yet been configured");
+		return ret;
+	}
+
+	/*changing  tx burst function to avoid any more enqueues */
+	dev->tx_pkt_burst = dummy_dev_tx;
+
+	/* Loop while dpni_disable() attempts to drain the egress FQs
+	 * and confirm them back to us.
+	 */
+	do {
+		ret = dpni_disable(dpni, 0, priv->token);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "dpni disable failed (%d)", ret);
+			return ret;
+		}
+		ret = dpni_is_enabled(dpni, 0, priv->token, &dpni_enabled);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "dpni_is_enabled failed (%d)", ret);
+			return ret;
+		}
+		if (dpni_enabled)
+			/* Allow the MC some slack */
+			rte_delay_us(100 * 1000);
+	} while (dpni_enabled && --retries);
+
+	if (!retries) {
+		PMD_DRV_LOG(WARNING, "Retry count exceeded disabling DPNI\n");
+		/* todo- we may have to manually cleanup queues.
+		 */
+	} else {
+		PMD_DRV_LOG(INFO, "Port %d Link DOWN successful",
+			    dev->data->port_id);
+	}
+
+	dev->data->dev_link.link_status = 0;
+
+	return ret;
+}
+
 static struct eth_dev_ops dpaa2_ethdev_ops = {
 	.dev_configure	  = dpaa2_eth_dev_configure,
 	.dev_start	      = dpaa2_dev_start,
@@ -998,6 +1114,8 @@ void dpaa2_dev_stats_reset(struct rte_eth_dev *dev)
 	.promiscuous_disable  = dpaa2_dev_promiscuous_disable,
 	.allmulticast_enable  = dpaa2_dev_allmulticast_enable,
 	.allmulticast_disable = dpaa2_dev_allmulticast_disable,
+	.dev_set_link_up      = dpaa2_dev_set_link_up,
+	.dev_set_link_down    = dpaa2_dev_set_link_down,
 	.link_update	   = dpaa2_dev_link_update,
 	.stats_get	       = dpaa2_dev_stats_get,
 	.stats_reset	   = dpaa2_dev_stats_reset,
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.h b/drivers/net/dpaa2/dpaa2_ethdev.h
index 3254b99..6b37c00 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.h
+++ b/drivers/net/dpaa2/dpaa2_ethdev.h
@@ -102,5 +102,5 @@ int dpaa2_remove_flow_dist(struct rte_eth_dev *eth_dev,
 uint16_t dpaa2_dev_prefetch_rx(void *queue, struct rte_mbuf **bufs,
 			       uint16_t nb_pkts);
 uint16_t dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts);
-
+uint16_t dummy_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts);
 #endif /* _DPAA2_ETHDEV_H */
diff --git a/drivers/net/dpaa2/dpaa2_rxtx.c b/drivers/net/dpaa2/dpaa2_rxtx.c
index d7e18ad..b2dfcce 100644
--- a/drivers/net/dpaa2/dpaa2_rxtx.c
+++ b/drivers/net/dpaa2/dpaa2_rxtx.c
@@ -458,3 +458,28 @@ static inline int __attribute__((hot))
 skip_tx:
 	return num_tx;
 }
+
+/**
+ * Dummy DPDK callback for TX.
+ *
+ * This function is used to temporarily replace the real callback during
+ * unsafe control operations on the queue, or in case of error.
+ *
+ * @param dpdk_txq
+ *   Generic pointer to TX queue structure.
+ * @param[in] pkts
+ *   Packets to transmit.
+ * @param pkts_n
+ *   Number of packets in array.
+ *
+ * @return
+ *   Number of packets successfully transmitted (<= pkts_n).
+ */
+uint16_t
+dummy_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
+{
+	(void)queue;
+	(void)bufs;
+	(void)nb_pkts;
+	return 0;
+}
-- 
1.9.1

  parent reply	other threads:[~2017-05-22  9:40 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-19 13:09 [dpdk-dev] [PATCH 1/4] net/dpaa2: stop using software annotation Hemant Agrawal
2017-04-19 13:09 ` [dpdk-dev] [PATCH 2/4] net/dpaa2: improve the error handling in dev init Hemant Agrawal
2017-05-12 13:51   ` Ferruh Yigit
2017-04-19 13:09 ` [dpdk-dev] [PATCH 3/4] bus/fslmc: support for multiple parallel dq requests Hemant Agrawal
2017-05-12 13:53   ` Ferruh Yigit
2017-04-19 13:09 ` [dpdk-dev] [PATCH 4/4] net/dpaa2: support parallel recv mode Hemant Agrawal
2017-05-12 13:48   ` Ferruh Yigit
2017-05-15  8:26     ` Hemant Agrawal
2017-05-15 12:37 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 PMD functional enhancements Hemant Agrawal
2017-05-15 12:37   ` [dpdk-dev] [PATCH v2 01/20] mk: change to cortex-a72 Hemant Agrawal
2017-05-15 16:49     ` Ferruh Yigit
2017-05-16 15:06       ` Hemant Agrawal
2017-05-15 12:37   ` [dpdk-dev] [PATCH v2 02/20] net/dpaa2: remove port level buffer layout definition Hemant Agrawal
2017-05-15 16:50     ` Ferruh Yigit
2017-05-15 12:37   ` [dpdk-dev] [PATCH v2 03/20] net/dpaa2: stop using software annotation Hemant Agrawal
2017-05-15 12:37   ` [dpdk-dev] [PATCH v2 04/20] net/dpaa2: improve the error handling in dev init Hemant Agrawal
2017-05-15 12:37   ` [dpdk-dev] [PATCH v2 05/20] bus/fslmc: support for parallel Rx DQ requests Hemant Agrawal
2017-05-15 12:37   ` [dpdk-dev] [PATCH v2 06/20] net/dpaa2: support parallel Rx mode Hemant Agrawal
2017-05-15 12:37   ` Hemant Agrawal
2017-05-15 12:37   ` [dpdk-dev] [PATCH v2 07/20] bus/fslmc: export qbman results in map file Hemant Agrawal
2017-05-15 16:55     ` Ferruh Yigit
2017-05-15 12:37   ` [dpdk-dev] [PATCH v2 08/20] net/dpaa2: add support for congestion notification Hemant Agrawal
2017-05-15 12:37   ` [dpdk-dev] [PATCH v2 09/20] net/dpaa2: add support for tail drop on queue Hemant Agrawal
2017-05-15 12:37   ` [dpdk-dev] [PATCH v2 10/20] bus/fslmc: update TAILQ usages in dpaa2 objects Hemant Agrawal
2017-05-15 12:37   ` [dpdk-dev] [PATCH v2 11/20] net/dpaa2: add support for MAC address filtering Hemant Agrawal
2017-05-15 12:37   ` [dpdk-dev] [PATCH v2 12/20] net/dpaa2: add support for multicast promiscuous mode Hemant Agrawal
2017-05-15 12:37   ` [dpdk-dev] [PATCH v2 13/20] net/dpaa2: add support for VLAN filter and offload Hemant Agrawal
2017-05-15 12:37   ` [dpdk-dev] [PATCH v2 14/20] net/dpaa2: add support for VLAN strip Hemant Agrawal
2017-05-15 12:37   ` [dpdk-dev] [PATCH v2 15/20] net/dpaa2: add link status config support Hemant Agrawal
2017-05-15 12:37   ` [dpdk-dev] [PATCH v2 16/20] net/dpaa2: add support for flow control Hemant Agrawal
2017-05-15 12:37   ` [dpdk-dev] [PATCH v2 17/20] net/dpaa2: configure jumbo frames Hemant Agrawal
2017-05-15 12:37   ` [dpdk-dev] [PATCH v2 18/20] bus/fslmc: add support to detect soc version Hemant Agrawal
2017-05-15 12:37   ` [dpdk-dev] [PATCH v2 19/20] net/dpaa2: add support for Firmware Version get Hemant Agrawal
2017-05-15 12:37   ` [dpdk-dev] [PATCH v2 20/20] bus/fslmc: reducing the debug log messages Hemant Agrawal
2017-05-22  9:39   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 PMD functional enhancements Hemant Agrawal
2017-05-22  9:39     ` [dpdk-dev] [PATCH v3 01/20] mk: change to cortex-a72 Hemant Agrawal
2017-05-22  9:39     ` [dpdk-dev] [PATCH v3 02/20] net/dpaa2: remove port level buffer layout definition Hemant Agrawal
2017-05-22  9:39     ` [dpdk-dev] [PATCH v3 03/20] net/dpaa2: stop using software annotation Hemant Agrawal
2017-05-22  9:39     ` [dpdk-dev] [PATCH v3 04/20] net/dpaa2: improve the error handling in dev init Hemant Agrawal
2017-05-22  9:39     ` [dpdk-dev] [PATCH v3 05/20] bus/fslmc: support for parallel Rx DQ requests Hemant Agrawal
2017-05-22  9:39     ` [dpdk-dev] [PATCH v3 06/20] net/dpaa2: support parallel Rx in eth pmd Hemant Agrawal
2017-05-22  9:39     ` [dpdk-dev] [PATCH v3 07/20] bus/fslmc: export qbman results in map file Hemant Agrawal
2017-05-22  9:39     ` [dpdk-dev] [PATCH v3 08/20] net/dpaa2: add support for congestion notification Hemant Agrawal
2017-05-24 11:45       ` Ferruh Yigit
2017-05-22  9:39     ` [dpdk-dev] [PATCH v3 09/20] net/dpaa2: add support for tail drop on queue Hemant Agrawal
2017-05-22  9:39     ` [dpdk-dev] [PATCH v3 10/20] bus/fslmc: update TAILQ usages in dpaa2 objects Hemant Agrawal
2017-05-22  9:39     ` [dpdk-dev] [PATCH v3 11/20] net/dpaa2: add support for MAC address filtering Hemant Agrawal
2017-05-22  9:39     ` [dpdk-dev] [PATCH v3 12/20] net/dpaa2: add support for multicast promiscuous mode Hemant Agrawal
2017-05-22  9:39     ` [dpdk-dev] [PATCH v3 13/20] net/dpaa2: add support for VLAN filter and offload Hemant Agrawal
2017-05-22  9:39     ` [dpdk-dev] [PATCH v3 14/20] net/dpaa2: add support for VLAN strip Hemant Agrawal
2017-05-22  9:39     ` Hemant Agrawal [this message]
2017-05-22  9:39     ` [dpdk-dev] [PATCH v3 16/20] net/dpaa2: add support for flow control Hemant Agrawal
2017-05-22  9:39     ` [dpdk-dev] [PATCH v3 17/20] net/dpaa2: configure jumbo frames Hemant Agrawal
2017-05-22  9:39     ` [dpdk-dev] [PATCH v3 18/20] bus/fslmc: add support to detect soc version Hemant Agrawal
2017-05-22  9:39     ` [dpdk-dev] [PATCH v3 19/20] net/dpaa2: add support for Firmware Version get Hemant Agrawal
2017-05-24 11:43       ` Ferruh Yigit
2017-05-22  9:39     ` [dpdk-dev] [PATCH v3 20/20] bus/fslmc: reducing the debug log messages Hemant Agrawal
2017-05-24 11:49     ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 PMD functional enhancements Ferruh Yigit
2017-05-26  7:51       ` Hemant Agrawal
2017-05-26  6:51     ` [dpdk-dev] [PATCH v4 " Hemant Agrawal
2017-05-26  6:51       ` [dpdk-dev] [PATCH v4 01/20] mk: change to cortex-a72 Hemant Agrawal
2017-05-26  6:51       ` [dpdk-dev] [PATCH v4 02/20] net/dpaa2: remove port level buffer layout definition Hemant Agrawal
2017-05-26  6:51       ` [dpdk-dev] [PATCH v4 03/20] net/dpaa2: stop using software annotation Hemant Agrawal
2017-05-26  6:51       ` [dpdk-dev] [PATCH v4 04/20] net/dpaa2: improve the error handling in dev init Hemant Agrawal
2017-05-26  6:51       ` [dpdk-dev] [PATCH v4 05/20] bus/fslmc: support for parallel Rx DQ requests Hemant Agrawal
2017-05-26  6:51       ` [dpdk-dev] [PATCH v4 06/20] net/dpaa2: support parallel Rx in eth pmd Hemant Agrawal
2017-05-26  6:51       ` [dpdk-dev] [PATCH v4 07/20] bus/fslmc: export qbman results in map file Hemant Agrawal
2017-05-26  6:51       ` [dpdk-dev] [PATCH v4 08/20] net/dpaa2: add support for congestion notification Hemant Agrawal
2017-05-26  6:51       ` [dpdk-dev] [PATCH v4 09/20] net/dpaa2: add support for tail drop on queue Hemant Agrawal
2017-05-26  6:51       ` [dpdk-dev] [PATCH v4 10/20] bus/fslmc: update TAILQ usages in dpaa2 objects Hemant Agrawal
2017-05-26  6:51       ` [dpdk-dev] [PATCH v4 11/20] net/dpaa2: add support for MAC address filtering Hemant Agrawal
2017-05-26  6:51       ` [dpdk-dev] [PATCH v4 12/20] net/dpaa2: add support for multicast promiscuous mode Hemant Agrawal
2017-05-26  6:51       ` [dpdk-dev] [PATCH v4 13/20] net/dpaa2: add support for VLAN filter and offload Hemant Agrawal
2017-05-26  6:51       ` [dpdk-dev] [PATCH v4 14/20] net/dpaa2: add support for VLAN strip Hemant Agrawal
2017-05-26  6:51       ` [dpdk-dev] [PATCH v4 15/20] net/dpaa2: add link status config support Hemant Agrawal
2017-05-26  6:51       ` [dpdk-dev] [PATCH v4 16/20] net/dpaa2: add support for flow control Hemant Agrawal
2017-05-26  6:51       ` [dpdk-dev] [PATCH v4 17/20] net/dpaa2: configure jumbo frames Hemant Agrawal
2017-05-26  6:51       ` [dpdk-dev] [PATCH v4 18/20] bus/fslmc: add support to detect soc version Hemant Agrawal
2017-05-26  8:51         ` Ferruh Yigit
2017-05-26  9:26         ` [dpdk-dev] [PATCH] bus/fslmc: fix license information Shreyansh Jain
2017-05-26  9:22           ` Ferruh Yigit
2017-05-26  6:51       ` [dpdk-dev] [PATCH v4 19/20] net/dpaa2: add support for Firmware Version get Hemant Agrawal
2017-05-26  6:51       ` [dpdk-dev] [PATCH v4 20/20] bus/fslmc: reducing the debug log messages Hemant Agrawal
2017-05-26  8:47       ` [dpdk-dev] [PATCH v4 00/20] NXP DPAA2 PMD functional enhancements Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1495445969-29199-16-git-send-email-hemant.agrawal@nxp.com \
    --to=hemant.agrawal@nxp.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=shreyansh.jain@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).