Skip to contentSkip to conversation

bonding PCI Port Hotplug

PATCH In review Bernard Iremonger 2 participants 8 messages Jul 27, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v7 cover bonding PCI Port Hotplug

Changes in V7:
Rebase.
Move call of bond_ethdev_free_queues() from bond_ethdev_stop() to bond_ethdev_close().
Add patch 4, doc patch for testpmd_app_ug, adds bonding example.

Changes in V6:
Rebase.
add rte_eth_bond_free() to rte_eth_bond_version.map

Changes in V5:
Rebase.
Refactor initialisation of static structures.

Changes in V4:
Rebase to latest code.
Move freeing of queue memory from uninit() function to close() function.

Changes in V3:
Rebase to latest code.
Modified testpmd to handle attach/detach of bonding pmd.

Changes in V2:
Rebased to use drivers/net/bonding dirctory
Free rx and tx queues in uninit() function.

Bernard Iremonger (4):
bonding: add support for PCI Port Hotplug
test-pmd: modified testpmd for link_bonding
bonding: free queue memory in close function
testpmd_app_ug: add example of re-attaching bonded port

 app/test-pmd/cmdline.c                       |  4 +-
 app/test-pmd/testpmd.c                       | 22 +++++++-
 app/test-pmd/testpmd.h                       |  7 ++-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst  | 13 +++++
 drivers/net/bonding/rte_eth_bond.h           | 13 ++++-
 drivers/net/bonding/rte_eth_bond_api.c       | 80 ++++++++++++++++++----------
 drivers/net/bonding/rte_eth_bond_pmd.c       | 44 +++++++++++++--
 drivers/net/bonding/rte_eth_bond_private.h   | 10 +++-
 drivers/net/bonding/rte_eth_bond_version.map |  1 +
 9 files changed, 156 insertions(+), 38 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH v7 1/4 bonding: add support for PCI Port Hotplug

This patch depends on the Port Hotplug Framework.
It implements the rte_dev_uninit_t() function for the link bonding pmd.

---
 drivers/net/bonding/rte_eth_bond.h           | 13 ++++-
 drivers/net/bonding/rte_eth_bond_api.c       | 80 ++++++++++++++++++----------
 drivers/net/bonding/rte_eth_bond_pmd.c       | 25 +++++++--
 drivers/net/bonding/rte_eth_bond_private.h   | 10 +++-
 drivers/net/bonding/rte_eth_bond_version.map |  1 +
 5 files changed, 96 insertions(+), 33 deletions(-)
drivers/net/bonding/rte_eth_bond.h +12 -1
index d688fc3..8efbf07 100644
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -131,6 +131,17 @@ int
 rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id);
 
 /**
+ * Free a bonded rte_eth_dev device
+ *
+ * @param name			Name of the link bonding device.
+ *
+ * @return
+ *	0 on success, negative value otherwise
+ */
+int
+rte_eth_bond_free(const char *name);
+
+/**
  * Add a rte_eth_dev device as a slave to the bonded device
  *
  * @param bonded_port_id	Port ID of bonded device.
drivers/net/bonding/rte_eth_bond_api.c +53 -27

122 lines not on this page · raw message

drivers/net/bonding/rte_eth_bond_pmd.c +22 -3
index 9cafe65..e1a9e7b 100644
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -1512,7 +1512,7 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
-static void
+void
 bond_ethdev_stop(struct rte_eth_dev *eth_dev)
 {
 	struct bond_dev_private *internals = eth_dev->data->dev_private;
@@ -1552,7 +1552,7 @@ bond_ethdev_stop(struct rte_eth_dev *eth_dev)
 	eth_dev->data->dev_started = 0;
 }
 
-static void
+void
 bond_ethdev_close(struct rte_eth_dev *dev __rte_unused)
 {
 }
@@ -2042,6 +2042,24 @@ parse_error:
 	return -1;
 }
 
+static int
+bond_uninit(const char *name)
+{
+	int  ret;
+
+	if (name == NULL)
+		return -EINVAL;
+
+	RTE_LOG(INFO, EAL, "Uninitializing pmd_bond for %s\n", name);
+
+	/* free link bonding eth device */
+	ret = rte_eth_bond_free(name);
+	if (ret < 0)
+		RTE_LOG(ERR, EAL, "Failed to free %s\n", name);
+
+	return ret;
+}
+
 /* this part will resolve the slave portids after all the other pdev and vdev
  * have been allocated */
 static int
@@ -2268,6 +2286,7 @@ static struct rte_driver bond_drv = {
 	.name = "eth_bond",
 	.type = PMD_VDEV,
 	.init = bond_init,
+	.uninit = bond_uninit,
 };
 
 PMD_REGISTER_DRIVER(bond_drv);
drivers/net/bonding/rte_eth_bond_private.h +8 -2
index c531e87..9f57f4d 100644
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -62,7 +62,7 @@
 
 extern const char *pmd_bond_init_valid_arguments[];
 
