DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ophir Munk <ophirmu@mellanox.com>
To: "dev@dpdk.org" <dev@dpdk.org>, Yongseok Koh <yskoh@mellanox.com>,
	Ophir Munk <ophirmu@mellanox.com>
Cc: Thomas Monjalon <thomas@monjalon.net>,
	Olga Shern <olgas@mellanox.com>, Asaf Penso <asafp@mellanox.com>,
	Shahaf Shuler <shahafs@mellanox.com>
Subject: [dpdk-dev] [PATCH v4 3/3] net/mlx5: close all ports on remove
Date: Tue, 23 Oct 2018 18:26:05 +0000	[thread overview]
Message-ID: <1540319157-11191-3-git-send-email-ophirmu@mellanox.com> (raw)
In-Reply-To: <1540319157-11191-1-git-send-email-ophirmu@mellanox.com>

With the introduction of representors several eth devices are using
the same rte device (e.g. a PCI bus). When calling port detach on one
eth device it is required that all eth devices belonging to the
same rte device have been closed in advance, then the rte device
itself can be removed/detached.
This commit implements this requirement implicitly by adding a
remove callback to struct rte_pci_driver.
The new behavior can be demonstrated in testpmd.
First we attach a representor 0 using PCI address 0000:08:00.0
testpmd> port attach  0000:08:00.0,representor=[0]
Attaching a new port...
EAL: PCI device 0000:08:00.0 on NUMA socket 0
EAL:   probe driver: 15b3:1013 net_mlx5
Port 0 is attached.
Done
Port 1 is attached.
Done

Port 0 is the master device (PF) - an ethdev of the PCI address.
Port 1 is representor 0 - another ethdev (representing a VF) using the
same PCI address. Next we detach port 1
testpmd> port detach 1
Removing a device...
Port 0 is closed
Port 1 is closed
Now total ports is 0
Done

Since port 0 has been implicitly closed we cannot act on it anymore.
testpmd> port stop 0
Invalid port 0

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
---
v1-v3
This patch was not part of the serie

v4:
Initial version

 drivers/net/mlx5/mlx5.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 7a8b45a..9f7a099 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -1485,6 +1485,22 @@ struct mlx5_dev_spawn_data {
 	return ret;
 }
 
+static int
+mlx5_pci_remove(struct rte_pci_device *pci_dev)
+{
+	uint16_t port_id;
+	struct rte_eth_dev *port;
+
+	for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++) {
+		port = &rte_eth_devices[port_id];
+		if (port->state != RTE_ETH_DEV_UNUSED &&
+				port->device == &pci_dev->device)
+			rte_eth_dev_close(port_id);
+	}
+
+	return 0;
+}
+
 static const struct rte_pci_id mlx5_pci_id_map[] = {
 	{
 		RTE_PCI_DEVICE(PCI_VENDOR_ID_MELLANOX,
@@ -1537,6 +1553,7 @@ struct mlx5_dev_spawn_data {
 	},
 	.id_table = mlx5_pci_id_map,
 	.probe = mlx5_pci_probe,
+	.remove = mlx5_pci_remove,
 	.drv_flags = RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_INTR_RMV |
 			RTE_PCI_DRV_PROBE_AGAIN,
 };
-- 
1.8.3.1

  parent reply	other threads:[~2018-10-23 18:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-03  8:01 [dpdk-dev] [PATCH] net/mlx5: allow multi probing Ophir Munk
2018-10-05  1:41 ` Yongseok Koh
2018-10-05 11:20   ` Ophir Munk
2018-10-05 11:06 ` [dpdk-dev] [PATCH v2] net/mlx5: allow multiple probing for representor Ophir Munk
2018-10-05 18:06   ` Yongseok Koh
2018-10-09 22:23     ` Ophir Munk
2018-10-19  8:12   ` [dpdk-dev] [PATCH v3] " Ophir Munk
2018-10-23 18:26     ` [dpdk-dev] [PATCH v4 1/3] " Ophir Munk
2018-10-23 18:26       ` [dpdk-dev] [PATCH v4 2/3] net/mlx5: release port on close Ophir Munk
2018-10-23 18:26       ` Ophir Munk [this message]
2018-10-24 13:19       ` [dpdk-dev] [PATCH v4 1/3] net/mlx5: allow multiple probing for representor Shahaf Shuler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1540319157-11191-3-git-send-email-ophirmu@mellanox.com \
    --to=ophirmu@mellanox.com \
    --cc=asafp@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=olgas@mellanox.com \
    --cc=shahafs@mellanox.com \
    --cc=thomas@monjalon.net \
    --cc=yskoh@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).