All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matan Azrad <matan@mellanox.com>
To: "Gaëtan Rivet" <gaetan.rivet@6wind.com>,
	"Thomas Monjalon" <thomas@monjalon.net>
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	Adrien Mazarguil <adrien.mazarguil@6wind.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [PATCH v3 1/6] ethdev: add devop to check removal status
Date: Wed, 20 Dec 2017 08:39:06 +0000	[thread overview]
Message-ID: <HE1PR0502MB3659E82571CF9D46400AD8E1D20C0@HE1PR0502MB3659.eurprd05.prod.outlook.com> (raw)
In-Reply-To: <20171219221322.stibgas3ac2yxqjk@bidouze.vm.6wind.com>

Hi

> -----Original Message-----
> From: Gaëtan Rivet [mailto:gaetan.rivet@6wind.com]
> Sent: Wednesday, December 20, 2017 12:13 AM
> To: Thomas Monjalon <thomas@monjalon.net>
> Cc: Matan Azrad <matan@mellanox.com>; Stephen Hemminger
> <stephen@networkplumber.org>; Adrien Mazarguil
> <adrien.mazarguil@6wind.com>; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v3 1/6] ethdev: add devop to check removal
> status
> 
> On Tue, Dec 19, 2017 at 09:51:10PM +0100, Thomas Monjalon wrote:
> > 19/12/2017 18:24, Matan Azrad:
> > > HI
> > >
> > > > -----Original Message-----
> > > > From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> > > > Sent: Tuesday, December 19, 2017 7:20 PM
> > > > To: Matan Azrad <matan@mellanox.com>
> > > > Cc: Adrien Mazarguil <adrien.mazarguil@6wind.com>; Thomas
> Monjalon
> > > > <thomas@monjalon.net>; Gaetan Rivet <gaetan.rivet@6wind.com>;
> > > > dev@dpdk.org
> > > > Subject: Re: [dpdk-dev] [PATCH v3 1/6] ethdev: add devop to check
> > > > removal status
> > > >
> > > > On Tue, 19 Dec 2017 17:10:10 +0000 Matan Azrad
> > > > <matan@mellanox.com> wrote:
> > > >
> > > > >  int
> > > > > +rte_eth_dev_is_removed(uint16_t port_id) {
> > > > > +	struct rte_eth_dev *dev;
> > > > > +	int ret;
> > > > > +
> > > > > +	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
> > > > > +
> > > > > +	dev = &rte_eth_devices[port_id];
> > > > > +
> > > > > +	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops-
> >is_removed, 0);
> > > > > +
> > > > > +	if (dev->state == RTE_ETH_DEV_REMOVED)
> > > > > +		return 1;
> > > > > +
> > > > > +	ret = dev->dev_ops->is_removed(dev);
> > > > > +	if (ret != 0)
> > > > > +		dev->state = RTE_ETH_DEV_REMOVED;
> > > > > +
> > > > > +	return ret;
> > > > > +}
> > > > > +
> > > >
> > > > This looks good.
> > > > May be a candidate to use bool instead of int for return value?
> > >
> > > Yes, I thought about it but didn't see any precedence for bool usage in
> ethdev APIs.
> > > Guys, what do you think?
> >
> > I think this function can return error, isn't it?
> > (look at macros *_OR_ERR_RET used in the function)
> >
> 
> But those macros are used to return 0.
> 
> While I think I see a logic behind it, I think it is surprising the API user, which is
> not ideal.
> 

The logic behind it is that "is" semantic is question which expects to yes\no answer.
Therefore, user who uses this API just expects to either True or False return value and doesn't need to check more errors options like -ENODEV or -ENOTSUP.
I decided that the return value will be only 0 or 1 to make it easier to user:
Removed - 1,
Present - 0,
No support - it makes sense that PMD which doesn't implement "is_removed" devop means that its underlying devices are not removable so they are always present and this function should return '0' for it.
No port - I think that '0' here will be better that '1'.

Stephen suggestion to replace '0' and '1' by 'false' and 'true' makes sense but I decided not to do it like this because of the next ideas:
1. No precedence for bool value in ethdev APIs.
2. Maybe it will be problematic to use *OR_ERR_RET defines to return bool value. 

I hope that this explanation helps you.

Thanks, 
Matan.
   
  


   
> --
> Gaëtan Rivet
> 6WIND

  reply	other threads:[~2017-12-20  8:39 UTC|newest]

