DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Xu, Rosen" <rosen.xu@intel.com>
To: "Richardson, Bruce" <bruce.richardson@intel.com>,
	Nipun Gupta <nipun.gupta@nxp.com>,
	Hemant Agrawal <hemant.agrawal@nxp.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
	"Zhang, Tianfei" <tianfei.zhang@intel.com>,
	 "Li, Xiaoyun" <xiaoyun.li@intel.com>,
	"Wu, Jingjing" <jingjing.wu@intel.com>,
	 Satha Rao <skoteshwar@marvell.com>,
	Mahipal Challa <mchalla@marvell.com>,
	Jerin Jacob <jerinj@marvell.com>
Subject: Re: [dpdk-dev] [PATCH 20.11 2/5] rawdev: allow drivers to return error from info function
Date: Sun, 12 Jul 2020 14:13:21 +0000
Message-ID: <BYAPR11MB2901AA8311107CC58F6947F389630@BYAPR11MB2901.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20200709152047.167730-3-bruce.richardson@intel.com>

Hi,

Reviewed-by: Rosen Xu <rosen.xu@intel.com>

> -----Original Message-----
> From: Richardson, Bruce <bruce.richardson@intel.com>
> Sent: Thursday, July 09, 2020 23:21
> To: Nipun Gupta <nipun.gupta@nxp.com>; Hemant Agrawal
> <hemant.agrawal@nxp.com>
> Cc: dev@dpdk.org; Xu, Rosen <rosen.xu@intel.com>; Zhang, Tianfei
> <tianfei.zhang@intel.com>; Li, Xiaoyun <xiaoyun.li@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>; Satha Rao <skoteshwar@marvell.com>; Mahipal
> Challa <mchalla@marvell.com>; Jerin Jacob <jerinj@marvell.com>;
> Richardson, Bruce <bruce.richardson@intel.com>
> Subject: [PATCH 20.11 2/5] rawdev: allow drivers to return error from info
> function
> 
> Since we now allow some parameter checking inside the driver info_get()
> functions, it makes sense to allow error return from those functions to the
> caller. Therefore we change the driver callback return type from void to int.
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  drivers/raw/ifpga/ifpga_rawdev.c       | 15 ++++++++-------
>  drivers/raw/ioat/ioat_rawdev.c         |  9 ++++++---
>  drivers/raw/ntb/ntb.c                  |  8 +++++---
>  drivers/raw/skeleton/skeleton_rawdev.c |  6 ++++--
>  lib/librte_rawdev/rte_rawdev.c         |  6 ++++--
>  lib/librte_rawdev/rte_rawdev_pmd.h     |  4 ++--
>  6 files changed, 29 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/raw/ifpga/ifpga_rawdev.c
> b/drivers/raw/ifpga/ifpga_rawdev.c
> index 47cfa3877..32a2b96c9 100644
> --- a/drivers/raw/ifpga/ifpga_rawdev.c
> +++ b/drivers/raw/ifpga/ifpga_rawdev.c
> @@ -603,7 +603,7 @@ ifpga_fill_afu_dev(struct opae_accelerator *acc,
>  	return 0;
>  }
> 
> -static void
> +static int
>  ifpga_rawdev_info_get(struct rte_rawdev *dev,
>  		      rte_rawdev_obj_t dev_info,
>  		      size_t dev_info_size)
> @@ -620,12 +620,12 @@ ifpga_rawdev_info_get(struct rte_rawdev *dev,
> 
>  	if (!dev_info || dev_info_size != sizeof(*afu_dev)) {
>  		IFPGA_RAWDEV_PMD_ERR("Invalid request");
> -		return;
> +		return -EINVAL;
>  	}
> 
>  	adapter = ifpga_rawdev_get_priv(dev);
>  	if (!adapter)
> -		return;
> +		return -ENOENT;
> 
>  	afu_dev = dev_info;
>  	afu_dev->rawdev = dev;
> @@ -637,7 +637,7 @@ ifpga_rawdev_info_get(struct rte_rawdev *dev,
> 
>  		if (ifpga_fill_afu_dev(acc, afu_dev)) {
>  			IFPGA_RAWDEV_PMD_ERR("cannot get info\n");
> -			return;
> +			return -ENOENT;
>  		}
>  	}
> 
> @@ -647,21 +647,21 @@ ifpga_rawdev_info_get(struct rte_rawdev *dev,
>  		/* get LineSide BAR Index */
>  		if (opae_manager_get_eth_group_region_info(mgr, 0,
>  			&opae_lside_eth_info)) {
> -			return;
> +			return -ENOENT;
>  		}
>  		lside_bar_idx = opae_lside_eth_info.mem_idx;
> 
>  		/* get NICSide BAR Index */
>  		if (opae_manager_get_eth_group_region_info(mgr, 1,
>  			&opae_nside_eth_info)) {
> -			return;
> +			return -ENOENT;
>  		}
>  		nside_bar_idx = opae_nside_eth_info.mem_idx;
> 
>  		if (lside_bar_idx >= PCI_MAX_RESOURCE ||
>  			nside_bar_idx >= PCI_MAX_RESOURCE ||
>  			lside_bar_idx == nside_bar_idx)
> -			return;
> +			return -ENOENT;
> 
>  		/* fill LineSide BAR Index */
>  		afu_dev->mem_resource[lside_bar_idx].phys_addr = @@ -
> 679,6 +679,7 @@ ifpga_rawdev_info_get(struct rte_rawdev *dev,
>  		afu_dev->mem_resource[nside_bar_idx].addr =
>  			opae_nside_eth_info.addr;
>  	}
> +	return 0;
>  }
> 
>  static int
> diff --git a/drivers/raw/ioat/ioat_rawdev.c b/drivers/raw/ioat/ioat_rawdev.c
> index 8dd856c55..6a336795d 100644
> --- a/drivers/raw/ioat/ioat_rawdev.c
> +++ b/drivers/raw/ioat/ioat_rawdev.c
> @@ -112,15 +112,18 @@ ioat_dev_stop(struct rte_rawdev *dev)
>  	RTE_SET_USED(dev);
>  }
> 
> -static void
> +static int
>  ioat_dev_info_get(struct rte_rawdev *dev, rte_rawdev_obj_t dev_info,
>  		size_t dev_info_size)
>  {
>  	struct rte_ioat_rawdev_config *cfg = dev_info;
>  	struct rte_ioat_rawdev *ioat = dev->dev_private;
> 
> -	if (cfg != NULL && dev_info_size == sizeof(*cfg))
> -		cfg->ring_size = ioat->ring_size;
> +	if (dev_info == NULL || dev_info_size != sizeof(*cfg))
> +		return -EINVAL;
> +
> +	cfg->ring_size = ioat->ring_size;
> +	return 0;
>  }
> 
>  static const char * const xstat_names[] = { diff --git a/drivers/raw/ntb/ntb.c
> b/drivers/raw/ntb/ntb.c index 4676c6f8f..eaeb67b74 100644
> --- a/drivers/raw/ntb/ntb.c
> +++ b/drivers/raw/ntb/ntb.c
> @@ -800,7 +800,7 @@ ntb_dequeue_bufs(struct rte_rawdev *dev,
>  	return nb_rx;
>  }
> 
> -static void
> +static int
>  ntb_dev_info_get(struct rte_rawdev *dev, rte_rawdev_obj_t dev_info,
>  		size_t dev_info_size)
>  {
> @@ -809,7 +809,7 @@ ntb_dev_info_get(struct rte_rawdev *dev,
> rte_rawdev_obj_t dev_info,
> 
>  	if (dev_info_size != sizeof(*info)){
>  		NTB_LOG(ERR, "Invalid size parameter to %s", __func__);
> -		return;
> +		return -EINVAL;
>  	}
> 
>  	info->mw_cnt = hw->mw_cnt;
> @@ -824,7 +824,7 @@ ntb_dev_info_get(struct rte_rawdev *dev,
> rte_rawdev_obj_t dev_info,
> 
>  	if (!hw->queue_size || !hw->queue_pairs) {
>  		NTB_LOG(ERR, "No queue size and queue num assigned.");
> -		return;
> +		return -EAGAIN;
>  	}
> 
>  	hw->hdr_size_per_queue = RTE_ALIGN(sizeof(struct ntb_header) +
> @@ -832,6 +832,8 @@ ntb_dev_info_get(struct rte_rawdev *dev,
> rte_rawdev_obj_t dev_info,
>  				hw->queue_size * sizeof(struct ntb_used),
>  				RTE_CACHE_LINE_SIZE);
>  	info->ntb_hdr_size = hw->hdr_size_per_queue * hw->queue_pairs;
> +
> +	return 0;
>  }
> 
>  static int
> diff --git a/drivers/raw/skeleton/skeleton_rawdev.c
> b/drivers/raw/skeleton/skeleton_rawdev.c
> index dc05f3ecf..dce300c35 100644
> --- a/drivers/raw/skeleton/skeleton_rawdev.c
> +++ b/drivers/raw/skeleton/skeleton_rawdev.c
> @@ -41,7 +41,7 @@ struct queue_buffers {  static struct queue_buffers
> queue_buf[SKELETON_MAX_QUEUES] = {};  static void clear_queue_bufs(int
> queue_id);
> 
> -static void skeleton_rawdev_info_get(struct rte_rawdev *dev,
> +static int skeleton_rawdev_info_get(struct rte_rawdev *dev,
>  				     rte_rawdev_obj_t dev_info,
>  				     size_t dev_info_size)
>  {
> @@ -52,7 +52,7 @@ static void skeleton_rawdev_info_get(struct
> rte_rawdev *dev,
> 
>  	if (!dev_info || dev_info_size != sizeof(*skeldev_conf)) {
>  		SKELETON_PMD_ERR("Invalid request");
> -		return;
> +		return -EINVAL;
>  	}
> 
>  	skeldev = skeleton_rawdev_get_priv(dev); @@ -63,6 +63,8 @@
> static void skeleton_rawdev_info_get(struct rte_rawdev *dev,
>  	skeldev_conf->capabilities = skeldev->capabilities;
>  	skeldev_conf->device_state = skeldev->device_state;
>  	skeldev_conf->firmware_state = skeldev->fw.firmware_state;
> +
> +	return 0;
>  }
> 
>  static int skeleton_rawdev_configure(const struct rte_rawdev *dev, diff --
> git a/lib/librte_rawdev/rte_rawdev.c b/lib/librte_rawdev/rte_rawdev.c
> index a57689035..bde33763e 100644
> --- a/lib/librte_rawdev/rte_rawdev.c
> +++ b/lib/librte_rawdev/rte_rawdev.c
> @@ -82,6 +82,7 @@ rte_rawdev_info_get(uint16_t dev_id, struct
> rte_rawdev_info *dev_info,
>  		size_t dev_private_size)
>  {
>  	struct rte_rawdev *rawdev;
> +	int ret = 0;
> 
>  	RTE_RAWDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
>  	RTE_FUNC_PTR_OR_ERR_RET(dev_info, -EINVAL); @@ -90,7 +91,8
> @@ rte_rawdev_info_get(uint16_t dev_id, struct rte_rawdev_info
> *dev_info,
> 
>  	if (dev_info->dev_private != NULL) {
>  		RTE_FUNC_PTR_OR_ERR_RET(*rawdev->dev_ops-
> >dev_info_get, -ENOTSUP);
> -		(*rawdev->dev_ops->dev_info_get)(rawdev, dev_info-
> >dev_private,
> +		ret = (*rawdev->dev_ops->dev_info_get)(rawdev,
> +				dev_info->dev_private,
>  				dev_private_size);
>  	}
> 
> @@ -98,7 +100,7 @@ rte_rawdev_info_get(uint16_t dev_id, struct
> rte_rawdev_info *dev_info,
>  	dev_info->device = rawdev->device;
>  	dev_info->socket_id = rawdev->socket_id;
> 
> -	return 0;
> +	return ret;
>  }
> 
>  int
> diff --git a/lib/librte_rawdev/rte_rawdev_pmd.h
> b/lib/librte_rawdev/rte_rawdev_pmd.h
> index 0e72a9205..89e46412a 100644
> --- a/lib/librte_rawdev/rte_rawdev_pmd.h
> +++ b/lib/librte_rawdev/rte_rawdev_pmd.h
> @@ -142,9 +142,9 @@ rte_rawdev_pmd_is_valid_dev(uint8_t dev_id)
>   *   The size of the structure pointed to by dev_info->dev_private
>   *
>   * @return
> - *   Returns 0 on success
> + *   Returns 0 on success, negative error code on failure
>   */
> -typedef void (*rawdev_info_get_t)(struct rte_rawdev *dev,
> +typedef int (*rawdev_info_get_t)(struct rte_rawdev *dev,
>  				  rte_rawdev_obj_t dev_info,
>  				  size_t dev_private_size);
> 
> --
> 2.25.1


  reply	other threads:[~2020-07-12 14:13 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-09 15:20 [dpdk-dev] [PATCH 20.11 0/5] Enhance rawdev APIs Bruce Richardson
2020-07-09 15:20 ` [dpdk-dev] [PATCH 20.11 1/5] rawdev: add private data length parameter to info fn Bruce Richardson
2020-07-12 14:13   ` Xu, Rosen
2020-07-09 15:20 ` [dpdk-dev] [PATCH 20.11 2/5] rawdev: allow drivers to return error from info function Bruce Richardson
2020-07-12 14:13   ` Xu, Rosen [this message]
2020-07-09 15:20 ` [dpdk-dev] [PATCH 20.11 3/5] rawdev: add private data length parameter to config fn Bruce Richardson
2020-07-12 14:13   ` Xu, Rosen
2020-07-09 15:20 ` [dpdk-dev] [PATCH 20.11 4/5] rawdev: add private data length parameter to queue fns Bruce Richardson
2020-07-09 15:20 ` [dpdk-dev] [PATCH 20.11 5/5] rawdev: allow queue default config query to return error Bruce Richardson
2020-08-13 11:27 ` [dpdk-dev] [PATCH v2 0/7] Enhance rawdev APIs Bruce Richardson
2020-08-13 11:27   ` [dpdk-dev] [PATCH v2 1/7] rawdev: add private data length parameter to info fn Bruce Richardson
2020-08-17  5:26     ` Xu, Rosen
2020-08-13 11:28   ` [dpdk-dev] [PATCH v2 2/7] rawdev: allow drivers to return error from info function Bruce Richardson
2020-08-13 11:28   ` [dpdk-dev] [PATCH v2 3/7] rawdev: add private data length parameter to config fn Bruce Richardson
2020-09-04 14:16     ` Bruce Richardson
2020-08-13 11:28   ` [dpdk-dev] [PATCH v2 4/7] rawdev: add private data length parameter to queue fns Bruce Richardson
2020-08-13 11:28   ` [dpdk-dev] [PATCH v2 5/7] rawdev: allow queue default config query to return error Bruce Richardson
2020-08-13 11:28   ` [dpdk-dev] [PATCH v2 6/7] rawdev: mark start and stop functions optional Bruce Richardson
2020-08-13 11:28   ` [dpdk-dev] [PATCH v2 7/7] doc: remove rawdev deprecation notice Bruce Richardson
2020-09-02 11:21   ` [dpdk-dev] [PATCH v2 0/7] Enhance rawdev APIs Nipun Gupta
2020-09-09  9:47   ` Thomas Monjalon
2020-09-10 14:36 ` [dpdk-dev] [PATCH v3 " Bruce Richardson
2020-09-10 14:36   ` [dpdk-dev] [PATCH v3 1/7] rawdev: add private data length parameter to info fn Bruce Richardson
2020-09-10 14:36   ` [dpdk-dev] [PATCH v3 2/7] rawdev: allow drivers to return error from info function Bruce Richardson
2020-09-10 14:36   ` [dpdk-dev] [PATCH v3 3/7] rawdev: add private data length parameter to config fn Bruce Richardson
2020-09-10 14:36   ` [dpdk-dev] [PATCH v3 4/7] rawdev: add private data length parameter to queue fns Bruce Richardson
2020-09-10 14:36   ` [dpdk-dev] [PATCH v3 5/7] rawdev: allow queue config query to return error Bruce Richardson
2020-09-10 14:36   ` [dpdk-dev] [PATCH v3 6/7] rawdev: mark start and stop functions optional Bruce Richardson
2020-09-10 14:36   ` [dpdk-dev] [PATCH v3 7/7] doc: remove rawdev deprecation notice Bruce Richardson
2020-09-11  9:56   ` [dpdk-dev] [PATCH v3 0/7] Enhance rawdev APIs Thomas Monjalon

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=BYAPR11MB2901AA8311107CC58F6947F389630@BYAPR11MB2901.namprd11.prod.outlook.com \
    --to=rosen.xu@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    --cc=jerinj@marvell.com \
    --cc=jingjing.wu@intel.com \
    --cc=mchalla@marvell.com \
    --cc=nipun.gupta@nxp.com \
    --cc=skoteshwar@marvell.com \
    --cc=tianfei.zhang@intel.com \
    --cc=xiaoyun.li@intel.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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ http://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git