From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v2 1/5] mlx5: add callbacks to support link (up / down) changes
Date: Thu, 3 Mar 2016 15:27:55 +0100 [thread overview]
Message-ID: <1457015279-3089-2-git-send-email-adrien.mazarguil@6wind.com> (raw)
In-Reply-To: <1457015279-3089-1-git-send-email-adrien.mazarguil@6wind.com>
From: Or Ami <ora@mellanox.com>
Burst functions are updated to make sure applications cannot attempt to
send/receive after link is brought down.
Signed-off-by: Or Ami <ora@mellanox.com>
---
doc/guides/rel_notes/release_16_04.rst | 4 ++
drivers/net/mlx5/mlx5.c | 2 +
drivers/net/mlx5/mlx5.h | 2 +
drivers/net/mlx5/mlx5_ethdev.c | 85 ++++++++++++++++++++++++++++++++++
4 files changed, 93 insertions(+)
diff --git a/doc/guides/rel_notes/release_16_04.rst b/doc/guides/rel_notes/release_16_04.rst
index 8669515..5e43d50 100644
--- a/doc/guides/rel_notes/release_16_04.rst
+++ b/doc/guides/rel_notes/release_16_04.rst
@@ -87,6 +87,10 @@ This section should contain new features added in this release. Sample format:
Only available with Mellanox OFED >= 3.2.
+* **mlx5: Added link up/down callbacks.**
+
+ Implemented callbacks to bring link up and down.
+
Resolved Issues
---------------
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index ad69ec2..14ac4ba 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -148,6 +148,8 @@ static const struct eth_dev_ops mlx5_dev_ops = {
.dev_configure = mlx5_dev_configure,
.dev_start = mlx5_dev_start,
.dev_stop = mlx5_dev_stop,
+ .dev_set_link_down = mlx5_set_link_down,
+ .dev_set_link_up = mlx5_set_link_up,
.dev_close = mlx5_dev_close,
.promiscuous_enable = mlx5_promiscuous_enable,
.promiscuous_disable = mlx5_promiscuous_disable,
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 43b24fb..9a3f240 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -168,6 +168,8 @@ void mlx5_dev_link_status_handler(void *);
void mlx5_dev_interrupt_handler(struct rte_intr_handle *, void *);
void priv_dev_interrupt_handler_uninstall(struct priv *, struct rte_eth_dev *);
void priv_dev_interrupt_handler_install(struct priv *, struct rte_eth_dev *);
+int mlx5_set_link_down(struct rte_eth_dev *dev);
+int mlx5_set_link_up(struct rte_eth_dev *dev);
/* mlx5_mac.c */
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 6704382..f609e0f 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -968,3 +968,88 @@ priv_dev_interrupt_handler_install(struct priv *priv, struct rte_eth_dev *dev)
dev);
}
}
+
+/**
+ * Change the link state (UP / DOWN).
+ *
+ * @param dev
+ * Pointer to Ethernet device structure.
+ * @param up
+ * Nonzero for link up, otherwise link down.
+ *
+ * @return
+ * 0 on success, errno value on failure.
+ */
+static int
+priv_set_link(struct priv *priv, int up)
+{
+ struct rte_eth_dev *dev = priv->dev;
+ int err;
+ unsigned int i;
+
+ if (up) {
+ err = priv_set_flags(priv, ~IFF_UP, IFF_UP);
+ if (err)
+ return err;
+ for (i = 0; i < priv->rxqs_n; i++)
+ if ((*priv->rxqs)[i]->sp)
+ break;
+ /* Check if an sp queue exists.
+ * Note: Some old frames might be received.
+ */
+ if (i == priv->rxqs_n)
+ dev->rx_pkt_burst = mlx5_rx_burst;
+ else
+ dev->rx_pkt_burst = mlx5_rx_burst_sp;
+ dev->tx_pkt_burst = mlx5_tx_burst;
+ } else {
+ err = priv_set_flags(priv, ~IFF_UP, ~IFF_UP);
+ if (err)
+ return err;
+ dev->rx_pkt_burst = removed_rx_burst;
+ dev->tx_pkt_burst = removed_tx_burst;
+ }
+ return 0;
+}
+
+/**
+ * DPDK callback to bring the link DOWN.
+ *
+ * @param dev
+ * Pointer to Ethernet device structure.
+ *
+ * @return
+ * 0 on success, errno value on failure.
+ */
+int
+mlx5_set_link_down(struct rte_eth_dev *dev)
+{
+ struct priv *priv = dev->data->dev_private;
+ int err;
+
+ priv_lock(priv);
+ err = priv_set_link(priv, 0);
+ priv_unlock(priv);
+ return err;
+}
+
+/**
+ * DPDK callback to bring the link UP.
+ *
+ * @param dev
+ * Pointer to Ethernet device structure.
+ *
+ * @return
+ * 0 on success, errno value on failure.
+ */
+int
+mlx5_set_link_up(struct rte_eth_dev *dev)
+{
+ struct priv *priv = dev->data->dev_private;
+ int err;
+
+ priv_lock(priv);
+ err = priv_set_link(priv, 1);
+ priv_unlock(priv);
+ return err;
+}
--
2.1.4
next prev parent reply other threads:[~2016-03-03 14:28 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-22 18:19 [dpdk-dev] [PATCH 0/4] Implement missing features in mlx5 Adrien Mazarguil
2016-02-22 18:19 ` [dpdk-dev] [PATCH 1/4] mlx5: add callbacks to support link (up / down) changes Adrien Mazarguil
2016-02-22 18:19 ` [dpdk-dev] [PATCH 2/4] mlx5: allow operation in secondary processes Adrien Mazarguil
2016-02-22 18:19 ` [dpdk-dev] [PATCH 3/4] mlx5: add support for HW packet padding Adrien Mazarguil
2016-02-22 18:19 ` [dpdk-dev] [PATCH 4/4] mlx5: add VLAN insertion offload Adrien Mazarguil
2016-03-03 14:27 ` [dpdk-dev] [PATCH v2 0/5] Implement missing features in mlx5 Adrien Mazarguil
2016-03-03 14:27 ` Adrien Mazarguil [this message]
2016-03-03 14:27 ` [dpdk-dev] [PATCH v2 2/5] mlx5: allow operation in secondary processes Adrien Mazarguil
2016-03-03 14:27 ` [dpdk-dev] [PATCH v2 3/5] mlx5: add RX CRC stripping configuration Adrien Mazarguil
2016-03-03 14:27 ` [dpdk-dev] [PATCH v2 4/5] mlx5: add support for HW packet padding Adrien Mazarguil
2016-03-03 14:27 ` [dpdk-dev] [PATCH v2 5/5] mlx5: add VLAN insertion offload Adrien Mazarguil
2016-03-11 15:24 ` Bruce Richardson
2016-03-16 13:45 ` Adrien Mazarguil
2016-03-17 15:38 ` [dpdk-dev] [PATCH v3 0/5] Implement missing features in mlx5 Adrien Mazarguil
2016-03-17 15:38 ` [dpdk-dev] [PATCH v3 1/5] mlx5: add callbacks to support link (up / down) changes Adrien Mazarguil
2016-03-17 15:38 ` [dpdk-dev] [PATCH v3 2/5] mlx5: allow operation in secondary processes Adrien Mazarguil
2016-03-17 15:38 ` [dpdk-dev] [PATCH v3 3/5] mlx5: add RX CRC stripping configuration Adrien Mazarguil
2016-03-17 15:38 ` [dpdk-dev] [PATCH v3 4/5] mlx5: add support for HW packet padding Adrien Mazarguil
2016-03-17 15:38 ` [dpdk-dev] [PATCH v3 5/5] mlx5: add VLAN insertion offload Adrien Mazarguil
2016-03-22 16:35 ` [dpdk-dev] [PATCH v3 0/5] Implement missing features in mlx5 Bruce Richardson
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=1457015279-3089-2-git-send-email-adrien.mazarguil@6wind.com \
--to=adrien.mazarguil@6wind.com \
--cc=dev@dpdk.org \
/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).