[v2,1/4] net/failsafe: replace local device with shared data

Message ID 1551779507-10857-1-git-send-email-rasland@mellanox.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series [v2,1/4] net/failsafe: replace local device with shared data |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Raslan Darawsheh March 5, 2019, 9:52 a.m. UTC
  In multiprocess context, the private structure is shared between
processes. The back reference from private to generic data was using
a pointer to a per process eth_dev. It's now changed to a reference of
the shared data.

Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/net/failsafe/failsafe.c         |  2 +-
 drivers/net/failsafe/failsafe_intr.c    | 10 +++++-----
 drivers/net/failsafe/failsafe_ops.c     |  4 ++--
 drivers/net/failsafe/failsafe_private.h |  6 +++++-
 drivers/net/failsafe/failsafe_rxtx.c    |  4 ++--
 5 files changed, 15 insertions(+), 11 deletions(-)
  

Comments

Gaëtan Rivet March 5, 2019, 4:43 p.m. UTC | #1
Hello Raslan,

Sorry for the delay.

I have had a little trouble reading the patches. I think the 3 first
should be squashed into a single one, it would be more coherent.

I think I have seen a few points where doing so would have prevented
some unnecessary changes for example, simplifying the series. (thinking
about at least two PORT_ID() and a few ETH() removal that might have
been prevented, I will try to point them all to you.)

On Tue, Mar 05, 2019 at 09:52:04AM +0000, Raslan Darawsheh wrote:
> In multiprocess context, the private structure is shared between
> processes. The back reference from private to generic data was using
> a pointer to a per process eth_dev. It's now changed to a reference of
> the shared data.
> 
> Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
>  drivers/net/failsafe/failsafe.c         |  2 +-
>  drivers/net/failsafe/failsafe_intr.c    | 10 +++++-----
>  drivers/net/failsafe/failsafe_ops.c     |  4 ++--
>  drivers/net/failsafe/failsafe_private.h |  6 +++++-
>  drivers/net/failsafe/failsafe_rxtx.c    |  4 ++--
>  5 files changed, 15 insertions(+), 11 deletions(-)
> 

Beside the squashing, this patch seems ok.
  
Gaëtan Rivet March 5, 2019, 5:40 p.m. UTC | #2
On Tue, Mar 05, 2019 at 05:43:26PM +0100, Gaëtan Rivet wrote:
> Hello Raslan,
> 
> Sorry for the delay.
> 
> I have had a little trouble reading the patches. I think the 3 first
> should be squashed into a single one, it would be more coherent.
> 
> I think I have seen a few points where doing so would have prevented
> some unnecessary changes for example, simplifying the series. (thinking
> about at least two PORT_ID() and a few ETH() removal that might have
> been prevented, I will try to point them all to you.)
> 
> On Tue, Mar 05, 2019 at 09:52:04AM +0000, Raslan Darawsheh wrote:
> > In multiprocess context, the private structure is shared between
> > processes. The back reference from private to generic data was using
> > a pointer to a per process eth_dev. It's now changed to a reference of
> > the shared data.
> > 
> > Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> > ---
> >  drivers/net/failsafe/failsafe.c         |  2 +-
> >  drivers/net/failsafe/failsafe_intr.c    | 10 +++++-----
> >  drivers/net/failsafe/failsafe_ops.c     |  4 ++--
> >  drivers/net/failsafe/failsafe_private.h |  6 +++++-
> >  drivers/net/failsafe/failsafe_rxtx.c    |  4 ++--
> >  5 files changed, 15 insertions(+), 11 deletions(-)
> > 
> 
> Beside the squashing, this patch seems ok.

Okay after reading a little more closely, it does not seem interesting
to squash finaly, and it will be simpler for you to continue with your
current series, so forget about that.
  
Thomas Monjalon March 5, 2019, 5:41 p.m. UTC | #3
05/03/2019 18:40, Gaëtan Rivet:
> On Tue, Mar 05, 2019 at 05:43:26PM +0100, Gaëtan Rivet wrote:
> > I have had a little trouble reading the patches. I think the 3 first
> > should be squashed into a single one, it would be more coherent.
> > 
> > I think I have seen a few points where doing so would have prevented
> > some unnecessary changes for example, simplifying the series. (thinking
> > about at least two PORT_ID() and a few ETH() removal that might have
> > been prevented, I will try to point them all to you.)
> > 
[...]
> > 
> > Beside the squashing, this patch seems ok.
> 
> Okay after reading a little more closely, it does not seem interesting
> to squash finaly, and it will be simpler for you to continue with your
> current series, so forget about that.

Yes, and it's easier to track changes when split as it is.
  

Patch

diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c
index 06e859e..68926ca 100644
--- a/drivers/net/failsafe/failsafe.c
+++ b/drivers/net/failsafe/failsafe.c
@@ -181,7 +181,7 @@  fs_eth_dev_create(struct rte_vdev_device *vdev)
 		return -1;
 	}
 	priv = PRIV(dev);
-	priv->dev = dev;
+	priv->data = dev->data;
 	dev->dev_ops = &failsafe_ops;
 	dev->data->mac_addrs = &PRIV(dev)->mac_addrs[0];
 	dev->data->dev_link = eth_link;
