All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bernard Iremonger <bernard.iremonger@intel.com>
To: dev@dpdk.org
Subject: [RFC PATCH V4] ixgbe: changes to support PCI Port Hotplug
Date: Mon,  8 Jun 2015 16:47:38 +0100	[thread overview]
Message-ID: <1433778458-17434-1-git-send-email-bernard.iremonger@intel.com> (raw)
In-Reply-To: <RFC PATCH>

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

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.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c |  107 ++++++++++++++++++++++++++++++++++++--
 drivers/net/ixgbe/ixgbe_ethdev.h |    2 +
 drivers/net/ixgbe/ixgbe_pf.c     |   22 ++++++++
 3 files changed, 126 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 0d9f9b2..7f9d286 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -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);
@@ -916,6 +918,57 @@ 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;
+	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);
+	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);
+
+	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;
+	}
+
+	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;
+	}
+
+	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.
@@ -1086,13 +1139,56 @@ 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;
+	}
+
+	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;
+	}
+
+	rte_free(eth_dev->data->mac_addrs);
+	eth_dev->data->mac_addrs = NULL;
+
+	return 0;
+}
+
 static struct eth_driver rte_ixgbe_pmd = {
 	{
 		.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),
 };
 
@@ -1103,9 +1199,10 @@ static struct eth_driver rte_ixgbevf_pmd = {
 	{
 		.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),
 };
 
