Skip to contentSkip to conversation

PCI Port Hotplug

PATCH Applied Bernard Iremonger 3 participants 6 messages Jul 2, 2015 – Jul 19, 2015 Network drivers

v6 of 7 Applied Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v6 cover PCI Port Hotplug

Changes in V6:
Rebased to latest code.
Remove release of queue memory form dev_uninit() functions. Add ixgbe_dev_free_queues() function and call it from close() functions.

Changes in V5:
Set nb_rx_queues and nb_tx_queues to 0 in uninit functions. Rebased to latest ixgbe code.

Changes in V4:
Release rx and tx queues in dev_uninit() functions. Replace TRUE and FALSE with 1 and 0.

Changes in V3:
Rebased to use drivers/net/ixgbe directory.

Changes in V2:
Added call to dev_close() in dev_uninit() functions. Removed input parameter checks from dev_uninit() functions.

Bernard Iremonger (2):
ixgbe: changes to support PCI Port Hotplug
ixgbe: release queue memory in close functions

 drivers/net/ixgbe/ixgbe_ethdev.c |  102 ++++++++++++++++++++++++++++++++++++--
 drivers/net/ixgbe/ixgbe_ethdev.h |    4 ++
 drivers/net/ixgbe/ixgbe_pf.c     |   22 ++++++++
 drivers/net/ixgbe/ixgbe_rxtx.c   |   19 +++++++
 4 files changed, 142 insertions(+), 5 deletions(-)
Signature · 1 line
1.7.4.1
#1 lore raw

PATCH v6 1/2 ixgbe: changes to support PCI Port Hotplug

This patch depends on the Port Hotplug Framework.
It implements the eth_dev_uninit functions for rte_ixgbe_pmd and rte_ixgbevf_pmd.

---
 drivers/net/ixgbe/ixgbe_ethdev.c |   98 ++++++++++++++++++++++++++++++++++++--
 drivers/net/ixgbe/ixgbe_ethdev.h |    2 +
 drivers/net/ixgbe/ixgbe_pf.c     |   22 +++++++++
 3 files changed, 117 insertions(+), 5 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +93 -5
index f18550c..f5fe120 100644
@@ -117,6 +117,7 @@
 #define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / sizeof(hw_stats->qprc[0]))
 
 static int eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev);
+static int eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev);
 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);
@@ -183,6 +184,7 @@ static void ixgbe_dcb_init(struct ixgbe_hw *hw,struct ixgbe_dcb_config *dcb_conf
 
 /* For Virtual Function support */
 static int eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev);
+static int eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev);
 static int  ixgbevf_dev_configure(struct rte_eth_dev *dev);
 static int  ixgbevf_dev_start(struct rte_eth_dev *dev);
 static void ixgbevf_dev_stop(struct rte_eth_dev *dev);
@@ -922,6 +924,46 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static int
+eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)
+{
+	struct rte_pci_device *pci_dev;
+	struct ixgbe_hw *hw;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return -EPERM;
+
+	hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	pci_dev = eth_dev->pci_dev;
+
+	if (hw->adapter_stopped == 0)
+		ixgbe_dev_close(eth_dev);
+
+	eth_dev->dev_ops = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+
+	/* Unlock any pending hardware semaphore */
+	ixgbe_swfw_lock_reset(hw);
+
+	/* disable uio intr before callback unregister */
+	rte_intr_disable(&(pci_dev->intr_handle));
+	rte_intr_callback_unregister(&(pci_dev->intr_handle),
+		ixgbe_dev_interrupt_handler, (void *)eth_dev);
+
+	/* uninitialize PF if max_vfs not zero */
+	ixgbe_pf_host_uninit(eth_dev);
+
+	rte_free(eth_dev->data->mac_addrs);
+	eth_dev->data->mac_addrs = NULL;
+
+	rte_free(eth_dev->data->hash_mac_addrs);
+	eth_dev->data->hash_mac_addrs = NULL;
+
+	return 0;
+}
 
 /*
  * Negotiate mailbox API version with the PF.
@@ -1092,13 +1134,58 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+/* Virtual Function device uninit */
+
+static int
+eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev)
+{
+	struct ixgbe_hw *hw;
+	unsigned i;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return -EPERM;
+
+	hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+
+	if (hw->adapter_stopped == 0)
+		ixgbevf_dev_close(eth_dev);
+
+	eth_dev->dev_ops = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+
+	/* Disable the interrupts for VF */
+	ixgbevf_intr_disable(hw);
+
+	for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
+		ixgbe_dev_rx_queue_release(eth_dev->data->rx_queues[i]);
+		eth_dev->data->rx_queues[i] = NULL;
+	}
+	eth_dev->data->nb_rx_queues = 0;
+
+	for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
+		ixgbe_dev_tx_queue_release(eth_dev->data->tx_queues[i]);
+		eth_dev->data->tx_queues[i] = NULL;
+	}
+	eth_dev->data->nb_tx_queues = 0;
+
+	rte_free(eth_dev->data->mac_addrs);
+	eth_dev->data->mac_addrs = NULL;
+
+	return 0;
+}
+
 static struct eth_driver rte_ixgbe_pmd = {
 	.pci_drv = {
 		.name = "rte_ixgbe_pmd",
 		.id_table = pci_id_ixgbe_map,
-		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
+			RTE_PCI_DRV_DETACHABLE,
 	},
 	.eth_dev_init = eth_ixgbe_dev_init,
+	.eth_dev_uninit = eth_ixgbe_dev_uninit,
 	.dev_private_size = sizeof(struct ixgbe_adapter),
 };
 