Thread overview: 98+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-02 15:42 [PATCH 0/3] Fail-safe fix removal handling lack Matan Azrad
2017-11-02 15:42 ` [PATCH 1/3] net/failsafe: " Matan Azrad
2017-11-06  8:19   ` Gaëtan Rivet
2017-11-02 15:42 ` [PATCH 2/3] net/mlx4: adjust removal error Matan Azrad
2017-11-03 13:05   ` Adrien Mazarguil
2017-11-05  6:52     ` Matan Azrad
2017-11-06 16:51       ` Adrien Mazarguil
2017-11-02 15:42 ` [PATCH 3/3] net/mlx5: " Matan Azrad
2017-11-03 13:06   ` Adrien Mazarguil
2017-11-05  6:57     ` Matan Azrad
2017-12-13 14:29 ` [PATCH v2 0/4] Fail-safe fix removal handling lack Matan Azrad
2017-12-13 14:29   ` [PATCH v2 1/4] ethdev: add devop to check removal status Matan Azrad
2017-12-13 14:29   ` [PATCH v2 2/4] net/mlx4: support a device removal check operation Matan Azrad
2017-12-13 14:29   ` [PATCH v2 3/4] net/mlx5: " Matan Azrad
2017-12-13 14:29   ` [PATCH v2 4/4] net/failsafe: fix removed device handling Matan Azrad
2017-12-13 15:16     ` Gaëtan Rivet
2017-12-13 15:48       ` Matan Azrad
2017-12-13 16:09         ` Gaëtan Rivet
2017-12-13 17:09           ` Thomas Monjalon
2017-12-14 10:40             ` Matan Azrad
2017-12-13 21:55           ` Gaëtan Rivet
2017-12-14 10:40             ` Matan Azrad
2017-12-14 10:48               ` Gaëtan Rivet
2017-12-14 13:07                 ` Matan Azrad
2017-12-14 13:27                   ` Gaëtan Rivet
2017-12-14 14:43                     ` Matan Azrad
2017-12-19 17:10   ` [PATCH v3 0/6] Fail-safe\ethdev: fix removal handling lack Matan Azrad
2017-12-19 17:10     ` [PATCH v3 1/6] ethdev: add devop to check removal status Matan Azrad
2017-12-19 17:20       ` Stephen Hemminger
2017-12-19 17:24         ` Matan Azrad
2017-12-19 20:51           ` Thomas Monjalon
2017-12-19 22:13             ` Gaëtan Rivet
2017-12-20  8:39               ` Matan Azrad [this message]
2018-01-07  9:53       ` Thomas Monjalon
2017-12-19 17:10     ` [PATCH v3 2/6] net/mlx4: support a device removal check operation Matan Azrad
2017-12-19 17:10     ` [PATCH v3 3/6] net/mlx5: " Matan Azrad
2017-12-19 17:10     ` [PATCH v3 4/6] ethdev: adjust APIs removal error report Matan Azrad
2018-01-07  9:56       ` Thomas Monjalon
2017-12-19 17:10     ` [PATCH v3 5/6] ethdev: adjust flow " Matan Azrad
2018-01-07  9:58       ` Thomas Monjalon
2017-12-19 17:10     ` [PATCH v3 6/6] net/failsafe: fix removed device handling Matan Azrad
2017-12-19 22:21       ` Gaëtan Rivet
2017-12-20 10:58         ` Matan Azrad
2018-01-08 10:57           ` Gaëtan Rivet
2018-01-08 12:55             ` Matan Azrad
2018-01-08 13:46               ` Gaëtan Rivet
2018-01-08 14:00                 ` Matan Azrad
2018-01-08 14:31                   ` Gaëtan Rivet
2018-01-10 12:30     ` [PATCH v4 0/6] Fail-safe\ethdev: fix removal handling lack Matan Azrad
2018-01-10 12:31       ` [PATCH v4 1/6] ethdev: add devop to check removal status Matan Azrad
2018-01-10 12:31       ` [PATCH v4 2/6] net/mlx4: support a device removal check operation Matan Azrad
2018-01-10 12:31       ` [PATCH v4 3/6] net/mlx5: " Matan Azrad
2018-01-10 12:31       ` [PATCH v4 4/6] ethdev: adjust APIs removal error report Matan Azrad
2018-01-10 12:31       ` [PATCH v4 5/6] ethdev: adjust flow " Matan Azrad
2018-01-10 12:31       ` [PATCH v4 6/6] net/failsafe: fix removed device handling Matan Azrad
2018-01-10 12:43         ` Matan Azrad
2018-01-10 13:51           ` Gaëtan Rivet
2018-01-10 13:47         ` Gaëtan Rivet
2018-01-17 20:19       ` [PATCH v5 0/6] Fail-safe\ethdev: fix removal handling lack Matan Azrad
2018-01-17 20:19         ` [PATCH v5 1/6] ethdev: add devop to check removal status Matan Azrad
2018-01-17 20:40           ` Ferruh Yigit
2018-01-17 20:19         ` [PATCH v5 2/6] net/mlx4: support a device removal check operation Matan Azrad
2018-01-17 20:19         ` [PATCH v5 3/6] net/mlx5: " Matan Azrad
2018-01-17 20:19         ` [PATCH v5 4/6] ethdev: adjust APIs removal error report Matan Azrad
2018-01-17 20:19         ` [PATCH v5 5/6] ethdev: adjust flow " Matan Azrad
2018-01-17 20:19         ` [PATCH v5 6/6] net/failsafe: fix removed device handling Matan Azrad
2018-01-18  8:44           ` Gaëtan Rivet
2018-01-18 11:27         ` [PATCH v6 0/6] Fail-safe\ethdev: fix removal handling lack Matan Azrad
2018-01-18 11:27           ` [PATCH v6 1/6] ethdev: add devop to check removal status Matan Azrad
2018-01-18 17:18             ` Ferruh Yigit
2018-01-18 17:57               ` Adrien Mazarguil
2018-01-18 18:02               ` Matan Azrad
2018-01-18 11:27           ` [PATCH v6 2/6] net/mlx4: support a device removal check operation Matan Azrad
2018-01-18 16:59             ` Adrien Mazarguil
2018-01-18 11:27           ` [PATCH v6 3/6] net/mlx5: " Matan Azrad
2018-01-18 16:59             ` Adrien Mazarguil
2018-01-18 11:27           ` [PATCH v6 4/6] ethdev: adjust APIs removal error report Matan Azrad
2018-01-18 17:31             ` Ferruh Yigit
2018-01-18 18:10               ` Matan Azrad
2018-01-19 16:19                 ` Ferruh Yigit
2018-01-19 17:35                   ` Ananyev, Konstantin
2018-01-19 17:54                   ` Thomas Monjalon
2018-01-19 18:13                     ` Ferruh Yigit
2018-01-19 18:16                       ` Thomas Monjalon
2018-01-20 19:04                         ` Matan Azrad
2018-01-20 20:28                           ` Thomas Monjalon
2018-01-20 20:45                             ` Matan Azrad
2018-01-21 20:07                   ` Ferruh Yigit
2018-01-18 11:27           ` [PATCH v6 5/6] ethdev: adjust flow " Matan Azrad
2018-01-18 11:27           ` [PATCH v6 6/6] net/failsafe: fix removed device handling Matan Azrad
2018-01-20 21:12           ` [PATCH v7 0/6] Fail-safe\ethdev: fix removal handling lack Matan Azrad
2018-01-20 21:12             ` [PATCH v7 1/6] ethdev: add devop to check removal status Matan Azrad
2018-01-20 21:12             ` [PATCH v7 2/6] net/mlx4: support a device removal check operation Matan Azrad
2018-01-20 21:12             ` [PATCH v7 3/6] net/mlx5: " Matan Azrad
2018-01-20 21:12             ` [PATCH v7 4/6] ethdev: adjust APIs removal error report Matan Azrad
2018-01-20 21:12             ` [PATCH v7 5/6] ethdev: adjust flow " Matan Azrad
2018-01-20 21:12             ` [PATCH v7 6/6] net/failsafe: fix removed device handling Matan Azrad
2018-01-21 20:28             ` [PATCH v7 0/6] Fail-safe\ethdev: fix removal handling lack 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=HE1PR0502MB3659E82571CF9D46400AD8E1D20C0@HE1PR0502MB3659.eurprd05.prod.outlook.com \
    --to=matan@mellanox.com \
    --cc=adrien.mazarguil@6wind.com \
    --cc=dev@dpdk.org \
    --cc=gaetan.rivet@6wind.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.