DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Gaëtan Rivet" <gaetan.rivet@6wind.com>
To: Raslan Darawsheh <rasland@mellanox.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
	Thomas Monjalon <thomas@monjalon.net>,
	"stephen@networkplumber.org" <stephen@networkplumber.org>
Subject: Re: [dpdk-dev] [PATCH v2 2/4] net/failsafe: change back-reference from sub-device
Date: Tue, 5 Mar 2019 17:48:54 +0100	[thread overview]
Message-ID: <20190305164854.2e5lb6o3j23vkpl3@bidouze.vm.6wind.com> (raw)
In-Reply-To: <1551779507-10857-2-git-send-email-rasland@mellanox.com>

Beside the squash referenced in p1,

On Tue, Mar 05, 2019 at 09:52:05AM +0000, Raslan Darawsheh wrote:
> In multiprocess context, the sub-device structure is shared
> between processes. The reference to the failsafe device was
> a per process pointer. It's changed to port id which is the
> same for all processes.
> 
> Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
> v2: changed macro to an inline function
> ---
>  drivers/net/failsafe/failsafe_eal.c     |  2 +-
>  drivers/net/failsafe/failsafe_ether.c   | 15 ++++++++-------
>  drivers/net/failsafe/failsafe_intr.c    | 10 +++++-----
>  drivers/net/failsafe/failsafe_private.h | 13 ++++++++++---
>  4 files changed, 24 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/net/failsafe/failsafe_eal.c b/drivers/net/failsafe/failsafe_eal.c
> index 8a888b1..56d1669 100644
> --- a/drivers/net/failsafe/failsafe_eal.c
> +++ b/drivers/net/failsafe/failsafe_eal.c
> @@ -114,7 +114,7 @@ fs_bus_init(struct rte_eth_dev *dev)
>  		}
>  		ETH(sdev) = &rte_eth_devices[pid];
>  		SUB_ID(sdev) = i;
> -		sdev->fs_dev = dev;
> +		sdev->fs_port_id = dev->data->port_id;
>  		sdev->dev = ETH(sdev)->device;
>  		sdev->state = DEV_PROBED;
>  	}
> diff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/failsafe_ether.c
> index 1783165..d5b1488 100644
> --- a/drivers/net/failsafe/failsafe_ether.c
> +++ b/drivers/net/failsafe/failsafe_ether.c
> @@ -298,7 +298,7 @@ fs_dev_remove(struct sub_device *sdev)
>  		break;
>  	}
>  	sdev->remove = 0;
> -	failsafe_hotplug_alarm_install(sdev->fs_dev);
> +	failsafe_hotplug_alarm_install(fsdev_from_subdev(sdev));
>  }
>  
>  static void
> @@ -318,8 +318,9 @@ fs_dev_stats_save(struct sub_device *sdev)
>  			WARN("Using latest snapshot taken before %"PRIu64" seconds.\n",
>  				 (rte_rdtsc() - timestamp) / rte_get_tsc_hz());
>  	}
> -	failsafe_stats_increment(&PRIV(sdev->fs_dev)->stats_accumulator,
> -			err ? &sdev->stats_snapshot.stats : &stats);
> +	failsafe_stats_increment
> +		(&PRIV(fsdev_from_subdev(sdev))->stats_accumulator,
> +		err ? &sdev->stats_snapshot.stats : &stats);
>  	memset(&sdev->stats_snapshot, 0, sizeof(sdev->stats_snapshot));
>  }
>  
> @@ -566,17 +567,17 @@ failsafe_eth_rmv_event_callback(uint16_t port_id __rte_unused,
>  {
>  	struct sub_device *sdev = cb_arg;
>  
> -	fs_lock(sdev->fs_dev, 0);
> +	fs_lock(fsdev_from_subdev(sdev), 0);
>  	/* Switch as soon as possible tx_dev. */
> -	fs_switch_dev(sdev->fs_dev, sdev);
> +	fs_switch_dev(fsdev_from_subdev(sdev), sdev);
>  	/* Use safe bursts in any case. */
> -	failsafe_set_burst_fn(sdev->fs_dev, 1);
> +	failsafe_set_burst_fn(fsdev_from_subdev(sdev), 1);
>  	/*
>  	 * Async removal, the sub-PMD will try to unregister
>  	 * the callback at the source of the current thread context.
>  	 */
>  	sdev->remove = 1;
> -	fs_unlock(sdev->fs_dev, 0);
> +	fs_unlock(fsdev_from_subdev(sdev), 0);
>  	return 0;
>  }
>  
> diff --git a/drivers/net/failsafe/failsafe_intr.c b/drivers/net/failsafe/failsafe_intr.c
> index 09aa3c6..d372d09 100644
> --- a/drivers/net/failsafe/failsafe_intr.c
> +++ b/drivers/net/failsafe/failsafe_intr.c
> @@ -274,14 +274,14 @@ failsafe_eth_rx_intr_ctl_subdevice(struct sub_device *sdev, int op)
>  	int rc;
>  	int ret = 0;
>  
> +	fsdev = fsdev_from_subdev(sdev);
>  	if (sdev == NULL || (ETH(sdev) == NULL) ||
> -	    sdev->fs_dev == NULL || (PRIV(sdev->fs_dev) == NULL)) {
> +		fsdev == NULL || (PRIV(fsdev) == NULL)) {
>  		ERROR("Called with invalid arguments");
>  		return -EINVAL;
>  	}
>  	dev = ETH(sdev);
> -	fsdev = sdev->fs_dev;
> -	epfd = PRIV(sdev->fs_dev)->rxp.efd;
> +	epfd = PRIV(fsdev)->rxp.efd;
>  	pid = PORT_ID(sdev);
>  
>  	if (epfd <= 0) {
> @@ -330,7 +330,7 @@ int failsafe_rx_intr_install_subdevice(struct sub_device *sdev)
>  	const struct rte_intr_conf *const intr_conf =
>  				&ETH(sdev)->data->dev_conf.intr_conf;
>  
> -	fsdev = sdev->fs_dev;
> +	fsdev = fsdev_from_subdev(sdev);
>  	rxq = (struct rxq **)fsdev->data->rx_queues;
>  	if (intr_conf->rxq == 0)
>  		return 0;
> @@ -368,7 +368,7 @@ void failsafe_rx_intr_uninstall_subdevice(struct sub_device *sdev)
>  	struct rte_eth_dev *fsdev;
>  	struct rxq *fsrxq;
>  
> -	fsdev = sdev->fs_dev;
> +	fsdev = fsdev_from_subdev(sdev);
>  	for (qid = 0; qid < ETH(sdev)->data->nb_rx_queues; qid++) {
>  		if (qid < fsdev->data->nb_rx_queues) {
>  			fsrxq = fsdev->data->rx_queues[qid];
> diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe/failsafe_private.h
> index 29dfd40..84e847f 100644
> --- a/drivers/net/failsafe/failsafe_private.h
> +++ b/drivers/net/failsafe/failsafe_private.h
> @@ -117,7 +117,7 @@ struct sub_device {
>  	/* Others are retrieved through a file descriptor */
>  	char *fd_str;
>  	/* fail-safe device backreference */
> -	struct rte_eth_dev *fs_dev;
> +	uint16_t fs_port_id; /* shared between processes*/
>  	/* flag calling for recollection */
>  	volatile unsigned int remove:1;
>  	/* flow isolation state */
> @@ -324,7 +324,8 @@ extern int failsafe_mac_from_arg;
>   */
>  #define FS_ATOMIC_RX(s, i) \
>  	rte_atomic64_read( \
> -	 &((struct rxq *)((s)->fs_dev->data->rx_queues[i]))->refcnt[(s)->sid] \
> +	 &((struct rxq *) \
> +	 (fsdev_from_subdev(s)->data->rx_queues[i]))->refcnt[(s)->sid] \
>  	)
>  /**
>   * s: (struct sub_device *)
> @@ -332,7 +333,8 @@ extern int failsafe_mac_from_arg;
>   */
>  #define FS_ATOMIC_TX(s, i) \
>  	rte_atomic64_read( \
> -	 &((struct txq *)((s)->fs_dev->data->tx_queues[i]))->refcnt[(s)->sid] \
> +	 &((struct txq *) \
> +	 (fsdev_from_subdev(s)->data->tx_queues[i]))->refcnt[(s)->sid] \
>  	)
>  
>  #ifdef RTE_EXEC_ENV_BSDAPP
> @@ -379,6 +381,11 @@ fs_find_next(struct rte_eth_dev *dev,
>  	return &subs[sid];
>  }
>  
> +static inline struct rte_eth_dev *
> +fsdev_from_subdev(struct sub_device *sdev) {
> +	return &rte_eth_devices[sdev->fs_port_id];
> +}
> +

Using a static inline that already enforce parameter type makes the
_from_subdev suffix redundant.

I think

fs_dev(struct sub_device *sdev);

would be more readable in most of the changes above, while keeping with
the fs_ prefix used in all static failsafe functions.

>  /*
>   * Lock hot-plug mutex.
>   * is_alarm means that the caller is, for sure, the hot-plug alarm mechanism.
> -- 
> 2.7.4
> 

-- 
Gaëtan Rivet
6WIND

  reply	other threads:[~2019-03-05 16:48 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-05  9:52 [dpdk-dev] [PATCH v2 1/4] net/failsafe: replace local device with shared data Raslan Darawsheh
2019-03-05  9:52 ` [dpdk-dev] [PATCH v2 3/4] net/failsafe: replace local sub-device " Raslan Darawsheh
2019-03-05  9:59   ` Thomas Monjalon
2019-03-05 17:38   ` Gaëtan Rivet
2019-03-05 17:58     ` Thomas Monjalon
2019-03-06 10:46       ` Gaëtan Rivet
2019-03-06 18:02         ` Thomas Monjalon
2019-03-07  8:43           ` Raslan Darawsheh
2019-03-07  9:47             ` Gaëtan Rivet
2019-03-07 11:34               ` Raslan Darawsheh
2019-03-07 11:50                 ` Gaëtan Rivet
2019-03-05  9:52 ` [dpdk-dev] [PATCH v2 2/4] net/failsafe: change back-reference from sub-device Raslan Darawsheh
2019-03-05 16:48   ` Gaëtan Rivet [this message]
2019-03-07  9:01     ` Raslan Darawsheh
2019-03-07  9:43       ` Gaëtan Rivet
2019-03-05  9:52 ` [dpdk-dev] [PATCH v2 4/4] net/failsafe: support secondary process Raslan Darawsheh
2019-03-05 16:43 ` [dpdk-dev] [PATCH v2 1/4] net/failsafe: replace local device with shared data Gaëtan Rivet
2019-03-05 17:40   ` Gaëtan Rivet
2019-03-05 17:41     ` Thomas Monjalon
2019-03-18 16:05 ` [dpdk-dev] [PATCH v3 0/4] support secondary process for failsafe Raslan Darawsheh
2019-03-18 16:05   ` Raslan Darawsheh
2019-03-18 16:05   ` [dpdk-dev] [PATCH v3 1/4] net/failsafe: replace local device with shared data Raslan Darawsheh
2019-03-18 16:05     ` Raslan Darawsheh
2019-03-18 16:05   ` [dpdk-dev] [PATCH v3 2/4] net/failsafe: change back-reference from sub-device Raslan Darawsheh
2019-03-18 16:05     ` Raslan Darawsheh
2019-03-18 16:05   ` [dpdk-dev] [PATCH v3 4/4] net/failsafe: support secondary process Raslan Darawsheh
2019-03-18 16:05     ` Raslan Darawsheh
2019-03-18 16:05   ` [dpdk-dev] [PATCH v3 3/4] net/failsafe: replace sub-device pointer with port id Raslan Darawsheh
2019-03-18 16:05     ` Raslan Darawsheh
2019-03-18 16:16   ` [dpdk-dev] [PATCH v3 0/4] support secondary process for failsafe Gaëtan Rivet
2019-03-18 16:16     ` Gaëtan Rivet
2019-03-27 14:08     ` Ferruh Yigit
2019-03-27 14:08       ` Ferruh Yigit

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=20190305164854.2e5lb6o3j23vkpl3@bidouze.vm.6wind.com \
    --to=gaetan.rivet@6wind.com \
    --cc=dev@dpdk.org \
    --cc=rasland@mellanox.com \
    --cc=stephen@networkplumber.org \
    --cc=thomas@monjalon.net \
    /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).