-extern const char *pmd_bond_driver_name;
+extern const char pmd_bond_driver_name[];
 
 /** Port Queue Mapping Structure */
 struct bond_rx_queue {
@@ -284,4 +284,10 @@ bond_tlb_enable(struct bond_dev_private *internals);
 void
 bond_tlb_activate_slave(struct bond_dev_private *internals);
 
+void
+bond_ethdev_stop(struct rte_eth_dev *eth_dev);
+
+void
+bond_ethdev_close(struct rte_eth_dev *dev __rte_unused);
+
 #endif
drivers/net/bonding/rte_eth_bond_version.map +1 -0
index 135999e..5519e11 100644
@@ -5,6 +5,7 @@ DPDK_2.0 {
 	rte_eth_bond_8023ad_setup;
 	rte_eth_bond_active_slaves_get;
 	rte_eth_bond_create;
+	rte_eth_bond_free;
 	rte_eth_bond_link_monitoring_set;
 	rte_eth_bond_mac_address_reset;
 	rte_eth_bond_mac_address_set;
Signature · 1 line
1.9.1
#3 lore raw

PATCH v7 2/4 test-pmd: modified testpmd for link_bonding

In reply to Bernard Iremonger

When the bonded port is started it also starts the slave port, but the slave port status is not set. A slave_flag has been added to struct rte_port to resolve this issue.

---
 app/test-pmd/cmdline.c |  4 +++-
 app/test-pmd/testpmd.c | 22 ++++++++++++++++++++--
 app/test-pmd/testpmd.h |  7 +++++--
 3 files changed, 28 insertions(+), 5 deletions(-)
app/test-pmd/cmdline.c +3 -1
index 8ab4687..5e24319 100644
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
  *   Copyright(c) 2014 6WIND S.A.
  *   All rights reserved.
  *
@@ -4019,6 +4019,7 @@ static void cmd_add_bonding_slave_parsed(void *parsed_result,
 		return;
 	}
 	init_port_config();
+	set_port_slave_flag(slave_port_id);
 }
 
 cmdline_parse_token_string_t cmd_addbonding_slave_add =
@@ -4075,6 +4076,7 @@ static void cmd_remove_bonding_slave_parsed(void *parsed_result,
 		return;
 	}
 	init_port_config();
+	clear_port_slave_flag(slave_port_id);
 }
 
 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
app/test-pmd/testpmd.c +20 -2
index 4769533..4bcece6 100644
@@ -1202,7 +1202,8 @@ all_ports_started(void)
 	FOREACH_PORT(pi, ports) {
 		port = &ports[pi];
 		/* Check if there is a port which is not started */
-		if (port->port_status != RTE_PORT_STARTED)
+		if ((port->port_status != RTE_PORT_STARTED) &&
+			(port->slave_flag == 0))
 			return 0;
 	}
 
@@ -1218,7 +1219,8 @@ all_ports_stopped(void)
 
 	FOREACH_PORT(pi, ports) {
 		port = &ports[pi];
-		if (port->port_status != RTE_PORT_STOPPED)
+		if ((port->port_status != RTE_PORT_STOPPED) &&
+			(port->slave_flag == 0))
 			return 0;
 	}
 
@@ -1808,6 +1810,22 @@ init_port_config(void)
 	}
 }
 
+void set_port_slave_flag(portid_t slave_pid)
+{
+	struct rte_port *port;
+
+	port = &ports[slave_pid];
+	port->slave_flag = 1;
+}
+
+void clear_port_slave_flag(portid_t slave_pid)
+{
+	struct rte_port *port;
+
+	port = &ports[slave_pid];
+	port->slave_flag = 0;
+}
+
 const uint16_t vlan_tags[] = {
 		0,  1,  2,  3,  4,  5,  6,  7,
 		8,  9, 10, 11,  12, 13, 14, 15,
app/test-pmd/testpmd.h +5 -2
index e91e077..8b2219a 100644
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -162,11 +162,12 @@ struct rte_port {
 	uint8_t                 need_reconfig;  /**< need reconfiguring port or not */
 	uint8_t                 need_reconfig_queues; /**< need reconfiguring queues or not */
 	uint8_t                 rss_flag;   /**< enable rss or not */
-	uint8_t			dcb_flag;   /**< enable dcb */
+	uint8_t			        dcb_flag;   /**< enable dcb */
 	struct rte_eth_rxconf   rx_conf;    /**< rx configuration */
 	struct rte_eth_txconf   tx_conf;    /**< tx configuration */
 	struct ether_addr       *mc_addr_pool; /**< pool of multicast addrs */
 	uint32_t                mc_addr_nb; /**< nb. of addr. in mc_addr_pool */
+	uint8_t                 slave_flag; /**< bonding slave port */
 };
 
 extern portid_t __rte_unused
@@ -534,6 +535,8 @@ 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);
+void set_port_slave_flag(portid_t slave_pid);
+void clear_port_slave_flag(portid_t slave_pid);
 int init_port_dcb_config(portid_t pid,struct dcb_config *dcb_conf);
 int start_port(portid_t pid);
 void stop_port(portid_t pid);
Signature · 1 line
1.9.1
#5 lore raw