@@ -1109,9 +1196,10 @@ static struct eth_driver rte_ixgbevf_pmd = {
 	.pci_drv = {
 		.name = "rte_ixgbevf_pmd",
 		.id_table = pci_id_ixgbevf_map,
-		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
 	},
 	.eth_dev_init = eth_ixgbevf_dev_init,
+	.eth_dev_uninit = eth_ixgbevf_dev_uninit,
 	.dev_private_size = sizeof(struct ixgbe_adapter),
 };
 
@@ -1481,7 +1569,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
 	}
 
 	/* stop adapter */
-	hw->adapter_stopped = FALSE;
+	hw->adapter_stopped = 0;
 	ixgbe_stop_adapter(hw);
 
 	/* reinitialize adapter
@@ -1639,7 +1727,7 @@ ixgbe_dev_stop(struct rte_eth_dev *dev)
 
 	/* reset the NIC */
 	ixgbe_pf_reset_hw(hw);
-	hw->adapter_stopped = FALSE;
+	hw->adapter_stopped = 0;
 
 	/* stop adapter */
 	ixgbe_stop_adapter(hw);
@@ -3043,7 +3131,7 @@ ixgbevf_dev_stop(struct rte_eth_dev *dev)
 
 	PMD_INIT_FUNC_TRACE();
 
-	hw->adapter_stopped = TRUE;
+	hw->adapter_stopped = 1;
 	ixgbe_stop_adapter(hw);
 
 	/*
drivers/net/ixgbe/ixgbe_ethdev.h +2 -0
index 19237b8..710ee87 100644
@@ -389,6 +389,8 @@ void ixgbe_vlan_hw_strip_disable_all(struct rte_eth_dev *dev);
 
 void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev);
 
+void ixgbe_pf_host_uninit(struct rte_eth_dev *eth_dev);
+
 void ixgbe_pf_mbx_process(struct rte_eth_dev *eth_dev);
 
 int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev);
drivers/net/ixgbe/ixgbe_pf.c +22 -0
index caed137..fd1c4ca 100644
@@ -144,6 +144,28 @@ void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
 	return;
 }
 
+void ixgbe_pf_host_uninit(struct rte_eth_dev *eth_dev)
+{
+	struct ixgbe_vf_info **vfinfo;
+	uint16_t vf_num;
+
+	PMD_INIT_FUNC_TRACE();
+
+	vfinfo = IXGBE_DEV_PRIVATE_TO_P_VFDATA(eth_dev->data->dev_private);
+
+	RTE_ETH_DEV_SRIOV(eth_dev).active = 0;
+	RTE_ETH_DEV_SRIOV(eth_dev).nb_q_per_pool = 0;
+	RTE_ETH_DEV_SRIOV(eth_dev).def_vmdq_idx = 0;
+	RTE_ETH_DEV_SRIOV(eth_dev).def_pool_q_idx = 0;
+
+	vf_num = dev_num_vf(eth_dev);
+	if (vf_num == 0)
+		return;
+
+	rte_free(*vfinfo);
+	*vfinfo = NULL;
+}
+
 int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
 {
 	uint32_t vtctl, fcrth;
Signature · 1 line
1.7.4.1
#2 lore raw

PATCH v2 1/1 librte_ether: release memory in uninit function.

In reply to Bernard Iremonger

Changes in v2:
do not free mac_addrs and hash_mac_addrs here.

---
 lib/librte_ether/rte_ethdev.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
lib/librte_ether/rte_ethdev.c +5 -1
index e13fde5..7ae101a 100644
@@ -369,8 +369,12 @@ rte_eth_dev_uninit(struct rte_pci_device *pci_dev)
 	/* free ether device */
 	rte_eth_dev_release_port(eth_dev);
 
