DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] doc: add bsd license to svg file
       [not found] <PATCH>
@ 2014-12-08 17:18 ` Bernard Iremonger
  2014-12-11 13:42   ` De Lara Guarch, Pablo
  2015-06-10 15:12 ` [dpdk-dev] [PATCH 0/2] doc: kni command line fixes Bernard Iremonger
                   ` (40 subsequent siblings)
  41 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2014-12-08 17:18 UTC (permalink / raw)
  To: dev


Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 .../sample_app_ug/img/exception_path_example.svg   |   36 ++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/doc/guides/sample_app_ug/img/exception_path_example.svg b/doc/guides/sample_app_ug/img/exception_path_example.svg
index 5b12974..e72f7ba 100644
--- a/doc/guides/sample_app_ug/img/exception_path_example.svg
+++ b/doc/guides/sample_app_ug/img/exception_path_example.svg
@@ -1,4 +1,40 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
+
+<!--
+# BSD LICENSE
+# Copyright (c) <2014>, Intel Corporation
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+#
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
+#   distribution.
+#
+# - Neither the name of Intel Corporation nor the names of its
+#   contributors may be used to endorse or promote products derived
+#   from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+# OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+
 <svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="330.16" width="568.88" version="1.0" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <g transform="matrix(0.136 0 0 .13439 -6.7377 -69.183)">
   <path d="m3004.4 514.8v2456.8h1228v-2456.8h-1228z" fill-rule="evenodd" fill="#fcd5b5"/>
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH] doc: add bsd license to svg file
  2014-12-08 17:18 ` [dpdk-dev] [PATCH] doc: add bsd license to svg file Bernard Iremonger
@ 2014-12-11 13:42   ` De Lara Guarch, Pablo
  0 siblings, 0 replies; 270+ messages in thread
From: De Lara Guarch, Pablo @ 2014-12-11 13:42 UTC (permalink / raw)
  To: Iremonger, Bernard, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bernard Iremonger
> Sent: Monday, December 08, 2014 5:19 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH] doc: add bsd license to svg file
> 
> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>

Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> ---
>  .../sample_app_ug/img/exception_path_example.svg   |   36
> ++++++++++++++++++++
>  1 files changed, 36 insertions(+), 0 deletions(-)
> 
> diff --git a/doc/guides/sample_app_ug/img/exception_path_example.svg
> b/doc/guides/sample_app_ug/img/exception_path_example.svg
> index 5b12974..e72f7ba 100644
> --- a/doc/guides/sample_app_ug/img/exception_path_example.svg
> +++ b/doc/guides/sample_app_ug/img/exception_path_example.svg
> @@ -1,4 +1,40 @@
>  <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> +
> +<!--
> +# BSD LICENSE
> +# Copyright (c) <2014>, Intel Corporation
> +# All rights reserved.
> +#
> +# Redistribution and use in source and binary forms, with or without
> +# modification, are permitted provided that the following conditions
> +# are met:
> +#
> +# - Redistributions of source code must retain the above copyright
> +#   notice, this list of conditions and the following disclaimer.
> +#
> +# - Redistributions in binary form must reproduce the above copyright
> +#   notice, this list of conditions and the following disclaimer in
> +#   the documentation and/or other materials provided with the
> +#   distribution.
> +#
> +# - Neither the name of Intel Corporation nor the names of its
> +#   contributors may be used to endorse or promote products derived
> +#   from this software without specific prior written permission.
> +#
> +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
> CONTRIBUTORS
> +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
> NOT
> +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
> FITNESS
> +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
> +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
> INDIRECT,
> +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
> +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
> GOODS OR
> +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> CONTRACT,
> +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
> ADVISED
> +# OF THE POSSIBILITY OF SUCH DAMAGE.
> +-->
> +
>  <svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
> xmlns="http://www.w3.org/2000/svg" height="330.16" width="568.88"
> version="1.0" xmlns:cc="http://creativecommons.org/ns#"
> xmlns:dc="http://purl.org/dc/elements/1.1/">
>   <g transform="matrix(0.136 0 0 .13439 -6.7377 -69.183)">
>    <path d="m3004.4 514.8v2456.8h1228v-2456.8h-1228z" fill-rule="evenodd"
> fill="#fcd5b5"/>
> --
> 1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 0/2]  doc: kni command line fixes
       [not found] <PATCH>
  2014-12-08 17:18 ` [dpdk-dev] [PATCH] doc: add bsd license to svg file Bernard Iremonger
@ 2015-06-10 15:12 ` Bernard Iremonger
  2015-06-10 15:12   ` [dpdk-dev] [PATCH 1/2] doc: correct kni command line in virtio chapter Bernard Iremonger
                     ` (2 more replies)
  2015-06-11 14:33 ` [dpdk-dev] [PATCH] doc: update port attach and detach in Testpmd Runtime Functions chapter Bernard Iremonger
                   ` (39 subsequent siblings)
  41 siblings, 3 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-10 15:12 UTC (permalink / raw)
  To: dev

Several kni command lines did not work.
The patches below fix the command lines.

Bernard Iremonger (2):
  doc: correct kni command line in virtio chapter
  doc: fix kni command line in Kernel NIC Interface chapter

 doc/guides/nics/virtio.rst                     |    4 ++--
 doc/guides/prog_guide/kernel_nic_interface.rst |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 1/2] doc: correct kni command line in virtio chapter
  2015-06-10 15:12 ` [dpdk-dev] [PATCH 0/2] doc: kni command line fixes Bernard Iremonger
@ 2015-06-10 15:12   ` Bernard Iremonger
  2015-06-15  2:29     ` Zhang, Helin
  2015-06-10 15:12   ` [dpdk-dev] [PATCH 2/2] doc: fix kni command line in Kernel NIC Interface chapter Bernard Iremonger
  2015-06-10 17:13   ` [dpdk-dev] [PATCH 0/2] doc: kni command line fixes Mcnamara, John
  2 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-10 15:12 UTC (permalink / raw)
  To: dev


Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 doc/guides/nics/virtio.rst |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/guides/nics/virtio.rst b/doc/guides/nics/virtio.rst
index 9f18b3a..200a8be 100644
--- a/doc/guides/nics/virtio.rst
+++ b/doc/guides/nics/virtio.rst
@@ -1,5 +1,5 @@
 ..  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
@@ -128,7 +128,7 @@ Host2VM communication example
 
     .. code-block:: console
 
-        examples/kni/build/app/kni -c 0xf -n 4 -- -p 0x1 -i 0x1 -o 0x2
+        examples/kni/build/app/kni -c 0xf -n 4 -- -p 0x1 -P --config="(0,1,3)"
 
     This command generates one network device vEth0 for physical port.
     If specify more physical ports, the generated network device will be vEth1, vEth2, and so on.
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 2/2] doc: fix kni command line in Kernel NIC Interface chapter
  2015-06-10 15:12 ` [dpdk-dev] [PATCH 0/2] doc: kni command line fixes Bernard Iremonger
  2015-06-10 15:12   ` [dpdk-dev] [PATCH 1/2] doc: correct kni command line in virtio chapter Bernard Iremonger
@ 2015-06-10 15:12   ` Bernard Iremonger
  2015-06-15  2:30     ` Zhang, Helin
  2015-06-10 17:13   ` [dpdk-dev] [PATCH 0/2] doc: kni command line fixes Mcnamara, John
  2 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-10 15:12 UTC (permalink / raw)
  To: dev


Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 doc/guides/prog_guide/kernel_nic_interface.rst |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/guides/prog_guide/kernel_nic_interface.rst b/doc/guides/prog_guide/kernel_nic_interface.rst
index fb12d43..713d30b 100644
--- a/doc/guides/prog_guide/kernel_nic_interface.rst
+++ b/doc/guides/prog_guide/kernel_nic_interface.rst
@@ -1,5 +1,5 @@
 ..  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
@@ -238,7 +238,7 @@ Of course, as a prerequisite, the vhost/vhost-net kernel CONFIG should be chosen
 
     .. code-block:: console
 
-        ./kni -c -0xf0 -n 4 -- -p 0x3 -P -config="(0,4,6),(1,5,7)"
+        examples/kni/build/app/kni -c -0xf0 -n 4 -- -p 0x3 -P --config="(0,4,6),(1,5,7)"
 
     This command runs the kni sample application with two physical ports.
     Each port pins two forwarding cores (ingress/egress) in user space.
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH 0/2]  doc: kni command line fixes
  2015-06-10 15:12 ` [dpdk-dev] [PATCH 0/2] doc: kni command line fixes Bernard Iremonger
  2015-06-10 15:12   ` [dpdk-dev] [PATCH 1/2] doc: correct kni command line in virtio chapter Bernard Iremonger
  2015-06-10 15:12   ` [dpdk-dev] [PATCH 2/2] doc: fix kni command line in Kernel NIC Interface chapter Bernard Iremonger
@ 2015-06-10 17:13   ` Mcnamara, John
  2015-07-27 21:45     ` Thomas Monjalon
  2 siblings, 1 reply; 270+ messages in thread
From: Mcnamara, John @ 2015-06-10 17:13 UTC (permalink / raw)
  To: Iremonger, Bernard, dev

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bernard Iremonger
> Sent: Wednesday, June 10, 2015 4:13 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH 0/2] doc: kni command line fixes
> 
> Several kni command lines did not work.
> The patches below fix the command lines.
> 

Series:
Acked-by: John McNamara <john.mcnamara@intel.com>

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH] doc: update port attach and detach in Testpmd Runtime Functions chapter
       [not found] <PATCH>
  2014-12-08 17:18 ` [dpdk-dev] [PATCH] doc: add bsd license to svg file Bernard Iremonger
  2015-06-10 15:12 ` [dpdk-dev] [PATCH 0/2] doc: kni command line fixes Bernard Iremonger
@ 2015-06-11 14:33 ` Bernard Iremonger
  2015-06-16  2:45   ` Tetsuya Mukawa
  2015-06-12 16:21 ` [dpdk-dev] [PATCH v3 0/2] bonding PCI Port Hotplug Bernard Iremonger
                   ` (38 subsequent siblings)
  41 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-11 14:33 UTC (permalink / raw)
  To: dev


Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   96 +++++++++++++++++++++++----
 1 files changed, 82 insertions(+), 14 deletions(-)

diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 761172e..fef3ceb 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -1,5 +1,5 @@
 ..  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
@@ -866,31 +866,61 @@ Attach a port specified by pci address or virtual device args.
 To attach a new pci device, the device should be recognized by kernel first.
 Then it should be moved under DPDK management.
 Finally the port can be attached to testpmd.
-On the other hand, to attach a port created by virtual device, above steps are not needed.
+
+For example, to move a pci device using ixgbe under DPDK management:
+
+.. code-block:: console
+
+    ./tools/dpdk_nic_bind.py --status
+
+    Network devices using DPDK-compatible driver
+    ============================================
+    <none>
+
+    Network devices using kernel driver
+    ===================================
+    0000:0a:00.0 '82599ES 10-Gigabit SFI/SFP+ Network Connection' if=eth2 drv=ixgbe unused=
+
+    ./tools/dpdk_nic_bind.py -b igb_uio 0000:0a:00.0
+    ./tools/dpdk_nic_bind.py --status
+
+    Network devices using DPDK-compatible driver
+    ============================================
+    0000:0a:00.0 '82599ES 10-Gigabit SFI/SFP+ Network Connection' drv=igb_uio unused=
+
+To attach a port created by virtual device, above steps are not needed.
 
 port attach (identifier)
 
-For example, to attach a port whose pci address is 0000:02:00.0.
+For example, to attach a port whose pci address is 0000:0a:00.0.
 
 .. code-block:: console
 
-    testpmd> port attach 0000:02:00.0
+    testpmd> port attach 0000:0a:00.0
     Attaching a new port...
-    ... snip ...
+    EAL: PCI device 0000:0a:00.0 on NUMA socket -1
+    EAL:   probe driver: 8086:10fb rte_ixgbe_pmd
+    EAL:   PCI memory mapped at 0x7f83bfa00000
+    EAL:   PCI memory mapped at 0x7f83bfa80000
+    PMD: eth_ixgbe_dev_init(): MAC: 2, PHY: 18, SFP+: 5
+    PMD: eth_ixgbe_dev_init(): port 0 vendorID=0x8086 deviceID=0x10fb
     Port 0 is attached. Now total ports is 1
     Done
+    testpmd>
 
 For example, to attach a port created by pcap PMD.
 
 .. code-block:: console
 
-    testpmd> port attach eth_pcap0,iface=eth0
+    testpmd> port attach eth_pcap0
     Attaching a new port...
-    ... snip ...
+    PMD: Initializing pmd_pcap for eth_pcap0
+    PMD: Creating pcap-backed ethdev on numa socket 0
     Port 0 is attached. Now total ports is 1
     Done
+    testpmd>
 
-In this case, identifier is "eth_pcap0,iface=eth0".
+In this case, identifier is "eth_pcap0".
 This identifier format is the same as "--vdev" format of DPDK applications.
 
 port detach
@@ -899,21 +929,59 @@ port detach
 Detach a specific port.
 
 Before detaching a port, the port should be closed.
-Also to remove a pci device completely from the system, first detach the port from testpmd.
-Then the device should be moved under kernel management.
-Finally the device can be removed using kernel pci hotplug functionality.
-On the other hand, to remove a port created by a virtual device, above steps are not needed.
 
 port detach (port_id)
 
-For example, to detach a port 0.
+For example, to detach a pci device port 0.
+
+.. code-block:: console
+
+    testpmd> port close 0
+    Closing ports...
+    Done
+    testpmd> port detach 0
+    Detaching a port...
+    EAL: PCI device 0000:0a:00.0 on NUMA socket -1
+    EAL:   remove driver: 8086:10fb rte_ixgbe_pmd
+    EAL:   PCI memory unmapped at 0x7f83bfa00000
+    EAL:   PCI memory unmapped at 0x7f83bfa80000
+    Done
+    testpmd>
+
+For example, to detach a virtual device port 0.
 
 .. code-block:: console
 
+    testpmd> port close 0
+    Closing ports...
+    Done
     testpmd> port detach 0
     Detaching a port...
-    ... snip ...
+    PMD: Closing pcap ethdev on numa socket 0
+    Port 'eth_pcap0' is detached. Now total ports is 0
     Done
+    testpmd>
+
+To remove a pci device completely from the system, first detach the port from testpmd.
+Then the device should be moved under kernel management.
+Finally the device can be removed using kernel pci hotplug functionality.
+
+For example, to move a pci device under kernel management:
+
+.. code-block:: console
+
+    ./tools/dpdk_nic_bind.py -b ixgbe 0000:0a:00.0
+    ./tools/dpdk_nic_bind.py --status
+
+    Network devices using DPDK-compatible driver
+    ============================================
+    <none>
+
+    Network devices using kernel driver
+    ===================================
+    0000:0a:00.0 '82599ES 10-Gigabit SFI/SFP+ Network Connection' if=eth2 drv=ixgbe unused=igb_uio
+
+To remove a port created by a virtual device, above steps are not needed.
 
 port start
 ~~~~~~~~~~
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 0/2] bonding PCI Port Hotplug
       [not found] <PATCH>
                   ` (2 preceding siblings ...)
  2015-06-11 14:33 ` [dpdk-dev] [PATCH] doc: update port attach and detach in Testpmd Runtime Functions chapter Bernard Iremonger
@ 2015-06-12 16:21 ` Bernard Iremonger
  2015-06-12 16:21   ` [dpdk-dev] [PATCH v3 1/2] bonding: add support for " Bernard Iremonger
                     ` (2 more replies)
  2015-06-16 11:30 ` [dpdk-dev] [PATCH v2 0/2] virtio: " Bernard Iremonger
                   ` (37 subsequent siblings)
  41 siblings, 3 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-12 16:21 UTC (permalink / raw)
  To: dev

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

Bernard Iremonger (2):
  bonding: add support for PCI Port Hotplug
  test-pmd: modified testpmd for link_bonding

 app/test-pmd/cmdline.c                     |    4 +-
 app/test-pmd/testpmd.c                     |   24 +++++++-
 app/test-pmd/testpmd.h                     |    7 ++-
 drivers/net/bonding/rte_eth_bond.h         |   13 ++++-
 drivers/net/bonding/rte_eth_bond_api.c     |   82 +++++++++++++++++++---------
 drivers/net/bonding/rte_eth_bond_pmd.c     |   23 +++++++-
 drivers/net/bonding/rte_eth_bond_private.h |    7 ++-
 7 files changed, 124 insertions(+), 36 deletions(-)

-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 1/2] bonding: add support for PCI Port Hotplug
  2015-06-12 16:21 ` [dpdk-dev] [PATCH v3 0/2] bonding PCI Port Hotplug Bernard Iremonger
@ 2015-06-12 16:21   ` Bernard Iremonger
  2015-06-12 16:21   ` [dpdk-dev] [PATCH v3 2/2] test-pmd: modified testpmd for link_bonding Bernard Iremonger
  2015-06-19 16:33   ` [dpdk-dev] [PATCH v3 0/2] bonding PCI Port Hotplug Declan Doherty
  2 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-12 16:21 UTC (permalink / raw)
  To: dev

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

Changes in V2:
Rebased to use drivers/net/bonding dirctory
Free rx and tx queues following comments from Declan

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/bonding/rte_eth_bond.h         |   13 ++++-
 drivers/net/bonding/rte_eth_bond_api.c     |   82 +++++++++++++++++++---------
 drivers/net/bonding/rte_eth_bond_pmd.c     |   23 +++++++-
 drivers/net/bonding/rte_eth_bond_private.h |    7 ++-
 4 files changed, 95 insertions(+), 30 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond.h b/drivers/net/bonding/rte_eth_bond.h
index d688fc3..8efbf07 100644
--- a/drivers/net/bonding/rte_eth_bond.h
+++ b/drivers/net/bonding/rte_eth_bond.h
@@ -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.
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index d4caa83..de74af8 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -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
@@ -192,7 +192,15 @@ number_of_sockets(void)
 	return ++sockets;
 }
 
-const char *driver_name = "Link Bonding PMD";
+const char driver_name[] = "rte_bond_pmd";
+static struct rte_pci_id pci_id_table;
+
+static struct eth_driver rte_bond_pmd = {
+	.pci_drv = {
+		.name = driver_name,
+		.drv_flags = RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_DETACHABLE,
+	},
+};
 
 int
 rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
@@ -200,9 +208,8 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	struct rte_pci_device *pci_dev = NULL;
 	struct bond_dev_private *internals = NULL;
 	struct rte_eth_dev *eth_dev = NULL;
-	struct eth_driver *eth_drv = NULL;
 	struct rte_pci_driver *pci_drv = NULL;
-	struct rte_pci_id *pci_id_table = NULL;
+
 	/* now do all data allocation - for eth_dev structure, dummy pci driver
 	 * and internal (private) data
 	 */
@@ -224,26 +231,15 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 		goto err;
 	}
 
-	eth_drv = rte_zmalloc_socket(name, sizeof(*eth_drv), 0, socket_id);
-	if (eth_drv == NULL) {
-		RTE_BOND_LOG(ERR, "Unable to malloc eth_drv on socket");
-		goto err;
-	}
-
-	pci_drv = &eth_drv->pci_drv;
+	pci_drv = &rte_bond_pmd.pci_drv;
 
-	pci_id_table = rte_zmalloc_socket(name, sizeof(*pci_id_table), 0, socket_id);
-	if (pci_id_table == NULL) {
-		RTE_BOND_LOG(ERR, "Unable to malloc pci_id_table on socket");
-		goto err;
-	}
-	pci_id_table->device_id = PCI_ANY_ID;
-	pci_id_table->subsystem_device_id = PCI_ANY_ID;
-	pci_id_table->vendor_id = PCI_ANY_ID;
-	pci_id_table->subsystem_vendor_id = PCI_ANY_ID;
+	memset(&pci_id_table, 0, sizeof(pci_id_table));
+	pci_id_table.device_id = PCI_ANY_ID;
+	pci_id_table.subsystem_device_id = PCI_ANY_ID;
+	pci_id_table.vendor_id = PCI_ANY_ID;
+	pci_id_table.subsystem_vendor_id = PCI_ANY_ID;
 
-	pci_drv->id_table = pci_id_table;
-	pci_drv->drv_flags = RTE_PCI_DRV_INTR_LSC;
+	pci_drv->id_table = &pci_id_table;
 
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
 	if (internals == NULL) {
@@ -261,7 +257,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	pci_dev->numa_node = socket_id;
 	pci_drv->name = driver_name;
 
-	eth_dev->driver = eth_drv;
+	eth_dev->driver = &rte_bond_pmd;
 	eth_dev->data->dev_private = internals;
 	eth_dev->data->nb_rx_queues = (uint16_t)1;
 	eth_dev->data->nb_tx_queues = (uint16_t)1;
@@ -317,13 +313,49 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 
 err:
 	rte_free(pci_dev);
-	rte_free(pci_id_table);
-	rte_free(eth_drv);
 	rte_free(internals);
+	rte_free(eth_dev->data->mac_addrs);
 
 	return -1;
 }
 
+int
+rte_eth_bond_free(const char *name)
+{
+	struct rte_eth_dev *eth_dev = NULL;
+	unsigned i;
+
+	/* now free all data allocation - for eth_dev structure,
+	 * dummy pci driver and internal (private) data
+	 */
+
+	/* find an ethdev entry */
+	eth_dev = rte_eth_dev_allocated(name);
+	if (eth_dev == NULL)
+		return -ENODEV;
+
+	if (eth_dev->data->dev_started == 1)
+		bond_ethdev_stop(eth_dev);
+
+	eth_dev->dev_ops = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+
+	for (i = 0; i < eth_dev->data->nb_rx_queues; i++)
+		rte_free(eth_dev->data->rx_queues[i]);
+
+	for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
+		rte_free(eth_dev->data->tx_queues[i]);
+
+	rte_free(eth_dev->pci_dev);
+	rte_free(eth_dev->data->dev_private);
+	rte_free(eth_dev->data->mac_addrs);
+
+	rte_eth_dev_release_port(eth_dev);
+
+	return 0;
+}
+
 static int
 __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
 {
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 8bad2e1..bd132df 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -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
@@ -1503,7 +1503,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;
@@ -2034,6 +2034,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
@@ -2260,6 +2278,7 @@ static struct rte_driver bond_drv = {
 	.name = "eth_bond",
 	.type = PMD_VDEV,
 	.init = bond_init,
+	.uninit = bond_uninit,
 };
 
 PMD_REGISTER_DRIVER(bond_drv);
diff --git a/drivers/net/bonding/rte_eth_bond_private.h b/drivers/net/bonding/rte_eth_bond_private.h
index 45e5c65..7b00e94 100644
--- a/drivers/net/bonding/rte_eth_bond_private.h
+++ b/drivers/net/bonding/rte_eth_bond_private.h
@@ -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 *driver_name;
+extern const char driver_name[];
 
 /** Port Queue Mapping Structure */
 struct bond_rx_queue {
@@ -284,4 +284,7 @@ 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);
+
 #endif
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 2/2] test-pmd: modified testpmd for link_bonding
  2015-06-12 16:21 ` [dpdk-dev] [PATCH v3 0/2] bonding PCI Port Hotplug Bernard Iremonger
  2015-06-12 16:21   ` [dpdk-dev] [PATCH v3 1/2] bonding: add support for " Bernard Iremonger
@ 2015-06-12 16:21   ` Bernard Iremonger
  2015-06-19 16:33   ` [dpdk-dev] [PATCH v3 0/2] bonding PCI Port Hotplug Declan Doherty
  2 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-12 16:21 UTC (permalink / raw)
  To: dev

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.

Changes in V3:
test-pmd changes added to patchset.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 app/test-pmd/cmdline.c |    4 +++-
 app/test-pmd/testpmd.c |   24 +++++++++++++++++++++---
 app/test-pmd/testpmd.h |    7 +++++--
 3 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f01db2a..a9c1b8b 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -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.
  *
@@ -3950,6 +3950,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 =
@@ -4006,6 +4007,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 =
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 82b465d..b271728 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -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
@@ -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;
 	}
 
@@ -1810,6 +1812,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,
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index c3b6700..466964d 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -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
@@ -159,9 +159,10 @@ 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 */
+	uint8_t                 slave_flag; /**< bonding slave port */
 };
 
 extern portid_t __rte_unused
@@ -528,6 +529,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);
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] doc: correct kni command line in virtio chapter
  2015-06-10 15:12   ` [dpdk-dev] [PATCH 1/2] doc: correct kni command line in virtio chapter Bernard Iremonger
@ 2015-06-15  2:29     ` Zhang, Helin
  0 siblings, 0 replies; 270+ messages in thread
From: Zhang, Helin @ 2015-06-15  2:29 UTC (permalink / raw)
  To: Iremonger, Bernard, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bernard Iremonger
> Sent: Wednesday, June 10, 2015 11:13 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH 1/2] doc: correct kni command line in virtio chapter
> 
> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
Acked-by: Helin Zhang <helin.zhang@intel.com>

> ---
>  doc/guides/nics/virtio.rst |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/doc/guides/nics/virtio.rst b/doc/guides/nics/virtio.rst index
> 9f18b3a..200a8be 100644
> --- a/doc/guides/nics/virtio.rst
> +++ b/doc/guides/nics/virtio.rst
> @@ -1,5 +1,5 @@
>  ..  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 @@
> -128,7 +128,7 @@ Host2VM communication example
> 
>      .. code-block:: console
> 
> -        examples/kni/build/app/kni -c 0xf -n 4 -- -p 0x1 -i 0x1 -o 0x2
> +        examples/kni/build/app/kni -c 0xf -n 4 -- -p 0x1 -P --config="(0,1,3)"
> 
>      This command generates one network device vEth0 for physical port.
>      If specify more physical ports, the generated network device will be vEth1,
> vEth2, and so on.
> --
> 1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH 2/2] doc: fix kni command line in Kernel NIC Interface chapter
  2015-06-10 15:12   ` [dpdk-dev] [PATCH 2/2] doc: fix kni command line in Kernel NIC Interface chapter Bernard Iremonger
@ 2015-06-15  2:30     ` Zhang, Helin
  0 siblings, 0 replies; 270+ messages in thread
From: Zhang, Helin @ 2015-06-15  2:30 UTC (permalink / raw)
  To: Iremonger, Bernard, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bernard Iremonger
> Sent: Wednesday, June 10, 2015 11:13 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH 2/2] doc: fix kni command line in Kernel NIC Interface
> chapter
> 
> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
Acked-by: Helin Zhang <helin.zhang@intel.com>

> ---
>  doc/guides/prog_guide/kernel_nic_interface.rst |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/doc/guides/prog_guide/kernel_nic_interface.rst
> b/doc/guides/prog_guide/kernel_nic_interface.rst
> index fb12d43..713d30b 100644
> --- a/doc/guides/prog_guide/kernel_nic_interface.rst
> +++ b/doc/guides/prog_guide/kernel_nic_interface.rst
> @@ -1,5 +1,5 @@
>  ..  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 @@
> -238,7 +238,7 @@ Of course, as a prerequisite, the vhost/vhost-net kernel
> CONFIG should be chosen
> 
>      .. code-block:: console
> 
> -        ./kni -c -0xf0 -n 4 -- -p 0x3 -P -config="(0,4,6),(1,5,7)"
> +        examples/kni/build/app/kni -c -0xf0 -n 4 -- -p 0x3 -P
> --config="(0,4,6),(1,5,7)"
> 
>      This command runs the kni sample application with two physical ports.
>      Each port pins two forwarding cores (ingress/egress) in user space.
> --
> 1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH] doc: update port attach and detach in Testpmd Runtime Functions chapter
  2015-06-11 14:33 ` [dpdk-dev] [PATCH] doc: update port attach and detach in Testpmd Runtime Functions chapter Bernard Iremonger
@ 2015-06-16  2:45   ` Tetsuya Mukawa
  2015-07-28 10:22     ` Thomas Monjalon
  0 siblings, 1 reply; 270+ messages in thread
From: Tetsuya Mukawa @ 2015-06-16  2:45 UTC (permalink / raw)
  To: Bernard Iremonger; +Cc: dev

On 2015/06/11 23:33, Bernard Iremonger wrote:
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> ---
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst |   96 +++++++++++++++++++++++----
>  1 files changed, 82 insertions(+), 14 deletions(-)
>
> diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> index 761172e..fef3ceb 100644
> --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> @@ -1,5 +1,5 @@
>  ..  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
> @@ -866,31 +866,61 @@ Attach a port specified by pci address or virtual device args.
>  To attach a new pci device, the device should be recognized by kernel first.
>  Then it should be moved under DPDK management.
>  Finally the port can be attached to testpmd.
> -On the other hand, to attach a port created by virtual device, above steps are not needed.
> +
> +For example, to move a pci device using ixgbe under DPDK management:
> +
> +.. code-block:: console
> +
> +    ./tools/dpdk_nic_bind.py --status
> +
> +    Network devices using DPDK-compatible driver
> +    ============================================
> +    <none>
> +
> +    Network devices using kernel driver
> +    ===================================
> +    0000:0a:00.0 '82599ES 10-Gigabit SFI/SFP+ Network Connection' if=eth2 drv=ixgbe unused=
> +
> +    ./tools/dpdk_nic_bind.py -b igb_uio 0000:0a:00.0
> +    ./tools/dpdk_nic_bind.py --status
> +
> +    Network devices using DPDK-compatible driver
> +    ============================================
> +    0000:0a:00.0 '82599ES 10-Gigabit SFI/SFP+ Network Connection' drv=igb_uio unused=
> +
> +To attach a port created by virtual device, above steps are not needed.
>  
>  port attach (identifier)
>  
> -For example, to attach a port whose pci address is 0000:02:00.0.
> +For example, to attach a port whose pci address is 0000:0a:00.0.
>  
>  .. code-block:: console
>  
> -    testpmd> port attach 0000:02:00.0
> +    testpmd> port attach 0000:0a:00.0
>      Attaching a new port...
> -    ... snip ...
> +    EAL: PCI device 0000:0a:00.0 on NUMA socket -1
> +    EAL:   probe driver: 8086:10fb rte_ixgbe_pmd
> +    EAL:   PCI memory mapped at 0x7f83bfa00000
> +    EAL:   PCI memory mapped at 0x7f83bfa80000
> +    PMD: eth_ixgbe_dev_init(): MAC: 2, PHY: 18, SFP+: 5
> +    PMD: eth_ixgbe_dev_init(): port 0 vendorID=0x8086 deviceID=0x10fb
>      Port 0 is attached. Now total ports is 1
>      Done
> +    testpmd>
>  
>  For example, to attach a port created by pcap PMD.
>  
>  .. code-block:: console
>  
> -    testpmd> port attach eth_pcap0,iface=eth0
> +    testpmd> port attach eth_pcap0
>      Attaching a new port...
> -    ... snip ...
> +    PMD: Initializing pmd_pcap for eth_pcap0
> +    PMD: Creating pcap-backed ethdev on numa socket 0
>      Port 0 is attached. Now total ports is 1
>      Done
> +    testpmd>
>  
> -In this case, identifier is "eth_pcap0,iface=eth0".
> +In this case, identifier is "eth_pcap0".
>  This identifier format is the same as "--vdev" format of DPDK applications.
>  
>  port detach
> @@ -899,21 +929,59 @@ port detach
>  Detach a specific port.
>  
>  Before detaching a port, the port should be closed.
> -Also to remove a pci device completely from the system, first detach the port from testpmd.
> -Then the device should be moved under kernel management.
> -Finally the device can be removed using kernel pci hotplug functionality.
> -On the other hand, to remove a port created by a virtual device, above steps are not needed.
>  
>  port detach (port_id)
>  
> -For example, to detach a port 0.
> +For example, to detach a pci device port 0.
> +
> +.. code-block:: console
> +
> +    testpmd> port close 0
> +    Closing ports...
> +    Done
> +    testpmd> port detach 0
> +    Detaching a port...
> +    EAL: PCI device 0000:0a:00.0 on NUMA socket -1
> +    EAL:   remove driver: 8086:10fb rte_ixgbe_pmd
> +    EAL:   PCI memory unmapped at 0x7f83bfa00000
> +    EAL:   PCI memory unmapped at 0x7f83bfa80000
> +    Done
> +    testpmd>
> +
> +For example, to detach a virtual device port 0.
>  
>  .. code-block:: console
>  
> +    testpmd> port close 0
> +    Closing ports...
> +    Done
>      testpmd> port detach 0
>      Detaching a port...
> -    ... snip ...
> +    PMD: Closing pcap ethdev on numa socket 0
> +    Port 'eth_pcap0' is detached. Now total ports is 0
>      Done
> +    testpmd>
> +
> +To remove a pci device completely from the system, first detach the port from testpmd.
> +Then the device should be moved under kernel management.
> +Finally the device can be removed using kernel pci hotplug functionality.
> +
> +For example, to move a pci device under kernel management:
> +
> +.. code-block:: console
> +
> +    ./tools/dpdk_nic_bind.py -b ixgbe 0000:0a:00.0
> +    ./tools/dpdk_nic_bind.py --status
> +
> +    Network devices using DPDK-compatible driver
> +    ============================================
> +    <none>
> +
> +    Network devices using kernel driver
> +    ===================================
> +    0000:0a:00.0 '82599ES 10-Gigabit SFI/SFP+ Network Connection' if=eth2 drv=ixgbe unused=igb_uio
> +
> +To remove a port created by a virtual device, above steps are not needed.
>  
>  port start
>  ~~~~~~~~~~

Acked-by: Tetsuya Mukawa <mukawa@igel.co.jp>

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v2 0/2] virtio: PCI Port Hotplug
       [not found] <PATCH>
                   ` (3 preceding siblings ...)
  2015-06-12 16:21 ` [dpdk-dev] [PATCH v3 0/2] bonding PCI Port Hotplug Bernard Iremonger
@ 2015-06-16 11:30 ` Bernard Iremonger
  2015-06-16 11:30   ` [dpdk-dev] [PATCH v3 1/2] virtio: add support for " Bernard Iremonger
  2015-06-16 11:30   ` [dpdk-dev] [PATCH v3 2/2] virtio: check vq parameter Bernard Iremonger
  2015-06-17 11:38 ` [dpdk-dev] [PATCH v4 0/6] i40e: PCI Port Hotplug Changes Bernard Iremonger
                   ` (36 subsequent siblings)
  41 siblings, 2 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-16 11:30 UTC (permalink / raw)
  To: dev

This patchset contains changes to add support for
PCI port hotplug.
It  also contains a fix to virtqueuq_detach_unused().

Bernard Iremonger (2):
  virtio: add support for PCI Port Hotplug
  virtio: check vq parameter

 drivers/net/virtio/virtio_ethdev.c |   83 +++++++++++++++++++++++++++++++++---
 drivers/net/virtio/virtqueue.c     |   14 +++---
 2 files changed, 84 insertions(+), 13 deletions(-)

-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 1/2] virtio: add support for PCI Port Hotplug
  2015-06-16 11:30 ` [dpdk-dev] [PATCH v2 0/2] virtio: " Bernard Iremonger
@ 2015-06-16 11:30   ` Bernard Iremonger
  2015-06-17  1:27     ` Ouyang, Changchun
  2015-06-16 11:30   ` [dpdk-dev] [PATCH v3 2/2] virtio: check vq parameter Bernard Iremonger
  1 sibling, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-16 11:30 UTC (permalink / raw)
  To: dev

This patch depends on the Port Hotplug Framework.
It implements the eth_dev_uninit_t() function for virtio pmd.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/virtio/virtio_ethdev.c |   83 +++++++++++++++++++++++++++++++++---
 1 files changed, 76 insertions(+), 7 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index fe5f9a1..cb35220 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -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
@@ -51,6 +51,7 @@
 #include <rte_pci.h>
 #include <rte_ether.h>
 #include <rte_common.h>
+#include <rte_errno.h>
 
 #include <rte_memory.h>
 #include <rte_eal.h>
@@ -63,6 +64,7 @@
 
 
 static int eth_virtio_dev_init(struct rte_eth_dev *eth_dev);
+static int eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev);
 static int  virtio_dev_configure(struct rte_eth_dev *dev);
 static int  virtio_dev_start(struct rte_eth_dev *dev);
 static void virtio_dev_stop(struct rte_eth_dev *dev);
@@ -324,8 +326,12 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
 	mz = rte_memzone_reserve_aligned(vq_name, vq->vq_ring_size,
 		socket_id, 0, VIRTIO_PCI_VRING_ALIGN);
 	if (mz == NULL) {
-		rte_free(vq);
-		return -ENOMEM;
+		if (rte_errno == EEXIST)
+			mz = rte_memzone_lookup(vq_name);
+		if (mz == NULL) {
+			rte_free(vq);
+			return -ENOMEM;
+		}
 	}
 
 	/*
@@ -358,8 +364,13 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
 			vq_size * hw->vtnet_hdr_size,
 			socket_id, 0, RTE_CACHE_LINE_SIZE);
 		if (vq->virtio_net_hdr_mz == NULL) {
-			rte_free(vq);
-			return -ENOMEM;
+			if (rte_errno == EEXIST)
+				vq->virtio_net_hdr_mz =
+					rte_memzone_lookup(vq_name);
+			if (vq->virtio_net_hdr_mz == NULL) {
+				rte_free(vq);
+				return -ENOMEM;
+			}
 		}
 		vq->virtio_net_hdr_mem =
 			vq->virtio_net_hdr_mz->phys_addr;
@@ -372,8 +383,13 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
 		vq->virtio_net_hdr_mz = rte_memzone_reserve_aligned(vq_name,
 			PAGE_SIZE, socket_id, 0, RTE_CACHE_LINE_SIZE);
 		if (vq->virtio_net_hdr_mz == NULL) {
-			rte_free(vq);
-			return -ENOMEM;
+			if (rte_errno == EEXIST)
+				vq->virtio_net_hdr_mz =
+					rte_memzone_lookup(vq_name);
+			if (vq->virtio_net_hdr_mz == NULL) {
+				rte_free(vq);
+				return -ENOMEM;
+			}
 		}
 		vq->virtio_net_hdr_mem =
 			vq->virtio_net_hdr_mz->phys_addr;
@@ -1250,12 +1266,63 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static int
+eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
+{
+	struct rte_pci_device *pci_dev;
+	struct virtio_hw *hw = eth_dev->data->dev_private;
+	unsigned int i;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rte_eal_process_type() == RTE_PROC_SECONDARY)
+		return -EPERM;
+
+	if (hw->started == 1) {
+		virtio_dev_stop(eth_dev);
+		virtio_dev_close(eth_dev);
+	}
+	pci_dev = eth_dev->pci_dev;
+
+	eth_dev->dev_ops = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+
+	rte_free(hw->cvq);
+	hw->cvq = NULL;
+
+	for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
+		rte_free(eth_dev->data->rx_queues[i]);
+		eth_dev->data->rx_queues[i] = NULL;
+	}
+
+	for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
+		rte_free(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;
+
+	/* reset interrupt callback  */
+	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
+		rte_intr_callback_unregister(&pci_dev->intr_handle,
+						virtio_interrupt_handler,
+						eth_dev);
+
+	PMD_INIT_LOG(DEBUG, "dev_uninit completed");
+
+	return 0;
+}
+
 static struct eth_driver rte_virtio_pmd = {
 	.pci_drv = {
 		.name = "rte_virtio_pmd",
 		.id_table = pci_id_virtio_map,
+		.drv_flags = RTE_PCI_DRV_DETACHABLE,
 	},
 	.eth_dev_init = eth_virtio_dev_init,
+	.eth_dev_uninit = eth_virtio_dev_uninit,
 	.dev_private_size = sizeof(struct virtio_hw),
 };
 
@@ -1398,6 +1465,8 @@ static void virtio_dev_free_mbufs(struct rte_eth_dev *dev)
 			     "Before freeing rxq[%d] used and unused buf", i);
 		VIRTQUEUE_DUMP((struct virtqueue *)dev->data->rx_queues[i]);
 
+		PMD_INIT_LOG(DEBUG, "rx_queues[%d]=%p",
+				i, dev->data->rx_queues[i]);
 		while ((buf = (struct rte_mbuf *)virtqueue_detatch_unused(
 					dev->data->rx_queues[i])) != NULL) {
 			rte_pktmbuf_free(buf);
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 2/2] virtio: check vq parameter
  2015-06-16 11:30 ` [dpdk-dev] [PATCH v2 0/2] virtio: " Bernard Iremonger
  2015-06-16 11:30   ` [dpdk-dev] [PATCH v3 1/2] virtio: add support for " Bernard Iremonger
@ 2015-06-16 11:30   ` Bernard Iremonger
  2015-06-17  1:27     ` Ouyang, Changchun
  1 sibling, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-16 11:30 UTC (permalink / raw)
  To: dev

If vq is NULL, there is a segmentation fault.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/virtio/virtqueue.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/net/virtio/virtqueue.c b/drivers/net/virtio/virtqueue.c
index 8a3005f..7f60e3e 100644
--- a/drivers/net/virtio/virtqueue.c
+++ b/drivers/net/virtio/virtqueue.c
@@ -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
@@ -60,11 +60,13 @@ virtqueue_detatch_unused(struct virtqueue *vq)
 	struct rte_mbuf *cookie;
 	int idx;
 
-	for (idx = 0; idx < vq->vq_nentries; idx++) {
-		if ((cookie = vq->vq_descx[idx].cookie) != NULL) {
-			vq->vq_descx[idx].cookie = NULL;
-			return cookie;
+	if (vq != NULL)
+		for (idx = 0; idx < vq->vq_nentries; idx++) {
+			cookie = vq->vq_descx[idx].cookie;
+			if (cookie != NULL) {
+				vq->vq_descx[idx].cookie = NULL;
+				return cookie;
+			}
 		}
-	}
 	return NULL;
 }
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/2] virtio: add support for PCI Port Hotplug
  2015-06-16 11:30   ` [dpdk-dev] [PATCH v3 1/2] virtio: add support for " Bernard Iremonger
@ 2015-06-17  1:27     ` Ouyang, Changchun
  0 siblings, 0 replies; 270+ messages in thread
From: Ouyang, Changchun @ 2015-06-17  1:27 UTC (permalink / raw)
  To: Iremonger, Bernard, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bernard Iremonger
> Sent: Tuesday, June 16, 2015 7:30 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v3 1/2] virtio: add support for PCI Port Hotplug
> 
> This patch depends on the Port Hotplug Framework.
> It implements the eth_dev_uninit_t() function for virtio pmd.
> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>

Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v3 2/2] virtio: check vq parameter
  2015-06-16 11:30   ` [dpdk-dev] [PATCH v3 2/2] virtio: check vq parameter Bernard Iremonger
@ 2015-06-17  1:27     ` Ouyang, Changchun
  0 siblings, 0 replies; 270+ messages in thread
From: Ouyang, Changchun @ 2015-06-17  1:27 UTC (permalink / raw)
  To: Iremonger, Bernard, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bernard Iremonger
> Sent: Tuesday, June 16, 2015 7:30 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v3 2/2] virtio: check vq parameter
> 
> If vq is NULL, there is a segmentation fault.
> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>

Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v4 0/6] i40e: PCI Port Hotplug Changes
       [not found] <PATCH>
                   ` (4 preceding siblings ...)
  2015-06-16 11:30 ` [dpdk-dev] [PATCH v2 0/2] virtio: " Bernard Iremonger
@ 2015-06-17 11:38 ` Bernard Iremonger
  2015-06-17 11:38   ` [dpdk-dev] [PATCH v4 1/6] i40e: changes to support PCI Port Hotplug Bernard Iremonger
                     ` (2 more replies)
  2015-06-17 11:39 ` [dpdk-dev] [PATCH v4 4/6] i40e: call _clear_cmd() when error occurs Bernard Iremonger
                   ` (35 subsequent siblings)
  41 siblings, 3 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-17 11:38 UTC (permalink / raw)
  To: dev

Changes in V4:
added patch 6 to fix segmentation fault reported by Michael Qiu.

Bernard Iremonger (6):
  i40e: changes to support PCI Port Hotplug
  i40e: release vmdq vsi's in dev_close
  i40e: increase ASQ_DELAY_MS to 100 in i40evf_wait_cmd_done()
  i40e: call _clear_cmd() when error occurs
  i40e: clear queues in i40evf_dev_stop
  i40e: check rxq parameter in i40e_reset_rx_queue

 drivers/net/i40e/i40e_ethdev.c    |   88 ++++++++++++++++++++++++++++++++++++-
 drivers/net/i40e/i40e_ethdev_vf.c |   71 +++++++++++++++++++++++++++---
 drivers/net/i40e/i40e_pf.c        |   34 ++++++++++++++
 drivers/net/i40e/i40e_pf.h        |    1 +
 drivers/net/i40e/i40e_rxtx.c      |    5 ++
 5 files changed, 192 insertions(+), 7 deletions(-)

-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v4 1/6] i40e: changes to support PCI Port Hotplug
  2015-06-17 11:38 ` [dpdk-dev] [PATCH v4 0/6] i40e: PCI Port Hotplug Changes Bernard Iremonger
@ 2015-06-17 11:38   ` Bernard Iremonger
  2015-06-17 11:38   ` [dpdk-dev] [PATCH v4 2/6] i40e: release vmdq vsi's in dev_close Bernard Iremonger
  2015-06-17 11:38   ` [dpdk-dev] [PATCH v4 3/6] i40e: increase ASQ_DELAY_MS to 100 in i40evf_wait_cmd_done() Bernard Iremonger
  2 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-17 11:38 UTC (permalink / raw)
  To: dev

This patch depends on the Port Hotplug Framework.
It implements the eth_dev_uninit functions for rte_i40e_pmd and
rte_i40evf_pmd.

Changes in V4:
Rebase to latest i40e code.

Changes in V3:
Release rx and tx queues in vf uninit function.
Rebase to use latest i40e code.

Changes in V2:
Rebase to use drivers/net/i40e directory.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c    |   79 ++++++++++++++++++++++++++++++++++++-
 drivers/net/i40e/i40e_ethdev_vf.c |   57 ++++++++++++++++++++++++++-
 drivers/net/i40e/i40e_pf.c        |   34 ++++++++++++++++
 drivers/net/i40e/i40e_pf.h        |    1 +
 4 files changed, 169 insertions(+), 2 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 2ada502..6e2030c 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -107,6 +107,7 @@
 	(1UL << RTE_ETH_FLOW_L2_PAYLOAD))
 
 static int eth_i40e_dev_init(struct rte_eth_dev *eth_dev);
+static int eth_i40e_dev_uninit(struct rte_eth_dev *eth_dev);
 static int i40e_dev_configure(struct rte_eth_dev *dev);
 static int i40e_dev_start(struct rte_eth_dev *dev);
 static void i40e_dev_stop(struct rte_eth_dev *dev);
@@ -268,9 +269,11 @@ static struct eth_driver rte_i40e_pmd = {
 	.pci_drv = {
 		.name = "rte_i40e_pmd",
 		.id_table = pci_id_i40e_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_i40e_dev_init,
+	.eth_dev_uninit = eth_i40e_dev_uninit,
 	.dev_private_size = sizeof(struct i40e_adapter),
 };
 
@@ -405,6 +408,7 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 	hw->subsystem_device_id = pci_dev->id.subsystem_device_id;
 	hw->bus.device = pci_dev->addr.devid;
 	hw->bus.func = pci_dev->addr.function;
+	hw->adapter_stopped = 0;
 
 	/* Make sure all is clean before doing PF reset */
 	i40e_clear_hw(hw);
@@ -584,6 +588,76 @@ err_get_capabilities:
 }
 
 static int
+eth_i40e_dev_uninit(struct rte_eth_dev *dev)
+{
+	struct rte_pci_device *pci_dev;
+	struct i40e_hw *hw;
+	struct i40e_filter_control_settings settings;
+	int ret;
+	uint8_t aq_fail = 0;
+	unsigned i;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
+	hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	pci_dev = dev->pci_dev;
+
+	if (hw->adapter_stopped == 0)
+		i40e_dev_close(dev);
+
+	dev->dev_ops = NULL;
+	dev->rx_pkt_burst = NULL;
+	dev->tx_pkt_burst = NULL;
+
+	/* Disable LLDP */
+	ret = i40e_aq_stop_lldp(hw, true, NULL);
+	if (ret != I40E_SUCCESS) /* Its failure can be ignored */
+		PMD_INIT_LOG(INFO, "Failed to stop lldp");
+
+	/* Clear PXE mode */
+	i40e_clear_pxe_mode(hw);
+
+	/* Unconfigure filter control */
+	memset(&settings, 0, sizeof(settings));
+	ret = i40e_set_filter_control(hw, &settings);
+	if (ret)
+		PMD_INIT_LOG(WARNING, "setup_pf_filter_control failed: %d",
+					ret);
+
+	/* Disable flow control */
+	hw->fc.requested_mode = I40E_FC_NONE;
+	i40e_set_fc(hw, &aq_fail, TRUE);
+
+	/* uninitialize pf host driver */
+	i40e_pf_host_uninit(dev);
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		i40e_dev_rx_queue_release(dev->data->rx_queues[i]);
+		dev->data->rx_queues[i] = NULL;
+	}
+
+	for (i = 0; i < dev->data->nb_tx_queues; i++) {
+		i40e_dev_tx_queue_release(dev->data->tx_queues[i]);
+		dev->data->tx_queues[i] = NULL;
+	}
+
+	rte_free(dev->data->mac_addrs);
+	dev->data->mac_addrs = NULL;
+
+	/* disable uio intr before callback unregister */
+	rte_intr_disable(&(pci_dev->intr_handle));
+
+	/* register callback func to eal lib */
+	rte_intr_callback_unregister(&(pci_dev->intr_handle),
+		i40e_dev_interrupt_handler, (void *)dev);
+
+	return 0;
+}
+
+static int
 i40e_dev_configure(struct rte_eth_dev *dev)
 {
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
@@ -858,6 +932,8 @@ i40e_dev_start(struct rte_eth_dev *dev)
 	struct i40e_vsi *main_vsi = pf->main_vsi;
 	int ret, i;
 
+	hw->adapter_stopped = 0;
+
 	if ((dev->data->dev_conf.link_duplex != ETH_LINK_AUTONEG_DUPLEX) &&
 		(dev->data->dev_conf.link_duplex != ETH_LINK_FULL_DUPLEX)) {
 		PMD_INIT_LOG(ERR, "Invalid link_duplex (%hu) for port %hhu",
@@ -965,6 +1041,7 @@ i40e_dev_close(struct rte_eth_dev *dev)
 	PMD_INIT_FUNC_TRACE();
 
 	i40e_dev_stop(dev);
+	hw->adapter_stopped = 1;
 
 	/* Disable interrupt */
 	i40e_pf_disable_irq0(hw);
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index f7332e7..ed320e1 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1146,6 +1146,22 @@ err:
 }
 
 static int
+i40evf_uninit_vf(struct rte_eth_dev *dev)
+{
+	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (hw->adapter_stopped == 0)
+		i40evf_dev_close(dev);
+	rte_free(vf->vf_res);
+	vf->vf_res = NULL;
+
+	return 0;
+}
+
+static int
 i40evf_dev_init(struct rte_eth_dev *eth_dev)
 {
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(\
@@ -1175,6 +1191,7 @@ i40evf_dev_init(struct rte_eth_dev *eth_dev)
 	hw->bus.device = eth_dev->pci_dev->addr.devid;
 	hw->bus.func = eth_dev->pci_dev->addr.function;
 	hw->hw_addr = (void *)eth_dev->pci_dev->mem_resource[0].addr;
+	hw->adapter_stopped = 0;
 
 	if(i40evf_init_vf(eth_dev) != 0) {
 		PMD_INIT_LOG(ERR, "Init vf failed");
@@ -1195,6 +1212,40 @@ i40evf_dev_init(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static int
+i40evf_dev_uninit(struct rte_eth_dev *eth_dev)
+{
+	unsigned i;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return -EPERM;
+
+	eth_dev->dev_ops = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+
+	if (i40evf_uninit_vf(eth_dev) != 0) {
+		PMD_INIT_LOG(ERR, "i40evf_uninit_vf failed");
+		return -1;
+	}
+
+	for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
+		i40e_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++) {
+		i40e_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;
+}
 /*
  * virtual function driver struct
  */
@@ -1202,9 +1253,10 @@ static struct eth_driver rte_i40evf_pmd = {
 	.pci_drv = {
 		.name = "rte_i40evf_pmd",
 		.id_table = pci_id_i40evf_map,
-		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
 	},
 	.eth_dev_init = i40evf_dev_init,
+	.eth_dev_uninit = i40evf_dev_uninit,
 	.dev_private_size = sizeof(struct i40e_vf),
 };
 
@@ -1524,6 +1576,8 @@ i40evf_dev_start(struct rte_eth_dev *dev)
 
 	PMD_INIT_FUNC_TRACE();
 
+	hw->adapter_stopped = 0;
+
 	vf->max_pkt_len = dev->data->dev_conf.rxmode.max_rx_pkt_len;
 	vf->num_queue_pairs = RTE_MAX(dev->data->nb_rx_queues,
 					dev->data->nb_tx_queues);
@@ -1709,6 +1763,7 @@ i40evf_dev_close(struct rte_eth_dev *dev)
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
 	i40evf_dev_stop(dev);
+	hw->adapter_stopped = 1;
 	i40evf_reset_vf(hw);
 	i40e_shutdown_adminq(hw);
 }
diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index b89a1e2..95c960c 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -1061,3 +1061,37 @@ fail:
 
 	return ret;
 }
+
+int
+i40e_pf_host_uninit(struct rte_eth_dev *dev)
+{
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+	uint32_t val;
+
+	PMD_INIT_FUNC_TRACE();
+
+	/**
+	 * return if SRIOV not enabled, VF number not configured or
+	 * no queue assigned.
+	 */
+	if ((!hw->func_caps.sr_iov_1_1) ||
+		(pf->vf_num == 0) ||
+		(pf->vf_nb_qps == 0))
+		return I40E_SUCCESS;
+
+	/* free memory to store VF structure */
+	rte_free(pf->vfs);
+	pf->vfs = NULL;
+
+	/* Disable irq0 for VFR event */
+	i40e_pf_disable_irq0(hw);
+
+	/* Disable VF link status interrupt */
+	val = I40E_READ_REG(hw, I40E_PFGEN_PORTMDIO_NUM);
+	val &= ~I40E_PFGEN_PORTMDIO_NUM_VFLINK_STAT_ENA_MASK;
+	I40E_WRITE_REG(hw, I40E_PFGEN_PORTMDIO_NUM, val);
+	I40E_WRITE_FLUSH(hw);
+
+	return I40E_SUCCESS;
+}
diff --git a/drivers/net/i40e/i40e_pf.h b/drivers/net/i40e/i40e_pf.h
index e08ba49..9c01829 100644
--- a/drivers/net/i40e/i40e_pf.h
+++ b/drivers/net/i40e/i40e_pf.h
@@ -123,5 +123,6 @@ void i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev,
 				__rte_unused uint32_t retval,
 				uint8_t *msg, uint16_t msglen);
 int i40e_pf_host_init(struct rte_eth_dev *dev);
+int i40e_pf_host_uninit(struct rte_eth_dev *dev);
 
 #endif /* _I40E_PF_H_ */
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v4 2/6] i40e: release vmdq vsi's in dev_close
  2015-06-17 11:38 ` [dpdk-dev] [PATCH v4 0/6] i40e: PCI Port Hotplug Changes Bernard Iremonger
  2015-06-17 11:38   ` [dpdk-dev] [PATCH v4 1/6] i40e: changes to support PCI Port Hotplug Bernard Iremonger
@ 2015-06-17 11:38   ` Bernard Iremonger
  2015-06-17 11:38   ` [dpdk-dev] [PATCH v4 3/6] i40e: increase ASQ_DELAY_MS to 100 in i40evf_wait_cmd_done() Bernard Iremonger
  2 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-17 11:38 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 6e2030c..58b18d0 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -1037,6 +1037,7 @@ i40e_dev_close(struct rte_eth_dev *dev)
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	uint32_t reg;
+	int i;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -1054,6 +1055,14 @@ i40e_dev_close(struct rte_eth_dev *dev)
 	i40e_fdir_teardown(pf);
 	i40e_vsi_release(pf->main_vsi);
 
+	for (i = 0; i < pf->nb_cfg_vmdq_vsi; i++) {
+		i40e_vsi_release(pf->vmdq[i].vsi);
+		pf->vmdq[i].vsi = NULL;
+	}
+
+	rte_free(pf->vmdq);
+	pf->vmdq = NULL;
+
 	/* shutdown the adminq */
 	i40e_aq_queue_shutdown(hw, true);
 	i40e_shutdown_adminq(hw);
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v4 3/6] i40e: increase ASQ_DELAY_MS to 100 in i40evf_wait_cmd_done()
  2015-06-17 11:38 ` [dpdk-dev] [PATCH v4 0/6] i40e: PCI Port Hotplug Changes Bernard Iremonger
  2015-06-17 11:38   ` [dpdk-dev] [PATCH v4 1/6] i40e: changes to support PCI Port Hotplug Bernard Iremonger
  2015-06-17 11:38   ` [dpdk-dev] [PATCH v4 2/6] i40e: release vmdq vsi's in dev_close Bernard Iremonger
@ 2015-06-17 11:38   ` Bernard Iremonger
  2 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-17 11:38 UTC (permalink / raw)
  To: dev

Increase delay to avoid i40evf_read_pfmsg() failures.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/i40e/i40e_ethdev_vf.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index ed320e1..7a6480a 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -299,7 +299,7 @@ i40evf_wait_cmd_done(struct rte_eth_dev *dev,
 	enum i40evf_aq_result ret;
 
 #define MAX_TRY_TIMES 10
-#define ASQ_DELAY_MS  50
+#define ASQ_DELAY_MS  100
 	do {
 		/* Delay some time first */
 		rte_delay_ms(ASQ_DELAY_MS);
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v4 4/6] i40e: call _clear_cmd() when error occurs
       [not found] <PATCH>
                   ` (5 preceding siblings ...)
  2015-06-17 11:38 ` [dpdk-dev] [PATCH v4 0/6] i40e: PCI Port Hotplug Changes Bernard Iremonger
@ 2015-06-17 11:39 ` Bernard Iremonger
  2015-06-17 11:39   ` [dpdk-dev] [PATCH v4 5/6] i40e: clear queues in i40evf_dev_stop Bernard Iremonger
  2015-06-17 11:39   ` [dpdk-dev] [PATCH v4 6/6] i40e: check rxq parameter in i40e_reset_rx_queue Bernard Iremonger
  2015-06-18 12:44 ` [dpdk-dev] [PATCH v5] e1000: igb and em1000 PCI Port Hotplug changes Bernard Iremonger
                   ` (34 subsequent siblings)
  41 siblings, 2 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-17 11:39 UTC (permalink / raw)
  To: dev

_clear_cmd() was not being called in failure situations,
resulting in the next command also failing.
Fix several typos.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/i40e/i40e_ethdev_vf.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 7a6480a..1b9362f 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -361,6 +361,7 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
 		     args->in_args, args->in_args_size, NULL);
 	if (err) {
 		PMD_DRV_LOG(ERR, "fail to send cmd %d", args->ops);
+		_clear_cmd(vf);
 		return err;
 	}
 
@@ -368,8 +369,10 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
 	/* read message and it's expected one */
 	if (!err && args->ops == info.ops)
 		_clear_cmd(vf);
-	else if (err)
+	else if (err) {
 		PMD_DRV_LOG(ERR, "Failed to read message from AdminQ");
+		_clear_cmd(vf);
+	}
 	else if (args->ops != info.ops)
 		PMD_DRV_LOG(ERR, "command mismatch, expect %u, get %u",
 			    args->ops, info.ops);
@@ -794,7 +797,7 @@ i40evf_stop_queues(struct rte_eth_dev *dev)
 	/* Stop TX queues first */
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
 		if (i40evf_dev_tx_queue_stop(dev, i) != 0) {
-			PMD_DRV_LOG(ERR, "Fail to start queue %u", i);
+			PMD_DRV_LOG(ERR, "Fail to stop queue %u", i);
 			return -1;
 		}
 	}
@@ -802,7 +805,7 @@ i40evf_stop_queues(struct rte_eth_dev *dev)
 	/* Then stop RX queues */
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		if (i40evf_dev_rx_queue_stop(dev, i) != 0) {
-			PMD_DRV_LOG(ERR, "Fail to start queue %u", i);
+			PMD_DRV_LOG(ERR, "Fail to stop queue %u", i);
 			return -1;
 		}
 	}
@@ -1443,7 +1446,7 @@ i40evf_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 		err = i40evf_switch_queue(dev, FALSE, tx_queue_id, FALSE);
 
 		if (err) {
-			PMD_DRV_LOG(ERR, "Failed to switch TX queue %u of",
+			PMD_DRV_LOG(ERR, "Failed to switch TX queue %u off",
 				    tx_queue_id);
 			return err;
 		}
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v4 5/6] i40e: clear queues in i40evf_dev_stop
  2015-06-17 11:39 ` [dpdk-dev] [PATCH v4 4/6] i40e: call _clear_cmd() when error occurs Bernard Iremonger
@ 2015-06-17 11:39   ` Bernard Iremonger
  2015-06-17 11:39   ` [dpdk-dev] [PATCH v4 6/6] i40e: check rxq parameter in i40e_reset_rx_queue Bernard Iremonger
  1 sibling, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-17 11:39 UTC (permalink / raw)
  To: dev

Changes in V3:
This patch added.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/i40e/i40e_ethdev_vf.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 1b9362f..26d0502 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1632,6 +1632,7 @@ i40evf_dev_stop(struct rte_eth_dev *dev)
 
 	i40evf_disable_queues_intr(hw);
 	i40evf_stop_queues(dev);
+	i40e_dev_clear_queues(dev);
 }
 
 static int
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v4 6/6] i40e: check rxq parameter in i40e_reset_rx_queue
  2015-06-17 11:39 ` [dpdk-dev] [PATCH v4 4/6] i40e: call _clear_cmd() when error occurs Bernard Iremonger
  2015-06-17 11:39   ` [dpdk-dev] [PATCH v4 5/6] i40e: clear queues in i40evf_dev_stop Bernard Iremonger
@ 2015-06-17 11:39   ` Bernard Iremonger
  1 sibling, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-17 11:39 UTC (permalink / raw)
  To: dev

There is a segmentation fault if rxq is NULL

Changes in V4:
This patch added.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/i40e/i40e_rxtx.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 2de0ac4..2a89e84 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -2269,6 +2269,11 @@ i40e_reset_rx_queue(struct i40e_rx_queue *rxq)
 	unsigned i;
 	uint16_t len;
 
+	if (!rxq) {
+		PMD_DRV_LOG(DEBUG, "Pointer to rxq is NULL");
+		return;
+	}
+
 #ifdef RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC
 	if (check_rx_burst_bulk_alloc_preconditions(rxq) == 0)
 		len = (uint16_t)(rxq->nb_rx_desc + RTE_PMD_I40E_RX_MAX_BURST);
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v5] e1000: igb and em1000 PCI Port Hotplug changes
       [not found] <PATCH>
                   ` (6 preceding siblings ...)
  2015-06-17 11:39 ` [dpdk-dev] [PATCH v4 4/6] i40e: call _clear_cmd() when error occurs Bernard Iremonger
@ 2015-06-18 12:44 ` Bernard Iremonger
  2015-06-19 17:03 ` [dpdk-dev] [PATCH v5 0/6] i40e: PCI Port Hotplug Changes Bernard Iremonger
                   ` (33 subsequent siblings)
  41 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-18 12:44 UTC (permalink / raw)
  To: dev

This patch depends on the Port Hotplug Framework.
It implements the eth_dev_uninit functions for rte_em_pmd,
rte_igb_pmd and rte_igbvf_pmd.

Changes in V5:
Moved adapter stopped boolean to struct e1000_adapter.
Rebase to latest code.

Changes in V4:
Release rx and tx queues in eth_igbvf_dev_uninit.

Changes in V3:
Add igb_adapter_stopped and em_adapter_stopped booleans.
Release rx and tx queues in eth_igb_dev_uninit.

Changes in V2:
Call dev_close() from  dev_uninit() functions.
Remove input parameter checking from dev_uninit() functions.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/e1000/e1000_ethdev.h |    8 ++-
 drivers/net/e1000/em_ethdev.c    |   57 ++++++++++++++++++-
 drivers/net/e1000/igb_ethdev.c   |  115 +++++++++++++++++++++++++++++++++++++-
 drivers/net/e1000/igb_pf.c       |   22 +++++++
 4 files changed, 197 insertions(+), 5 deletions(-)

diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h
index c451faa..ee8b872 100644
--- a/drivers/net/e1000/e1000_ethdev.h
+++ b/drivers/net/e1000/e1000_ethdev.h
@@ -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
@@ -229,8 +229,12 @@ struct e1000_adapter {
 	struct e1000_vfta       shadow_vfta;
 	struct e1000_vf_info    *vfdata;
 	struct e1000_filter_info filter;
+	bool stopped;
 };
 
+#define E1000_DEV_PRIVATE(adapter) \
+	((struct e1000_adapter *)adapter)
+
 #define E1000_DEV_PRIVATE_TO_HW(adapter) \
 	(&((struct e1000_adapter *)adapter)->hw)
 
@@ -337,4 +341,6 @@ uint16_t eth_em_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 uint16_t eth_em_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		uint16_t nb_pkts);
 
+void igb_pf_host_uninit(struct rte_eth_dev *dev);
+
 #endif /* _E1000_ETHDEV_H_ */
diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index a306c55..0f471c2 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -224,6 +224,8 @@ static int
 eth_em_dev_init(struct rte_eth_dev *eth_dev)
 {
 	struct rte_pci_device *pci_dev;
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(eth_dev->data->dev_private);
 	struct e1000_hw *hw =
 		E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 	struct e1000_vfta * shadow_vfta =
@@ -246,6 +248,7 @@ eth_em_dev_init(struct rte_eth_dev *eth_dev)
 
 	hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
 	hw->device_id = pci_dev->id.device_id;
+	adapter->stopped = 0;
 
 	/* For ICH8 support we'll need to map the flash memory BAR */
 
@@ -285,13 +288,58 @@ eth_em_dev_init(struct rte_eth_dev *eth_dev)
 	return (0);
 }
 
+static int
+eth_em_dev_uninit(struct rte_eth_dev *eth_dev)
+{
+	struct rte_pci_device *pci_dev;
+	unsigned i;
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(eth_dev->data->dev_private);
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return -EPERM;
+
+	pci_dev = eth_dev->pci_dev;
+
+	if (adapter->stopped == 0)
+		eth_em_close(eth_dev);
+
+	eth_dev->dev_ops = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+
+	rte_free(eth_dev->data->mac_addrs);
+	eth_dev->data->mac_addrs = NULL;
+
+	for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
+		eth_em_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++) {
+		eth_em_tx_queue_release(eth_dev->data->tx_queues[i]);
+		eth_dev->data->tx_queues[i] = NULL;
+	}
+
+	/* disable uio intr before callback unregister */
+	rte_intr_disable(&(pci_dev->intr_handle));
+	rte_intr_callback_unregister(&(pci_dev->intr_handle),
+		eth_em_interrupt_handler, (void *)eth_dev);
+
+	return 0;
+}
+
 static struct eth_driver rte_em_pmd = {
 	.pci_drv = {
 		.name = "rte_em_pmd",
 		.id_table = pci_id_em_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_em_dev_init,
+	.eth_dev_uninit = eth_em_dev_uninit,
 	.dev_private_size = sizeof(struct e1000_adapter),
 };
 
@@ -451,6 +499,8 @@ em_set_pba(struct e1000_hw *hw)
 static int
 eth_em_start(struct rte_eth_dev *dev)
 {
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(dev->data->dev_private);
 	struct e1000_hw *hw =
 		E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	int ret, mask;
@@ -570,6 +620,8 @@ eth_em_start(struct rte_eth_dev *dev)
 		}
 	}
 
+	adapter->stopped = 0;
+
 	PMD_INIT_LOG(DEBUG, "<<");
 
 	return (0);
@@ -613,8 +665,11 @@ static void
 eth_em_close(struct rte_eth_dev *dev)
 {
 	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(dev->data->dev_private);
 
 	eth_em_stop(dev);
+	adapter->stopped = 1;
 	e1000_phy_hw_reset(hw);
 	em_release_manageability(hw);
 	em_hw_control_release(hw);
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 24c7510..ffd849d 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -465,9 +465,12 @@ eth_igb_dev_init(struct rte_eth_dev *eth_dev)
 	struct e1000_hw *hw =
 		E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 	struct e1000_vfta * shadow_vfta =
-			E1000_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
+		E1000_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
 	struct e1000_filter_info *filter_info =
 		E1000_DEV_PRIVATE_TO_FILTER_INFO(eth_dev->data->dev_private);
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(eth_dev->data->dev_private);
+
 	uint32_t ctrl_ext;
 
 	pci_dev = eth_dev->pci_dev;
@@ -570,6 +573,7 @@ eth_igb_dev_init(struct rte_eth_dev *eth_dev)
 		goto err_late;
 	}
 	hw->mac.get_link_status = 1;
+	adapter->stopped = 0;
 
 	/* Indicate SOL/IDER usage */
 	if (e1000_check_reset_block(hw) < 0) {
@@ -614,6 +618,57 @@ err_late:
 	return (error);
 }
 
+static int
+eth_igb_dev_uninit(struct rte_eth_dev *eth_dev)
+{
+	struct rte_pci_device *pci_dev;
+	struct e1000_hw *hw;
+	unsigned i;
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(eth_dev->data->dev_private);
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return -EPERM;
+
+	hw = E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	pci_dev = eth_dev->pci_dev;
+
+	if (adapter->stopped == 0)
+		eth_igb_close(eth_dev);
+
+	eth_dev->dev_ops = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+
+	for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
+		eth_igb_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++) {
+		eth_igb_tx_queue_release(eth_dev->data->tx_queues[i]);
+		eth_dev->data->tx_queues[i] = NULL;
+	}
+
+	/* Reset any pending lock */
+	igb_reset_swfw_lock(hw);
+
+	rte_free(eth_dev->data->mac_addrs);
+	eth_dev->data->mac_addrs = NULL;
+
+	/* uninitialize PF if max_vfs not zero */
+	igb_pf_host_uninit(eth_dev);
+
+	/* disable uio intr before callback unregister */
+	rte_intr_disable(&(pci_dev->intr_handle));
+	rte_intr_callback_unregister(&(pci_dev->intr_handle),
+		eth_igb_interrupt_handler, (void *)eth_dev);
+
+	return 0;
+}
+
 /*
  * Virtual Function device init
  */
@@ -621,6 +676,8 @@ static int
 eth_igbvf_dev_init(struct rte_eth_dev *eth_dev)
 {
 	struct rte_pci_device *pci_dev;
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(eth_dev->data->dev_private);
 	struct e1000_hw *hw =
 		E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 	int diag;
@@ -645,6 +702,7 @@ eth_igbvf_dev_init(struct rte_eth_dev *eth_dev)
 	hw->device_id = pci_dev->id.device_id;
 	hw->vendor_id = pci_dev->id.vendor_id;
 	hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
+	adapter->stopped = 0;
 
 	/* Initialize the shared code (base driver) */
 	diag = e1000_setup_init_funcs(hw, TRUE);
@@ -685,13 +743,50 @@ eth_igbvf_dev_init(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static int
+eth_igbvf_dev_uninit(struct rte_eth_dev *eth_dev)
+{
+	unsigned i;
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(eth_dev->data->dev_private);
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return -EPERM;
+
+	if (adapter->stopped == 0)
+		igbvf_dev_close(eth_dev);
+
+	eth_dev->dev_ops = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+
+	for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
+		eth_igb_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++) {
+		eth_igb_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_igb_pmd = {
 	.pci_drv = {
 		.name = "rte_igb_pmd",
 		.id_table = pci_id_igb_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_igb_dev_init,
+	.eth_dev_uninit = eth_igb_dev_uninit,
 	.dev_private_size = sizeof(struct e1000_adapter),
 };
 
@@ -702,9 +797,10 @@ static struct eth_driver rte_igbvf_pmd = {
 	.pci_drv = {
 		.name = "rte_igbvf_pmd",
 		.id_table = pci_id_igbvf_map,
-		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
 	},
 	.eth_dev_init = eth_igbvf_dev_init,
+	.eth_dev_uninit = eth_igbvf_dev_uninit,
 	.dev_private_size = sizeof(struct e1000_adapter),
 };
 
@@ -758,6 +854,8 @@ eth_igb_start(struct rte_eth_dev *dev)
 {
 	struct e1000_hw *hw =
 		E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(dev->data->dev_private);
 	int ret, i, mask;
 	uint32_t ctrl_ext;
 
@@ -786,6 +884,7 @@ eth_igb_start(struct rte_eth_dev *dev)
 		PMD_INIT_LOG(ERR, "Unable to initialize the hardware");
 		return (-EIO);
 	}
+	adapter->stopped = 0;
 
 	E1000_WRITE_REG(hw, E1000_VET, ETHER_TYPE_VLAN << 16 | ETHER_TYPE_VLAN);
 
@@ -992,9 +1091,13 @@ static void
 eth_igb_close(struct rte_eth_dev *dev)
 {
 	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(dev->data->dev_private);
 	struct rte_eth_link link;
 
 	eth_igb_stop(dev);
+	adapter->stopped = 1;
+
 	e1000_phy_hw_reset(hw);
 	igb_release_manageability(hw);
 	igb_hw_control_release(hw);
@@ -2228,11 +2331,14 @@ igbvf_dev_start(struct rte_eth_dev *dev)
 {
 	struct e1000_hw *hw =
 		E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(dev->data->dev_private);
 	int ret;
 
 	PMD_INIT_FUNC_TRACE();
 
 	hw->mac.ops.reset_hw(hw);
+	adapter->stopped = 0;
 
 	/* Set all vfta */
 	igbvf_set_vfta_all(dev,1);
@@ -2270,12 +2376,15 @@ static void
 igbvf_dev_close(struct rte_eth_dev *dev)
 {
 	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(dev->data->dev_private);
 
 	PMD_INIT_FUNC_TRACE();
 
 	e1000_reset_hw(hw);
 
 	igbvf_dev_stop(dev);
+	adapter->stopped = 1;
 }
 
 static int igbvf_set_vfta(struct e1000_hw *hw, uint16_t vid, bool on)
diff --git a/drivers/net/e1000/igb_pf.c b/drivers/net/e1000/igb_pf.c
index 6a4d210..26c2960 100644
--- a/drivers/net/e1000/igb_pf.c
+++ b/drivers/net/e1000/igb_pf.c
@@ -127,6 +127,28 @@ void igb_pf_host_init(struct rte_eth_dev *eth_dev)
 	return;
 }
 
+void igb_pf_host_uninit(struct rte_eth_dev *dev)
+{
+	struct e1000_vf_info **vfinfo;
+	uint16_t vf_num;
+
+	PMD_INIT_FUNC_TRACE();
+
+	vfinfo = E1000_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
+
+	RTE_ETH_DEV_SRIOV(dev).active = 0;
+	RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = 0;
+	RTE_ETH_DEV_SRIOV(dev).def_vmdq_idx = 0;
+	RTE_ETH_DEV_SRIOV(dev).def_pool_q_idx = 0;
+
+	vf_num = dev_num_vf(dev);
+	if (vf_num == 0)
+		return;
+
+	rte_free(*vfinfo);
+	*vfinfo = NULL;
+}
+
 #define E1000_RAH_POOLSEL_SHIFT    (18)
 int igb_pf_host_configure(struct rte_eth_dev *eth_dev)
 {
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v3 0/2] bonding PCI Port Hotplug
  2015-06-12 16:21 ` [dpdk-dev] [PATCH v3 0/2] bonding PCI Port Hotplug Bernard Iremonger
  2015-06-12 16:21   ` [dpdk-dev] [PATCH v3 1/2] bonding: add support for " Bernard Iremonger
  2015-06-12 16:21   ` [dpdk-dev] [PATCH v3 2/2] test-pmd: modified testpmd for link_bonding Bernard Iremonger
@ 2015-06-19 16:33   ` Declan Doherty
  2 siblings, 0 replies; 270+ messages in thread
From: Declan Doherty @ 2015-06-19 16:33 UTC (permalink / raw)
  To: Bernard Iremonger, dev

On 12/06/15 17:21, Bernard Iremonger wrote:
> Changes in V3:
> Modified testpmd to handle attach/detach of bonding pmd.
>
> Bernard Iremonger (2):
>    bonding: add support for PCI Port Hotplug
>    test-pmd: modified testpmd for link_bonding
>
>   app/test-pmd/cmdline.c                     |    4 +-
>   app/test-pmd/testpmd.c                     |   24 +++++++-
>   app/test-pmd/testpmd.h                     |    7 ++-
>   drivers/net/bonding/rte_eth_bond.h         |   13 ++++-
>   drivers/net/bonding/rte_eth_bond_api.c     |   82 +++++++++++++++++++---------
>   drivers/net/bonding/rte_eth_bond_pmd.c     |   23 +++++++-
>   drivers/net/bonding/rte_eth_bond_private.h |    7 ++-
>   7 files changed, 124 insertions(+), 36 deletions(-)
>

Acked-by: Declan Doherty <declan.doherty@intel.com>

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v5 0/6] i40e: PCI Port Hotplug Changes
       [not found] <PATCH>
                   ` (7 preceding siblings ...)
  2015-06-18 12:44 ` [dpdk-dev] [PATCH v5] e1000: igb and em1000 PCI Port Hotplug changes Bernard Iremonger
@ 2015-06-19 17:03 ` Bernard Iremonger
  2015-06-19 17:03   ` [dpdk-dev] [PATCH v5 1/6] i40e: changes to support PCI Port Hotplug Bernard Iremonger
                     ` (6 more replies)
  2015-06-22 10:44 ` [dpdk-dev] [PATCH v6] e1000: igb and em1000 PCI Port Hotplug changes Bernard Iremonger
                   ` (32 subsequent siblings)
  41 siblings, 7 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-19 17:03 UTC (permalink / raw)
  To: dev

Changes in V5:
Increased timeout in i40evf_wait_cmd_done()
Set nb_rx_queues and nb_tx_queues to 0 in uninit functions.
Rebased to latest i40e code.

Changes in V4:
added patch 6 to fix segmentation fault reported by Michael Qiu.
Rebase to latest i40e code.

Changes in V3:
Release rx and tx queues in vf uninit function.
Rebase to use latest i40e code.

Changes in V2:
Rebase to use drivers/net/i40e directory.

Bernard Iremonger (6):
  i40e: changes to support PCI Port Hotplug
  i40e: release vmdq vsi's in dev_close
  i40e: increase ASQ_DELAY_MS to 100 in i40evf_wait_cmd_done()
  i40e: call _clear_cmd() when error occurs
  i40e: clear queues in i40evf_dev_stop
  i40e: check rxq parameter in i40e_reset_rx_queue

 drivers/net/i40e/i40e_ethdev.c    |   88 ++++++++++++++++++++++++++++++++++++-
 drivers/net/i40e/i40e_ethdev_vf.c |   71 +++++++++++++++++++++++++++---
 drivers/net/i40e/i40e_pf.c        |   34 ++++++++++++++
 drivers/net/i40e/i40e_pf.h        |    1 +
 drivers/net/i40e/i40e_rxtx.c      |    5 ++
 5 files changed, 192 insertions(+), 7 deletions(-)

-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v5 1/6] i40e: changes to support PCI Port Hotplug
  2015-06-19 17:03 ` [dpdk-dev] [PATCH v5 0/6] i40e: PCI Port Hotplug Changes Bernard Iremonger
@ 2015-06-19 17:03   ` Bernard Iremonger
  2015-06-19 17:03   ` [dpdk-dev] [PATCH v5 2/6] i40e: release vmdq vsi's in dev_close Bernard Iremonger
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-19 17:03 UTC (permalink / raw)
  To: dev

This patch depends on the Port Hotplug Framework.
It implements the eth_dev_uninit functions for rte_i40e_pmd and
rte_i40evf_pmd.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c    |   81 ++++++++++++++++++++++++++++++++++++-
 drivers/net/i40e/i40e_ethdev_vf.c |   59 ++++++++++++++++++++++++++-
 drivers/net/i40e/i40e_pf.c        |   34 +++++++++++++++
 drivers/net/i40e/i40e_pf.h        |    1 +
 4 files changed, 173 insertions(+), 2 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 2ada502..9ae68d6 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -107,6 +107,7 @@
 	(1UL << RTE_ETH_FLOW_L2_PAYLOAD))
 
 static int eth_i40e_dev_init(struct rte_eth_dev *eth_dev);
+static int eth_i40e_dev_uninit(struct rte_eth_dev *eth_dev);
 static int i40e_dev_configure(struct rte_eth_dev *dev);
 static int i40e_dev_start(struct rte_eth_dev *dev);
 static void i40e_dev_stop(struct rte_eth_dev *dev);
@@ -268,9 +269,11 @@ static struct eth_driver rte_i40e_pmd = {
 	.pci_drv = {
 		.name = "rte_i40e_pmd",
 		.id_table = pci_id_i40e_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_i40e_dev_init,
+	.eth_dev_uninit = eth_i40e_dev_uninit,
 	.dev_private_size = sizeof(struct i40e_adapter),
 };
 
@@ -405,6 +408,7 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 	hw->subsystem_device_id = pci_dev->id.subsystem_device_id;
 	hw->bus.device = pci_dev->addr.devid;
 	hw->bus.func = pci_dev->addr.function;
+	hw->adapter_stopped = 0;
 
 	/* Make sure all is clean before doing PF reset */
 	i40e_clear_hw(hw);
@@ -584,6 +588,78 @@ err_get_capabilities:
 }
 
 static int
+eth_i40e_dev_uninit(struct rte_eth_dev *dev)
+{
+	struct rte_pci_device *pci_dev;
+	struct i40e_hw *hw;
+	struct i40e_filter_control_settings settings;
+	int ret;
+	uint8_t aq_fail = 0;
+	unsigned i;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
+	hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	pci_dev = dev->pci_dev;
+
+	if (hw->adapter_stopped == 0)
+		i40e_dev_close(dev);
+
+	dev->dev_ops = NULL;
+	dev->rx_pkt_burst = NULL;
+	dev->tx_pkt_burst = NULL;
+
+	/* Disable LLDP */
+	ret = i40e_aq_stop_lldp(hw, true, NULL);
+	if (ret != I40E_SUCCESS) /* Its failure can be ignored */
+		PMD_INIT_LOG(INFO, "Failed to stop lldp");
+
+	/* Clear PXE mode */
+	i40e_clear_pxe_mode(hw);
+
+	/* Unconfigure filter control */
+	memset(&settings, 0, sizeof(settings));
+	ret = i40e_set_filter_control(hw, &settings);
+	if (ret)
+		PMD_INIT_LOG(WARNING, "setup_pf_filter_control failed: %d",
+					ret);
+
+	/* Disable flow control */
+	hw->fc.requested_mode = I40E_FC_NONE;
+	i40e_set_fc(hw, &aq_fail, TRUE);
+
+	/* uninitialize pf host driver */
+	i40e_pf_host_uninit(dev);
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		i40e_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++) {
+		i40e_dev_tx_queue_release(dev->data->tx_queues[i]);
+		dev->data->tx_queues[i] = NULL;
+	}
+	dev->data->nb_tx_queues = 0;
+
+	rte_free(dev->data->mac_addrs);
+	dev->data->mac_addrs = NULL;
+
+	/* disable uio intr before callback unregister */
+	rte_intr_disable(&(pci_dev->intr_handle));
+
+	/* register callback func to eal lib */
+	rte_intr_callback_unregister(&(pci_dev->intr_handle),
+		i40e_dev_interrupt_handler, (void *)dev);
+
+	return 0;
+}
+
+static int
 i40e_dev_configure(struct rte_eth_dev *dev)
 {
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
@@ -858,6 +934,8 @@ i40e_dev_start(struct rte_eth_dev *dev)
 	struct i40e_vsi *main_vsi = pf->main_vsi;
 	int ret, i;
 
+	hw->adapter_stopped = 0;
+
 	if ((dev->data->dev_conf.link_duplex != ETH_LINK_AUTONEG_DUPLEX) &&
 		(dev->data->dev_conf.link_duplex != ETH_LINK_FULL_DUPLEX)) {
 		PMD_INIT_LOG(ERR, "Invalid link_duplex (%hu) for port %hhu",
@@ -965,6 +1043,7 @@ i40e_dev_close(struct rte_eth_dev *dev)
 	PMD_INIT_FUNC_TRACE();
 
 	i40e_dev_stop(dev);
+	hw->adapter_stopped = 1;
 
 	/* Disable interrupt */
 	i40e_pf_disable_irq0(hw);
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index f7332e7..d812655 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1146,6 +1146,22 @@ err:
 }
 
 static int
+i40evf_uninit_vf(struct rte_eth_dev *dev)
+{
+	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (hw->adapter_stopped == 0)
+		i40evf_dev_close(dev);
+	rte_free(vf->vf_res);
+	vf->vf_res = NULL;
+
+	return 0;
+}
+
+static int
 i40evf_dev_init(struct rte_eth_dev *eth_dev)
 {
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(\
@@ -1175,6 +1191,7 @@ i40evf_dev_init(struct rte_eth_dev *eth_dev)
 	hw->bus.device = eth_dev->pci_dev->addr.devid;
 	hw->bus.func = eth_dev->pci_dev->addr.function;
 	hw->hw_addr = (void *)eth_dev->pci_dev->mem_resource[0].addr;
+	hw->adapter_stopped = 0;
 
 	if(i40evf_init_vf(eth_dev) != 0) {
 		PMD_INIT_LOG(ERR, "Init vf failed");
@@ -1195,6 +1212,42 @@ i40evf_dev_init(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static int
+i40evf_dev_uninit(struct rte_eth_dev *eth_dev)
+{
+	unsigned i;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return -EPERM;
+
+	eth_dev->dev_ops = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+
+	if (i40evf_uninit_vf(eth_dev) != 0) {
+		PMD_INIT_LOG(ERR, "i40evf_uninit_vf failed");
+		return -1;
+	}
+
+	for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
+		i40e_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++) {
+		i40e_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;
+}
 /*
  * virtual function driver struct
  */
@@ -1202,9 +1255,10 @@ static struct eth_driver rte_i40evf_pmd = {
 	.pci_drv = {
 		.name = "rte_i40evf_pmd",
 		.id_table = pci_id_i40evf_map,
-		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
 	},
 	.eth_dev_init = i40evf_dev_init,
+	.eth_dev_uninit = i40evf_dev_uninit,
 	.dev_private_size = sizeof(struct i40e_vf),
 };
 
@@ -1524,6 +1578,8 @@ i40evf_dev_start(struct rte_eth_dev *dev)
 
 	PMD_INIT_FUNC_TRACE();
 
+	hw->adapter_stopped = 0;
+
 	vf->max_pkt_len = dev->data->dev_conf.rxmode.max_rx_pkt_len;
 	vf->num_queue_pairs = RTE_MAX(dev->data->nb_rx_queues,
 					dev->data->nb_tx_queues);
@@ -1709,6 +1765,7 @@ i40evf_dev_close(struct rte_eth_dev *dev)
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
 	i40evf_dev_stop(dev);
+	hw->adapter_stopped = 1;
 	i40evf_reset_vf(hw);
 	i40e_shutdown_adminq(hw);
 }
diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index b89a1e2..95c960c 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -1061,3 +1061,37 @@ fail:
 
 	return ret;
 }
+
+int
+i40e_pf_host_uninit(struct rte_eth_dev *dev)
+{
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+	uint32_t val;
+
+	PMD_INIT_FUNC_TRACE();
+
+	/**
+	 * return if SRIOV not enabled, VF number not configured or
+	 * no queue assigned.
+	 */
+	if ((!hw->func_caps.sr_iov_1_1) ||
+		(pf->vf_num == 0) ||
+		(pf->vf_nb_qps == 0))
+		return I40E_SUCCESS;
+
+	/* free memory to store VF structure */
+	rte_free(pf->vfs);
+	pf->vfs = NULL;
+
+	/* Disable irq0 for VFR event */
+	i40e_pf_disable_irq0(hw);
+
+	/* Disable VF link status interrupt */
+	val = I40E_READ_REG(hw, I40E_PFGEN_PORTMDIO_NUM);
+	val &= ~I40E_PFGEN_PORTMDIO_NUM_VFLINK_STAT_ENA_MASK;
+	I40E_WRITE_REG(hw, I40E_PFGEN_PORTMDIO_NUM, val);
+	I40E_WRITE_FLUSH(hw);
+
+	return I40E_SUCCESS;
+}
diff --git a/drivers/net/i40e/i40e_pf.h b/drivers/net/i40e/i40e_pf.h
index e08ba49..9c01829 100644
--- a/drivers/net/i40e/i40e_pf.h
+++ b/drivers/net/i40e/i40e_pf.h
@@ -123,5 +123,6 @@ void i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev,
 				__rte_unused uint32_t retval,
 				uint8_t *msg, uint16_t msglen);
 int i40e_pf_host_init(struct rte_eth_dev *dev);
+int i40e_pf_host_uninit(struct rte_eth_dev *dev);
 
 #endif /* _I40E_PF_H_ */
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v5 2/6] i40e: release vmdq vsi's in dev_close
  2015-06-19 17:03 ` [dpdk-dev] [PATCH v5 0/6] i40e: PCI Port Hotplug Changes Bernard Iremonger
  2015-06-19 17:03   ` [dpdk-dev] [PATCH v5 1/6] i40e: changes to support PCI Port Hotplug Bernard Iremonger
@ 2015-06-19 17:03   ` Bernard Iremonger
  2015-06-19 17:03   ` [dpdk-dev] [PATCH v5 3/6] i40e: increase ASQ_DELAY_MS to 100 and MAX_TRY_TIMES to 20 in i40evf_wait_cmd_done() Bernard Iremonger
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-19 17:03 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 9ae68d6..4661436 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -1039,6 +1039,7 @@ i40e_dev_close(struct rte_eth_dev *dev)
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	uint32_t reg;
+	int i;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -1056,6 +1057,14 @@ i40e_dev_close(struct rte_eth_dev *dev)
 	i40e_fdir_teardown(pf);
 	i40e_vsi_release(pf->main_vsi);
 
+	for (i = 0; i < pf->nb_cfg_vmdq_vsi; i++) {
+		i40e_vsi_release(pf->vmdq[i].vsi);
+		pf->vmdq[i].vsi = NULL;
+	}
+
+	rte_free(pf->vmdq);
+	pf->vmdq = NULL;
+
 	/* shutdown the adminq */
 	i40e_aq_queue_shutdown(hw, true);
 	i40e_shutdown_adminq(hw);
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v5 3/6] i40e: increase ASQ_DELAY_MS to 100 and MAX_TRY_TIMES to 20 in i40evf_wait_cmd_done()
  2015-06-19 17:03 ` [dpdk-dev] [PATCH v5 0/6] i40e: PCI Port Hotplug Changes Bernard Iremonger
  2015-06-19 17:03   ` [dpdk-dev] [PATCH v5 1/6] i40e: changes to support PCI Port Hotplug Bernard Iremonger
  2015-06-19 17:03   ` [dpdk-dev] [PATCH v5 2/6] i40e: release vmdq vsi's in dev_close Bernard Iremonger
@ 2015-06-19 17:03   ` Bernard Iremonger
  2015-06-19 17:04   ` [dpdk-dev] [PATCH v5 4/6] i40e: call _clear_cmd() when error occurs Bernard Iremonger
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-19 17:03 UTC (permalink / raw)
  To: dev

Increase delay from 50 * 10 to 100 * 20 to avoid i40evf_read_pfmsg() failures.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/i40e/i40e_ethdev_vf.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index d812655..9a6aa29 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -298,8 +298,8 @@ i40evf_wait_cmd_done(struct rte_eth_dev *dev,
 	int i = 0;
 	enum i40evf_aq_result ret;
 
-#define MAX_TRY_TIMES 10
-#define ASQ_DELAY_MS  50
+#define MAX_TRY_TIMES 20
+#define ASQ_DELAY_MS  100
 	do {
 		/* Delay some time first */
 		rte_delay_ms(ASQ_DELAY_MS);
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v5 4/6] i40e: call _clear_cmd() when error occurs
  2015-06-19 17:03 ` [dpdk-dev] [PATCH v5 0/6] i40e: PCI Port Hotplug Changes Bernard Iremonger
                     ` (2 preceding siblings ...)
  2015-06-19 17:03   ` [dpdk-dev] [PATCH v5 3/6] i40e: increase ASQ_DELAY_MS to 100 and MAX_TRY_TIMES to 20 in i40evf_wait_cmd_done() Bernard Iremonger
@ 2015-06-19 17:04   ` Bernard Iremonger
  2015-06-19 17:04   ` [dpdk-dev] [PATCH v5 5/6] i40e: clear queues in i40evf_dev_stop Bernard Iremonger
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-19 17:04 UTC (permalink / raw)
  To: dev

_clear_cmd() was not being called in failure situations,
resulting in the next command also failing.
Fix several typos.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/i40e/i40e_ethdev_vf.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 9a6aa29..6f3ecff 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -361,6 +361,7 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
 		     args->in_args, args->in_args_size, NULL);
 	if (err) {
 		PMD_DRV_LOG(ERR, "fail to send cmd %d", args->ops);
+		_clear_cmd(vf);
 		return err;
 	}
 
@@ -368,8 +369,10 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
 	/* read message and it's expected one */
 	if (!err && args->ops == info.ops)
 		_clear_cmd(vf);
-	else if (err)
+	else if (err) {
 		PMD_DRV_LOG(ERR, "Failed to read message from AdminQ");
+		_clear_cmd(vf);
+	}
 	else if (args->ops != info.ops)
 		PMD_DRV_LOG(ERR, "command mismatch, expect %u, get %u",
 			    args->ops, info.ops);
@@ -794,7 +797,7 @@ i40evf_stop_queues(struct rte_eth_dev *dev)
 	/* Stop TX queues first */
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
 		if (i40evf_dev_tx_queue_stop(dev, i) != 0) {
-			PMD_DRV_LOG(ERR, "Fail to start queue %u", i);
+			PMD_DRV_LOG(ERR, "Fail to stop queue %u", i);
 			return -1;
 		}
 	}
@@ -802,7 +805,7 @@ i40evf_stop_queues(struct rte_eth_dev *dev)
 	/* Then stop RX queues */
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		if (i40evf_dev_rx_queue_stop(dev, i) != 0) {
-			PMD_DRV_LOG(ERR, "Fail to start queue %u", i);
+			PMD_DRV_LOG(ERR, "Fail to stop queue %u", i);
 			return -1;
 		}
 	}
@@ -1445,7 +1448,7 @@ i40evf_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 		err = i40evf_switch_queue(dev, FALSE, tx_queue_id, FALSE);
 
 		if (err) {
-			PMD_DRV_LOG(ERR, "Failed to switch TX queue %u of",
+			PMD_DRV_LOG(ERR, "Failed to switch TX queue %u off",
 				    tx_queue_id);
 			return err;
 		}
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v5 5/6] i40e: clear queues in i40evf_dev_stop
  2015-06-19 17:03 ` [dpdk-dev] [PATCH v5 0/6] i40e: PCI Port Hotplug Changes Bernard Iremonger
                     ` (3 preceding siblings ...)
  2015-06-19 17:04   ` [dpdk-dev] [PATCH v5 4/6] i40e: call _clear_cmd() when error occurs Bernard Iremonger
@ 2015-06-19 17:04   ` Bernard Iremonger
  2015-06-19 17:04   ` [dpdk-dev] [PATCH v5 6/6] i40e: check rxq parameter in i40e_reset_rx_queue Bernard Iremonger
  2015-06-25  2:28   ` [dpdk-dev] [PATCH v5 0/6] i40e: PCI Port Hotplug Changes Zhang, Helin
  6 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-19 17:04 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/i40e/i40e_ethdev_vf.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 6f3ecff..f0ddfed 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1634,6 +1634,7 @@ i40evf_dev_stop(struct rte_eth_dev *dev)
 
 	i40evf_disable_queues_intr(hw);
 	i40evf_stop_queues(dev);
+	i40e_dev_clear_queues(dev);
 }
 
 static int
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v5 6/6] i40e: check rxq parameter in i40e_reset_rx_queue
  2015-06-19 17:03 ` [dpdk-dev] [PATCH v5 0/6] i40e: PCI Port Hotplug Changes Bernard Iremonger
                     ` (4 preceding siblings ...)
  2015-06-19 17:04   ` [dpdk-dev] [PATCH v5 5/6] i40e: clear queues in i40evf_dev_stop Bernard Iremonger
@ 2015-06-19 17:04   ` Bernard Iremonger
  2015-06-25  2:28   ` [dpdk-dev] [PATCH v5 0/6] i40e: PCI Port Hotplug Changes Zhang, Helin
  6 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-19 17:04 UTC (permalink / raw)
  To: dev

There is a segmentation fault if rxq is NULL

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/i40e/i40e_rxtx.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 2de0ac4..2a89e84 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -2269,6 +2269,11 @@ i40e_reset_rx_queue(struct i40e_rx_queue *rxq)
 	unsigned i;
 	uint16_t len;
 
+	if (!rxq) {
+		PMD_DRV_LOG(DEBUG, "Pointer to rxq is NULL");
+		return;
+	}
+
 #ifdef RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC
 	if (check_rx_burst_bulk_alloc_preconditions(rxq) == 0)
 		len = (uint16_t)(rxq->nb_rx_desc + RTE_PMD_I40E_RX_MAX_BURST);
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v6] e1000: igb and em1000 PCI Port Hotplug changes
       [not found] <PATCH>
                   ` (8 preceding siblings ...)
  2015-06-19 17:03 ` [dpdk-dev] [PATCH v5 0/6] i40e: PCI Port Hotplug Changes Bernard Iremonger
@ 2015-06-22 10:44 ` Bernard Iremonger
  2015-06-25  2:33   ` Zhang, Helin
  2015-06-26  8:56   ` Zhang, Helin
  2015-06-24 15:08 ` [dpdk-dev] [PATCH v5] ixgbe: changes to support PCI Port Hotplug Bernard Iremonger
                   ` (31 subsequent siblings)
  41 siblings, 2 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-22 10:44 UTC (permalink / raw)
  To: dev

This patch depends on the Port Hotplug Framework.
It implements the eth_dev_uninit functions for rte_em_pmd,
rte_igb_pmd and rte_igbvf_pmd.

Changes in v6:
Set nb_rx_queues and nb_tx_queues to 0 in uninit functions.
Rebase to latest code.

Changes in V5:
Moved adapter stopped boolean to struct e1000_adapter.
Rebase to latest code.

Changes in V4:
Release rx and tx queues in eth_igbvf_dev_uninit.

Changes in V3:
Add igb_adapter_stopped and em_adapter_stopped booleans.
Release rx and tx queues in eth_igb_dev_uninit.

Changes in V2:
Call dev_close() from  dev_uninit() functions.
Remove input parameter checking from dev_uninit() functions.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/e1000/e1000_ethdev.h |    8 ++-
 drivers/net/e1000/em_ethdev.c    |   59 ++++++++++++++++++-
 drivers/net/e1000/igb_ethdev.c   |  119 +++++++++++++++++++++++++++++++++++++-
 drivers/net/e1000/igb_pf.c       |   22 +++++++
 4 files changed, 203 insertions(+), 5 deletions(-)

diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h
index c451faa..ee8b872 100644
--- a/drivers/net/e1000/e1000_ethdev.h
+++ b/drivers/net/e1000/e1000_ethdev.h
@@ -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
@@ -229,8 +229,12 @@ struct e1000_adapter {
 	struct e1000_vfta       shadow_vfta;
 	struct e1000_vf_info    *vfdata;
 	struct e1000_filter_info filter;
+	bool stopped;
 };
 
+#define E1000_DEV_PRIVATE(adapter) \
+	((struct e1000_adapter *)adapter)
+
 #define E1000_DEV_PRIVATE_TO_HW(adapter) \
 	(&((struct e1000_adapter *)adapter)->hw)
 
@@ -337,4 +341,6 @@ uint16_t eth_em_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 uint16_t eth_em_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		uint16_t nb_pkts);
 
+void igb_pf_host_uninit(struct rte_eth_dev *dev);
+
 #endif /* _E1000_ETHDEV_H_ */
diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index a306c55..b496c39 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -224,6 +224,8 @@ static int
 eth_em_dev_init(struct rte_eth_dev *eth_dev)
 {
 	struct rte_pci_device *pci_dev;
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(eth_dev->data->dev_private);
 	struct e1000_hw *hw =
 		E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 	struct e1000_vfta * shadow_vfta =
@@ -246,6 +248,7 @@ eth_em_dev_init(struct rte_eth_dev *eth_dev)
 
 	hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
 	hw->device_id = pci_dev->id.device_id;
+	adapter->stopped = 0;
 
 	/* For ICH8 support we'll need to map the flash memory BAR */
 
@@ -285,13 +288,60 @@ eth_em_dev_init(struct rte_eth_dev *eth_dev)
 	return (0);
 }
 
+static int
+eth_em_dev_uninit(struct rte_eth_dev *eth_dev)
+{
+	struct rte_pci_device *pci_dev;
+	unsigned i;
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(eth_dev->data->dev_private);
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return -EPERM;
+
+	pci_dev = eth_dev->pci_dev;
+
+	if (adapter->stopped == 0)
+		eth_em_close(eth_dev);
+
+	eth_dev->dev_ops = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+
+	rte_free(eth_dev->data->mac_addrs);
+	eth_dev->data->mac_addrs = NULL;
+
+	for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
+		eth_em_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++) {
+		eth_em_tx_queue_release(eth_dev->data->tx_queues[i]);
+		eth_dev->data->tx_queues[i] = NULL;
+	}
+	eth_dev->data->nb_tx_queues = 0;
+
+	/* disable uio intr before callback unregister */
+	rte_intr_disable(&(pci_dev->intr_handle));
+	rte_intr_callback_unregister(&(pci_dev->intr_handle),
+		eth_em_interrupt_handler, (void *)eth_dev);
+
+	return 0;
+}
+
 static struct eth_driver rte_em_pmd = {
 	.pci_drv = {
 		.name = "rte_em_pmd",
 		.id_table = pci_id_em_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_em_dev_init,
+	.eth_dev_uninit = eth_em_dev_uninit,
 	.dev_private_size = sizeof(struct e1000_adapter),
 };
 
@@ -451,6 +501,8 @@ em_set_pba(struct e1000_hw *hw)
 static int
 eth_em_start(struct rte_eth_dev *dev)
 {
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(dev->data->dev_private);
 	struct e1000_hw *hw =
 		E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	int ret, mask;
@@ -570,6 +622,8 @@ eth_em_start(struct rte_eth_dev *dev)
 		}
 	}
 
+	adapter->stopped = 0;
+
 	PMD_INIT_LOG(DEBUG, "<<");
 
 	return (0);
@@ -613,8 +667,11 @@ static void
 eth_em_close(struct rte_eth_dev *dev)
 {
 	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(dev->data->dev_private);
 
 	eth_em_stop(dev);
+	adapter->stopped = 1;
 	e1000_phy_hw_reset(hw);
 	em_release_manageability(hw);
 	em_hw_control_release(hw);
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 24c7510..16acdc9 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -465,9 +465,12 @@ eth_igb_dev_init(struct rte_eth_dev *eth_dev)
 	struct e1000_hw *hw =
 		E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 	struct e1000_vfta * shadow_vfta =
-			E1000_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
+		E1000_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
 	struct e1000_filter_info *filter_info =
 		E1000_DEV_PRIVATE_TO_FILTER_INFO(eth_dev->data->dev_private);
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(eth_dev->data->dev_private);
+
 	uint32_t ctrl_ext;
 
 	pci_dev = eth_dev->pci_dev;
@@ -570,6 +573,7 @@ eth_igb_dev_init(struct rte_eth_dev *eth_dev)
 		goto err_late;
 	}
 	hw->mac.get_link_status = 1;
+	adapter->stopped = 0;
 
 	/* Indicate SOL/IDER usage */
 	if (e1000_check_reset_block(hw) < 0) {
@@ -614,6 +618,59 @@ err_late:
 	return (error);
 }
 
+static int
+eth_igb_dev_uninit(struct rte_eth_dev *eth_dev)
+{
+	struct rte_pci_device *pci_dev;
+	struct e1000_hw *hw;
+	unsigned i;
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(eth_dev->data->dev_private);
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return -EPERM;
+
+	hw = E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	pci_dev = eth_dev->pci_dev;
+
+	if (adapter->stopped == 0)
+		eth_igb_close(eth_dev);
+
+	eth_dev->dev_ops = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+
+	for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
+		eth_igb_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++) {
+		eth_igb_tx_queue_release(eth_dev->data->tx_queues[i]);
+		eth_dev->data->tx_queues[i] = NULL;
+	}
+	eth_dev->data->nb_tx_queues = 0;
+
+	/* Reset any pending lock */
+	igb_reset_swfw_lock(hw);
+
+	rte_free(eth_dev->data->mac_addrs);
+	eth_dev->data->mac_addrs = NULL;
+
+	/* uninitialize PF if max_vfs not zero */
+	igb_pf_host_uninit(eth_dev);
+
+	/* disable uio intr before callback unregister */
+	rte_intr_disable(&(pci_dev->intr_handle));
+	rte_intr_callback_unregister(&(pci_dev->intr_handle),
+		eth_igb_interrupt_handler, (void *)eth_dev);
+
+	return 0;
+}
+
 /*
  * Virtual Function device init
  */
@@ -621,6 +678,8 @@ static int
 eth_igbvf_dev_init(struct rte_eth_dev *eth_dev)
 {
 	struct rte_pci_device *pci_dev;
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(eth_dev->data->dev_private);
 	struct e1000_hw *hw =
 		E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 	int diag;
@@ -645,6 +704,7 @@ eth_igbvf_dev_init(struct rte_eth_dev *eth_dev)
 	hw->device_id = pci_dev->id.device_id;
 	hw->vendor_id = pci_dev->id.vendor_id;
 	hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
+	adapter->stopped = 0;
 
 	/* Initialize the shared code (base driver) */
 	diag = e1000_setup_init_funcs(hw, TRUE);
@@ -685,13 +745,52 @@ eth_igbvf_dev_init(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static int
+eth_igbvf_dev_uninit(struct rte_eth_dev *eth_dev)
+{
+	unsigned i;
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(eth_dev->data->dev_private);
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return -EPERM;
+
+	if (adapter->stopped == 0)
+		igbvf_dev_close(eth_dev);
+
+	eth_dev->dev_ops = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+
+	for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
+		eth_igb_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++) {
+		eth_igb_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_igb_pmd = {
 	.pci_drv = {
 		.name = "rte_igb_pmd",
 		.id_table = pci_id_igb_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_igb_dev_init,
+	.eth_dev_uninit = eth_igb_dev_uninit,
 	.dev_private_size = sizeof(struct e1000_adapter),
 };
 
@@ -702,9 +801,10 @@ static struct eth_driver rte_igbvf_pmd = {
 	.pci_drv = {
 		.name = "rte_igbvf_pmd",
 		.id_table = pci_id_igbvf_map,
-		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
 	},
 	.eth_dev_init = eth_igbvf_dev_init,
+	.eth_dev_uninit = eth_igbvf_dev_uninit,
 	.dev_private_size = sizeof(struct e1000_adapter),
 };
 
@@ -758,6 +858,8 @@ eth_igb_start(struct rte_eth_dev *dev)
 {
 	struct e1000_hw *hw =
 		E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(dev->data->dev_private);
 	int ret, i, mask;
 	uint32_t ctrl_ext;
 
@@ -786,6 +888,7 @@ eth_igb_start(struct rte_eth_dev *dev)
 		PMD_INIT_LOG(ERR, "Unable to initialize the hardware");
 		return (-EIO);
 	}
+	adapter->stopped = 0;
 
 	E1000_WRITE_REG(hw, E1000_VET, ETHER_TYPE_VLAN << 16 | ETHER_TYPE_VLAN);
 
@@ -992,9 +1095,13 @@ static void
 eth_igb_close(struct rte_eth_dev *dev)
 {
 	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(dev->data->dev_private);
 	struct rte_eth_link link;
 
 	eth_igb_stop(dev);
+	adapter->stopped = 1;
+
 	e1000_phy_hw_reset(hw);
 	igb_release_manageability(hw);
 	igb_hw_control_release(hw);
@@ -2228,11 +2335,14 @@ igbvf_dev_start(struct rte_eth_dev *dev)
 {
 	struct e1000_hw *hw =
 		E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(dev->data->dev_private);
 	int ret;
 
 	PMD_INIT_FUNC_TRACE();
 
 	hw->mac.ops.reset_hw(hw);
+	adapter->stopped = 0;
 
 	/* Set all vfta */
 	igbvf_set_vfta_all(dev,1);
@@ -2270,12 +2380,15 @@ static void
 igbvf_dev_close(struct rte_eth_dev *dev)
 {
 	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(dev->data->dev_private);
 
 	PMD_INIT_FUNC_TRACE();
 
 	e1000_reset_hw(hw);
 
 	igbvf_dev_stop(dev);
+	adapter->stopped = 1;
 }
 
 static int igbvf_set_vfta(struct e1000_hw *hw, uint16_t vid, bool on)
diff --git a/drivers/net/e1000/igb_pf.c b/drivers/net/e1000/igb_pf.c
index 6a4d210..26c2960 100644
--- a/drivers/net/e1000/igb_pf.c
+++ b/drivers/net/e1000/igb_pf.c
@@ -127,6 +127,28 @@ void igb_pf_host_init(struct rte_eth_dev *eth_dev)
 	return;
 }
 
+void igb_pf_host_uninit(struct rte_eth_dev *dev)
+{
+	struct e1000_vf_info **vfinfo;
+	uint16_t vf_num;
+
+	PMD_INIT_FUNC_TRACE();
+
+	vfinfo = E1000_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
+
+	RTE_ETH_DEV_SRIOV(dev).active = 0;
+	RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = 0;
+	RTE_ETH_DEV_SRIOV(dev).def_vmdq_idx = 0;
+	RTE_ETH_DEV_SRIOV(dev).def_pool_q_idx = 0;
+
+	vf_num = dev_num_vf(dev);
+	if (vf_num == 0)
+		return;
+
+	rte_free(*vfinfo);
+	*vfinfo = NULL;
+}
+
 #define E1000_RAH_POOLSEL_SHIFT    (18)
 int igb_pf_host_configure(struct rte_eth_dev *eth_dev)
 {
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v5] ixgbe: changes to support PCI Port Hotplug
       [not found] <PATCH>
                   ` (9 preceding siblings ...)
  2015-06-22 10:44 ` [dpdk-dev] [PATCH v6] e1000: igb and em1000 PCI Port Hotplug changes Bernard Iremonger
@ 2015-06-24 15:08 ` Bernard Iremonger
  2015-06-25 11:41   ` Ananyev, Konstantin
  2015-06-25 14:30 ` [dpdk-dev] [PATCH] librte_ether: release memory in uninit function Bernard Iremonger
                   ` (30 subsequent siblings)
  41 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-24 15:08 UTC (permalink / raw)
  To: dev

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 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.

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

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index f18550c..b657c38 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);
@@ -922,6 +924,59 @@ 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;
+	}
+	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;
+
+	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 +1147,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 +1209,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 +1582,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 +1740,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 +3144,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..46d1ea9 100644
--- a/drivers/net/ixgbe/ixgbe_pf.c
+++ b/drivers/net/ixgbe/ixgbe_pf.c
@@ -144,6 +144,29 @@ 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

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v5 0/6] i40e: PCI Port Hotplug Changes
  2015-06-19 17:03 ` [dpdk-dev] [PATCH v5 0/6] i40e: PCI Port Hotplug Changes Bernard Iremonger
                     ` (5 preceding siblings ...)
  2015-06-19 17:04   ` [dpdk-dev] [PATCH v5 6/6] i40e: check rxq parameter in i40e_reset_rx_queue Bernard Iremonger
@ 2015-06-25  2:28   ` Zhang, Helin
  6 siblings, 0 replies; 270+ messages in thread
From: Zhang, Helin @ 2015-06-25  2:28 UTC (permalink / raw)
  To: Iremonger, Bernard, dev



> -----Original Message-----
> From: Iremonger, Bernard
> Sent: Saturday, June 20, 2015 1:04 AM
> To: dev@dpdk.org
> Cc: Zhang, Helin; Iremonger, Bernard
> Subject: [PATCH v5 0/6] i40e: PCI Port Hotplug Changes
> 
> Changes in V5:
> Increased timeout in i40evf_wait_cmd_done() Set nb_rx_queues and
> nb_tx_queues to 0 in uninit functions.
> Rebased to latest i40e code.
> 
> Changes in V4:
> added patch 6 to fix segmentation fault reported by Michael Qiu.
> Rebase to latest i40e code.
> 
> Changes in V3:
> Release rx and tx queues in vf uninit function.
> Rebase to use latest i40e code.
> 
> Changes in V2:
> Rebase to use drivers/net/i40e directory.
> 
> Bernard Iremonger (6):
>   i40e: changes to support PCI Port Hotplug
>   i40e: release vmdq vsi's in dev_close
>   i40e: increase ASQ_DELAY_MS to 100 in i40evf_wait_cmd_done()
>   i40e: call _clear_cmd() when error occurs
>   i40e: clear queues in i40evf_dev_stop
>   i40e: check rxq parameter in i40e_reset_rx_queue
> 
>  drivers/net/i40e/i40e_ethdev.c    |   88
> ++++++++++++++++++++++++++++++++++++-
>  drivers/net/i40e/i40e_ethdev_vf.c |   71
> +++++++++++++++++++++++++++---
>  drivers/net/i40e/i40e_pf.c        |   34 ++++++++++++++
>  drivers/net/i40e/i40e_pf.h        |    1 +
>  drivers/net/i40e/i40e_rxtx.c      |    5 ++
>  5 files changed, 192 insertions(+), 7 deletions(-)
> 
> --
> 1.7.4.1

Acked-by: Helin Zhang <helin.zhang@intel.com>

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v6] e1000: igb and em1000 PCI Port Hotplug changes
  2015-06-22 10:44 ` [dpdk-dev] [PATCH v6] e1000: igb and em1000 PCI Port Hotplug changes Bernard Iremonger
@ 2015-06-25  2:33   ` Zhang, Helin
  2015-06-25  9:04     ` Iremonger, Bernard
  2015-06-26  8:56   ` Zhang, Helin
  1 sibling, 1 reply; 270+ messages in thread
From: Zhang, Helin @ 2015-06-25  2:33 UTC (permalink / raw)
  To: Iremonger, Bernard, dev

Hi Bernard

> -----Original Message-----
> From: Iremonger, Bernard
> Sent: Monday, June 22, 2015 6:44 PM
> To: dev@dpdk.org
> Cc: Zhang, Helin; Iremonger, Bernard
> Subject: [PATCH v6] e1000: igb and em1000 PCI Port Hotplug changes
> 
> This patch depends on the Port Hotplug Framework.
> It implements the eth_dev_uninit functions for rte_em_pmd, rte_igb_pmd and
> rte_igbvf_pmd.
Would it be better to split this patch into smaller patches in a patch set as you did
for i40e hotplug?

Regards,
Helin

> 
> Changes in v6:
> Set nb_rx_queues and nb_tx_queues to 0 in uninit functions.
> Rebase to latest code.
> 
> Changes in V5:
> Moved adapter stopped boolean to struct e1000_adapter.
> Rebase to latest code.
> 
> Changes in V4:
> Release rx and tx queues in eth_igbvf_dev_uninit.
> 
> Changes in V3:
> Add igb_adapter_stopped and em_adapter_stopped booleans.
> Release rx and tx queues in eth_igb_dev_uninit.
> 
> Changes in V2:
> Call dev_close() from  dev_uninit() functions.
> Remove input parameter checking from dev_uninit() functions.
> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> ---
>  drivers/net/e1000/e1000_ethdev.h |    8 ++-
>  drivers/net/e1000/em_ethdev.c    |   59 ++++++++++++++++++-
>  drivers/net/e1000/igb_ethdev.c   |  119
> +++++++++++++++++++++++++++++++++++++-
>  drivers/net/e1000/igb_pf.c       |   22 +++++++
>  4 files changed, 203 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/e1000/e1000_ethdev.h
> b/drivers/net/e1000/e1000_ethdev.h
> index c451faa..ee8b872 100644
> --- a/drivers/net/e1000/e1000_ethdev.h
> +++ b/drivers/net/e1000/e1000_ethdev.h
> @@ -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
> @@ -229,8 +229,12 @@ struct e1000_adapter {
>  	struct e1000_vfta       shadow_vfta;
>  	struct e1000_vf_info    *vfdata;
>  	struct e1000_filter_info filter;
> +	bool stopped;
>  };
> 
> +#define E1000_DEV_PRIVATE(adapter) \
> +	((struct e1000_adapter *)adapter)
> +
>  #define E1000_DEV_PRIVATE_TO_HW(adapter) \
>  	(&((struct e1000_adapter *)adapter)->hw)
> 
> @@ -337,4 +341,6 @@ uint16_t eth_em_recv_pkts(void *rx_queue, struct
> rte_mbuf **rx_pkts,  uint16_t eth_em_recv_scattered_pkts(void *rx_queue,
> struct rte_mbuf **rx_pkts,
>  		uint16_t nb_pkts);
> 
> +void igb_pf_host_uninit(struct rte_eth_dev *dev);
> +
>  #endif /* _E1000_ETHDEV_H_ */
> diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
> index a306c55..b496c39 100644
> --- a/drivers/net/e1000/em_ethdev.c
> +++ b/drivers/net/e1000/em_ethdev.c
> @@ -224,6 +224,8 @@ static int
>  eth_em_dev_init(struct rte_eth_dev *eth_dev)  {
>  	struct rte_pci_device *pci_dev;
> +	struct e1000_adapter *adapter =
> +		E1000_DEV_PRIVATE(eth_dev->data->dev_private);
>  	struct e1000_hw *hw =
>  		E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
>  	struct e1000_vfta * shadow_vfta =
> @@ -246,6 +248,7 @@ eth_em_dev_init(struct rte_eth_dev *eth_dev)
> 
>  	hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
>  	hw->device_id = pci_dev->id.device_id;
> +	adapter->stopped = 0;
> 
>  	/* For ICH8 support we'll need to map the flash memory BAR */
> 
> @@ -285,13 +288,60 @@ eth_em_dev_init(struct rte_eth_dev *eth_dev)
>  	return (0);
>  }
> 
> +static int
> +eth_em_dev_uninit(struct rte_eth_dev *eth_dev) {
> +	struct rte_pci_device *pci_dev;
> +	unsigned i;
> +	struct e1000_adapter *adapter =
> +		E1000_DEV_PRIVATE(eth_dev->data->dev_private);
> +
> +	PMD_INIT_FUNC_TRACE();
> +
> +	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
> +		return -EPERM;
> +
> +	pci_dev = eth_dev->pci_dev;
> +
> +	if (adapter->stopped == 0)
> +		eth_em_close(eth_dev);
> +
> +	eth_dev->dev_ops = NULL;
> +	eth_dev->rx_pkt_burst = NULL;
> +	eth_dev->tx_pkt_burst = NULL;
> +
> +	rte_free(eth_dev->data->mac_addrs);
> +	eth_dev->data->mac_addrs = NULL;
> +
> +	for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
> +		eth_em_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++) {
> +		eth_em_tx_queue_release(eth_dev->data->tx_queues[i]);
> +		eth_dev->data->tx_queues[i] = NULL;
> +	}
> +	eth_dev->data->nb_tx_queues = 0;
> +
> +	/* disable uio intr before callback unregister */
> +	rte_intr_disable(&(pci_dev->intr_handle));
> +	rte_intr_callback_unregister(&(pci_dev->intr_handle),
> +		eth_em_interrupt_handler, (void *)eth_dev);
> +
> +	return 0;
> +}
> +
>  static struct eth_driver rte_em_pmd = {
>  	.pci_drv = {
>  		.name = "rte_em_pmd",
>  		.id_table = pci_id_em_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_em_dev_init,
> +	.eth_dev_uninit = eth_em_dev_uninit,
>  	.dev_private_size = sizeof(struct e1000_adapter),  };
> 
> @@ -451,6 +501,8 @@ em_set_pba(struct e1000_hw *hw)  static int
> eth_em_start(struct rte_eth_dev *dev)  {
> +	struct e1000_adapter *adapter =
> +		E1000_DEV_PRIVATE(dev->data->dev_private);
>  	struct e1000_hw *hw =
>  		E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
>  	int ret, mask;
> @@ -570,6 +622,8 @@ eth_em_start(struct rte_eth_dev *dev)
>  		}
>  	}
> 
> +	adapter->stopped = 0;
> +
>  	PMD_INIT_LOG(DEBUG, "<<");
> 
>  	return (0);
> @@ -613,8 +667,11 @@ static void
>  eth_em_close(struct rte_eth_dev *dev)
>  {
>  	struct e1000_hw *hw =
> E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> +	struct e1000_adapter *adapter =
> +		E1000_DEV_PRIVATE(dev->data->dev_private);
> 
>  	eth_em_stop(dev);
> +	adapter->stopped = 1;
>  	e1000_phy_hw_reset(hw);
>  	em_release_manageability(hw);
>  	em_hw_control_release(hw);
> diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
> index 24c7510..16acdc9 100644
> --- a/drivers/net/e1000/igb_ethdev.c
> +++ b/drivers/net/e1000/igb_ethdev.c
> @@ -465,9 +465,12 @@ eth_igb_dev_init(struct rte_eth_dev *eth_dev)
>  	struct e1000_hw *hw =
>  		E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
>  	struct e1000_vfta * shadow_vfta =
> -			E1000_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
> +		E1000_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
>  	struct e1000_filter_info *filter_info =
>  		E1000_DEV_PRIVATE_TO_FILTER_INFO(eth_dev->data->dev_private);
> +	struct e1000_adapter *adapter =
> +		E1000_DEV_PRIVATE(eth_dev->data->dev_private);
> +
>  	uint32_t ctrl_ext;
> 
>  	pci_dev = eth_dev->pci_dev;
> @@ -570,6 +573,7 @@ eth_igb_dev_init(struct rte_eth_dev *eth_dev)
>  		goto err_late;
>  	}
>  	hw->mac.get_link_status = 1;
> +	adapter->stopped = 0;
> 
>  	/* Indicate SOL/IDER usage */
>  	if (e1000_check_reset_block(hw) < 0) { @@ -614,6 +618,59 @@ err_late:
>  	return (error);
>  }
> 
> +static int
> +eth_igb_dev_uninit(struct rte_eth_dev *eth_dev) {
> +	struct rte_pci_device *pci_dev;
> +	struct e1000_hw *hw;
> +	unsigned i;
> +	struct e1000_adapter *adapter =
> +		E1000_DEV_PRIVATE(eth_dev->data->dev_private);
> +
> +	PMD_INIT_FUNC_TRACE();
> +
> +	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
> +		return -EPERM;
> +
> +	hw = E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
> +	pci_dev = eth_dev->pci_dev;
> +
> +	if (adapter->stopped == 0)
> +		eth_igb_close(eth_dev);
> +
> +	eth_dev->dev_ops = NULL;
> +	eth_dev->rx_pkt_burst = NULL;
> +	eth_dev->tx_pkt_burst = NULL;
> +
> +	for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
> +		eth_igb_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++) {
> +		eth_igb_tx_queue_release(eth_dev->data->tx_queues[i]);
> +		eth_dev->data->tx_queues[i] = NULL;
> +	}
> +	eth_dev->data->nb_tx_queues = 0;
> +
> +	/* Reset any pending lock */
> +	igb_reset_swfw_lock(hw);
> +
> +	rte_free(eth_dev->data->mac_addrs);
> +	eth_dev->data->mac_addrs = NULL;
> +
> +	/* uninitialize PF if max_vfs not zero */
> +	igb_pf_host_uninit(eth_dev);
> +
> +	/* disable uio intr before callback unregister */
> +	rte_intr_disable(&(pci_dev->intr_handle));
> +	rte_intr_callback_unregister(&(pci_dev->intr_handle),
> +		eth_igb_interrupt_handler, (void *)eth_dev);
> +
> +	return 0;
> +}
> +
>  /*
>   * Virtual Function device init
>   */
> @@ -621,6 +678,8 @@ static int
>  eth_igbvf_dev_init(struct rte_eth_dev *eth_dev)  {
>  	struct rte_pci_device *pci_dev;
> +	struct e1000_adapter *adapter =
> +		E1000_DEV_PRIVATE(eth_dev->data->dev_private);
>  	struct e1000_hw *hw =
>  		E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
>  	int diag;
> @@ -645,6 +704,7 @@ eth_igbvf_dev_init(struct rte_eth_dev *eth_dev)
>  	hw->device_id = pci_dev->id.device_id;
>  	hw->vendor_id = pci_dev->id.vendor_id;
>  	hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
> +	adapter->stopped = 0;
> 
>  	/* Initialize the shared code (base driver) */
>  	diag = e1000_setup_init_funcs(hw, TRUE); @@ -685,13 +745,52 @@
> eth_igbvf_dev_init(struct rte_eth_dev *eth_dev)
>  	return 0;
>  }
> 
> +static int
> +eth_igbvf_dev_uninit(struct rte_eth_dev *eth_dev) {
> +	unsigned i;
> +	struct e1000_adapter *adapter =
> +		E1000_DEV_PRIVATE(eth_dev->data->dev_private);
> +
> +	PMD_INIT_FUNC_TRACE();
> +
> +	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
> +		return -EPERM;
> +
> +	if (adapter->stopped == 0)
> +		igbvf_dev_close(eth_dev);
> +
> +	eth_dev->dev_ops = NULL;
> +	eth_dev->rx_pkt_burst = NULL;
> +	eth_dev->tx_pkt_burst = NULL;
> +
> +	for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
> +		eth_igb_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++) {
> +		eth_igb_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_igb_pmd = {
>  	.pci_drv = {
>  		.name = "rte_igb_pmd",
>  		.id_table = pci_id_igb_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_igb_dev_init,
> +	.eth_dev_uninit = eth_igb_dev_uninit,
>  	.dev_private_size = sizeof(struct e1000_adapter),  };
> 
> @@ -702,9 +801,10 @@ static struct eth_driver rte_igbvf_pmd = {
>  	.pci_drv = {
>  		.name = "rte_igbvf_pmd",
>  		.id_table = pci_id_igbvf_map,
> -		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
> +		.drv_flags = RTE_PCI_DRV_NEED_MAPPING |
> RTE_PCI_DRV_DETACHABLE,
>  	},
>  	.eth_dev_init = eth_igbvf_dev_init,
> +	.eth_dev_uninit = eth_igbvf_dev_uninit,
>  	.dev_private_size = sizeof(struct e1000_adapter),  };
> 
> @@ -758,6 +858,8 @@ eth_igb_start(struct rte_eth_dev *dev)  {
>  	struct e1000_hw *hw =
>  		E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> +	struct e1000_adapter *adapter =
> +		E1000_DEV_PRIVATE(dev->data->dev_private);
>  	int ret, i, mask;
>  	uint32_t ctrl_ext;
> 
> @@ -786,6 +888,7 @@ eth_igb_start(struct rte_eth_dev *dev)
>  		PMD_INIT_LOG(ERR, "Unable to initialize the hardware");
>  		return (-EIO);
>  	}
> +	adapter->stopped = 0;
> 
>  	E1000_WRITE_REG(hw, E1000_VET, ETHER_TYPE_VLAN << 16 |
> ETHER_TYPE_VLAN);
> 
> @@ -992,9 +1095,13 @@ static void
>  eth_igb_close(struct rte_eth_dev *dev)
>  {
>  	struct e1000_hw *hw =
> E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> +	struct e1000_adapter *adapter =
> +		E1000_DEV_PRIVATE(dev->data->dev_private);
>  	struct rte_eth_link link;
> 
>  	eth_igb_stop(dev);
> +	adapter->stopped = 1;
> +
>  	e1000_phy_hw_reset(hw);
>  	igb_release_manageability(hw);
>  	igb_hw_control_release(hw);
> @@ -2228,11 +2335,14 @@ igbvf_dev_start(struct rte_eth_dev *dev)  {
>  	struct e1000_hw *hw =
>  		E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> +	struct e1000_adapter *adapter =
> +		E1000_DEV_PRIVATE(dev->data->dev_private);
>  	int ret;
> 
>  	PMD_INIT_FUNC_TRACE();
> 
>  	hw->mac.ops.reset_hw(hw);
> +	adapter->stopped = 0;
> 
>  	/* Set all vfta */
>  	igbvf_set_vfta_all(dev,1);
> @@ -2270,12 +2380,15 @@ static void
>  igbvf_dev_close(struct rte_eth_dev *dev)  {
>  	struct e1000_hw *hw =
> E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> +	struct e1000_adapter *adapter =
> +		E1000_DEV_PRIVATE(dev->data->dev_private);
> 
>  	PMD_INIT_FUNC_TRACE();
> 
>  	e1000_reset_hw(hw);
> 
>  	igbvf_dev_stop(dev);
> +	adapter->stopped = 1;
>  }
> 
>  static int igbvf_set_vfta(struct e1000_hw *hw, uint16_t vid, bool on) diff --git
> a/drivers/net/e1000/igb_pf.c b/drivers/net/e1000/igb_pf.c index
> 6a4d210..26c2960 100644
> --- a/drivers/net/e1000/igb_pf.c
> +++ b/drivers/net/e1000/igb_pf.c
> @@ -127,6 +127,28 @@ void igb_pf_host_init(struct rte_eth_dev *eth_dev)
>  	return;
>  }
> 
> +void igb_pf_host_uninit(struct rte_eth_dev *dev) {
> +	struct e1000_vf_info **vfinfo;
> +	uint16_t vf_num;
> +
> +	PMD_INIT_FUNC_TRACE();
> +
> +	vfinfo = E1000_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
> +
> +	RTE_ETH_DEV_SRIOV(dev).active = 0;
> +	RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = 0;
> +	RTE_ETH_DEV_SRIOV(dev).def_vmdq_idx = 0;
> +	RTE_ETH_DEV_SRIOV(dev).def_pool_q_idx = 0;
> +
> +	vf_num = dev_num_vf(dev);
> +	if (vf_num == 0)
> +		return;
> +
> +	rte_free(*vfinfo);
> +	*vfinfo = NULL;
> +}
> +
>  #define E1000_RAH_POOLSEL_SHIFT    (18)
>  int igb_pf_host_configure(struct rte_eth_dev *eth_dev)  {
> --
> 1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v6] e1000: igb and em1000 PCI Port Hotplug changes
  2015-06-25  2:33   ` Zhang, Helin
@ 2015-06-25  9:04     ` Iremonger, Bernard
  0 siblings, 0 replies; 270+ messages in thread
From: Iremonger, Bernard @ 2015-06-25  9:04 UTC (permalink / raw)
  To: Zhang, Helin, dev


> -----Original Message-----
> From: Zhang, Helin
> Sent: Thursday, June 25, 2015 3:34 AM
> To: Iremonger, Bernard; dev@dpdk.org
> Subject: RE: [PATCH v6] e1000: igb and em1000 PCI Port Hotplug changes
> 
> Hi Bernard
> 
> > -----Original Message-----
> > From: Iremonger, Bernard
> > Sent: Monday, June 22, 2015 6:44 PM
> > To: dev@dpdk.org
> > Cc: Zhang, Helin; Iremonger, Bernard
> > Subject: [PATCH v6] e1000: igb and em1000 PCI Port Hotplug changes
> >
> > This patch depends on the Port Hotplug Framework.
> > It implements the eth_dev_uninit functions for rte_em_pmd,
> rte_igb_pmd
> > and rte_igbvf_pmd.
> Would it be better to split this patch into smaller patches in a patch set as you
> did for i40e hotplug?
> 
> Regards,
> Helin

Hi Helin,
I don't think there is anything to be gained by splitting up this patch.
All the changes are hotplug related.

In the case of the i40e, there are five patches which are unrelated to hotplug 
which resolve issues encountered during development.
 
Regards,

Bernard

<snip>

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v5] ixgbe: changes to support PCI Port Hotplug
  2015-06-24 15:08 ` [dpdk-dev] [PATCH v5] ixgbe: changes to support PCI Port Hotplug Bernard Iremonger
@ 2015-06-25 11:41   ` Ananyev, Konstantin
  0 siblings, 0 replies; 270+ messages in thread
From: Ananyev, Konstantin @ 2015-06-25 11:41 UTC (permalink / raw)
  To: Iremonger, Bernard, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bernard Iremonger
> Sent: Wednesday, June 24, 2015 4:09 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v5] 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.
> 
> 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.
> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> ---

Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

> 1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH] librte_ether: release memory in uninit function.
       [not found] <PATCH>
                   ` (10 preceding siblings ...)
  2015-06-24 15:08 ` [dpdk-dev] [PATCH v5] ixgbe: changes to support PCI Port Hotplug Bernard Iremonger
@ 2015-06-25 14:30 ` Bernard Iremonger
  2015-06-25 14:41   ` Stephen Hemminger
  2015-06-25 18:32   ` Ananyev, Konstantin
  2015-06-26  9:32 ` [dpdk-dev] [PATCH v2] " Bernard Iremonger
                   ` (29 subsequent siblings)
  41 siblings, 2 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-25 14:30 UTC (permalink / raw)
  To: dev


Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 lib/librte_ether/rte_ethdev.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index e13fde5..2404556 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -369,8 +369,14 @@ 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);
+		rte_free(eth_dev->data->mac_addrs);
+		rte_free(eth_dev->data->hash_mac_addrs);
+		memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));
+	}
 
 	eth_dev->pci_dev = NULL;
 	eth_dev->driver = NULL;
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH] librte_ether: release memory in uninit function.
  2015-06-25 14:30 ` [dpdk-dev] [PATCH] librte_ether: release memory in uninit function Bernard Iremonger
@ 2015-06-25 14:41   ` Stephen Hemminger
  2015-06-25 18:32   ` Ananyev, Konstantin
  1 sibling, 0 replies; 270+ messages in thread
From: Stephen Hemminger @ 2015-06-25 14:41 UTC (permalink / raw)
  To: Bernard Iremonger; +Cc: dev

On Thu, 25 Jun 2015 15:30:28 +0100
Bernard Iremonger <bernard.iremonger@intel.com> wrote:

> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> ---
>  lib/librte_ether/rte_ethdev.c |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index e13fde5..2404556 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -369,8 +369,14 @@ 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);
> +		rte_free(eth_dev->data->mac_addrs);
> +		rte_free(eth_dev->data->hash_mac_addrs);
> +		memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));


Glad to see this problem addressed.

I would prefer that the component that created the object be responsible
for doing its own cleanup.

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH] librte_ether: release memory in uninit function.
  2015-06-25 14:30 ` [dpdk-dev] [PATCH] librte_ether: release memory in uninit function Bernard Iremonger
  2015-06-25 14:41   ` Stephen Hemminger
@ 2015-06-25 18:32   ` Ananyev, Konstantin
  2015-06-26  8:17     ` Iremonger, Bernard
  1 sibling, 1 reply; 270+ messages in thread
From: Ananyev, Konstantin @ 2015-06-25 18:32 UTC (permalink / raw)
  To: Iremonger, Bernard, dev

Hi Bernard,

> -----Original Message-----
> From: Iremonger, Bernard
> Sent: Thursday, June 25, 2015 3:30 PM
> To: dev@dpdk.org
> Cc: Zhang, Helin; Ananyev, Konstantin; Qiu, Michael; mukawa@igel.co.jp; Iremonger, Bernard
> Subject: [PATCH] librte_ether: release memory in uninit function.
> 
> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> ---
>  lib/librte_ether/rte_ethdev.c |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index e13fde5..2404556 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -369,8 +369,14 @@ 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);
> +		rte_free(eth_dev->data->mac_addrs);
> +		rte_free(eth_dev->data->hash_mac_addrs);

Sorry, but I don't understand why you put last 2 rte_free()s here.
You already do relese mac_addrs and hash_mac_addrs memory at each PMD _uninit routine.
Plus, as Stephen said - it would be better if same component (PMD in that case) would do both alloc and free.
Apart from that, patch looks good to me.

Konstantin 


> +		memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));
> +	}
> 
>  	eth_dev->pci_dev = NULL;
>  	eth_dev->driver = NULL;
> --
> 1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH] librte_ether: release memory in uninit function.
  2015-06-25 18:32   ` Ananyev, Konstantin
@ 2015-06-26  8:17     ` Iremonger, Bernard
  0 siblings, 0 replies; 270+ messages in thread
From: Iremonger, Bernard @ 2015-06-26  8:17 UTC (permalink / raw)
  To: Ananyev, Konstantin, dev

> -----Original Message-----
> From: Ananyev, Konstantin
> Sent: Thursday, June 25, 2015 7:33 PM
> To: Iremonger, Bernard; dev@dpdk.org
> Cc: Zhang, Helin; Qiu, Michael; mukawa@igel.co.jp
> Subject: RE: [PATCH] librte_ether: release memory in uninit function.
> 
> Hi Bernard,
> 
> > -----Original Message-----
> > From: Iremonger, Bernard
> > Sent: Thursday, June 25, 2015 3:30 PM
> > To: dev@dpdk.org
> > Cc: Zhang, Helin; Ananyev, Konstantin; Qiu, Michael;
> > mukawa@igel.co.jp; Iremonger, Bernard
> > Subject: [PATCH] librte_ether: release memory in uninit function.
> >
> >
> > Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> > ---
> >  lib/librte_ether/rte_ethdev.c |    8 +++++++-
> >  1 files changed, 7 insertions(+), 1 deletions(-)
> >
> > diff --git a/lib/librte_ether/rte_ethdev.c
> > b/lib/librte_ether/rte_ethdev.c index e13fde5..2404556 100644
> > --- a/lib/librte_ether/rte_ethdev.c
> > +++ b/lib/librte_ether/rte_ethdev.c
> > @@ -369,8 +369,14 @@ 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);
> > +		rte_free(eth_dev->data->mac_addrs);
> > +		rte_free(eth_dev->data->hash_mac_addrs);
> 
> Sorry, but I don't understand why you put last 2 rte_free()s here.
> You already do relese mac_addrs and hash_mac_addrs memory at each PMD
> _uninit routine.
> Plus, as Stephen said - it would be better if same component (PMD in that
> case) would do both alloc and free.
> Apart from that, patch looks good to me.
> 
> Konstantin

Hi Konstantin,

I thought it might be safer to free the memory here rather than relying on the PMD to do it.
It is probably better if the PMD who does the alloc also does the free.

I will send a v2 of the patch.

Regards,

Bernard.

> 
> 
> > +		memset(eth_dev->data, 0, sizeof(struct
> rte_eth_dev_data));
> > +	}
> >
> >  	eth_dev->pci_dev = NULL;
> >  	eth_dev->driver = NULL;
> > --
> > 1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v6] e1000: igb and em1000 PCI Port Hotplug changes
  2015-06-22 10:44 ` [dpdk-dev] [PATCH v6] e1000: igb and em1000 PCI Port Hotplug changes Bernard Iremonger
  2015-06-25  2:33   ` Zhang, Helin
@ 2015-06-26  8:56   ` Zhang, Helin
  1 sibling, 0 replies; 270+ messages in thread
From: Zhang, Helin @ 2015-06-26  8:56 UTC (permalink / raw)
  To: Iremonger, Bernard, dev



> -----Original Message-----
> From: Iremonger, Bernard
> Sent: Monday, June 22, 2015 6:44 PM
> To: dev@dpdk.org
> Cc: Zhang, Helin; Iremonger, Bernard
> Subject: [PATCH v6] e1000: igb and em1000 PCI Port Hotplug changes
> 
> This patch depends on the Port Hotplug Framework.
> It implements the eth_dev_uninit functions for rte_em_pmd, rte_igb_pmd and
> rte_igbvf_pmd.
> 
> Changes in v6:
> Set nb_rx_queues and nb_tx_queues to 0 in uninit functions.
> Rebase to latest code.
> 
> Changes in V5:
> Moved adapter stopped boolean to struct e1000_adapter.
> Rebase to latest code.
> 
> Changes in V4:
> Release rx and tx queues in eth_igbvf_dev_uninit.
> 
> Changes in V3:
> Add igb_adapter_stopped and em_adapter_stopped booleans.
> Release rx and tx queues in eth_igb_dev_uninit.
> 
> Changes in V2:
> Call dev_close() from  dev_uninit() functions.
> Remove input parameter checking from dev_uninit() functions.
> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
Acked-by: Helin Zhang <helin.zhang@intel.com>

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit function.
       [not found] <PATCH>
                   ` (11 preceding siblings ...)
  2015-06-25 14:30 ` [dpdk-dev] [PATCH] librte_ether: release memory in uninit function Bernard Iremonger
@ 2015-06-26  9:32 ` Bernard Iremonger
  2015-06-26  9:55   ` Ananyev, Konstantin
  2015-06-29  8:54   ` Qiu, Michael
  2015-07-02 14:36 ` [dpdk-dev] [PATCH v6 0/2] PCI Port Hotplug Bernard Iremonger
                   ` (28 subsequent siblings)
  41 siblings, 2 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-06-26  9:32 UTC (permalink / raw)
  To: dev

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

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 lib/librte_ether/rte_ethdev.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index e13fde5..7ae101a 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -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;
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit function.
  2015-06-26  9:32 ` [dpdk-dev] [PATCH v2] " Bernard Iremonger
@ 2015-06-26  9:55   ` Ananyev, Konstantin
  2015-06-29  8:54   ` Qiu, Michael
  1 sibling, 0 replies; 270+ messages in thread
From: Ananyev, Konstantin @ 2015-06-26  9:55 UTC (permalink / raw)
  To: Iremonger, Bernard, dev



> -----Original Message-----
> From: Iremonger, Bernard
> Sent: Friday, June 26, 2015 10:33 AM
> To: dev@dpdk.org
> Cc: Zhang, Helin; Ananyev, Konstantin; Qiu, Michael; mukawa@igel.co.jp; Iremonger, Bernard
> Subject: [PATCH v2] librte_ether: release memory in uninit function.
> 
> Changes in v2:
> do not free mac_addrs and hash_mac_addrs here.
> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> ---
>  lib/librte_ether/rte_ethdev.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index e13fde5..7ae101a 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -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;
> --

Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

> 1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit function.
  2015-06-26  9:32 ` [dpdk-dev] [PATCH v2] " Bernard Iremonger
  2015-06-26  9:55   ` Ananyev, Konstantin
@ 2015-06-29  8:54   ` Qiu, Michael
  2015-06-29 10:20     ` Iremonger, Bernard
  1 sibling, 1 reply; 270+ messages in thread
From: Qiu, Michael @ 2015-06-29  8:54 UTC (permalink / raw)
  To: Iremonger, Bernard, dev

On 6/26/2015 5:32 PM, Iremonger, Bernard wrote:
> Changes in v2:
> do not free mac_addrs and hash_mac_addrs here.
>
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> ---
>  lib/librte_ether/rte_ethdev.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index e13fde5..7ae101a 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -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;


Actually, This could be put in rte_eth_dev_close() becasue queues should
be released when closed.

Also before free dev->data->rx_queues you should make sure
dev->data->rx_queues[i] has been freed in PMD close() function, So this
two should be better done at the same time, ether in 
rte_eth_dev_close() or in PMD close() function. For hotplug in fm10k, I
put it in PMD close() function.
 
Thanks,
Michael

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit function.
  2015-06-29  8:54   ` Qiu, Michael
@ 2015-06-29 10:20     ` Iremonger, Bernard
  2015-06-29 15:22       ` Qiu, Michael
  0 siblings, 1 reply; 270+ messages in thread
From: Iremonger, Bernard @ 2015-06-29 10:20 UTC (permalink / raw)
  To: Qiu, Michael, dev



> -----Original Message-----
> From: Qiu, Michael
> Sent: Monday, June 29, 2015 9:55 AM
> To: Iremonger, Bernard; dev@dpdk.org
> Cc: Zhang, Helin; Ananyev, Konstantin; mukawa@igel.co.jp; Stephen
> Hemminger
> Subject: Re: [PATCH v2] librte_ether: release memory in uninit function.
> 
> On 6/26/2015 5:32 PM, Iremonger, Bernard wrote:
> > Changes in v2:
> > do not free mac_addrs and hash_mac_addrs here.
> >
> > Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> > ---
> >  lib/librte_ether/rte_ethdev.c |    6 +++++-
> >  1 files changed, 5 insertions(+), 1 deletions(-)
> >
> > diff --git a/lib/librte_ether/rte_ethdev.c
> > b/lib/librte_ether/rte_ethdev.c index e13fde5..7ae101a 100644
> > --- a/lib/librte_ether/rte_ethdev.c
> > +++ b/lib/librte_ether/rte_ethdev.c
> > @@ -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;
> 
> 
> Actually, This could be put in rte_eth_dev_close() becasue queues should be
> released when closed.
> 
> Also before free dev->data->rx_queues you should make sure
> dev->data->rx_queues[i] has been freed in PMD close() function, So this
> two should be better done at the same time, ether in
> rte_eth_dev_close() or in PMD close() function. For hotplug in fm10k, I put it
> in PMD close() function.
> 
> Thanks,
> Michael
Hi Michael,
 
The consensus is that the rx_queue and tx_queue memory should not be released in the PMD as it is not allocated by the PMD. The memory is allocated in rte_eth_dev_rx_queue_config() and rte_eth_dev_tx_queue_config(), which are both called from rte_eth_dev_configure() which is called by the application (for example test_pmd). So it seems to make sense to free this memory  in rte_eth_dev_uninit().

Regards,

Bernard.

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit function.
  2015-06-29 10:20     ` Iremonger, Bernard
@ 2015-06-29 15:22       ` Qiu, Michael
  2015-06-29 16:42         ` Iremonger, Bernard
  0 siblings, 1 reply; 270+ messages in thread
From: Qiu, Michael @ 2015-06-29 15:22 UTC (permalink / raw)
  To: Iremonger, Bernard, dev

On 2015/6/29 18:20, Iremonger, Bernard wrote:
>
>> -----Original Message-----
>> From: Qiu, Michael
>> Sent: Monday, June 29, 2015 9:55 AM
>> To: Iremonger, Bernard; dev@dpdk.org
>> Cc: Zhang, Helin; Ananyev, Konstantin; mukawa@igel.co.jp; Stephen
>> Hemminger
>> Subject: Re: [PATCH v2] librte_ether: release memory in uninit function.
>>
>> On 6/26/2015 5:32 PM, Iremonger, Bernard wrote:
>>> Changes in v2:
>>> do not free mac_addrs and hash_mac_addrs here.
>>>
>>> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
>>> ---
>>>  lib/librte_ether/rte_ethdev.c |    6 +++++-
>>>  1 files changed, 5 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/lib/librte_ether/rte_ethdev.c
>>> b/lib/librte_ether/rte_ethdev.c index e13fde5..7ae101a 100644
>>> --- a/lib/librte_ether/rte_ethdev.c
>>> +++ b/lib/librte_ether/rte_ethdev.c
>>> @@ -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;
>>
>> Actually, This could be put in rte_eth_dev_close() becasue queues should be
>> released when closed.
>>
>> Also before free dev->data->rx_queues you should make sure
>> dev->data->rx_queues[i] has been freed in PMD close() function, So this
>> two should be better done at the same time, ether in
>> rte_eth_dev_close() or in PMD close() function. For hotplug in fm10k, I put it
>> in PMD close() function.
>>
>> Thanks,
>> Michael
> Hi Michael,
>  
> The consensus is that the rx_queue and tx_queue memory should not be released in the PMD as it is not allocated by the PMD. The memory is allocated in rte_eth_dev_rx_queue_config() and rte_eth_dev_tx_queue_config(), which are both called from rte_eth_dev_configure() which is called by the application (for example test_pmd). So it seems to make sense to free this memory  in rte_eth_dev_uninit().

It really make sense to free memory in rte_ether level, but when close a
port with out detached? just as stop --> close() --> quit(), the memory
will not be released :)

Thanks,
Michael
 
>
> Regards,
>
> Bernard.
>
>
>
>
>


^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit function.
  2015-06-29 15:22       ` Qiu, Michael
@ 2015-06-29 16:42         ` Iremonger, Bernard
  2015-06-30  1:31           ` Qiu, Michael
  0 siblings, 1 reply; 270+ messages in thread
From: Iremonger, Bernard @ 2015-06-29 16:42 UTC (permalink / raw)
  To: Qiu, Michael, dev



> -----Original Message-----
> From: Qiu, Michael
> Sent: Monday, June 29, 2015 4:22 PM
> To: Iremonger, Bernard; dev@dpdk.org
> Cc: Zhang, Helin; Ananyev, Konstantin; mukawa@igel.co.jp; Stephen
> Hemminger
> Subject: Re: [PATCH v2] librte_ether: release memory in uninit function.
> 
> On 2015/6/29 18:20, Iremonger, Bernard wrote:
> >
> >> -----Original Message-----
> >> From: Qiu, Michael
> >> Sent: Monday, June 29, 2015 9:55 AM
> >> To: Iremonger, Bernard; dev@dpdk.org
> >> Cc: Zhang, Helin; Ananyev, Konstantin; mukawa@igel.co.jp; Stephen
> >> Hemminger
> >> Subject: Re: [PATCH v2] librte_ether: release memory in uninit function.
> >>
> >> On 6/26/2015 5:32 PM, Iremonger, Bernard wrote:
> >>> Changes in v2:
> >>> do not free mac_addrs and hash_mac_addrs here.
> >>>
> >>> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> >>> ---
> >>>  lib/librte_ether/rte_ethdev.c |    6 +++++-
> >>>  1 files changed, 5 insertions(+), 1 deletions(-)
> >>>
> >>> diff --git a/lib/librte_ether/rte_ethdev.c
> >>> b/lib/librte_ether/rte_ethdev.c index e13fde5..7ae101a 100644
> >>> --- a/lib/librte_ether/rte_ethdev.c
> >>> +++ b/lib/librte_ether/rte_ethdev.c
> >>> @@ -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;
> >>
> >> Actually, This could be put in rte_eth_dev_close() becasue queues
> >> should be released when closed.
> >>
> >> Also before free dev->data->rx_queues you should make sure
> >> dev->data->rx_queues[i] has been freed in PMD close() function, So
> >> dev->data->this
> >> two should be better done at the same time, ether in
> >> rte_eth_dev_close() or in PMD close() function. For hotplug in fm10k,
> >> I put it in PMD close() function.
> >>
> >> Thanks,
> >> Michael
> > Hi Michael,
> >
> > The consensus is that the rx_queue and tx_queue memory should not be
> released in the PMD as it is not allocated by the PMD. The memory is
> allocated in rte_eth_dev_rx_queue_config() and
> rte_eth_dev_tx_queue_config(), which are both called from
> rte_eth_dev_configure() which is called by the application (for example
> test_pmd). So it seems to make sense to free this memory  in
> rte_eth_dev_uninit().
> 
> It really make sense to free memory in rte_ether level, but when close a port
> with out detached? just as stop --> close() --> quit(), the memory will not be
> released :)
> 

In the above scenario lots of memory will not be released.

This is why the detach() and the underlying dev_uninit() functions were introduced.
The dev_uninit() functions currently call dev_close()  which in turn calls dev_stop() which calls dev_clear_queues(). 
The dev_clear_queues()  function does not release the queue_memory or the queue array memory. The queue memory is now released in the dev_uninit() and the  queue array memory is released in the rte_eth_dev_uninit() function.

If the queue array memory is released in rte_eth_dev_close() then the release of the queue_memory will have to be moved to the dev_close() functions from the dev_uninit() functions. This will impact all the existing  PMD hotplug patches.   It will also change the existing dev_close() functionality.

My preference is to leave the existing dev_close() functions unchanged as far as possible and to do what needs to be done in the dev_uninit() functions.

We probably need the view of the maintainers as to whether this should be done in the close() or uninit() functions.  

Regards,

Bernard.

 

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit function.
  2015-06-29 16:42         ` Iremonger, Bernard
@ 2015-06-30  1:31           ` Qiu, Michael
  2015-07-06 11:35             ` Qiu, Michael
  0 siblings, 1 reply; 270+ messages in thread
From: Qiu, Michael @ 2015-06-30  1:31 UTC (permalink / raw)
  To: Iremonger, Bernard, dev

On 6/30/2015 12:42 AM, Iremonger, Bernard wrote:
>
>> -----Original Message-----
>> From: Qiu, Michael
>> Sent: Monday, June 29, 2015 4:22 PM
>> To: Iremonger, Bernard; dev@dpdk.org
>> Cc: Zhang, Helin; Ananyev, Konstantin; mukawa@igel.co.jp; Stephen
>> Hemminger
>> Subject: Re: [PATCH v2] librte_ether: release memory in uninit function.
>>
>> On 2015/6/29 18:20, Iremonger, Bernard wrote:
>>>> -----Original Message-----
>>>> From: Qiu, Michael
>>>> Sent: Monday, June 29, 2015 9:55 AM
>>>> To: Iremonger, Bernard; dev@dpdk.org
>>>> Cc: Zhang, Helin; Ananyev, Konstantin; mukawa@igel.co.jp; Stephen
>>>> Hemminger
>>>> Subject: Re: [PATCH v2] librte_ether: release memory in uninit function.
>>>>
>>>> On 6/26/2015 5:32 PM, Iremonger, Bernard wrote:
>>>>> Changes in v2:
>>>>> do not free mac_addrs and hash_mac_addrs here.
>>>>>
>>>>> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
>>>>> ---
>>>>>  lib/librte_ether/rte_ethdev.c |    6 +++++-
>>>>>  1 files changed, 5 insertions(+), 1 deletions(-)
>>>>>
>>>>> diff --git a/lib/librte_ether/rte_ethdev.c
>>>>> b/lib/librte_ether/rte_ethdev.c index e13fde5..7ae101a 100644
>>>>> --- a/lib/librte_ether/rte_ethdev.c
>>>>> +++ b/lib/librte_ether/rte_ethdev.c
>>>>> @@ -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;
>>>> Actually, This could be put in rte_eth_dev_close() becasue queues
>>>> should be released when closed.
>>>>
>>>> Also before free dev->data->rx_queues you should make sure
>>>> dev->data->rx_queues[i] has been freed in PMD close() function, So
>>>> dev->data->this
>>>> two should be better done at the same time, ether in
>>>> rte_eth_dev_close() or in PMD close() function. For hotplug in fm10k,
>>>> I put it in PMD close() function.
>>>>
>>>> Thanks,
>>>> Michael
>>> Hi Michael,
>>>
>>> The consensus is that the rx_queue and tx_queue memory should not be
>> released in the PMD as it is not allocated by the PMD. The memory is
>> allocated in rte_eth_dev_rx_queue_config() and
>> rte_eth_dev_tx_queue_config(), which are both called from
>> rte_eth_dev_configure() which is called by the application (for example
>> test_pmd). So it seems to make sense to free this memory  in
>> rte_eth_dev_uninit().
>>
>> It really make sense to free memory in rte_ether level, but when close a port
>> with out detached? just as stop --> close() --> quit(), the memory will not be
>> released :)
>>
> In the above scenario lots of memory will not be released.
>
> This is why the detach() and the underlying dev_uninit() functions were introduced.

First detach is only for hotplug, for *users do not use hotplug*, that
scenario is the right action. So  "lots of memory will not be released"
is issue need be fixed, actually, in fm10k driver, lots of memory has
been released.

> The dev_uninit() functions currently call dev_close()  which in turn calls dev_stop() which calls dev_clear_queues(). 

Users do hotplug then must call stop() --> close() --> dev_uninit(), it
works fine. But do you think it make sense to release memory when
close() it?
 
> The dev_clear_queues()  function does not release the queue_memory or the queue array memory. The queue memory is now released in the dev_uninit() and the  queue array memory is released in the rte_eth_dev_uninit() function.

That's your implementation,  make sure not all users will detach a
device, but the right action must include close(), do you agree?

>
> If the queue array memory is released in rte_eth_dev_close() then the release of the queue_memory will have to be moved to the dev_close() functions from the dev_uninit() functions. This will impact all the existing  PMD hotplug patches.   It will also change the existing dev_close() functionality.

Why impact?? Actually it works fine with fm10k driver. What I concern is
*when user do not use hotplug*, it will lead lots of memory not
released, that unacceptable, to move release action to
rte_eth_dev_close()  is just a   suggestion by me, I think *the solution
should cover both scenario*, am I right?


>
> My preference is to leave the existing dev_close() functions unchanged as far as possible and to do what needs to be done in the dev_uninit() functions.
>
> We probably need the view of the maintainers as to whether this should be done in the close() or uninit() functions.  
>
> Regards,
>
> Bernard.
>
>  
>
>
>
>


^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v6 0/2] PCI Port Hotplug
       [not found] <PATCH>
                   ` (12 preceding siblings ...)
  2015-06-26  9:32 ` [dpdk-dev] [PATCH v2] " Bernard Iremonger
@ 2015-07-02 14:36 ` Bernard Iremonger
  2015-07-02 14:36   ` [dpdk-dev] [PATCH v6 1/2] ixgbe: changes to support " Bernard Iremonger
                     ` (3 more replies)
  2015-07-03 14:03 ` [dpdk-dev] [PATCH v6 0/7] i40e: PCI Port Hotplug Changes Bernard Iremonger
                   ` (27 subsequent siblings)
  41 siblings, 4 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-02 14:36 UTC (permalink / raw)
  To: dev

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(-)

-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v6 1/2] ixgbe: changes to support PCI Port Hotplug
  2015-07-02 14:36 ` [dpdk-dev] [PATCH v6 0/2] PCI Port Hotplug Bernard Iremonger
@ 2015-07-02 14:36   ` Bernard Iremonger
  2015-07-02 14:36   ` [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit function Bernard Iremonger
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-02 14:36 UTC (permalink / raw)
  To: dev

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

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 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(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index f18550c..f5fe120 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);
@@ -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);
 
 	/*
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

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit function.
  2015-07-02 14:36 ` [dpdk-dev] [PATCH v6 0/2] PCI Port Hotplug Bernard Iremonger
  2015-07-02 14:36   ` [dpdk-dev] [PATCH v6 1/2] ixgbe: changes to support " Bernard Iremonger
@ 2015-07-02 14:36   ` Bernard Iremonger
  2015-07-02 14:36   ` [dpdk-dev] [PATCH v6 2/2] ixgbe: release queue memory in close functions Bernard Iremonger
  2015-07-02 14:59   ` [dpdk-dev] [PATCH v6 0/2] PCI Port Hotplug Ananyev, Konstantin
  3 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-02 14:36 UTC (permalink / raw)
  To: dev

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

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 lib/librte_ether/rte_ethdev.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index e13fde5..7ae101a 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -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;
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v6 2/2] ixgbe: release queue memory in close functions
  2015-07-02 14:36 ` [dpdk-dev] [PATCH v6 0/2] PCI Port Hotplug Bernard Iremonger
  2015-07-02 14:36   ` [dpdk-dev] [PATCH v6 1/2] ixgbe: changes to support " Bernard Iremonger
  2015-07-02 14:36   ` [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit function Bernard Iremonger
@ 2015-07-02 14:36   ` Bernard Iremonger
  2015-07-02 14:59   ` [dpdk-dev] [PATCH v6 0/2] PCI Port Hotplug Ananyev, Konstantin
  3 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-02 14:36 UTC (permalink / raw)
  To: dev

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

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 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(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index f5fe120..4ff1671 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -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);
 }
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index 710ee87..fb9cea6 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -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);
diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index 3ace8a8..52ac188 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -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
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v6 0/2] PCI Port Hotplug
  2015-07-02 14:36 ` [dpdk-dev] [PATCH v6 0/2] PCI Port Hotplug Bernard Iremonger
                     ` (2 preceding siblings ...)
  2015-07-02 14:36   ` [dpdk-dev] [PATCH v6 2/2] ixgbe: release queue memory in close functions Bernard Iremonger
@ 2015-07-02 14:59   ` Ananyev, Konstantin
  2015-07-19 15:42     ` Thomas Monjalon
  3 siblings, 1 reply; 270+ messages in thread
From: Ananyev, Konstantin @ 2015-07-02 14:59 UTC (permalink / raw)
  To: Iremonger, Bernard, dev



> -----Original Message-----
> From: Iremonger, Bernard
> Sent: Thursday, July 02, 2015 3:37 PM
> To: dev@dpdk.org
> 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
> 
>  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(-)
> 
> --

Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

> 1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v6 0/7] i40e: PCI Port Hotplug Changes
       [not found] <PATCH>
                   ` (13 preceding siblings ...)
  2015-07-02 14:36 ` [dpdk-dev] [PATCH v6 0/2] PCI Port Hotplug Bernard Iremonger
@ 2015-07-03 14:03 ` Bernard Iremonger
  2015-07-03 14:03   ` [dpdk-dev] [PATCH v6 1/7] i40e: changes to support PCI Port Hotplug Bernard Iremonger
                     ` (7 more replies)
  2015-07-03 14:38 ` [dpdk-dev] [PATCH v7 0/2] e1000: PCI Port Hotplug changes Bernard Iremonger
                   ` (26 subsequent siblings)
  41 siblings, 8 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-03 14:03 UTC (permalink / raw)
  To: dev

Changes in V6:
Rebased to latest code.
Removed release of rx and tx queues from uninit() functions.
added patch 7, add function i40e_dev_free_queues() and call from close() functions.

Changes in V5:
Increased timeout in i40evf_wait_cmd_done()
Set nb_rx_queues and nb_tx_queues to 0 in uninit functions.
Rebased to latest i40e code.

Changes in V4:
added patch 6 to fix segmentation fault reported by Michael Qiu.
Rebase to latest i40e code.

Changes in V3:
Release rx and tx queues in vf uninit function.
Rebase to use latest i40e code.

Changes in V2:
Rebase to use drivers/net/i40e directory.


Bernard Iremonger (7):
  i40e: changes to support PCI Port Hotplug
  i40e: release vmdq vsi's in dev_close
  i40e: increase ASQ_DELAY_MS to 100 and MAX_TRY_TIMES to 20 in
    i40evf_wait_cmd_done()
  i40e: call _clear_cmd() when error occurs
  i40e: clear queues in i40evf_dev_stop
  i40e: check rxq parameter in i40e_reset_rx_queue
  i40e: release queue memory in close functions

 drivers/net/i40e/i40e_ethdev.c    |   78 ++++++++++++++++++++++++++++++++++++-
 drivers/net/i40e/i40e_ethdev_vf.c |   62 ++++++++++++++++++++++++++---
 drivers/net/i40e/i40e_pf.c        |   34 ++++++++++++++++
 drivers/net/i40e/i40e_pf.h        |    1 +
 drivers/net/i40e/i40e_rxtx.c      |   25 ++++++++++++
 drivers/net/i40e/i40e_rxtx.h      |    1 +
 6 files changed, 193 insertions(+), 8 deletions(-)

-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v6 1/7] i40e: changes to support PCI Port Hotplug
  2015-07-03 14:03 ` [dpdk-dev] [PATCH v6 0/7] i40e: PCI Port Hotplug Changes Bernard Iremonger
@ 2015-07-03 14:03   ` Bernard Iremonger
  2015-07-03 14:03   ` [dpdk-dev] [PATCH v6 2/7] i40e: release vmdq vsi's in dev_close Bernard Iremonger
                     ` (6 subsequent siblings)
  7 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-03 14:03 UTC (permalink / raw)
  To: dev

This patch depends on the Port Hotplug Framework.
It implements the eth_dev_uninit functions for rte_i40e_pmd and
rte_i40evf_pmd.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c    |   68 ++++++++++++++++++++++++++++++++++++-
 drivers/net/i40e/i40e_ethdev_vf.c |   45 ++++++++++++++++++++++++-
 drivers/net/i40e/i40e_pf.c        |   34 ++++++++++++++++++
 drivers/net/i40e/i40e_pf.h        |    1 +
 4 files changed, 146 insertions(+), 2 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 2ada502..449785b 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -107,6 +107,7 @@
 	(1UL << RTE_ETH_FLOW_L2_PAYLOAD))
 
 static int eth_i40e_dev_init(struct rte_eth_dev *eth_dev);
+static int eth_i40e_dev_uninit(struct rte_eth_dev *eth_dev);
 static int i40e_dev_configure(struct rte_eth_dev *dev);
 static int i40e_dev_start(struct rte_eth_dev *dev);
 static void i40e_dev_stop(struct rte_eth_dev *dev);
@@ -268,9 +269,11 @@ static struct eth_driver rte_i40e_pmd = {
 	.pci_drv = {
 		.name = "rte_i40e_pmd",
 		.id_table = pci_id_i40e_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_i40e_dev_init,
+	.eth_dev_uninit = eth_i40e_dev_uninit,
 	.dev_private_size = sizeof(struct i40e_adapter),
 };
 
@@ -405,6 +408,7 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 	hw->subsystem_device_id = pci_dev->id.subsystem_device_id;
 	hw->bus.device = pci_dev->addr.devid;
 	hw->bus.func = pci_dev->addr.function;
+	hw->adapter_stopped = 0;
 
 	/* Make sure all is clean before doing PF reset */
 	i40e_clear_hw(hw);
@@ -584,6 +588,65 @@ err_get_capabilities:
 }
 
 static int
+eth_i40e_dev_uninit(struct rte_eth_dev *dev)
+{
+	struct rte_pci_device *pci_dev;
+	struct i40e_hw *hw;
+	struct i40e_filter_control_settings settings;
+	int ret;
+	uint8_t aq_fail = 0;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
+	hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	pci_dev = dev->pci_dev;
+
+	if (hw->adapter_stopped == 0)
+		i40e_dev_close(dev);
+
+	dev->dev_ops = NULL;
+	dev->rx_pkt_burst = NULL;
+	dev->tx_pkt_burst = NULL;
+
+	/* Disable LLDP */
+	ret = i40e_aq_stop_lldp(hw, true, NULL);
+	if (ret != I40E_SUCCESS) /* Its failure can be ignored */
+		PMD_INIT_LOG(INFO, "Failed to stop lldp");
+
+	/* Clear PXE mode */
+	i40e_clear_pxe_mode(hw);
+
+	/* Unconfigure filter control */
+	memset(&settings, 0, sizeof(settings));
+	ret = i40e_set_filter_control(hw, &settings);
+	if (ret)
+		PMD_INIT_LOG(WARNING, "setup_pf_filter_control failed: %d",
+					ret);
+
+	/* Disable flow control */
+	hw->fc.requested_mode = I40E_FC_NONE;
+	i40e_set_fc(hw, &aq_fail, TRUE);
+
+	/* uninitialize pf host driver */
+	i40e_pf_host_uninit(dev);
+
+	rte_free(dev->data->mac_addrs);
+	dev->data->mac_addrs = NULL;
+
+	/* disable uio intr before callback unregister */
+	rte_intr_disable(&(pci_dev->intr_handle));
+
+	/* register callback func to eal lib */
+	rte_intr_callback_unregister(&(pci_dev->intr_handle),
+		i40e_dev_interrupt_handler, (void *)dev);
+
+	return 0;
+}
+
+static int
 i40e_dev_configure(struct rte_eth_dev *dev)
 {
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
@@ -858,6 +921,8 @@ i40e_dev_start(struct rte_eth_dev *dev)
 	struct i40e_vsi *main_vsi = pf->main_vsi;
 	int ret, i;
 
+	hw->adapter_stopped = 0;
+
 	if ((dev->data->dev_conf.link_duplex != ETH_LINK_AUTONEG_DUPLEX) &&
 		(dev->data->dev_conf.link_duplex != ETH_LINK_FULL_DUPLEX)) {
 		PMD_INIT_LOG(ERR, "Invalid link_duplex (%hu) for port %hhu",
@@ -965,6 +1030,7 @@ i40e_dev_close(struct rte_eth_dev *dev)
 	PMD_INIT_FUNC_TRACE();
 
 	i40e_dev_stop(dev);
+	hw->adapter_stopped = 1;
 
 	/* Disable interrupt */
 	i40e_pf_disable_irq0(hw);
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index f7332e7..fb12d63 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1146,6 +1146,22 @@ err:
 }
 
 static int
+i40evf_uninit_vf(struct rte_eth_dev *dev)
+{
+	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (hw->adapter_stopped == 0)
+		i40evf_dev_close(dev);
+	rte_free(vf->vf_res);
+	vf->vf_res = NULL;
+
+	return 0;
+}
+
+static int
 i40evf_dev_init(struct rte_eth_dev *eth_dev)
 {
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(\
@@ -1175,6 +1191,7 @@ i40evf_dev_init(struct rte_eth_dev *eth_dev)
 	hw->bus.device = eth_dev->pci_dev->addr.devid;
 	hw->bus.func = eth_dev->pci_dev->addr.function;
 	hw->hw_addr = (void *)eth_dev->pci_dev->mem_resource[0].addr;
+	hw->adapter_stopped = 0;
 
 	if(i40evf_init_vf(eth_dev) != 0) {
 		PMD_INIT_LOG(ERR, "Init vf failed");
@@ -1195,6 +1212,28 @@ i40evf_dev_init(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static int
+i40evf_dev_uninit(struct rte_eth_dev *eth_dev)
+{
+	PMD_INIT_FUNC_TRACE();
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return -EPERM;
+
+	eth_dev->dev_ops = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+
+	if (i40evf_uninit_vf(eth_dev) != 0) {
+		PMD_INIT_LOG(ERR, "i40evf_uninit_vf failed");
+		return -1;
+	}
+
+	rte_free(eth_dev->data->mac_addrs);
+	eth_dev->data->mac_addrs = NULL;
+
+	return 0;
+}
 /*
  * virtual function driver struct
  */
@@ -1202,9 +1241,10 @@ static struct eth_driver rte_i40evf_pmd = {
 	.pci_drv = {
 		.name = "rte_i40evf_pmd",
 		.id_table = pci_id_i40evf_map,
-		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
 	},
 	.eth_dev_init = i40evf_dev_init,
+	.eth_dev_uninit = i40evf_dev_uninit,
 	.dev_private_size = sizeof(struct i40e_vf),
 };
 
@@ -1524,6 +1564,8 @@ i40evf_dev_start(struct rte_eth_dev *dev)
 
 	PMD_INIT_FUNC_TRACE();
 
+	hw->adapter_stopped = 0;
+
 	vf->max_pkt_len = dev->data->dev_conf.rxmode.max_rx_pkt_len;
 	vf->num_queue_pairs = RTE_MAX(dev->data->nb_rx_queues,
 					dev->data->nb_tx_queues);
@@ -1709,6 +1751,7 @@ i40evf_dev_close(struct rte_eth_dev *dev)
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
 	i40evf_dev_stop(dev);
+	hw->adapter_stopped = 1;
 	i40evf_reset_vf(hw);
 	i40e_shutdown_adminq(hw);
 }
diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index b89a1e2..95c960c 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -1061,3 +1061,37 @@ fail:
 
 	return ret;
 }
+
+int
+i40e_pf_host_uninit(struct rte_eth_dev *dev)
+{
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+	uint32_t val;
+
+	PMD_INIT_FUNC_TRACE();
+
+	/**
+	 * return if SRIOV not enabled, VF number not configured or
+	 * no queue assigned.
+	 */
+	if ((!hw->func_caps.sr_iov_1_1) ||
+		(pf->vf_num == 0) ||
+		(pf->vf_nb_qps == 0))
+		return I40E_SUCCESS;
+
+	/* free memory to store VF structure */
+	rte_free(pf->vfs);
+	pf->vfs = NULL;
+
+	/* Disable irq0 for VFR event */
+	i40e_pf_disable_irq0(hw);
+
+	/* Disable VF link status interrupt */
+	val = I40E_READ_REG(hw, I40E_PFGEN_PORTMDIO_NUM);
+	val &= ~I40E_PFGEN_PORTMDIO_NUM_VFLINK_STAT_ENA_MASK;
+	I40E_WRITE_REG(hw, I40E_PFGEN_PORTMDIO_NUM, val);
+	I40E_WRITE_FLUSH(hw);
+
+	return I40E_SUCCESS;
+}
diff --git a/drivers/net/i40e/i40e_pf.h b/drivers/net/i40e/i40e_pf.h
index e08ba49..9c01829 100644
--- a/drivers/net/i40e/i40e_pf.h
+++ b/drivers/net/i40e/i40e_pf.h
@@ -123,5 +123,6 @@ void i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev,
 				__rte_unused uint32_t retval,
 				uint8_t *msg, uint16_t msglen);
 int i40e_pf_host_init(struct rte_eth_dev *dev);
+int i40e_pf_host_uninit(struct rte_eth_dev *dev);
 
 #endif /* _I40E_PF_H_ */
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v6 2/7] i40e: release vmdq vsi's in dev_close
  2015-07-03 14:03 ` [dpdk-dev] [PATCH v6 0/7] i40e: PCI Port Hotplug Changes Bernard Iremonger
  2015-07-03 14:03   ` [dpdk-dev] [PATCH v6 1/7] i40e: changes to support PCI Port Hotplug Bernard Iremonger
@ 2015-07-03 14:03   ` Bernard Iremonger
  2015-07-03 14:03   ` [dpdk-dev] [PATCH v6 3/7] i40e: increase ASQ_DELAY_MS to 100 and MAX_TRY_TIMES to 20 in i40evf_wait_cmd_done() Bernard Iremonger
                     ` (5 subsequent siblings)
  7 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-03 14:03 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 449785b..bc1bab2 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -1026,6 +1026,7 @@ i40e_dev_close(struct rte_eth_dev *dev)
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	uint32_t reg;
+	int i;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -1043,6 +1044,14 @@ i40e_dev_close(struct rte_eth_dev *dev)
 	i40e_fdir_teardown(pf);
 	i40e_vsi_release(pf->main_vsi);
 
+	for (i = 0; i < pf->nb_cfg_vmdq_vsi; i++) {
+		i40e_vsi_release(pf->vmdq[i].vsi);
+		pf->vmdq[i].vsi = NULL;
+	}
+
+	rte_free(pf->vmdq);
+	pf->vmdq = NULL;
+
 	/* shutdown the adminq */
 	i40e_aq_queue_shutdown(hw, true);
 	i40e_shutdown_adminq(hw);
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v6 3/7] i40e: increase ASQ_DELAY_MS to 100 and MAX_TRY_TIMES to 20 in i40evf_wait_cmd_done()
  2015-07-03 14:03 ` [dpdk-dev] [PATCH v6 0/7] i40e: PCI Port Hotplug Changes Bernard Iremonger
  2015-07-03 14:03   ` [dpdk-dev] [PATCH v6 1/7] i40e: changes to support PCI Port Hotplug Bernard Iremonger
  2015-07-03 14:03   ` [dpdk-dev] [PATCH v6 2/7] i40e: release vmdq vsi's in dev_close Bernard Iremonger
@ 2015-07-03 14:03   ` Bernard Iremonger
  2015-07-03 14:03   ` [dpdk-dev] [PATCH v6 4/7] i40e: call _clear_cmd() when error occurs Bernard Iremonger
                     ` (4 subsequent siblings)
  7 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-03 14:03 UTC (permalink / raw)
  To: dev

Increase delay from 50 * 10 to 100 * 20 to avoid i40evf_read_pfmsg() failures.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/i40e/i40e_ethdev_vf.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index fb12d63..f0142ad 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -298,8 +298,8 @@ i40evf_wait_cmd_done(struct rte_eth_dev *dev,
 	int i = 0;
 	enum i40evf_aq_result ret;
 
-#define MAX_TRY_TIMES 10
-#define ASQ_DELAY_MS  50
+#define MAX_TRY_TIMES 20
+#define ASQ_DELAY_MS  100
 	do {
 		/* Delay some time first */
 		rte_delay_ms(ASQ_DELAY_MS);
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v6 4/7] i40e: call _clear_cmd() when error occurs
  2015-07-03 14:03 ` [dpdk-dev] [PATCH v6 0/7] i40e: PCI Port Hotplug Changes Bernard Iremonger
                     ` (2 preceding siblings ...)
  2015-07-03 14:03   ` [dpdk-dev] [PATCH v6 3/7] i40e: increase ASQ_DELAY_MS to 100 and MAX_TRY_TIMES to 20 in i40evf_wait_cmd_done() Bernard Iremonger
@ 2015-07-03 14:03   ` Bernard Iremonger
  2015-07-03 14:03   ` [dpdk-dev] [PATCH v6 5/7] i40e: clear queues in i40evf_dev_stop Bernard Iremonger
                     ` (3 subsequent siblings)
  7 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-03 14:03 UTC (permalink / raw)
  To: dev

_clear_cmd() was not being called in failure situations,
resulting in the next command also failing.
Fix several typos.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/i40e/i40e_ethdev_vf.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index f0142ad..b2c32d6 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -361,6 +361,7 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
 		     args->in_args, args->in_args_size, NULL);
 	if (err) {
 		PMD_DRV_LOG(ERR, "fail to send cmd %d", args->ops);
+		_clear_cmd(vf);
 		return err;
 	}
 
@@ -368,8 +369,10 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
 	/* read message and it's expected one */
 	if (!err && args->ops == info.ops)
 		_clear_cmd(vf);
-	else if (err)
+	else if (err) {
 		PMD_DRV_LOG(ERR, "Failed to read message from AdminQ");
+		_clear_cmd(vf);
+	}
 	else if (args->ops != info.ops)
 		PMD_DRV_LOG(ERR, "command mismatch, expect %u, get %u",
 			    args->ops, info.ops);
@@ -794,7 +797,7 @@ i40evf_stop_queues(struct rte_eth_dev *dev)
 	/* Stop TX queues first */
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
 		if (i40evf_dev_tx_queue_stop(dev, i) != 0) {
-			PMD_DRV_LOG(ERR, "Fail to start queue %u", i);
+			PMD_DRV_LOG(ERR, "Fail to stop queue %u", i);
 			return -1;
 		}
 	}
@@ -802,7 +805,7 @@ i40evf_stop_queues(struct rte_eth_dev *dev)
 	/* Then stop RX queues */
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		if (i40evf_dev_rx_queue_stop(dev, i) != 0) {
-			PMD_DRV_LOG(ERR, "Fail to start queue %u", i);
+			PMD_DRV_LOG(ERR, "Fail to stop queue %u", i);
 			return -1;
 		}
 	}
@@ -1431,7 +1434,7 @@ i40evf_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 		err = i40evf_switch_queue(dev, FALSE, tx_queue_id, FALSE);
 
 		if (err) {
-			PMD_DRV_LOG(ERR, "Failed to switch TX queue %u of",
+			PMD_DRV_LOG(ERR, "Failed to switch TX queue %u off",
 				    tx_queue_id);
 			return err;
 		}
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v6 5/7] i40e: clear queues in i40evf_dev_stop
  2015-07-03 14:03 ` [dpdk-dev] [PATCH v6 0/7] i40e: PCI Port Hotplug Changes Bernard Iremonger
                     ` (3 preceding siblings ...)
  2015-07-03 14:03   ` [dpdk-dev] [PATCH v6 4/7] i40e: call _clear_cmd() when error occurs Bernard Iremonger
@ 2015-07-03 14:03   ` Bernard Iremonger
  2015-07-03 14:03   ` [dpdk-dev] [PATCH v6 6/7] i40e: check rxq parameter in i40e_reset_rx_queue Bernard Iremonger
                     ` (2 subsequent siblings)
  7 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-03 14:03 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/i40e/i40e_ethdev_vf.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index b2c32d6..d2b86a7 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1620,6 +1620,7 @@ i40evf_dev_stop(struct rte_eth_dev *dev)
 
 	i40evf_disable_queues_intr(hw);
 	i40evf_stop_queues(dev);
+	i40e_dev_clear_queues(dev);
 }
 
 static int
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v6 6/7] i40e: check rxq parameter in i40e_reset_rx_queue
  2015-07-03 14:03 ` [dpdk-dev] [PATCH v6 0/7] i40e: PCI Port Hotplug Changes Bernard Iremonger
                     ` (4 preceding siblings ...)
  2015-07-03 14:03   ` [dpdk-dev] [PATCH v6 5/7] i40e: clear queues in i40evf_dev_stop Bernard Iremonger
@ 2015-07-03 14:03   ` Bernard Iremonger
  2015-07-03 14:04   ` [dpdk-dev] [PATCH v6 7/7] i40e: release queue memory in close functions Bernard Iremonger
  2015-07-10 20:44   ` [dpdk-dev] [PATCH v6 0/7] i40e: PCI Port Hotplug Changes Zhang, Helin
  7 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-03 14:03 UTC (permalink / raw)
  To: dev

There is a segmentation fault if rxq is NULL

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/i40e/i40e_rxtx.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 2de0ac4..2a89e84 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -2269,6 +2269,11 @@ i40e_reset_rx_queue(struct i40e_rx_queue *rxq)
 	unsigned i;
 	uint16_t len;
 
+	if (!rxq) {
+		PMD_DRV_LOG(DEBUG, "Pointer to rxq is NULL");
+		return;
+	}
+
 #ifdef RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC
 	if (check_rx_burst_bulk_alloc_preconditions(rxq) == 0)
 		len = (uint16_t)(rxq->nb_rx_desc + RTE_PMD_I40E_RX_MAX_BURST);
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v6 7/7] i40e: release queue memory in close functions
  2015-07-03 14:03 ` [dpdk-dev] [PATCH v6 0/7] i40e: PCI Port Hotplug Changes Bernard Iremonger
                     ` (5 preceding siblings ...)
  2015-07-03 14:03   ` [dpdk-dev] [PATCH v6 6/7] i40e: check rxq parameter in i40e_reset_rx_queue Bernard Iremonger
@ 2015-07-03 14:04   ` Bernard Iremonger
  2015-07-10 20:44   ` [dpdk-dev] [PATCH v6 0/7] i40e: PCI Port Hotplug Changes Zhang, Helin
  7 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-03 14:04 UTC (permalink / raw)
  To: dev

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

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c    |    1 +
 drivers/net/i40e/i40e_ethdev_vf.c |    1 +
 drivers/net/i40e/i40e_rxtx.c      |   20 ++++++++++++++++++++
 drivers/net/i40e/i40e_rxtx.h      |    1 +
 4 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index bc1bab2..cdb5576 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -1032,6 +1032,7 @@ i40e_dev_close(struct rte_eth_dev *dev)
 
 	i40e_dev_stop(dev);
 	hw->adapter_stopped = 1;
+	i40e_dev_free_queues(dev);
 
 	/* Disable interrupt */
 	i40e_pf_disable_irq0(hw);
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index d2b86a7..41c0b93 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1756,6 +1756,7 @@ i40evf_dev_close(struct rte_eth_dev *dev)
 
 	i40evf_dev_stop(dev);
 	hw->adapter_stopped = 1;
+	i40e_dev_free_queues(dev);
 	i40evf_reset_vf(hw);
 	i40e_shutdown_adminq(hw);
 }
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 2a89e84..6c11c75 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -2588,6 +2588,26 @@ i40e_dev_clear_queues(struct rte_eth_dev *dev)
 	}
 }
 
+void
+i40e_dev_free_queues(struct rte_eth_dev *dev)
+{
+	uint16_t i;
+
+	PMD_INIT_FUNC_TRACE();
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		i40e_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++) {
+		i40e_dev_tx_queue_release(dev->data->tx_queues[i]);
+		dev->data->tx_queues[i] = NULL;
+	}
+	dev->data->nb_tx_queues = 0;
+}
+
 #define I40E_FDIR_NUM_TX_DESC  I40E_MIN_RING_DESC
 #define I40E_FDIR_NUM_RX_DESC  I40E_MIN_RING_DESC
 
diff --git a/drivers/net/i40e/i40e_rxtx.h b/drivers/net/i40e/i40e_rxtx.h
index decbc3d..224ebb3 100644
--- a/drivers/net/i40e/i40e_rxtx.h
+++ b/drivers/net/i40e/i40e_rxtx.h
@@ -198,6 +198,7 @@ int i40e_rx_queue_init(struct i40e_rx_queue *rxq);
 void i40e_free_tx_resources(struct i40e_tx_queue *txq);
 void i40e_free_rx_resources(struct i40e_rx_queue *rxq);
 void i40e_dev_clear_queues(struct rte_eth_dev *dev);
+void i40e_dev_free_queues(struct rte_eth_dev *dev);
 void i40e_reset_rx_queue(struct i40e_rx_queue *rxq);
 void i40e_reset_tx_queue(struct i40e_tx_queue *txq);
 void i40e_tx_queue_release_mbufs(struct i40e_tx_queue *txq);
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v7 0/2] e1000: PCI Port Hotplug changes
       [not found] <PATCH>
                   ` (14 preceding siblings ...)
  2015-07-03 14:03 ` [dpdk-dev] [PATCH v6 0/7] i40e: PCI Port Hotplug Changes Bernard Iremonger
@ 2015-07-03 14:38 ` Bernard Iremonger
  2015-07-03 14:38   ` [dpdk-dev] [PATCH v7 1/2] e1000: igb and em1000 " Bernard Iremonger
                     ` (2 more replies)
  2015-07-07  9:18 ` [dpdk-dev] [PATCH v4 0/4] virtio: PCI Port Hotplug Bernard Iremonger
                   ` (25 subsequent siblings)
  41 siblings, 3 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-03 14:38 UTC (permalink / raw)
  To: dev

Changes in v7:
Rebase to latest code.
Remove freeing of queue memory from uninit functions
Add patch 2, free queue memory in close functions

Changes in v6:
Set nb_rx_queues and nb_tx_queues to 0 in uninit functions.
Rebase to latest code.

Changes in v5:
Moved adapter stopped boolean to struct e1000_adapter.
Rebase to latest code.

Changes in v4:
Release rx and tx queues in eth_igbvf_dev_uninit.

Changes in v3:
Add igb_adapter_stopped and em_adapter_stopped booleans.
Release rx and tx queues in eth_igb_dev_uninit.

Changes in v2:
Call dev_close() from  dev_uninit() functions.
Remove input parameter checking from dev_uninit() functions.


Bernard Iremonger (2):
  e1000: igb and em1000 PCI Port Hotplug changes
  e1000: free queue memory in close functions

 drivers/net/e1000/e1000_ethdev.h |   10 ++++-
 drivers/net/e1000/em_ethdev.c    |   47 ++++++++++++++++++-
 drivers/net/e1000/em_rxtx.c      |   18 +++++++
 drivers/net/e1000/igb_ethdev.c   |   96 ++++++++++++++++++++++++++++++++++++--
 drivers/net/e1000/igb_pf.c       |   22 +++++++++
 drivers/net/e1000/igb_rxtx.c     |   18 +++++++
 6 files changed, 205 insertions(+), 6 deletions(-)

-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v7 1/2] e1000: igb and em1000 PCI Port Hotplug changes
  2015-07-03 14:38 ` [dpdk-dev] [PATCH v7 0/2] e1000: PCI Port Hotplug changes Bernard Iremonger
@ 2015-07-03 14:38   ` Bernard Iremonger
  2015-07-13 15:53     ` Zhang, Helin
  2015-07-03 14:38   ` [dpdk-dev] [PATCH v7 2/2] e1000: free queue memory in close functions Bernard Iremonger
  2015-07-19 15:26   ` [dpdk-dev] [PATCH v7 0/2] e1000: PCI Port Hotplug changes Thomas Monjalon
  2 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-03 14:38 UTC (permalink / raw)
  To: dev

This patch depends on the Port Hotplug Framework.
It implements the eth_dev_uninit functions for rte_em_pmd,
rte_igb_pmd and rte_igbvf_pmd.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/e1000/e1000_ethdev.h |    8 +++-
 drivers/net/e1000/em_ethdev.c    |   46 ++++++++++++++++++-
 drivers/net/e1000/em_rxtx.c      |   12 +++++
 drivers/net/e1000/igb_ethdev.c   |   93 ++++++++++++++++++++++++++++++++++++-
 drivers/net/e1000/igb_pf.c       |   22 +++++++++
 drivers/net/e1000/igb_rxtx.c     |   12 +++++
 6 files changed, 188 insertions(+), 5 deletions(-)

diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h
index c451faa..ee8b872 100644
--- a/drivers/net/e1000/e1000_ethdev.h
+++ b/drivers/net/e1000/e1000_ethdev.h
@@ -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
@@ -229,8 +229,12 @@ struct e1000_adapter {
 	struct e1000_vfta       shadow_vfta;
 	struct e1000_vf_info    *vfdata;
 	struct e1000_filter_info filter;
+	bool stopped;
 };
 
+#define E1000_DEV_PRIVATE(adapter) \
+	((struct e1000_adapter *)adapter)
+
 #define E1000_DEV_PRIVATE_TO_HW(adapter) \
 	(&((struct e1000_adapter *)adapter)->hw)
 
@@ -337,4 +341,6 @@ uint16_t eth_em_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 uint16_t eth_em_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		uint16_t nb_pkts);
 
+void igb_pf_host_uninit(struct rte_eth_dev *dev);
+
 #endif /* _E1000_ETHDEV_H_ */
diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index a306c55..dfabb15 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -224,6 +224,8 @@ static int
 eth_em_dev_init(struct rte_eth_dev *eth_dev)
 {
 	struct rte_pci_device *pci_dev;
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(eth_dev->data->dev_private);
 	struct e1000_hw *hw =
 		E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 	struct e1000_vfta * shadow_vfta =
@@ -246,6 +248,7 @@ eth_em_dev_init(struct rte_eth_dev *eth_dev)
 
 	hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
 	hw->device_id = pci_dev->id.device_id;
+	adapter->stopped = 0;
 
 	/* For ICH8 support we'll need to map the flash memory BAR */
 
@@ -285,13 +288,47 @@ eth_em_dev_init(struct rte_eth_dev *eth_dev)
 	return (0);
 }
 
+static int
+eth_em_dev_uninit(struct rte_eth_dev *eth_dev)
+{
+	struct rte_pci_device *pci_dev;
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(eth_dev->data->dev_private);
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return -EPERM;
+
+	pci_dev = eth_dev->pci_dev;
+
+	if (adapter->stopped == 0)
+		eth_em_close(eth_dev);
+
+	eth_dev->dev_ops = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+
+	rte_free(eth_dev->data->mac_addrs);
+	eth_dev->data->mac_addrs = NULL;
+
+	/* disable uio intr before callback unregister */
+	rte_intr_disable(&(pci_dev->intr_handle));
+	rte_intr_callback_unregister(&(pci_dev->intr_handle),
+		eth_em_interrupt_handler, (void *)eth_dev);
+
+	return 0;
+}
+
 static struct eth_driver rte_em_pmd = {
 	.pci_drv = {
 		.name = "rte_em_pmd",
 		.id_table = pci_id_em_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_em_dev_init,
+	.eth_dev_uninit = eth_em_dev_uninit,
 	.dev_private_size = sizeof(struct e1000_adapter),
 };
 
@@ -451,6 +488,8 @@ em_set_pba(struct e1000_hw *hw)
 static int
 eth_em_start(struct rte_eth_dev *dev)
 {
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(dev->data->dev_private);
 	struct e1000_hw *hw =
 		E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	int ret, mask;
@@ -570,6 +609,8 @@ eth_em_start(struct rte_eth_dev *dev)
 		}
 	}
 
+	adapter->stopped = 0;
+
 	PMD_INIT_LOG(DEBUG, "<<");
 
 	return (0);
@@ -613,8 +654,11 @@ static void
 eth_em_close(struct rte_eth_dev *dev)
 {
 	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(dev->data->dev_private);
 
 	eth_em_stop(dev);
+	adapter->stopped = 1;
 	e1000_phy_hw_reset(hw);
 	em_release_manageability(hw);
 	em_hw_control_release(hw);
diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c
index fdc825f..976df60 100644
--- a/drivers/net/e1000/em_rxtx.c
+++ b/drivers/net/e1000/em_rxtx.c
@@ -1512,6 +1512,18 @@ em_dev_clear_queues(struct rte_eth_dev *dev)
 			em_reset_rx_queue(rxq);
 		}
 	}
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		eth_em_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++) {
+		eth_em_tx_queue_release(dev->data->tx_queues[i]);
+		dev->data->tx_queues[i] = NULL;
+	}
+	dev->data->nb_tx_queues = 0;
 }
 
 /*
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 24c7510..80e4a6c 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -465,9 +465,12 @@ eth_igb_dev_init(struct rte_eth_dev *eth_dev)
 	struct e1000_hw *hw =
 		E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 	struct e1000_vfta * shadow_vfta =
-			E1000_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
+		E1000_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
 	struct e1000_filter_info *filter_info =
 		E1000_DEV_PRIVATE_TO_FILTER_INFO(eth_dev->data->dev_private);
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(eth_dev->data->dev_private);
+
 	uint32_t ctrl_ext;
 
 	pci_dev = eth_dev->pci_dev;
@@ -570,6 +573,7 @@ eth_igb_dev_init(struct rte_eth_dev *eth_dev)
 		goto err_late;
 	}
 	hw->mac.get_link_status = 1;
+	adapter->stopped = 0;
 
 	/* Indicate SOL/IDER usage */
 	if (e1000_check_reset_block(hw) < 0) {
@@ -614,6 +618,46 @@ err_late:
 	return (error);
 }
 
+static int
+eth_igb_dev_uninit(struct rte_eth_dev *eth_dev)
+{
+	struct rte_pci_device *pci_dev;
+	struct e1000_hw *hw;
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(eth_dev->data->dev_private);
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return -EPERM;
+
+	hw = E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	pci_dev = eth_dev->pci_dev;
+
+	if (adapter->stopped == 0)
+		eth_igb_close(eth_dev);
+
+	eth_dev->dev_ops = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+
+	/* Reset any pending lock */
+	igb_reset_swfw_lock(hw);
+
+	rte_free(eth_dev->data->mac_addrs);
+	eth_dev->data->mac_addrs = NULL;
+
+	/* uninitialize PF if max_vfs not zero */
+	igb_pf_host_uninit(eth_dev);
+
+	/* disable uio intr before callback unregister */
+	rte_intr_disable(&(pci_dev->intr_handle));
+	rte_intr_callback_unregister(&(pci_dev->intr_handle),
+		eth_igb_interrupt_handler, (void *)eth_dev);
+
+	return 0;
+}
+
 /*
  * Virtual Function device init
  */
@@ -621,6 +665,8 @@ static int
 eth_igbvf_dev_init(struct rte_eth_dev *eth_dev)
 {
 	struct rte_pci_device *pci_dev;
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(eth_dev->data->dev_private);
 	struct e1000_hw *hw =
 		E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 	int diag;
@@ -645,6 +691,7 @@ eth_igbvf_dev_init(struct rte_eth_dev *eth_dev)
 	hw->device_id = pci_dev->id.device_id;
 	hw->vendor_id = pci_dev->id.vendor_id;
 	hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
+	adapter->stopped = 0;
 
 	/* Initialize the shared code (base driver) */
 	diag = e1000_setup_init_funcs(hw, TRUE);
@@ -685,13 +732,39 @@ eth_igbvf_dev_init(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static int
+eth_igbvf_dev_uninit(struct rte_eth_dev *eth_dev)
+{
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(eth_dev->data->dev_private);
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return -EPERM;
+
+	if (adapter->stopped == 0)
+		igbvf_dev_close(eth_dev);
+
+	eth_dev->dev_ops = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+
+	rte_free(eth_dev->data->mac_addrs);
+	eth_dev->data->mac_addrs = NULL;
+
+	return 0;
+}
+
 static struct eth_driver rte_igb_pmd = {
 	.pci_drv = {
 		.name = "rte_igb_pmd",
 		.id_table = pci_id_igb_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_igb_dev_init,
+	.eth_dev_uninit = eth_igb_dev_uninit,
 	.dev_private_size = sizeof(struct e1000_adapter),
 };
 
@@ -702,9 +775,10 @@ static struct eth_driver rte_igbvf_pmd = {
 	.pci_drv = {
 		.name = "rte_igbvf_pmd",
 		.id_table = pci_id_igbvf_map,
-		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
 	},
 	.eth_dev_init = eth_igbvf_dev_init,
+	.eth_dev_uninit = eth_igbvf_dev_uninit,
 	.dev_private_size = sizeof(struct e1000_adapter),
 };
 
@@ -758,6 +832,8 @@ eth_igb_start(struct rte_eth_dev *dev)
 {
 	struct e1000_hw *hw =
 		E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(dev->data->dev_private);
 	int ret, i, mask;
 	uint32_t ctrl_ext;
 
@@ -786,6 +862,7 @@ eth_igb_start(struct rte_eth_dev *dev)
 		PMD_INIT_LOG(ERR, "Unable to initialize the hardware");
 		return (-EIO);
 	}
+	adapter->stopped = 0;
 
 	E1000_WRITE_REG(hw, E1000_VET, ETHER_TYPE_VLAN << 16 | ETHER_TYPE_VLAN);
 
@@ -992,9 +1069,13 @@ static void
 eth_igb_close(struct rte_eth_dev *dev)
 {
 	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(dev->data->dev_private);
 	struct rte_eth_link link;
 
 	eth_igb_stop(dev);
+	adapter->stopped = 1;
+
 	e1000_phy_hw_reset(hw);
 	igb_release_manageability(hw);
 	igb_hw_control_release(hw);
@@ -2228,11 +2309,14 @@ igbvf_dev_start(struct rte_eth_dev *dev)
 {
 	struct e1000_hw *hw =
 		E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(dev->data->dev_private);
 	int ret;
 
 	PMD_INIT_FUNC_TRACE();
 
 	hw->mac.ops.reset_hw(hw);
+	adapter->stopped = 0;
 
 	/* Set all vfta */
 	igbvf_set_vfta_all(dev,1);
@@ -2270,12 +2354,15 @@ static void
 igbvf_dev_close(struct rte_eth_dev *dev)
 {
 	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct e1000_adapter *adapter =
+		E1000_DEV_PRIVATE(dev->data->dev_private);
 
 	PMD_INIT_FUNC_TRACE();
 
 	e1000_reset_hw(hw);
 
 	igbvf_dev_stop(dev);
+	adapter->stopped = 1;
 }
 
 static int igbvf_set_vfta(struct e1000_hw *hw, uint16_t vid, bool on)
diff --git a/drivers/net/e1000/igb_pf.c b/drivers/net/e1000/igb_pf.c
index 6a4d210..26c2960 100644
--- a/drivers/net/e1000/igb_pf.c
+++ b/drivers/net/e1000/igb_pf.c
@@ -127,6 +127,28 @@ void igb_pf_host_init(struct rte_eth_dev *eth_dev)
 	return;
 }
 
+void igb_pf_host_uninit(struct rte_eth_dev *dev)
+{
+	struct e1000_vf_info **vfinfo;
+	uint16_t vf_num;
+
+	PMD_INIT_FUNC_TRACE();
+
+	vfinfo = E1000_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
+
+	RTE_ETH_DEV_SRIOV(dev).active = 0;
+	RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = 0;
+	RTE_ETH_DEV_SRIOV(dev).def_vmdq_idx = 0;
+	RTE_ETH_DEV_SRIOV(dev).def_pool_q_idx = 0;
+
+	vf_num = dev_num_vf(dev);
+	if (vf_num == 0)
+		return;
+
+	rte_free(*vfinfo);
+	*vfinfo = NULL;
+}
+
 #define E1000_RAH_POOLSEL_SHIFT    (18)
 int igb_pf_host_configure(struct rte_eth_dev *eth_dev)
 {
diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c
index 43d6703..1bf8c93 100644
--- a/drivers/net/e1000/igb_rxtx.c
+++ b/drivers/net/e1000/igb_rxtx.c
@@ -1498,6 +1498,18 @@ igb_dev_clear_queues(struct rte_eth_dev *dev)
 			igb_reset_rx_queue(rxq);
 		}
 	}
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		eth_igb_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++) {
+		eth_igb_tx_queue_release(dev->data->tx_queues[i]);
+		dev->data->tx_queues[i] = NULL;
+	}
+	dev->data->nb_tx_queues = 0;
 }
 
 /**
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v7 2/2] e1000: free queue memory in close functions
  2015-07-03 14:38 ` [dpdk-dev] [PATCH v7 0/2] e1000: PCI Port Hotplug changes Bernard Iremonger
  2015-07-03 14:38   ` [dpdk-dev] [PATCH v7 1/2] e1000: igb and em1000 " Bernard Iremonger
@ 2015-07-03 14:38   ` Bernard Iremonger
  2015-07-13 15:54     ` Zhang, Helin
  2015-07-19 15:26   ` [dpdk-dev] [PATCH v7 0/2] e1000: PCI Port Hotplug changes Thomas Monjalon
  2 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-03 14:38 UTC (permalink / raw)
  To: dev

add new functions igb_dev_free_queues() and em_dev_free_queues()

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/e1000/e1000_ethdev.h |    2 ++
 drivers/net/e1000/em_ethdev.c    |    1 +
 drivers/net/e1000/em_rxtx.c      |    6 ++++++
 drivers/net/e1000/igb_ethdev.c   |    3 ++-
 drivers/net/e1000/igb_rxtx.c     |    6 ++++++
 5 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h
index ee8b872..4e69e44 100644
--- a/drivers/net/e1000/e1000_ethdev.h
+++ b/drivers/net/e1000/e1000_ethdev.h
@@ -259,6 +259,7 @@ struct e1000_adapter {
 void eth_igb_tx_queue_release(void *txq);
 void eth_igb_rx_queue_release(void *rxq);
 void igb_dev_clear_queues(struct rte_eth_dev *dev);
+void igb_dev_free_queues(struct rte_eth_dev *dev);
 
 int eth_igb_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
 		uint16_t nb_rx_desc, unsigned int socket_id,
@@ -313,6 +314,7 @@ void eth_em_tx_queue_release(void *txq);
 void eth_em_rx_queue_release(void *rxq);
 
 void em_dev_clear_queues(struct rte_eth_dev *dev);
+void em_dev_free_queues(struct rte_eth_dev *dev);
 
 int eth_em_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
 		uint16_t nb_rx_desc, unsigned int socket_id,
diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index dfabb15..d8c04e7 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -659,6 +659,7 @@ eth_em_close(struct rte_eth_dev *dev)
 
 	eth_em_stop(dev);
 	adapter->stopped = 1;
+	em_dev_free_queues(dev);
 	e1000_phy_hw_reset(hw);
 	em_release_manageability(hw);
 	em_hw_control_release(hw);
diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c
index 976df60..9913ad0 100644
--- a/drivers/net/e1000/em_rxtx.c
+++ b/drivers/net/e1000/em_rxtx.c
@@ -1512,6 +1512,12 @@ em_dev_clear_queues(struct rte_eth_dev *dev)
 			em_reset_rx_queue(rxq);
 		}
 	}
+}
+
+void
+em_dev_free_queues(struct rte_eth_dev *dev)
+{
+	uint16_t i;
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		eth_em_rx_queue_release(dev->data->rx_queues[i]);
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 80e4a6c..6e92f2e 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -1089,7 +1089,7 @@ eth_igb_close(struct rte_eth_dev *dev)
 		E1000_WRITE_REG(hw, E1000_82580_PHY_POWER_MGMT, phpm_reg);
 	}
 
-	igb_dev_clear_queues(dev);
+	igb_dev_free_queues(dev);
 
 	memset(&link, 0, sizeof(link));
 	rte_igb_dev_atomic_write_link_status(dev, &link);
@@ -2363,6 +2363,7 @@ igbvf_dev_close(struct rte_eth_dev *dev)
 
 	igbvf_dev_stop(dev);
 	adapter->stopped = 1;
+	igb_dev_free_queues(dev);
 }
 
 static int igbvf_set_vfta(struct e1000_hw *hw, uint16_t vid, bool on)
diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c
index 1bf8c93..0aecf8c 100644
--- a/drivers/net/e1000/igb_rxtx.c
+++ b/drivers/net/e1000/igb_rxtx.c
@@ -1498,6 +1498,12 @@ igb_dev_clear_queues(struct rte_eth_dev *dev)
 			igb_reset_rx_queue(rxq);
 		}
 	}
+}
+
+void
+igb_dev_free_queues(struct rte_eth_dev *dev)
+{
+	uint16_t i;
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		eth_igb_rx_queue_release(dev->data->rx_queues[i]);
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit function.
  2015-06-30  1:31           ` Qiu, Michael
@ 2015-07-06 11:35             ` Qiu, Michael
  2015-07-07  3:38               ` Tetsuya Mukawa
  0 siblings, 1 reply; 270+ messages in thread
From: Qiu, Michael @ 2015-07-06 11:35 UTC (permalink / raw)
  To: dev

Hi, all

As we has gap on the memory release action to be done in which step, I
appreciate all your comments on this patch.

Currently, the correct quit sequence for testpmd is stop() --->
port_stop() --> port_close() --> quit(). This will lead lots of memory
not released by default, like queues.

We have 3 potential proposals(normal case means without hotplug):

1. Those memory release in close()  other left in uninit()
    This will work fine for both hotplug case and normal case.

2. leave close() just as the same before, all be done in uninit()
    This will works fine for hotplug, for normal case maybe has
issue(memory not released?).

3. Combine close() and uninit(), only one will be left.
    This will work fine for both hotplug case and normal case. But it
may change a lot, such as logic.

4. other.

For more details, you could go though this thread.


Thanks,
Michael


On 6/30/2015 9:32 AM, Qiu, Michael wrote:
> On 6/30/2015 12:42 AM, Iremonger, Bernard wrote:
>>> -----Original Message-----
>>> From: Qiu, Michael
>>> Sent: Monday, June 29, 2015 4:22 PM
>>> To: Iremonger, Bernard; dev@dpdk.org
>>> Cc: Zhang, Helin; Ananyev, Konstantin; mukawa@igel.co.jp; Stephen
>>> Hemminger
>>> Subject: Re: [PATCH v2] librte_ether: release memory in uninit function.
>>>
>>> On 2015/6/29 18:20, Iremonger, Bernard wrote:
>>>>> -----Original Message-----
>>>>> From: Qiu, Michael
>>>>> Sent: Monday, June 29, 2015 9:55 AM
>>>>> To: Iremonger, Bernard; dev@dpdk.org
>>>>> Cc: Zhang, Helin; Ananyev, Konstantin; mukawa@igel.co.jp; Stephen
>>>>> Hemminger
>>>>> Subject: Re: [PATCH v2] librte_ether: release memory in uninit function.
>>>>>
>>>>> On 6/26/2015 5:32 PM, Iremonger, Bernard wrote:
>>>>>> Changes in v2:
>>>>>> do not free mac_addrs and hash_mac_addrs here.
>>>>>>
>>>>>> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
>>>>>> ---
>>>>>>  lib/librte_ether/rte_ethdev.c |    6 +++++-
>>>>>>  1 files changed, 5 insertions(+), 1 deletions(-)
>>>>>>
>>>>>> diff --git a/lib/librte_ether/rte_ethdev.c
>>>>>> b/lib/librte_ether/rte_ethdev.c index e13fde5..7ae101a 100644
>>>>>> --- a/lib/librte_ether/rte_ethdev.c
>>>>>> +++ b/lib/librte_ether/rte_ethdev.c
>>>>>> @@ -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;
>>>>> Actually, This could be put in rte_eth_dev_close() becasue queues
>>>>> should be released when closed.
>>>>>
>>>>> Also before free dev->data->rx_queues you should make sure
>>>>> dev->data->rx_queues[i] has been freed in PMD close() function, So
>>>>> dev->data->this
>>>>> two should be better done at the same time, ether in
>>>>> rte_eth_dev_close() or in PMD close() function. For hotplug in fm10k,
>>>>> I put it in PMD close() function.
>>>>>
>>>>> Thanks,
>>>>> Michael
>>>> Hi Michael,
>>>>
>>>> The consensus is that the rx_queue and tx_queue memory should not be
>>> released in the PMD as it is not allocated by the PMD. The memory is
>>> allocated in rte_eth_dev_rx_queue_config() and
>>> rte_eth_dev_tx_queue_config(), which are both called from
>>> rte_eth_dev_configure() which is called by the application (for example
>>> test_pmd). So it seems to make sense to free this memory  in
>>> rte_eth_dev_uninit().
>>>
>>> It really make sense to free memory in rte_ether level, but when close a port
>>> with out detached? just as stop --> close() --> quit(), the memory will not be
>>> released :)
>>>
>> In the above scenario lots of memory will not be released.
>>
>> This is why the detach() and the underlying dev_uninit() functions were introduced.
> First detach is only for hotplug, for *users do not use hotplug*, that
> scenario is the right action. So  "lots of memory will not be released"
> is issue need be fixed, actually, in fm10k driver, lots of memory has
> been released.
>
>> The dev_uninit() functions currently call dev_close()  which in turn calls dev_stop() which calls dev_clear_queues(). 
> Users do hotplug then must call stop() --> close() --> dev_uninit(), it
> works fine. But do you think it make sense to release memory when
> close() it?
>  
>> The dev_clear_queues()  function does not release the queue_memory or the queue array memory. The queue memory is now released in the dev_uninit() and the  queue array memory is released in the rte_eth_dev_uninit() function.
> That's your implementation,  make sure not all users will detach a
> device, but the right action must include close(), do you agree?
>
>> If the queue array memory is released in rte_eth_dev_close() then the release of the queue_memory will have to be moved to the dev_close() functions from the dev_uninit() functions. This will impact all the existing  PMD hotplug patches.   It will also change the existing dev_close() functionality.
> Why impact?? Actually it works fine with fm10k driver. What I concern is
> *when user do not use hotplug*, it will lead lots of memory not
> released, that unacceptable, to move release action to
> rte_eth_dev_close()  is just a   suggestion by me, I think *the solution
> should cover both scenario*, am I right?
>
>
>> My preference is to leave the existing dev_close() functions unchanged as far as possible and to do what needs to be done in the dev_uninit() functions.
>>
>> We probably need the view of the maintainers as to whether this should be done in the close() or uninit() functions.  
>>
>> Regards,
>>
>> Bernard.
>>
>>  
>>
>>
>>
>>
>


^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit function.
  2015-07-06 11:35             ` Qiu, Michael
@ 2015-07-07  3:38               ` Tetsuya Mukawa
  2015-07-07 10:53                 ` Iremonger, Bernard
  0 siblings, 1 reply; 270+ messages in thread
From: Tetsuya Mukawa @ 2015-07-07  3:38 UTC (permalink / raw)
  To: dev

On 2015/07/06 20:35, Qiu, Michael wrote:
> Hi, all
>
> As we has gap on the memory release action to be done in which step, I
> appreciate all your comments on this patch.
>
> Currently, the correct quit sequence for testpmd is stop() --->
> port_stop() --> port_close() --> quit(). This will lead lots of memory
> not released by default, like queues.
>
> We have 3 potential proposals(normal case means without hotplug):
>
> 1. Those memory release in close()  other left in uninit()
>     This will work fine for both hotplug case and normal case.

+1

I assume that once close() is called, we cannot start the port again
without hotplugging.
This is my premise.

It might be good that we move finalization code to close() as much as
possible, because of followings.
1. Anyway, once close() is called, we cannot start the port again. So it
should be ok to free resources in close().
2. Non-hotplugging applications can release resources if we implement
finalization code to close().

Also I guess Stephen's suggestion is important to keep code clean.
It may be good that 'dev->data->rx/tx_queues[queue_id]' are freed in
rx/tx_queue_release() of each PMD, and rx/tx_queue_release() will be
called by rte_eth_dev_close(). Also 'dev->data->rx/tx_queues[]' should
be freed in ethdev.c.

> 3. Combine close() and uninit(), only one will be left.
>     This will work fine for both hotplug case and normal case. But it
> may change a lot, such as logic.

I guess this will be second option.  But I agree we need to change a
lot. Also after enabling hotplug by default, when someone only wants to
close the port, it will be impossible.

Regards,
Tetsuya

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v4 0/4] virtio: PCI Port Hotplug
       [not found] <PATCH>
                   ` (15 preceding siblings ...)
  2015-07-03 14:38 ` [dpdk-dev] [PATCH v7 0/2] e1000: PCI Port Hotplug changes Bernard Iremonger
@ 2015-07-07  9:18 ` Bernard Iremonger
  2015-07-07  9:18   ` [dpdk-dev] [PATCH v4 1/4] virtio: add support for " Bernard Iremonger
                     ` (3 more replies)
  2015-07-07 10:21 ` [dpdk-dev] [PATCH v4 0/3] bonding PCI Port Hotplug Bernard Iremonger
                   ` (24 subsequent siblings)
  41 siblings, 4 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-07  9:18 UTC (permalink / raw)
  To: dev

This patchset contains changes to add support for PCI Port Hotplug
It also contains a fix to virtqueue_detatch_unused().
It also contains a fix to testpmd to facilate testing on VM's.

Changes in V4:
Rebase to latest code.
Move freeing of queue memory from uninit() function to close() function.
Change to testpmd to facilate testing on VM.

Changes in V3:
Rebase to latest code.
Free queue memory in uninit() function.

Changes in V2:
Rebase to use new drivers directory.
Reuse memzones.

Bernard Iremonger (4):
  virtio: add support for PCI Port Hotplug
  virtio: check vq parameter in virtqueue_detatch_unused() function
  virtio: free queue memory in virtio_dev_close()
  test-pmd: remove call to rte_eth_promiscuous_disable() from
    detach_port()

 app/test-pmd/testpmd.c             |    4 +-
 drivers/net/virtio/virtio_ethdev.c |   91 +++++++++++++++++++++++++++++++++---
 drivers/net/virtio/virtqueue.c     |   14 +++--
 3 files changed, 93 insertions(+), 16 deletions(-)

-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v4 1/4] virtio: add support for PCI Port Hotplug
  2015-07-07  9:18 ` [dpdk-dev] [PATCH v4 0/4] virtio: PCI Port Hotplug Bernard Iremonger
@ 2015-07-07  9:18   ` Bernard Iremonger
  2015-07-07  9:18   ` [dpdk-dev] [PATCH v4 2/4] virtio: check vq parameter in virtqueue_detatch_unused() function Bernard Iremonger
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-07  9:18 UTC (permalink / raw)
  To: dev

This patch depends on the Port Hotplug Framework.
It implements the eth_dev_uninit_t() function for virtio pmd.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/virtio/virtio_ethdev.c |   72 ++++++++++++++++++++++++++++++++---
 1 files changed, 65 insertions(+), 7 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index fe5f9a1..b88f297 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -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
@@ -51,6 +51,7 @@
 #include <rte_pci.h>
 #include <rte_ether.h>
 #include <rte_common.h>
+#include <rte_errno.h>
 
 #include <rte_memory.h>
 #include <rte_eal.h>
@@ -63,6 +64,7 @@
 
 
 static int eth_virtio_dev_init(struct rte_eth_dev *eth_dev);
+static int eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev);
 static int  virtio_dev_configure(struct rte_eth_dev *dev);
 static int  virtio_dev_start(struct rte_eth_dev *dev);
 static void virtio_dev_stop(struct rte_eth_dev *dev);
@@ -324,8 +326,12 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
 	mz = rte_memzone_reserve_aligned(vq_name, vq->vq_ring_size,
 		socket_id, 0, VIRTIO_PCI_VRING_ALIGN);
 	if (mz == NULL) {
-		rte_free(vq);
-		return -ENOMEM;
+		if (rte_errno == EEXIST)
+			mz = rte_memzone_lookup(vq_name);
+		if (mz == NULL) {
+			rte_free(vq);
+			return -ENOMEM;
+		}
 	}
 
 	/*
@@ -358,8 +364,13 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
 			vq_size * hw->vtnet_hdr_size,
 			socket_id, 0, RTE_CACHE_LINE_SIZE);
 		if (vq->virtio_net_hdr_mz == NULL) {
-			rte_free(vq);
-			return -ENOMEM;
+			if (rte_errno == EEXIST)
+				vq->virtio_net_hdr_mz =
+					rte_memzone_lookup(vq_name);
+			if (vq->virtio_net_hdr_mz == NULL) {
+				rte_free(vq);
+				return -ENOMEM;
+			}
 		}
 		vq->virtio_net_hdr_mem =
 			vq->virtio_net_hdr_mz->phys_addr;
@@ -372,8 +383,13 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
 		vq->virtio_net_hdr_mz = rte_memzone_reserve_aligned(vq_name,
 			PAGE_SIZE, socket_id, 0, RTE_CACHE_LINE_SIZE);
 		if (vq->virtio_net_hdr_mz == NULL) {
-			rte_free(vq);
-			return -ENOMEM;
+			if (rte_errno == EEXIST)
+				vq->virtio_net_hdr_mz =
+					rte_memzone_lookup(vq_name);
+			if (vq->virtio_net_hdr_mz == NULL) {
+				rte_free(vq);
+				return -ENOMEM;
+			}
 		}
 		vq->virtio_net_hdr_mem =
 			vq->virtio_net_hdr_mz->phys_addr;
@@ -1250,12 +1266,52 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static int
+eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
+{
+	struct rte_pci_device *pci_dev;
+	struct virtio_hw *hw = eth_dev->data->dev_private;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rte_eal_process_type() == RTE_PROC_SECONDARY)
+		return -EPERM;
+
+	if (hw->started == 1) {
+		virtio_dev_stop(eth_dev);
+		virtio_dev_close(eth_dev);
+	}
+	pci_dev = eth_dev->pci_dev;
+
+	eth_dev->dev_ops = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+
+	rte_free(hw->cvq);
+	hw->cvq = NULL;
+
+	rte_free(eth_dev->data->mac_addrs);
+	eth_dev->data->mac_addrs = NULL;
+
+	/* reset interrupt callback  */
+	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
+		rte_intr_callback_unregister(&pci_dev->intr_handle,
+						virtio_interrupt_handler,
+						eth_dev);
+
+	PMD_INIT_LOG(DEBUG, "dev_uninit completed");
+
+	return 0;
+}
+
 static struct eth_driver rte_virtio_pmd = {
 	.pci_drv = {
 		.name = "rte_virtio_pmd",
 		.id_table = pci_id_virtio_map,
+		.drv_flags = RTE_PCI_DRV_DETACHABLE,
 	},
 	.eth_dev_init = eth_virtio_dev_init,
+	.eth_dev_uninit = eth_virtio_dev_uninit,
 	.dev_private_size = sizeof(struct virtio_hw),
 };
 
@@ -1398,6 +1454,8 @@ static void virtio_dev_free_mbufs(struct rte_eth_dev *dev)
 			     "Before freeing rxq[%d] used and unused buf", i);
 		VIRTQUEUE_DUMP((struct virtqueue *)dev->data->rx_queues[i]);
 
+		PMD_INIT_LOG(DEBUG, "rx_queues[%d]=%p",
+				i, dev->data->rx_queues[i]);
 		while ((buf = (struct rte_mbuf *)virtqueue_detatch_unused(
 					dev->data->rx_queues[i])) != NULL) {
 			rte_pktmbuf_free(buf);
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v4 2/4] virtio: check vq parameter in virtqueue_detatch_unused() function
  2015-07-07  9:18 ` [dpdk-dev] [PATCH v4 0/4] virtio: PCI Port Hotplug Bernard Iremonger
  2015-07-07  9:18   ` [dpdk-dev] [PATCH v4 1/4] virtio: add support for " Bernard Iremonger
@ 2015-07-07  9:18   ` Bernard Iremonger
  2015-07-07  9:18   ` [dpdk-dev] [PATCH v4 3/4] virtio: free queue memory in virtio_dev_close() Bernard Iremonger
  2015-07-07  9:18   ` [dpdk-dev] [PATCH v4 4/4] test-pmd: remove call to rte_eth_promiscuous_disable() from detach_port() Bernard Iremonger
  3 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-07  9:18 UTC (permalink / raw)
  To: dev

If vq is NULL, there is a segmentation fault.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/virtio/virtqueue.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/net/virtio/virtqueue.c b/drivers/net/virtio/virtqueue.c
index 8a3005f..7f60e3e 100644
--- a/drivers/net/virtio/virtqueue.c
+++ b/drivers/net/virtio/virtqueue.c
@@ -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
@@ -60,11 +60,13 @@ virtqueue_detatch_unused(struct virtqueue *vq)
 	struct rte_mbuf *cookie;
 	int idx;
 
-	for (idx = 0; idx < vq->vq_nentries; idx++) {
-		if ((cookie = vq->vq_descx[idx].cookie) != NULL) {
-			vq->vq_descx[idx].cookie = NULL;
-			return cookie;
+	if (vq != NULL)
+		for (idx = 0; idx < vq->vq_nentries; idx++) {
+			cookie = vq->vq_descx[idx].cookie;
+			if (cookie != NULL) {
+				vq->vq_descx[idx].cookie = NULL;
+				return cookie;
+			}
 		}
-	}
 	return NULL;
 }
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v4 3/4] virtio: free queue memory in virtio_dev_close()
  2015-07-07  9:18 ` [dpdk-dev] [PATCH v4 0/4] virtio: PCI Port Hotplug Bernard Iremonger
  2015-07-07  9:18   ` [dpdk-dev] [PATCH v4 1/4] virtio: add support for " Bernard Iremonger
  2015-07-07  9:18   ` [dpdk-dev] [PATCH v4 2/4] virtio: check vq parameter in virtqueue_detatch_unused() function Bernard Iremonger
@ 2015-07-07  9:18   ` Bernard Iremonger
  2015-07-07 18:04     ` Stephen Hemminger
  2015-07-07  9:18   ` [dpdk-dev] [PATCH v4 4/4] test-pmd: remove call to rte_eth_promiscuous_disable() from detach_port() Bernard Iremonger
  3 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-07  9:18 UTC (permalink / raw)
  To: dev

Add function virtio_free_queues() and call from virtio_dev_close()

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/virtio/virtio_ethdev.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index b88f297..ed99f33 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -428,6 +428,24 @@ virtio_dev_cq_queue_setup(struct rte_eth_dev *dev, uint16_t vtpci_queue_idx,
 }
 
 static void
+virtio_free_queues(struct rte_eth_dev *dev)
+{
+	unsigned int 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;
+}
+
+static void
 virtio_dev_close(struct rte_eth_dev *dev)
 {
 	struct virtio_hw *hw = dev->data->dev_private;
@@ -441,6 +459,7 @@ virtio_dev_close(struct rte_eth_dev *dev)
 	vtpci_reset(hw);
 	hw->started = 0;
 	virtio_dev_free_mbufs(dev);
+	virtio_free_queues(dev);
 }
 
 static void
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v4 4/4] test-pmd: remove call to rte_eth_promiscuous_disable() from detach_port()
  2015-07-07  9:18 ` [dpdk-dev] [PATCH v4 0/4] virtio: PCI Port Hotplug Bernard Iremonger
                     ` (2 preceding siblings ...)
  2015-07-07  9:18   ` [dpdk-dev] [PATCH v4 3/4] virtio: free queue memory in virtio_dev_close() Bernard Iremonger
@ 2015-07-07  9:18   ` Bernard Iremonger
  2015-07-08  0:42     ` Ouyang, Changchun
  3 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-07  9:18 UTC (permalink / raw)
  To: dev

At this point the stop() and close() functions have already been called.
The rte_eth_promiscuous_disable() function does not return on the VM.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 app/test-pmd/testpmd.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 82b465d..4769533 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -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
@@ -1542,8 +1542,6 @@ detach_port(uint8_t port_id)
 		return;
 	}
 
-	rte_eth_promiscuous_disable(port_id);
-
 	if (rte_eth_dev_detach(port_id, name))
 		return;
 
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v4 0/3] bonding PCI Port Hotplug
       [not found] <PATCH>
                   ` (16 preceding siblings ...)
  2015-07-07  9:18 ` [dpdk-dev] [PATCH v4 0/4] virtio: PCI Port Hotplug Bernard Iremonger
@ 2015-07-07 10:21 ` Bernard Iremonger
  2015-07-07 10:21   ` [dpdk-dev] [PATCH v4 1/3] bonding: add support for " Bernard Iremonger
                     ` (2 more replies)
  2015-07-07 13:09 ` [dpdk-dev] [PATCH v4 0/1] ring PCI Port Hotplug Bernard Iremonger
                   ` (23 subsequent siblings)
  41 siblings, 3 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-07 10:21 UTC (permalink / raw)
  To: dev

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 (3):
  bonding: add support for PCI Port Hotplug
  test-pmd: modified testpmd for link_bonding
  bonding: free queue memory in stop function

 app/test-pmd/cmdline.c                     |    4 +-
 app/test-pmd/testpmd.c                     |   24 ++++++++-
 app/test-pmd/testpmd.h                     |    7 ++-
 drivers/net/bonding/rte_eth_bond.h         |   13 +++++-
 drivers/net/bonding/rte_eth_bond_api.c     |   75 ++++++++++++++++++---------
 drivers/net/bonding/rte_eth_bond_pmd.c     |   41 +++++++++++++++-
 drivers/net/bonding/rte_eth_bond_private.h |    7 ++-
 7 files changed, 136 insertions(+), 35 deletions(-)

-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v4 1/3] bonding: add support for PCI Port Hotplug
  2015-07-07 10:21 ` [dpdk-dev] [PATCH v4 0/3] bonding PCI Port Hotplug Bernard Iremonger
@ 2015-07-07 10:21   ` Bernard Iremonger
  2015-07-15 10:22     ` Declan Doherty
  2015-07-07 10:21   ` [dpdk-dev] [PATCH v4 2/3] test-pmd: modified testpmd for link_bonding Bernard Iremonger
  2015-07-07 10:21   ` [dpdk-dev] [PATCH v4 3/3] bonding: free queue memory in stop function Bernard Iremonger
  2 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-07 10:21 UTC (permalink / raw)
  To: dev

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

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/bonding/rte_eth_bond.h         |   13 +++++-
 drivers/net/bonding/rte_eth_bond_api.c     |   75 ++++++++++++++++++---------
 drivers/net/bonding/rte_eth_bond_pmd.c     |   23 ++++++++-
 drivers/net/bonding/rte_eth_bond_private.h |    7 ++-
 4 files changed, 88 insertions(+), 30 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond.h b/drivers/net/bonding/rte_eth_bond.h
index d688fc3..8efbf07 100644
--- a/drivers/net/bonding/rte_eth_bond.h
+++ b/drivers/net/bonding/rte_eth_bond.h
@@ -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.
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index d810ec4..9d8da1c 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -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
@@ -192,7 +192,15 @@ number_of_sockets(void)
 	return ++sockets;
 }
 
-const char *driver_name = "Link Bonding PMD";
+const char driver_name[] = "rte_bond_pmd";
+static struct rte_pci_id pci_id_table;
+
+static struct eth_driver rte_bond_pmd = {
+	.pci_drv = {
+		.name = driver_name,
+		.drv_flags = RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_DETACHABLE,
+	},
+};
 
 int
 rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
@@ -200,9 +208,8 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	struct rte_pci_device *pci_dev = NULL;
 	struct bond_dev_private *internals = NULL;
 	struct rte_eth_dev *eth_dev = NULL;
-	struct eth_driver *eth_drv = NULL;
 	struct rte_pci_driver *pci_drv = NULL;
-	struct rte_pci_id *pci_id_table = NULL;
+
 	/* now do all data allocation - for eth_dev structure, dummy pci driver
 	 * and internal (private) data
 	 */
@@ -224,26 +231,15 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 		goto err;
 	}
 
-	eth_drv = rte_zmalloc_socket(name, sizeof(*eth_drv), 0, socket_id);
-	if (eth_drv == NULL) {
-		RTE_BOND_LOG(ERR, "Unable to malloc eth_drv on socket");
-		goto err;
-	}
+	pci_drv = &rte_bond_pmd.pci_drv;
 
-	pci_drv = &eth_drv->pci_drv;
+	memset(&pci_id_table, 0, sizeof(pci_id_table));
+	pci_id_table.device_id = PCI_ANY_ID;
+	pci_id_table.subsystem_device_id = PCI_ANY_ID;
+	pci_id_table.vendor_id = PCI_ANY_ID;
+	pci_id_table.subsystem_vendor_id = PCI_ANY_ID;
 
-	pci_id_table = rte_zmalloc_socket(name, sizeof(*pci_id_table), 0, socket_id);
-	if (pci_id_table == NULL) {
-		RTE_BOND_LOG(ERR, "Unable to malloc pci_id_table on socket");
-		goto err;
-	}
-	pci_id_table->device_id = PCI_ANY_ID;
-	pci_id_table->subsystem_device_id = PCI_ANY_ID;
-	pci_id_table->vendor_id = PCI_ANY_ID;
-	pci_id_table->subsystem_vendor_id = PCI_ANY_ID;
-
-	pci_drv->id_table = pci_id_table;
-	pci_drv->drv_flags = RTE_PCI_DRV_INTR_LSC;
+	pci_drv->id_table = &pci_id_table;
 
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
 	if (internals == NULL) {
@@ -262,7 +258,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	pci_drv->name = driver_name;
 	pci_dev->driver = pci_drv;
 
-	eth_dev->driver = eth_drv;
+	eth_dev->driver = &rte_bond_pmd;
 	eth_dev->data->dev_private = internals;
 	eth_dev->data->nb_rx_queues = (uint16_t)1;
 	eth_dev->data->nb_tx_queues = (uint16_t)1;
@@ -318,13 +314,42 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 
 err:
 	rte_free(pci_dev);
-	rte_free(pci_id_table);
-	rte_free(eth_drv);
 	rte_free(internals);
+	rte_free(eth_dev->data->mac_addrs);
 
 	return -1;
 }
 
+int
+rte_eth_bond_free(const char *name)
+{
+	struct rte_eth_dev *eth_dev = NULL;
+
+	/* now free all data allocation - for eth_dev structure,
+	 * dummy pci driver and internal (private) data
+	 */
+
+	/* find an ethdev entry */
+	eth_dev = rte_eth_dev_allocated(name);
+	if (eth_dev == NULL)
+		return -ENODEV;
+
+	if (eth_dev->data->dev_started == 1)
+		bond_ethdev_stop(eth_dev);
+
+	eth_dev->dev_ops = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+
+	rte_free(eth_dev->pci_dev);
+	rte_free(eth_dev->data->dev_private);
+	rte_free(eth_dev->data->mac_addrs);
+
+	rte_eth_dev_release_port(eth_dev);
+
+	return 0;
+}
+
 static int
 __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
 {
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 989e878..a2eecb9 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -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;
@@ -2043,6 +2043,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
@@ -2269,6 +2287,7 @@ static struct rte_driver bond_drv = {
 	.name = "eth_bond",
 	.type = PMD_VDEV,
 	.init = bond_init,
+	.uninit = bond_uninit,
 };
 
 PMD_REGISTER_DRIVER(bond_drv);
diff --git a/drivers/net/bonding/rte_eth_bond_private.h b/drivers/net/bonding/rte_eth_bond_private.h
index 45e5c65..7b00e94 100644
--- a/drivers/net/bonding/rte_eth_bond_private.h
+++ b/drivers/net/bonding/rte_eth_bond_private.h
@@ -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 *driver_name;
+extern const char driver_name[];
 
 /** Port Queue Mapping Structure */
 struct bond_rx_queue {
@@ -284,4 +284,7 @@ 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);
+
 #endif
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v4 2/3] test-pmd: modified testpmd for link_bonding
  2015-07-07 10:21 ` [dpdk-dev] [PATCH v4 0/3] bonding PCI Port Hotplug Bernard Iremonger
  2015-07-07 10:21   ` [dpdk-dev] [PATCH v4 1/3] bonding: add support for " Bernard Iremonger
@ 2015-07-07 10:21   ` Bernard Iremonger
  2015-07-07 10:21   ` [dpdk-dev] [PATCH v4 3/3] bonding: free queue memory in stop function Bernard Iremonger
  2 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-07 10:21 UTC (permalink / raw)
  To: dev

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.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 app/test-pmd/cmdline.c |    4 +++-
 app/test-pmd/testpmd.c |   24 +++++++++++++++++++++---
 app/test-pmd/testpmd.h |    7 +++++--
 3 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 8142910..c1f4cad 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -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.
  *
@@ -3950,6 +3950,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 =
@@ -4006,6 +4007,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 =
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 82b465d..b271728 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -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
@@ -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;
 	}
 
@@ -1810,6 +1812,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,
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index f2c84d9..27462bc 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -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
@@ -159,11 +159,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
@@ -530,6 +531,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);
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v4 3/3] bonding: free queue memory in stop function
  2015-07-07 10:21 ` [dpdk-dev] [PATCH v4 0/3] bonding PCI Port Hotplug Bernard Iremonger
  2015-07-07 10:21   ` [dpdk-dev] [PATCH v4 1/3] bonding: add support for " Bernard Iremonger
  2015-07-07 10:21   ` [dpdk-dev] [PATCH v4 2/3] test-pmd: modified testpmd for link_bonding Bernard Iremonger
@ 2015-07-07 10:21   ` Bernard Iremonger
  2 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-07 10:21 UTC (permalink / raw)
  To: dev

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

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/bonding/rte_eth_bond_pmd.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index a2eecb9..8734df0 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -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)
 {
@@ -1550,6 +1568,8 @@ bond_ethdev_stop(struct rte_eth_dev *eth_dev)
 
 	eth_dev->data->dev_link.link_status = 0;
 	eth_dev->data->dev_started = 0;
+
+	bond_ethdev_free_queues(eth_dev);
 }
 
 static void
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit function.
  2015-07-07  3:38               ` Tetsuya Mukawa
@ 2015-07-07 10:53                 ` Iremonger, Bernard
  2015-07-08  3:47                   ` Tetsuya Mukawa
  0 siblings, 1 reply; 270+ messages in thread
From: Iremonger, Bernard @ 2015-07-07 10:53 UTC (permalink / raw)
  To: Tetsuya Mukawa, dev

> -----Original Message-----
> From: Tetsuya Mukawa [mailto:mukawa@igel.co.jp]
> Sent: Tuesday, July 7, 2015 4:38 AM
> To: dev@dpdk.org
> Cc: Qiu, Michael; Iremonger, Bernard; thomas.monjalon@6wind.com;
> Ananyev, Konstantin; Stephen Hemminger; Zhang, Helin; Chen, Jing D; Neil
> Horman
> Subject: Re: [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit
> function.
> 
> On 2015/07/06 20:35, Qiu, Michael wrote:
> > Hi, all
> >
> > As we has gap on the memory release action to be done in which step, I
> > appreciate all your comments on this patch.
> >
> > Currently, the correct quit sequence for testpmd is stop() --->
> > port_stop() --> port_close() --> quit(). This will lead lots of memory
> > not released by default, like queues.

There is also the scenario (outside of testpmd) where an application can call rte_eth_dev_close() or rte_eth_dev_detach() which calls rte_eth_dev_uninit() directly from an application.
In these cases the memory allocated in the EAL layer should be released in both rte_eth_dev_close() and rte_eth_dev_detach().
This patch is intended to address the rte_eth_dev_detach() case only (hotplug case).
Perhaps there should be a separate patch to address the rte_eth_dev_close() case.

Regards,

Bernard.

> >
> > We have 3 potential proposals(normal case means without hotplug):
> >
> > 1. Those memory release in close()  other left in uninit()
> >     This will work fine for both hotplug case and normal case.
> 
> +1
> 
> I assume that once close() is called, we cannot start the port again without
> hotplugging.
> This is my premise.
> 
> It might be good that we move finalization code to close() as much as
> possible, because of followings.
> 1. Anyway, once close() is called, we cannot start the port again. So it should
> be ok to free resources in close().
> 2. Non-hotplugging applications can release resources if we implement
> finalization code to close().
> 
> Also I guess Stephen's suggestion is important to keep code clean.
> It may be good that 'dev->data->rx/tx_queues[queue_id]' are freed in
> rx/tx_queue_release() of each PMD, and rx/tx_queue_release() will be
> called by rte_eth_dev_close(). Also 'dev->data->rx/tx_queues[]' should be
> freed in ethdev.c.
> 
> > 3. Combine close() and uninit(), only one will be left.
> >     This will work fine for both hotplug case and normal case. But it
> > may change a lot, such as logic.
> 
> I guess this will be second option.  But I agree we need to change a lot. Also
> after enabling hotplug by default, when someone only wants to close the
> port, it will be impossible.
> 
> Regards,
> Tetsuya

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v4 0/1] ring PCI Port Hotplug
       [not found] <PATCH>
                   ` (17 preceding siblings ...)
  2015-07-07 10:21 ` [dpdk-dev] [PATCH v4 0/3] bonding PCI Port Hotplug Bernard Iremonger
@ 2015-07-07 13:09 ` Bernard Iremonger
  2015-07-07 13:09   ` [dpdk-dev] [PATCH v4 1/1] ring: changes to support " Bernard Iremonger
  2015-07-13 13:04 ` [dpdk-dev] [PATCH v3 0/2] librte_ether release memory Bernard Iremonger
                   ` (22 subsequent siblings)
  41 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-07 13:09 UTC (permalink / raw)
  To: dev

Changes in V4:
Rebase to latest code.
Update commit line, no changes to code.

Changes in V3:
Rebase to use drivers/net/ring directory
Handle no parameters case

Changes in V2:
Fix crash in the rte_pmd_ring_devuninit() function.

Bernard Iremonger (1):
  ring: changes to support PCI Port Hotplug

 drivers/net/ring/rte_eth_ring.c |   97 ++++++++++++++++++++++++++++++---------
 1 files changed, 75 insertions(+), 22 deletions(-)

-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v4 1/1] ring: changes to support PCI Port Hotplug
  2015-07-07 13:09 ` [dpdk-dev] [PATCH v4 0/1] ring PCI Port Hotplug Bernard Iremonger
@ 2015-07-07 13:09   ` Bernard Iremonger
  2015-07-18 20:27     ` Thomas Monjalon
  2015-07-27  2:52     ` Thomas Monjalon
  0 siblings, 2 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-07 13:09 UTC (permalink / raw)
  To: dev

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

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
Acked-by: Bruce Richardson <bruce.ruchardson@intel.com>
---
 drivers/net/ring/rte_eth_ring.c |   97 ++++++++++++++++++++++++++++++---------
 1 files changed, 75 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index ada025f..6fd3d0a 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -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
@@ -252,6 +252,15 @@ static const struct eth_dev_ops ops = {
 	.mac_addr_add = eth_mac_addr_add,
 };
 
+static struct eth_driver rte_ring_pmd = {
+	.pci_drv = {
+		.name = "rte_ring_pmd",
+		.drv_flags = RTE_PCI_DRV_DETACHABLE,
+	},
+};
+
+static struct rte_pci_id id_table;
+
 int
 rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 		const unsigned nb_rx_queues,
@@ -263,8 +272,6 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 	struct rte_pci_device *pci_dev = NULL;
 	struct pmd_internals *internals = NULL;
 	struct rte_eth_dev *eth_dev = NULL;
-	struct eth_driver *eth_drv = NULL;
-	struct rte_pci_id *id_table = NULL;
 
 	unsigned i;
 
@@ -288,10 +295,6 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 	if (pci_dev == NULL)
 		goto error;
 
-	id_table = rte_zmalloc_socket(name, sizeof(*id_table), 0, numa_node);
-	if (id_table == NULL)
-		goto error;
-
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, numa_node);
 	if (internals == NULL)
 		goto error;
@@ -301,9 +304,6 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 	if (eth_dev == NULL)
 		goto error;
 
-	eth_drv = rte_zmalloc_socket(name, sizeof(*eth_drv), 0, numa_node);
-	if (eth_drv == NULL)
-		goto error;
 
 	/* now put it all together
 	 * - store queue data in internals,
@@ -323,21 +323,22 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 		internals->tx_ring_queues[i].rng = tx_queues[i];
 	}
 
-	eth_drv->pci_drv.name = ring_ethdev_driver_name;
-	eth_drv->pci_drv.id_table = id_table;
+	rte_ring_pmd.pci_drv.name = ring_ethdev_driver_name;
+	rte_ring_pmd.pci_drv.id_table = &id_table;
 
 	pci_dev->numa_node = numa_node;
-	pci_dev->driver = &eth_drv->pci_drv;
+	pci_dev->driver = &rte_ring_pmd.pci_drv;
 
 	data->dev_private = internals;
 	data->port_id = eth_dev->data->port_id;
+	memmove(data->name, eth_dev->data->name, sizeof(data->name));
 	data->nb_rx_queues = (uint16_t)nb_rx_queues;
 	data->nb_tx_queues = (uint16_t)nb_tx_queues;
 	data->dev_link = pmd_link;
 	data->mac_addrs = &internals->address;
 
 	eth_dev->data = data;
-	eth_dev->driver = eth_drv;
+	eth_dev->driver = &rte_ring_pmd;
 	eth_dev->dev_ops = &ops;
 	eth_dev->pci_dev = pci_dev;
 	TAILQ_INIT(&(eth_dev->link_intr_cbs));
@@ -532,20 +533,37 @@ rte_pmd_ring_devinit(const char *name, const char *params)
 
 	RTE_LOG(INFO, PMD, "Initializing pmd_ring for %s\n", name);
 
-	if (params == NULL || params[0] == '\0')
-		eth_dev_ring_create(name, rte_socket_id(), DEV_CREATE);
+	if (params == NULL || params[0] == '\0') {
+		ret = eth_dev_ring_create(name, rte_socket_id(), DEV_CREATE);
+		if (ret == -1) {
+			RTE_LOG(INFO, PMD,
+				"Attach to pmd_ring for %s\n", name);
+			ret = eth_dev_ring_create(name, rte_socket_id(),
+						  DEV_ATTACH);
+		}
+	}
 	else {
 		kvlist = rte_kvargs_parse(params, valid_arguments);
 
 		if (!kvlist) {
 			RTE_LOG(INFO, PMD, "Ignoring unsupported parameters when creating"
 					" rings-backed ethernet device\n");
-			eth_dev_ring_create(name, rte_socket_id(), DEV_CREATE);
-			return 0;
+			ret = eth_dev_ring_create(name, rte_socket_id(),
+						  DEV_CREATE);
+			if (ret == -1) {
+				RTE_LOG(INFO, PMD,
+					"Attach to pmd_ring for %s\n",
+					name);
+				ret = eth_dev_ring_create(name, rte_socket_id(),
+							  DEV_ATTACH);
+			}
+			return ret;
 		} else {
 			ret = rte_kvargs_count(kvlist, ETH_RING_NUMA_NODE_ACTION_ARG);
-			info = rte_zmalloc("struct node_action_list", sizeof(struct node_action_list) +
-					   (sizeof(struct node_action_pair) * ret), 0);
+			info = rte_zmalloc("struct node_action_list",
+					   sizeof(struct node_action_list) +
+					   (sizeof(struct node_action_pair) * ret),
+					   0);
 			if (!info)
 				goto out_free;
 
@@ -559,8 +577,18 @@ rte_pmd_ring_devinit(const char *name, const char *params)
 				goto out_free;
 
 			for (info->count = 0; info->count < info->total; info->count++) {
-				eth_dev_ring_create(name, info->list[info->count].node,
-						    info->list[info->count].action);
+				ret = eth_dev_ring_create(name,
+							  info->list[info->count].node,
+							  info->list[info->count].action);
+				if ((ret == -1) &&
+				    (info->list[info->count].action == DEV_CREATE)) {
+					RTE_LOG(INFO, PMD,
+						"Attach to pmd_ring for %s\n",
+						name);
+					ret = eth_dev_ring_create(name,
+							info->list[info->count].node,
+							DEV_ATTACH);
+				}
 			}
 		}
 	}
@@ -571,10 +599,35 @@ out_free:
 	return ret;
 }
 
+static int
+rte_pmd_ring_devuninit(const char *name)
+{
+	struct rte_eth_dev *eth_dev = NULL;
+
+	RTE_LOG(INFO, PMD, "Un-Initializing pmd_ring for %s\n", name);
+
+	if (name == NULL)
+		return -EINVAL;
+
+	/* find an ethdev entry */
+	eth_dev = rte_eth_dev_allocated(name);
+	if (eth_dev == NULL)
+		return -ENODEV;
+
+	eth_dev_stop(eth_dev);
+	rte_free(eth_dev->data->dev_private);
+	rte_free(eth_dev->data);
+	rte_free(eth_dev->pci_dev);
+
+	rte_eth_dev_release_port(eth_dev);
+	return 0;
+}
+
 static struct rte_driver pmd_ring_drv = {
 	.name = "eth_ring",
 	.type = PMD_VDEV,
 	.init = rte_pmd_ring_devinit,
+	.uninit = rte_pmd_ring_devuninit,
 };
 
 PMD_REGISTER_DRIVER(pmd_ring_drv);
-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v4 3/4] virtio: free queue memory in virtio_dev_close()
  2015-07-07  9:18   ` [dpdk-dev] [PATCH v4 3/4] virtio: free queue memory in virtio_dev_close() Bernard Iremonger
@ 2015-07-07 18:04     ` Stephen Hemminger
  0 siblings, 0 replies; 270+ messages in thread
From: Stephen Hemminger @ 2015-07-07 18:04 UTC (permalink / raw)
  To: Bernard Iremonger; +Cc: dev

On Tue,  7 Jul 2015 10:18:06 +0100
Bernard Iremonger <bernard.iremonger@intel.com> wrote:

> Add function virtio_free_queues() and call from virtio_dev_close()
> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> ---
>  drivers/net/virtio/virtio_ethdev.c |   19 +++++++++++++++++++
>  1 files changed, 19 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
> index b88f297..ed99f33 100644
> --- a/drivers/net/virtio/virtio_ethdev.c
> +++ b/drivers/net/virtio/virtio_ethdev.c
> @@ -428,6 +428,24 @@ virtio_dev_cq_queue_setup(struct rte_eth_dev *dev, uint16_t vtpci_queue_idx,
>  }
>  
>  static void
> +virtio_free_queues(struct rte_eth_dev *dev)
> +{
> +	unsigned int 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;
> +}
> +
> +static void
>  virtio_dev_close(struct rte_eth_dev *dev)
>  {
>  	struct virtio_hw *hw = dev->data->dev_private;
> @@ -441,6 +459,7 @@ virtio_dev_close(struct rte_eth_dev *dev)
>  	vtpci_reset(hw);
>  	hw->started = 0;
>  	virtio_dev_free_mbufs(dev);
> +	virtio_free_queues(dev);
>  }
>  
>  static void

I think virtio should implement regular queue free:

Subject: virtio: add proper queue release

When rx or tx queue is released, the virtio driver leaks memory
because it never frees the associated queue structure.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

--- a/lib/librte_pmd_virtio/virtio_ethdev.c
+++ b/lib/librte_pmd_virtio/virtio_ethdev.c
@@ -78,9 +78,6 @@ static int virtio_dev_link_update(struct
 static void virtio_set_hwaddr(struct virtio_hw *hw);
 static void virtio_get_hwaddr(struct virtio_hw *hw);
 
-static void virtio_dev_rx_queue_release(__rte_unused void *rxq);
-static void virtio_dev_tx_queue_release(__rte_unused void *txq);
-
 static void virtio_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats);
 static void virtio_dev_stats_reset(struct rte_eth_dev *dev);
 static void virtio_dev_free_mbufs(struct rte_eth_dev *dev);
@@ -389,6 +386,19 @@ int virtio_dev_queue_setup(struct rte_et
 	return 0;
 }
 
+
+void
+virtio_dev_queue_release(struct virtqueue *vq)
+{
+	struct virtio_hw *hw = vq->hw;
+
+	/* Select and deactivate the queue */
+	VIRTIO_WRITE_REG_2(hw, VIRTIO_PCI_QUEUE_SEL, vq->queue_id);
+	VIRTIO_WRITE_REG_4(hw, VIRTIO_PCI_QUEUE_PFN, 0);
+
+	rte_free(vq);
+}
+
 static int
 virtio_dev_cq_queue_setup(struct rte_eth_dev *dev, uint16_t vtpci_queue_idx,
 		uint32_t socket_id)
@@ -536,10 +546,8 @@ static struct eth_dev_ops virtio_eth_dev
 	.stats_reset             = virtio_dev_stats_reset,
 	.link_update             = virtio_dev_link_update,
 	.rx_queue_setup          = virtio_dev_rx_queue_setup,
-	/* meaningfull only to multiple queue */
 	.rx_queue_release        = virtio_dev_rx_queue_release,
 	.tx_queue_setup          = virtio_dev_tx_queue_setup,
-	/* meaningfull only to multiple queue */
 	.tx_queue_release        = virtio_dev_tx_queue_release,
 	/* collect stats per queue */
 	.queue_stats_mapping_set = virtio_dev_queue_stats_mapping_set,
@@ -1278,19 +1286,6 @@ rte_virtio_pmd_init(const char *name __r
 }
 
 /*
- * Only 1 queue is supported, no queue release related operation
- */
-static void
-virtio_dev_rx_queue_release(__rte_unused void *rxq)
-{
-}
-
-static void
-virtio_dev_tx_queue_release(__rte_unused void *txq)
-{
-}
-
-/*
  * Configure virtio device
  * It returns 0 on success.
  */
--- a/lib/librte_pmd_virtio/virtio_ethdev.h
+++ b/lib/librte_pmd_virtio/virtio_ethdev.h
@@ -84,15 +84,21 @@ int virtio_dev_queue_setup(struct rte_et
 			unsigned int socket_id,
 			struct virtqueue **pvq);
 
+void virtio_dev_queue_release(struct virtqueue *vq);
+
 int  virtio_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
 		uint16_t nb_rx_desc, unsigned int socket_id,
 		const struct rte_eth_rxconf *rx_conf,
 		struct rte_mempool *mb_pool);
 
+void virtio_dev_rx_queue_release(void *rxq);
+
 int  virtio_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 		uint16_t nb_tx_desc, unsigned int socket_id,
 		const struct rte_eth_txconf *tx_conf);
 
+void virtio_dev_tx_queue_release(void *txq);
+
 uint16_t virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		uint16_t nb_pkts);
 
--- a/lib/librte_pmd_virtio/virtio_rxtx.c
+++ b/lib/librte_pmd_virtio/virtio_rxtx.c
@@ -401,6 +401,13 @@ virtio_dev_rx_queue_setup(struct rte_eth
 	return 0;
 }
 
+void
+virtio_dev_rx_queue_release(void *rxq)
+{
+	if (rxq)
+		virtio_dev_queue_release(rxq);
+}
+
 /*
  * struct rte_eth_dev *dev: Used to update dev
  * uint16_t nb_desc: Defaults to values read from config space
@@ -455,6 +462,13 @@ virtio_dev_tx_queue_setup(struct rte_eth
 	return 0;
 }
 
+void
+virtio_dev_tx_queue_release(void *txq)
+{
+	if (txq)
+		virtio_dev_queue_release(txq);
+}
+
 static void
 virtio_discard_rxbuf(struct virtqueue *vq, struct rte_mbuf *m)
 {

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v4 4/4] test-pmd: remove call to rte_eth_promiscuous_disable() from detach_port()
  2015-07-07  9:18   ` [dpdk-dev] [PATCH v4 4/4] test-pmd: remove call to rte_eth_promiscuous_disable() from detach_port() Bernard Iremonger
@ 2015-07-08  0:42     ` Ouyang, Changchun
  2015-07-09  2:04       ` Tetsuya Mukawa
  0 siblings, 1 reply; 270+ messages in thread
From: Ouyang, Changchun @ 2015-07-08  0:42 UTC (permalink / raw)
  To: Iremonger, Bernard, dev



> -----Original Message-----
> From: Iremonger, Bernard
> Sent: Tuesday, July 7, 2015 5:18 PM
> To: dev@dpdk.org
> Cc: Ouyang, Changchun; Iremonger, Bernard
> Subject: [PATCH v4 4/4] test-pmd: remove call to
> rte_eth_promiscuous_disable() from detach_port()
> 
> At this point the stop() and close() functions have already been called.
> The rte_eth_promiscuous_disable() function does not return on the VM.

I think we need root the cause why it doesn't return on the VM.

> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> ---
>  app/test-pmd/testpmd.c |    4 +---
>  1 files changed, 1 insertions(+), 3 deletions(-)
> 
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
> 82b465d..4769533 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -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
> @@ -1542,8 +1542,6 @@ detach_port(uint8_t port_id)
>  		return;
>  	}
> 
> -	rte_eth_promiscuous_disable(port_id);
> -

It seems a workaround.

>  	if (rte_eth_dev_detach(port_id, name))
>  		return;
> 
> --
> 1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit function.
  2015-07-07 10:53                 ` Iremonger, Bernard
@ 2015-07-08  3:47                   ` Tetsuya Mukawa
  2015-07-08  9:49                     ` Iremonger, Bernard
  0 siblings, 1 reply; 270+ messages in thread
From: Tetsuya Mukawa @ 2015-07-08  3:47 UTC (permalink / raw)
  To: Iremonger, Bernard, dev

On 2015/07/07 19:53, Iremonger, Bernard wrote:
>> -----Original Message-----
>> From: Tetsuya Mukawa [mailto:mukawa@igel.co.jp]
>> Sent: Tuesday, July 7, 2015 4:38 AM
>> To: dev@dpdk.org
>> Cc: Qiu, Michael; Iremonger, Bernard; thomas.monjalon@6wind.com;
>> Ananyev, Konstantin; Stephen Hemminger; Zhang, Helin; Chen, Jing D; Neil
>> Horman
>> Subject: Re: [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit
>> function.
>>
>> On 2015/07/06 20:35, Qiu, Michael wrote:
>>> Hi, all
>>>
>>> As we has gap on the memory release action to be done in which step, I
>>> appreciate all your comments on this patch.
>>>
>>> Currently, the correct quit sequence for testpmd is stop() --->
>>> port_stop() --> port_close() --> quit(). This will lead lots of memory
>>> not released by default, like queues.
> There is also the scenario (outside of testpmd) where an application can call rte_eth_dev_close() or rte_eth_dev_detach() which calls rte_eth_dev_uninit() directly from an application.
> In these cases the memory allocated in the EAL layer should be released in both rte_eth_dev_close() and rte_eth_dev_detach().

Hi Bernard,

All DPDK applications that uses hotpluggingmust call rte_eth_dev_stop()
and rte_eth_dev_close()APIs before detaching ports.
(This is described in DPDK documentation)
Could we ignore applications that only calls rte_eth_dev_detach()?

> This patch is intended to address the rte_eth_dev_detach() case only (hotplug case).
> Perhaps there should be a separate patch to address the rte_eth_dev_close() case.

We all needs to have consensus about how to implement finalization code
in close() and uninit().
Probably one of options will be implementing finalization code in
close() as much as possible.

Tetsuya,

> Regards,
>
> Bernard.
>
>>> We have 3 potential proposals(normal case means without hotplug):
>>>
>>> 1. Those memory release in close()  other left in uninit()
>>>     This will work fine for both hotplug case and normal case.
>> +1
>>
>> I assume that once close() is called, we cannot start the port again without
>> hotplugging.
>> This is my premise.
>>
>> It might be good that we move finalization code to close() as much as
>> possible, because of followings.
>> 1. Anyway, once close() is called, we cannot start the port again. So it should
>> be ok to free resources in close().
>> 2. Non-hotplugging applications can release resources if we implement
>> finalization code to close().
>>
>> Also I guess Stephen's suggestion is important to keep code clean.
>> It may be good that 'dev->data->rx/tx_queues[queue_id]' are freed in
>> rx/tx_queue_release() of each PMD, and rx/tx_queue_release() will be
>> called by rte_eth_dev_close(). Also 'dev->data->rx/tx_queues[]' should be
>> freed in ethdev.c.
>>
>>> 3. Combine close() and uninit(), only one will be left.
>>>     This will work fine for both hotplug case and normal case. But it
>>> may change a lot, such as logic.
>> I guess this will be second option.  But I agree we need to change a lot. Also
>> after enabling hotplug by default, when someone only wants to close the
>> port, it will be impossible.
>>
>> Regards,
>> Tetsuya

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit function.
  2015-07-08  3:47                   ` Tetsuya Mukawa
@ 2015-07-08  9:49                     ` Iremonger, Bernard
  2015-07-08  9:59                       ` Thomas Monjalon
                                         ` (2 more replies)
  0 siblings, 3 replies; 270+ messages in thread
From: Iremonger, Bernard @ 2015-07-08  9:49 UTC (permalink / raw)
  To: Tetsuya Mukawa, dev



> -----Original Message-----
> From: Tetsuya Mukawa [mailto:mukawa@igel.co.jp]
> Sent: Wednesday, July 8, 2015 4:48 AM
> To: Iremonger, Bernard; dev@dpdk.org
> Cc: Qiu, Michael; thomas.monjalon@6wind.com; Ananyev, Konstantin;
> Stephen Hemminger; Zhang, Helin; Chen, Jing D; Neil Horman
> Subject: Re: [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit
> function.
> 
> On 2015/07/07 19:53, Iremonger, Bernard wrote:
> >> -----Original Message-----
> >> From: Tetsuya Mukawa [mailto:mukawa@igel.co.jp]
> >> Sent: Tuesday, July 7, 2015 4:38 AM
> >> To: dev@dpdk.org
> >> Cc: Qiu, Michael; Iremonger, Bernard; thomas.monjalon@6wind.com;
> >> Ananyev, Konstantin; Stephen Hemminger; Zhang, Helin; Chen, Jing D;
> >> Neil Horman
> >> Subject: Re: [dpdk-dev] [PATCH v2] librte_ether: release memory in
> >> uninit function.
> >>
> >> On 2015/07/06 20:35, Qiu, Michael wrote:
> >>> Hi, all
> >>>
> >>> As we has gap on the memory release action to be done in which step,
> >>> I appreciate all your comments on this patch.
> >>>
> >>> Currently, the correct quit sequence for testpmd is stop() --->
> >>> port_stop() --> port_close() --> quit(). This will lead lots of
> >>> memory not released by default, like queues.
> > There is also the scenario (outside of testpmd) where an application can call
> rte_eth_dev_close() or rte_eth_dev_detach() which calls
> rte_eth_dev_uninit() directly from an application.
> > In these cases the memory allocated in the EAL layer should be released in
> both rte_eth_dev_close() and rte_eth_dev_detach().
> 
> Hi Bernard,
> 
> All DPDK applications that uses hotpluggingmust call rte_eth_dev_stop() and
> rte_eth_dev_close()APIs before detaching ports.
> (This is described in DPDK documentation) Could we ignore applications that
> only calls rte_eth_dev_detach()?
> 
> > This patch is intended to address the rte_eth_dev_detach() case only
> (hotplug case).
> > Perhaps there should be a separate patch to address the
> rte_eth_dev_close() case.
> 
> We all needs to have consensus about how to implement finalization code in
> close() and uninit().
> Probably one of options will be implementing finalization code in
> close() as much as possible.
> 
> Tetsuya,

Hi Tetsuya,
Testpmd enforces the dev_stop(), dev_close() and dev_detach() sequence.
There is no reason why an application cannot call dev_detach() directly. 

During internal review of PMD dev_uninit()  functions it was decided to ensure that this sequence was adhered to by calling dev_close() which calls dev_stop() from the dev_uninit() function.
In the PMD hotplug patches the following calling sequence is implemented:
dev_uninit() calls dev_close() calls dev_stop().
At present most of the finalization code is implemented in dev_close() and dev_stop().
The dev_uninit() functions implement what is left of the finalization code.

Regards,

Bernard.

> 
> > Regards,
> >
> > Bernard.
> >
> >>> We have 3 potential proposals(normal case means without hotplug):
> >>>
> >>> 1. Those memory release in close()  other left in uninit()
> >>>     This will work fine for both hotplug case and normal case.
> >> +1
> >>
> >> I assume that once close() is called, we cannot start the port again
> >> without hotplugging.
> >> This is my premise.
> >>
> >> It might be good that we move finalization code to close() as much as
> >> possible, because of followings.
> >> 1. Anyway, once close() is called, we cannot start the port again. So
> >> it should be ok to free resources in close().
> >> 2. Non-hotplugging applications can release resources if we implement
> >> finalization code to close().
> >>
> >> Also I guess Stephen's suggestion is important to keep code clean.
> >> It may be good that 'dev->data->rx/tx_queues[queue_id]' are freed in
> >> rx/tx_queue_release() of each PMD, and rx/tx_queue_release() will be
> >> called by rte_eth_dev_close(). Also 'dev->data->rx/tx_queues[]'
> >> should be freed in ethdev.c.
> >>
> >>> 3. Combine close() and uninit(), only one will be left.
> >>>     This will work fine for both hotplug case and normal case. But
> >>> it may change a lot, such as logic.
> >> I guess this will be second option.  But I agree we need to change a
> >> lot. Also after enabling hotplug by default, when someone only wants
> >> to close the port, it will be impossible.
> >>
> >> Regards,
> >> Tetsuya

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit function.
  2015-07-08  9:49                     ` Iremonger, Bernard
@ 2015-07-08  9:59                       ` Thomas Monjalon
  2015-07-09  3:32                         ` Tetsuya Mukawa
  2015-07-09  5:46                       ` [dpdk-dev] [PATCH] doc: Fix doxygen comments of rte_eth_dev_close() and rte_eth_dev_detach() Tetsuya Mukawa
  2015-07-09  8:19                       ` [dpdk-dev] [PATCH v2] " Tetsuya Mukawa
  2 siblings, 1 reply; 270+ messages in thread
From: Thomas Monjalon @ 2015-07-08  9:59 UTC (permalink / raw)
  To: Iremonger, Bernard, Tetsuya Mukawa; +Cc: dev

2015-07-08 09:49, Iremonger, Bernard:
> From: Tetsuya Mukawa [mailto:mukawa@igel.co.jp]
> > On 2015/07/07 19:53, Iremonger, Bernard wrote:
> > > From: Tetsuya Mukawa [mailto:mukawa@igel.co.jp]
> > >> On 2015/07/06 20:35, Qiu, Michael wrote:
> > >>> Hi, all
> > >>>
> > >>> As we has gap on the memory release action to be done in which step,
> > >>> I appreciate all your comments on this patch.
> > >>>
> > >>> Currently, the correct quit sequence for testpmd is stop() --->
> > >>> port_stop() --> port_close() --> quit(). This will lead lots of
> > >>> memory not released by default, like queues.
> > > There is also the scenario (outside of testpmd) where an application can call
> > rte_eth_dev_close() or rte_eth_dev_detach() which calls
> > rte_eth_dev_uninit() directly from an application.
> > > In these cases the memory allocated in the EAL layer should be released in
> > both rte_eth_dev_close() and rte_eth_dev_detach().
> > 
> > Hi Bernard,
> > 
> > All DPDK applications that uses hotpluggingmust call rte_eth_dev_stop() and
> > rte_eth_dev_close()APIs before detaching ports.
> > (This is described in DPDK documentation) Could we ignore applications that
> > only calls rte_eth_dev_detach()?
> > 
> > > This patch is intended to address the rte_eth_dev_detach() case only
> > (hotplug case).
> > > Perhaps there should be a separate patch to address the
> > rte_eth_dev_close() case.
> > 
> > We all needs to have consensus about how to implement finalization code in
> > close() and uninit().
> > Probably one of options will be implementing finalization code in
> > close() as much as possible.
> > 
> > Tetsuya,
> 
> Hi Tetsuya,
> Testpmd enforces the dev_stop(), dev_close() and dev_detach() sequence.
> There is no reason why an application cannot call dev_detach() directly. 
> 
> During internal review of PMD dev_uninit()  functions it was decided to ensure that this sequence was adhered to by calling dev_close() which calls dev_stop() from the dev_uninit() function.
> In the PMD hotplug patches the following calling sequence is implemented:
> dev_uninit() calls dev_close() calls dev_stop().
> At present most of the finalization code is implemented in dev_close() and dev_stop().
> The dev_uninit() functions implement what is left of the finalization code.

It appears that the API is not defined.
None of these assumptions is written in rte_ethdev.h.
Please continue the discussion by submitting a patch fixing the doxygen
comments of these functions.
How an application developper is supposed to use these functions without
having a clear explanation of their roles in doxygen?

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v4 4/4] test-pmd: remove call to rte_eth_promiscuous_disable() from detach_port()
  2015-07-08  0:42     ` Ouyang, Changchun
@ 2015-07-09  2:04       ` Tetsuya Mukawa
  0 siblings, 0 replies; 270+ messages in thread
From: Tetsuya Mukawa @ 2015-07-09  2:04 UTC (permalink / raw)
  To: Ouyang, Changchun, Iremonger, Bernard, dev

On 2015/07/08 9:42, Ouyang, Changchun wrote:
>> -----Original Message-----
>> From: Iremonger, Bernard
>> Sent: Tuesday, July 7, 2015 5:18 PM
>> To: dev@dpdk.org
>> Cc: Ouyang, Changchun; Iremonger, Bernard
>> Subject: [PATCH v4 4/4] test-pmd: remove call to
>> rte_eth_promiscuous_disable() from detach_port()
>>
>> At this point the stop() and close() functions have already been called.
>> The rte_eth_promiscuous_disable() function does not return on the VM.
> I think we need root the cause why it doesn't return on the VM.

It seems this patch is correct.
The root cause is that when close() is called, virtio-net device will be
reset by vtpci_reset(), and at this point all virtqueues will be invalid
in virtio-net device.
After resetting device, we should not call
rte_eth_promiscuous_disable(), because it will use an one of virtqueues.
Anyway, promiscuous configuration will be initialized when the device is
reset.

Regards,
Tetsuya

>
>> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
>> ---
>>  app/test-pmd/testpmd.c |    4 +---
>>  1 files changed, 1 insertions(+), 3 deletions(-)
>>
>> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
>> 82b465d..4769533 100644
>> --- a/app/test-pmd/testpmd.c
>> +++ b/app/test-pmd/testpmd.c
>> @@ -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
>> @@ -1542,8 +1542,6 @@ detach_port(uint8_t port_id)
>>  		return;
>>  	}
>>
>> -	rte_eth_promiscuous_disable(port_id);
>> -
> It seems a workaround.
>
>>  	if (rte_eth_dev_detach(port_id, name))
>>  		return;
>>
>> --
>> 1.7.4.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit function.
  2015-07-08  9:59                       ` Thomas Monjalon
@ 2015-07-09  3:32                         ` Tetsuya Mukawa
  2015-07-14  5:15                           ` Qiu, Michael
  0 siblings, 1 reply; 270+ messages in thread
From: Tetsuya Mukawa @ 2015-07-09  3:32 UTC (permalink / raw)
  To: Thomas Monjalon, Iremonger, Bernard, Qiu, Michael; +Cc: dev

On 2015/07/08 18:59, Thomas Monjalon wrote:
> 2015-07-08 09:49, Iremonger, Bernard:
>> From: Tetsuya Mukawa [mailto:mukawa@igel.co.jp]
>>> On 2015/07/07 19:53, Iremonger, Bernard wrote:
>>>> From: Tetsuya Mukawa [mailto:mukawa@igel.co.jp]
>>>>> On 2015/07/06 20:35, Qiu, Michael wrote:
>>>>>> Hi, all
>>>>>>
>>>>>> As we has gap on the memory release action to be done in which step,
>>>>>> I appreciate all your comments on this patch.
>>>>>>
>>>>>> Currently, the correct quit sequence for testpmd is stop() --->
>>>>>> port_stop() --> port_close() --> quit(). This will lead lots of
>>>>>> memory not released by default, like queues.
>>>> There is also the scenario (outside of testpmd) where an application can call
>>> rte_eth_dev_close() or rte_eth_dev_detach() which calls
>>> rte_eth_dev_uninit() directly from an application.
>>>> In these cases the memory allocated in the EAL layer should be released in
>>> both rte_eth_dev_close() and rte_eth_dev_detach().
>>>
>>> Hi Bernard,
>>>
>>> All DPDK applications that uses hotpluggingmust call rte_eth_dev_stop() and
>>> rte_eth_dev_close()APIs before detaching ports.
>>> (This is described in DPDK documentation) Could we ignore applications that
>>> only calls rte_eth_dev_detach()?
>>>
>>>> This patch is intended to address the rte_eth_dev_detach() case only
>>> (hotplug case).
>>>> Perhaps there should be a separate patch to address the
>>> rte_eth_dev_close() case.
>>>
>>> We all needs to have consensus about how to implement finalization code in
>>> close() and uninit().
>>> Probably one of options will be implementing finalization code in
>>> close() as much as possible.
>>>
>>> Tetsuya,
>> Hi Tetsuya,
>> Testpmd enforces the dev_stop(), dev_close() and dev_detach() sequence.
>> There is no reason why an application cannot call dev_detach() directly. 
>>
>> During internal review of PMD dev_uninit()  functions it was decided to ensure that this sequence was adhered to by calling dev_close() which calls dev_stop() from the dev_uninit() function.
>> In the PMD hotplug patches the following calling sequence is implemented:
>> dev_uninit() calls dev_close() calls dev_stop().
>> At present most of the finalization code is implemented in dev_close() and dev_stop().
>> The dev_uninit() functions implement what is left of the finalization code.
> It appears that the API is not defined.
> None of these assumptions is written in rte_ethdev.h.
> Please continue the discussion by submitting a patch fixing the doxygen
> comments of these functions.
> How an application developper is supposed to use these functions without
> having a clear explanation of their roles in doxygen?

Yes, this assumption is only written in DPDK user's guide.
So we should add description to doxygen. I will take care of it.

Anyway, I will add description to doxygen like user's guide.
 (A) stop() and close() must be called before detach().
 (B) close() releases all most all resources.
Probably Bernard and Michael patches are fit for above restrictions.

It may be good to add below in DPDK-2.2, though supporting below feature
will be more user friendly.
 (C) Even if stop() and close() are not called, detach() will take care
of it.

Probably, it's not so much time left before releasing DPDK-2.1.
So how about keeping current restriction written in user's guide, then
add a new feature in DPDK-2.2.

Regards,
Tetsuya

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH] doc: Fix doxygen comments of rte_eth_dev_close() and rte_eth_dev_detach()
  2015-07-08  9:49                     ` Iremonger, Bernard
  2015-07-08  9:59                       ` Thomas Monjalon
@ 2015-07-09  5:46                       ` Tetsuya Mukawa
  2015-07-09  7:28                         ` Thomas Monjalon
  2015-07-09  8:19                       ` [dpdk-dev] [PATCH v2] " Tetsuya Mukawa
  2 siblings, 1 reply; 270+ messages in thread
From: Tetsuya Mukawa @ 2015-07-09  5:46 UTC (permalink / raw)
  To: dev

The patch fixes doxygen comments of below functions.
 - rte_eth_dev_close()
   Add description about what kind of resources will be freed.
 - rte_eth_dev_detach()
   Add description about when the function can be called.

Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
---
 lib/librte_ether/rte_ethdev.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 438d59a..3148416 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1633,6 +1633,8 @@ int rte_eth_dev_attach(const char *devargs, uint8_t *port_id);
 
 /**
  * Detach a Ethernet device specified by port identifier.
+ * This function must be called when the device is in the
+ * closed state.
  *
  * @param port_id
  *   The port identifier of the device to detach.
@@ -1987,6 +1989,8 @@ extern int rte_eth_dev_set_link_down(uint8_t port_id);
 
 /**
  * Close an Ethernet device. The device cannot be restarted!
+ * The function frees all resources except for needed by the
+ * closed state. To free these resources, call rte_eth_dev_detach().
  *
  * @param port_id
  *   The port identifier of the Ethernet device.
-- 
2.1.4

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH] doc: Fix doxygen comments of rte_eth_dev_close() and rte_eth_dev_detach()
  2015-07-09  5:46                       ` [dpdk-dev] [PATCH] doc: Fix doxygen comments of rte_eth_dev_close() and rte_eth_dev_detach() Tetsuya Mukawa
@ 2015-07-09  7:28                         ` Thomas Monjalon
  2015-07-09  8:10                           ` Tetsuya Mukawa
  0 siblings, 1 reply; 270+ messages in thread
From: Thomas Monjalon @ 2015-07-09  7:28 UTC (permalink / raw)
  To: Tetsuya Mukawa; +Cc: dev

2015-07-09 14:46, Tetsuya Mukawa:
> The patch fixes doxygen comments of below functions.
>  - rte_eth_dev_close()
>    Add description about what kind of resources will be freed.
>  - rte_eth_dev_detach()
>    Add description about when the function can be called.
> 
> Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>

>  /**
>   * Close an Ethernet device. The device cannot be restarted!
> + * The function frees all resources except for needed by the
> + * closed state. To free these resources, call rte_eth_dev_detach().

Maybe we should tell that stop must be called before close:
"Close a stopped Ethernet device."

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH] doc: Fix doxygen comments of rte_eth_dev_close() and rte_eth_dev_detach()
  2015-07-09  7:28                         ` Thomas Monjalon
@ 2015-07-09  8:10                           ` Tetsuya Mukawa
  0 siblings, 0 replies; 270+ messages in thread
From: Tetsuya Mukawa @ 2015-07-09  8:10 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

On 2015/07/09 16:28, Thomas Monjalon wrote:
> 2015-07-09 14:46, Tetsuya Mukawa:
>> The patch fixes doxygen comments of below functions.
>>  - rte_eth_dev_close()
>>    Add description about what kind of resources will be freed.
>>  - rte_eth_dev_detach()
>>    Add description about when the function can be called.
>>
>> Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
>>  /**
>>   * Close an Ethernet device. The device cannot be restarted!
>> + * The function frees all resources except for needed by the
>> + * closed state. To free these resources, call rte_eth_dev_detach().
> Maybe we should tell that stop must be called before close:
> "Close a stopped Ethernet device."

Sure, I will add it and submit again soon.

Tetsuya

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v2] doc: Fix doxygen comments of rte_eth_dev_close() and rte_eth_dev_detach()
  2015-07-08  9:49                     ` Iremonger, Bernard
  2015-07-08  9:59                       ` Thomas Monjalon
  2015-07-09  5:46                       ` [dpdk-dev] [PATCH] doc: Fix doxygen comments of rte_eth_dev_close() and rte_eth_dev_detach() Tetsuya Mukawa
@ 2015-07-09  8:19                       ` Tetsuya Mukawa
  2015-07-10 22:31                         ` Thomas Monjalon
  2 siblings, 1 reply; 270+ messages in thread
From: Tetsuya Mukawa @ 2015-07-09  8:19 UTC (permalink / raw)
  To: dev

The patch fixes doxygen comments of below functions.
 - rte_eth_dev_close()
   Add description about when the function can be called and also about
   what kind of resources will be freed.
 - rte_eth_dev_detach()
   Add description about when the function can be called.

Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
---
 lib/librte_ether/rte_ethdev.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 438d59a..f4e3d42 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1633,6 +1633,8 @@ int rte_eth_dev_attach(const char *devargs, uint8_t *port_id);
 
 /**
  * Detach a Ethernet device specified by port identifier.
+ * This function must be called when the device is in the
+ * closed state.
  *
  * @param port_id
  *   The port identifier of the device to detach.
@@ -1986,7 +1988,9 @@ extern int rte_eth_dev_set_link_up(uint8_t port_id);
 extern int rte_eth_dev_set_link_down(uint8_t port_id);
 
 /**
- * Close an Ethernet device. The device cannot be restarted!
+ * Close a stopped Ethernet device. The device cannot be restarted!
+ * The function frees all resources except for needed by the
+ * closed state. To free these resources, call rte_eth_dev_detach().
  *
  * @param port_id
  *   The port identifier of the Ethernet device.
-- 
2.1.4

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v6 0/7] i40e: PCI Port Hotplug Changes
  2015-07-03 14:03 ` [dpdk-dev] [PATCH v6 0/7] i40e: PCI Port Hotplug Changes Bernard Iremonger
                     ` (6 preceding siblings ...)
  2015-07-03 14:04   ` [dpdk-dev] [PATCH v6 7/7] i40e: release queue memory in close functions Bernard Iremonger
@ 2015-07-10 20:44   ` Zhang, Helin
  2015-07-19 19:39     ` Thomas Monjalon
  7 siblings, 1 reply; 270+ messages in thread
From: Zhang, Helin @ 2015-07-10 20:44 UTC (permalink / raw)
  To: Iremonger, Bernard, dev



> -----Original Message-----
> From: Iremonger, Bernard
> Sent: Friday, July 3, 2015 7:04 AM
> To: dev@dpdk.org
> Cc: Zhang, Helin; Qiu, Michael; Iremonger, Bernard
> Subject: [PATCH v6 0/7] i40e: PCI Port Hotplug Changes
> 
> Changes in V6:
> Rebased to latest code.
> Removed release of rx and tx queues from uninit() functions.
> added patch 7, add function i40e_dev_free_queues() and call from close()
> functions.
> 
> Changes in V5:
> Increased timeout in i40evf_wait_cmd_done() Set nb_rx_queues and
> nb_tx_queues to 0 in uninit functions.
> Rebased to latest i40e code.
> 
> Changes in V4:
> added patch 6 to fix segmentation fault reported by Michael Qiu.
> Rebase to latest i40e code.
> 
> Changes in V3:
> Release rx and tx queues in vf uninit function.
> Rebase to use latest i40e code.
> 
> Changes in V2:
> Rebase to use drivers/net/i40e directory.
> 
> 
> Bernard Iremonger (7):
>   i40e: changes to support PCI Port Hotplug
>   i40e: release vmdq vsi's in dev_close
>   i40e: increase ASQ_DELAY_MS to 100 and MAX_TRY_TIMES to 20 in
>     i40evf_wait_cmd_done()
>   i40e: call _clear_cmd() when error occurs
>   i40e: clear queues in i40evf_dev_stop
>   i40e: check rxq parameter in i40e_reset_rx_queue
>   i40e: release queue memory in close functions
> 
>  drivers/net/i40e/i40e_ethdev.c    |   78
> ++++++++++++++++++++++++++++++++++++-
>  drivers/net/i40e/i40e_ethdev_vf.c |   62 ++++++++++++++++++++++++++---
>  drivers/net/i40e/i40e_pf.c        |   34 ++++++++++++++++
>  drivers/net/i40e/i40e_pf.h        |    1 +
>  drivers/net/i40e/i40e_rxtx.c      |   25 ++++++++++++
>  drivers/net/i40e/i40e_rxtx.h      |    1 +
>  6 files changed, 193 insertions(+), 8 deletions(-)
> 
> --
> 1.7.4.1

Acked-by: Helin Zhang <helin.zhang@intel.com>

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v2] doc: Fix doxygen comments of rte_eth_dev_close() and rte_eth_dev_detach()
  2015-07-09  8:19                       ` [dpdk-dev] [PATCH v2] " Tetsuya Mukawa
@ 2015-07-10 22:31                         ` Thomas Monjalon
  0 siblings, 0 replies; 270+ messages in thread
From: Thomas Monjalon @ 2015-07-10 22:31 UTC (permalink / raw)
  To: Tetsuya Mukawa; +Cc: dev

2015-07-09 17:19, Tetsuya Mukawa:
> The patch fixes doxygen comments of below functions.
>  - rte_eth_dev_close()
>    Add description about when the function can be called and also about
>    what kind of resources will be freed.
>  - rte_eth_dev_detach()
>    Add description about when the function can be called.
> 
> Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>

Applied, thanks

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 0/2] librte_ether release memory
       [not found] <PATCH>
                   ` (18 preceding siblings ...)
  2015-07-07 13:09 ` [dpdk-dev] [PATCH v4 0/1] ring PCI Port Hotplug Bernard Iremonger
@ 2015-07-13 13:04 ` Bernard Iremonger
  2015-07-13 13:04   ` [dpdk-dev] [PATCH v3 1/2] librte_ether: release memory in uninit function Bernard Iremonger
                     ` (2 more replies)
  2015-07-14 13:10 ` [dpdk-dev] [PATCH v5 0/4] virtio PCI Port Hotplug Bernard Iremonger
                   ` (21 subsequent siblings)
  41 siblings, 3 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-13 13:04 UTC (permalink / raw)
  To: dev

Changes in V3:
Release queue array memory in rte_eth_dev_close() function

Changes in V2:
do not free mac_addrs and hash_mac_addrs in rte_eth_dev_uninit() function.

Bernard Iremonger (2):
  librte_ether: release memory in uninit function.
  librte_ether: release queue array memory in close function

 lib/librte_ether/rte_ethdev.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 1/2] librte_ether: release memory in uninit function.
  2015-07-13 13:04 ` [dpdk-dev] [PATCH v3 0/2] librte_ether release memory Bernard Iremonger
@ 2015-07-13 13:04   ` Bernard Iremonger
  2015-07-17 13:55     ` Thomas Monjalon
  2015-07-13 13:04   ` [dpdk-dev] [PATCH v3 2/2] librte_ether: release queue array memory in close function Bernard Iremonger
  2015-07-14  4:51   ` [dpdk-dev] [PATCH v3 0/2] librte_ether release memory Qiu, Michael
  2 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-13 13:04 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index b79e5f79..270697e 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -387,8 +387,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;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 2/2] librte_ether: release queue array memory in close function
  2015-07-13 13:04 ` [dpdk-dev] [PATCH v3 0/2] librte_ether release memory Bernard Iremonger
  2015-07-13 13:04   ` [dpdk-dev] [PATCH v3 1/2] librte_ether: release memory in uninit function Bernard Iremonger
@ 2015-07-13 13:04   ` Bernard Iremonger
  2015-07-19 21:37     ` Thomas Monjalon
  2015-07-14  4:51   ` [dpdk-dev] [PATCH v3 0/2] librte_ether release memory Qiu, Michael
  2 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-13 13:04 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 270697e..04b6212 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1395,6 +1395,11 @@ rte_eth_dev_close(uint8_t port_id)
 	FUNC_PTR_OR_RET(*dev->dev_ops->dev_close);
 	dev->data->dev_started = 0;
 	(*dev->dev_ops->dev_close)(dev);
+
+	rte_free(dev->data->rx_queues);
+	dev->data->rx_queues = NULL;
+	rte_free(dev->data->tx_queues);
+	dev->data->tx_queues = NULL;
 }
 
 int
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v7 1/2] e1000: igb and em1000 PCI Port Hotplug changes
  2015-07-03 14:38   ` [dpdk-dev] [PATCH v7 1/2] e1000: igb and em1000 " Bernard Iremonger
@ 2015-07-13 15:53     ` Zhang, Helin
  0 siblings, 0 replies; 270+ messages in thread
From: Zhang, Helin @ 2015-07-13 15:53 UTC (permalink / raw)
  To: Iremonger, Bernard, dev



> -----Original Message-----
> From: Iremonger, Bernard
> Sent: Friday, July 3, 2015 7:38 AM
> To: dev@dpdk.org
> Cc: Zhang, Helin; Qiu, Michael; Iremonger, Bernard
> Subject: [PATCH v7 1/2] e1000: igb and em1000 PCI Port Hotplug changes
> 
> This patch depends on the Port Hotplug Framework.
> It implements the eth_dev_uninit functions for rte_em_pmd, rte_igb_pmd and
> rte_igbvf_pmd.
> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
Acked-by: Helin Zhang <helin.zhang@intel.com>

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v7 2/2] e1000: free queue memory in close functions
  2015-07-03 14:38   ` [dpdk-dev] [PATCH v7 2/2] e1000: free queue memory in close functions Bernard Iremonger
@ 2015-07-13 15:54     ` Zhang, Helin
  0 siblings, 0 replies; 270+ messages in thread
From: Zhang, Helin @ 2015-07-13 15:54 UTC (permalink / raw)
  To: Iremonger, Bernard, dev



> -----Original Message-----
> From: Iremonger, Bernard
> Sent: Friday, July 3, 2015 7:38 AM
> To: dev@dpdk.org
> Cc: Zhang, Helin; Qiu, Michael; Iremonger, Bernard
> Subject: [PATCH v7 2/2] e1000: free queue memory in close functions
> 
> add new functions igb_dev_free_queues() and em_dev_free_queues()
> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
Acked-by: Helin Zhang <helin.zhang@intel.com>

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v3 0/2] librte_ether release memory
  2015-07-13 13:04 ` [dpdk-dev] [PATCH v3 0/2] librte_ether release memory Bernard Iremonger
  2015-07-13 13:04   ` [dpdk-dev] [PATCH v3 1/2] librte_ether: release memory in uninit function Bernard Iremonger
  2015-07-13 13:04   ` [dpdk-dev] [PATCH v3 2/2] librte_ether: release queue array memory in close function Bernard Iremonger
@ 2015-07-14  4:51   ` Qiu, Michael
  2 siblings, 0 replies; 270+ messages in thread
From: Qiu, Michael @ 2015-07-14  4:51 UTC (permalink / raw)
  To: Iremonger, Bernard, dev

On 7/13/2015 9:04 PM, Iremonger, Bernard wrote:
> Changes in V3:
> Release queue array memory in rte_eth_dev_close() function
>
> Changes in V2:
> do not free mac_addrs and hash_mac_addrs in rte_eth_dev_uninit() function.
>
> Bernard Iremonger (2):
>   librte_ether: release memory in uninit function.
>   librte_ether: release queue array memory in close function
>
>  lib/librte_ether/rte_ethdev.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>

Acked-by: Michael Qiu <michael.qiu@intel.com>

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v2] librte_ether: release memory in uninit function.
  2015-07-09  3:32                         ` Tetsuya Mukawa
@ 2015-07-14  5:15                           ` Qiu, Michael
  0 siblings, 0 replies; 270+ messages in thread
From: Qiu, Michael @ 2015-07-14  5:15 UTC (permalink / raw)
  To: Tetsuya Mukawa, Thomas Monjalon, Iremonger, Bernard; +Cc: dev

On 7/9/2015 11:32 AM, Tetsuya Mukawa wrote:
> On 2015/07/08 18:59, Thomas Monjalon wrote:
>> 2015-07-08 09:49, Iremonger, Bernard:
>>> From: Tetsuya Mukawa [mailto:mukawa@igel.co.jp]
>>>> On 2015/07/07 19:53, Iremonger, Bernard wrote:
>>>>> From: Tetsuya Mukawa [mailto:mukawa@igel.co.jp]
>>>>>> On 2015/07/06 20:35, Qiu, Michael wrote:
>>>>>>> Hi, all
>>>>>>>
>>>>>>> As we has gap on the memory release action to be done in which step,
>>>>>>> I appreciate all your comments on this patch.
>>>>>>>
>>>>>>> Currently, the correct quit sequence for testpmd is stop() --->
>>>>>>> port_stop() --> port_close() --> quit(). This will lead lots of
>>>>>>> memory not released by default, like queues.

[.../...]

>> It appears that the API is not defined.
>> None of these assumptions is written in rte_ethdev.h.
>> Please continue the discussion by submitting a patch fixing the doxygen
>> comments of these functions.
>> How an application developper is supposed to use these functions without
>> having a clear explanation of their roles in doxygen?
> Yes, this assumption is only written in DPDK user's guide.
> So we should add description to doxygen. I will take care of it.
>
> Anyway, I will add description to doxygen like user's guide.
>  (A) stop() and close() must be called before detach().
>  (B) close() releases all most all resources.
> Probably Bernard and Michael patches are fit for above restrictions.
>
> It may be good to add below in DPDK-2.2, though supporting below feature
> will be more user friendly.
>  (C) Even if stop() and close() are not called, detach() will take care
> of it.
>
> Probably, it's not so much time left before releasing DPDK-2.1.
> So how about keeping current restriction written in user's guide, then
> add a new feature in DPDK-2.2.

Yes, agree.

Thanks,
Michael
> Regards,
> Tetsuya
>


^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v5 0/4] virtio PCI Port Hotplug
       [not found] <PATCH>
                   ` (19 preceding siblings ...)
  2015-07-13 13:04 ` [dpdk-dev] [PATCH v3 0/2] librte_ether release memory Bernard Iremonger
@ 2015-07-14 13:10 ` Bernard Iremonger
  2015-07-14 13:10   ` [dpdk-dev] [PATCH 1/5] virtio: add support for " Bernard Iremonger
                     ` (4 more replies)
  2015-07-15 13:50 ` [dpdk-dev] [PATCH v6 0/6] virtio PCI Port Hotplug Bernard Iremonger
                   ` (20 subsequent siblings)
  41 siblings, 5 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-14 13:10 UTC (permalink / raw)
  To: dev

Changes in V5:
Rebase.
Add proper queue release patch (patch 3).
Reorder patches, moved previous patch 3 to patch 4,
moved previous patch 4 to patch 5.

Changes in V4:
Rebase to latest code.
Move freeing of queue memory from uninit() function to close() function.
Change to testpmd to facilate testing on VM.

Changes in V3:
Rebase to latest code.
Free queue memory in uninit() function.

Changes in V2:
Rebase to use new drivers directory.
Reuse memzones.



Bernard Iremonger (4):
  virtio: add support for PCI Port Hotplug
  virtio: check vq parameter in virtqueue_detatch_unused() function
  virtio: add proper queue release
  virtio: free queue memory in virtio_dev_close()

 drivers/net/virtio/virtio_ethdev.c | 122 +++++++++++++++++++++++++++++--------
 drivers/net/virtio/virtio_ethdev.h |   8 ++-
 drivers/net/virtio/virtio_rxtx.c   |  12 ++++
 drivers/net/virtio/virtqueue.c     |  14 +++--
 4 files changed, 124 insertions(+), 32 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 1/5] virtio: add support for PCI Port Hotplug
  2015-07-14 13:10 ` [dpdk-dev] [PATCH v5 0/4] virtio PCI Port Hotplug Bernard Iremonger
@ 2015-07-14 13:10   ` Bernard Iremonger
  2015-07-14 13:10   ` [dpdk-dev] [PATCH 2/5] virtio: check vq parameter in virtqueue_detatch_unused() function Bernard Iremonger
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-14 13:10 UTC (permalink / raw)
  To: dev

This patch depends on the Port Hotplug Framework.
It implements the eth_dev_uninit_t() function for virtio pmd.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/virtio/virtio_ethdev.c | 72 ++++++++++++++++++++++++++++++++++----
 1 file changed, 65 insertions(+), 7 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index fe5f9a1..b88f297 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -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
@@ -51,6 +51,7 @@
 #include <rte_pci.h>
 #include <rte_ether.h>
 #include <rte_common.h>
+#include <rte_errno.h>
 
 #include <rte_memory.h>
 #include <rte_eal.h>
@@ -63,6 +64,7 @@
 
 
 static int eth_virtio_dev_init(struct rte_eth_dev *eth_dev);
+static int eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev);
 static int  virtio_dev_configure(struct rte_eth_dev *dev);
 static int  virtio_dev_start(struct rte_eth_dev *dev);
 static void virtio_dev_stop(struct rte_eth_dev *dev);
@@ -324,8 +326,12 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
 	mz = rte_memzone_reserve_aligned(vq_name, vq->vq_ring_size,
 		socket_id, 0, VIRTIO_PCI_VRING_ALIGN);
 	if (mz == NULL) {
-		rte_free(vq);
-		return -ENOMEM;
+		if (rte_errno == EEXIST)
+			mz = rte_memzone_lookup(vq_name);
+		if (mz == NULL) {
+			rte_free(vq);
+			return -ENOMEM;
+		}
 	}
 
 	/*
@@ -358,8 +364,13 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
 			vq_size * hw->vtnet_hdr_size,
 			socket_id, 0, RTE_CACHE_LINE_SIZE);
 		if (vq->virtio_net_hdr_mz == NULL) {
-			rte_free(vq);
-			return -ENOMEM;
+			if (rte_errno == EEXIST)
+				vq->virtio_net_hdr_mz =
+					rte_memzone_lookup(vq_name);
+			if (vq->virtio_net_hdr_mz == NULL) {
+				rte_free(vq);
+				return -ENOMEM;
+			}
 		}
 		vq->virtio_net_hdr_mem =
 			vq->virtio_net_hdr_mz->phys_addr;
@@ -372,8 +383,13 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
 		vq->virtio_net_hdr_mz = rte_memzone_reserve_aligned(vq_name,
 			PAGE_SIZE, socket_id, 0, RTE_CACHE_LINE_SIZE);
 		if (vq->virtio_net_hdr_mz == NULL) {
-			rte_free(vq);
-			return -ENOMEM;
+			if (rte_errno == EEXIST)
+				vq->virtio_net_hdr_mz =
+					rte_memzone_lookup(vq_name);
+			if (vq->virtio_net_hdr_mz == NULL) {
+				rte_free(vq);
+				return -ENOMEM;
+			}
 		}
 		vq->virtio_net_hdr_mem =
 			vq->virtio_net_hdr_mz->phys_addr;
@@ -1250,12 +1266,52 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static int
+eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
+{
+	struct rte_pci_device *pci_dev;
+	struct virtio_hw *hw = eth_dev->data->dev_private;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rte_eal_process_type() == RTE_PROC_SECONDARY)
+		return -EPERM;
+
+	if (hw->started == 1) {
+		virtio_dev_stop(eth_dev);
+		virtio_dev_close(eth_dev);
+	}
+	pci_dev = eth_dev->pci_dev;
+
+	eth_dev->dev_ops = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+
+	rte_free(hw->cvq);
+	hw->cvq = NULL;
+
+	rte_free(eth_dev->data->mac_addrs);
+	eth_dev->data->mac_addrs = NULL;
+
+	/* reset interrupt callback  */
+	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
+		rte_intr_callback_unregister(&pci_dev->intr_handle,
+						virtio_interrupt_handler,
+						eth_dev);
+
+	PMD_INIT_LOG(DEBUG, "dev_uninit completed");
+
+	return 0;
+}
+
 static struct eth_driver rte_virtio_pmd = {
 	.pci_drv = {
 		.name = "rte_virtio_pmd",
 		.id_table = pci_id_virtio_map,
+		.drv_flags = RTE_PCI_DRV_DETACHABLE,
 	},
 	.eth_dev_init = eth_virtio_dev_init,
+	.eth_dev_uninit = eth_virtio_dev_uninit,
 	.dev_private_size = sizeof(struct virtio_hw),
 };
 
@@ -1398,6 +1454,8 @@ static void virtio_dev_free_mbufs(struct rte_eth_dev *dev)
 			     "Before freeing rxq[%d] used and unused buf", i);
 		VIRTQUEUE_DUMP((struct virtqueue *)dev->data->rx_queues[i]);
 
+		PMD_INIT_LOG(DEBUG, "rx_queues[%d]=%p",
+				i, dev->data->rx_queues[i]);
 		while ((buf = (struct rte_mbuf *)virtqueue_detatch_unused(
 					dev->data->rx_queues[i])) != NULL) {
 			rte_pktmbuf_free(buf);
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 2/5] virtio: check vq parameter in virtqueue_detatch_unused() function
  2015-07-14 13:10 ` [dpdk-dev] [PATCH v5 0/4] virtio PCI Port Hotplug Bernard Iremonger
  2015-07-14 13:10   ` [dpdk-dev] [PATCH 1/5] virtio: add support for " Bernard Iremonger
@ 2015-07-14 13:10   ` Bernard Iremonger
  2015-07-14 13:10   ` [dpdk-dev] [PATCH 3/5] virtio: add proper queue release Bernard Iremonger
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-14 13:10 UTC (permalink / raw)
  To: dev

If vq is NULL, there is a segmentation fault.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/virtio/virtqueue.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/net/virtio/virtqueue.c b/drivers/net/virtio/virtqueue.c
index 8a3005f..7f60e3e 100644
--- a/drivers/net/virtio/virtqueue.c
+++ b/drivers/net/virtio/virtqueue.c
@@ -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
@@ -60,11 +60,13 @@ virtqueue_detatch_unused(struct virtqueue *vq)
 	struct rte_mbuf *cookie;
 	int idx;
 
-	for (idx = 0; idx < vq->vq_nentries; idx++) {
-		if ((cookie = vq->vq_descx[idx].cookie) != NULL) {
-			vq->vq_descx[idx].cookie = NULL;
-			return cookie;
+	if (vq != NULL)
+		for (idx = 0; idx < vq->vq_nentries; idx++) {
+			cookie = vq->vq_descx[idx].cookie;
+			if (cookie != NULL) {
+				vq->vq_descx[idx].cookie = NULL;
+				return cookie;
+			}
 		}
-	}
 	return NULL;
 }
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 3/5] virtio: add proper queue release
  2015-07-14 13:10 ` [dpdk-dev] [PATCH v5 0/4] virtio PCI Port Hotplug Bernard Iremonger
  2015-07-14 13:10   ` [dpdk-dev] [PATCH 1/5] virtio: add support for " Bernard Iremonger
  2015-07-14 13:10   ` [dpdk-dev] [PATCH 2/5] virtio: check vq parameter in virtqueue_detatch_unused() function Bernard Iremonger
@ 2015-07-14 13:10   ` Bernard Iremonger
  2015-07-14 13:10   ` [dpdk-dev] [PATCH 4/5] virtio: free queue memory in virtio_dev_close() Bernard Iremonger
  2015-07-14 13:10   ` [dpdk-dev] [PATCH v5 5/5] test-pmd: remove call to rte_eth_promiscuous_disable() from detach_port() Bernard Iremonger
  4 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-14 13:10 UTC (permalink / raw)
  To: dev

Add functions virtio_dev_queue_release(), virtio_dev_rx_queue_release() and
virtio_dev_tx_queue_release().

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/virtio/virtio_ethdev.c | 31 +++++++++++++------------------
 drivers/net/virtio/virtio_ethdev.h |  8 +++++++-
 drivers/net/virtio/virtio_rxtx.c   | 12 ++++++++++++
 3 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index b88f297..b32b3e9 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -80,9 +80,6 @@ static int virtio_dev_link_update(struct rte_eth_dev *dev,
 static void virtio_set_hwaddr(struct virtio_hw *hw);
 static void virtio_get_hwaddr(struct virtio_hw *hw);
 
-static void virtio_dev_rx_queue_release(__rte_unused void *rxq);
-static void virtio_dev_tx_queue_release(__rte_unused void *txq);
-
 static void virtio_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats);
 static void virtio_dev_stats_reset(struct rte_eth_dev *dev);
 static void virtio_dev_free_mbufs(struct rte_eth_dev *dev);
@@ -240,6 +237,19 @@ virtio_set_multiple_queues(struct rte_eth_dev *dev, uint16_t nb_queues)
 	return 0;
 }
 
+void
+virtio_dev_queue_release(struct virtqueue *vq) {
+	struct virtio_hw *hw = vq->hw;
+
+	if (vq) {
+		/* Select and deactivate the queue */
+		VIRTIO_WRITE_REG_2(hw, VIRTIO_PCI_QUEUE_SEL, vq->queue_id);
+		VIRTIO_WRITE_REG_4(hw, VIRTIO_PCI_QUEUE_PFN, 0);
+
+		rte_free(vq);
+	}
+}
+
 int virtio_dev_queue_setup(struct rte_eth_dev *dev,
 			int queue_type,
 			uint16_t queue_idx,
@@ -553,10 +563,8 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {
 	.stats_reset             = virtio_dev_stats_reset,
 	.link_update             = virtio_dev_link_update,
 	.rx_queue_setup          = virtio_dev_rx_queue_setup,
-	/* meaningfull only to multiple queue */
 	.rx_queue_release        = virtio_dev_rx_queue_release,
 	.tx_queue_setup          = virtio_dev_tx_queue_setup,
-	/* meaningfull only to multiple queue */
 	.tx_queue_release        = virtio_dev_tx_queue_release,
 	/* collect stats per queue */
 	.queue_stats_mapping_set = virtio_dev_queue_stats_mapping_set,
@@ -1335,19 +1343,6 @@ rte_virtio_pmd_init(const char *name __rte_unused,
 }
 
 /*
- * Only 1 queue is supported, no queue release related operation
- */
-static void
-virtio_dev_rx_queue_release(__rte_unused void *rxq)
-{
-}
-
-static void
-virtio_dev_tx_queue_release(__rte_unused void *txq)
-{
-}
-
-/*
  * Configure virtio device
  * It returns 0 on success.
  */
diff --git a/drivers/net/virtio/virtio_ethdev.h b/drivers/net/virtio/virtio_ethdev.h
index df2cb7d..3858b00 100644
--- a/drivers/net/virtio/virtio_ethdev.h
+++ b/drivers/net/virtio/virtio_ethdev.h
@@ -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
@@ -84,15 +84,21 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
 			unsigned int socket_id,
 			struct virtqueue **pvq);
 
+void virtio_dev_queue_release(struct virtqueue *vq);
+
 int  virtio_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
 		uint16_t nb_rx_desc, unsigned int socket_id,
 		const struct rte_eth_rxconf *rx_conf,
 		struct rte_mempool *mb_pool);
 
+void virtio_dev_rx_queue_release(void *rxq);
+
 int  virtio_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 		uint16_t nb_tx_desc, unsigned int socket_id,
 		const struct rte_eth_txconf *tx_conf);
 
+void virtio_dev_tx_queue_release(void *txq);
+
 uint16_t virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		uint16_t nb_pkts);
 
diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index 091c7fb..5388caa 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -401,6 +401,12 @@ virtio_dev_rx_queue_setup(struct rte_eth_dev *dev,
 	return 0;
 }
 
+void
+virtio_dev_rx_queue_release(void *rxq)
+{
+	virtio_dev_queue_release(rxq);
+}
+
 /*
  * struct rte_eth_dev *dev: Used to update dev
  * uint16_t nb_desc: Defaults to values read from config space
@@ -455,6 +461,12 @@ virtio_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	return 0;
 }
 
+void
+virtio_dev_tx_queue_release(void *txq)
+{
+	virtio_dev_queue_release(txq);
+}
+
 static void
 virtio_discard_rxbuf(struct virtqueue *vq, struct rte_mbuf *m)
 {
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 4/5] virtio: free queue memory in virtio_dev_close()
  2015-07-14 13:10 ` [dpdk-dev] [PATCH v5 0/4] virtio PCI Port Hotplug Bernard Iremonger
                     ` (2 preceding siblings ...)
  2015-07-14 13:10   ` [dpdk-dev] [PATCH 3/5] virtio: add proper queue release Bernard Iremonger
@ 2015-07-14 13:10   ` Bernard Iremonger
  2015-07-14 18:28     ` Stephen Hemminger
  2015-07-15  1:36     ` Ouyang, Changchun
  2015-07-14 13:10   ` [dpdk-dev] [PATCH v5 5/5] test-pmd: remove call to rte_eth_promiscuous_disable() from detach_port() Bernard Iremonger
  4 siblings, 2 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-14 13:10 UTC (permalink / raw)
  To: dev

Add function virtio_free_queues() and call from virtio_dev_close()
Use virtio_dev_rx_queue_release() and virtio_dev_tx_queue_release()

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/virtio/virtio_ethdev.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index b32b3e9..4676ab1 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -438,6 +438,24 @@ virtio_dev_cq_queue_setup(struct rte_eth_dev *dev, uint16_t vtpci_queue_idx,
 }
 
 static void
+virtio_free_queues(struct rte_eth_dev *dev)
+{
+	unsigned int i;
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		virtio_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++) {
+		virtio_dev_tx_queue_release(dev->data->tx_queues[i]);
+		dev->data->tx_queues[i] = NULL;
+	}
+	dev->data->nb_tx_queues = 0;
+}
+
+static void
 virtio_dev_close(struct rte_eth_dev *dev)
 {
 	struct virtio_hw *hw = dev->data->dev_private;
@@ -451,6 +469,7 @@ virtio_dev_close(struct rte_eth_dev *dev)
 	vtpci_reset(hw);
 	hw->started = 0;
 	virtio_dev_free_mbufs(dev);
+	virtio_free_queues(dev);
 }
 
 static void
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v5 5/5] test-pmd: remove call to rte_eth_promiscuous_disable() from detach_port()
  2015-07-14 13:10 ` [dpdk-dev] [PATCH v5 0/4] virtio PCI Port Hotplug Bernard Iremonger
                     ` (3 preceding siblings ...)
  2015-07-14 13:10   ` [dpdk-dev] [PATCH 4/5] virtio: free queue memory in virtio_dev_close() Bernard Iremonger
@ 2015-07-14 13:10   ` Bernard Iremonger
  4 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-14 13:10 UTC (permalink / raw)
  To: dev

At this point the stop() and close() functions have already been called.
The rte_eth_promiscuous_disable() function does not return on the VM.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 app/test-pmd/testpmd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 82b465d..4769533 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -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
@@ -1542,8 +1542,6 @@ detach_port(uint8_t port_id)
 		return;
 	}
 
-	rte_eth_promiscuous_disable(port_id);
-
 	if (rte_eth_dev_detach(port_id, name))
 		return;
 
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH 4/5] virtio: free queue memory in virtio_dev_close()
  2015-07-14 13:10   ` [dpdk-dev] [PATCH 4/5] virtio: free queue memory in virtio_dev_close() Bernard Iremonger
@ 2015-07-14 18:28     ` Stephen Hemminger
  2015-07-15  8:27       ` Iremonger, Bernard
  2015-07-15  1:36     ` Ouyang, Changchun
  1 sibling, 1 reply; 270+ messages in thread
From: Stephen Hemminger @ 2015-07-14 18:28 UTC (permalink / raw)
  To: Bernard Iremonger; +Cc: dev

On Tue, 14 Jul 2015 14:10:58 +0100
Bernard Iremonger <bernard.iremonger@intel.com> wrote:

>  static void
> +virtio_free_queues(struct rte_eth_dev *dev)
> +{
> +	unsigned int i;
> +
> +	for (i = 0; i < dev->data->nb_rx_queues; i++) {
> +		virtio_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++) {
> +		virtio_dev_tx_queue_release(dev->data->tx_queues[i]);
> +		dev->data->tx_queues[i] = NULL;
> +	}
> +	dev->data->nb_tx_queues = 0;
> +}
> +

Where does command queue get freed?

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH 4/5] virtio: free queue memory in virtio_dev_close()
  2015-07-14 13:10   ` [dpdk-dev] [PATCH 4/5] virtio: free queue memory in virtio_dev_close() Bernard Iremonger
  2015-07-14 18:28     ` Stephen Hemminger
@ 2015-07-15  1:36     ` Ouyang, Changchun
  2015-07-15  8:01       ` Iremonger, Bernard
  1 sibling, 1 reply; 270+ messages in thread
From: Ouyang, Changchun @ 2015-07-15  1:36 UTC (permalink / raw)
  To: Iremonger, Bernard, dev



> -----Original Message-----
> From: Iremonger, Bernard
> Sent: Tuesday, July 14, 2015 9:11 PM
> To: dev@dpdk.org
> Cc: Ouyang, Changchun; stephen@networkplumber.org; Iremonger, Bernard
> Subject: [PATCH 4/5] virtio: free queue memory in virtio_dev_close()
> 
> Add function virtio_free_queues() and call from virtio_dev_close() Use
> virtio_dev_rx_queue_release() and virtio_dev_tx_queue_release()
> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> ---
>  drivers/net/virtio/virtio_ethdev.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/drivers/net/virtio/virtio_ethdev.c
> b/drivers/net/virtio/virtio_ethdev.c
> index b32b3e9..4676ab1 100644
> --- a/drivers/net/virtio/virtio_ethdev.c
> +++ b/drivers/net/virtio/virtio_ethdev.c
> @@ -438,6 +438,24 @@ virtio_dev_cq_queue_setup(struct rte_eth_dev
> *dev, uint16_t vtpci_queue_idx,  }
> 
>  static void
> +virtio_free_queues(struct rte_eth_dev *dev) {
> +	unsigned int i;
> +
> +	for (i = 0; i < dev->data->nb_rx_queues; i++) {
> +		virtio_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++) {
> +		virtio_dev_tx_queue_release(dev->data->tx_queues[i]);
> +		dev->data->tx_queues[i] = NULL;
> +	}
> +	dev->data->nb_tx_queues = 0;
> +}
> +
> +static void
>  virtio_dev_close(struct rte_eth_dev *dev)  {
>  	struct virtio_hw *hw = dev->data->dev_private; @@ -451,6 +469,7
> @@ virtio_dev_close(struct rte_eth_dev *dev)
>  	vtpci_reset(hw);
>  	hw->started = 0;
>  	virtio_dev_free_mbufs(dev);
> +	virtio_free_queues(dev);

Validate it with vhost sample or not for this change?

>  }
> 
>  static void
> --
> 1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH 4/5] virtio: free queue memory in virtio_dev_close()
  2015-07-15  1:36     ` Ouyang, Changchun
@ 2015-07-15  8:01       ` Iremonger, Bernard
  2015-07-15  8:36         ` Ouyang, Changchun
  0 siblings, 1 reply; 270+ messages in thread
From: Iremonger, Bernard @ 2015-07-15  8:01 UTC (permalink / raw)
  To: Ouyang, Changchun, dev

Hi  Ouyang,

<snip>

> > --- a/drivers/net/virtio/virtio_ethdev.c
> > +++ b/drivers/net/virtio/virtio_ethdev.c
> > @@ -438,6 +438,24 @@ virtio_dev_cq_queue_setup(struct rte_eth_dev
> > *dev, uint16_t vtpci_queue_idx,  }
> >
> >  static void
> > +virtio_free_queues(struct rte_eth_dev *dev) {
> > +	unsigned int i;
> > +
> > +	for (i = 0; i < dev->data->nb_rx_queues; i++) {
> > +		virtio_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++) {
> > +		virtio_dev_tx_queue_release(dev->data->tx_queues[i]);
> > +		dev->data->tx_queues[i] = NULL;
> > +	}
> > +	dev->data->nb_tx_queues = 0;
> > +}
> > +
> > +static void
> >  virtio_dev_close(struct rte_eth_dev *dev)  {
> >  	struct virtio_hw *hw = dev->data->dev_private; @@ -451,6 +469,7
> @@
> > virtio_dev_close(struct rte_eth_dev *dev)
> >  	vtpci_reset(hw);
> >  	hw->started = 0;
> >  	virtio_dev_free_mbufs(dev);
> > +	virtio_free_queues(dev);
> 
> Validate it with vhost sample or not for this change?

I have tested this change with testpmd on a Fedora VM.

Regards,

Bernard.

> 
> >  }
> >
> >  static void
> > --
> > 1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH 4/5] virtio: free queue memory in virtio_dev_close()
  2015-07-14 18:28     ` Stephen Hemminger
@ 2015-07-15  8:27       ` Iremonger, Bernard
  2015-07-15  8:38         ` Ouyang, Changchun
  0 siblings, 1 reply; 270+ messages in thread
From: Iremonger, Bernard @ 2015-07-15  8:27 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

> -----Original Message-----
> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Tuesday, July 14, 2015 7:28 PM
> To: Iremonger, Bernard
> Cc: dev@dpdk.org; Ouyang, Changchun
> Subject: Re: [PATCH 4/5] virtio: free queue memory in virtio_dev_close()
> 
> On Tue, 14 Jul 2015 14:10:58 +0100
> Bernard Iremonger <bernard.iremonger@intel.com> wrote:
> 
> >  static void
> > +virtio_free_queues(struct rte_eth_dev *dev) {
> > +	unsigned int i;
> > +
> > +	for (i = 0; i < dev->data->nb_rx_queues; i++) {
> > +		virtio_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++) {
> > +		virtio_dev_tx_queue_release(dev->data->tx_queues[i]);
> > +		dev->data->tx_queues[i] = NULL;
> > +	}
> > +	dev->data->nb_tx_queues = 0;
> > +}
> > +
> 
> Where does command queue get freed?

The command queue is set up in the eth_virtio_dev_init() function and  freed in the eth_virtio_dev_uninit() function.

Regards,

Bernard.

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH 4/5] virtio: free queue memory in virtio_dev_close()
  2015-07-15  8:01       ` Iremonger, Bernard
@ 2015-07-15  8:36         ` Ouyang, Changchun
  0 siblings, 0 replies; 270+ messages in thread
From: Ouyang, Changchun @ 2015-07-15  8:36 UTC (permalink / raw)
  To: Iremonger, Bernard, dev

Hi, Bernard

> -----Original Message-----
> From: Iremonger, Bernard
> Sent: Wednesday, July 15, 2015 4:02 PM
> To: Ouyang, Changchun; dev@dpdk.org
> Cc: Xu, Qian Q; stephen@networkplumber.org
> Subject: RE: [PATCH 4/5] virtio: free queue memory in virtio_dev_close()
> 
> Hi  Ouyang,
> 
> <snip>
> 
> > > --- a/drivers/net/virtio/virtio_ethdev.c
> > > +++ b/drivers/net/virtio/virtio_ethdev.c
> > > @@ -438,6 +438,24 @@ virtio_dev_cq_queue_setup(struct rte_eth_dev
> > > *dev, uint16_t vtpci_queue_idx,  }
> > >
> > >  static void
> > > +virtio_free_queues(struct rte_eth_dev *dev) {
> > > +	unsigned int i;
> > > +
> > > +	for (i = 0; i < dev->data->nb_rx_queues; i++) {
> > > +		virtio_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++) {
> > > +		virtio_dev_tx_queue_release(dev->data->tx_queues[i]);
> > > +		dev->data->tx_queues[i] = NULL;
> > > +	}
> > > +	dev->data->nb_tx_queues = 0;
> > > +}
> > > +
> > > +static void
> > >  virtio_dev_close(struct rte_eth_dev *dev)  {
> > >  	struct virtio_hw *hw = dev->data->dev_private; @@ -451,6 +469,7
> > @@
> > > virtio_dev_close(struct rte_eth_dev *dev)
> > >  	vtpci_reset(hw);
> > >  	hw->started = 0;
> > >  	virtio_dev_free_mbufs(dev);
> > > +	virtio_free_queues(dev);
> >
> > Validate it with vhost sample or not for this change?
> 
> I have tested this change with testpmd on a Fedora VM.

I think we should make sure it will not break any current test case for virtio,
So before applying it, it needs use vhost sample on host and test the virtio driver on guest.

Thanks
Changchun
   

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH 4/5] virtio: free queue memory in virtio_dev_close()
  2015-07-15  8:27       ` Iremonger, Bernard
@ 2015-07-15  8:38         ` Ouyang, Changchun
  2015-07-15  8:50           ` Iremonger, Bernard
  0 siblings, 1 reply; 270+ messages in thread
From: Ouyang, Changchun @ 2015-07-15  8:38 UTC (permalink / raw)
  To: Iremonger, Bernard, Stephen Hemminger; +Cc: dev



> -----Original Message-----
> From: Iremonger, Bernard
> Sent: Wednesday, July 15, 2015 4:27 PM
> To: Stephen Hemminger
> Cc: dev@dpdk.org; Ouyang, Changchun
> Subject: RE: [PATCH 4/5] virtio: free queue memory in virtio_dev_close()
> 
> > -----Original Message-----
> > From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> > Sent: Tuesday, July 14, 2015 7:28 PM
> > To: Iremonger, Bernard
> > Cc: dev@dpdk.org; Ouyang, Changchun
> > Subject: Re: [PATCH 4/5] virtio: free queue memory in virtio_dev_close()
> >
> > On Tue, 14 Jul 2015 14:10:58 +0100
> > Bernard Iremonger <bernard.iremonger@intel.com> wrote:
> >
> > >  static void
> > > +virtio_free_queues(struct rte_eth_dev *dev) {
> > > +	unsigned int i;
> > > +
> > > +	for (i = 0; i < dev->data->nb_rx_queues; i++) {
> > > +		virtio_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++) {
> > > +		virtio_dev_tx_queue_release(dev->data->tx_queues[i]);
> > > +		dev->data->tx_queues[i] = NULL;
> > > +	}
> > > +	dev->data->nb_tx_queues = 0;
> > > +}
> > > +
> >
> > Where does command queue get freed?
> 
> The command queue is set up in the eth_virtio_dev_init() function and
> freed in the eth_virtio_dev_uninit() function.
> 

Do you mean control vq?

> Regards,
> 
> Bernard.

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH 4/5] virtio: free queue memory in virtio_dev_close()
  2015-07-15  8:38         ` Ouyang, Changchun
@ 2015-07-15  8:50           ` Iremonger, Bernard
  0 siblings, 0 replies; 270+ messages in thread
From: Iremonger, Bernard @ 2015-07-15  8:50 UTC (permalink / raw)
  To: Ouyang, Changchun, Stephen Hemminger; +Cc: dev



> -----Original Message-----
> From: Ouyang, Changchun
> Sent: Wednesday, July 15, 2015 9:39 AM
> To: Iremonger, Bernard; Stephen Hemminger
> Cc: dev@dpdk.org; Ouyang, Changchun
> Subject: RE: [PATCH 4/5] virtio: free queue memory in virtio_dev_close()
> 
> 
> 
> > -----Original Message-----
> > From: Iremonger, Bernard
> > Sent: Wednesday, July 15, 2015 4:27 PM
> > To: Stephen Hemminger
> > Cc: dev@dpdk.org; Ouyang, Changchun
> > Subject: RE: [PATCH 4/5] virtio: free queue memory in
> > virtio_dev_close()
> >
> > > -----Original Message-----
> > > From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> > > Sent: Tuesday, July 14, 2015 7:28 PM
> > > To: Iremonger, Bernard
> > > Cc: dev@dpdk.org; Ouyang, Changchun
> > > Subject: Re: [PATCH 4/5] virtio: free queue memory in
> > > virtio_dev_close()
> > >
> > > On Tue, 14 Jul 2015 14:10:58 +0100
> > > Bernard Iremonger <bernard.iremonger@intel.com> wrote:
> > >
> > > >  static void
> > > > +virtio_free_queues(struct rte_eth_dev *dev) {
> > > > +	unsigned int i;
> > > > +
> > > > +	for (i = 0; i < dev->data->nb_rx_queues; i++) {
> > > > +		virtio_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++) {
> > > > +		virtio_dev_tx_queue_release(dev->data->tx_queues[i]);
> > > > +		dev->data->tx_queues[i] = NULL;
> > > > +	}
> > > > +	dev->data->nb_tx_queues = 0;
> > > > +}
> > > > +
> > >
> > > Where does command queue get freed?
> >
> > The command queue is set up in the eth_virtio_dev_init() function and
> > freed in the eth_virtio_dev_uninit() function.
> >
> 
> Do you mean control vq?

I am referring to hw->cvq.

Regards,

Bernard.

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v4 1/3] bonding: add support for PCI Port Hotplug
  2015-07-07 10:21   ` [dpdk-dev] [PATCH v4 1/3] bonding: add support for " Bernard Iremonger
@ 2015-07-15 10:22     ` Declan Doherty
  0 siblings, 0 replies; 270+ messages in thread
From: Declan Doherty @ 2015-07-15 10:22 UTC (permalink / raw)
  To: Bernard Iremonger, dev

On 07/07/15 11:21, Bernard Iremonger wrote:
> This patch depends on the Port Hotplug Framework.
> It implements the rte_dev_uninit_t() function for the link bonding pmd.
>
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> ---
...
>

I think we can clean up the create function a bit further as the 
pci_id_table is static for all bonded devices we can just statically 
initialize it, as this will remove the resetting of the parameters each 
time a bonding device is created. See below

Declan

diff --git a/drivers/net/bonding/rte_eth_bond_api.c 
b/drivers/net/bonding/rte_eth_bond_api.c
index 9d8da1c..bf25470 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -193,12 +193,19 @@ number_of_sockets(void)
  }

  const char driver_name[] = "rte_bond_pmd";
-static struct rte_pci_id pci_id_table;
+
+static struct rte_pci_id pci_id_table = {
+       .device_id = PCI_ANY_ID,
+       .subsystem_device_id = PCI_ANY_ID,
+       .vendor_id = PCI_ANY_ID,
+       .subsystem_vendor_id = PCI_ANY_ID
+};

  static struct eth_driver rte_bond_pmd = {
         .pci_drv = {
                 .name = driver_name,
                 .drv_flags = RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_DETACHABLE,
+               .id_table = &pci_id_table
         },
  };

@@ -208,7 +215,6 @@ rte_eth_bond_create(const char *name, uint8_t mode, 
uint8_t socket_id)
         struct rte_pci_device *pci_dev = NULL;
         struct bond_dev_private *internals = NULL;
         struct rte_eth_dev *eth_dev = NULL;
-       struct rte_pci_driver *pci_drv = NULL;

         /* now do all data allocation - for eth_dev structure, dummy 
pci driver
          * and internal (private) data
@@ -231,16 +237,6 @@ rte_eth_bond_create(const char *name, uint8_t mode, 
uint8_t socket_id)
                 goto err;
         }

-       pci_drv = &rte_bond_pmd.pci_drv;
-
-       memset(&pci_id_table, 0, sizeof(pci_id_table));
-       pci_id_table.device_id = PCI_ANY_ID;
-       pci_id_table.subsystem_device_id = PCI_ANY_ID;
-       pci_id_table.vendor_id = PCI_ANY_ID;
-       pci_id_table.subsystem_vendor_id = PCI_ANY_ID;
-
-       pci_drv->id_table = &pci_id_table;
-
         internals = rte_zmalloc_socket(name, sizeof(*internals), 0, 
socket_id);
         if (internals == NULL) {
                 RTE_BOND_LOG(ERR, "Unable to malloc internals on socket");
@@ -255,8 +251,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, 
uint8_t socket_id)
         }

         pci_dev->numa_node = socket_id;
-       pci_drv->name = driver_name;
-       pci_dev->driver = pci_drv;
+       pci_dev->driver = &rte_bond_pmd.pci_drv;

         eth_dev->driver = &rte_bond_pmd;
         eth_dev->data->dev_private = internals;

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v6 0/6] virtio PCI Port Hotplug
       [not found] <PATCH>
                   ` (20 preceding siblings ...)
  2015-07-14 13:10 ` [dpdk-dev] [PATCH v5 0/4] virtio PCI Port Hotplug Bernard Iremonger
@ 2015-07-15 13:50 ` Bernard Iremonger
  2015-07-15 13:51   ` [dpdk-dev] [PATCH v6 1/6] virtio: add support for " Bernard Iremonger
                     ` (6 more replies)
  2015-07-15 15:32 ` [dpdk-dev] [PATCH v5 0/3] bonding " Bernard Iremonger
                   ` (19 subsequent siblings)
  41 siblings, 7 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-15 13:50 UTC (permalink / raw)
  To: dev

Changes in V6:
Rebase.
Use queue_release function in dev_uninit function (patch 5)
Set vq to NULL in queue release function.
Move previous patch 5 to patch 6.


Changes in V5:
Rebase.
Add proper queue release patch (patch 3).
Reorder patches, moved previous patch 3 to patch 4,
moved previous patch 4 to patch 5.

Changes in V4:
Rebase to latest code.
Move freeing of queue memory from uninit() function to close() function.
Change to testpmd to facilate testing on VM.

Changes in V3:
Rebase to latest code.
Free queue memory in uninit() function.

Changes in V2:
Rebase to use new drivers directory.

Bernard Iremonger (6):
  virtio: add support for PCI Port Hotplug
  virtio: check vq parameter in virtqueue_detatch_unused() function
  virtio: add proper queue release
  virtio: free queue memory in virtio_dev_close()
  virtio: use queue_release in dev_uninit
  test-pmd: remove call to rte_eth_promiscuous_disable() from
    detach_port()

 app/test-pmd/testpmd.c             |   4 +-
 drivers/net/virtio/virtio_ethdev.c | 120 +++++++++++++++++++++++++++++--------
 drivers/net/virtio/virtio_ethdev.h |   8 ++-
 drivers/net/virtio/virtio_rxtx.c   |  12 ++++
 drivers/net/virtio/virtqueue.c     |  14 +++--
 5 files changed, 123 insertions(+), 35 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v6 1/6] virtio: add support for PCI Port Hotplug
  2015-07-15 13:50 ` [dpdk-dev] [PATCH v6 0/6] virtio PCI Port Hotplug Bernard Iremonger
@ 2015-07-15 13:51   ` Bernard Iremonger
  2015-07-15 13:51   ` [dpdk-dev] [PATCH v6 2/6] virtio: check vq parameter in virtqueue_detatch_unused() function Bernard Iremonger
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-15 13:51 UTC (permalink / raw)
  To: dev

This patch depends on the Port Hotplug Framework.
It implements the eth_dev_uninit_t() function for virtio pmd.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/virtio/virtio_ethdev.c | 72 ++++++++++++++++++++++++++++++++++----
 1 file changed, 65 insertions(+), 7 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index fe5f9a1..b88f297 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -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
@@ -51,6 +51,7 @@
 #include <rte_pci.h>
 #include <rte_ether.h>
 #include <rte_common.h>
+#include <rte_errno.h>
 
 #include <rte_memory.h>
 #include <rte_eal.h>
@@ -63,6 +64,7 @@
 
 
 static int eth_virtio_dev_init(struct rte_eth_dev *eth_dev);
+static int eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev);
 static int  virtio_dev_configure(struct rte_eth_dev *dev);
 static int  virtio_dev_start(struct rte_eth_dev *dev);
 static void virtio_dev_stop(struct rte_eth_dev *dev);
@@ -324,8 +326,12 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
 	mz = rte_memzone_reserve_aligned(vq_name, vq->vq_ring_size,
 		socket_id, 0, VIRTIO_PCI_VRING_ALIGN);
 	if (mz == NULL) {
-		rte_free(vq);
-		return -ENOMEM;
+		if (rte_errno == EEXIST)
+			mz = rte_memzone_lookup(vq_name);
+		if (mz == NULL) {
+			rte_free(vq);
+			return -ENOMEM;
+		}
 	}
 
 	/*
@@ -358,8 +364,13 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
 			vq_size * hw->vtnet_hdr_size,
 			socket_id, 0, RTE_CACHE_LINE_SIZE);
 		if (vq->virtio_net_hdr_mz == NULL) {
-			rte_free(vq);
-			return -ENOMEM;
+			if (rte_errno == EEXIST)
+				vq->virtio_net_hdr_mz =
+					rte_memzone_lookup(vq_name);
+			if (vq->virtio_net_hdr_mz == NULL) {
+				rte_free(vq);
+				return -ENOMEM;
+			}
 		}
 		vq->virtio_net_hdr_mem =
 			vq->virtio_net_hdr_mz->phys_addr;
@@ -372,8 +383,13 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
 		vq->virtio_net_hdr_mz = rte_memzone_reserve_aligned(vq_name,
 			PAGE_SIZE, socket_id, 0, RTE_CACHE_LINE_SIZE);
 		if (vq->virtio_net_hdr_mz == NULL) {
-			rte_free(vq);
-			return -ENOMEM;
+			if (rte_errno == EEXIST)
+				vq->virtio_net_hdr_mz =
+					rte_memzone_lookup(vq_name);
+			if (vq->virtio_net_hdr_mz == NULL) {
+				rte_free(vq);
+				return -ENOMEM;
+			}
 		}
 		vq->virtio_net_hdr_mem =
 			vq->virtio_net_hdr_mz->phys_addr;
@@ -1250,12 +1266,52 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static int
+eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
+{
+	struct rte_pci_device *pci_dev;
+	struct virtio_hw *hw = eth_dev->data->dev_private;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rte_eal_process_type() == RTE_PROC_SECONDARY)
+		return -EPERM;
+
+	if (hw->started == 1) {
+		virtio_dev_stop(eth_dev);
+		virtio_dev_close(eth_dev);
+	}
+	pci_dev = eth_dev->pci_dev;
+
+	eth_dev->dev_ops = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+
+	rte_free(hw->cvq);
+	hw->cvq = NULL;
+
+	rte_free(eth_dev->data->mac_addrs);
+	eth_dev->data->mac_addrs = NULL;
+
+	/* reset interrupt callback  */
+	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
+		rte_intr_callback_unregister(&pci_dev->intr_handle,
+						virtio_interrupt_handler,
+						eth_dev);
+
+	PMD_INIT_LOG(DEBUG, "dev_uninit completed");
+
+	return 0;
+}
+
 static struct eth_driver rte_virtio_pmd = {
 	.pci_drv = {
 		.name = "rte_virtio_pmd",
 		.id_table = pci_id_virtio_map,
+		.drv_flags = RTE_PCI_DRV_DETACHABLE,
 	},
 	.eth_dev_init = eth_virtio_dev_init,
+	.eth_dev_uninit = eth_virtio_dev_uninit,
 	.dev_private_size = sizeof(struct virtio_hw),
 };
 
@@ -1398,6 +1454,8 @@ static void virtio_dev_free_mbufs(struct rte_eth_dev *dev)
 			     "Before freeing rxq[%d] used and unused buf", i);
 		VIRTQUEUE_DUMP((struct virtqueue *)dev->data->rx_queues[i]);
 
+		PMD_INIT_LOG(DEBUG, "rx_queues[%d]=%p",
+				i, dev->data->rx_queues[i]);
 		while ((buf = (struct rte_mbuf *)virtqueue_detatch_unused(
 					dev->data->rx_queues[i])) != NULL) {
 			rte_pktmbuf_free(buf);
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v6 2/6] virtio: check vq parameter in virtqueue_detatch_unused() function
  2015-07-15 13:50 ` [dpdk-dev] [PATCH v6 0/6] virtio PCI Port Hotplug Bernard Iremonger
  2015-07-15 13:51   ` [dpdk-dev] [PATCH v6 1/6] virtio: add support for " Bernard Iremonger
@ 2015-07-15 13:51   ` Bernard Iremonger
  2015-07-15 13:51   ` [dpdk-dev] [PATCH v6 3/6] virtio: add proper queue release Bernard Iremonger
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-15 13:51 UTC (permalink / raw)
  To: dev

If vq is NULL, there is a segmentation fault.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/virtio/virtqueue.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/net/virtio/virtqueue.c b/drivers/net/virtio/virtqueue.c
index 8a3005f..7f60e3e 100644
--- a/drivers/net/virtio/virtqueue.c
+++ b/drivers/net/virtio/virtqueue.c
@@ -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
@@ -60,11 +60,13 @@ virtqueue_detatch_unused(struct virtqueue *vq)
 	struct rte_mbuf *cookie;
 	int idx;
 
-	for (idx = 0; idx < vq->vq_nentries; idx++) {
-		if ((cookie = vq->vq_descx[idx].cookie) != NULL) {
-			vq->vq_descx[idx].cookie = NULL;
-			return cookie;
+	if (vq != NULL)
+		for (idx = 0; idx < vq->vq_nentries; idx++) {
+			cookie = vq->vq_descx[idx].cookie;
+			if (cookie != NULL) {
+				vq->vq_descx[idx].cookie = NULL;
+				return cookie;
+			}
 		}
-	}
 	return NULL;
 }
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v6 3/6] virtio: add proper queue release
  2015-07-15 13:50 ` [dpdk-dev] [PATCH v6 0/6] virtio PCI Port Hotplug Bernard Iremonger
  2015-07-15 13:51   ` [dpdk-dev] [PATCH v6 1/6] virtio: add support for " Bernard Iremonger
  2015-07-15 13:51   ` [dpdk-dev] [PATCH v6 2/6] virtio: check vq parameter in virtqueue_detatch_unused() function Bernard Iremonger
@ 2015-07-15 13:51   ` Bernard Iremonger
  2015-07-15 13:51   ` [dpdk-dev] [PATCH v6 4/6] virtio: free queue memory in virtio_dev_close() Bernard Iremonger
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-15 13:51 UTC (permalink / raw)
  To: dev

Add functions virtio_dev_queue_release(), virtio_dev_rx_queue_release() and
virtio_dev_tx_queue_release().

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/virtio/virtio_ethdev.c | 32 ++++++++++++++------------------
 drivers/net/virtio/virtio_ethdev.h |  8 +++++++-
 drivers/net/virtio/virtio_rxtx.c   | 12 ++++++++++++
 3 files changed, 33 insertions(+), 19 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index b88f297..964fcc0 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -80,9 +80,6 @@ static int virtio_dev_link_update(struct rte_eth_dev *dev,
 static void virtio_set_hwaddr(struct virtio_hw *hw);
 static void virtio_get_hwaddr(struct virtio_hw *hw);
 
-static void virtio_dev_rx_queue_release(__rte_unused void *rxq);
-static void virtio_dev_tx_queue_release(__rte_unused void *txq);
-
 static void virtio_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats);
 static void virtio_dev_stats_reset(struct rte_eth_dev *dev);
 static void virtio_dev_free_mbufs(struct rte_eth_dev *dev);
@@ -240,6 +237,20 @@ virtio_set_multiple_queues(struct rte_eth_dev *dev, uint16_t nb_queues)
 	return 0;
 }
 
+void
+virtio_dev_queue_release(struct virtqueue *vq) {
+	struct virtio_hw *hw = vq->hw;
+
+	if (vq) {
+		/* Select and deactivate the queue */
+		VIRTIO_WRITE_REG_2(hw, VIRTIO_PCI_QUEUE_SEL, vq->queue_id);
+		VIRTIO_WRITE_REG_4(hw, VIRTIO_PCI_QUEUE_PFN, 0);
+
+		rte_free(vq);
+		vq = NULL;
+	}
+}
+
 int virtio_dev_queue_setup(struct rte_eth_dev *dev,
 			int queue_type,
 			uint16_t queue_idx,
@@ -553,10 +564,8 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {
 	.stats_reset             = virtio_dev_stats_reset,
 	.link_update             = virtio_dev_link_update,
 	.rx_queue_setup          = virtio_dev_rx_queue_setup,
-	/* meaningfull only to multiple queue */
 	.rx_queue_release        = virtio_dev_rx_queue_release,
 	.tx_queue_setup          = virtio_dev_tx_queue_setup,
-	/* meaningfull only to multiple queue */
 	.tx_queue_release        = virtio_dev_tx_queue_release,
 	/* collect stats per queue */
 	.queue_stats_mapping_set = virtio_dev_queue_stats_mapping_set,
@@ -1335,19 +1344,6 @@ rte_virtio_pmd_init(const char *name __rte_unused,
 }
 
 /*
- * Only 1 queue is supported, no queue release related operation
- */
-static void
-virtio_dev_rx_queue_release(__rte_unused void *rxq)
-{
-}
-
-static void
-virtio_dev_tx_queue_release(__rte_unused void *txq)
-{
-}
-
-/*
  * Configure virtio device
  * It returns 0 on success.
  */
diff --git a/drivers/net/virtio/virtio_ethdev.h b/drivers/net/virtio/virtio_ethdev.h
index df2cb7d..3858b00 100644
--- a/drivers/net/virtio/virtio_ethdev.h
+++ b/drivers/net/virtio/virtio_ethdev.h
@@ -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
@@ -84,15 +84,21 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
 			unsigned int socket_id,
 			struct virtqueue **pvq);
 
+void virtio_dev_queue_release(struct virtqueue *vq);
+
 int  virtio_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
 		uint16_t nb_rx_desc, unsigned int socket_id,
 		const struct rte_eth_rxconf *rx_conf,
 		struct rte_mempool *mb_pool);
 
+void virtio_dev_rx_queue_release(void *rxq);
+
 int  virtio_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 		uint16_t nb_tx_desc, unsigned int socket_id,
 		const struct rte_eth_txconf *tx_conf);
 
+void virtio_dev_tx_queue_release(void *txq);
+
 uint16_t virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		uint16_t nb_pkts);
 
diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index 091c7fb..5388caa 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -401,6 +401,12 @@ virtio_dev_rx_queue_setup(struct rte_eth_dev *dev,
 	return 0;
 }
 
+void
+virtio_dev_rx_queue_release(void *rxq)
+{
+	virtio_dev_queue_release(rxq);
+}
+
 /*
  * struct rte_eth_dev *dev: Used to update dev
  * uint16_t nb_desc: Defaults to values read from config space
@@ -455,6 +461,12 @@ virtio_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	return 0;
 }
 
+void
+virtio_dev_tx_queue_release(void *txq)
+{
+	virtio_dev_queue_release(txq);
+}
+
 static void
 virtio_discard_rxbuf(struct virtqueue *vq, struct rte_mbuf *m)
 {
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v6 4/6] virtio: free queue memory in virtio_dev_close()
  2015-07-15 13:50 ` [dpdk-dev] [PATCH v6 0/6] virtio PCI Port Hotplug Bernard Iremonger
                     ` (2 preceding siblings ...)
  2015-07-15 13:51   ` [dpdk-dev] [PATCH v6 3/6] virtio: add proper queue release Bernard Iremonger
@ 2015-07-15 13:51   ` Bernard Iremonger
  2015-07-15 13:51   ` [dpdk-dev] [PATCH v6 5/6] virtio: use queue_release in dev_uninit Bernard Iremonger
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-15 13:51 UTC (permalink / raw)
  To: dev

Add function virtio_free_queues() and call from virtio_dev_close()
Use virtio_dev_rx_queue_release() and virtio_dev_tx_queue_release()

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/virtio/virtio_ethdev.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 964fcc0..b992898 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -439,6 +439,22 @@ virtio_dev_cq_queue_setup(struct rte_eth_dev *dev, uint16_t vtpci_queue_idx,
 }
 
 static void
+virtio_free_queues(struct rte_eth_dev *dev)
+{
+	unsigned int i;
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++)
+		virtio_dev_rx_queue_release(dev->data->rx_queues[i]);
+
+	dev->data->nb_rx_queues = 0;
+
+	for (i = 0; i < dev->data->nb_tx_queues; i++)
+		virtio_dev_tx_queue_release(dev->data->tx_queues[i]);
+
+	dev->data->nb_tx_queues = 0;
+}
+
+static void
 virtio_dev_close(struct rte_eth_dev *dev)
 {
 	struct virtio_hw *hw = dev->data->dev_private;
@@ -452,6 +468,7 @@ virtio_dev_close(struct rte_eth_dev *dev)
 	vtpci_reset(hw);
 	hw->started = 0;
 	virtio_dev_free_mbufs(dev);
+	virtio_free_queues(dev);
 }
 
 static void
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v6 5/6] virtio: use queue_release in dev_uninit
  2015-07-15 13:50 ` [dpdk-dev] [PATCH v6 0/6] virtio PCI Port Hotplug Bernard Iremonger
                     ` (3 preceding siblings ...)
  2015-07-15 13:51   ` [dpdk-dev] [PATCH v6 4/6] virtio: free queue memory in virtio_dev_close() Bernard Iremonger
@ 2015-07-15 13:51   ` Bernard Iremonger
  2015-07-15 13:51   ` [dpdk-dev] [PATCH v6 6/6] test-pmd: remove call to rte_eth_promiscuous_disable() from detach_port() Bernard Iremonger
  2015-07-17  0:53   ` [dpdk-dev] [PATCH v6 0/6] virtio PCI Port Hotplug Stephen Hemminger
  6 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-15 13:51 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/virtio/virtio_ethdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index b992898..9ca9bb2 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1313,8 +1313,7 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
 	eth_dev->tx_pkt_burst = NULL;
 	eth_dev->rx_pkt_burst = NULL;
 
-	rte_free(hw->cvq);
-	hw->cvq = NULL;
+	virtio_dev_queue_release(hw->cvq);
 
 	rte_free(eth_dev->data->mac_addrs);
 	eth_dev->data->mac_addrs = NULL;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v6 6/6] test-pmd: remove call to rte_eth_promiscuous_disable() from detach_port()
  2015-07-15 13:50 ` [dpdk-dev] [PATCH v6 0/6] virtio PCI Port Hotplug Bernard Iremonger
                     ` (4 preceding siblings ...)
  2015-07-15 13:51   ` [dpdk-dev] [PATCH v6 5/6] virtio: use queue_release in dev_uninit Bernard Iremonger
@ 2015-07-15 13:51   ` Bernard Iremonger
  2015-07-17  9:23     ` Xu, Qian Q
  2015-07-17  0:53   ` [dpdk-dev] [PATCH v6 0/6] virtio PCI Port Hotplug Stephen Hemminger
  6 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-15 13:51 UTC (permalink / raw)
  To: dev

At this point the stop() and close() functions have already been called.
The rte_eth_promiscuous_disable() function does not return on the VM.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 app/test-pmd/testpmd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 82b465d..4769533 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -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
@@ -1542,8 +1542,6 @@ detach_port(uint8_t port_id)
 		return;
 	}
 
-	rte_eth_promiscuous_disable(port_id);
-
 	if (rte_eth_dev_detach(port_id, name))
 		return;
 
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v5 0/3] bonding PCI Port Hotplug
       [not found] <PATCH>
                   ` (21 preceding siblings ...)
  2015-07-15 13:50 ` [dpdk-dev] [PATCH v6 0/6] virtio PCI Port Hotplug Bernard Iremonger
@ 2015-07-15 15:32 ` Bernard Iremonger
  2015-07-15 15:32   ` [dpdk-dev] [PATCH v5 1/3] bonding: add support for " Bernard Iremonger
                     ` (2 more replies)
  2015-07-21 15:16 ` [dpdk-dev] [PATCH v6 0/3] bonding PCI Port Hotplug Bernard Iremonger
                   ` (18 subsequent siblings)
  41 siblings, 3 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-15 15:32 UTC (permalink / raw)
  To: dev

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 (3):
  bonding: add support for PCI Port Hotplug
  test-pmd: modified testpmd for link_bonding
  bonding: free queue memory in stop function

 app/test-pmd/cmdline.c                     |  4 +-
 app/test-pmd/testpmd.c                     | 24 +++++++--
 app/test-pmd/testpmd.h                     |  7 ++-
 drivers/net/bonding/rte_eth_bond.h         | 13 ++++-
 drivers/net/bonding/rte_eth_bond_api.c     | 78 +++++++++++++++++++-----------
 drivers/net/bonding/rte_eth_bond_pmd.c     | 41 +++++++++++++++-
 drivers/net/bonding/rte_eth_bond_private.h |  7 ++-
 7 files changed, 137 insertions(+), 37 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v5 1/3] bonding: add support for PCI Port Hotplug
  2015-07-15 15:32 ` [dpdk-dev] [PATCH v5 0/3] bonding " Bernard Iremonger
@ 2015-07-15 15:32   ` Bernard Iremonger
  2015-07-18 20:39     ` Thomas Monjalon
  2015-07-15 15:32   ` [dpdk-dev] [PATCH v5 2/3] test-pmd: modified testpmd for link_bonding Bernard Iremonger
  2015-07-15 15:32   ` [dpdk-dev] [PATCH v5 3/3] bonding: free queue memory in stop function Bernard Iremonger
  2 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-15 15:32 UTC (permalink / raw)
  To: dev

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

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/bonding/rte_eth_bond.h         | 13 ++++-
 drivers/net/bonding/rte_eth_bond_api.c     | 78 +++++++++++++++++++-----------
 drivers/net/bonding/rte_eth_bond_pmd.c     | 23 ++++++++-
 drivers/net/bonding/rte_eth_bond_private.h |  7 ++-
 4 files changed, 89 insertions(+), 32 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond.h b/drivers/net/bonding/rte_eth_bond.h
index d688fc3..8efbf07 100644
--- a/drivers/net/bonding/rte_eth_bond.h
+++ b/drivers/net/bonding/rte_eth_bond.h
@@ -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.
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index d810ec4..613144f 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -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
@@ -192,7 +192,22 @@ number_of_sockets(void)
 	return ++sockets;
 }
 
-const char *driver_name = "Link Bonding PMD";
+const char driver_name[] = "rte_bond_pmd";
+
+static struct rte_pci_id pci_id_table = {
+	.device_id = PCI_ANY_ID,
+	.subsystem_device_id = PCI_ANY_ID,
+	.vendor_id = PCI_ANY_ID,
+	.subsystem_vendor_id = PCI_ANY_ID,
+};
+
+static struct eth_driver rte_bond_pmd = {
+	.pci_drv = {
+		.name = driver_name,
+		.drv_flags = RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_DETACHABLE,
+		.id_table = &pci_id_table,
+	},
+};
 
 int
 rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
@@ -200,9 +215,8 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	struct rte_pci_device *pci_dev = NULL;
 	struct bond_dev_private *internals = NULL;
 	struct rte_eth_dev *eth_dev = NULL;
-	struct eth_driver *eth_drv = NULL;
 	struct rte_pci_driver *pci_drv = NULL;
-	struct rte_pci_id *pci_id_table = NULL;
+
 	/* now do all data allocation - for eth_dev structure, dummy pci driver
 	 * and internal (private) data
 	 */
@@ -224,26 +238,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 		goto err;
 	}
 
-	eth_drv = rte_zmalloc_socket(name, sizeof(*eth_drv), 0, socket_id);
-	if (eth_drv == NULL) {
-		RTE_BOND_LOG(ERR, "Unable to malloc eth_drv on socket");
-		goto err;
-	}
-
-	pci_drv = &eth_drv->pci_drv;
-
-	pci_id_table = rte_zmalloc_socket(name, sizeof(*pci_id_table), 0, socket_id);
-	if (pci_id_table == NULL) {
-		RTE_BOND_LOG(ERR, "Unable to malloc pci_id_table on socket");
-		goto err;
-	}
-	pci_id_table->device_id = PCI_ANY_ID;
-	pci_id_table->subsystem_device_id = PCI_ANY_ID;
-	pci_id_table->vendor_id = PCI_ANY_ID;
-	pci_id_table->subsystem_vendor_id = PCI_ANY_ID;
-
-	pci_drv->id_table = pci_id_table;
-	pci_drv->drv_flags = RTE_PCI_DRV_INTR_LSC;
+	pci_drv = &rte_bond_pmd.pci_drv;
 
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
 	if (internals == NULL) {
@@ -262,7 +257,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	pci_drv->name = driver_name;
 	pci_dev->driver = pci_drv;
 
-	eth_dev->driver = eth_drv;
+	eth_dev->driver = &rte_bond_pmd;
 	eth_dev->data->dev_private = internals;
 	eth_dev->data->nb_rx_queues = (uint16_t)1;
 	eth_dev->data->nb_tx_queues = (uint16_t)1;
@@ -318,13 +313,42 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 
 err:
 	rte_free(pci_dev);
-	rte_free(pci_id_table);
-	rte_free(eth_drv);
 	rte_free(internals);
+	rte_free(eth_dev->data->mac_addrs);
 
 	return -1;
 }
 
+int
+rte_eth_bond_free(const char *name)
+{
+	struct rte_eth_dev *eth_dev = NULL;
+
+	/* now free all data allocation - for eth_dev structure,
+	 * dummy pci driver and internal (private) data
+	 */
+
+	/* find an ethdev entry */
+	eth_dev = rte_eth_dev_allocated(name);
+	if (eth_dev == NULL)
+		return -ENODEV;
+
+	if (eth_dev->data->dev_started == 1)
+		bond_ethdev_stop(eth_dev);
+
+	eth_dev->dev_ops = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+
+	rte_free(eth_dev->pci_dev);
+	rte_free(eth_dev->data->dev_private);
+	rte_free(eth_dev->data->mac_addrs);
+
+	rte_eth_dev_release_port(eth_dev);
+
+	return 0;
+}
+
 static int
 __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
 {
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 989e878..a2eecb9 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -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;
@@ -2043,6 +2043,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
@@ -2269,6 +2287,7 @@ static struct rte_driver bond_drv = {
 	.name = "eth_bond",
 	.type = PMD_VDEV,
 	.init = bond_init,
+	.uninit = bond_uninit,
 };
 
 PMD_REGISTER_DRIVER(bond_drv);
diff --git a/drivers/net/bonding/rte_eth_bond_private.h b/drivers/net/bonding/rte_eth_bond_private.h
index 45e5c65..7b00e94 100644
--- a/drivers/net/bonding/rte_eth_bond_private.h
+++ b/drivers/net/bonding/rte_eth_bond_private.h
@@ -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 *driver_name;
+extern const char driver_name[];
 
 /** Port Queue Mapping Structure */
 struct bond_rx_queue {
@@ -284,4 +284,7 @@ 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);
+
 #endif
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v5 2/3] test-pmd: modified testpmd for link_bonding
  2015-07-15 15:32 ` [dpdk-dev] [PATCH v5 0/3] bonding " Bernard Iremonger
  2015-07-15 15:32   ` [dpdk-dev] [PATCH v5 1/3] bonding: add support for " Bernard Iremonger
@ 2015-07-15 15:32   ` Bernard Iremonger
  2015-07-15 15:32   ` [dpdk-dev] [PATCH v5 3/3] bonding: free queue memory in stop function Bernard Iremonger
  2 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-15 15:32 UTC (permalink / raw)
  To: dev

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.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 app/test-pmd/cmdline.c |  4 +++-
 app/test-pmd/testpmd.c | 24 +++++++++++++++++++++---
 app/test-pmd/testpmd.h |  7 +++++--
 3 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 9eaacb4..e0119d1 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -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 =
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 82b465d..b271728 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -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
@@ -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;
 	}
 
@@ -1810,6 +1812,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,
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index e91e077..8b2219a 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -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);
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v5 3/3] bonding: free queue memory in stop function
  2015-07-15 15:32 ` [dpdk-dev] [PATCH v5 0/3] bonding " Bernard Iremonger
  2015-07-15 15:32   ` [dpdk-dev] [PATCH v5 1/3] bonding: add support for " Bernard Iremonger
  2015-07-15 15:32   ` [dpdk-dev] [PATCH v5 2/3] test-pmd: modified testpmd for link_bonding Bernard Iremonger
@ 2015-07-15 15:32   ` Bernard Iremonger
  2 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-15 15:32 UTC (permalink / raw)
  To: dev

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

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index a2eecb9..8734df0 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -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)
 {
@@ -1550,6 +1568,8 @@ bond_ethdev_stop(struct rte_eth_dev *eth_dev)
 
 	eth_dev->data->dev_link.link_status = 0;
 	eth_dev->data->dev_started = 0;
+
+	bond_ethdev_free_queues(eth_dev);
 }
 
 static void
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v6 0/6] virtio PCI Port Hotplug
  2015-07-15 13:50 ` [dpdk-dev] [PATCH v6 0/6] virtio PCI Port Hotplug Bernard Iremonger
                     ` (5 preceding siblings ...)
  2015-07-15 13:51   ` [dpdk-dev] [PATCH v6 6/6] test-pmd: remove call to rte_eth_promiscuous_disable() from detach_port() Bernard Iremonger
@ 2015-07-17  0:53   ` Stephen Hemminger
  2015-07-19 20:12     ` Thomas Monjalon
  6 siblings, 1 reply; 270+ messages in thread
From: Stephen Hemminger @ 2015-07-17  0:53 UTC (permalink / raw)
  To: Bernard Iremonger; +Cc: dev

On Wed, 15 Jul 2015 14:50:59 +0100
Bernard Iremonger <bernard.iremonger@intel.com> wrote:

> Changes in V6:
> Rebase.
> Use queue_release function in dev_uninit function (patch 5)
> Set vq to NULL in queue release function.
> Move previous patch 5 to patch 6.
> 
> 
> Changes in V5:
> Rebase.
> Add proper queue release patch (patch 3).
> Reorder patches, moved previous patch 3 to patch 4,
> moved previous patch 4 to patch 5.
> 
> Changes in V4:
> Rebase to latest code.
> Move freeing of queue memory from uninit() function to close() function.
> Change to testpmd to facilate testing on VM.
> 
> Changes in V3:
> Rebase to latest code.
> Free queue memory in uninit() function.
> 
> Changes in V2:
> Rebase to use new drivers directory.
> 
> Bernard Iremonger (6):
>   virtio: add support for PCI Port Hotplug
>   virtio: check vq parameter in virtqueue_detatch_unused() function
>   virtio: add proper queue release
>   virtio: free queue memory in virtio_dev_close()
>   virtio: use queue_release in dev_uninit
>   test-pmd: remove call to rte_eth_promiscuous_disable() from
>     detach_port()
> 
>  app/test-pmd/testpmd.c             |   4 +-
>  drivers/net/virtio/virtio_ethdev.c | 120 +++++++++++++++++++++++++++++--------
>  drivers/net/virtio/virtio_ethdev.h |   8 ++-
>  drivers/net/virtio/virtio_rxtx.c   |  12 ++++
>  drivers/net/virtio/virtqueue.c     |  14 +++--
>  5 files changed, 123 insertions(+), 35 deletions(-)
> 

Looks good thanks.

Acked-by: Stephen Hemminger <stephen@networkplumber.org>

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v6 6/6] test-pmd: remove call to rte_eth_promiscuous_disable() from detach_port()
  2015-07-15 13:51   ` [dpdk-dev] [PATCH v6 6/6] test-pmd: remove call to rte_eth_promiscuous_disable() from detach_port() Bernard Iremonger
@ 2015-07-17  9:23     ` Xu, Qian Q
  0 siblings, 0 replies; 270+ messages in thread
From: Xu, Qian Q @ 2015-07-17  9:23 UTC (permalink / raw)
  To: Iremonger, Bernard, dev

Bernard
Apply the patchset and run vhost-sample, both vhost-user and vhost-cuse, no impact. Thx. 

Thanks
Qian


-----Original Message-----
From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bernard Iremonger
Sent: Wednesday, July 15, 2015 9:51 PM
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v6 6/6] test-pmd: remove call to rte_eth_promiscuous_disable() from detach_port()

At this point the stop() and close() functions have already been called.
The rte_eth_promiscuous_disable() function does not return on the VM.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 app/test-pmd/testpmd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 82b465d..4769533 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -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
@@ -1542,8 +1542,6 @@ detach_port(uint8_t port_id)
 		return;
 	}
 
-	rte_eth_promiscuous_disable(port_id);
-
 	if (rte_eth_dev_detach(port_id, name))
 		return;
 
--
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/2] librte_ether: release memory in uninit function.
  2015-07-13 13:04   ` [dpdk-dev] [PATCH v3 1/2] librte_ether: release memory in uninit function Bernard Iremonger
@ 2015-07-17 13:55     ` Thomas Monjalon
  0 siblings, 0 replies; 270+ messages in thread
From: Thomas Monjalon @ 2015-07-17 13:55 UTC (permalink / raw)
  To: Bernard Iremonger; +Cc: dev

2015-07-13 14:04, Bernard Iremonger:
> @@ -387,8 +387,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));
> +	}

What is the benefit of freeing queues in detach/uninit function?
It is already freed in the close function of your other patch
and calling close() is mandatory before calling detach():
	http://dpdk.org/browse/dpdk/tree/doc/guides/prog_guide/port_hotplug_framework.rst#n63
	http://dpdk.org/browse/dpdk/tree/lib/librte_ether/rte_ethdev.h#n1699

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v4 1/1] ring: changes to support PCI Port Hotplug
  2015-07-07 13:09   ` [dpdk-dev] [PATCH v4 1/1] ring: changes to support " Bernard Iremonger
@ 2015-07-18 20:27     ` Thomas Monjalon
  2015-07-21 15:36       ` Iremonger, Bernard
  2015-07-27  2:52     ` Thomas Monjalon
  1 sibling, 1 reply; 270+ messages in thread
From: Thomas Monjalon @ 2015-07-18 20:27 UTC (permalink / raw)
  To: Bernard Iremonger; +Cc: dev

2015-07-07 14:09, Bernard Iremonger:
> +static struct eth_driver rte_ring_pmd = {
> +	.pci_drv = {

We really have to stop faking PCI.
EAL must be changed to allow non-PCI drivers without workaround.
A device can have no bus (virtual device) or a PCI bus or another one.

Let's rework EAL for release 2.2 before integrating this patch.

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v5 1/3] bonding: add support for PCI Port Hotplug
  2015-07-15 15:32   ` [dpdk-dev] [PATCH v5 1/3] bonding: add support for " Bernard Iremonger
@ 2015-07-18 20:39     ` Thomas Monjalon
  2015-07-21 10:18       ` Iremonger, Bernard
  0 siblings, 1 reply; 270+ messages in thread
From: Thomas Monjalon @ 2015-07-18 20:39 UTC (permalink / raw)
  To: Bernard Iremonger; +Cc: dev

2015-07-15 16:32, Bernard Iremonger:
> This patch depends on the Port Hotplug Framework.
> It implements the rte_dev_uninit_t() function for the link bonding pmd.
> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> ---
>  drivers/net/bonding/rte_eth_bond.h         | 13 ++++-
>  drivers/net/bonding/rte_eth_bond_api.c     | 78 +++++++++++++++++++-----------
>  drivers/net/bonding/rte_eth_bond_pmd.c     | 23 ++++++++-
>  drivers/net/bonding/rte_eth_bond_private.h |  7 ++-
[...]
> --- a/drivers/net/bonding/rte_eth_bond.h
> +++ b/drivers/net/bonding/rte_eth_bond.h
>  /**
> + * 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);

Why it is not exported in .map?

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v7 0/2] e1000: PCI Port Hotplug changes
  2015-07-03 14:38 ` [dpdk-dev] [PATCH v7 0/2] e1000: PCI Port Hotplug changes Bernard Iremonger
  2015-07-03 14:38   ` [dpdk-dev] [PATCH v7 1/2] e1000: igb and em1000 " Bernard Iremonger
  2015-07-03 14:38   ` [dpdk-dev] [PATCH v7 2/2] e1000: free queue memory in close functions Bernard Iremonger
@ 2015-07-19 15:26   ` Thomas Monjalon
  2 siblings, 0 replies; 270+ messages in thread
From: Thomas Monjalon @ 2015-07-19 15:26 UTC (permalink / raw)
  To: Bernard Iremonger; +Cc: dev

> Bernard Iremonger (2):
>   e1000: igb and em1000 PCI Port Hotplug changes
>   e1000: free queue memory in close functions

Applied, thanks

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v6 0/2] PCI Port Hotplug
  2015-07-02 14:59   ` [dpdk-dev] [PATCH v6 0/2] PCI Port Hotplug Ananyev, Konstantin
@ 2015-07-19 15:42     ` Thomas Monjalon
  0 siblings, 0 replies; 270+ messages in thread
From: Thomas Monjalon @ 2015-07-19 15:42 UTC (permalink / raw)
  To: Iremonger, Bernard; +Cc: dev

> > Bernard Iremonger (2):
> >   ixgbe: changes to support PCI Port Hotplug
> >   ixgbe: release queue memory in close functions
> 
> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v6 0/7] i40e: PCI Port Hotplug Changes
  2015-07-10 20:44   ` [dpdk-dev] [PATCH v6 0/7] i40e: PCI Port Hotplug Changes Zhang, Helin
@ 2015-07-19 19:39     ` Thomas Monjalon
  0 siblings, 0 replies; 270+ messages in thread
From: Thomas Monjalon @ 2015-07-19 19:39 UTC (permalink / raw)
  To: Iremonger, Bernard; +Cc: dev

> > Bernard Iremonger (7):
> >   i40e: changes to support PCI Port Hotplug
> >   i40e: release vmdq vsi's in dev_close
> >   i40e: increase ASQ_DELAY_MS to 100 and MAX_TRY_TIMES to 20 in
> >     i40evf_wait_cmd_done()
> >   i40e: call _clear_cmd() when error occurs
> >   i40e: clear queues in i40evf_dev_stop
> >   i40e: check rxq parameter in i40e_reset_rx_queue
> >   i40e: release queue memory in close functions
> 
> Acked-by: Helin Zhang <helin.zhang@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v6 0/6] virtio PCI Port Hotplug
  2015-07-17  0:53   ` [dpdk-dev] [PATCH v6 0/6] virtio PCI Port Hotplug Stephen Hemminger
@ 2015-07-19 20:12     ` Thomas Monjalon
  0 siblings, 0 replies; 270+ messages in thread
From: Thomas Monjalon @ 2015-07-19 20:12 UTC (permalink / raw)
  To: Bernard Iremonger; +Cc: dev

> > Bernard Iremonger (6):
> >   virtio: add support for PCI Port Hotplug
> >   virtio: check vq parameter in virtqueue_detatch_unused() function
> >   virtio: add proper queue release
> >   virtio: free queue memory in virtio_dev_close()
> >   virtio: use queue_release in dev_uninit
> >   test-pmd: remove call to rte_eth_promiscuous_disable() from
> >     detach_port()
> 
> Looks good thanks.
> 
> Acked-by: Stephen Hemminger <stephen@networkplumber.org>

Applied, thanks

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v3 2/2] librte_ether: release queue array memory in close function
  2015-07-13 13:04   ` [dpdk-dev] [PATCH v3 2/2] librte_ether: release queue array memory in close function Bernard Iremonger
@ 2015-07-19 21:37     ` Thomas Monjalon
  0 siblings, 0 replies; 270+ messages in thread
From: Thomas Monjalon @ 2015-07-19 21:37 UTC (permalink / raw)
  To: Bernard Iremonger; +Cc: dev

2015-07-13 14:04, Bernard Iremonger:
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>

Applied without the first patch which seems useless.

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v5 1/3] bonding: add support for PCI Port Hotplug
  2015-07-18 20:39     ` Thomas Monjalon
@ 2015-07-21 10:18       ` Iremonger, Bernard
  0 siblings, 0 replies; 270+ messages in thread
From: Iremonger, Bernard @ 2015-07-21 10:18 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

Hi Thomas,

> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Saturday, July 18, 2015 9:40 PM
> To: Iremonger, Bernard
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v5 1/3] bonding: add support for PCI Port
> Hotplug
> 
> 2015-07-15 16:32, Bernard Iremonger:
> > This patch depends on the Port Hotplug Framework.
> > It implements the rte_dev_uninit_t() function for the link bonding pmd.
> >
> > Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> > ---
> >  drivers/net/bonding/rte_eth_bond.h         | 13 ++++-
> >  drivers/net/bonding/rte_eth_bond_api.c     | 78 +++++++++++++++++++-
> ----------
> >  drivers/net/bonding/rte_eth_bond_pmd.c     | 23 ++++++++-
> >  drivers/net/bonding/rte_eth_bond_private.h |  7 ++-
> [...]
> > --- a/drivers/net/bonding/rte_eth_bond.h
> > +++ b/drivers/net/bonding/rte_eth_bond.h
> >  /**
> > + * 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);
> 
> Why it is not exported in .map?

This is an oversight, I will set a v6 patch set. 

Regards,

Bernard.

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v6 0/3] bonding PCI Port Hotplug
       [not found] <PATCH>
                   ` (22 preceding siblings ...)
  2015-07-15 15:32 ` [dpdk-dev] [PATCH v5 0/3] bonding " Bernard Iremonger
@ 2015-07-21 15:16 ` Bernard Iremonger
  2015-07-21 15:16   ` [dpdk-dev] [PATCH v6 1/3] bonding: add support for " Bernard Iremonger
                     ` (2 more replies)
  2015-07-27 15:54 ` [dpdk-dev] [PATCH v7 0/4] bonding PCI Port Hotplug Bernard Iremonger
                   ` (17 subsequent siblings)
  41 siblings, 3 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-21 15:16 UTC (permalink / raw)
  To: dev

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 (3):
  bonding: add support for PCI Port Hotplug
  test-pmd: modified testpmd for link_bonding
  bonding: free queue memory in stop function

 app/test-pmd/cmdline.c                       |  4 +-
 app/test-pmd/testpmd.c                       | 22 +++++++-
 app/test-pmd/testpmd.h                       |  7 ++-
 drivers/net/bonding/rte_eth_bond.h           | 13 ++++-
 drivers/net/bonding/rte_eth_bond_api.c       | 78 ++++++++++++++++++----------
 drivers/net/bonding/rte_eth_bond_pmd.c       | 41 ++++++++++++++-
 drivers/net/bonding/rte_eth_bond_private.h   |  7 ++-
 drivers/net/bonding/rte_eth_bond_version.map |  1 +
 8 files changed, 137 insertions(+), 36 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v6 1/3] bonding: add support for PCI Port Hotplug
  2015-07-21 15:16 ` [dpdk-dev] [PATCH v6 0/3] bonding PCI Port Hotplug Bernard Iremonger
@ 2015-07-21 15:16   ` Bernard Iremonger
  2015-07-21 15:16   ` [dpdk-dev] [PATCH v6 2/3] test-pmd: modified testpmd for link_bonding Bernard Iremonger
  2015-07-21 15:16   ` [dpdk-dev] [PATCH v6 3/3] bonding: free queue memory in stop function Bernard Iremonger
  2 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-21 15:16 UTC (permalink / raw)
  To: dev

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

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/bonding/rte_eth_bond.h           | 13 ++++-
 drivers/net/bonding/rte_eth_bond_api.c       | 78 ++++++++++++++++++----------
 drivers/net/bonding/rte_eth_bond_pmd.c       | 23 +++++++-
 drivers/net/bonding/rte_eth_bond_private.h   |  7 ++-
 drivers/net/bonding/rte_eth_bond_version.map |  1 +
 5 files changed, 90 insertions(+), 32 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond.h b/drivers/net/bonding/rte_eth_bond.h
index d688fc3..8efbf07 100644
--- a/drivers/net/bonding/rte_eth_bond.h
+++ b/drivers/net/bonding/rte_eth_bond.h
@@ -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.
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index f602658..61ae7ef 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -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
@@ -163,7 +163,22 @@ number_of_sockets(void)
 	return ++sockets;
 }
 
-const char *pmd_bond_driver_name = "Link Bonding PMD";
+const char pmd_bond_driver_name[] = "rte_bond_pmd";
+
+static struct rte_pci_id pci_id_table = {
+	.device_id = PCI_ANY_ID,
+	.subsystem_device_id = PCI_ANY_ID,
+	.vendor_id = PCI_ANY_ID,
+	.subsystem_vendor_id = PCI_ANY_ID,
+};
+
+static struct eth_driver rte_bond_pmd = {
+	.pci_drv = {
+		.name = pmd_bond_driver_name,
+		.drv_flags = RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_DETACHABLE,
+		.id_table = &pci_id_table,
+	},
+};
 
 int
 rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
@@ -171,9 +186,8 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	struct rte_pci_device *pci_dev = NULL;
 	struct bond_dev_private *internals = NULL;
 	struct rte_eth_dev *eth_dev = NULL;
-	struct eth_driver *eth_drv = NULL;
 	struct rte_pci_driver *pci_drv = NULL;
-	struct rte_pci_id *pci_id_table = NULL;
+
 	/* now do all data allocation - for eth_dev structure, dummy pci driver
 	 * and internal (private) data
 	 */
@@ -195,26 +209,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 		goto err;
 	}
 
-	eth_drv = rte_zmalloc_socket(name, sizeof(*eth_drv), 0, socket_id);
-	if (eth_drv == NULL) {
-		RTE_BOND_LOG(ERR, "Unable to malloc eth_drv on socket");
-		goto err;
-	}
-
-	pci_drv = &eth_drv->pci_drv;
-
-	pci_id_table = rte_zmalloc_socket(name, sizeof(*pci_id_table), 0, socket_id);
-	if (pci_id_table == NULL) {
-		RTE_BOND_LOG(ERR, "Unable to malloc pci_id_table on socket");
-		goto err;
-	}
-	pci_id_table->device_id = PCI_ANY_ID;
-	pci_id_table->subsystem_device_id = PCI_ANY_ID;
-	pci_id_table->vendor_id = PCI_ANY_ID;
-	pci_id_table->subsystem_vendor_id = PCI_ANY_ID;
-
-	pci_drv->id_table = pci_id_table;
-	pci_drv->drv_flags = RTE_PCI_DRV_INTR_LSC;
+	pci_drv = &rte_bond_pmd.pci_drv;
 
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
 	if (internals == NULL) {
@@ -233,7 +228,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	pci_drv->name = pmd_bond_driver_name;
 	pci_dev->driver = pci_drv;
 
-	eth_dev->driver = eth_drv;
+	eth_dev->driver = &rte_bond_pmd;
 	eth_dev->data->dev_private = internals;
 	eth_dev->data->nb_rx_queues = (uint16_t)1;
 	eth_dev->data->nb_tx_queues = (uint16_t)1;
@@ -289,13 +284,42 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 
 err:
 	rte_free(pci_dev);
-	rte_free(pci_id_table);
-	rte_free(eth_drv);
 	rte_free(internals);
+	rte_free(eth_dev->data->mac_addrs);
 
 	return -1;
 }
 
+int
+rte_eth_bond_free(const char *name)
+{
+	struct rte_eth_dev *eth_dev = NULL;
+
+	/* now free all data allocation - for eth_dev structure,
+	 * dummy pci driver and internal (private) data
+	 */
+
+	/* find an ethdev entry */
+	eth_dev = rte_eth_dev_allocated(name);
+	if (eth_dev == NULL)
+		return -ENODEV;
+
+	if (eth_dev->data->dev_started == 1)
+		bond_ethdev_stop(eth_dev);
+
+	eth_dev->dev_ops = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+
+	rte_free(eth_dev->pci_dev);
+	rte_free(eth_dev->data->dev_private);
+	rte_free(eth_dev->data->mac_addrs);
+
+	rte_eth_dev_release_port(eth_dev);
+
+	return 0;
+}
+
 static int
 __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
 {
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 9cafe65..cad8f3c 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -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;
@@ -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);
diff --git a/drivers/net/bonding/rte_eth_bond_private.h b/drivers/net/bonding/rte_eth_bond_private.h
index c531e87..205c642 100644
--- a/drivers/net/bonding/rte_eth_bond_private.h
+++ b/drivers/net/bonding/rte_eth_bond_private.h
@@ -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,7 @@ 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);
+
 #endif
diff --git a/drivers/net/bonding/rte_eth_bond_version.map b/drivers/net/bonding/rte_eth_bond_version.map
index 135999e..5519e11 100644
--- a/drivers/net/bonding/rte_eth_bond_version.map
+++ b/drivers/net/bonding/rte_eth_bond_version.map
@@ -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;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v6 2/3] test-pmd: modified testpmd for link_bonding
  2015-07-21 15:16 ` [dpdk-dev] [PATCH v6 0/3] bonding PCI Port Hotplug Bernard Iremonger
  2015-07-21 15:16   ` [dpdk-dev] [PATCH v6 1/3] bonding: add support for " Bernard Iremonger
@ 2015-07-21 15:16   ` Bernard Iremonger
  2015-07-21 15:16   ` [dpdk-dev] [PATCH v6 3/3] bonding: free queue memory in stop function Bernard Iremonger
  2 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-21 15:16 UTC (permalink / raw)
  To: dev

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.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 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(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 8ab4687..5e24319 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -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 =
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 4769533..4bcece6 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -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,
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index e91e077..8b2219a 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -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);
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v6 3/3] bonding: free queue memory in stop function
  2015-07-21 15:16 ` [dpdk-dev] [PATCH v6 0/3] bonding PCI Port Hotplug Bernard Iremonger
  2015-07-21 15:16   ` [dpdk-dev] [PATCH v6 1/3] bonding: add support for " Bernard Iremonger
  2015-07-21 15:16   ` [dpdk-dev] [PATCH v6 2/3] test-pmd: modified testpmd for link_bonding Bernard Iremonger
@ 2015-07-21 15:16   ` Bernard Iremonger
  2015-07-27  2:48     ` Thomas Monjalon
  2 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-21 15:16 UTC (permalink / raw)
  To: dev

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

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index cad8f3c..2221197 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -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)
 {
@@ -1550,6 +1568,8 @@ bond_ethdev_stop(struct rte_eth_dev *eth_dev)
 
 	eth_dev->data->dev_link.link_status = 0;
 	eth_dev->data->dev_started = 0;
+
+	bond_ethdev_free_queues(eth_dev);
 }
 
 static void
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v4 1/1] ring: changes to support PCI Port Hotplug
  2015-07-18 20:27     ` Thomas Monjalon
@ 2015-07-21 15:36       ` Iremonger, Bernard
  0 siblings, 0 replies; 270+ messages in thread
From: Iremonger, Bernard @ 2015-07-21 15:36 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

Hi Thomas,


> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Saturday, July 18, 2015 9:28 PM
> To: Iremonger, Bernard
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v4 1/1] ring: changes to support PCI Port
> Hotplug
> 
> 2015-07-07 14:09, Bernard Iremonger:
> > +static struct eth_driver rte_ring_pmd = {
> > +	.pci_drv = {
> 
> We really have to stop faking PCI.
> EAL must be changed to allow non-PCI drivers without workaround.
> A device can have no bus (virtual device) or a PCI bus or another one.
> 
> Let's rework EAL for release 2.2 before integrating this patch.

The  fake pci _drv is already used in the pcap and null  pmds and in the original ring driver.
Could they not all be reworked  when the EAL is changed for 2.2.
Surely we should be working with the 2.1 EAL.

Regards,

Bernard.

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v6 3/3] bonding: free queue memory in stop function
  2015-07-21 15:16   ` [dpdk-dev] [PATCH v6 3/3] bonding: free queue memory in stop function Bernard Iremonger
@ 2015-07-27  2:48     ` Thomas Monjalon
  2015-07-27  8:31       ` Iremonger, Bernard
  0 siblings, 1 reply; 270+ messages in thread
From: Thomas Monjalon @ 2015-07-27  2:48 UTC (permalink / raw)
  To: Bernard Iremonger; +Cc: dev

2015-07-21 16:16, Bernard Iremonger:
> add function bond_ethdev_free_queues() and call from the bond_ethdev_stop() function.

Other drivers free their queues when closing.
Why is it done in stop() for bonding?

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v4 1/1] ring: changes to support PCI Port Hotplug
  2015-07-07 13:09   ` [dpdk-dev] [PATCH v4 1/1] ring: changes to support " Bernard Iremonger
  2015-07-18 20:27     ` Thomas Monjalon
@ 2015-07-27  2:52     ` Thomas Monjalon
  1 sibling, 0 replies; 270+ messages in thread
From: Thomas Monjalon @ 2015-07-27  2:52 UTC (permalink / raw)
  To: Bernard Iremonger; +Cc: dev

2015-07-07 14:09, Bernard Iremonger:
> This patch depends on the Port Hotplug Framework.
> It implements the rte_dev_uninit_t() function for the ring pmd.
> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> Acked-by: Bruce Richardson <bruce.ruchardson@intel.com>

Applied.
The EAL must reworked without fake PCI before any other change to the ring PMD,
thanks.

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v6 3/3] bonding: free queue memory in stop function
  2015-07-27  2:48     ` Thomas Monjalon
@ 2015-07-27  8:31       ` Iremonger, Bernard
  2015-07-27  9:55         ` Thomas Monjalon
  0 siblings, 1 reply; 270+ messages in thread
From: Iremonger, Bernard @ 2015-07-27  8:31 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev


> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Monday, July 27, 2015 3:48 AM
> To: Iremonger, Bernard
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v6 3/3] bonding: free queue memory in stop
> function
> 
> 2015-07-21 16:16, Bernard Iremonger:
> > add function bond_ethdev_free_queues() and call from the
> bond_ethdev_stop() function.
> 
> Other drivers free their queues when closing.
> Why is it done in stop() for bonding?

Hi Thomas,

The close() function  is empty in bonding so I decided to free the queues in the stop() function which is implemented.
The stop() function is called before the close() function, so the effect is the same. 
It would be better to free the queues in the close() function, I will move it there.

Regards,

Bernard.
  

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v6 3/3] bonding: free queue memory in stop function
  2015-07-27  8:31       ` Iremonger, Bernard
@ 2015-07-27  9:55         ` Thomas Monjalon
  0 siblings, 0 replies; 270+ messages in thread
From: Thomas Monjalon @ 2015-07-27  9:55 UTC (permalink / raw)
  To: Iremonger, Bernard; +Cc: dev

2015-07-27 08:31, Iremonger, Bernard:
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > 2015-07-21 16:16, Bernard Iremonger:
> > > add function bond_ethdev_free_queues() and call from the
> > bond_ethdev_stop() function.
> > 
> > Other drivers free their queues when closing.
> > Why is it done in stop() for bonding?
> 
> Hi Thomas,
> 
> The close() function  is empty in bonding so I decided to free the queues in the stop() function which is implemented.
> The stop() function is called before the close() function, so the effect is the same.

No, the effect is not the same. We can call stop() without close()
and then re-start the port.

> It would be better to free the queues in the close() function, I will move it there.

Yes please.

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v7 0/4] bonding PCI Port Hotplug
       [not found] <PATCH>
                   ` (23 preceding siblings ...)
  2015-07-21 15:16 ` [dpdk-dev] [PATCH v6 0/3] bonding PCI Port Hotplug Bernard Iremonger
@ 2015-07-27 15:54 ` Bernard Iremonger
  2015-07-27 15:54   ` [dpdk-dev] [PATCH v7 1/4] bonding: add support for " Bernard Iremonger
                     ` (4 more replies)
  2015-08-04 15:26 ` [dpdk-dev] [PATCH 1/1] bonding: fix error handling in rte_eth_bond_create() Bernard Iremonger
                   ` (16 subsequent siblings)
  41 siblings, 5 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-27 15:54 UTC (permalink / raw)
  To: dev

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(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v7 1/4] bonding: add support for PCI Port Hotplug
  2015-07-27 15:54 ` [dpdk-dev] [PATCH v7 0/4] bonding PCI Port Hotplug Bernard Iremonger
@ 2015-07-27 15:54   ` Bernard Iremonger
  2015-07-27 17:14     ` Thomas Monjalon
  2015-07-27 15:54   ` [dpdk-dev] [PATCH v7 2/4] test-pmd: modified testpmd for link_bonding Bernard Iremonger
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-27 15:54 UTC (permalink / raw)
  To: dev

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

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 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(-)

diff --git a/drivers/net/bonding/rte_eth_bond.h b/drivers/net/bonding/rte_eth_bond.h
index d688fc3..8efbf07 100644
--- a/drivers/net/bonding/rte_eth_bond.h
+++ b/drivers/net/bonding/rte_eth_bond.h
@@ -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.
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index f602658..4ca26dd 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -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
@@ -163,7 +163,22 @@ number_of_sockets(void)
 	return ++sockets;
 }
 
-const char *pmd_bond_driver_name = "Link Bonding PMD";
+const char pmd_bond_driver_name[] = "rte_bond_pmd";
+
+static struct rte_pci_id pci_id_table = {
+	.device_id = PCI_ANY_ID,
+	.subsystem_device_id = PCI_ANY_ID,
+	.vendor_id = PCI_ANY_ID,
+	.subsystem_vendor_id = PCI_ANY_ID,
+};
+
+static struct eth_driver rte_bond_pmd = {
+	.pci_drv = {
+		.name = pmd_bond_driver_name,
+		.drv_flags = RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_DETACHABLE,
+		.id_table = &pci_id_table,
+	},
+};
 
 int
 rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
@@ -171,9 +186,8 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	struct rte_pci_device *pci_dev = NULL;
 	struct bond_dev_private *internals = NULL;
 	struct rte_eth_dev *eth_dev = NULL;
-	struct eth_driver *eth_drv = NULL;
 	struct rte_pci_driver *pci_drv = NULL;
-	struct rte_pci_id *pci_id_table = NULL;
+
 	/* now do all data allocation - for eth_dev structure, dummy pci driver
 	 * and internal (private) data
 	 */
@@ -195,26 +209,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 		goto err;
 	}
 
-	eth_drv = rte_zmalloc_socket(name, sizeof(*eth_drv), 0, socket_id);
-	if (eth_drv == NULL) {
-		RTE_BOND_LOG(ERR, "Unable to malloc eth_drv on socket");
-		goto err;
-	}
-
-	pci_drv = &eth_drv->pci_drv;
-
-	pci_id_table = rte_zmalloc_socket(name, sizeof(*pci_id_table), 0, socket_id);
-	if (pci_id_table == NULL) {
-		RTE_BOND_LOG(ERR, "Unable to malloc pci_id_table on socket");
-		goto err;
-	}
-	pci_id_table->device_id = PCI_ANY_ID;
-	pci_id_table->subsystem_device_id = PCI_ANY_ID;
-	pci_id_table->vendor_id = PCI_ANY_ID;
-	pci_id_table->subsystem_vendor_id = PCI_ANY_ID;
-
-	pci_drv->id_table = pci_id_table;
-	pci_drv->drv_flags = RTE_PCI_DRV_INTR_LSC;
+	pci_drv = &rte_bond_pmd.pci_drv;
 
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
 	if (internals == NULL) {
@@ -233,7 +228,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	pci_drv->name = pmd_bond_driver_name;
 	pci_dev->driver = pci_drv;
 
-	eth_dev->driver = eth_drv;
+	eth_dev->driver = &rte_bond_pmd;
 	eth_dev->data->dev_private = internals;
 	eth_dev->data->nb_rx_queues = (uint16_t)1;
 	eth_dev->data->nb_tx_queues = (uint16_t)1;
@@ -289,13 +284,44 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 
 err:
 	rte_free(pci_dev);
-	rte_free(pci_id_table);
-	rte_free(eth_drv);
 	rte_free(internals);
+	rte_free(eth_dev->data->mac_addrs);
 
 	return -1;
 }
 
+int
+rte_eth_bond_free(const char *name)
+{
+	struct rte_eth_dev *eth_dev = NULL;
+
+	/* now free all data allocation - for eth_dev structure,
+	 * dummy pci driver and internal (private) data
+	 */
+
+	/* find an ethdev entry */
+	eth_dev = rte_eth_dev_allocated(name);
+	if (eth_dev == NULL)
+		return -ENODEV;
+
+	if (eth_dev->data->dev_started == 1) {
+		bond_ethdev_stop(eth_dev);
+		bond_ethdev_close(eth_dev);
+	}
+
+	eth_dev->dev_ops = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+
+	rte_free(eth_dev->pci_dev);
+	rte_free(eth_dev->data->dev_private);
+	rte_free(eth_dev->data->mac_addrs);
+
+	rte_eth_dev_release_port(eth_dev);
+
+	return 0;
+}
+
 static int
 __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
 {
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 9cafe65..e1a9e7b 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -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);
diff --git a/drivers/net/bonding/rte_eth_bond_private.h b/drivers/net/bonding/rte_eth_bond_private.h
index c531e87..9f57f4d 100644
--- a/drivers/net/bonding/rte_eth_bond_private.h
+++ b/drivers/net/bonding/rte_eth_bond_private.h
@@ -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
diff --git a/drivers/net/bonding/rte_eth_bond_version.map b/drivers/net/bonding/rte_eth_bond_version.map
index 135999e..5519e11 100644
--- a/drivers/net/bonding/rte_eth_bond_version.map
+++ b/drivers/net/bonding/rte_eth_bond_version.map
@@ -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;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v7 2/4] test-pmd: modified testpmd for link_bonding
  2015-07-27 15:54 ` [dpdk-dev] [PATCH v7 0/4] bonding PCI Port Hotplug Bernard Iremonger
  2015-07-27 15:54   ` [dpdk-dev] [PATCH v7 1/4] bonding: add support for " Bernard Iremonger
@ 2015-07-27 15:54   ` Bernard Iremonger
  2015-07-27 17:15     ` Thomas Monjalon
  2015-07-27 15:54   ` [dpdk-dev] [PATCH v7 3/4] bonding: free queue memory in close function Bernard Iremonger
                     ` (2 subsequent siblings)
  4 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-27 15:54 UTC (permalink / raw)
  To: dev

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.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 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(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 8ab4687..5e24319 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -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 =
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 4769533..4bcece6 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -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,
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index e91e077..8b2219a 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -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);
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v7 3/4] bonding: free queue memory in close function
  2015-07-27 15:54 ` [dpdk-dev] [PATCH v7 0/4] bonding PCI Port Hotplug Bernard Iremonger
  2015-07-27 15:54   ` [dpdk-dev] [PATCH v7 1/4] bonding: add support for " Bernard Iremonger
  2015-07-27 15:54   ` [dpdk-dev] [PATCH v7 2/4] test-pmd: modified testpmd for link_bonding Bernard Iremonger
@ 2015-07-27 15:54   ` Bernard Iremonger
  2015-07-27 15:54   ` [dpdk-dev] [PATCH v7 4/4] testpmd_app_ug: add example of re-attaching bonded port Bernard Iremonger
  2015-07-27 17:38   ` [dpdk-dev] [PATCH v7 0/4] bonding PCI Port Hotplug Thomas Monjalon
  4 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-27 15:54 UTC (permalink / raw)
  To: dev

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

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 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(-)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index e1a9e7b..5cc6372 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -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 */
diff --git a/drivers/net/bonding/rte_eth_bond_private.h b/drivers/net/bonding/rte_eth_bond_private.h
index 9f57f4d..038bca6 100644
--- a/drivers/net/bonding/rte_eth_bond_private.h
+++ b/drivers/net/bonding/rte_eth_bond_private.h
@@ -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
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v7 4/4] testpmd_app_ug: add example of re-attaching bonded port
  2015-07-27 15:54 ` [dpdk-dev] [PATCH v7 0/4] bonding PCI Port Hotplug Bernard Iremonger
                     ` (2 preceding siblings ...)
  2015-07-27 15:54   ` [dpdk-dev] [PATCH v7 3/4] bonding: free queue memory in close function Bernard Iremonger
@ 2015-07-27 15:54   ` Bernard Iremonger
  2015-07-27 17:38   ` [dpdk-dev] [PATCH v7 0/4] bonding PCI Port Hotplug Thomas Monjalon
  4 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-07-27 15:54 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 4652962..5272bf4 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -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
 ~~~~~~~~~~~
 
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v7 1/4] bonding: add support for PCI Port Hotplug
  2015-07-27 15:54   ` [dpdk-dev] [PATCH v7 1/4] bonding: add support for " Bernard Iremonger
@ 2015-07-27 17:14     ` Thomas Monjalon
  0 siblings, 0 replies; 270+ messages in thread
From: Thomas Monjalon @ 2015-07-27 17:14 UTC (permalink / raw)
  To: Bernard Iremonger; +Cc: dev

2015-07-27 16:54, Bernard Iremonger:
> --- a/drivers/net/bonding/rte_eth_bond_version.map
> +++ b/drivers/net/bonding/rte_eth_bond_version.map
> @@ -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.

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v7 2/4] test-pmd: modified testpmd for link_bonding
  2015-07-27 15:54   ` [dpdk-dev] [PATCH v7 2/4] test-pmd: modified testpmd for link_bonding Bernard Iremonger
@ 2015-07-27 17:15     ` Thomas Monjalon
  0 siblings, 0 replies; 270+ messages in thread
From: Thomas Monjalon @ 2015-07-27 17:15 UTC (permalink / raw)
  To: Bernard Iremonger; +Cc: dev

2015-07-27 16:54, Bernard Iremonger:
>         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 */
> 

It doesn't appear to be a desired change.

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v7 0/4] bonding PCI Port Hotplug
  2015-07-27 15:54 ` [dpdk-dev] [PATCH v7 0/4] bonding PCI Port Hotplug Bernard Iremonger
                     ` (3 preceding siblings ...)
  2015-07-27 15:54   ` [dpdk-dev] [PATCH v7 4/4] testpmd_app_ug: add example of re-attaching bonded port Bernard Iremonger
@ 2015-07-27 17:38   ` Thomas Monjalon
  4 siblings, 0 replies; 270+ messages in thread
From: Thomas Monjalon @ 2015-07-27 17:38 UTC (permalink / raw)
  To: Bernard Iremonger; +Cc: dev

2015-07-27 16:54, Bernard Iremonger:
> 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

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH 0/2]  doc: kni command line fixes
  2015-06-10 17:13   ` [dpdk-dev] [PATCH 0/2] doc: kni command line fixes Mcnamara, John
@ 2015-07-27 21:45     ` Thomas Monjalon
  0 siblings, 0 replies; 270+ messages in thread
From: Thomas Monjalon @ 2015-07-27 21:45 UTC (permalink / raw)
  To: Iremonger, Bernard; +Cc: dev

2015-06-10 17:13, Mcnamara, John:
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bernard Iremonger
> > Sent: Wednesday, June 10, 2015 4:13 PM
> > To: dev@dpdk.org
> > Subject: [dpdk-dev] [PATCH 0/2] doc: kni command line fixes
> > 
> > Several kni command lines did not work.
> > The patches below fix the command lines.
> > 
> 
> Series:
> Acked-by: John McNamara <john.mcnamara@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH] doc: update port attach and detach in Testpmd Runtime Functions chapter
  2015-06-16  2:45   ` Tetsuya Mukawa
@ 2015-07-28 10:22     ` Thomas Monjalon
  0 siblings, 0 replies; 270+ messages in thread
From: Thomas Monjalon @ 2015-07-28 10:22 UTC (permalink / raw)
  To: Bernard Iremonger; +Cc: dev

2015-06-16 11:45, Tetsuya Mukawa:
> On 2015/06/11 23:33, Bernard Iremonger wrote:
> > Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> 
> Acked-by: Tetsuya Mukawa <mukawa@igel.co.jp>

Applied, thanks

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 1/1] bonding: fix error handling in rte_eth_bond_create()
       [not found] <PATCH>
                   ` (24 preceding siblings ...)
  2015-07-27 15:54 ` [dpdk-dev] [PATCH v7 0/4] bonding PCI Port Hotplug Bernard Iremonger
@ 2015-08-04 15:26 ` Bernard Iremonger
  2015-08-04 15:52   ` Thomas Monjalon
  2015-08-05 12:36 ` [dpdk-dev] [PATCH v2 " Bernard Iremonger
                   ` (15 subsequent siblings)
  41 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-08-04 15:26 UTC (permalink / raw)
  To: dev

if the name parameter to rte_eth_bond_create() was NULL,
there was a segmentation fault.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/bonding/rte_eth_bond_api.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index 4ca26dd..ffac3c9 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -194,19 +194,19 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 
 	if (name == NULL) {
 		RTE_BOND_LOG(ERR, "Invalid name specified");
-		goto err;
+		goto err1;
 	}
 
 	if (socket_id >= number_of_sockets()) {
 		RTE_BOND_LOG(ERR,
 				"Invalid socket id specified to create bonded device on.");
-		goto err;
+		goto err1;
 	}
 
 	pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, socket_id);
 	if (pci_dev == NULL) {
 		RTE_BOND_LOG(ERR, "Unable to malloc pci dev on socket");
-		goto err;
+		goto err1;
 	}
 
 	pci_drv = &rte_bond_pmd.pci_drv;
@@ -214,14 +214,14 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
 	if (internals == NULL) {
 		RTE_BOND_LOG(ERR, "Unable to malloc internals on socket");
-		goto err;
+		goto err2;
 	}
 
 	/* reserve an ethdev entry */
 	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
 	if (eth_dev == NULL) {
 		RTE_BOND_LOG(ERR, "Unable to allocate rte_eth_dev");
-		goto err;
+		goto err3;
 	}
 
 	pci_dev->numa_node = socket_id;
@@ -239,6 +239,10 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 
 	eth_dev->data->mac_addrs = rte_zmalloc_socket(name, ETHER_ADDR_LEN, 0,
 			socket_id);
+	if (eth_dev->data->mac_addrs == NULL) {
+		RTE_BOND_LOG(ERR, "Unable to malloc mac_addrs");
+		goto err3;
+	}
 
 	eth_dev->data->dev_started = 0;
 	eth_dev->data->promiscuous = 0;
@@ -277,16 +281,18 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	if (bond_ethdev_mode_set(eth_dev, mode)) {
 		RTE_BOND_LOG(ERR, "Failed to set bonded device %d mode too %d",
 				 eth_dev->data->port_id, mode);
-		goto err;
+		goto err4;
 	}
 
 	return eth_dev->data->port_id;
 
-err:
-	rte_free(pci_dev);
-	rte_free(internals);
+err4:
 	rte_free(eth_dev->data->mac_addrs);
-
+err3:
+	rte_free(internals);
+err2:
+	rte_free(pci_dev);
+err1:
 	return -1;
 }
 
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH 1/1] bonding: fix error handling in rte_eth_bond_create()
  2015-08-04 15:26 ` [dpdk-dev] [PATCH 1/1] bonding: fix error handling in rte_eth_bond_create() Bernard Iremonger
@ 2015-08-04 15:52   ` Thomas Monjalon
  2015-08-05 12:28     ` Iremonger, Bernard
  0 siblings, 1 reply; 270+ messages in thread
From: Thomas Monjalon @ 2015-08-04 15:52 UTC (permalink / raw)
  To: Bernard Iremonger; +Cc: dev

2015-08-04 16:26, Bernard Iremonger:
> if the name parameter to rte_eth_bond_create() was NULL,
> there was a segmentation fault.

What is the root cause of the crash?
I guess it is rte_free(eth_dev->data->mac_addrs) because eth_dev is NULL.

[...]
> -err:
> -	rte_free(pci_dev);
> -	rte_free(internals);
> +err4:
>  	rte_free(eth_dev->data->mac_addrs);
> -
> +err3:
> +	rte_free(internals);
> +err2:
> +	rte_free(pci_dev);
> +err1:
>  	return -1;
>  }

rte_free should be harmless with NULL parameter.
It is easier to add "if (eth_dev != NULL)" than maintaining many error labels.

By the way, why rte_eth_dev_release_port() is not called?

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH 1/1] bonding: fix error handling in rte_eth_bond_create()
  2015-08-04 15:52   ` Thomas Monjalon
@ 2015-08-05 12:28     ` Iremonger, Bernard
  0 siblings, 0 replies; 270+ messages in thread
From: Iremonger, Bernard @ 2015-08-05 12:28 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

Hi Thomas,


<snip>
 
> What is the root cause of the crash?
> I guess it is rte_free(eth_dev->data->mac_addrs) because eth_dev is NULL.

Yes, that is the roor cause.

> 
> [...]
> > -err:
> > -	rte_free(pci_dev);
> > -	rte_free(internals);
> > +err4:
> >  	rte_free(eth_dev->data->mac_addrs);
> > -
> > +err3:
> > +	rte_free(internals);
> > +err2:
> > +	rte_free(pci_dev);
> > +err1:
> >  	return -1;
> >  }
> 
> rte_free should be harmless with NULL parameter.
> It is easier to add "if (eth_dev != NULL)" than maintaining many error labels.

I will revise patch to remove multible error labels.

> 
> By the way, why rte_eth_dev_release_port() is not called?
I will add a call to rte_eth_dev_release_port().

Regards,

Bernard.

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v2 1/1] bonding: fix error handling in rte_eth_bond_create()
       [not found] <PATCH>
                   ` (25 preceding siblings ...)
  2015-08-04 15:26 ` [dpdk-dev] [PATCH 1/1] bonding: fix error handling in rte_eth_bond_create() Bernard Iremonger
@ 2015-08-05 12:36 ` Bernard Iremonger
  2015-08-05 12:48   ` Liu, Yong
  2015-08-05 13:15   ` Thomas Monjalon
  2015-08-05 14:04 ` [dpdk-dev] [PATCH v3 1/1] bonding: fix device initialisation error handling Bernard Iremonger
                   ` (14 subsequent siblings)
  41 siblings, 2 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-08-05 12:36 UTC (permalink / raw)
  To: dev

if the name parameter to rte_eth_bond_create() was NULL,
there was a segmentation fault because eth_dev was also NULL.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/bonding/rte_eth_bond_api.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index 4ca26dd..0681d1a 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -239,6 +239,10 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 
 	eth_dev->data->mac_addrs = rte_zmalloc_socket(name, ETHER_ADDR_LEN, 0,
 			socket_id);
+	if (eth_dev->data->mac_addrs == NULL) {
+		RTE_BOND_LOG(ERR, "Unable to malloc mac_addrs");
+		goto err;
+	}
 
 	eth_dev->data->dev_started = 0;
 	eth_dev->data->promiscuous = 0;
@@ -285,8 +289,10 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 err:
 	rte_free(pci_dev);
 	rte_free(internals);
-	rte_free(eth_dev->data->mac_addrs);
-
+	if (eth_dev != NULL) {
+		rte_free(eth_dev->data->mac_addrs);
+		rte_eth_dev_release_port(eth_dev);
+	}
 	return -1;
 }
 
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v2 1/1] bonding: fix error handling in rte_eth_bond_create()
  2015-08-05 12:36 ` [dpdk-dev] [PATCH v2 " Bernard Iremonger
@ 2015-08-05 12:48   ` Liu, Yong
  2015-08-05 13:15   ` Thomas Monjalon
  1 sibling, 0 replies; 270+ messages in thread
From: Liu, Yong @ 2015-08-05 12:48 UTC (permalink / raw)
  To: Iremonger, Bernard, dev

Tested-by: Marvin Liu <yong.liu@intel.com>

> -----Original Message-----
> From: Iremonger, Bernard
> Sent: Wednesday, August 05, 2015 8:37 PM
> To: dev@dpdk.org
> Cc: Jastrzebski, MichalX K; Liu, Yong; Iremonger, Bernard
> Subject: [PATCH v2 1/1] bonding: fix error handling in
> rte_eth_bond_create()
> 
> if the name parameter to rte_eth_bond_create() was NULL,
> there was a segmentation fault because eth_dev was also NULL.
> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> ---
>  drivers/net/bonding/rte_eth_bond_api.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/bonding/rte_eth_bond_api.c
> b/drivers/net/bonding/rte_eth_bond_api.c
> index 4ca26dd..0681d1a 100644
> --- a/drivers/net/bonding/rte_eth_bond_api.c
> +++ b/drivers/net/bonding/rte_eth_bond_api.c
> @@ -239,6 +239,10 @@ rte_eth_bond_create(const char *name, uint8_t mode,
> uint8_t socket_id)
> 
>  	eth_dev->data->mac_addrs = rte_zmalloc_socket(name, ETHER_ADDR_LEN,
> 0,
>  			socket_id);
> +	if (eth_dev->data->mac_addrs == NULL) {
> +		RTE_BOND_LOG(ERR, "Unable to malloc mac_addrs");
> +		goto err;
> +	}
> 
>  	eth_dev->data->dev_started = 0;
>  	eth_dev->data->promiscuous = 0;
> @@ -285,8 +289,10 @@ rte_eth_bond_create(const char *name, uint8_t mode,
> uint8_t socket_id)
>  err:
>  	rte_free(pci_dev);
>  	rte_free(internals);
> -	rte_free(eth_dev->data->mac_addrs);
> -
> +	if (eth_dev != NULL) {
> +		rte_free(eth_dev->data->mac_addrs);
> +		rte_eth_dev_release_port(eth_dev);
> +	}
>  	return -1;
>  }
> 
> --
> 1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v2 1/1] bonding: fix error handling in rte_eth_bond_create()
  2015-08-05 12:36 ` [dpdk-dev] [PATCH v2 " Bernard Iremonger
  2015-08-05 12:48   ` Liu, Yong
@ 2015-08-05 13:15   ` Thomas Monjalon
  2015-08-05 13:19     ` Iremonger, Bernard
  1 sibling, 1 reply; 270+ messages in thread
From: Thomas Monjalon @ 2015-08-05 13:15 UTC (permalink / raw)
  To: Bernard Iremonger; +Cc: dev

2015-08-05 13:36, Bernard Iremonger:
> if the name parameter to rte_eth_bond_create() was NULL,
> there was a segmentation fault because eth_dev was also NULL.

You also add error handling of mac_addrs alloc and release_port().
It deserves to be said in this commit message.

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v2 1/1] bonding: fix error handling in rte_eth_bond_create()
  2015-08-05 13:15   ` Thomas Monjalon
@ 2015-08-05 13:19     ` Iremonger, Bernard
  2015-08-05 13:35       ` Thomas Monjalon
  0 siblings, 1 reply; 270+ messages in thread
From: Iremonger, Bernard @ 2015-08-05 13:19 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

Hi Thomas,

> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Wednesday, August 5, 2015 2:16 PM
> To: Iremonger, Bernard
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v2 1/1] bonding: fix error handling in
> rte_eth_bond_create()
> 
> 2015-08-05 13:36, Bernard Iremonger:
> > if the name parameter to rte_eth_bond_create() was NULL, there was a
> > segmentation fault because eth_dev was also NULL.
> 
> You also add error handling of mac_addrs alloc and release_port().
> It deserves to be said in this commit message.

Will I send a v3 patch ?

Regards,

Bernard.

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v2 1/1] bonding: fix error handling in rte_eth_bond_create()
  2015-08-05 13:19     ` Iremonger, Bernard
@ 2015-08-05 13:35       ` Thomas Monjalon
  2015-08-05 13:39         ` Iremonger, Bernard
  0 siblings, 1 reply; 270+ messages in thread
From: Thomas Monjalon @ 2015-08-05 13:35 UTC (permalink / raw)
  To: Iremonger, Bernard; +Cc: dev

2015-08-05 13:19, Iremonger, Bernard:
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > 2015-08-05 13:36, Bernard Iremonger:
> > > if the name parameter to rte_eth_bond_create() was NULL, there was a
> > > segmentation fault because eth_dev was also NULL.
> > 
> > You also add error handling of mac_addrs alloc and release_port().
> > It deserves to be said in this commit message.
> 
> Will I send a v3 patch ?

My comment was mostly to show which kind of information may be useful.
Sometimes I write it myself. You are welcome to write it in order I add it
or you can send a v3.

Other note: the function names are avoided in commit titles as they are
redundant with the title prefix and not so easy to read.
The title could be
	bonding: fix crash on initialization error
or, to include other fixes,
	bonding: fix device initialization error handling

Thanks

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v2 1/1] bonding: fix error handling in rte_eth_bond_create()
  2015-08-05 13:35       ` Thomas Monjalon
@ 2015-08-05 13:39         ` Iremonger, Bernard
  0 siblings, 0 replies; 270+ messages in thread
From: Iremonger, Bernard @ 2015-08-05 13:39 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

Hi Thomas,

> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Wednesday, August 5, 2015 2:35 PM
> To: Iremonger, Bernard
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v2 1/1] bonding: fix error handling in
> rte_eth_bond_create()
> 
> 2015-08-05 13:19, Iremonger, Bernard:
> > From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > > 2015-08-05 13:36, Bernard Iremonger:
> > > > if the name parameter to rte_eth_bond_create() was NULL, there was
> > > > a segmentation fault because eth_dev was also NULL.
> > >
> > > You also add error handling of mac_addrs alloc and release_port().
> > > It deserves to be said in this commit message.
> >
> > Will I send a v3 patch ?
> 
> My comment was mostly to show which kind of information may be useful.
> Sometimes I write it myself. You are welcome to write it in order I add it or
> you can send a v3.
> 
> Other note: the function names are avoided in commit titles as they are
> redundant with the title prefix and not so easy to read.
> The title could be
> 	bonding: fix crash on initialization error or, to include other fixes,
> 	bonding: fix device initialization error handling
> 
> Thanks

I will send a v3.

Regards,

Bernard.

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 1/1] bonding: fix device initialisation error handling
       [not found] <PATCH>
                   ` (26 preceding siblings ...)
  2015-08-05 12:36 ` [dpdk-dev] [PATCH v2 " Bernard Iremonger
@ 2015-08-05 14:04 ` Bernard Iremonger
  2015-08-06  8:19   ` Jastrzebski, MichalX K
  2015-09-28 13:03 ` [dpdk-dev] [PATCH 00/20] remove pci driver from vdevs Bernard Iremonger
                   ` (13 subsequent siblings)
  41 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-08-05 14:04 UTC (permalink / raw)
  To: dev

If the name parameter to rte_eth_bond_create() was NULL,
there was a segmentation fault because eth_dev was also NULL.
Add error handling of mac_addrs memory allocation.
Add call to rte_eth_dev_release_port() in error handling.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/bonding/rte_eth_bond_api.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index 4ca26dd..0681d1a 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -239,6 +239,10 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 
 	eth_dev->data->mac_addrs = rte_zmalloc_socket(name, ETHER_ADDR_LEN, 0,
 			socket_id);
+	if (eth_dev->data->mac_addrs == NULL) {
+		RTE_BOND_LOG(ERR, "Unable to malloc mac_addrs");
+		goto err;
+	}
 
 	eth_dev->data->dev_started = 0;
 	eth_dev->data->promiscuous = 0;
@@ -285,8 +289,10 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 err:
 	rte_free(pci_dev);
 	rte_free(internals);
-	rte_free(eth_dev->data->mac_addrs);
-
+	if (eth_dev != NULL) {
+		rte_free(eth_dev->data->mac_addrs);
+		rte_eth_dev_release_port(eth_dev);
+	}
 	return -1;
 }
 
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/1] bonding: fix device initialisation error handling
  2015-08-05 14:04 ` [dpdk-dev] [PATCH v3 1/1] bonding: fix device initialisation error handling Bernard Iremonger
@ 2015-08-06  8:19   ` Jastrzebski, MichalX K
  2015-08-10  0:06     ` Thomas Monjalon
  0 siblings, 1 reply; 270+ messages in thread
From: Jastrzebski, MichalX K @ 2015-08-06  8:19 UTC (permalink / raw)
  To: dev

> -----Original Message-----
> From: Iremonger, Bernard
> Sent: Wednesday, August 05, 2015 4:04 PM
> To: dev@dpdk.org
> Cc: Jastrzebski, MichalX K; Liu, Yong; Iremonger, Bernard
> Subject: [PATCH v3 1/1] bonding: fix device initialisation error handling
> 
> If the name parameter to rte_eth_bond_create() was NULL,
> there was a segmentation fault because eth_dev was also NULL.
> Add error handling of mac_addrs memory allocation.
> Add call to rte_eth_dev_release_port() in error handling.
> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
Acked-by: Michal Jastrzebski <michalx.k.jastrzebski@intel.com>

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/1] bonding: fix device initialisation error handling
  2015-08-06  8:19   ` Jastrzebski, MichalX K
@ 2015-08-10  0:06     ` Thomas Monjalon
  0 siblings, 0 replies; 270+ messages in thread
From: Thomas Monjalon @ 2015-08-10  0:06 UTC (permalink / raw)
  To: Jastrzebski, MichalX K; +Cc: dev

> > If the name parameter to rte_eth_bond_create() was NULL,
> > there was a segmentation fault because eth_dev was also NULL.
> > Add error handling of mac_addrs memory allocation.
> > Add call to rte_eth_dev_release_port() in error handling.
> > 
> > Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> Acked-by: Michal Jastrzebski <michalx.k.jastrzebski@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 00/20] remove pci driver from vdevs
       [not found] <PATCH>
                   ` (27 preceding siblings ...)
  2015-08-05 14:04 ` [dpdk-dev] [PATCH v3 1/1] bonding: fix device initialisation error handling Bernard Iremonger
@ 2015-09-28 13:03 ` Bernard Iremonger
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 01/20] librte_eal: add RTE_KDRV_NONE for vdevs Bernard Iremonger
                     ` (19 more replies)
  2015-10-01 15:16 ` [dpdk-dev] [PATCH 0/1] vmxnet3 hotplug support Bernard Iremonger
                   ` (12 subsequent siblings)
  41 siblings, 20 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-09-28 13:03 UTC (permalink / raw)
  To: dev

There is a dummy pci driver in the vdev PMD's at present.
This patch set removes the pci driver from the vdev PMD's.
Changes have been made to librte_ether to handle vdevs and pdevs in the same way.

The following vdev PMD's have had the pci driver removed:

null
ring
bonding
pcap
af_packet
xenvirt
mpipe

All the pdev PMD's have been modified to copy the pci device info into ethdev data.

Bernard Iremonger (17):
  librte_eal: add RTE_KDRV_NONE for vdevs
  librte_ether: add fields from rte_pci_driver to rte_eth_dev_data
  librte_ether: add function rte_eth_copy_dev_info()
  null: remove pci device driver
  ring: remove pci device driver
  bonding: remove pci device driver
  pcap: remove pci device driver
  ixgbe: copy pci device info to eth_dev data
  e1000: copy pci device info to eth_dev data
  i40e: copy pci device info to eth_dev data
  fm10k: copy pci device info to eth_dev data
  bnx2x: copy pci device info to eth_dev data
  cxgbe: copy pci device info to eth_dev data
  enic: copy pci device info to eth_dev data
  mlx4: copy pci device info to eth_dev data
  virtio: copy pci device info to eth_dev data
  vmxnet3: copy pci device info to eth_dev data

David Hunt (3):
  af_packet: remove pci device driver
  xenvirt: remove pci device driver
  mpipe: remove pci device driver

 drivers/net/af_packet/rte_eth_af_packet.c  | 20 +++++------
 drivers/net/bnx2x/bnx2x_ethdev.c           |  4 +++
 drivers/net/bonding/rte_eth_bond_alb.c     |  2 +-
 drivers/net/bonding/rte_eth_bond_api.c     | 58 +++++++++---------------------
 drivers/net/bonding/rte_eth_bond_pmd.c     | 16 ++++-----
 drivers/net/bonding/rte_eth_bond_private.h |  2 +-
 drivers/net/cxgbe/cxgbe_ethdev.c           |  5 +++
 drivers/net/e1000/em_ethdev.c              |  3 ++
 drivers/net/e1000/igb_ethdev.c             |  5 +++
 drivers/net/enic/enic_ethdev.c             |  2 ++
 drivers/net/fm10k/fm10k_ethdev.c           |  2 ++
 drivers/net/i40e/i40e_ethdev.c             |  3 ++
 drivers/net/i40e/i40e_ethdev_vf.c          |  2 ++
 drivers/net/ixgbe/ixgbe_ethdev.c           |  4 +++
 drivers/net/mlx4/mlx4.c                    |  4 +++
 drivers/net/mpipe/mpipe_tilegx.c           | 10 ++++--
 drivers/net/null/rte_eth_null.c            | 32 +++++------------
 drivers/net/pcap/rte_eth_pcap.c            | 31 +++++-----------
 drivers/net/ring/rte_eth_ring.c            | 37 +++++--------------
 drivers/net/virtio/virtio_ethdev.c         |  3 ++
 drivers/net/vmxnet3/vmxnet3_ethdev.c       |  2 ++
 drivers/net/xenvirt/rte_eth_xenvirt.c      | 14 +++-----
 lib/librte_eal/common/include/rte_pci.h    |  3 +-
 lib/librte_ether/rte_ethdev.c              | 54 ++++++++++++++++------------
 lib/librte_ether/rte_ethdev.h              | 29 +++++++++++++++
 lib/librte_ether/rte_ether_version.map     |  7 ++++
 26 files changed, 180 insertions(+), 174 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 01/20] librte_eal: add RTE_KDRV_NONE for vdevs
  2015-09-28 13:03 ` [dpdk-dev] [PATCH 00/20] remove pci driver from vdevs Bernard Iremonger
@ 2015-09-28 13:03   ` Bernard Iremonger
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 02/20] librte_ether: add fields from rte_pci_driver to rte_eth_dev_data Bernard Iremonger
                     ` (18 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-09-28 13:03 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 lib/librte_eal/common/include/rte_pci.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index 83e3c28..334c12e 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -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
@@ -149,6 +149,7 @@ enum rte_kernel_driver {
 	RTE_KDRV_VFIO,
 	RTE_KDRV_UIO_GENERIC,
 	RTE_KDRV_NIC_UIO,
+	RTE_KDRV_NONE,
 };
 
 /**
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 02/20] librte_ether: add fields from rte_pci_driver to rte_eth_dev_data
  2015-09-28 13:03 ` [dpdk-dev] [PATCH 00/20] remove pci driver from vdevs Bernard Iremonger
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 01/20] librte_eal: add RTE_KDRV_NONE for vdevs Bernard Iremonger
@ 2015-09-28 13:03   ` Bernard Iremonger
  2015-09-29 19:08     ` Neil Horman
  2015-09-30 13:18     ` Neil Horman
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 03/20] librte_ether: add function rte_eth_copy_dev_info() Bernard Iremonger
                     ` (17 subsequent siblings)
  19 siblings, 2 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-09-28 13:03 UTC (permalink / raw)
  To: dev

add dev_flags to rte_eth_dev_data, add macros for dev_flags.
add kdrv to rte_eth_dev_data.
add numa_node to rte_eth_dev_data.
add drv_name to rte_eth_dev_data.
use dev_type to distinguish between vdev's and pdev's.
remove pci_dev branches.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 53 ++++++++++++++++++++++++-------------------
 lib/librte_ether/rte_ethdev.h | 15 ++++++++++++
 2 files changed, 45 insertions(+), 23 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index b309309..e4cb285 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -424,7 +424,7 @@ rte_eth_dev_socket_id(uint8_t port_id)
 {
 	if (!rte_eth_dev_is_valid_port(port_id))
 		return -1;
-	return rte_eth_devices[port_id].pci_dev->numa_node;
+	return rte_eth_devices[port_id].data->numa_node;
 }
 
 uint8_t
@@ -503,27 +503,25 @@ rte_eth_dev_get_name_by_port(uint8_t port_id, char *name)
 static int
 rte_eth_dev_is_detachable(uint8_t port_id)
 {
-	uint32_t drv_flags;
+	uint32_t dev_flags;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
 		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -EINVAL;
 	}
 
-	if (rte_eth_devices[port_id].dev_type == RTE_ETH_DEV_PCI) {
-		switch (rte_eth_devices[port_id].pci_dev->kdrv) {
-		case RTE_KDRV_IGB_UIO:
-		case RTE_KDRV_UIO_GENERIC:
-		case RTE_KDRV_NIC_UIO:
-			break;
-		case RTE_KDRV_VFIO:
-		default:
-			return -ENOTSUP;
-		}
+	switch (rte_eth_devices[port_id].data->kdrv) {
+	case RTE_KDRV_IGB_UIO:
+	case RTE_KDRV_UIO_GENERIC:
+	case RTE_KDRV_NIC_UIO:
+	case RTE_KDRV_NONE:
+		break;
+	case RTE_KDRV_VFIO:
+	default:
+		return -ENOTSUP;
 	}
-
-	drv_flags = rte_eth_devices[port_id].driver->pci_drv.drv_flags;
-	return !(drv_flags & RTE_PCI_DRV_DETACHABLE);
+	dev_flags = rte_eth_devices[port_id].data->dev_flags;
+	return !(dev_flags & RTE_ETH_DEV_DETACHABLE);
 }
 
 /* attach the new physical device, then store port_id of the device */
@@ -1143,14 +1141,11 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	 * If link state interrupt is enabled, check that the
 	 * device supports it.
 	 */
-	if (dev_conf->intr_conf.lsc == 1) {
-		const struct rte_pci_driver *pci_drv = &dev->driver->pci_drv;
-
-		if (!(pci_drv->drv_flags & RTE_PCI_DRV_INTR_LSC)) {
+	if ((dev_conf->intr_conf.lsc == 1) &&
+		(!(dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC))) {
 			PMD_DEBUG_TRACE("driver %s does not support lsc\n",
-					pci_drv->name);
+					dev->data->drv_name);
 			return -EINVAL;
-		}
 	}
 
 	/*
@@ -1795,8 +1790,7 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 	FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
 	(*dev->dev_ops->dev_infos_get)(dev, dev_info);
 	dev_info->pci_dev = dev->pci_dev;
-	if (dev->driver)
-		dev_info->driver_name = dev->driver->pci_drv.name;
+	dev_info->driver_name = dev->data->drv_name;
 }
 
 void
@@ -3570,3 +3564,16 @@ rte_eth_dev_set_eeprom(uint8_t port_id, struct rte_dev_eeprom_info *info)
 	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_eeprom, -ENOTSUP);
 	return (*dev->dev_ops->set_eeprom)(dev, info);
 }
+
+void
+rte_eth_copy_dev_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_dev)
+{
+	if ((eth_dev == NULL) || (pci_dev == NULL))
+		PMD_DEBUG_TRACE("NULL pointer eth_dev=%p pci_dev=%p\n",
+				eth_dev, pci_dev);
+
+	eth_dev->data->dev_flags = pci_dev->driver->drv_flags;
+	eth_dev->data->kdrv = pci_dev->kdrv;
+	eth_dev->data->numa_node = pci_dev->numa_node;
+	eth_dev->data->drv_name = pci_dev->driver->name;
+}
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index fa06554..9cd262b 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1635,8 +1635,23 @@ struct rte_eth_dev_data {
 		all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
 		dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
 		lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
+	uint32_t dev_flags; /**< Flags controlling handling of device. */
+	enum rte_kernel_driver kdrv;	/**< Kernel driver passthrough */
+	int numa_node;
+	const char *drv_name;
 };
 
+/** Device needs PCI BAR mapping (done with either IGB_UIO or VFIO) */
+#define RTE_ETH_DEV_DRV_NEED_MAPPING	RTE_PCI_DRV_NEED_MAPPING
+/** Device needs to be unbound even if no module is provided */
+#define RTE_ETH_DEV_DRV_FORCE_UNBIND	RTE_PCI_DRV_FORCE_UNBIND
+/** Device supports link state interrupt */
+#define RTE_ETH_DEV_INTR_LSC	RTE_PCI_DRV_INTR_LSC
+/** Device  supports detaching capability */
+#define RTE_ETH_DEV_DETACHABLE	RTE_PCI_DRV_DETACHABLE
+/** Device  is a bonded device */
+#define RTE_ETH_DEV_BONDED	0x0020
+
 /**
  * @internal
  * The pool of *rte_eth_dev* structures. The size of the pool
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 03/20] librte_ether: add function rte_eth_copy_dev_info()
  2015-09-28 13:03 ` [dpdk-dev] [PATCH 00/20] remove pci driver from vdevs Bernard Iremonger
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 01/20] librte_eal: add RTE_KDRV_NONE for vdevs Bernard Iremonger
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 02/20] librte_ether: add fields from rte_pci_driver to rte_eth_dev_data Bernard Iremonger
@ 2015-09-28 13:03   ` Bernard Iremonger
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 04/20] null: remove pci device driver Bernard Iremonger
                     ` (16 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-09-28 13:03 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 lib/librte_ether/rte_ethdev.c          |  1 +
 lib/librte_ether/rte_ethdev.h          | 14 ++++++++++++++
 lib/librte_ether/rte_ether_version.map |  7 +++++++
 3 files changed, 22 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index e4cb285..7fa0c01 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3576,4 +3576,5 @@ rte_eth_copy_dev_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_de
 	eth_dev->data->kdrv = pci_dev->kdrv;
 	eth_dev->data->numa_node = pci_dev->numa_node;
 	eth_dev->data->drv_name = pci_dev->driver->name;
+
 }
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 9cd262b..e335a94 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -3993,6 +3993,20 @@ extern int rte_eth_timesync_read_rx_timestamp(uint8_t port_id,
 extern int rte_eth_timesync_read_tx_timestamp(uint8_t port_id,
 					      struct timespec *timestamp);
 
+/**
+ * Copy pci device info to the Ethernet device data.
+ *
+ * @param eth_dev
+ * The *eth_dev* pointer is the address of the *rte_eth_dev* structure.
+ * @param pci_dev
+ * The *pci_dev* pointer is the address of the *rte_pci_device* structure.
+ *
+ * @return
+ *   - 0 on success, negative on error
+ */
+extern void rte_eth_copy_dev_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_dev);
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index 8345a6c..e6a43be 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -127,3 +127,10 @@ DPDK_2.1 {
 	rte_eth_timesync_read_tx_timestamp;
 
 } DPDK_2.0;
+
+DPDK_2.2 {
+	global:
+
+	rte_eth_copy_dev_info;
+
+} DPDK_2.1;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 04/20] null: remove pci device driver
  2015-09-28 13:03 ` [dpdk-dev] [PATCH 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (2 preceding siblings ...)
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 03/20] librte_ether: add function rte_eth_copy_dev_info() Bernard Iremonger
@ 2015-09-28 13:03   ` Bernard Iremonger
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 05/20] ring: " Bernard Iremonger
                     ` (15 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-09-28 13:03 UTC (permalink / raw)
  To: dev

remove rte_null_pmd and pci_dev.
initialise dev_flags, driver, drv_name, kdrv and numa_node fields in eth_dev data

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/null/rte_eth_null.c | 32 +++++++++-----------------------
 1 file changed, 9 insertions(+), 23 deletions(-)

diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index e244595..d6a59e6 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -1,8 +1,8 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright (C) IGEL Co.,Ltd.
- *   All rights reserved.
+ *   Copyright (C) IGEL Co.,Ltd. All rights reserved.
+ *   Copyright(c) 2015 Intel Corporation. All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
  *   modification, are permitted provided that the following conditions
@@ -340,13 +340,6 @@ eth_stats_reset(struct rte_eth_dev *dev)
 	}
 }
 
-static struct eth_driver rte_null_pmd = {
-	.pci_drv = {
-		.name = "rte_null_pmd",
-		.drv_flags = RTE_PCI_DRV_DETACHABLE,
-	},
-};
-
 static void
 eth_queue_release(void *q)
 {
@@ -386,7 +379,6 @@ eth_dev_null_create(const char *name,
 	const unsigned nb_rx_queues = 1;
 	const unsigned nb_tx_queues = 1;
 	struct rte_eth_dev_data *data = NULL;
-	struct rte_pci_device *pci_dev = NULL;
 	struct pmd_internals *internals = NULL;
 	struct rte_eth_dev *eth_dev = NULL;
 
@@ -403,10 +395,6 @@ eth_dev_null_create(const char *name,
 	if (data == NULL)
 		goto error;
 
-	pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, numa_node);
-	if (pci_dev == NULL)
-		goto error;
-
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, numa_node);
 	if (internals == NULL)
 		goto error;
@@ -418,8 +406,7 @@ eth_dev_null_create(const char *name,
 
 	/* now put it all together
 	 * - store queue data in internals,
-	 * - store numa_node info in pci_driver
-	 * - point eth_dev_data to internals and pci_driver
+	 * - point eth_dev_data to internals
 	 * - and point eth_dev structure to new eth_dev_data structure
 	 */
 	/* NOTE: we'll replace the data element, of originally allocated eth_dev
@@ -431,8 +418,6 @@ eth_dev_null_create(const char *name,
 	internals->packet_copy = packet_copy;
 	internals->numa_node = numa_node;
 
-	pci_dev->numa_node = numa_node;
-
 	data->dev_private = internals;
 	data->port_id = eth_dev->data->port_id;
 	data->nb_rx_queues = (uint16_t)nb_rx_queues;
@@ -443,8 +428,11 @@ eth_dev_null_create(const char *name,
 
 	eth_dev->data = data;
 	eth_dev->dev_ops = &ops;
-	eth_dev->pci_dev = pci_dev;
-	eth_dev->driver = &rte_null_pmd;
+	eth_dev->driver = NULL;
+	eth_dev->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
+	eth_dev->data->kdrv = RTE_KDRV_NONE;
+	eth_dev->data->drv_name = NULL;
+	eth_dev->data->numa_node = numa_node;
 
 	/* finally assign rx and tx ops */
 	if (packet_copy) {
@@ -459,7 +447,6 @@ eth_dev_null_create(const char *name,
 
 error:
 	rte_free(data);
-	rte_free(pci_dev);
 	rte_free(internals);
 
 	return -1;
@@ -562,14 +549,13 @@ rte_pmd_null_devuninit(const char *name)
 	RTE_LOG(INFO, PMD, "Closing null ethdev on numa socket %u\n",
 			rte_socket_id());
 
-	/* reserve an ethdev entry */
+	/* find the ethdev entry */
 	eth_dev = rte_eth_dev_allocated(name);
 	if (eth_dev == NULL)
 		return -1;
 
 	rte_free(eth_dev->data->dev_private);
 	rte_free(eth_dev->data);
-	rte_free(eth_dev->pci_dev);
 
 	rte_eth_dev_release_port(eth_dev);
 
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 05/20] ring: remove pci device driver
  2015-09-28 13:03 ` [dpdk-dev] [PATCH 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (3 preceding siblings ...)
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 04/20] null: remove pci device driver Bernard Iremonger
@ 2015-09-28 13:03   ` Bernard Iremonger
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 06/20] bonding: " Bernard Iremonger
                     ` (14 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-09-28 13:03 UTC (permalink / raw)
  To: dev

remove rte_ring_pmd and pci_dev.
initialise dev_flags, driver, drv_name, kdrv and numa_node fields in eth_dev data.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/ring/rte_eth_ring.c | 37 ++++++++-----------------------------
 1 file changed, 8 insertions(+), 29 deletions(-)

diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index 0ba36d5..65608b2 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -44,8 +44,6 @@
 #define ETH_RING_ACTION_CREATE		"CREATE"
 #define ETH_RING_ACTION_ATTACH		"ATTACH"
 
-static const char *ring_ethdev_driver_name = "Ring PMD";
-
 static const char *valid_arguments[] = {
 	ETH_RING_NUMA_NODE_ACTION_ARG,
 	NULL
@@ -252,15 +250,6 @@ static const struct eth_dev_ops ops = {
 	.mac_addr_add = eth_mac_addr_add,
 };
 
-static struct eth_driver rte_ring_pmd = {
-	.pci_drv = {
-		.name = "rte_ring_pmd",
-		.drv_flags = RTE_PCI_DRV_DETACHABLE,
-	},
-};
-
-static struct rte_pci_id id_table;
-
 int
 rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 		const unsigned nb_rx_queues,
@@ -269,7 +258,6 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 		const unsigned numa_node)
 {
 	struct rte_eth_dev_data *data = NULL;
-	struct rte_pci_device *pci_dev = NULL;
 	struct pmd_internals *internals = NULL;
 	struct rte_eth_dev *eth_dev = NULL;
 
@@ -291,10 +279,6 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 	if (data == NULL)
 		goto error;
 
-	pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, numa_node);
-	if (pci_dev == NULL)
-		goto error;
-
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, numa_node);
 	if (internals == NULL)
 		goto error;
@@ -304,11 +288,10 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 	if (eth_dev == NULL)
 		goto error;
 
-
 	/* now put it all together
 	 * - store queue data in internals,
-	 * - store numa_node info in pci_driver
-	 * - point eth_dev_data to internals and pci_driver
+	 * - store numa_node info in eth_dev_data
+	 * - point eth_dev_data to internals
 	 * - and point eth_dev structure to new eth_dev_data structure
 	 */
 	/* NOTE: we'll replace the data element, of originally allocated eth_dev
@@ -323,12 +306,6 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 		internals->tx_ring_queues[i].rng = tx_queues[i];
 	}
 
-	rte_ring_pmd.pci_drv.name = ring_ethdev_driver_name;
-	rte_ring_pmd.pci_drv.id_table = &id_table;
-
-	pci_dev->numa_node = numa_node;
-	pci_dev->driver = &rte_ring_pmd.pci_drv;
-
 	data->dev_private = internals;
 	data->port_id = eth_dev->data->port_id;
 	memmove(data->name, eth_dev->data->name, sizeof(data->name));
@@ -338,9 +315,13 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 	data->mac_addrs = &internals->address;
 
 	eth_dev->data = data;
-	eth_dev->driver = &rte_ring_pmd;
+	eth_dev->driver = NULL;
 	eth_dev->dev_ops = &ops;
-	eth_dev->pci_dev = pci_dev;
+	eth_dev->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
+	eth_dev->data->kdrv = RTE_KDRV_NONE;
+	eth_dev->data->drv_name = NULL;
+	eth_dev->data->numa_node = numa_node;
+
 	TAILQ_INIT(&(eth_dev->link_intr_cbs));
 
 	/* finally assign rx and tx ops */
@@ -351,7 +332,6 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 
 error:
 	rte_free(data);
-	rte_free(pci_dev);
 	rte_free(internals);
 
 	return -1;
@@ -561,7 +541,6 @@ rte_pmd_ring_devuninit(const char *name)
 	eth_dev_stop(eth_dev);
 	rte_free(eth_dev->data->dev_private);
 	rte_free(eth_dev->data);
-	rte_free(eth_dev->pci_dev);
 
 	rte_eth_dev_release_port(eth_dev);
 	return 0;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 06/20] bonding: remove pci device driver
  2015-09-28 13:03 ` [dpdk-dev] [PATCH 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (4 preceding siblings ...)
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 05/20] ring: " Bernard Iremonger
@ 2015-09-28 13:03   ` Bernard Iremonger
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 07/20] pcap: " Bernard Iremonger
                     ` (13 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-09-28 13:03 UTC (permalink / raw)
  To: dev

remove pci_dev, pci_drv, rte_bond_pmd and pci_id_table.
initialise dev_flags, kdrv, driver, drv_name and numa_node fields in eth_dev data.
handle numa_node for vdevs
handle RTE_ETH_DEV_INTR_LSC for vdevs
rename valid_bonded_device to check_for_bonded_device

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/bonding/rte_eth_bond_alb.c     |  2 +-
 drivers/net/bonding/rte_eth_bond_api.c     | 58 +++++++++---------------------
 drivers/net/bonding/rte_eth_bond_pmd.c     | 16 ++++-----
 drivers/net/bonding/rte_eth_bond_private.h |  2 +-
 4 files changed, 26 insertions(+), 52 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_alb.c b/drivers/net/bonding/rte_eth_bond_alb.c
index 6df318e..3157543 100644
--- a/drivers/net/bonding/rte_eth_bond_alb.c
+++ b/drivers/net/bonding/rte_eth_bond_alb.c
@@ -65,7 +65,7 @@ bond_mode_alb_enable(struct rte_eth_dev *bond_dev)
 
 	uint16_t data_size;
 	char mem_name[RTE_ETH_NAME_MAX_LEN];
-	int socket_id = bond_dev->pci_dev->numa_node;
+	int socket_id = bond_dev->data->numa_node;
 
 	/* Fill hash table with initial values */
 	memset(hash_table, 0, sizeof(struct client_data) * ALB_HASH_TABLE_SIZE);
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index 0681d1a..55f028f 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -45,14 +45,17 @@
 #define DEFAULT_POLLING_INTERVAL_10_MS (10)
 
 int
-valid_bonded_ethdev(const struct rte_eth_dev *eth_dev)
+check_for_bonded_ethdev(const struct rte_eth_dev *eth_dev)
 {
 	/* Check valid pointer */
-	if (eth_dev->driver->pci_drv.name == NULL)
+	if (!eth_dev)
 		return -1;
 
-	/* return 0 if driver name matches */
-	return eth_dev->driver->pci_drv.name != pmd_bond_driver_name;
+	/* return 0 if bonded device */
+	if (eth_dev->data->dev_flags & RTE_ETH_DEV_BONDED)
+		return 0;
+	else
+		return 1;
 }
 
 int
@@ -61,7 +64,7 @@ valid_bonded_port_id(uint8_t port_id)
 	if (!rte_eth_dev_is_valid_port(port_id))
 		return -1;
 
-	return valid_bonded_ethdev(&rte_eth_devices[port_id]);
+	return check_for_bonded_ethdev(&rte_eth_devices[port_id]);
 }
 
 int
@@ -72,7 +75,7 @@ valid_slave_port_id(uint8_t port_id)
 		return -1;
 
 	/* Verify that port_id refers to a non bonded port */
-	if (!valid_bonded_ethdev(&rte_eth_devices[port_id]))
+	if (check_for_bonded_ethdev(&rte_eth_devices[port_id]) == 0)
 		return -1;
 
 	return 0;
@@ -163,30 +166,11 @@ number_of_sockets(void)
 	return ++sockets;
 }
 
-const char pmd_bond_driver_name[] = "rte_bond_pmd";
-
-static struct rte_pci_id pci_id_table = {
-	.device_id = PCI_ANY_ID,
-	.subsystem_device_id = PCI_ANY_ID,
-	.vendor_id = PCI_ANY_ID,
-	.subsystem_vendor_id = PCI_ANY_ID,
-};
-
-static struct eth_driver rte_bond_pmd = {
-	.pci_drv = {
-		.name = pmd_bond_driver_name,
-		.drv_flags = RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_DETACHABLE,
-		.id_table = &pci_id_table,
-	},
-};
-
 int
 rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 {
-	struct rte_pci_device *pci_dev = NULL;
 	struct bond_dev_private *internals = NULL;
 	struct rte_eth_dev *eth_dev = NULL;
-	struct rte_pci_driver *pci_drv = NULL;
 
 	/* now do all data allocation - for eth_dev structure, dummy pci driver
 	 * and internal (private) data
@@ -203,14 +187,6 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 		goto err;
 	}
 
-	pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, socket_id);
-	if (pci_dev == NULL) {
-		RTE_BOND_LOG(ERR, "Unable to malloc pci dev on socket");
-		goto err;
-	}
-
-	pci_drv = &rte_bond_pmd.pci_drv;
-
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
 	if (internals == NULL) {
 		RTE_BOND_LOG(ERR, "Unable to malloc internals on socket");
@@ -224,11 +200,6 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 		goto err;
 	}
 
-	pci_dev->numa_node = socket_id;
-	pci_drv->name = pmd_bond_driver_name;
-	pci_dev->driver = pci_drv;
-
-	eth_dev->driver = &rte_bond_pmd;
 	eth_dev->data->dev_private = internals;
 	eth_dev->data->nb_rx_queues = (uint16_t)1;
 	eth_dev->data->nb_tx_queues = (uint16_t)1;
@@ -250,7 +221,12 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	eth_dev->data->all_multicast = 0;
 
 	eth_dev->dev_ops = &default_dev_ops;
-	eth_dev->pci_dev = pci_dev;
+	eth_dev->data->dev_flags = RTE_ETH_DEV_INTR_LSC |
+		RTE_ETH_DEV_DETACHABLE | RTE_ETH_DEV_BONDED;
+	eth_dev->driver = NULL;
+	eth_dev->data->kdrv = RTE_KDRV_NONE;
+	eth_dev->data->drv_name = NULL;
+	eth_dev->data->numa_node =  socket_id;
 
 	rte_spinlock_init(&internals->lock);
 
@@ -287,7 +263,6 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	return eth_dev->data->port_id;
 
 err:
-	rte_free(pci_dev);
 	rte_free(internals);
 	if (eth_dev != NULL) {
 		rte_free(eth_dev->data->mac_addrs);
@@ -319,7 +294,6 @@ rte_eth_bond_free(const char *name)
 	eth_dev->rx_pkt_burst = NULL;
 	eth_dev->tx_pkt_burst = NULL;
 
-	rte_free(eth_dev->pci_dev);
 	rte_free(eth_dev->data->dev_private);
 	rte_free(eth_dev->data->mac_addrs);
 
@@ -348,7 +322,7 @@ __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
 	/* Verify that new slave device is not already a slave of another
 	 * bonded device */
 	for (i = rte_eth_dev_count()-1; i >= 0; i--) {
-		if (valid_bonded_ethdev(&rte_eth_devices[i]) == 0) {
+		if (check_for_bonded_ethdev(&rte_eth_devices[i]) == 0) {
 			temp_internals = rte_eth_devices[i].data->dev_private;
 
 			for (j = 0; j < temp_internals->slave_count; j++) {
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 5cc6372..f4f29c5 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -1307,7 +1307,7 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
 	rte_eth_dev_stop(slave_eth_dev->data->port_id);
 
 	/* Enable interrupts on slave device if supported */
-	if (slave_eth_dev->driver->pci_drv.drv_flags & RTE_PCI_DRV_INTR_LSC)
+	if (slave_eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
 		slave_eth_dev->data->dev_conf.intr_conf.lsc = 1;
 
 	/* Configure device */
@@ -1362,9 +1362,9 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
 	}
 
 	/* If lsc interrupt is set, check initial slave's link status */
-	if (slave_eth_dev->driver->pci_drv.drv_flags & RTE_PCI_DRV_INTR_LSC)
+	if (slave_eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
 		bond_ethdev_lsc_event_callback(slave_eth_dev->data->port_id,
-				RTE_ETH_EVENT_INTR_LSC, &bonded_eth_dev->data->port_id);
+			RTE_ETH_EVENT_INTR_LSC, &bonded_eth_dev->data->port_id);
 
 	return 0;
 }
@@ -1447,7 +1447,7 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
 	int i;
 
 	/* slave eth dev will be started by bonded device */
-	if (valid_bonded_ethdev(eth_dev)) {
+	if (check_for_bonded_ethdev(eth_dev)) {
 		RTE_BOND_LOG(ERR, "User tried to explicitly start a slave eth_dev (%d)",
 				eth_dev->data->port_id);
 		return -1;
@@ -1592,7 +1592,7 @@ bond_ethdev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->max_tx_queues = (uint16_t)512;
 
 	dev_info->min_rx_bufsize = 0;
-	dev_info->pci_dev = dev->pci_dev;
+	dev_info->pci_dev = NULL;
 
 	dev_info->rx_offload_capa = internals->rx_offload_capa;
 	dev_info->tx_offload_capa = internals->tx_offload_capa;
@@ -1605,7 +1605,7 @@ bond_ethdev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
 {
 	struct bond_rx_queue *bd_rx_q = (struct bond_rx_queue *)
 			rte_zmalloc_socket(NULL, sizeof(struct bond_rx_queue),
-					0, dev->pci_dev->numa_node);
+					0, dev->data->numa_node);
 	if (bd_rx_q == NULL)
 		return -1;
 
@@ -1629,7 +1629,7 @@ bond_ethdev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 {
 	struct bond_tx_queue *bd_tx_q  = (struct bond_tx_queue *)
 			rte_zmalloc_socket(NULL, sizeof(struct bond_tx_queue),
-					0, dev->pci_dev->numa_node);
+					0, dev->data->numa_node);
 
 	if (bd_tx_q == NULL)
 		return -1;
@@ -1873,7 +1873,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 	bonded_eth_dev = &rte_eth_devices[*(uint8_t *)param];
 	slave_eth_dev = &rte_eth_devices[port_id];
 
-	if (valid_bonded_ethdev(bonded_eth_dev))
+	if (check_for_bonded_ethdev(bonded_eth_dev))
 		return;
 
 	internals = bonded_eth_dev->data->dev_private;
diff --git a/drivers/net/bonding/rte_eth_bond_private.h b/drivers/net/bonding/rte_eth_bond_private.h
index 038bca6..82dadfc 100644
--- a/drivers/net/bonding/rte_eth_bond_private.h
+++ b/drivers/net/bonding/rte_eth_bond_private.h
@@ -162,7 +162,7 @@ struct bond_dev_private {
 extern struct eth_dev_ops default_dev_ops;
 
 int
-valid_bonded_ethdev(const struct rte_eth_dev *eth_dev);
+check_for_bonded_ethdev(const struct rte_eth_dev *eth_dev);
 
 /* Search given slave array to find possition of given id.
  * Return slave pos or slaves_count if not found. */
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 07/20] pcap: remove pci device driver
  2015-09-28 13:03 ` [dpdk-dev] [PATCH 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (5 preceding siblings ...)
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 06/20] bonding: " Bernard Iremonger
@ 2015-09-28 13:03   ` Bernard Iremonger
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 08/20] af_packet: " Bernard Iremonger
                     ` (12 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-09-28 13:03 UTC (permalink / raw)
  To: dev

remove rte_pcap_pmd and pci_dev.
initialise dev_flags, driver, drv_name, kdrv and numa_node fields in eth_dev data

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/pcap/rte_eth_pcap.c | 31 +++++++++----------------------
 1 file changed, 9 insertions(+), 22 deletions(-)

diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index f2e4634..5f416f4 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -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.
  *
@@ -617,13 +617,6 @@ static const struct eth_dev_ops ops = {
 	.stats_reset = eth_stats_reset,
 };
 
-static struct eth_driver rte_pcap_pmd = {
-	.pci_drv = {
-		.name = "rte_pcap_pmd",
-		.drv_flags = RTE_PCI_DRV_DETACHABLE,
-	},
-};
-
 /*
  * Function handler that opens the pcap file for reading a stores a
  * reference of it for use it later on.
@@ -806,7 +799,6 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues,
 		struct rte_kvargs *kvlist)
 {
 	struct rte_eth_dev_data *data = NULL;
-	struct rte_pci_device *pci_dev = NULL;
 	unsigned k_idx;
 	struct rte_kvargs_pair *pair = NULL;
 
@@ -819,17 +811,13 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues,
 	RTE_LOG(INFO, PMD,
 			"Creating pcap-backed ethdev on numa socket %u\n", numa_node);
 
-	/* now do all data allocation - for eth_dev structure, dummy pci driver
+	/* now do all data allocation - for eth_dev structure
 	 * and internal (private) data
 	 */
 	data = rte_zmalloc_socket(name, sizeof(*data), 0, numa_node);
 	if (data == NULL)
 		goto error;
 
-	pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, numa_node);
-	if (pci_dev == NULL)
-		goto error;
-
 	*internals = rte_zmalloc_socket(name, sizeof(**internals), 0, numa_node);
 	if (*internals == NULL)
 		goto error;
@@ -845,8 +833,8 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues,
 
 	/* now put it all together
 	 * - store queue data in internals,
-	 * - store numa_node info in pci_driver
-	 * - point eth_dev_data to internals and pci_driver
+	 * - store numa_node info in eth_dev
+	 * - point eth_dev_data to internals
 	 * - and point eth_dev structure to new eth_dev_data structure
 	 */
 	/* NOTE: we'll replace the data element, of originally allocated eth_dev
@@ -860,8 +848,6 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues,
 	else
 		(*internals)->if_index = if_nametoindex(pair->value);
 
-	pci_dev->numa_node = numa_node;
-
 	data->dev_private = *internals;
 	data->port_id = (*eth_dev)->data->port_id;
 	snprintf(data->name, sizeof(data->name), "%s", (*eth_dev)->data->name);
@@ -874,14 +860,16 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues,
 
 	(*eth_dev)->data = data;
 	(*eth_dev)->dev_ops = &ops;
-	(*eth_dev)->pci_dev = pci_dev;
-	(*eth_dev)->driver = &rte_pcap_pmd;
+	(*eth_dev)->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
+	(*eth_dev)->driver = NULL;
+	(*eth_dev)->data->kdrv = RTE_KDRV_NONE;
+	(*eth_dev)->data->drv_name = NULL;
+	(*eth_dev)->data->numa_node = numa_node;
 
 	return 0;
 
 error:
 	rte_free(data);
-	rte_free(pci_dev);
 	rte_free(*internals);
 
 	return -1;
@@ -1096,7 +1084,6 @@ rte_pmd_pcap_devuninit(const char *name)
 
 	rte_free(eth_dev->data->dev_private);
 	rte_free(eth_dev->data);
-	rte_free(eth_dev->pci_dev);
 
 	rte_eth_dev_release_port(eth_dev);
 
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 08/20] af_packet: remove pci device driver
  2015-09-28 13:03 ` [dpdk-dev] [PATCH 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (6 preceding siblings ...)
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 07/20] pcap: " Bernard Iremonger
@ 2015-09-28 13:03   ` Bernard Iremonger
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 09/20] xenvirt: " Bernard Iremonger
                     ` (11 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-09-28 13:03 UTC (permalink / raw)
  To: dev

From: David Hunt <david.hunt@intel.com>

initialise dev_flags, driver, kdrv, drv_name and numa_node fileds in eth_dev data.

Signed-off-by: David Hunt <david.hunt@intel.com>
Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/af_packet/rte_eth_af_packet.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index bdd9628..7c3c455 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -5,7 +5,7 @@
  *
  *   Originally based upon librte_pmd_pcap code:
  *
- *   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.
  *
@@ -431,7 +431,6 @@ rte_pmd_init_internals(const char *name,
                        struct rte_kvargs *kvlist)
 {
 	struct rte_eth_dev_data *data = NULL;
-	struct rte_pci_device *pci_dev = NULL;
 	struct rte_kvargs_pair *pair = NULL;
 	struct ifreq ifr;
 	size_t ifnamelen;
@@ -469,10 +468,6 @@ rte_pmd_init_internals(const char *name,
 	if (data == NULL)
 		goto error;
 
-	pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, numa_node);
-	if (pci_dev == NULL)
-		goto error;
-
 	*internals = rte_zmalloc_socket(name, sizeof(**internals),
 	                                0, numa_node);
 	if (*internals == NULL)
@@ -655,8 +650,8 @@ rte_pmd_init_internals(const char *name,
 	/*
 	 * now put it all together
 	 * - store queue data in internals,
-	 * - store numa_node info in pci_driver
-	 * - point eth_dev_data to internals and pci_driver
+	 * - store numa_node info in eth_dev
+	 * - point eth_dev_data to internals
 	 * - and point eth_dev structure to new eth_dev_data structure
 	 */
 
@@ -669,17 +664,18 @@ rte_pmd_init_internals(const char *name,
 	data->dev_link = pmd_link;
 	data->mac_addrs = &(*internals)->eth_addr;
 
-	pci_dev->numa_node = numa_node;
-
 	(*eth_dev)->data = data;
 	(*eth_dev)->dev_ops = &ops;
-	(*eth_dev)->pci_dev = pci_dev;
+	(*eth_dev)->data->dev_flags = 0;
+	(*eth_dev)->driver = NULL;
+	(*eth_dev)->data->drv_name = NULL;
+	(*eth_dev)->data->kdrv = RTE_KDRV_NONE;
+	(*eth_dev)->data->numa_node = numa_node;
 
 	return 0;
 
 error:
 	rte_free(data);
-	rte_free(pci_dev);
 
 	if (*internals) {
 		for (q = 0; q < nb_queues; q++) {
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 09/20] xenvirt: remove pci device driver
  2015-09-28 13:03 ` [dpdk-dev] [PATCH 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (7 preceding siblings ...)
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 08/20] af_packet: " Bernard Iremonger
@ 2015-09-28 13:03   ` Bernard Iremonger
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 10/20] mpipe: " Bernard Iremonger
                     ` (10 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-09-28 13:03 UTC (permalink / raw)
  To: dev

From: David Hunt <david.hunt@intel.com>

Initialise dev_flags, driver, kdrv, drv_name and numa_node in eth_dev data.

Signed-off-by: David Hunt <david.hunt@intel.com>
Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/xenvirt/rte_eth_xenvirt.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/net/xenvirt/rte_eth_xenvirt.c b/drivers/net/xenvirt/rte_eth_xenvirt.c
index 73e8bce..b3383af 100644
--- a/drivers/net/xenvirt/rte_eth_xenvirt.c
+++ b/drivers/net/xenvirt/rte_eth_xenvirt.c
@@ -617,7 +617,6 @@ eth_dev_xenvirt_create(const char *name, const char *params,
                 enum dev_action action)
 {
 	struct rte_eth_dev_data *data = NULL;
-	struct rte_pci_device *pci_dev = NULL;
 	struct pmd_internals *internals = NULL;
 	struct rte_eth_dev *eth_dev = NULL;
 	struct xenvirt_dict dict;
@@ -639,10 +638,6 @@ eth_dev_xenvirt_create(const char *name, const char *params,
 	if (data == NULL)
 		goto err;
 
-	pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, numa_node);
-	if (pci_dev == NULL)
-		goto err;
-
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, numa_node);
 	if (internals == NULL)
 		goto err;
@@ -652,8 +647,6 @@ eth_dev_xenvirt_create(const char *name, const char *params,
 	if (eth_dev == NULL)
 		goto err;
 
-	pci_dev->numa_node = numa_node;
-
 	data->dev_private = internals;
 	data->port_id = eth_dev->data->port_id;
 	data->nb_rx_queues = (uint16_t)1;
@@ -668,7 +661,11 @@ eth_dev_xenvirt_create(const char *name, const char *params,
 
 	eth_dev->data = data;
 	eth_dev->dev_ops = &ops;
-	eth_dev->pci_dev = pci_dev;
+	eth_dev->data->dev_flags = 0;
+	eth_dev->data->kdrv = RTE_KDRV_NONE;
+	eth_dev->data->drv_name = NULL;
+	eth_dev->driver = NULL;
+	eth_dev->data->numa_node = numa_node;
 
 	eth_dev->rx_pkt_burst = eth_xenvirt_rx;
 	eth_dev->tx_pkt_burst = eth_xenvirt_tx;
@@ -680,7 +677,6 @@ eth_dev_xenvirt_create(const char *name, const char *params,
 
 err:
 	rte_free(data);
-	rte_free(pci_dev);
 	rte_free(internals);
 
 	return -1;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 10/20] mpipe: remove pci device driver
  2015-09-28 13:03 ` [dpdk-dev] [PATCH 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (8 preceding siblings ...)
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 09/20] xenvirt: " Bernard Iremonger
@ 2015-09-28 13:03   ` Bernard Iremonger
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 11/20] ixgbe: copy pci device info to eth_dev data Bernard Iremonger
                     ` (9 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-09-28 13:03 UTC (permalink / raw)
  To: dev

From: David Hunt <david.hunt@intel.com>

initialise dev_flags, kdrv, driver, drv_name and numa_node in eth_dev data.

Signed-off-by: David Hunt <david.hunt@intel.com>
Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/mpipe/mpipe_tilegx.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/net/mpipe/mpipe_tilegx.c b/drivers/net/mpipe/mpipe_tilegx.c
index 743feef..2329f49 100644
--- a/drivers/net/mpipe/mpipe_tilegx.c
+++ b/drivers/net/mpipe/mpipe_tilegx.c
@@ -2,6 +2,7 @@
  *   BSD LICENSE
  *
  *   Copyright(c) 2015 EZchip Semiconductor Ltd. All rights reserved.
+ *   Copyright(c) 2015 Intel Corporation. All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
  *   modification, are permitted provided that the following conditions
@@ -122,7 +123,6 @@ struct mpipe_dev_priv {
 	int channel;			/* Device channel. */
 	int port_id;			/* DPDK port index. */
 	struct rte_eth_dev *eth_dev;	/* DPDK device. */
-	struct rte_pci_device pci_dev;	/* PCI device data. */
 	struct rte_mbuf **tx_comps;	/* TX completion array. */
 	struct rte_mempool *rx_mpool;	/* mpool used by the rx queues. */
 	unsigned rx_offset;		/* Receive head room. */
@@ -1567,7 +1567,6 @@ rte_pmd_mpipe_devinit(const char *ifname,
 	priv->context = context;
 	priv->instance = instance;
 	priv->is_xaui = (strncmp(ifname, "xgbe", 4) == 0);
-	priv->pci_dev.numa_node = instance;
 	priv->channel = -1;
 
 	mac = priv->mac_addr.addr_bytes;
@@ -1591,9 +1590,14 @@ rte_pmd_mpipe_devinit(const char *ifname,
 	priv->eth_dev = eth_dev;
 	priv->port_id = eth_dev->data->port_id;
 	eth_dev->data->dev_private = priv;
-	eth_dev->pci_dev = &priv->pci_dev;
 	eth_dev->data->mac_addrs = &priv->mac_addr;
 
+	eth_dev->data->dev_flags = 0;
+	eth_dev->data->kdrv = RTE_KDRV_NONE;
+	eth_dev->driver = NULL;
+	eth_dev->data->drv_name = NULL;
+	eth_dev->data->numa_node = instance;
+
 	eth_dev->dev_ops      = &mpipe_dev_ops;
 	eth_dev->rx_pkt_burst = &mpipe_recv_pkts;
 	eth_dev->tx_pkt_burst = &mpipe_xmit_pkts;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 11/20] ixgbe: copy pci device info to eth_dev data
  2015-09-28 13:03 ` [dpdk-dev] [PATCH 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (9 preceding siblings ...)
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 10/20] mpipe: " Bernard Iremonger
@ 2015-09-28 13:03   ` Bernard Iremonger
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 12/20] e1000: " Bernard Iremonger
                     ` (8 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-09-28 13:03 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index ec2918c..08b5cbb 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -887,6 +887,8 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)
 	}
 	pci_dev = eth_dev->pci_dev;
 
+	rte_eth_copy_dev_info(eth_dev, pci_dev);
+
 	/* Vendor and Device ID need to be set before init of shared code */
 	hw->device_id = pci_dev->id.device_id;
 	hw->vendor_id = pci_dev->id.vendor_id;
@@ -1155,6 +1157,8 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
 
 	pci_dev = eth_dev->pci_dev;
 
+	rte_eth_copy_dev_info(eth_dev, pci_dev);
+
 	hw->device_id = pci_dev->id.device_id;
 	hw->vendor_id = pci_dev->id.vendor_id;
 	hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 12/20] e1000: copy pci device info to eth_dev data
  2015-09-28 13:03 ` [dpdk-dev] [PATCH 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (10 preceding siblings ...)
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 11/20] ixgbe: copy pci device info to eth_dev data Bernard Iremonger
@ 2015-09-28 13:03   ` Bernard Iremonger
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 13/20] i40e: " Bernard Iremonger
                     ` (7 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-09-28 13:03 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/e1000/em_ethdev.c  | 3 +++
 drivers/net/e1000/igb_ethdev.c | 5 +++++
 2 files changed, 8 insertions(+)

diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index 912f5dd..aa1bf48 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -232,6 +232,9 @@ eth_em_dev_init(struct rte_eth_dev *eth_dev)
 		E1000_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
 
 	pci_dev = eth_dev->pci_dev;
+
+	rte_eth_copy_dev_info(eth_dev, pci_dev);
+
 	eth_dev->dev_ops = &eth_em_ops;
 	eth_dev->rx_pkt_burst = (eth_rx_burst_t)&eth_em_recv_pkts;
 	eth_dev->tx_pkt_burst = (eth_tx_burst_t)&eth_em_xmit_pkts;
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 848ef6e..2a7aa31 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -531,6 +531,9 @@ eth_igb_dev_init(struct rte_eth_dev *eth_dev)
 	uint32_t ctrl_ext;
 
 	pci_dev = eth_dev->pci_dev;
+
+	rte_eth_copy_dev_info(eth_dev, pci_dev);
+
 	eth_dev->dev_ops = &eth_igb_ops;
 	eth_dev->rx_pkt_burst = &eth_igb_recv_pkts;
 	eth_dev->tx_pkt_burst = &eth_igb_xmit_pkts;
@@ -739,6 +742,8 @@ eth_igbvf_dev_init(struct rte_eth_dev *eth_dev)
 
 	pci_dev = eth_dev->pci_dev;
 
+	rte_eth_copy_dev_info(eth_dev, pci_dev);
+
 	hw->device_id = pci_dev->id.device_id;
 	hw->vendor_id = pci_dev->id.vendor_id;
 	hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 13/20] i40e: copy pci device info to eth_dev data
  2015-09-28 13:03 ` [dpdk-dev] [PATCH 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (11 preceding siblings ...)
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 12/20] e1000: " Bernard Iremonger
@ 2015-09-28 13:03   ` Bernard Iremonger
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 14/20] fm10k: " Bernard Iremonger
                     ` (6 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-09-28 13:03 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c    | 3 +++
 drivers/net/i40e/i40e_ethdev_vf.c | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 2dd9fdc..bd81d4e 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -408,6 +408,9 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 		return 0;
 	}
 	pci_dev = dev->pci_dev;
+
+	rte_eth_copy_dev_info(dev, pci_dev);
+
 	pf->adapter = I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 	pf->adapter->eth_dev = dev;
 	pf->dev_data = dev->data;
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index b694400..ab718fb 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1187,6 +1187,8 @@ i40evf_dev_init(struct rte_eth_dev *eth_dev)
 		return 0;
 	}
 
+	rte_eth_copy_dev_info(eth_dev, eth_dev->pci_dev);
+
 	hw->vendor_id = eth_dev->pci_dev->id.vendor_id;
 	hw->device_id = eth_dev->pci_dev->id.device_id;
 	hw->subsystem_vendor_id = eth_dev->pci_dev->id.subsystem_vendor_id;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 14/20] fm10k: copy pci device info to eth_dev data
  2015-09-28 13:03 ` [dpdk-dev] [PATCH 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (12 preceding siblings ...)
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 13/20] i40e: " Bernard Iremonger
@ 2015-09-28 13:03   ` Bernard Iremonger
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 15/20] bnx2x: " Bernard Iremonger
                     ` (5 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-09-28 13:03 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/fm10k/fm10k_ethdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index a69c990..12be227 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -2075,6 +2075,8 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
+	rte_eth_copy_dev_info(dev, dev->pci_dev);
+
 	macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private);
 	memset(macvlan, 0, sizeof(*macvlan));
 	/* Vendor and Device ID need to be set before init of shared code */
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 15/20] bnx2x: copy pci device info to eth_dev data
  2015-09-28 13:03 ` [dpdk-dev] [PATCH 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (13 preceding siblings ...)
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 14/20] fm10k: " Bernard Iremonger
@ 2015-09-28 13:03   ` Bernard Iremonger
  2015-09-28 19:55     ` Stephen Hemminger
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 16/20] cxgbe: " Bernard Iremonger
                     ` (4 subsequent siblings)
  19 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-09-28 13:03 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/bnx2x/bnx2x_ethdev.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index 09b5920..c4941d1 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2013-2015 Brocade Communications Systems, Inc.
+ * Copyright(c) 2015 Intel Corporation.
  *
  * All rights reserved.
  */
@@ -419,6 +420,9 @@ bnx2x_common_dev_init(struct rte_eth_dev *eth_dev, int is_vf)
 
 	eth_dev->dev_ops = is_vf ? &bnx2xvf_eth_dev_ops : &bnx2x_eth_dev_ops;
 	pci_dev = eth_dev->pci_dev;
+
+	rte_eth_copy_dev_info(eth_dev, pci_dev);
+
 	sc = eth_dev->data->dev_private;
 	sc->pcie_bus    = pci_dev->addr.bus;
 	sc->pcie_device = pci_dev->addr.devid;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 16/20] cxgbe: copy pci device info to eth_dev data
  2015-09-28 13:03 ` [dpdk-dev] [PATCH 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (14 preceding siblings ...)
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 15/20] bnx2x: " Bernard Iremonger
@ 2015-09-28 13:03   ` Bernard Iremonger
  2015-09-28 18:53     ` Rahul Lakkireddy
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 17/20] enic: " Bernard Iremonger
                     ` (3 subsequent siblings)
  19 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-09-28 13:03 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/cxgbe/cxgbe_ethdev.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 478051a..2fa2cc3 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -2,6 +2,8 @@
  *   BSD LICENSE
  *
  *   Copyright(c) 2014-2015 Chelsio Communications.
+ *   Copyright(c) 2015 Intel Corporation.
+ *
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -744,6 +746,9 @@ static int eth_cxgbe_dev_init(struct rte_eth_dev *eth_dev)
 		return 0;
 
 	pci_dev = eth_dev->pci_dev;
+
+	rte_eth_copy_dev_info(eth_dev, pci_dev);
+
 	snprintf(name, sizeof(name), "cxgbeadapter%d", eth_dev->data->port_id);
 	adapter = rte_zmalloc(name, sizeof(*adapter), 0);
 	if (!adapter)
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 17/20] enic: copy pci device info to eth_dev data
  2015-09-28 13:03 ` [dpdk-dev] [PATCH 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (15 preceding siblings ...)
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 16/20] cxgbe: " Bernard Iremonger
@ 2015-09-28 13:03   ` Bernard Iremonger
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 18/20] mlx4: " Bernard Iremonger
                     ` (2 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-09-28 13:03 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/enic/enic_ethdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c
index 8280cea..b4ed3d2 100644
--- a/drivers/net/enic/enic_ethdev.c
+++ b/drivers/net/enic/enic_ethdev.c
@@ -3,6 +3,7 @@
  * Copyright 2007 Nuova Systems, Inc.  All rights reserved.
  *
  * Copyright (c) 2014, Cisco Systems, Inc.
+ * Copyright(c) 2015 Intel Corporation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -599,6 +600,7 @@ static int eth_enicpmd_dev_init(struct rte_eth_dev *eth_dev)
 	eth_dev->tx_pkt_burst = &enicpmd_xmit_pkts;
 
 	pdev = eth_dev->pci_dev;
+	rte_eth_copy_dev_info(eth_dev, pdev);
 	enic->pdev = pdev;
 	addr = &pdev->addr;
 
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 18/20] mlx4: copy pci device info to eth_dev data
  2015-09-28 13:03 ` [dpdk-dev] [PATCH 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (16 preceding siblings ...)
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 17/20] enic: " Bernard Iremonger
@ 2015-09-28 13:03   ` Bernard Iremonger
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 19/20] virtio: " Bernard Iremonger
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 20/20] vmxnet3: " Bernard Iremonger
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-09-28 13:03 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/mlx4/mlx4.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index 6c6342f..851a000 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -3,6 +3,7 @@
  *
  *   Copyright 2012-2015 6WIND S.A.
  *   Copyright 2012 Mellanox.
+ *   Copyright(c) 2015 Intel Corporation. All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
  *   modification, are permitted provided that the following conditions
@@ -4980,6 +4981,9 @@ mlx4_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 
 		eth_dev->data->dev_private = priv;
 		eth_dev->pci_dev = pci_dev;
+
+		rte_eth_copy_dev_info(eth_dev, pci_dev);
+
 		eth_dev->driver = &mlx4_driver;
 		eth_dev->data->rx_mbuf_alloc_failed = 0;
 		eth_dev->data->mtu = ETHER_MTU;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 19/20] virtio: copy pci device info to eth_dev data
  2015-09-28 13:03 ` [dpdk-dev] [PATCH 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (17 preceding siblings ...)
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 18/20] mlx4: " Bernard Iremonger
@ 2015-09-28 13:03   ` Bernard Iremonger
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 20/20] vmxnet3: " Bernard Iremonger
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-09-28 13:03 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/virtio/virtio_ethdev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 465d3cd..20059a0 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1185,6 +1185,9 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 	}
 
 	pci_dev = eth_dev->pci_dev;
+
+	rte_eth_copy_dev_info(eth_dev, pci_dev);
+
 	if (virtio_resource_init(pci_dev) < 0)
 		return -1;
 
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 20/20] vmxnet3: copy pci device info to eth_dev data
  2015-09-28 13:03 ` [dpdk-dev] [PATCH 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (18 preceding siblings ...)
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 19/20] virtio: " Bernard Iremonger
@ 2015-09-28 13:03   ` Bernard Iremonger
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-09-28 13:03 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/vmxnet3/vmxnet3_ethdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c
index a70be5c..2beee3e 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c
@@ -235,6 +235,8 @@ eth_vmxnet3_dev_init(struct rte_eth_dev *eth_dev)
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
+	rte_eth_copy_dev_info(eth_dev, pci_dev);
+
 	/* Vendor and Device ID need to be set before init of shared code */
 	hw->device_id = pci_dev->id.device_id;
 	hw->vendor_id = pci_dev->id.vendor_id;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH 16/20] cxgbe: copy pci device info to eth_dev data
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 16/20] cxgbe: " Bernard Iremonger
@ 2015-09-28 18:53     ` Rahul Lakkireddy
  2015-09-29  8:41       ` Iremonger, Bernard
  0 siblings, 1 reply; 270+ messages in thread
From: Rahul Lakkireddy @ 2015-09-28 18:53 UTC (permalink / raw)
  To: Bernard Iremonger; +Cc: dev, Felix Marti, Kumar Sanghvi, Nirranjan Kirubaharan

Hi Bernard,

On Monday, September 09/28/15, 2015 at 14:03:34 +0100, Bernard Iremonger wrote:
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> ---
>  drivers/net/cxgbe/cxgbe_ethdev.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
> index 478051a..2fa2cc3 100644
> --- a/drivers/net/cxgbe/cxgbe_ethdev.c
> +++ b/drivers/net/cxgbe/cxgbe_ethdev.c
> @@ -2,6 +2,8 @@
>   *   BSD LICENSE
>   *
>   *   Copyright(c) 2014-2015 Chelsio Communications.
> + *   Copyright(c) 2015 Intel Corporation.
> + *
>   *   All rights reserved.
>   *
>   *   Redistribution and use in source and binary forms, with or without
> @@ -744,6 +746,9 @@ static int eth_cxgbe_dev_init(struct rte_eth_dev *eth_dev)
>  		return 0;
>  
>  	pci_dev = eth_dev->pci_dev;
> +
> +	rte_eth_copy_dev_info(eth_dev, pci_dev);
> +
>  	snprintf(name, sizeof(name), "cxgbeadapter%d", eth_dev->data->port_id);
>  	adapter = rte_zmalloc(name, sizeof(*adapter), 0);
>  	if (!adapter)
> -- 
> 1.9.1
> 

Out of curiosity, do you really need to add Intel copyright on top of source
file for a 3 line change in source file? I see that you have done the same for
cisco, mellanox, broadcom and other vendors as well.

I don't claim to understand Copyright very well. However, I have seen in other
open community projects like kernel.org where people many times do significant
change in someone else's code and yet, don't normally add their own copyright
to source files.

Care to explain what is the intention here with addition of Intel Copyright
statement?

Thanks,
Rahul

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH 15/20] bnx2x: copy pci device info to eth_dev data
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 15/20] bnx2x: " Bernard Iremonger
@ 2015-09-28 19:55     ` Stephen Hemminger
  2015-09-29  8:43       ` Iremonger, Bernard
  0 siblings, 1 reply; 270+ messages in thread
From: Stephen Hemminger @ 2015-09-28 19:55 UTC (permalink / raw)
  To: Bernard Iremonger; +Cc: dev

On Mon, 28 Sep 2015 14:03:33 +0100
Bernard Iremonger <bernard.iremonger@intel.com> wrote:

>  /*
>   * Copyright (c) 2013-2015 Brocade Communications Systems, Inc.
> + * Copyright(c) 2015 Intel Corporation.
>   *
>   * All rights reserved.
>   */

I agree with others, you can't claim copyright until you have
made substantive changes. At one point a lawyer told me that
had to be 10% of the code.

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH 16/20] cxgbe: copy pci device info to eth_dev data
  2015-09-28 18:53     ` Rahul Lakkireddy
@ 2015-09-29  8:41       ` Iremonger, Bernard
  0 siblings, 0 replies; 270+ messages in thread
From: Iremonger, Bernard @ 2015-09-29  8:41 UTC (permalink / raw)
  To: Rahul Lakkireddy; +Cc: dev, Felix Marti, Kumar Sanghvi, Nirranjan Kirubaharan

Hi Rahul,

<snip>

> Out of curiosity, do you really need to add Intel copyright on top of source
> file for a 3 line change in source file? I see that you have done the same for
> cisco, mellanox, broadcom and other vendors as well.
> 
> I don't claim to understand Copyright very well. However, I have seen in
> other
> open community projects like kernel.org where people many times do
> significant
> change in someone else's code and yet, don't normally add their own
> copyright
> to source files.
> 
> Care to explain what is the intention here with addition of Intel Copyright
> statement?
> 
> Thanks,
> Rahul

I thought it was necessary to add the Intel Copyright, because I had modified the code.
I will remove it in the next revision of the patchset.

Regards,

Bernard.

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH 15/20] bnx2x: copy pci device info to eth_dev data
  2015-09-28 19:55     ` Stephen Hemminger
@ 2015-09-29  8:43       ` Iremonger, Bernard
  0 siblings, 0 replies; 270+ messages in thread
From: Iremonger, Bernard @ 2015-09-29  8:43 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

Hi Stephen,

<snip>

> On Mon, 28 Sep 2015 14:03:33 +0100
> Bernard Iremonger <bernard.iremonger@intel.com> wrote:
> 
> >  /*
> >   * Copyright (c) 2013-2015 Brocade Communications Systems, Inc.
> > + * Copyright(c) 2015 Intel Corporation.
> >   *
> >   * All rights reserved.
> >   */
> 
> I agree with others, you can't claim copyright until you have made
> substantive changes. At one point a lawyer told me that had to be 10% of the
> code.

I thought it was necessary to add the copyright line because I had modified the code.
I will remove it in the next revision of the patch set.

Regards,

Bernard.

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH 02/20] librte_ether: add fields from rte_pci_driver to rte_eth_dev_data
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 02/20] librte_ether: add fields from rte_pci_driver to rte_eth_dev_data Bernard Iremonger
@ 2015-09-29 19:08     ` Neil Horman
  2015-09-30  9:56       ` Bruce Richardson
  2015-09-30 13:18     ` Neil Horman
  1 sibling, 1 reply; 270+ messages in thread
From: Neil Horman @ 2015-09-29 19:08 UTC (permalink / raw)
  To: Bernard Iremonger; +Cc: dev

On Mon, Sep 28, 2015 at 02:03:20PM +0100, Bernard Iremonger wrote:
> add dev_flags to rte_eth_dev_data, add macros for dev_flags.
> add kdrv to rte_eth_dev_data.
> add numa_node to rte_eth_dev_data.
> add drv_name to rte_eth_dev_data.
> use dev_type to distinguish between vdev's and pdev's.
> remove pci_dev branches.
> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> ---
>  lib/librte_ether/rte_ethdev.c | 53 ++++++++++++++++++++++++-------------------
>  lib/librte_ether/rte_ethdev.h | 15 ++++++++++++
>  2 files changed, 45 insertions(+), 23 deletions(-)
> 
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index b309309..e4cb285 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -424,7 +424,7 @@ rte_eth_dev_socket_id(uint8_t port_id)
>  {
>  	if (!rte_eth_dev_is_valid_port(port_id))
>  		return -1;
> -	return rte_eth_devices[port_id].pci_dev->numa_node;
> +	return rte_eth_devices[port_id].data->numa_node;
>  }
>  
>  uint8_t
> @@ -503,27 +503,25 @@ rte_eth_dev_get_name_by_port(uint8_t port_id, char *name)
>  static int
>  rte_eth_dev_is_detachable(uint8_t port_id)
>  {
> -	uint32_t drv_flags;
> +	uint32_t dev_flags;
>  
>  	if (!rte_eth_dev_is_valid_port(port_id)) {
>  		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
>  		return -EINVAL;
>  	}
>  
> -	if (rte_eth_devices[port_id].dev_type == RTE_ETH_DEV_PCI) {
> -		switch (rte_eth_devices[port_id].pci_dev->kdrv) {
> -		case RTE_KDRV_IGB_UIO:
> -		case RTE_KDRV_UIO_GENERIC:
> -		case RTE_KDRV_NIC_UIO:
> -			break;
> -		case RTE_KDRV_VFIO:
> -		default:
> -			return -ENOTSUP;
> -		}
> +	switch (rte_eth_devices[port_id].data->kdrv) {
> +	case RTE_KDRV_IGB_UIO:
> +	case RTE_KDRV_UIO_GENERIC:
> +	case RTE_KDRV_NIC_UIO:
> +	case RTE_KDRV_NONE:
> +		break;
> +	case RTE_KDRV_VFIO:
> +	default:
> +		return -ENOTSUP;
>  	}
> -
> -	drv_flags = rte_eth_devices[port_id].driver->pci_drv.drv_flags;
> -	return !(drv_flags & RTE_PCI_DRV_DETACHABLE);
> +	dev_flags = rte_eth_devices[port_id].data->dev_flags;
> +	return !(dev_flags & RTE_ETH_DEV_DETACHABLE);
>  }
>  
>  /* attach the new physical device, then store port_id of the device */
> @@ -1143,14 +1141,11 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
>  	 * If link state interrupt is enabled, check that the
>  	 * device supports it.
>  	 */
> -	if (dev_conf->intr_conf.lsc == 1) {
> -		const struct rte_pci_driver *pci_drv = &dev->driver->pci_drv;
> -
> -		if (!(pci_drv->drv_flags & RTE_PCI_DRV_INTR_LSC)) {
> +	if ((dev_conf->intr_conf.lsc == 1) &&
> +		(!(dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC))) {
>  			PMD_DEBUG_TRACE("driver %s does not support lsc\n",
> -					pci_drv->name);
> +					dev->data->drv_name);
>  			return -EINVAL;
> -		}
>  	}
>  
>  	/*
> @@ -1795,8 +1790,7 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
>  	FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
>  	(*dev->dev_ops->dev_infos_get)(dev, dev_info);
>  	dev_info->pci_dev = dev->pci_dev;
> -	if (dev->driver)
> -		dev_info->driver_name = dev->driver->pci_drv.name;
> +	dev_info->driver_name = dev->data->drv_name;
>  }
>  
>  void
> @@ -3570,3 +3564,16 @@ rte_eth_dev_set_eeprom(uint8_t port_id, struct rte_dev_eeprom_info *info)
>  	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_eeprom, -ENOTSUP);
>  	return (*dev->dev_ops->set_eeprom)(dev, info);
>  }
> +
> +void
> +rte_eth_copy_dev_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_dev)
> +{
> +	if ((eth_dev == NULL) || (pci_dev == NULL))
> +		PMD_DEBUG_TRACE("NULL pointer eth_dev=%p pci_dev=%p\n",
> +				eth_dev, pci_dev);
> +
> +	eth_dev->data->dev_flags = pci_dev->driver->drv_flags;
> +	eth_dev->data->kdrv = pci_dev->kdrv;
> +	eth_dev->data->numa_node = pci_dev->numa_node;
> +	eth_dev->data->drv_name = pci_dev->driver->name;
> +}
> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> index fa06554..9cd262b 100644
> --- a/lib/librte_ether/rte_ethdev.h
> +++ b/lib/librte_ether/rte_ethdev.h
> @@ -1635,8 +1635,23 @@ struct rte_eth_dev_data {
>  		all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
>  		dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
>  		lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
> +	uint32_t dev_flags; /**< Flags controlling handling of device. */
> +	enum rte_kernel_driver kdrv;	/**< Kernel driver passthrough */
Why add this here? The ennumerated driver types are all variants on PCI bus
types.  Not sure why the ethernet interface needs to know this info

> +	int numa_node;
Ditto, this seems like information that is only relevant if the device is on a
physical bus (i.e. virual devices are likely to not have a numa node)

> +	const char *drv_name;
>  };
>  
> +/** Device needs PCI BAR mapping (done with either IGB_UIO or VFIO) */
> +#define RTE_ETH_DEV_DRV_NEED_MAPPING	RTE_PCI_DRV_NEED_MAPPING
> +/** Device needs to be unbound even if no module is provided */
> +#define RTE_ETH_DEV_DRV_FORCE_UNBIND	RTE_PCI_DRV_FORCE_UNBIND
> +/** Device supports link state interrupt */
> +#define RTE_ETH_DEV_INTR_LSC	RTE_PCI_DRV_INTR_LSC
> +/** Device  supports detaching capability */
> +#define RTE_ETH_DEV_DETACHABLE	RTE_PCI_DRV_DETACHABLE
> +/** Device  is a bonded device */
> +#define RTE_ETH_DEV_BONDED	0x0020
> +
>  /**
>   * @internal
>   * The pool of *rte_eth_dev* structures. The size of the pool
> -- 
> 1.9.1
> 
> 

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH 02/20] librte_ether: add fields from rte_pci_driver to rte_eth_dev_data
  2015-09-29 19:08     ` Neil Horman
@ 2015-09-30  9:56       ` Bruce Richardson
  2015-09-30 13:14         ` Neil Horman
  0 siblings, 1 reply; 270+ messages in thread
From: Bruce Richardson @ 2015-09-30  9:56 UTC (permalink / raw)
  To: Neil Horman; +Cc: dev

On Tue, Sep 29, 2015 at 03:08:12PM -0400, Neil Horman wrote:
> On Mon, Sep 28, 2015 at 02:03:20PM +0100, Bernard Iremonger wrote:
> > add dev_flags to rte_eth_dev_data, add macros for dev_flags.
> > add kdrv to rte_eth_dev_data.
> > add numa_node to rte_eth_dev_data.
> > add drv_name to rte_eth_dev_data.
> > use dev_type to distinguish between vdev's and pdev's.
> > remove pci_dev branches.
> > 
> > Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> > ---
> >  lib/librte_ether/rte_ethdev.c | 53 ++++++++++++++++++++++++-------------------
> >  lib/librte_ether/rte_ethdev.h | 15 ++++++++++++
> >  2 files changed, 45 insertions(+), 23 deletions(-)
> > 
<snip>
> > +++ b/lib/librte_ether/rte_ethdev.h
> > @@ -1635,8 +1635,23 @@ struct rte_eth_dev_data {
> >  		all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
> >  		dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
> >  		lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
> > +	uint32_t dev_flags; /**< Flags controlling handling of device. */
> > +	enum rte_kernel_driver kdrv;	/**< Kernel driver passthrough */
> Why add this here? The ennumerated driver types are all variants on PCI bus
> types.  Not sure why the ethernet interface needs to know this info
> 
> > +	int numa_node;
> Ditto, this seems like information that is only relevant if the device is on a
> physical bus (i.e. virual devices are likely to not have a numa node)
>
Actually, I disagree. For some virtual devices they will have a numa node. For
ring or other virtual PMDs the numa node will be the node on which the ring /
mempool etc. memory is allocated on, and can be of relevance.

/Bruce

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH 02/20] librte_ether: add fields from rte_pci_driver to rte_eth_dev_data
  2015-09-30  9:56       ` Bruce Richardson
@ 2015-09-30 13:14         ` Neil Horman
  2015-09-30 13:21           ` Bruce Richardson
  0 siblings, 1 reply; 270+ messages in thread
From: Neil Horman @ 2015-09-30 13:14 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

On Wed, Sep 30, 2015 at 10:56:04AM +0100, Bruce Richardson wrote:
> On Tue, Sep 29, 2015 at 03:08:12PM -0400, Neil Horman wrote:
> > On Mon, Sep 28, 2015 at 02:03:20PM +0100, Bernard Iremonger wrote:
> > > add dev_flags to rte_eth_dev_data, add macros for dev_flags.
> > > add kdrv to rte_eth_dev_data.
> > > add numa_node to rte_eth_dev_data.
> > > add drv_name to rte_eth_dev_data.
> > > use dev_type to distinguish between vdev's and pdev's.
> > > remove pci_dev branches.
> > > 
> > > Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> > > ---
> > >  lib/librte_ether/rte_ethdev.c | 53 ++++++++++++++++++++++++-------------------
> > >  lib/librte_ether/rte_ethdev.h | 15 ++++++++++++
> > >  2 files changed, 45 insertions(+), 23 deletions(-)
> > > 
> <snip>
> > > +++ b/lib/librte_ether/rte_ethdev.h
> > > @@ -1635,8 +1635,23 @@ struct rte_eth_dev_data {
> > >  		all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
> > >  		dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
> > >  		lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
> > > +	uint32_t dev_flags; /**< Flags controlling handling of device. */
> > > +	enum rte_kernel_driver kdrv;	/**< Kernel driver passthrough */
> > Why add this here? The ennumerated driver types are all variants on PCI bus
> > types.  Not sure why the ethernet interface needs to know this info
> > 
> > > +	int numa_node;
> > Ditto, this seems like information that is only relevant if the device is on a
> > physical bus (i.e. virual devices are likely to not have a numa node)
> >
> Actually, I disagree. For some virtual devices they will have a numa node. For
> ring or other virtual PMDs the numa node will be the node on which the ring /
> mempool etc. memory is allocated on, and can be of relevance.
> 
> /Bruce
> 

I think its fairly clear that some devices (including virtual ones) have some
relevant relation to a numa_node (There are even some that have no numa_node,
for which a -1 value makes some sense).  That said, there are just as many that
don't have a relevant numa_node.

1) There are some drivers for which numa_node make no sense (regardless of
value):
 * af_packet - The numa node is at best determined at run time by the interface
the socket is bound to

 * pcap - same as af_packet

 * bonding - multiple interfaces mean multiple numa_nodes, any value set here is
just as likely to be wrong as right

 * mpipe - no real large memory area to associate with a numa node

 * virtio - uses iopl for communication, and cannot know its numa_node

 * vmxnet3 - same concept as virtio

 * xenvirt - same as vmxnet3

I think its better that you store numa locality information in a pmd's private
bus data, and export it to applications via a device method.  that provides the
flexibility to tell the application that there is no numa locality for a device
(by not implementing the method), without having to expose an unset data field
to the application.

Neil

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH 02/20] librte_ether: add fields from rte_pci_driver to rte_eth_dev_data
  2015-09-28 13:03   ` [dpdk-dev] [PATCH 02/20] librte_ether: add fields from rte_pci_driver to rte_eth_dev_data Bernard Iremonger
  2015-09-29 19:08     ` Neil Horman
@ 2015-09-30 13:18     ` Neil Horman
  2015-09-30 13:23       ` Bruce Richardson
  1 sibling, 1 reply; 270+ messages in thread
From: Neil Horman @ 2015-09-30 13:18 UTC (permalink / raw)
  To: Bernard Iremonger; +Cc: dev

> +}
> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> index fa06554..9cd262b 100644
> --- a/lib/librte_ether/rte_ethdev.h
> +++ b/lib/librte_ether/rte_ethdev.h
> @@ -1635,8 +1635,23 @@ struct rte_eth_dev_data {
>  		all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
>  		dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
>  		lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
> +	uint32_t dev_flags; /**< Flags controlling handling of device. */
> +	enum rte_kernel_driver kdrv;	/**< Kernel driver passthrough */
> +	int numa_node;
> +	const char *drv_name;
>  };
>  
Unrelated to my other questions on this code: Is rte_eth_dev_data ever
allocation by any applications?  If so, this will have to go through the ABI
process.  I don't think it is, but I wanted to ask to be sure

Neil

> +/** Device needs PCI BAR mapping (done with either IGB_UIO or VFIO) */
> +#define RTE_ETH_DEV_DRV_NEED_MAPPING	RTE_PCI_DRV_NEED_MAPPING
> +/** Device needs to be unbound even if no module is provided */
> +#define RTE_ETH_DEV_DRV_FORCE_UNBIND	RTE_PCI_DRV_FORCE_UNBIND
> +/** Device supports link state interrupt */
> +#define RTE_ETH_DEV_INTR_LSC	RTE_PCI_DRV_INTR_LSC
> +/** Device  supports detaching capability */
> +#define RTE_ETH_DEV_DETACHABLE	RTE_PCI_DRV_DETACHABLE
> +/** Device  is a bonded device */
> +#define RTE_ETH_DEV_BONDED	0x0020
> +
>  /**
>   * @internal
>   * The pool of *rte_eth_dev* structures. The size of the pool
> -- 
> 1.9.1
> 
> 

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH 02/20] librte_ether: add fields from rte_pci_driver to rte_eth_dev_data
  2015-09-30 13:14         ` Neil Horman
@ 2015-09-30 13:21           ` Bruce Richardson
  2015-09-30 16:33             ` Iremonger, Bernard
  0 siblings, 1 reply; 270+ messages in thread
From: Bruce Richardson @ 2015-09-30 13:21 UTC (permalink / raw)
  To: Neil Horman; +Cc: dev

On Wed, Sep 30, 2015 at 09:14:48AM -0400, Neil Horman wrote:
> On Wed, Sep 30, 2015 at 10:56:04AM +0100, Bruce Richardson wrote:
> > On Tue, Sep 29, 2015 at 03:08:12PM -0400, Neil Horman wrote:
> > > On Mon, Sep 28, 2015 at 02:03:20PM +0100, Bernard Iremonger wrote:
> > > > add dev_flags to rte_eth_dev_data, add macros for dev_flags.
> > > > add kdrv to rte_eth_dev_data.
> > > > add numa_node to rte_eth_dev_data.
> > > > add drv_name to rte_eth_dev_data.
> > > > use dev_type to distinguish between vdev's and pdev's.
> > > > remove pci_dev branches.
> > > > 
> > > > Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> > > > ---
> > > >  lib/librte_ether/rte_ethdev.c | 53 ++++++++++++++++++++++++-------------------
> > > >  lib/librte_ether/rte_ethdev.h | 15 ++++++++++++
> > > >  2 files changed, 45 insertions(+), 23 deletions(-)
> > > > 
> > <snip>
> > > > +++ b/lib/librte_ether/rte_ethdev.h
> > > > @@ -1635,8 +1635,23 @@ struct rte_eth_dev_data {
> > > >  		all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
> > > >  		dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
> > > >  		lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
> > > > +	uint32_t dev_flags; /**< Flags controlling handling of device. */
> > > > +	enum rte_kernel_driver kdrv;	/**< Kernel driver passthrough */
> > > Why add this here? The ennumerated driver types are all variants on PCI bus
> > > types.  Not sure why the ethernet interface needs to know this info
> > > 
> > > > +	int numa_node;
> > > Ditto, this seems like information that is only relevant if the device is on a
> > > physical bus (i.e. virual devices are likely to not have a numa node)
> > >
> > Actually, I disagree. For some virtual devices they will have a numa node. For
> > ring or other virtual PMDs the numa node will be the node on which the ring /
> > mempool etc. memory is allocated on, and can be of relevance.
> > 
> > /Bruce
> > 
> 
> I think its fairly clear that some devices (including virtual ones) have some
> relevant relation to a numa_node (There are even some that have no numa_node,
> for which a -1 value makes some sense).  That said, there are just as many that
> don't have a relevant numa_node.
> 
> 1) There are some drivers for which numa_node make no sense (regardless of
> value):
>  * af_packet - The numa node is at best determined at run time by the interface
> the socket is bound to
> 
>  * pcap - same as af_packet
> 
>  * bonding - multiple interfaces mean multiple numa_nodes, any value set here is
> just as likely to be wrong as right
> 
>  * mpipe - no real large memory area to associate with a numa node
> 
>  * virtio - uses iopl for communication, and cannot know its numa_node
> 
>  * vmxnet3 - same concept as virtio
> 
>  * xenvirt - same as vmxnet3
> 
> I think its better that you store numa locality information in a pmd's private
> bus data, and export it to applications via a device method.  that provides the
> flexibility to tell the application that there is no numa locality for a device
> (by not implementing the method), without having to expose an unset data field
> to the application.
> 
> Neil
> 

Sure, that could work.
However, is it really worthwhile asking drivers to implement a new ethdev API
function, rather than just having them set the numa node field correctly in the
init function?

/Bruce

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH 02/20] librte_ether: add fields from rte_pci_driver to rte_eth_dev_data
  2015-09-30 13:18     ` Neil Horman
@ 2015-09-30 13:23       ` Bruce Richardson
  0 siblings, 0 replies; 270+ messages in thread
From: Bruce Richardson @ 2015-09-30 13:23 UTC (permalink / raw)
  To: Neil Horman; +Cc: dev

On Wed, Sep 30, 2015 at 09:18:53AM -0400, Neil Horman wrote:
> > +}
> > diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> > index fa06554..9cd262b 100644
> > --- a/lib/librte_ether/rte_ethdev.h
> > +++ b/lib/librte_ether/rte_ethdev.h
> > @@ -1635,8 +1635,23 @@ struct rte_eth_dev_data {
> >  		all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
> >  		dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
> >  		lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
> > +	uint32_t dev_flags; /**< Flags controlling handling of device. */
> > +	enum rte_kernel_driver kdrv;	/**< Kernel driver passthrough */
> > +	int numa_node;
> > +	const char *drv_name;
> >  };
> >  
> Unrelated to my other questions on this code: Is rte_eth_dev_data ever
> allocation by any applications?  If so, this will have to go through the ABI
> process.  I don't think it is, but I wanted to ask to be sure
> 
> Neil
> 

No - applications do not allocate this structure directly, it's internal only, so
we should be safe here from an ABI perspective.

/Bruce

^ permalink raw reply	[flat|nested] 270+ messages in thread

* Re: [dpdk-dev] [PATCH 02/20] librte_ether: add fields from rte_pci_driver to rte_eth_dev_data
  2015-09-30 13:21           ` Bruce Richardson
@ 2015-09-30 16:33             ` Iremonger, Bernard
  0 siblings, 0 replies; 270+ messages in thread
From: Iremonger, Bernard @ 2015-09-30 16:33 UTC (permalink / raw)
  To: Richardson, Bruce, Neil Horman; +Cc: dev

Hi Neil

<snip>
> > > > > +++ b/lib/librte_ether/rte_ethdev.h
> > > > > @@ -1635,8 +1635,23 @@ struct rte_eth_dev_data {
> > > > >  		all_multicast : 1, /**< RX all multicast mode ON(1) /
> OFF(0). */
> > > > >  		dev_started : 1,   /**< Device state: STARTED(1) /
> STOPPED(0). */
> > > > >  		lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
> > > > > +	uint32_t dev_flags; /**< Flags controlling handling of device.
> */
> > > > > +	enum rte_kernel_driver kdrv;	/**< Kernel driver
> passthrough */
> > > > Why add this here? The ennumerated driver types are all variants
> > > > on PCI bus types.  Not sure why the ethernet interface needs to
> > > > know this info
> > > >
> > > > > +	int numa_node;
> > > > Ditto, this seems like information that is only relevant if the
> > > > device is on a physical bus (i.e. virual devices are likely to not
> > > > have a numa node)
> > > >
> > > Actually, I disagree. For some virtual devices they will have a numa
> > > node. For ring or other virtual PMDs the numa node will be the node
> > > on which the ring / mempool etc. memory is allocated on, and can be of
> relevance.
> > >
> > > /Bruce
> > >
> >
> > I think its fairly clear that some devices (including virtual ones)
> > have some relevant relation to a numa_node (There are even some that
> > have no numa_node, for which a -1 value makes some sense).  That said,
> > there are just as many that don't have a relevant numa_node.
> >
> > 1) There are some drivers for which numa_node make no sense
> > (regardless of
> > value):
> >  * af_packet - The numa node is at best determined at run time by the
> > interface the socket is bound to
> >
> >  * pcap - same as af_packet
> >
> >  * bonding - multiple interfaces mean multiple numa_nodes, any value
> > set here is just as likely to be wrong as right
> >
> >  * mpipe - no real large memory area to associate with a numa node
> >
> >  * virtio - uses iopl for communication, and cannot know its numa_node
> >
> >  * vmxnet3 - same concept as virtio
> >
> >  * xenvirt - same as vmxnet3
> >
> > I think its better that you store numa locality information in a pmd's
> > private bus data, and export it to applications via a device method.
> > that provides the flexibility to tell the application that there is no
> > numa locality for a device (by not implementing the method), without
> > having to expose an unset data field to the application.
> >
> > Neil
> >
> 
> Sure, that could work.
> However, is it really worthwhile asking drivers to implement a new ethdev
> API function, rather than just having them set the numa node field correctly
> in the init function?
> 
> /Bruce

The four fields below have been added  to  struct rte_eth_dev_data

	uint32_t dev_flags; /**< Flags controlling handling of device. */
	enum rte_kernel_driver kdrv;	/**< Kernel driver passthrough */
	int numa_node;
	const char *drv_name;

The data for these fields is available in the struct rte_pci_device.
In order to remove the pci_device  from the vdev PMD's this data needs to be available in the eth_dev.
A new function rte_eth_copy_dev_info() has been added to the eth_dev for use by the pdevs to copy this data from the pci_device to the ethdev.
In the vdevs the pci_device has been removed and the new fields are set up directly in the rte_driver.init function.

The numa_node is already initialised  in  the following vdev PMD's:

af_packet - initialized from socket_id
bonding - initialized from socket_id
mpipe - initialized from instance
null   - initialized from socket_id
pcap - initialized from socket_id
ring  - initialized form socket_id
xenvirt - initialized from socket_id

Regards,

Bernard.

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 0/1]  vmxnet3 hotplug support
       [not found] <PATCH>
                   ` (28 preceding siblings ...)
  2015-09-28 13:03 ` [dpdk-dev] [PATCH 00/20] remove pci driver from vdevs Bernard Iremonger
@ 2015-10-01 15:16 ` Bernard Iremonger
  2015-10-01 15:16   ` [dpdk-dev] [PATCH 1/1] vmxnet3: add PCI Port Hotplug support Bernard Iremonger
  2015-10-02  9:08 ` [dpdk-dev] [PATCH 1/2] xenvirt: add support for PCI Port Hotplug Bernard Iremonger
                   ` (11 subsequent siblings)
  41 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-10-01 15:16 UTC (permalink / raw)
  To: dev

add PCI Port Hotplug support to the vmxnet3 PMD


This patch depends on 4 patches from the following patch set:

0000-remove-pci-driver-from-vdevs.patch 

0001-librte_eal-add-RTE_KDRV_NONE-for-vdevs.patch
0002-librte_ether-add-fields-from-rte_pci_driver-to-rte_e.patch
0003-librte_ether-add-function-rte_eth_copy_dev_info.patch
0020-vmxnet3-copy-pci-device-info-to-eth_dev-data.patch

Bernard Iremonger (1):
  vmxnet3: add PCI Port Hotplug support

 drivers/net/vmxnet3/vmxnet3_ethdev.c | 33 +++++++++++++++++++++++++++++----
 1 file changed, 29 insertions(+), 4 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 1/1] vmxnet3: add PCI Port Hotplug support
  2015-10-01 15:16 ` [dpdk-dev] [PATCH 0/1] vmxnet3 hotplug support Bernard Iremonger
@ 2015-10-01 15:16   ` Bernard Iremonger
  0 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-10-01 15:16 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/vmxnet3/vmxnet3_ethdev.c | 33 +++++++++++++++++++++++++++++----
 1 file changed, 29 insertions(+), 4 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c
index 2beee3e..5cd708e 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c
@@ -70,6 +70,7 @@
 #define PROCESS_SYS_EVENTS 0
 
 static int eth_vmxnet3_dev_init(struct rte_eth_dev *eth_dev);
+static int eth_vmxnet3_dev_uninit(struct rte_eth_dev *eth_dev);
 static int vmxnet3_dev_configure(struct rte_eth_dev *dev);
 static int vmxnet3_dev_start(struct rte_eth_dev *dev);
 static void vmxnet3_dev_stop(struct rte_eth_dev *dev);
@@ -296,13 +297,37 @@ eth_vmxnet3_dev_init(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static int
+eth_vmxnet3_dev_uninit(struct rte_eth_dev *eth_dev)
+{
+	struct vmxnet3_hw *hw = eth_dev->data->dev_private;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
+	if (hw->adapter_stopped == 0)
+		vmxnet3_dev_close(eth_dev);
+
+	eth_dev->dev_ops = NULL;
+	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+
+	rte_free(eth_dev->data->mac_addrs);
+	eth_dev->data->mac_addrs = NULL;
+
+	return 0;
+}
+
 static struct eth_driver rte_vmxnet3_pmd = {
 	.pci_drv = {
 		.name = "rte_vmxnet3_pmd",
 		.id_table = pci_id_vmxnet3_map,
-		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
 	},
 	.eth_dev_init = eth_vmxnet3_dev_init,
+	.eth_dev_uninit = eth_vmxnet3_dev_uninit,
 	.dev_private_size = sizeof(struct vmxnet3_hw),
 };
 
@@ -581,7 +606,7 @@ vmxnet3_dev_stop(struct rte_eth_dev *dev)
 
 	PMD_INIT_FUNC_TRACE();
 
-	if (hw->adapter_stopped == TRUE) {
+	if (hw->adapter_stopped == 1) {
 		PMD_INIT_LOG(DEBUG, "Device already closed.");
 		return;
 	}
@@ -597,7 +622,7 @@ vmxnet3_dev_stop(struct rte_eth_dev *dev)
 	/* reset the device */
 	VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD, VMXNET3_CMD_RESET_DEV);
 	PMD_INIT_LOG(DEBUG, "Device reset.");
-	hw->adapter_stopped = FALSE;
+	hw->adapter_stopped = 0;
 
 	vmxnet3_dev_clear_queues(dev);
 
@@ -617,7 +642,7 @@ vmxnet3_dev_close(struct rte_eth_dev *dev)
 	PMD_INIT_FUNC_TRACE();
 
 	vmxnet3_dev_stop(dev);
-	hw->adapter_stopped = TRUE;
+	hw->adapter_stopped = 1;
 }
 
 static void
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 1/2] xenvirt: add support for PCI Port Hotplug
       [not found] <PATCH>
                   ` (29 preceding siblings ...)
  2015-10-01 15:16 ` [dpdk-dev] [PATCH 0/1] vmxnet3 hotplug support Bernard Iremonger
@ 2015-10-02  9:08 ` Bernard Iremonger
  2015-10-02  9:08   ` [dpdk-dev] [PATCH 2/2] xenvirt: free queues in dev_close Bernard Iremonger
  2015-10-02  9:09 ` [dpdk-dev] [PATCH] vhost_xen: fix compile error in main.c Bernard Iremonger
                   ` (10 subsequent siblings)
  41 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-10-02  9:08 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/xenvirt/rte_eth_xenvirt.c | 63 +++++++++++++++++++++++++++++++----
 drivers/net/xenvirt/rte_xen_lib.c     | 26 ++++++++++++---
 drivers/net/xenvirt/rte_xen_lib.h     |  5 ++-
 3 files changed, 83 insertions(+), 11 deletions(-)

diff --git a/drivers/net/xenvirt/rte_eth_xenvirt.c b/drivers/net/xenvirt/rte_eth_xenvirt.c
index b3383af..8923826 100644
--- a/drivers/net/xenvirt/rte_eth_xenvirt.c
+++ b/drivers/net/xenvirt/rte_eth_xenvirt.c
@@ -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
@@ -642,10 +642,14 @@ eth_dev_xenvirt_create(const char *name, const char *params,
 	if (internals == NULL)
 		goto err;
 
-	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
-	if (eth_dev == NULL)
-		goto err;
+	/* find an ethdev entry */
+	eth_dev = rte_eth_dev_allocated(name);
+	if (eth_dev == NULL) {
+		/* reserve an ethdev entry */
+		eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+		if (eth_dev == NULL)
+			goto err;
+	}
 
 	data->dev_private = internals;
 	data->port_id = eth_dev->data->port_id;
@@ -661,7 +665,7 @@ eth_dev_xenvirt_create(const char *name, const char *params,
 
 	eth_dev->data = data;
 	eth_dev->dev_ops = &ops;
-	eth_dev->data->dev_flags = 0;
+	eth_dev->data->dev_flags = RTE_PCI_DRV_DETACHABLE;
 	eth_dev->data->kdrv = RTE_KDRV_NONE;
 	eth_dev->data->drv_name = NULL;
 	eth_dev->driver = NULL;
@@ -683,6 +687,38 @@ err:
 }
 
 
+static int
+eth_dev_xenvirt_free(const char *name, const unsigned numa_node)
+{
+	struct rte_eth_dev *eth_dev = NULL;
+
+	RTE_LOG(DEBUG, PMD,
+		"Free virtio rings backed ethdev on numa socket %u\n",
+		numa_node);
+
+	/* find an ethdev entry */
+	eth_dev = rte_eth_dev_allocated(name);
+	if (eth_dev == NULL)
+		return -1;
+
+	if (eth_dev->data->dev_started == 1) {
+		eth_dev_stop(eth_dev);
+		eth_dev_close(eth_dev);
+	}
+
+	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->tx_pkt_burst = NULL;
+	eth_dev->dev_ops = NULL;
+
+	rte_free(eth_dev->data);
+	rte_free(eth_dev->data->dev_private);
+	rte_free(eth_dev->data->mac_addrs);
+
+	virtio_idx--;
+
+	return 0;
+}
+
 /*TODO: Support multiple process model */
 static int
 rte_pmd_xenvirt_devinit(const char *name, const char *params)
@@ -701,10 +737,25 @@ rte_pmd_xenvirt_devinit(const char *name, const char *params)
 	return 0;
 }
 
+static int
+rte_pmd_xenvirt_devuninit(const char *name)
+{
+	eth_dev_xenvirt_free(name, rte_socket_id());
+
+	if (virtio_idx == 0) {
+		if (xenstore_uninit() != 0)
+			RTE_LOG(ERR, PMD, "%s: xenstore uninit failed\n", __func__);
+
+		gntalloc_close();
+	}
+	return 0;
+}
+
 static struct rte_driver pmd_xenvirt_drv = {
 	.name = "eth_xenvirt",
 	.type = PMD_VDEV,
 	.init = rte_pmd_xenvirt_devinit,
+	.uninit = rte_pmd_xenvirt_devuninit,
 };
 
 PMD_REGISTER_DRIVER(pmd_xenvirt_drv);
diff --git a/drivers/net/xenvirt/rte_xen_lib.c b/drivers/net/xenvirt/rte_xen_lib.c
index b3932f0..5900b53 100644
--- a/drivers/net/xenvirt/rte_xen_lib.c
+++ b/drivers/net/xenvirt/rte_xen_lib.c
@@ -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
@@ -50,6 +50,7 @@
 
 #include <rte_common.h>
 #include <rte_string_fns.h>
+#include <rte_malloc.h>
 
 #include "rte_xen_lib.h"
 
@@ -72,6 +73,8 @@ int gntalloc_fd = -1;
 static char *dompath = NULL;
 /* handle to xenstore read/write operations */
 static struct xs_handle *xs = NULL;
+/* flag to indicate if xenstore cleanup is required */
+static bool is_xenstore_cleaned_up;
 
 /*
  * Reserve a virtual address space.
@@ -275,7 +278,6 @@ xenstore_init(void)
 {
 	unsigned int len, domid;
 	char *buf;
-	static int cleanup = 0;
 	char *end;
 
 	xs = xs_domain_open();
@@ -301,16 +303,32 @@ xenstore_init(void)
 
 	xs_transaction_start(xs); /* When to stop transaction */
 
-	if (cleanup == 0) {
+	if (is_xenstore_cleaned_up == 0) {
 		if (xenstore_cleanup())
 			return -1;
-		cleanup = 1;
+		is_xenstore_cleaned_up = 1;
 	}
 
 	return 0;
 }
 
 int
+xenstore_uninit(void)
+{
+	xs_close(xs);
+
+	if (is_xenstore_cleaned_up == 0) {
+		if (xenstore_cleanup())
+			return -1;
+		is_xenstore_cleaned_up = 1;
+	}
+	free(dompath);
+	dompath = NULL;
+
+	return 0;
+}
+
+int
 xenstore_write(const char *key_str, const char *val_str)
 {
 	char grant_path[PATH_MAX];
diff --git a/drivers/net/xenvirt/rte_xen_lib.h b/drivers/net/xenvirt/rte_xen_lib.h
index 0ba7148..d973eac 100644
--- a/drivers/net/xenvirt/rte_xen_lib.h
+++ b/drivers/net/xenvirt/rte_xen_lib.h
@@ -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
@@ -93,6 +93,9 @@ int
 xenstore_init(void);
 
 int
+xenstore_uninit(void);
+
+int
 xenstore_write(const char *key_str, const char *val_str);
 
 int
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 2/2] xenvirt: free queues in dev_close
  2015-10-02  9:08 ` [dpdk-dev] [PATCH 1/2] xenvirt: add support for PCI Port Hotplug Bernard Iremonger
@ 2015-10-02  9:08   ` Bernard Iremonger
  0 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-10-02  9:08 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/xenvirt/rte_eth_xenvirt.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/net/xenvirt/rte_eth_xenvirt.c b/drivers/net/xenvirt/rte_eth_xenvirt.c
index 8923826..1bf35b7 100644
--- a/drivers/net/xenvirt/rte_eth_xenvirt.c
+++ b/drivers/net/xenvirt/rte_eth_xenvirt.c
@@ -75,6 +75,9 @@ static struct rte_eth_link pmd_link = {
 		.link_status = 0
 };
 
+static void
+eth_xenvirt_free_queues(struct rte_eth_dev *dev);
+
 static inline struct rte_mbuf *
 rte_rxmbuf_alloc(struct rte_mempool *mp)
 {
@@ -326,7 +329,7 @@ eth_dev_stop(struct rte_eth_dev *dev)
 static void
 eth_dev_close(struct rte_eth_dev *dev)
 {
-	RTE_SET_USED(dev);
+	eth_xenvirt_free_queues(dev);
 }
 
 static void
@@ -362,8 +365,9 @@ eth_stats_reset(struct rte_eth_dev *dev)
 }
 
 static void
-eth_queue_release(void *q __rte_unused)
+eth_queue_release(void *q)
 {
+	rte_free(q);
 }
 
 static int
@@ -524,7 +528,23 @@ eth_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 	return 0;
 }
 
+static void
+eth_xenvirt_free_queues(struct rte_eth_dev *dev)
+{
+	int i;
 
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		eth_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++) {
+		eth_queue_release(dev->data->tx_queues[i]);
+		dev->data->tx_queues[i] = NULL;
+	}
+	dev->data->nb_tx_queues = 0;
+}
 
 static const struct eth_dev_ops ops = {
 	.dev_start = eth_dev_start,
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH] vhost_xen: fix compile error in main.c
       [not found] <PATCH>
                   ` (30 preceding siblings ...)
  2015-10-02  9:08 ` [dpdk-dev] [PATCH 1/2] xenvirt: add support for PCI Port Hotplug Bernard Iremonger
@ 2015-10-02  9:09 ` Bernard Iremonger
  2015-10-02  9:20 ` [dpdk-dev] [PATCH 0/2] xenvirt hotplug support Bernard Iremonger
                   ` (9 subsequent siblings)
  41 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-10-02  9:09 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 examples/vhost_xen/main.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/examples/vhost_xen/main.c b/examples/vhost_xen/main.c
index 5d20700..d124be1 100644
--- a/examples/vhost_xen/main.c
+++ b/examples/vhost_xen/main.c
@@ -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
@@ -579,6 +579,7 @@ virtio_dev_rx(struct virtio_net *dev, struct rte_mbuf **pkts, uint32_t count)
 	uint16_t res_base_idx, res_end_idx;
 	uint16_t free_entries;
 	uint8_t success = 0;
+	void *userdata;
 
 	LOG_DEBUG(VHOST_DATA, "(%"PRIu64") virtio_dev_rx()\n", dev->device_fh);
 	vq = dev->virtqueue_rx;
@@ -656,13 +657,14 @@ virtio_dev_rx(struct virtio_net *dev, struct rte_mbuf **pkts, uint32_t count)
 		vq->used->ring[res_cur_idx & (vq->size - 1)].len = packet_len;
 
 		/* Copy mbuf data to buffer */
-		rte_memcpy((void *)(uintptr_t)buff_addr, (const void*)buff->data, rte_pktmbuf_data_len(buff));
+		userdata = rte_pktmbuf_mtod(buff, void *);
+		rte_memcpy((void *)(uintptr_t)buff_addr, userdata, rte_pktmbuf_data_len(buff));
 
 		res_cur_idx++;
 		packet_success++;
 
 		/* mergeable is disabled then a header is required per buffer. */
-		rte_memcpy((void *)(uintptr_t)buff_hdr_addr, (const void*)&virtio_hdr, vq->vhost_hlen);
+		rte_memcpy((void *)(uintptr_t)buff_hdr_addr, (const void *)&virtio_hdr, vq->vhost_hlen);
 		if (res_cur_idx < res_end_idx) {
 			/* Prefetch descriptor index. */
 			rte_prefetch0(&vq->desc[head[packet_success]]);
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH 0/2] xenvirt hotplug support
       [not found] <PATCH>
                   ` (31 preceding siblings ...)
  2015-10-02  9:09 ` [dpdk-dev] [PATCH] vhost_xen: fix compile error in main.c Bernard Iremonger
@ 2015-10-02  9:20 ` Bernard Iremonger
  2015-10-12 16:25 ` [dpdk-dev] [PATCH v3 00/20] remove pci driver from vdevs Bernard Iremonger
                   ` (8 subsequent siblings)
  41 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-10-02  9:20 UTC (permalink / raw)
  To: dev

add PCI Port Hotplug support to the xenvirt PMD


This patch depends on 4 patches from the following patch set:

0000-remove-pci-driver-from-vdevs.patch 

0001-librte_eal-add-RTE_KDRV_NONE-for-vdevs.patch
0002-librte_ether-add-fields-from-rte_pci_driver-to-rte_e.patch
0003-librte_ether-add-function-rte_eth_copy_dev_info.patch
0009-xenvirt-copy-pci-device-info-to-eth_dev-data.patch

Bernard Iremonger (2):
  xenvirt: add support for PCI Port Hotplug
  xenvirt: free queues in dev_close

 drivers/net/xenvirt/rte_eth_xenvirt.c | 87 +++++++++++++++++++++++++++++++----
 drivers/net/xenvirt/rte_xen_lib.c     | 26 +++++++++--
 drivers/net/xenvirt/rte_xen_lib.h     |  5 +-
 3 files changed, 105 insertions(+), 13 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 00/20] remove pci driver from vdevs
       [not found] <PATCH>
                   ` (32 preceding siblings ...)
  2015-10-02  9:20 ` [dpdk-dev] [PATCH 0/2] xenvirt hotplug support Bernard Iremonger
@ 2015-10-12 16:25 ` Bernard Iremonger
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 01/20] librte_eal: add RTE_KDRV_NONE for vdevs Bernard Iremonger
                     ` (19 more replies)
  2015-10-20 15:37 ` [dpdk-dev] [PATCH 1/2] virtio: fixed segmentation fault in queue_release Bernard Iremonger
                   ` (7 subsequent siblings)
  41 siblings, 20 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-10-12 16:25 UTC (permalink / raw)
  To: dev

There is a dummy pci driver in the vdev PMD's at present.
This patch set removes the pci driver from the vdev PMD's.
Changes have been made to librte_ether to handle vdevs and pdevs in the same way.

The following vdev PMD's have had the pci driver removed:

null
ring
bonding
pcap
af_packet
xenvirt
mpipe

All the pdev PMD's have been modified to copy the pci device info into ethdev data.

Changes in v3:
rebase to latest code.
restructure patches 0002 and 0003 to fix compile issue in patch 0002.

Changes in V2:
rebase to latest code.
fix compile error in rte_ethdev.c when debug disabled.
remove intel copyright from bnx2x, cxgbe, enic, mlx4, mpipe and null PMD's.

Bernard Iremonger (17):
  librte_eal: add RTE_KDRV_NONE for vdevs
  librte_ether: add fields from rte_pci_driver to rte_eth_dev_data
  librte_ether: add function rte_eth_copy_dev_info()
  null: remove pci device driver
  ring: remove pci device driver
  bonding: remove pci device driver
  pcap: remove pci device driver
  ixgbe: copy pci device info to eth_dev data
  e1000: copy pci device info to eth_dev data
  i40e: copy pci device info to eth_dev data
  fm10k: copy pci device info to eth_dev data
  bnx2x: copy pci device info to eth_dev data
  cxgbe: copy pci device info to eth_dev data
  enic: copy pci device info to eth_dev data
  mlx4: copy pci device info to eth_dev data
  virtio: copy pci device info to eth_dev data
  vmxnet3: copy pci device info to eth_dev data

David Hunt (3):
  af_packet: remove pci device driver
  xenvirt: remove pci device driver
  mpipe: remove pci device driver

 drivers/net/af_packet/rte_eth_af_packet.c  | 20 +++++------
 drivers/net/bnx2x/bnx2x_ethdev.c           |  3 ++
 drivers/net/bonding/rte_eth_bond_alb.c     |  2 +-
 drivers/net/bonding/rte_eth_bond_api.c     | 58 +++++++++---------------------
 drivers/net/bonding/rte_eth_bond_pmd.c     | 16 ++++-----
 drivers/net/bonding/rte_eth_bond_private.h |  2 +-
 drivers/net/cxgbe/cxgbe_ethdev.c           |  3 ++
 drivers/net/e1000/em_ethdev.c              |  3 ++
 drivers/net/e1000/igb_ethdev.c             |  5 +++
 drivers/net/enic/enic_ethdev.c             |  1 +
 drivers/net/fm10k/fm10k_ethdev.c           |  2 ++
 drivers/net/i40e/i40e_ethdev.c             |  3 ++
 drivers/net/i40e/i40e_ethdev_vf.c          |  2 ++
 drivers/net/ixgbe/ixgbe_ethdev.c           |  4 +++
 drivers/net/mlx4/mlx4.c                    |  3 ++
 drivers/net/mpipe/mpipe_tilegx.c           |  9 +++--
 drivers/net/null/rte_eth_null.c            | 28 ++++-----------
 drivers/net/pcap/rte_eth_pcap.c            | 31 +++++-----------
 drivers/net/ring/rte_eth_ring.c            | 37 +++++--------------
 drivers/net/virtio/virtio_ethdev.c         |  3 ++
 drivers/net/vmxnet3/vmxnet3_ethdev.c       |  2 ++
 drivers/net/xenvirt/rte_eth_xenvirt.c      | 14 +++-----
 lib/librte_eal/common/include/rte_pci.h    |  3 +-
 lib/librte_ether/rte_ethdev.c              | 54 ++++++++++++++++------------
 lib/librte_ether/rte_ethdev.h              | 29 +++++++++++++++
 lib/librte_ether/rte_ether_version.map     |  7 ++++
 26 files changed, 172 insertions(+), 172 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 01/20] librte_eal: add RTE_KDRV_NONE for vdevs
  2015-10-12 16:25 ` [dpdk-dev] [PATCH v3 00/20] remove pci driver from vdevs Bernard Iremonger
@ 2015-10-12 16:25   ` Bernard Iremonger
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 02/20] librte_ether: add fields from rte_pci_driver to rte_eth_dev_data Bernard Iremonger
                     ` (18 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-10-12 16:25 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 lib/librte_eal/common/include/rte_pci.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index 83e3c28..334c12e 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -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
@@ -149,6 +149,7 @@ enum rte_kernel_driver {
 	RTE_KDRV_VFIO,
 	RTE_KDRV_UIO_GENERIC,
 	RTE_KDRV_NIC_UIO,
+	RTE_KDRV_NONE,
 };
 
 /**
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 02/20] librte_ether: add fields from rte_pci_driver to rte_eth_dev_data
  2015-10-12 16:25 ` [dpdk-dev] [PATCH v3 00/20] remove pci driver from vdevs Bernard Iremonger
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 01/20] librte_eal: add RTE_KDRV_NONE for vdevs Bernard Iremonger
@ 2015-10-12 16:25   ` Bernard Iremonger
  2015-10-14 16:28     ` Mcnamara, John
                       ` (2 more replies)
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 03/20] librte_ether: add function rte_eth_copy_dev_info() Bernard Iremonger
                     ` (17 subsequent siblings)
  19 siblings, 3 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-10-12 16:25 UTC (permalink / raw)
  To: dev

add dev_flags to rte_eth_dev_data, add macros for dev_flags.
add kdrv to rte_eth_dev_data.
add numa_node to rte_eth_dev_data.
add drv_name to rte_eth_dev_data.
use dev_type to distinguish between vdev's and pdev's.
remove pci_dev branches.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 40 +++++++++++++++++-----------------------
 lib/librte_ether/rte_ethdev.h | 15 +++++++++++++++
 2 files changed, 32 insertions(+), 23 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index f593f6e..4187595 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -424,7 +424,7 @@ rte_eth_dev_socket_id(uint8_t port_id)
 {
 	if (!rte_eth_dev_is_valid_port(port_id))
 		return -1;
-	return rte_eth_devices[port_id].pci_dev->numa_node;
+	return rte_eth_devices[port_id].data->numa_node;
 }
 
 uint8_t
@@ -503,27 +503,25 @@ rte_eth_dev_get_name_by_port(uint8_t port_id, char *name)
 static int
 rte_eth_dev_is_detachable(uint8_t port_id)
 {
-	uint32_t drv_flags;
+	uint32_t dev_flags;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
 		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -EINVAL;
 	}
 
-	if (rte_eth_devices[port_id].dev_type == RTE_ETH_DEV_PCI) {
-		switch (rte_eth_devices[port_id].pci_dev->kdrv) {
-		case RTE_KDRV_IGB_UIO:
-		case RTE_KDRV_UIO_GENERIC:
-		case RTE_KDRV_NIC_UIO:
-			break;
-		case RTE_KDRV_VFIO:
-		default:
-			return -ENOTSUP;
-		}
+	switch (rte_eth_devices[port_id].data->kdrv) {
+	case RTE_KDRV_IGB_UIO:
+	case RTE_KDRV_UIO_GENERIC:
+	case RTE_KDRV_NIC_UIO:
+	case RTE_KDRV_NONE:
+		break;
+	case RTE_KDRV_VFIO:
+	default:
+		return -ENOTSUP;
 	}
-
-	drv_flags = rte_eth_devices[port_id].driver->pci_drv.drv_flags;
-	return !(drv_flags & RTE_PCI_DRV_DETACHABLE);
+	dev_flags = rte_eth_devices[port_id].data->dev_flags;
+	return !(dev_flags & RTE_ETH_DEV_DETACHABLE);
 }
 
 /* attach the new physical device, then store port_id of the device */
@@ -1143,14 +1141,11 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	 * If link state interrupt is enabled, check that the
 	 * device supports it.
 	 */
-	if (dev_conf->intr_conf.lsc == 1) {
-		const struct rte_pci_driver *pci_drv = &dev->driver->pci_drv;
-
-		if (!(pci_drv->drv_flags & RTE_PCI_DRV_INTR_LSC)) {
+	if ((dev_conf->intr_conf.lsc == 1) &&
+		(!(dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC))) {
 			PMD_DEBUG_TRACE("driver %s does not support lsc\n",
-					pci_drv->name);
+					dev->data->drv_name);
 			return -EINVAL;
-		}
 	}
 
 	/*
@@ -1795,8 +1790,7 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 	FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
 	(*dev->dev_ops->dev_infos_get)(dev, dev_info);
 	dev_info->pci_dev = dev->pci_dev;
-	if (dev->driver)
-		dev_info->driver_name = dev->driver->pci_drv.name;
+	dev_info->driver_name = dev->data->drv_name;
 }
 
 void
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 8a8c82b..d440bd6 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1471,8 +1471,23 @@ struct rte_eth_dev_data {
 		all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
 		dev_started : 1,   /**< Device state: STARTED(1) / STOPPED(0). */
 		lro         : 1;   /**< RX LRO is ON(1) / OFF(0) */
+	uint32_t dev_flags; /**< Flags controlling handling of device. */
+	enum rte_kernel_driver kdrv;	/**< Kernel driver passthrough */
+	int numa_node;
+	const char *drv_name;
 };
 
+/** Device needs PCI BAR mapping (done with either IGB_UIO or VFIO) */
+#define RTE_ETH_DEV_DRV_NEED_MAPPING	RTE_PCI_DRV_NEED_MAPPING
+/** Device needs to be unbound even if no module is provided */
+#define RTE_ETH_DEV_DRV_FORCE_UNBIND	RTE_PCI_DRV_FORCE_UNBIND
+/** Device supports link state interrupt */
+#define RTE_ETH_DEV_INTR_LSC	RTE_PCI_DRV_INTR_LSC
+/** Device  supports detaching capability */
+#define RTE_ETH_DEV_DETACHABLE	RTE_PCI_DRV_DETACHABLE
+/** Device  is a bonded device */
+#define RTE_ETH_DEV_BONDED	0x0020
+
 /**
  * @internal
  * The pool of *rte_eth_dev* structures. The size of the pool
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 03/20] librte_ether: add function rte_eth_copy_dev_info()
  2015-10-12 16:25 ` [dpdk-dev] [PATCH v3 00/20] remove pci driver from vdevs Bernard Iremonger
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 01/20] librte_eal: add RTE_KDRV_NONE for vdevs Bernard Iremonger
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 02/20] librte_ether: add fields from rte_pci_driver to rte_eth_dev_data Bernard Iremonger
@ 2015-10-12 16:25   ` Bernard Iremonger
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 04/20] null: remove pci device driver Bernard Iremonger
                     ` (16 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-10-12 16:25 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 lib/librte_ether/rte_ethdev.c          | 14 ++++++++++++++
 lib/librte_ether/rte_ethdev.h          | 14 ++++++++++++++
 lib/librte_ether/rte_ether_version.map |  7 +++++++
 3 files changed, 35 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 4187595..2fce370 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3336,3 +3336,17 @@ rte_eth_dev_set_eeprom(uint8_t port_id, struct rte_dev_eeprom_info *info)
 	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_eeprom, -ENOTSUP);
 	return (*dev->dev_ops->set_eeprom)(dev, info);
 }
+
+void
+rte_eth_copy_dev_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_dev)
+{
+	if ((eth_dev == NULL) || (pci_dev == NULL)) {
+		PMD_DEBUG_TRACE("NULL pointer eth_dev=%p pci_dev=%p\n",
+				eth_dev, pci_dev);
+	}
+
+	eth_dev->data->dev_flags = pci_dev->driver->drv_flags;
+	eth_dev->data->kdrv = pci_dev->kdrv;
+	eth_dev->data->numa_node = pci_dev->numa_node;
+	eth_dev->data->drv_name = pci_dev->driver->name;
+}
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index d440bd6..815e2fc 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -3613,6 +3613,20 @@ extern int rte_eth_timesync_read_rx_timestamp(uint8_t port_id,
 extern int rte_eth_timesync_read_tx_timestamp(uint8_t port_id,
 					      struct timespec *timestamp);
 
+/**
+ * Copy pci device info to the Ethernet device data.
+ *
+ * @param eth_dev
+ * The *eth_dev* pointer is the address of the *rte_eth_dev* structure.
+ * @param pci_dev
+ * The *pci_dev* pointer is the address of the *rte_pci_device* structure.
+ *
+ * @return
+ *   - 0 on success, negative on error
+ */
+extern void rte_eth_copy_dev_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_dev);
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index 8345a6c..e6a43be 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -127,3 +127,10 @@ DPDK_2.1 {
 	rte_eth_timesync_read_tx_timestamp;
 
 } DPDK_2.0;
+
+DPDK_2.2 {
+	global:
+
+	rte_eth_copy_dev_info;
+
+} DPDK_2.1;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 04/20] null: remove pci device driver
  2015-10-12 16:25 ` [dpdk-dev] [PATCH v3 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (2 preceding siblings ...)
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 03/20] librte_ether: add function rte_eth_copy_dev_info() Bernard Iremonger
@ 2015-10-12 16:25   ` Bernard Iremonger
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 05/20] ring: " Bernard Iremonger
                     ` (15 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-10-12 16:25 UTC (permalink / raw)
  To: dev

remove rte_null_pmd and pci_dev.
initialise dev_flags, driver, drv_name, kdrv and numa_node fields in eth_dev data

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/null/rte_eth_null.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index e244595..fb7473f 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -340,13 +340,6 @@ eth_stats_reset(struct rte_eth_dev *dev)
 	}
 }
 
-static struct eth_driver rte_null_pmd = {
-	.pci_drv = {
-		.name = "rte_null_pmd",
-		.drv_flags = RTE_PCI_DRV_DETACHABLE,
-	},
-};
-
 static void
 eth_queue_release(void *q)
 {
@@ -386,7 +379,6 @@ eth_dev_null_create(const char *name,
 	const unsigned nb_rx_queues = 1;
 	const unsigned nb_tx_queues = 1;
 	struct rte_eth_dev_data *data = NULL;
-	struct rte_pci_device *pci_dev = NULL;
 	struct pmd_internals *internals = NULL;
 	struct rte_eth_dev *eth_dev = NULL;
 
@@ -403,10 +395,6 @@ eth_dev_null_create(const char *name,
 	if (data == NULL)
 		goto error;
 
-	pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, numa_node);
-	if (pci_dev == NULL)
-		goto error;
-
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, numa_node);
 	if (internals == NULL)
 		goto error;
@@ -418,8 +406,7 @@ eth_dev_null_create(const char *name,
 
 	/* now put it all together
 	 * - store queue data in internals,
-	 * - store numa_node info in pci_driver
-	 * - point eth_dev_data to internals and pci_driver
+	 * - point eth_dev_data to internals
 	 * - and point eth_dev structure to new eth_dev_data structure
 	 */
 	/* NOTE: we'll replace the data element, of originally allocated eth_dev
@@ -431,8 +418,6 @@ eth_dev_null_create(const char *name,
 	internals->packet_copy = packet_copy;
 	internals->numa_node = numa_node;
 
-	pci_dev->numa_node = numa_node;
-
 	data->dev_private = internals;
 	data->port_id = eth_dev->data->port_id;
 	data->nb_rx_queues = (uint16_t)nb_rx_queues;
@@ -443,8 +428,11 @@ eth_dev_null_create(const char *name,
 
 	eth_dev->data = data;
 	eth_dev->dev_ops = &ops;
-	eth_dev->pci_dev = pci_dev;
-	eth_dev->driver = &rte_null_pmd;
+	eth_dev->driver = NULL;
+	eth_dev->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
+	eth_dev->data->kdrv = RTE_KDRV_NONE;
+	eth_dev->data->drv_name = NULL;
+	eth_dev->data->numa_node = numa_node;
 
 	/* finally assign rx and tx ops */
 	if (packet_copy) {
@@ -459,7 +447,6 @@ eth_dev_null_create(const char *name,
 
 error:
 	rte_free(data);
-	rte_free(pci_dev);
 	rte_free(internals);
 
 	return -1;
@@ -562,14 +549,13 @@ rte_pmd_null_devuninit(const char *name)
 	RTE_LOG(INFO, PMD, "Closing null ethdev on numa socket %u\n",
 			rte_socket_id());
 
-	/* reserve an ethdev entry */
+	/* find the ethdev entry */
 	eth_dev = rte_eth_dev_allocated(name);
 	if (eth_dev == NULL)
 		return -1;
 
 	rte_free(eth_dev->data->dev_private);
 	rte_free(eth_dev->data);
-	rte_free(eth_dev->pci_dev);
 
 	rte_eth_dev_release_port(eth_dev);
 
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 05/20] ring: remove pci device driver
  2015-10-12 16:25 ` [dpdk-dev] [PATCH v3 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (3 preceding siblings ...)
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 04/20] null: remove pci device driver Bernard Iremonger
@ 2015-10-12 16:25   ` Bernard Iremonger
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 06/20] bonding: " Bernard Iremonger
                     ` (14 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-10-12 16:25 UTC (permalink / raw)
  To: dev

remove rte_ring_pmd and pci_dev.
initialise dev_flags, driver, drv_name, kdrv and numa_node fields in eth_dev data.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/ring/rte_eth_ring.c | 37 ++++++++-----------------------------
 1 file changed, 8 insertions(+), 29 deletions(-)

diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index 0ba36d5..65608b2 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -44,8 +44,6 @@
 #define ETH_RING_ACTION_CREATE		"CREATE"
 #define ETH_RING_ACTION_ATTACH		"ATTACH"
 
-static const char *ring_ethdev_driver_name = "Ring PMD";
-
 static const char *valid_arguments[] = {
 	ETH_RING_NUMA_NODE_ACTION_ARG,
 	NULL
@@ -252,15 +250,6 @@ static const struct eth_dev_ops ops = {
 	.mac_addr_add = eth_mac_addr_add,
 };
 
-static struct eth_driver rte_ring_pmd = {
-	.pci_drv = {
-		.name = "rte_ring_pmd",
-		.drv_flags = RTE_PCI_DRV_DETACHABLE,
-	},
-};
-
-static struct rte_pci_id id_table;
-
 int
 rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 		const unsigned nb_rx_queues,
@@ -269,7 +258,6 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 		const unsigned numa_node)
 {
 	struct rte_eth_dev_data *data = NULL;
-	struct rte_pci_device *pci_dev = NULL;
 	struct pmd_internals *internals = NULL;
 	struct rte_eth_dev *eth_dev = NULL;
 
@@ -291,10 +279,6 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 	if (data == NULL)
 		goto error;
 
-	pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, numa_node);
-	if (pci_dev == NULL)
-		goto error;
-
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, numa_node);
 	if (internals == NULL)
 		goto error;
@@ -304,11 +288,10 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 	if (eth_dev == NULL)
 		goto error;
 
-
 	/* now put it all together
 	 * - store queue data in internals,
-	 * - store numa_node info in pci_driver
-	 * - point eth_dev_data to internals and pci_driver
+	 * - store numa_node info in eth_dev_data
+	 * - point eth_dev_data to internals
 	 * - and point eth_dev structure to new eth_dev_data structure
 	 */
 	/* NOTE: we'll replace the data element, of originally allocated eth_dev
@@ -323,12 +306,6 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 		internals->tx_ring_queues[i].rng = tx_queues[i];
 	}
 
-	rte_ring_pmd.pci_drv.name = ring_ethdev_driver_name;
-	rte_ring_pmd.pci_drv.id_table = &id_table;
-
-	pci_dev->numa_node = numa_node;
-	pci_dev->driver = &rte_ring_pmd.pci_drv;
-
 	data->dev_private = internals;
 	data->port_id = eth_dev->data->port_id;
 	memmove(data->name, eth_dev->data->name, sizeof(data->name));
@@ -338,9 +315,13 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 	data->mac_addrs = &internals->address;
 
 	eth_dev->data = data;
-	eth_dev->driver = &rte_ring_pmd;
+	eth_dev->driver = NULL;
 	eth_dev->dev_ops = &ops;
-	eth_dev->pci_dev = pci_dev;
+	eth_dev->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
+	eth_dev->data->kdrv = RTE_KDRV_NONE;
+	eth_dev->data->drv_name = NULL;
+	eth_dev->data->numa_node = numa_node;
+
 	TAILQ_INIT(&(eth_dev->link_intr_cbs));
 
 	/* finally assign rx and tx ops */
@@ -351,7 +332,6 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 
 error:
 	rte_free(data);
-	rte_free(pci_dev);
 	rte_free(internals);
 
 	return -1;
@@ -561,7 +541,6 @@ rte_pmd_ring_devuninit(const char *name)
 	eth_dev_stop(eth_dev);
 	rte_free(eth_dev->data->dev_private);
 	rte_free(eth_dev->data);
-	rte_free(eth_dev->pci_dev);
 
 	rte_eth_dev_release_port(eth_dev);
 	return 0;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 06/20] bonding: remove pci device driver
  2015-10-12 16:25 ` [dpdk-dev] [PATCH v3 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (4 preceding siblings ...)
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 05/20] ring: " Bernard Iremonger
@ 2015-10-12 16:25   ` Bernard Iremonger
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 07/20] pcap: " Bernard Iremonger
                     ` (13 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-10-12 16:25 UTC (permalink / raw)
  To: dev

remove pci_dev, pci_drv, rte_bond_pmd and pci_id_table.
initialise dev_flags, kdrv, driver, drv_name and numa_node fields in eth_dev data.
handle numa_node for vdevs
handle RTE_ETH_DEV_INTR_LSC for vdevs
rename valid_bonded_device to check_for_bonded_device

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/bonding/rte_eth_bond_alb.c     |  2 +-
 drivers/net/bonding/rte_eth_bond_api.c     | 58 +++++++++---------------------
 drivers/net/bonding/rte_eth_bond_pmd.c     | 16 ++++-----
 drivers/net/bonding/rte_eth_bond_private.h |  2 +-
 4 files changed, 26 insertions(+), 52 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_alb.c b/drivers/net/bonding/rte_eth_bond_alb.c
index 6df318e..3157543 100644
--- a/drivers/net/bonding/rte_eth_bond_alb.c
+++ b/drivers/net/bonding/rte_eth_bond_alb.c
@@ -65,7 +65,7 @@ bond_mode_alb_enable(struct rte_eth_dev *bond_dev)
 
 	uint16_t data_size;
 	char mem_name[RTE_ETH_NAME_MAX_LEN];
-	int socket_id = bond_dev->pci_dev->numa_node;
+	int socket_id = bond_dev->data->numa_node;
 
 	/* Fill hash table with initial values */
 	memset(hash_table, 0, sizeof(struct client_data) * ALB_HASH_TABLE_SIZE);
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index 0681d1a..55f028f 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -45,14 +45,17 @@
 #define DEFAULT_POLLING_INTERVAL_10_MS (10)
 
 int
-valid_bonded_ethdev(const struct rte_eth_dev *eth_dev)
+check_for_bonded_ethdev(const struct rte_eth_dev *eth_dev)
 {
 	/* Check valid pointer */
-	if (eth_dev->driver->pci_drv.name == NULL)
+	if (!eth_dev)
 		return -1;
 
-	/* return 0 if driver name matches */
-	return eth_dev->driver->pci_drv.name != pmd_bond_driver_name;
+	/* return 0 if bonded device */
+	if (eth_dev->data->dev_flags & RTE_ETH_DEV_BONDED)
+		return 0;
+	else
+		return 1;
 }
 
 int
@@ -61,7 +64,7 @@ valid_bonded_port_id(uint8_t port_id)
 	if (!rte_eth_dev_is_valid_port(port_id))
 		return -1;
 
-	return valid_bonded_ethdev(&rte_eth_devices[port_id]);
+	return check_for_bonded_ethdev(&rte_eth_devices[port_id]);
 }
 
 int
@@ -72,7 +75,7 @@ valid_slave_port_id(uint8_t port_id)
 		return -1;
 
 	/* Verify that port_id refers to a non bonded port */
-	if (!valid_bonded_ethdev(&rte_eth_devices[port_id]))
+	if (check_for_bonded_ethdev(&rte_eth_devices[port_id]) == 0)
 		return -1;
 
 	return 0;
@@ -163,30 +166,11 @@ number_of_sockets(void)
 	return ++sockets;
 }
 
-const char pmd_bond_driver_name[] = "rte_bond_pmd";
-
-static struct rte_pci_id pci_id_table = {
-	.device_id = PCI_ANY_ID,
-	.subsystem_device_id = PCI_ANY_ID,
-	.vendor_id = PCI_ANY_ID,
-	.subsystem_vendor_id = PCI_ANY_ID,
-};
-
-static struct eth_driver rte_bond_pmd = {
-	.pci_drv = {
-		.name = pmd_bond_driver_name,
-		.drv_flags = RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_DETACHABLE,
-		.id_table = &pci_id_table,
-	},
-};
-
 int
 rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 {
-	struct rte_pci_device *pci_dev = NULL;
 	struct bond_dev_private *internals = NULL;
 	struct rte_eth_dev *eth_dev = NULL;
-	struct rte_pci_driver *pci_drv = NULL;
 
 	/* now do all data allocation - for eth_dev structure, dummy pci driver
 	 * and internal (private) data
@@ -203,14 +187,6 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 		goto err;
 	}
 
-	pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, socket_id);
-	if (pci_dev == NULL) {
-		RTE_BOND_LOG(ERR, "Unable to malloc pci dev on socket");
-		goto err;
-	}
-
-	pci_drv = &rte_bond_pmd.pci_drv;
-
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
 	if (internals == NULL) {
 		RTE_BOND_LOG(ERR, "Unable to malloc internals on socket");
@@ -224,11 +200,6 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 		goto err;
 	}
 
-	pci_dev->numa_node = socket_id;
-	pci_drv->name = pmd_bond_driver_name;
-	pci_dev->driver = pci_drv;
-
-	eth_dev->driver = &rte_bond_pmd;
 	eth_dev->data->dev_private = internals;
 	eth_dev->data->nb_rx_queues = (uint16_t)1;
 	eth_dev->data->nb_tx_queues = (uint16_t)1;
@@ -250,7 +221,12 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	eth_dev->data->all_multicast = 0;
 
 	eth_dev->dev_ops = &default_dev_ops;
-	eth_dev->pci_dev = pci_dev;
+	eth_dev->data->dev_flags = RTE_ETH_DEV_INTR_LSC |
+		RTE_ETH_DEV_DETACHABLE | RTE_ETH_DEV_BONDED;
+	eth_dev->driver = NULL;
+	eth_dev->data->kdrv = RTE_KDRV_NONE;
+	eth_dev->data->drv_name = NULL;
+	eth_dev->data->numa_node =  socket_id;
 
 	rte_spinlock_init(&internals->lock);
 
@@ -287,7 +263,6 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	return eth_dev->data->port_id;
 
 err:
-	rte_free(pci_dev);
 	rte_free(internals);
 	if (eth_dev != NULL) {
 		rte_free(eth_dev->data->mac_addrs);
@@ -319,7 +294,6 @@ rte_eth_bond_free(const char *name)
 	eth_dev->rx_pkt_burst = NULL;
 	eth_dev->tx_pkt_burst = NULL;
 
-	rte_free(eth_dev->pci_dev);
 	rte_free(eth_dev->data->dev_private);
 	rte_free(eth_dev->data->mac_addrs);
 
@@ -348,7 +322,7 @@ __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
 	/* Verify that new slave device is not already a slave of another
 	 * bonded device */
 	for (i = rte_eth_dev_count()-1; i >= 0; i--) {
-		if (valid_bonded_ethdev(&rte_eth_devices[i]) == 0) {
+		if (check_for_bonded_ethdev(&rte_eth_devices[i]) == 0) {
 			temp_internals = rte_eth_devices[i].data->dev_private;
 
 			for (j = 0; j < temp_internals->slave_count; j++) {
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 5cc6372..f4f29c5 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -1307,7 +1307,7 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
 	rte_eth_dev_stop(slave_eth_dev->data->port_id);
 
 	/* Enable interrupts on slave device if supported */
-	if (slave_eth_dev->driver->pci_drv.drv_flags & RTE_PCI_DRV_INTR_LSC)
+	if (slave_eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
 		slave_eth_dev->data->dev_conf.intr_conf.lsc = 1;
 
 	/* Configure device */
@@ -1362,9 +1362,9 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
 	}
 
 	/* If lsc interrupt is set, check initial slave's link status */
-	if (slave_eth_dev->driver->pci_drv.drv_flags & RTE_PCI_DRV_INTR_LSC)
+	if (slave_eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
 		bond_ethdev_lsc_event_callback(slave_eth_dev->data->port_id,
-				RTE_ETH_EVENT_INTR_LSC, &bonded_eth_dev->data->port_id);
+			RTE_ETH_EVENT_INTR_LSC, &bonded_eth_dev->data->port_id);
 
 	return 0;
 }
@@ -1447,7 +1447,7 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
 	int i;
 
 	/* slave eth dev will be started by bonded device */
-	if (valid_bonded_ethdev(eth_dev)) {
+	if (check_for_bonded_ethdev(eth_dev)) {
 		RTE_BOND_LOG(ERR, "User tried to explicitly start a slave eth_dev (%d)",
 				eth_dev->data->port_id);
 		return -1;
@@ -1592,7 +1592,7 @@ bond_ethdev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->max_tx_queues = (uint16_t)512;
 
 	dev_info->min_rx_bufsize = 0;
-	dev_info->pci_dev = dev->pci_dev;
+	dev_info->pci_dev = NULL;
 
 	dev_info->rx_offload_capa = internals->rx_offload_capa;
 	dev_info->tx_offload_capa = internals->tx_offload_capa;
@@ -1605,7 +1605,7 @@ bond_ethdev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
 {
 	struct bond_rx_queue *bd_rx_q = (struct bond_rx_queue *)
 			rte_zmalloc_socket(NULL, sizeof(struct bond_rx_queue),
-					0, dev->pci_dev->numa_node);
+					0, dev->data->numa_node);
 	if (bd_rx_q == NULL)
 		return -1;
 
@@ -1629,7 +1629,7 @@ bond_ethdev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 {
 	struct bond_tx_queue *bd_tx_q  = (struct bond_tx_queue *)
 			rte_zmalloc_socket(NULL, sizeof(struct bond_tx_queue),
-					0, dev->pci_dev->numa_node);
+					0, dev->data->numa_node);
 
 	if (bd_tx_q == NULL)
 		return -1;
@@ -1873,7 +1873,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 	bonded_eth_dev = &rte_eth_devices[*(uint8_t *)param];
 	slave_eth_dev = &rte_eth_devices[port_id];
 
-	if (valid_bonded_ethdev(bonded_eth_dev))
+	if (check_for_bonded_ethdev(bonded_eth_dev))
 		return;
 
 	internals = bonded_eth_dev->data->dev_private;
diff --git a/drivers/net/bonding/rte_eth_bond_private.h b/drivers/net/bonding/rte_eth_bond_private.h
index 038bca6..82dadfc 100644
--- a/drivers/net/bonding/rte_eth_bond_private.h
+++ b/drivers/net/bonding/rte_eth_bond_private.h
@@ -162,7 +162,7 @@ struct bond_dev_private {
 extern struct eth_dev_ops default_dev_ops;
 
 int
-valid_bonded_ethdev(const struct rte_eth_dev *eth_dev);
+check_for_bonded_ethdev(const struct rte_eth_dev *eth_dev);
 
 /* Search given slave array to find possition of given id.
  * Return slave pos or slaves_count if not found. */
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 07/20] pcap: remove pci device driver
  2015-10-12 16:25 ` [dpdk-dev] [PATCH v3 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (5 preceding siblings ...)
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 06/20] bonding: " Bernard Iremonger
@ 2015-10-12 16:25   ` Bernard Iremonger
  2015-10-14 16:31     ` Mcnamara, John
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 08/20] af_packet: " Bernard Iremonger
                     ` (12 subsequent siblings)
  19 siblings, 1 reply; 270+ messages in thread
From: Bernard Iremonger @ 2015-10-12 16:25 UTC (permalink / raw)
  To: dev

remove rte_pcap_pmd and pci_dev.
initialise dev_flags, driver, drv_name, kdrv and numa_node fields in eth_dev data

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/pcap/rte_eth_pcap.c | 31 +++++++++----------------------
 1 file changed, 9 insertions(+), 22 deletions(-)

diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index f2e4634..5f416f4 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -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.
  *
@@ -617,13 +617,6 @@ static const struct eth_dev_ops ops = {
 	.stats_reset = eth_stats_reset,
 };
 
-static struct eth_driver rte_pcap_pmd = {
-	.pci_drv = {
-		.name = "rte_pcap_pmd",
-		.drv_flags = RTE_PCI_DRV_DETACHABLE,
-	},
-};
-
 /*
  * Function handler that opens the pcap file for reading a stores a
  * reference of it for use it later on.
@@ -806,7 +799,6 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues,
 		struct rte_kvargs *kvlist)
 {
 	struct rte_eth_dev_data *data = NULL;
-	struct rte_pci_device *pci_dev = NULL;
 	unsigned k_idx;
 	struct rte_kvargs_pair *pair = NULL;
 
@@ -819,17 +811,13 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues,
 	RTE_LOG(INFO, PMD,
 			"Creating pcap-backed ethdev on numa socket %u\n", numa_node);
 
-	/* now do all data allocation - for eth_dev structure, dummy pci driver
+	/* now do all data allocation - for eth_dev structure
 	 * and internal (private) data
 	 */
 	data = rte_zmalloc_socket(name, sizeof(*data), 0, numa_node);
 	if (data == NULL)
 		goto error;
 
-	pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, numa_node);
-	if (pci_dev == NULL)
-		goto error;
-
 	*internals = rte_zmalloc_socket(name, sizeof(**internals), 0, numa_node);
 	if (*internals == NULL)
 		goto error;
@@ -845,8 +833,8 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues,
 
 	/* now put it all together
 	 * - store queue data in internals,
-	 * - store numa_node info in pci_driver
-	 * - point eth_dev_data to internals and pci_driver
+	 * - store numa_node info in eth_dev
+	 * - point eth_dev_data to internals
 	 * - and point eth_dev structure to new eth_dev_data structure
 	 */
 	/* NOTE: we'll replace the data element, of originally allocated eth_dev
@@ -860,8 +848,6 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues,
 	else
 		(*internals)->if_index = if_nametoindex(pair->value);
 
-	pci_dev->numa_node = numa_node;
-
 	data->dev_private = *internals;
 	data->port_id = (*eth_dev)->data->port_id;
 	snprintf(data->name, sizeof(data->name), "%s", (*eth_dev)->data->name);
@@ -874,14 +860,16 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues,
 
 	(*eth_dev)->data = data;
 	(*eth_dev)->dev_ops = &ops;
-	(*eth_dev)->pci_dev = pci_dev;
-	(*eth_dev)->driver = &rte_pcap_pmd;
+	(*eth_dev)->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
+	(*eth_dev)->driver = NULL;
+	(*eth_dev)->data->kdrv = RTE_KDRV_NONE;
+	(*eth_dev)->data->drv_name = NULL;
+	(*eth_dev)->data->numa_node = numa_node;
 
 	return 0;
 
 error:
 	rte_free(data);
-	rte_free(pci_dev);
 	rte_free(*internals);
 
 	return -1;
@@ -1096,7 +1084,6 @@ rte_pmd_pcap_devuninit(const char *name)
 
 	rte_free(eth_dev->data->dev_private);
 	rte_free(eth_dev->data);
-	rte_free(eth_dev->pci_dev);
 
 	rte_eth_dev_release_port(eth_dev);
 
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 08/20] af_packet: remove pci device driver
  2015-10-12 16:25 ` [dpdk-dev] [PATCH v3 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (6 preceding siblings ...)
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 07/20] pcap: " Bernard Iremonger
@ 2015-10-12 16:25   ` Bernard Iremonger
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 09/20] xenvirt: " Bernard Iremonger
                     ` (11 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-10-12 16:25 UTC (permalink / raw)
  To: dev

From: David Hunt <david.hunt@intel.com>

initialise dev_flags, driver, kdrv, drv_name and numa_node fileds in eth_dev data.

Signed-off-by: David Hunt <david.hunt@intel.com>
Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/af_packet/rte_eth_af_packet.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index bdd9628..7c3c455 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -5,7 +5,7 @@
  *
  *   Originally based upon librte_pmd_pcap code:
  *
- *   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.
  *
@@ -431,7 +431,6 @@ rte_pmd_init_internals(const char *name,
                        struct rte_kvargs *kvlist)
 {
 	struct rte_eth_dev_data *data = NULL;
-	struct rte_pci_device *pci_dev = NULL;
 	struct rte_kvargs_pair *pair = NULL;
 	struct ifreq ifr;
 	size_t ifnamelen;
@@ -469,10 +468,6 @@ rte_pmd_init_internals(const char *name,
 	if (data == NULL)
 		goto error;
 
-	pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, numa_node);
-	if (pci_dev == NULL)
-		goto error;
-
 	*internals = rte_zmalloc_socket(name, sizeof(**internals),
 	                                0, numa_node);
 	if (*internals == NULL)
@@ -655,8 +650,8 @@ rte_pmd_init_internals(const char *name,
 	/*
 	 * now put it all together
 	 * - store queue data in internals,
-	 * - store numa_node info in pci_driver
-	 * - point eth_dev_data to internals and pci_driver
+	 * - store numa_node info in eth_dev
+	 * - point eth_dev_data to internals
 	 * - and point eth_dev structure to new eth_dev_data structure
 	 */
 
@@ -669,17 +664,18 @@ rte_pmd_init_internals(const char *name,
 	data->dev_link = pmd_link;
 	data->mac_addrs = &(*internals)->eth_addr;
 
-	pci_dev->numa_node = numa_node;
-
 	(*eth_dev)->data = data;
 	(*eth_dev)->dev_ops = &ops;
-	(*eth_dev)->pci_dev = pci_dev;
+	(*eth_dev)->data->dev_flags = 0;
+	(*eth_dev)->driver = NULL;
+	(*eth_dev)->data->drv_name = NULL;
+	(*eth_dev)->data->kdrv = RTE_KDRV_NONE;
+	(*eth_dev)->data->numa_node = numa_node;
 
 	return 0;
 
 error:
 	rte_free(data);
-	rte_free(pci_dev);
 
 	if (*internals) {
 		for (q = 0; q < nb_queues; q++) {
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 09/20] xenvirt: remove pci device driver
  2015-10-12 16:25 ` [dpdk-dev] [PATCH v3 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (7 preceding siblings ...)
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 08/20] af_packet: " Bernard Iremonger
@ 2015-10-12 16:25   ` Bernard Iremonger
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 10/20] mpipe: " Bernard Iremonger
                     ` (10 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-10-12 16:25 UTC (permalink / raw)
  To: dev

From: David Hunt <david.hunt@intel.com>

Initialise dev_flags, driver, kdrv, drv_name and numa_node in eth_dev data.

Signed-off-by: David Hunt <david.hunt@intel.com>
Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/xenvirt/rte_eth_xenvirt.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/net/xenvirt/rte_eth_xenvirt.c b/drivers/net/xenvirt/rte_eth_xenvirt.c
index 73e8bce..b3383af 100644
--- a/drivers/net/xenvirt/rte_eth_xenvirt.c
+++ b/drivers/net/xenvirt/rte_eth_xenvirt.c
@@ -617,7 +617,6 @@ eth_dev_xenvirt_create(const char *name, const char *params,
                 enum dev_action action)
 {
 	struct rte_eth_dev_data *data = NULL;
-	struct rte_pci_device *pci_dev = NULL;
 	struct pmd_internals *internals = NULL;
 	struct rte_eth_dev *eth_dev = NULL;
 	struct xenvirt_dict dict;
@@ -639,10 +638,6 @@ eth_dev_xenvirt_create(const char *name, const char *params,
 	if (data == NULL)
 		goto err;
 
-	pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, numa_node);
-	if (pci_dev == NULL)
-		goto err;
-
 	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, numa_node);
 	if (internals == NULL)
 		goto err;
@@ -652,8 +647,6 @@ eth_dev_xenvirt_create(const char *name, const char *params,
 	if (eth_dev == NULL)
 		goto err;
 
-	pci_dev->numa_node = numa_node;
-
 	data->dev_private = internals;
 	data->port_id = eth_dev->data->port_id;
 	data->nb_rx_queues = (uint16_t)1;
@@ -668,7 +661,11 @@ eth_dev_xenvirt_create(const char *name, const char *params,
 
 	eth_dev->data = data;
 	eth_dev->dev_ops = &ops;
-	eth_dev->pci_dev = pci_dev;
+	eth_dev->data->dev_flags = 0;
+	eth_dev->data->kdrv = RTE_KDRV_NONE;
+	eth_dev->data->drv_name = NULL;
+	eth_dev->driver = NULL;
+	eth_dev->data->numa_node = numa_node;
 
 	eth_dev->rx_pkt_burst = eth_xenvirt_rx;
 	eth_dev->tx_pkt_burst = eth_xenvirt_tx;
@@ -680,7 +677,6 @@ eth_dev_xenvirt_create(const char *name, const char *params,
 
 err:
 	rte_free(data);
-	rte_free(pci_dev);
 	rte_free(internals);
 
 	return -1;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 10/20] mpipe: remove pci device driver
  2015-10-12 16:25 ` [dpdk-dev] [PATCH v3 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (8 preceding siblings ...)
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 09/20] xenvirt: " Bernard Iremonger
@ 2015-10-12 16:25   ` Bernard Iremonger
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 11/20] ixgbe: copy pci device info to eth_dev data Bernard Iremonger
                     ` (9 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-10-12 16:25 UTC (permalink / raw)
  To: dev

From: David Hunt <david.hunt@intel.com>

initialise dev_flags, kdrv, driver, drv_name and numa_node in eth_dev data.

Signed-off-by: David Hunt <david.hunt@intel.com>
Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/mpipe/mpipe_tilegx.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/mpipe/mpipe_tilegx.c b/drivers/net/mpipe/mpipe_tilegx.c
index 743feef..5afd191 100644
--- a/drivers/net/mpipe/mpipe_tilegx.c
+++ b/drivers/net/mpipe/mpipe_tilegx.c
@@ -122,7 +122,6 @@ struct mpipe_dev_priv {
 	int channel;			/* Device channel. */
 	int port_id;			/* DPDK port index. */
 	struct rte_eth_dev *eth_dev;	/* DPDK device. */
-	struct rte_pci_device pci_dev;	/* PCI device data. */
 	struct rte_mbuf **tx_comps;	/* TX completion array. */
 	struct rte_mempool *rx_mpool;	/* mpool used by the rx queues. */
 	unsigned rx_offset;		/* Receive head room. */
@@ -1567,7 +1566,6 @@ rte_pmd_mpipe_devinit(const char *ifname,
 	priv->context = context;
 	priv->instance = instance;
 	priv->is_xaui = (strncmp(ifname, "xgbe", 4) == 0);
-	priv->pci_dev.numa_node = instance;
 	priv->channel = -1;
 
 	mac = priv->mac_addr.addr_bytes;
@@ -1591,9 +1589,14 @@ rte_pmd_mpipe_devinit(const char *ifname,
 	priv->eth_dev = eth_dev;
 	priv->port_id = eth_dev->data->port_id;
 	eth_dev->data->dev_private = priv;
-	eth_dev->pci_dev = &priv->pci_dev;
 	eth_dev->data->mac_addrs = &priv->mac_addr;
 
+	eth_dev->data->dev_flags = 0;
+	eth_dev->data->kdrv = RTE_KDRV_NONE;
+	eth_dev->driver = NULL;
+	eth_dev->data->drv_name = NULL;
+	eth_dev->data->numa_node = instance;
+
 	eth_dev->dev_ops      = &mpipe_dev_ops;
 	eth_dev->rx_pkt_burst = &mpipe_recv_pkts;
 	eth_dev->tx_pkt_burst = &mpipe_xmit_pkts;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 11/20] ixgbe: copy pci device info to eth_dev data
  2015-10-12 16:25 ` [dpdk-dev] [PATCH v3 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (9 preceding siblings ...)
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 10/20] mpipe: " Bernard Iremonger
@ 2015-10-12 16:25   ` Bernard Iremonger
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 12/20] e1000: " Bernard Iremonger
                     ` (8 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-10-12 16:25 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index ec2918c..08b5cbb 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -887,6 +887,8 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)
 	}
 	pci_dev = eth_dev->pci_dev;
 
+	rte_eth_copy_dev_info(eth_dev, pci_dev);
+
 	/* Vendor and Device ID need to be set before init of shared code */
 	hw->device_id = pci_dev->id.device_id;
 	hw->vendor_id = pci_dev->id.vendor_id;
@@ -1155,6 +1157,8 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
 
 	pci_dev = eth_dev->pci_dev;
 
+	rte_eth_copy_dev_info(eth_dev, pci_dev);
+
 	hw->device_id = pci_dev->id.device_id;
 	hw->vendor_id = pci_dev->id.vendor_id;
 	hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 12/20] e1000: copy pci device info to eth_dev data
  2015-10-12 16:25 ` [dpdk-dev] [PATCH v3 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (10 preceding siblings ...)
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 11/20] ixgbe: copy pci device info to eth_dev data Bernard Iremonger
@ 2015-10-12 16:25   ` Bernard Iremonger
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 13/20] i40e: " Bernard Iremonger
                     ` (7 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-10-12 16:25 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/e1000/em_ethdev.c  | 3 +++
 drivers/net/e1000/igb_ethdev.c | 5 +++++
 2 files changed, 8 insertions(+)

diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index 912f5dd..aa1bf48 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -232,6 +232,9 @@ eth_em_dev_init(struct rte_eth_dev *eth_dev)
 		E1000_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
 
 	pci_dev = eth_dev->pci_dev;
+
+	rte_eth_copy_dev_info(eth_dev, pci_dev);
+
 	eth_dev->dev_ops = &eth_em_ops;
 	eth_dev->rx_pkt_burst = (eth_rx_burst_t)&eth_em_recv_pkts;
 	eth_dev->tx_pkt_burst = (eth_tx_burst_t)&eth_em_xmit_pkts;
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 848ef6e..2a7aa31 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -531,6 +531,9 @@ eth_igb_dev_init(struct rte_eth_dev *eth_dev)
 	uint32_t ctrl_ext;
 
 	pci_dev = eth_dev->pci_dev;
+
+	rte_eth_copy_dev_info(eth_dev, pci_dev);
+
 	eth_dev->dev_ops = &eth_igb_ops;
 	eth_dev->rx_pkt_burst = &eth_igb_recv_pkts;
 	eth_dev->tx_pkt_burst = &eth_igb_xmit_pkts;
@@ -739,6 +742,8 @@ eth_igbvf_dev_init(struct rte_eth_dev *eth_dev)
 
 	pci_dev = eth_dev->pci_dev;
 
+	rte_eth_copy_dev_info(eth_dev, pci_dev);
+
 	hw->device_id = pci_dev->id.device_id;
 	hw->vendor_id = pci_dev->id.vendor_id;
 	hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 13/20] i40e: copy pci device info to eth_dev data
  2015-10-12 16:25 ` [dpdk-dev] [PATCH v3 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (11 preceding siblings ...)
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 12/20] e1000: " Bernard Iremonger
@ 2015-10-12 16:25   ` Bernard Iremonger
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 14/20] fm10k: " Bernard Iremonger
                     ` (6 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-10-12 16:25 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c    | 3 +++
 drivers/net/i40e/i40e_ethdev_vf.c | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 2dd9fdc..bd81d4e 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -408,6 +408,9 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 		return 0;
 	}
 	pci_dev = dev->pci_dev;
+
+	rte_eth_copy_dev_info(dev, pci_dev);
+
 	pf->adapter = I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 	pf->adapter->eth_dev = dev;
 	pf->dev_data = dev->data;
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index b694400..ab718fb 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1187,6 +1187,8 @@ i40evf_dev_init(struct rte_eth_dev *eth_dev)
 		return 0;
 	}
 
+	rte_eth_copy_dev_info(eth_dev, eth_dev->pci_dev);
+
 	hw->vendor_id = eth_dev->pci_dev->id.vendor_id;
 	hw->device_id = eth_dev->pci_dev->id.device_id;
 	hw->subsystem_vendor_id = eth_dev->pci_dev->id.subsystem_vendor_id;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 14/20] fm10k: copy pci device info to eth_dev data
  2015-10-12 16:25 ` [dpdk-dev] [PATCH v3 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (12 preceding siblings ...)
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 13/20] i40e: " Bernard Iremonger
@ 2015-10-12 16:25   ` Bernard Iremonger
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 15/20] bnx2x: " Bernard Iremonger
                     ` (5 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-10-12 16:25 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/fm10k/fm10k_ethdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index a69c990..12be227 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -2075,6 +2075,8 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
+	rte_eth_copy_dev_info(dev, dev->pci_dev);
+
 	macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private);
 	memset(macvlan, 0, sizeof(*macvlan));
 	/* Vendor and Device ID need to be set before init of shared code */
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 15/20] bnx2x: copy pci device info to eth_dev data
  2015-10-12 16:25 ` [dpdk-dev] [PATCH v3 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (13 preceding siblings ...)
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 14/20] fm10k: " Bernard Iremonger
@ 2015-10-12 16:25   ` Bernard Iremonger
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 16/20] cxgbe: " Bernard Iremonger
                     ` (4 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-10-12 16:25 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/bnx2x/bnx2x_ethdev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index 09b5920..fbcd5f4 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c
@@ -419,6 +419,9 @@ bnx2x_common_dev_init(struct rte_eth_dev *eth_dev, int is_vf)
 
 	eth_dev->dev_ops = is_vf ? &bnx2xvf_eth_dev_ops : &bnx2x_eth_dev_ops;
 	pci_dev = eth_dev->pci_dev;
+
+	rte_eth_copy_dev_info(eth_dev, pci_dev);
+
 	sc = eth_dev->data->dev_private;
 	sc->pcie_bus    = pci_dev->addr.bus;
 	sc->pcie_device = pci_dev->addr.devid;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 16/20] cxgbe: copy pci device info to eth_dev data
  2015-10-12 16:25 ` [dpdk-dev] [PATCH v3 00/20] remove pci driver from vdevs Bernard Iremonger
                     ` (14 preceding siblings ...)
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 15/20] bnx2x: " Bernard Iremonger
@ 2015-10-12 16:25   ` Bernard Iremonger
  2015-10-12 16:25   ` [dpdk-dev] [PATCH v3 17/20] enic: " Bernard Iremonger
                     ` (3 subsequent siblings)
  19 siblings, 0 replies; 270+ messages in thread
From: Bernard Iremonger @ 2015-10-12 16:25 UTC (permalink / raw)
  To: dev

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/cxgbe/cxgbe_ethdev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 478051a..f081879 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -744,6 +744,9 @@ static int eth_cxgbe_dev_init(struct rte_eth_dev *eth_dev)
 		return 0;
 
 	pci_dev = eth_dev->pci_dev;
+
+	rte_eth_copy_dev_info(eth_dev, pci_dev);
+
 	snprintf(name, sizeof(name), "cxgbeadapter%d", eth_dev->data->port_id);
 	adapter = rte_zmalloc(name, sizeof(*adapter), 0);
 	if (!adapter)
-- 
1.9.1

^ permalink raw reply	[flat|nested] 270+ messages in thread

* [dpdk-dev] [PATCH v3 17/20] enic: copy pci device info to eth_dev data
  2015-10-12 16:25 ` [dpdk-dev] [PATCH v3 00/20] remove pci driver from vdevs Bernard Iremonger
                     `