PATCH v7 3/4 bonding: free queue memory in close function

In reply to Bernard Iremonger

add function bond_ethdev_free_queues() and call from the bond_ethdev_close() function.

---
 drivers/net/bonding/rte_eth_bond_pmd.c     | 21 ++++++++++++++++++++-
 drivers/net/bonding/rte_eth_bond_private.h |  2 +-
 2 files changed, 21 insertions(+), 2 deletions(-)
drivers/net/bonding/rte_eth_bond_pmd.c +20 -1
index e1a9e7b..5cc6372 100644
@@ -1512,6 +1512,24 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static void
+bond_ethdev_free_queues(struct rte_eth_dev *dev)
+{
+	uint8_t i;
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		rte_free(dev->data->rx_queues[i]);
+		dev->data->rx_queues[i] = NULL;
+	}
+	dev->data->nb_rx_queues = 0;
+
+	for (i = 0; i < dev->data->nb_tx_queues; i++) {
+		rte_free(dev->data->tx_queues[i]);
+		dev->data->tx_queues[i] = NULL;
+	}
+	dev->data->nb_tx_queues = 0;
+}
+
 void
 bond_ethdev_stop(struct rte_eth_dev *eth_dev)
 {
@@ -1553,8 +1571,9 @@ bond_ethdev_stop(struct rte_eth_dev *eth_dev)
 }
 
 void
-bond_ethdev_close(struct rte_eth_dev *dev __rte_unused)
+bond_ethdev_close(struct rte_eth_dev *dev)
 {
+	bond_ethdev_free_queues(dev);
 }
 
 /* forward declaration */
drivers/net/bonding/rte_eth_bond_private.h +1 -1
index 9f57f4d..038bca6 100644
@@ -288,6 +288,6 @@ void
 bond_ethdev_stop(struct rte_eth_dev *eth_dev);
 
 void
-bond_ethdev_close(struct rte_eth_dev *dev __rte_unused);
+bond_ethdev_close(struct rte_eth_dev *dev);
 
 #endif
Signature · 1 line
1.9.1
#6 lore raw

PATCH v7 4/4 testpmd_app_ug: add example of re-attaching bonded port

In reply to Bernard Iremonger
---
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 13 +++++++++++++
 1 file changed, 13 insertions(+)
doc/guides/testpmd_app_ug/testpmd_funcs.rst +13 -0
index 4652962..5272bf4 100644
@@ -909,6 +909,19 @@ For example, to attach a port created by pcap PMD.
 In this case, identifier is "eth_pcap0,iface=eth0".
 This identifier format is the same as "--vdev" format of DPDK applications.
 
+For example, to re-attach a bonded port which has been previously detached,
+the mode and slave parameters must be given.
+
+.. code-block:: console
+
+    testpmd> port attach eth_bond_testpmd_0,mode=0,slave=1
+    Attaching a new port...
+    EAL: Initializing pmd_bond for eth_bond_testpmd_0
+    EAL: Create bonded device eth_bond_testpmd_0 on port 0 in mode 0 on socket 0.
+    Port 0 is attached. Now total ports is 1
+    Done
+
+
 port detach
 ~~~~~~~~~~~
 
Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH v7 1/4] bonding: add support for PCI Port Hotplug

In reply to Bernard Iremonger

2015-07-27 16:54, Bernard Iremonger:

drivers/net/bonding/rte_eth_bond_version.map DPDK_2.0 { · line 11

Quoted 11 lines
drivers/net/bonding/rte_eth_bond_version.map +1 -0
@@ -5,6 +5,7 @@ DPDK_2.0 {
        rte_eth_bond_8023ad_setup;
        rte_eth_bond_active_slaves_get;
        rte_eth_bond_create;
+       rte_eth_bond_free;
        rte_eth_bond_link_monitoring_set;
        rte_eth_bond_mac_address_reset;
        rte_eth_bond_mac_address_set;

It must be added in a new node DPDK_2.1.

#4 lore raw

Re: [PATCH v7 2/4] test-pmd: modified testpmd for link_bonding

In reply to Bernard Iremonger

2015-07-27 16:54, Bernard Iremonger:

app/test-pmd/testpmd.h struct rte_port { · line 167

Quoted 7 lines

uint8_t need_reconfig_queues; /**< need reconfiguring queues or not */
uint8_t rss_flag; /**< enable rss or not */

app/test-pmd/testpmd.h +1 -1
-       uint8_t                 dcb_flag;   /**< enable dcb */
+       uint8_t                         dcb_flag;   /**< enable dcb */
        struct rte_eth_rxconf   rx_conf;    /**< rx configuration */
        struct rte_eth_txconf   tx_conf;    /**< tx configuration */

It doesn't appear to be a desired change.

#7 lore raw
In reply to Bernard Iremonger

2015-07-27 16:54, Bernard Iremonger:

Quoted 5 lines

Bernard Iremonger (4):
bonding: add support for PCI Port Hotplug
test-pmd: modified testpmd for link_bonding
bonding: free queue memory in close function
testpmd_app_ug: add example of re-attaching bonded port

Applied with last mintue fixes