-	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		rte_free(eth_dev->data->rx_queues);
+		rte_free(eth_dev->data->tx_queues);
 		rte_free(eth_dev->data->dev_private);
+		memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));
+	}
 
 	eth_dev->pci_dev = NULL;
 	eth_dev->driver = NULL;
Signature · 1 line
1.7.4.1
#3 lore raw

PATCH v6 2/2 ixgbe: release queue memory in close functions

In reply to Bernard Iremonger

add ixgbe_dev_free_queues() function and call it from close() functions.

---
 drivers/net/ixgbe/ixgbe_ethdev.c |    4 ++++
 drivers/net/ixgbe/ixgbe_ethdev.h |    2 ++
 drivers/net/ixgbe/ixgbe_rxtx.c   |   19 +++++++++++++++++++
 3 files changed, 25 insertions(+), 0 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +4 -0
index f5fe120..4ff1671 100644
@@ -1843,6 +1843,8 @@ ixgbe_dev_close(struct rte_eth_dev *dev)
 	ixgbe_dev_stop(dev);
 	hw->adapter_stopped = 1;
 
+	ixgbe_dev_free_queues(dev);
+
 	ixgbe_disable_pcie_master(hw);
 
 	/* reprogram the RAR[0] in case user changed it. */
@@ -3157,6 +3159,8 @@ ixgbevf_dev_close(struct rte_eth_dev *dev)
 
 	ixgbevf_dev_stop(dev);
 
+	ixgbe_dev_free_queues(dev);
+
 	/* reprogram the RAR[0] in case user changed it. */
 	ixgbe_set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
 }
drivers/net/ixgbe/ixgbe_ethdev.h +2 -0
index 710ee87..fb9cea6 100644
@@ -311,6 +311,8 @@ struct ixgbe_adapter {
  */
 void ixgbe_dev_clear_queues(struct rte_eth_dev *dev);
 
+void ixgbe_dev_free_queues(struct rte_eth_dev *dev);
+
 void ixgbe_dev_rx_queue_release(void *rxq);
 
 void ixgbe_dev_tx_queue_release(void *txq);
drivers/net/ixgbe/ixgbe_rxtx.c +19 -0
index 3ace8a8..52ac188 100644
@@ -2496,6 +2496,25 @@ ixgbe_dev_clear_queues(struct rte_eth_dev *dev)
 	}
 }
 
+void
+ixgbe_dev_free_queues(struct rte_eth_dev *dev)
+{
+	unsigned i;
+
+	PMD_INIT_FUNC_TRACE();
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		ixgbe_dev_rx_queue_release(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++) {
+		ixgbe_dev_tx_queue_release(dev->data->tx_queues[i]);
+		dev->data->tx_queues[i] = NULL;
+	}
+	dev->data->nb_tx_queues = 0;
+}
 /*********************************************************************
  *
  *  Device RX/TX init functions
Signature · 1 line
1.7.4.1
Acked-by on the v6 series
#4 lore raw
In reply to Bernard Iremonger
Quoted 33 lines

-----Original Message-----
From: Iremonger, Bernard
Sent: Thursday, July 02, 2015 3:37 PM
To: [email protected]
Cc: Zhang, Helin; Qiu, Michael; Ananyev, Konstantin; Iremonger, Bernard
Subject: [PATCH v6 0/2] PCI Port Hotplug

Changes in V6:
Rebased to latest code.
Remove release of queue memory form dev_uninit() functions. Add ixgbe_dev_free_queues() function and call it from close() functions.

Changes in V5:
Set nb_rx_queues and nb_tx_queues to 0 in uninit functions. Rebased to latest ixgbe code.

Changes in V4:
Release rx and tx queues in dev_uninit() functions. Replace TRUE and FALSE with 1 and 0.

Changes in V3:
Rebased to use drivers/net/ixgbe directory.

Changes in V2:
Added call to dev_close() in dev_uninit() functions. Removed input parameter checks from dev_uninit() functions.

Bernard Iremonger (2):
ixgbe: changes to support PCI Port Hotplug
ixgbe: release queue memory in close functions

Quoted 7 lines
 drivers/net/ixgbe/ixgbe_ethdev.c |  102 ++++++++++++++++++++++++++++++++++++--
 drivers/net/ixgbe/ixgbe_ethdev.h |    4 ++
 drivers/net/ixgbe/ixgbe_pf.c     |   22 ++++++++
 drivers/net/ixgbe/ixgbe_rxtx.c   |   19 +++++++
 4 files changed, 142 insertions(+), 5 deletions(-)

--

Quoted 1 line

1.7.4.1