From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by dpdk.org (Postfix) with ESMTP id 272382BD5 for ; Thu, 7 Mar 2019 10:43:59 +0100 (CET) Received: by mail-wm1-f68.google.com with SMTP id n19so8570122wmi.1 for ; Thu, 07 Mar 2019 01:43:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=R2rIdlrCDl+8Fh4VtV2Tvlvnz8sGCeNlSat+qrjqIHU=; b=RRYo7iDRrHku4RjQSs8BnGVA7HTo7A0GrAwrg6/a+38gMi46up5Kvn7PQhsoLfx3gT xd//4XdcpBgD8k1ZdfyMIIRJKK+hN6q3B/bGtMYMg+JZGOdHTxAAuvcHxE3nHLjGQtOs qSFRr+9mO/kweFTvH1Iy6WdsyItE91fcSzJmL+gMV2x7kgPPc78FxyIEo/RlWpylgDHL IHsrITh7qlVgnGrrWgQzhI4FRMRTYir6quoajwM8HExg5eAeNYEcfm5t1z3WKoPX/gap HeWqmtfsQLDHnnp+f/LdTrthGrdXZHtGKRr4/jsCN/SoqIKSY7PKEWYnliYGAhteyKkU Fb1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=R2rIdlrCDl+8Fh4VtV2Tvlvnz8sGCeNlSat+qrjqIHU=; b=RiZcle8No4ummrqJwP8s21sVynkh+Y87hwQc4Vj5eGkVu4OPgZY1Uxe18/DIGXzoTQ iYunNyZt81EgPXqa08DuLFkEkYwAxGsxJ/B3fL76fHFwvAdEbkN/8DoD3HRFsL9sJtmC 1pl/wPKFYkYr32Bnnkqk7xwMsBcMBLqXmVBvcbSFmFxmdhF7D3vJku1vpHNG9RvYCBMK uFeKaMdWqFNJdz/uCjbSZHMhsk/ZR9Fwm3yzQWXZcFpaN1FYj7idRnyAffS3hTpihv8C EJ5iBkB4WxjRlIaidhTKVpmSh76T2v94qNccC2YBd9aGaU4YHTQfuySLGjB3J2Ng4+IQ 9x2g== X-Gm-Message-State: APjAAAWHFraNKCtQHc74ZjYUAcs+7qwFjgfY/aipHt/8H7YR9s8XeQ/C kNPaevk0vPZWo5gN8aO/prN8eg== X-Google-Smtp-Source: APXvYqyUTv8di9ZxKYa89P7EWjhqT6TEH+iyM/aPpwYDuRTmZjtEM1z4A0bHrBUK06b1y0B3S1/XqQ== X-Received: by 2002:a7b:cb48:: with SMTP id v8mr4951266wmj.138.1551951838629; Thu, 07 Mar 2019 01:43:58 -0800 (PST) Received: from bidouze.vm.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id z1sm1001344wrt.55.2019.03.07.01.43.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Mar 2019 01:43:57 -0800 (PST) Date: Thu, 7 Mar 2019 10:43:55 +0100 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet To: Raslan Darawsheh Cc: "dev@dpdk.org" , Thomas Monjalon , "stephen@networkplumber.org" Message-ID: <20190307094355.2xsch2yuzd7nrgvf@bidouze.vm.6wind.com> References: <1551779507-10857-1-git-send-email-rasland@mellanox.com> <1551779507-10857-2-git-send-email-rasland@mellanox.com> <20190305164854.2e5lb6o3j23vkpl3@bidouze.vm.6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [dpdk-dev] [PATCH v2 2/4] net/failsafe: change back-reference from sub-device X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Mar 2019 09:44:00 -0000 Hello Raslan, On Thu, Mar 07, 2019 at 09:01:11AM +0000, Raslan Darawsheh wrote: > Hi, > > > -----Original Message----- > > From: Gaëtan Rivet > > Sent: Tuesday, March 5, 2019 6:49 PM > > To: Raslan Darawsheh > > Cc: dev@dpdk.org; Thomas Monjalon ; > > stephen@networkplumber.org > > Subject: Re: [PATCH v2 2/4] net/failsafe: change back-reference from sub- > > device > > > > 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 > > > Signed-off-by: Thomas Monjalon > > > --- > > > 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 = > > > Ð(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. > > > > I think you are right if I'm only reading the prototype of the function/implementation. > But, if I'm reading it from the function call, it would be easier to read/understand it. > I would change the prefix to be fs_dev_from_subdev instead what do you think? > I prefer reading fs_dev(sdev) instead of fs{,_}dev_from_subdev(sdev), so I'd still vote for using fs_dev(); I think in the context of fail-safe it is clear enough that it gives a handle to the fail-safe device. > > > > /* > > > * 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 > > > Kindest regards, > Raslan Darawsheh -- Gaëtan Rivet 6WIND