From: Ouyang Changchun <changchun.ouyang@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 1/3] ether: Add API to support administrative link up and down
Date: Thu, 22 May 2014 14:11:11 +0800 [thread overview]
Message-ID: <1400739073-32011-2-git-send-email-changchun.ouyang@intel.com> (raw)
In-Reply-To: <1400739073-32011-1-git-send-email-changchun.ouyang@intel.com>
This patch addes API to support administrative link up and down.
Signed-off-by: Ouyang Changchun <changchun.ouyang@intel.com>
---
lib/librte_ether/rte_ethdev.c | 38 ++++++++++++++++++++++++++++++++++++++
lib/librte_ether/rte_ethdev.h | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+)
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 0ddedfb..06a0896 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -796,6 +796,44 @@ rte_eth_dev_stop(uint8_t port_id)
(*dev->dev_ops->dev_stop)(dev);
}
+int
+rte_eth_dev_admin_link_up(uint8_t port_id)
+{
+ struct rte_eth_dev *dev;
+
+ /* This function is only safe when called from the primary process
+ * in a multi-process setup*/
+ PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
+
+ if (port_id >= nb_ports) {
+ PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+ return (-EINVAL);
+ }
+ dev = &rte_eth_devices[port_id];
+
+ FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_admin_link_up, -ENOTSUP);
+ return (*dev->dev_ops->dev_admin_link_up)(dev);
+}
+
+int
+rte_eth_dev_admin_link_down(uint8_t port_id)
+{
+ struct rte_eth_dev *dev;
+
+ /* This function is only safe when called from the primary process
+ * in a multi-process setup*/
+ PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
+
+ if (port_id >= nb_ports) {
+ PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+ return (-EINVAL);
+ }
+ dev = &rte_eth_devices[port_id];
+
+ FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_admin_link_down, -ENOTSUP);
+ return (*dev->dev_ops->dev_admin_link_down)(dev);
+}
+
void
rte_eth_dev_close(uint8_t port_id)
{
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 2be6e4f..d33ff93 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -891,6 +891,12 @@ typedef int (*eth_dev_start_t)(struct rte_eth_dev *dev);
typedef void (*eth_dev_stop_t)(struct rte_eth_dev *dev);
/**< @internal Function used to stop a configured Ethernet device. */
+typedef int (*eth_dev_admin_link_up_t)(struct rte_eth_dev *dev);
+/**< @internal Function used to link up a configured Ethernet device administratively. */
+
+typedef int (*eth_dev_admin_link_down_t)(struct rte_eth_dev *dev);
+/**< @internal Function used to link down a configured Ethernet device administratively. */
+
typedef void (*eth_dev_close_t)(struct rte_eth_dev *dev);
/**< @internal Function used to close a configured Ethernet device. */
@@ -1223,6 +1229,8 @@ struct eth_dev_ops {
eth_dev_configure_t dev_configure; /**< Configure device. */
eth_dev_start_t dev_start; /**< Start device. */
eth_dev_stop_t dev_stop; /**< Stop device. */
+ eth_dev_admin_link_up_t dev_admin_link_up; /**< Device link up administratively. */
+ eth_dev_admin_link_down_t dev_admin_link_down; /**< device link down admininstratively. */
eth_dev_close_t dev_close; /**< Close device. */
eth_promiscuous_enable_t promiscuous_enable; /**< Promiscuous ON. */
eth_promiscuous_disable_t promiscuous_disable;/**< Promiscuous OFF. */
@@ -1696,6 +1704,32 @@ extern int rte_eth_dev_start(uint8_t port_id);
*/
extern void rte_eth_dev_stop(uint8_t port_id);
+
+/**
+ * Link up an Ethernet device administratively.
+ *
+ * The administrative device link up will re-enable the device rx/tx functionality
+ * after it is previously administrative device linked down.
+ *
+ * @param port_id
+ * The port identifier of the Ethernet device.
+ * @return
+ * - 0: Success, Ethernet device linked up administratively.
+ * - <0: Error code of the driver device link up function.
+ */
+extern int rte_eth_dev_admin_link_up(uint8_t port_id);
+
+/**
+ * Link down an Ethernet device administratively.
+ * The device rx/tx functionality will be disabled if success,
+ * and it can be re-enabled with a call to
+ * rte_eth_dev_admin_link_up()
+ *
+ * @param port_id
+ * The port identifier of the Ethernet device.
+ */
+extern int rte_eth_dev_admin_link_down(uint8_t port_id);
+
/**
* Close an Ethernet device. The device cannot be restarted!
*
--
1.9.0
next prev parent reply other threads:[~2014-05-22 6:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-22 6:11 [dpdk-dev] [PATCH 0/3] Support administrative link up and link down Ouyang Changchun
2014-05-22 6:11 ` Ouyang Changchun [this message]
2014-05-22 6:11 ` [dpdk-dev] [PATCH 2/3] ixgbe: Implement the functionality of administrative link up and down in IXGBE PMD Ouyang Changchun
2014-05-22 6:11 ` [dpdk-dev] [PATCH 3/3] testpmd: Add commands to test administrative link up and down of PMD Ouyang Changchun
2014-05-22 13:17 ` [dpdk-dev] [PATCH 0/3] Support administrative link up and link down Ivan Boule
2014-05-22 14:44 ` Ouyang, Changchun
2014-05-22 15:31 ` Ivan Boule
2014-05-23 2:08 ` Ouyang, Changchun
2014-05-23 9:24 ` Ivan Boule
2014-05-28 1:42 ` Ouyang, Changchun
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=1400739073-32011-2-git-send-email-changchun.ouyang@intel.com \
--to=changchun.ouyang@intel.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).