@@ -1475,7 +1572,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
@@ -1628,7 +1725,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);
@@ -3015,7 +3112,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);
 
 	/*
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index 19237b8..710ee87 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -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);
diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c
index caed137..fd1c4ca 100644
--- a/drivers/net/ixgbe/ixgbe_pf.c
+++ b/drivers/net/ixgbe/ixgbe_pf.c
@@ -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;
-- 
1.7.4.1

  parent reply	other threads:[~2015-06-08 15:47 UTC|newest]

Thread overview: 96+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <RFC PATCH>
2015-04-08 10:02 ` [RFC PATCH] librte_pmd_ixgbe: changes to support PCI Port Hotplug Bernard Iremonger
2015-04-22  3:14   ` Qiu, Michael
2015-04-08 14:11 ` [RFC PATCH] librte_pmd_e1000: igb and em1000 PCI Port Hotplug changes Bernard Iremonger
2015-04-30 13:16 ` [RFC PATCH 1/1] librte_pmd_ring: changes to support PCI Port Hotplug Bernard Iremonger
2015-04-30 15:40 ` [RFC PATCH 1/4] librte_pmd_i40e: " Bernard Iremonger
2015-04-30 15:41 ` [RFC PATCH 2/4] librte_pmd_i40e: release vmdq vsi's in dev_close Bernard Iremonger
2015-04-30 15:42 ` [RFC PATCH 3/4] librte_pmd_i40e: increase ASQ_DELAY_MS to 100 in i40evf_wait_cmd_done() Bernard Iremonger
2015-04-30 15:42 ` [RFC PATCH 4/4] librte_pmd_i40e: call _clear_cmd() when error occurs Bernard Iremonger
2015-05-01 14:36 ` [RFC PATCH] librte_pmd_bond: add support for PCI Port Hotplug Bernard Iremonger
     [not found]   ` <1430490979-1994-1-git-send-email-bernard.iremonger-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-05-01 15:17     ` Neil Horman
2015-05-01 15:28 ` [RFC PATCH] librte_pmd_virtio: " Bernard Iremonger
2015-05-05 14:36 ` [RFC PATCH V2] librte_pmd_ring: changes to support " Bernard Iremonger
     [not found]   ` <1430836601-12248-1-git-send-email-bernard.iremonger-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-05-06 16:15     ` Bruce Richardson
2015-05-06 10:22 ` [RFC PATCH V2] librte_pmd_ixgbe: " Bernard Iremonger
2015-05-06 11:20 ` [RFC PATCH V2] librte_pmd_e1000: igb and em1000 PCI Port Hotplug changes Bernard Iremonger
2015-05-27 16:00 ` [RFC PATCH V2 1/2] drivers/net/virtio: add support for PCI Port Hotplug Bernard Iremonger
2015-05-27 16:00 ` [RFC PATCH V2 2/2] drivers/net/virtio: check vq parameter Bernard Iremonger
2015-06-16  1:08   ` Ouyang, Changchun
2015-05-28 12:28 ` [RFC PATCH V2] drivers/net/bonding: add support for PCI Port Hotplug Bernard Iremonger
2015-05-29 13:46 ` [RFC PATCH V3] drivers/net/ring: changes to support " Bernard Iremonger
2015-06-03 15:21   ` Bruce Richardson
2015-06-02 10:18 ` [RFC PATCH V3] ixgbe: " Bernard Iremonger
2015-06-03 14:03 ` [RFC PATCH V3] e1000: igb and em1000 PCI Port Hotplug changes Bernard Iremonger
2015-06-04 16:24 ` [RFC PATCH V2 1/4] i40e: changes to support PCI Port Hotplug Bernard Iremonger
2015-06-24  8:03   ` Qiu, Michael
2015-06-04 16:25 ` [RFC PATCH V2 2/4] i40e: release vmdq vsi's in dev_close Bernard Iremonger
2015-06-04 16:25 ` [RFC PATCH V2 3/4] i40e: increase ASQ_DELAY_MS to 100 in i40evf_wait_cmd_done() Bernard Iremonger
2015-06-04 16:26 ` [RFC PATCH V2 4/4] i40e: call _clear_cmd() when error occurs Bernard Iremonger
2015-06-08 15:47 ` Bernard Iremonger [this message]
2015-06-15 22:31   ` [RFC PATCH V4] ixgbe: changes to support PCI Port Hotplug Ananyev, Konstantin
2015-06-17  6:11   ` Zhang, Helin
2015-06-24  7:45   ` Qiu, Michael
2015-06-24  7:46   ` Qiu, Michael
2015-06-10  8:27 ` [RFC PATCH V3 0/5] PCI Port Hotplug changes Bernard Iremonger
2015-06-10  8:27   ` [RFC PATCH V3 1/5] i40e: changes to support PCI Port Hotplug Bernard Iremonger
2015-06-10  8:27   ` [RFC PATCH V3 2/5] i40e: release vmdq vsi's in dev_close Bernard Iremonger
2015-06-10  8:27   ` [RFC PATCH V3 3/5] i40e: increase ASQ_DELAY_MS to 100 in i40evf_wait_cmd_done() Bernard Iremonger
2015-06-10  8:27   ` [RFC PATCH V3 4/5] i40e: call _clear_cmd() when error occurs Bernard Iremonger
2015-06-10  8:27   ` [RFC PATCH V3 5/5] i40e: clear queues in i40evf_dev_stop Bernard Iremonger
2015-06-10 12:09 ` [RFC PATCH V4] e1000: igb and em1000 PCI Port Hotplug changes Bernard Iremonger
2015-08-27 15:40 ` [RFC PATCH 0/6] remove pci driver from vdevs Bernard Iremonger
2015-08-27 15:40   ` [RFC PATCH 1/6] librte_ether: add fields from rte_pci_driver to rte_eth_dev and rte_eth_dev_data Bernard Iremonger
2015-08-31 14:07     ` Thomas Monjalon
2015-09-01 11:38       ` Iremonger, Bernard
2015-09-01 12:03         ` Bruce Richardson
2015-09-01 12:37         ` Ananyev, Konstantin
2015-09-01 12:43           ` Richardson, Bruce
2015-08-27 15:40   ` [RFC PATCH 2/6] librte_ether: handle RTE_ETH_DEV_INTR_LSC for vdevs Bernard Iremonger
2015-08-27 15:40   ` [RFC PATCH 3/6] null: remove pci device driver Bernard Iremonger
2015-08-31 14:11     ` Thomas Monjalon
2015-08-31 16:05       ` Iremonger, Bernard
2015-08-27 15:40   ` [RFC PATCH 4/6] ring: " Bernard Iremonger
2015-08-27 15:40   ` [RFC PATCH 5/6] bonding: " Bernard Iremonger
2015-08-27 17:48     ` Stephen Hemminger
2015-08-28  8:32       ` Iremonger, Bernard
2015-08-28 15:57         ` Stephen Hemminger
2015-08-27 15:40   ` [RFC PATCH 6/6] pcap: " Bernard Iremonger
2015-08-27 17:43   ` [RFC PATCH 0/6] remove pci driver from vdevs John W. Linville
2015-08-28  8:15     ` Iremonger, Bernard
2015-08-28 10:32       ` Neil Horman
2015-08-28 19:48         ` Wiles, Keith
2015-08-31 11:21           ` Iremonger, Bernard
2015-08-31 12:41             ` Neil Horman
2015-08-28 17:51       ` John W. Linville
2015-08-31 10:23         ` Iremonger, Bernard
2015-08-31 12:59           ` Neil Horman
2015-08-31 14:22             ` Thomas Monjalon
2015-09-01 13:38               ` Iremonger, Bernard
2015-09-01 19:18                 ` Neil Horman
2015-09-03 14:02                   ` Iremonger, Bernard
2015-09-07  9:22                     ` Zende, Amruta S
2015-09-04 11:01 ` [RFC PATCH 00/18] refactor eal driver registration code Bernard Iremonger
2015-09-04 11:01   ` [RFC PATCH 01/18] librte_eal: remove type field from rte_driver structure Bernard Iremonger
2015-09-04 13:08     ` Thomas Monjalon
2015-09-04 11:01   ` [RFC PATCH 02/18] af_packet: " Bernard Iremonger
2015-09-04 11:01   ` [RFC PATCH 03/18] bnx2x: remove type field and initialise name field in " Bernard Iremonger
2015-09-04 11:26     ` Harish Patil
2015-09-04 11:01   ` [RFC PATCH 04/18] bonding: remove type field from " Bernard Iremonger
2015-09-04 11:01   ` [RFC PATCH 05/18] cxgbe: " Bernard Iremonger
2015-09-04 11:01   ` [RFC PATCH 06/18] e1000: remove type field and initialise name field in rte_driver structures Bernard Iremonger
2015-09-04 11:01   ` [RFC PATCH 07/18] enic: remove type field and initialise name field in rte_driver structure Bernard Iremonger
2015-09-04 11:01   ` [RFC PATCH 08/18] fm10k: " Bernard Iremonger
2015-09-04 11:01   ` [RFC PATCH 09/18] i40e: remove type field and initialise name field in rte_driver structures Bernard Iremonger
2015-09-04 11:01   ` [RFC PATCH 10/18] ixgbe: remove type field and initialise name field in rte_driver structure Bernard Iremonger
2015-09-04 11:01   ` [RFC PATCH 11/18] mlx4: remove type field from " Bernard Iremonger
2015-09-04 11:01   ` [RFC PATCH 12/18] mpipe: remove type field and update name in " Bernard Iremonger
2015-09-04 11:01   ` [RFC PATCH 13/18] null: remove type field from " Bernard Iremonger
2015-09-04 11:01   ` [RFC PATCH 14/18] pcap: " Bernard Iremonger
2015-09-04 11:01   ` [RFC PATCH 15/18] ring: " Bernard Iremonger
2015-09-04 11:01   ` [RFC PATCH 16/18] virtio_ethdev: remove type field and initialise name field in " Bernard Iremonger
2015-09-04 11:01   ` [RFC PATCH 17/18] vmxnet3: " Bernard Iremonger
2015-09-04 11:01   ` [RFC PATCH 18/18] xenvirt: remove type field from " Bernard Iremonger
2015-09-04 11:18   ` [RFC PATCH 00/18] refactor eal driver registration code Bruce Richardson
2015-09-04 12:46     ` Iremonger, Bernard
2015-09-04 12:53       ` Bruce Richardson
2015-09-05  2:21     ` Neil Horman

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=1433778458-17434-1-git-send-email-bernard.iremonger@intel.com \
    --to=bernard.iremonger@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.