* [dpdk-dev] [PATCH v2 1/3] ether: Add API to support set link up and link down
2014-05-28 7:14 [dpdk-dev] [PATCH v2 0/3] Support setting link up and link down Ouyang Changchun
@ 2014-05-28 7:15 ` Ouyang Changchun
2014-05-28 7:15 ` [dpdk-dev] [PATCH v2 2/3] ixgbe: Implement the functionality of setting link up and down in IXGBE PMD Ouyang Changchun
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Ouyang Changchun @ 2014-05-28 7:15 UTC (permalink / raw)
To: dev
Please ignore previous v1 patch, just use this v2 patch.
This patch adds API to support the functionality of setting link up and down.
It can be used to repeatedly stop and restart RX/TX of a port without re-allocating
resources for the port and re-configuring the port.
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 a5727dd..97e3f9d 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -691,6 +691,44 @@ rte_eth_dev_stop(uint8_t port_id)
(*dev->dev_ops->dev_stop)(dev);
}
+int
+rte_eth_dev_set_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_set_link_up, -ENOTSUP);
+ return (*dev->dev_ops->dev_set_link_up)(dev);
+}
+
+int
+rte_eth_dev_set_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_set_link_down, -ENOTSUP);
+ return (*dev->dev_ops->dev_set_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 d5ea46b..84f2e9f 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -823,6 +823,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_set_link_up_t)(struct rte_eth_dev *dev);
+/**< @internal Function used to link up a configured Ethernet device. */
+
+typedef int (*eth_dev_set_link_down_t)(struct rte_eth_dev *dev);
+/**< @internal Function used to link down a configured Ethernet device. */
+
typedef void (*eth_dev_close_t)(struct rte_eth_dev *dev);
/**< @internal Function used to close a configured Ethernet device. */
@@ -1084,6 +1090,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_set_link_up_t dev_set_link_up; /**< Device link up. */
+ eth_dev_set_link_down_t dev_set_link_down; /**< Device link down. */
eth_dev_close_t dev_close; /**< Close device. */
eth_promiscuous_enable_t promiscuous_enable; /**< Promiscuous ON. */
eth_promiscuous_disable_t promiscuous_disable;/**< Promiscuous OFF. */
@@ -1475,6 +1483,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.
+ *
+ * Set device link up will re-enable the device rx/tx
+ * functionality after it is previously set device linked down.
+ *
+ * @param port_id
+ * The port identifier of the Ethernet device.
+ * @return
+ * - 0: Success, Ethernet device linked up.
+ * - <0: Error code of the driver device link up function.
+ */
+extern int rte_eth_dev_set_link_up(uint8_t port_id);
+
+/**
+ * Link down an Ethernet device.
+ * The device rx/tx functionality will be disabled if success,
+ * and it can be re-enabled with a call to
+ * rte_eth_dev_set_link_up()
+ *
+ * @param port_id
+ * The port identifier of the Ethernet device.
+ */
+extern int rte_eth_dev_set_link_down(uint8_t port_id);
+
/**
* Close an Ethernet device. The device cannot be restarted!
*
--
1.9.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [dpdk-dev] [PATCH v2 2/3] ixgbe: Implement the functionality of setting link up and down in IXGBE PMD
2014-05-28 7:14 [dpdk-dev] [PATCH v2 0/3] Support setting link up and link down Ouyang Changchun
2014-05-28 7:15 ` [dpdk-dev] [PATCH v2 1/3] ether: Add API to support set " Ouyang Changchun
@ 2014-05-28 7:15 ` Ouyang Changchun
2014-05-28 7:15 ` [dpdk-dev] [PATCH v2 3/3] testpmd: Add commands to test link up and down of PMD Ouyang Changchun
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Ouyang Changchun @ 2014-05-28 7:15 UTC (permalink / raw)
To: dev
Please ignore the previous v1 patch, just apply this v2 patch.
This patch implements the functionality of setting link up and down in IXGBE PMD.
It is implemented by enabling or disabling TX laser.
Signed-off-by: Ouyang Changchun <changchun.ouyang@intel.com>
---
lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 63 +++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
index c9b5fe4..8f9c97a 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
@@ -97,6 +97,8 @@ static int eth_ixgbe_dev_init(struct eth_driver *eth_drv,
static int ixgbe_dev_configure(struct rte_eth_dev *dev);
static int ixgbe_dev_start(struct rte_eth_dev *dev);
static void ixgbe_dev_stop(struct rte_eth_dev *dev);
+static int ixgbe_dev_set_link_up(struct rte_eth_dev *dev);
+static int ixgbe_dev_set_link_down(struct rte_eth_dev *dev);
static void ixgbe_dev_close(struct rte_eth_dev *dev);
static void ixgbe_dev_promiscuous_enable(struct rte_eth_dev *dev);
static void ixgbe_dev_promiscuous_disable(struct rte_eth_dev *dev);
@@ -246,6 +248,8 @@ static struct eth_dev_ops ixgbe_eth_dev_ops = {
.dev_configure = ixgbe_dev_configure,
.dev_start = ixgbe_dev_start,
.dev_stop = ixgbe_dev_stop,
+ .dev_set_link_up = ixgbe_dev_set_link_up,
+ .dev_set_link_down = ixgbe_dev_set_link_down,
.dev_close = ixgbe_dev_close,
.promiscuous_enable = ixgbe_dev_promiscuous_enable,
.promiscuous_disable = ixgbe_dev_promiscuous_disable,
@@ -1458,6 +1462,65 @@ ixgbe_dev_stop(struct rte_eth_dev *dev)
}
/*
+ * Set device link up: enable tx laser.
+ */
+static int
+ixgbe_dev_set_link_up(struct rte_eth_dev *dev)
+{
+ struct ixgbe_hw *hw =
+ IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ if (hw->mac.type == ixgbe_mac_82599EB) {
+#ifdef RTE_NIC_BYPASS
+ if (hw->device_id == IXGBE_DEV_ID_82599_BYPASS) {
+ /* Not suported in bypass mode */
+ PMD_INIT_LOG(ERR,
+ "\nSet link up is not supported "
+ "by device id 0x%x\n",
+ hw->device_id);
+ return -ENOTSUP;
+ }
+#endif
+ /* Turn on the laser */
+ ixgbe_enable_tx_laser(hw);
+ return 0;
+ }
+
+ PMD_INIT_LOG(ERR, "\nSet link up is not supported by device id 0x%x\n",
+ hw->device_id);
+ return -ENOTSUP;
+}
+
+/*
+ * Set device link down: disable tx laser.
+ */
+static int
+ixgbe_dev_set_link_down(struct rte_eth_dev *dev)
+{
+ struct ixgbe_hw *hw =
+ IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ if (hw->mac.type == ixgbe_mac_82599EB) {
+#ifdef RTE_NIC_BYPASS
+ if (hw->device_id == IXGBE_DEV_ID_82599_BYPASS) {
+ /* Not suported in bypass mode */
+ PMD_INIT_LOG(ERR,
+ "\nSet link down is not supported "
+ "by device id 0x%x\n",
+ hw->device_id);
+ return -ENOTSUP;
+ }
+#endif
+ /* Turn off the laser */
+ ixgbe_disable_tx_laser(hw);
+ return 0;
+ }
+
+ PMD_INIT_LOG(ERR,
+ "\nSet link down is not supported by device id 0x%x\n",
+ hw->device_id);
+ return -ENOTSUP;
+}
+
+/*
* Reest and stop device.
*/
static void
--
1.9.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [dpdk-dev] [PATCH v2 3/3] testpmd: Add commands to test link up and down of PMD
2014-05-28 7:14 [dpdk-dev] [PATCH v2 0/3] Support setting link up and link down Ouyang Changchun
2014-05-28 7:15 ` [dpdk-dev] [PATCH v2 1/3] ether: Add API to support set " Ouyang Changchun
2014-05-28 7:15 ` [dpdk-dev] [PATCH v2 2/3] ixgbe: Implement the functionality of setting link up and down in IXGBE PMD Ouyang Changchun
@ 2014-05-28 7:15 ` Ouyang Changchun
2014-05-28 12:10 ` [dpdk-dev] [PATCH v2 0/3] Support setting link up and link down Ivan Boule
2014-06-04 15:36 ` Cao, Waterman
4 siblings, 0 replies; 8+ messages in thread
From: Ouyang Changchun @ 2014-05-28 7:15 UTC (permalink / raw)
To: dev
Please ignore previous patch v1, and just apply this patch v2.
This patch adds commands to test the functionality of setting link up and down of PMD in testpmd.
Signed-off-by: Ouyang Changchun <changchun.ouyang@intel.com>
---
app/test-pmd/cmdline.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++
app/test-pmd/testpmd.c | 14 +++++++++
app/test-pmd/testpmd.h | 2 ++
3 files changed, 97 insertions(+)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index b3824f9..29bf5b5 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3780,6 +3780,85 @@ cmdline_parse_inst_t cmd_start_tx_first = {
},
};
+/* *** SET LINK UP *** */
+struct cmd_set_link_up_result {
+ cmdline_fixed_string_t set;
+ cmdline_fixed_string_t link_up;
+ cmdline_fixed_string_t port;
+ uint8_t port_id;
+};
+
+cmdline_parse_token_string_t cmd_set_link_up_set =
+ TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
+cmdline_parse_token_string_t cmd_set_link_up_link_up =
+ TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
+ "link-up");
+cmdline_parse_token_string_t cmd_set_link_up_port =
+ TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
+cmdline_parse_token_num_t cmd_set_link_up_port_id =
+ TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
+
+static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
+ __attribute__((unused)) struct cmdline *cl,
+ __attribute__((unused)) void *data)
+{
+ struct cmd_set_link_up_result *res = parsed_result;
+ dev_set_link_up(res->port_id);
+}
+
+cmdline_parse_inst_t cmd_set_link_up = {
+ .f = cmd_set_link_up_parsed,
+ .data = NULL,
+ .help_str = "set link-up port (port id)",
+ .tokens = {
+ (void *)&cmd_set_link_up_set,
+ (void *)&cmd_set_link_up_link_up,
+ (void *)&cmd_set_link_up_port,
+ (void *)&cmd_set_link_up_port_id,
+ NULL,
+ },
+};
+
+/* *** SET LINK DOWN *** */
+struct cmd_set_link_down_result {
+ cmdline_fixed_string_t set;
+ cmdline_fixed_string_t link_down;
+ cmdline_fixed_string_t port;
+ uint8_t port_id;
+};
+
+cmdline_parse_token_string_t cmd_set_link_down_set =
+ TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
+cmdline_parse_token_string_t cmd_set_link_down_link_down =
+ TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
+ "link-down");
+cmdline_parse_token_string_t cmd_set_link_down_port =
+ TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
+cmdline_parse_token_num_t cmd_set_link_down_port_id =
+ TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
+
+static void cmd_set_link_down_parsed(
+ __attribute__((unused)) void *parsed_result,
+ __attribute__((unused)) struct cmdline *cl,
+ __attribute__((unused)) void *data)
+{
+ struct cmd_set_link_down_result *res = parsed_result;
+ dev_set_link_down(res->port_id);
+}
+
+cmdline_parse_inst_t cmd_set_link_down = {
+ .f = cmd_set_link_down_parsed,
+ .data = NULL,
+ .help_str = "set link-down port (port id)",
+ .tokens = {
+ (void *)&cmd_set_link_down_set,
+ (void *)&cmd_set_link_down_link_down,
+ (void *)&cmd_set_link_down_port,
+ (void *)&cmd_set_link_down_port_id,
+ NULL,
+ },
+};
+
/* *** SHOW CFG *** */
struct cmd_showcfg_result {
cmdline_fixed_string_t show;
@@ -5164,6 +5243,8 @@ cmdline_parse_ctx_t main_ctx[] = {
(cmdline_parse_inst_t *)&cmd_showcfg,
(cmdline_parse_inst_t *)&cmd_start,
(cmdline_parse_inst_t *)&cmd_start_tx_first,
+ (cmdline_parse_inst_t *)&cmd_set_link_up,
+ (cmdline_parse_inst_t *)&cmd_set_link_down,
(cmdline_parse_inst_t *)&cmd_reset,
(cmdline_parse_inst_t *)&cmd_set_numbers,
(cmdline_parse_inst_t *)&cmd_set_txpkts,
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index bc38305..8f20fda 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1208,6 +1208,20 @@ stop_packet_forwarding(void)
test_done = 1;
}
+void
+dev_set_link_up(portid_t pid)
+{
+ if (rte_eth_dev_set_link_up((uint8_t)pid) < 0)
+ printf("\nSet link up fail.\n");
+}
+
+void
+dev_set_link_down(portid_t pid)
+{
+ if (rte_eth_dev_set_link_down((uint8_t)pid) < 0)
+ printf("\nSet link down fail.\n");
+}
+
static int
all_ports_started(void)
{
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 2bdb1a2..88a29e9 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -499,6 +499,8 @@ char *list_pkt_forwarding_modes(void);
void set_pkt_forwarding_mode(const char *fwd_mode);
void start_packet_forwarding(int with_tx_first);
void stop_packet_forwarding(void);
+void dev_set_link_up(portid_t pid);
+void dev_set_link_down(portid_t pid);
void init_port_config(void);
int init_port_dcb_config(portid_t pid,struct dcb_config *dcb_conf);
int start_port(portid_t pid);
--
1.9.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-dev] [PATCH v2 0/3] Support setting link up and link down
2014-05-28 7:14 [dpdk-dev] [PATCH v2 0/3] Support setting link up and link down Ouyang Changchun
` (2 preceding siblings ...)
2014-05-28 7:15 ` [dpdk-dev] [PATCH v2 3/3] testpmd: Add commands to test link up and down of PMD Ouyang Changchun
@ 2014-05-28 12:10 ` Ivan Boule
2014-06-11 10:09 ` Thomas Monjalon
2014-06-04 15:36 ` Cao, Waterman
4 siblings, 1 reply; 8+ messages in thread
From: Ivan Boule @ 2014-05-28 12:10 UTC (permalink / raw)
To: Ouyang Changchun, dev
On 05/28/2014 09:14 AM, Ouyang Changchun wrote:
> Please ignore the previous patch series with subject: "Support administrative link up and link down"
> This v2 patch series will replace the previous patch series.
>
> This patch series contain the following 3 items:
> 1. Add API to support setting link up and down, it can be used to repeatedly stop and restart
> RX/TX of a port without re-allocating resources for the port and re-configuring the port.
> 2. Implement the functionality of setting link up and down in IXGBE PMD.
> 3. Add command in testpmd to test the functionality of setting link up and down of PMD.
>
> Ouyang Changchun (3):
> Add API to support set link up and link down.
> Implement the functionality of setting link up and link down in IXGBE
> PMD.
> Add command line to test the functionality of setting link up and link
> down in testpmd.
>
Acked by: Ivan Boule <Ivan.Boule@6wind.com>
--
Ivan Boule
6WIND Development Engineer
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-dev] [PATCH v2 0/3] Support setting link up and link down
2014-05-28 12:10 ` [dpdk-dev] [PATCH v2 0/3] Support setting link up and link down Ivan Boule
@ 2014-06-11 10:09 ` Thomas Monjalon
0 siblings, 0 replies; 8+ messages in thread
From: Thomas Monjalon @ 2014-06-11 10:09 UTC (permalink / raw)
To: Ouyang Changchun; +Cc: dev
> > This patch series contain the following 3 items:
> > 1. Add API to support setting link up and down, it can be used to repeatedly stop and restart
> > RX/TX of a port without re-allocating resources for the port and re-configuring the port.
> > 2. Implement the functionality of setting link up and down in IXGBE PMD.
> > 3. Add command in testpmd to test the functionality of setting link up and down of PMD.
>
> Acked by: Ivan Boule <Ivan.Boule@6wind.com>
Applied for version 1.7.0.
Thanks
--
Thomas
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-dev] [PATCH v2 0/3] Support setting link up and link down
2014-05-28 7:14 [dpdk-dev] [PATCH v2 0/3] Support setting link up and link down Ouyang Changchun
` (3 preceding siblings ...)
2014-05-28 12:10 ` [dpdk-dev] [PATCH v2 0/3] Support setting link up and link down Ivan Boule
@ 2014-06-04 15:36 ` Cao, Waterman
2014-06-09 16:25 ` Thomas Monjalon
4 siblings, 1 reply; 8+ messages in thread
From: Cao, Waterman @ 2014-06-04 15:36 UTC (permalink / raw)
To: Ouyang, Changchun, dev, Thomas Monjalon
Tested-by: Waterman Cao <waterman.cao at intel.com>
This patch is used to fix bug, and has been tested by Intel.
We verified API by testpmd, it passed.
Please see test steps as the following:
1. In the host machine, set the DPDK environment as usual and start testpmd:
./app/test-pmd/testpmd -c f -n 4 -- -i
2. Start packet forwarding on both ports.
3. In the tester/traffic generator, send the packet with destine MAC to any port on host.
4. Then launch testpmd on host, use the following command to set link up/down to the port:
testpmd> set link-up port 0(or 1)
testpmd> set link-down port 0(or 1)
5. Then check port status
See test environment information as the following:
Fedora 20 x86_64, Linux Kernel 3.13.9-200, GCC 4.8.2
Intel Xeon CPU E5-2680 v2 @ 2.80GHz
NIC: Intel Niantic 82599, Intel i350, Intel 82580 and Intel 82576
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-dev] [PATCH v2 0/3] Support setting link up and link down
2014-06-04 15:36 ` Cao, Waterman
@ 2014-06-09 16:25 ` Thomas Monjalon
0 siblings, 0 replies; 8+ messages in thread
From: Thomas Monjalon @ 2014-06-09 16:25 UTC (permalink / raw)
To: Cao, Waterman; +Cc: dev
2014-06-04 15:36, Cao, Waterman:
> Tested-by: Waterman Cao <waterman.cao at intel.com>
>
> This patch is used to fix bug, and has been tested by Intel.
> We verified API by testpmd, it passed.
> Please see test steps as the following:
> 1. In the host machine, set the DPDK environment as usual and start testpmd:
> ./app/test-pmd/testpmd -c f -n 4 -- -i
> 2. Start packet forwarding on both ports.
> 3. In the tester/traffic generator, send the packet with destine MAC to any
> port on host.
> 4. Then launch testpmd on host, use the following command to
> set link up/down to the port:
> testpmd> set link-up port 0(or 1)
> testpmd> set link-down port 0(or 1)
> 5. Then check port status
>
> See test environment information as the following:
> Fedora 20 x86_64, Linux Kernel 3.13.9-200, GCC 4.8.2
> Intel Xeon CPU E5-2680 v2 @ 2.80GHz
> NIC: Intel Niantic 82599, Intel i350, Intel 82580 and Intel 82576
Excellent test report!
Thank you
--
Thomas
^ permalink raw reply [flat|nested] 8+ messages in thread