diff --git a/drivers/net/failsafe/failsafe_intr.c b/drivers/net/failsafe/failsafe_intr.c
index 1c2cb71..09aa3c6 100644
--- a/drivers/net/failsafe/failsafe_intr.c
+++ b/drivers/net/failsafe/failsafe_intr.c
@@ -133,8 +133,8 @@  fs_rx_event_proxy_service_install(struct fs_priv *priv)
 	/* prepare service info */
 	memset(&service, 0, sizeof(struct rte_service_spec));
 	snprintf(service.name, sizeof(service.name), "%s_Rx_service",
-		 priv->dev->data->name);
-	service.socket_id = priv->dev->data->numa_node;
+		 priv->data->name);
+	service.socket_id = priv->data->numa_node;
 	service.callback = fs_rx_event_proxy_routine;
 	service.callback_userdata = priv;
 
@@ -437,7 +437,7 @@  fs_rx_intr_vec_install(struct fs_priv *priv)
 	unsigned int count;
 	struct rte_intr_handle *intr_handle;
 
-	rxqs_n = priv->dev->data->nb_rx_queues;
+	rxqs_n = priv->data->nb_rx_queues;
 	n = RTE_MIN(rxqs_n, (uint32_t)RTE_MAX_RXTX_INTR_VEC_ID);
 	count = 0;
 	intr_handle = &priv->intr_handle;
@@ -452,7 +452,7 @@  fs_rx_intr_vec_install(struct fs_priv *priv)
 		return -rte_errno;
 	}
 	for (i = 0; i < n; i++) {
-		struct rxq *rxq = priv->dev->data->rx_queues[i];
+		struct rxq *rxq = priv->data->rx_queues[i];
 
 		/* Skip queues that cannot request interrupts. */
 		if (rxq == NULL || rxq->event_fd < 0) {
@@ -521,7 +521,7 @@  failsafe_rx_intr_install(struct rte_eth_dev *dev)
 {
 	struct fs_priv *priv = PRIV(dev);
 	const struct rte_intr_conf *const intr_conf =
-			&priv->dev->data->dev_conf.intr_conf;
+			&priv->data->dev_conf.intr_conf;
 
 	if (intr_conf->rxq == 0 || dev->intr_handle != NULL)
 		return 0;
diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c
index e3add40..65957a2 100644
--- a/drivers/net/failsafe/failsafe_ops.c
+++ b/drivers/net/failsafe/failsafe_ops.c
@@ -452,7 +452,7 @@  fs_rx_queue_release(void *queue)
 	if (queue == NULL)
 		return;
 	rxq = queue;
-	dev = rxq->priv->dev;
+	dev = &rte_eth_devices[rxq->priv->data->port_id];
 	fs_lock(dev, 0);
 	if (rxq->event_fd > 0)
 		close(rxq->event_fd);
@@ -636,7 +636,7 @@  fs_tx_queue_release(void *queue)
 	if (queue == NULL)
 		return;
 	txq = queue;
-	dev = txq->priv->dev;
+	dev = &rte_eth_devices[txq->priv->data->port_id];
 	fs_lock(dev, 0);
 	FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
 		if (ETH(sdev)->data->tx_queues != NULL &&
diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe/failsafe_private.h
index 0dfea65..29dfd40 100644
--- a/drivers/net/failsafe/failsafe_private.h
+++ b/drivers/net/failsafe/failsafe_private.h
@@ -128,8 +128,12 @@  struct sub_device {
 	unsigned int lsc_callback:1;
 };
 
+/*
+ * This is referenced by eth_dev->data->dev_private
+ * This is shared between processes.
+ */
 struct fs_priv {
-	struct rte_eth_dev *dev;
+	struct rte_eth_dev_data *data; /* backreference to shared data. */
 	/*
 	 * Set of sub_devices.
 	 * subs[0] is the preferred device
diff --git a/drivers/net/failsafe/failsafe_rxtx.c b/drivers/net/failsafe/failsafe_rxtx.c
index 034f47b..231c832 100644
--- a/drivers/net/failsafe/failsafe_rxtx.c
+++ b/drivers/net/failsafe/failsafe_rxtx.c
@@ -126,7 +126,7 @@  failsafe_tx_burst(void *queue,
 	uint16_t nb_tx;
 
 	txq = queue;
-	sdev = TX_SUBDEV(txq->priv->dev);
+	sdev = TX_SUBDEV(&rte_eth_devices[txq->priv->data->port_id]);
 	if (unlikely(fs_tx_unsafe(sdev)))
 		return 0;
 	sub_txq = ETH(sdev)->data->tx_queues[txq->qid];
@@ -147,7 +147,7 @@  failsafe_tx_burst_fast(void *queue,
 	uint16_t nb_tx;
 
 	txq = queue;
-	sdev = TX_SUBDEV(txq->priv->dev);
+	sdev = TX_SUBDEV(&rte_eth_devices[txq->priv->data->port_id]);
 	RTE_ASSERT(!fs_tx_unsafe(sdev));
 	sub_txq = ETH(sdev)->data->tx_queues[txq->qid];
 	FS_ATOMIC_P(txq->refcnt[sdev->sid]);