DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Xing, Beilei" <beilei.xing@intel.com>
To: "Xia, Chenbo" <chenbo.xia@intel.com>,
	"dev@dpdk.org" <dev@dpdk.org>,
	"thomas@monjalon.net" <thomas@monjalon.net>,
	"david.marchand@redhat.com" <david.marchand@redhat.com>
Cc: "stephen@networkplumber.org" <stephen@networkplumber.org>,
	"Liang, Cunming" <cunming.liang@intel.com>,
	"Lu, Xiuchun" <xiuchun.lu@intel.com>,
	"Li, Miao" <miao.li@intel.com>,
	"Wu, Jingjing" <jingjing.wu@intel.com>
Subject: Re: [dpdk-dev] [PATCH 4/8] emu/iavf: add vfio-user device register and	unregister
Date: Thu, 7 Jan 2021 07:18:50 +0000	[thread overview]
Message-ID: <MN2PR11MB3807154E1C372EC8002C0C0DF7AF0@MN2PR11MB3807.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20201218074736.93999-5-chenbo.xia@intel.com>



> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Chenbo Xia
> Sent: Friday, December 18, 2020 3:48 PM
> To: dev@dpdk.org; thomas@monjalon.net; david.marchand@redhat.com
> Cc: stephen@networkplumber.org; Liang, Cunming
> <cunming.liang@intel.com>; Lu, Xiuchun <xiuchun.lu@intel.com>; Li, Miao
> <miao.li@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>
> Subject: [dpdk-dev] [PATCH 4/8] emu/iavf: add vfio-user device register and
> unregister
> 
> This patch adds vfio-user APIs call in driver probe and remove.
> rte_vfio_user_register() and rte_vfio_user_unregister() are called to
> create/destroy a vfio-user device. Notify callbacks that libvfio_user defines are
> also implemented.
> 
> Signed-off-by: Chenbo Xia <chenbo.xia@intel.com>
> Signed-off-by: Miao Li <miao.li@intel.com>
> ---


> +static struct iavf_emudev *find_iavf_with_dev_id(int vfio_dev_id) {

It's better to change the function name to follow other function names' style.
iavf_emu_xxx 

> +	struct iavf_emu_sock_list *list;
> +	char sock_addr[PATH_MAX];
> +	int ret;
> +
> +	ret = rte_vfio_get_sock_addr(vfio_dev_id, sock_addr,
> +		sizeof(sock_addr));
> +	if (ret) {
> +		EMU_IAVF_LOG(ERR, "Can not find vfio device %d "
> +			"sock_addr.\n", vfio_dev_id);
> +		return NULL;
> +	}
> +
> +	list = iavf_emu_find_sock_list(sock_addr);
> +	if (!list) {
> +		EMU_IAVF_LOG(ERR, "Can not find sock list.\n");
> +		return NULL;
> +	}
> +
> +	return (struct iavf_emudev *)list->emu_dev->priv_data; }

It's better to check if list->emu_dev is NULL first.

> +
> +static int iavf_emu_new_device(int vfio_dev_id) {
> +	struct iavf_emudev *dev;
> +	int ret;
> +
> +	dev = find_iavf_with_dev_id(vfio_dev_id);
> +	if (!dev)
> +		return -1;
> +
> +	dev->vfio->dev_id = vfio_dev_id;
> +
> +	ret = iavf_emu_setup_mem_table(dev);
> +	if (ret) {
> +		EMU_IAVF_LOG(ERR, "Failed to set up memtable for "
> +			"device %d", dev->vfio->dev_id);
> +		return ret;
> +	}
> +
> +	ret = iavf_emu_setup_irq(dev);
> +	if (ret) {
> +		EMU_IAVF_LOG(ERR, "Failed to set up irq for "
> +			"device %d", dev->vfio->dev_id);
> +		return ret;
> +	}
> +
> +	ret = iavf_emu_setup_queues(dev);
> +	if (ret) {
> +		EMU_IAVF_LOG(ERR, "Failed to set up queues for "
> +			"device %d", dev->vfio->dev_id);
> +		return ret;
> +	}
> +
> +	ret = dev->ops->device_ready(dev->edev);

Same as above, and please also check other functions, such as device_destroy...

> +	if (ret)
> +		return ret;
> +
> +	dev->ready = 1;
> +	return 0;
> +}
> +
> +static void iavf_emu_destroy_device(int vfio_dev_id) {
> +	struct iavf_emudev *dev;
> +
> +	dev = find_iavf_with_dev_id(vfio_dev_id);
> +	if (!dev)
> +		return;
> +
> +	iavf_emu_reset_all_resources(dev);

Should we add 'dev->ready = 0' here?

> +
> +	dev->ops->device_destroy(dev->edev);
> +}
> +



> +static int iavf_emu_lock_datapath(int vfio_dev_id, int lock) {
> +	struct iavf_emudev *dev;
> +
> +	dev = find_iavf_with_dev_id(vfio_dev_id);
> +	if (!dev)
> +		return -1;
> +
> +	return dev->ops->lock_dp(dev->edev, lock); }
> +
> +static int iavf_emu_reset_device(int vfio_dev_id) {
> +	struct iavf_emudev *dev;
> +
> +	dev = find_iavf_with_dev_id(vfio_dev_id);
> +	if (!dev)
> +		return -1;
> +
> +	iavf_emu_reset_all_resources(dev);

Should we add 'dev->ready = 0' here?

> +
> +	return dev->ops->reset_device(dev->edev);
> +}
> +


  reply	other threads:[~2021-01-07  7:18 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-18  7:47 [dpdk-dev] [PATCH 0/8] Introduce emudev library and iavf emudev driver Chenbo Xia
2020-12-18  7:47 ` [dpdk-dev] [PATCH 1/8] lib: introduce emudev library Chenbo Xia
2020-12-18  7:47 ` [dpdk-dev] [PATCH 2/8] doc: add emudev library guide Chenbo Xia
2020-12-18  7:47 ` [dpdk-dev] [PATCH 3/8] emu: introduce emulated iavf driver Chenbo Xia
2020-12-18  7:47 ` [dpdk-dev] [PATCH 4/8] emu/iavf: add vfio-user device register and unregister Chenbo Xia
2021-01-07  7:18   ` Xing, Beilei [this message]
2021-01-07  8:41     ` Xia, Chenbo
2020-12-18  7:47 ` [dpdk-dev] [PATCH 5/8] emu/iavf: add resource management and internal logic of iavf Chenbo Xia
2020-12-18  7:47 ` [dpdk-dev] [PATCH 6/8] emu/iavf: add emudev operations to fit in emudev framework Chenbo Xia
2020-12-18  7:47 ` [dpdk-dev] [PATCH 7/8] test/emudev: introduce functional test Chenbo Xia
2020-12-18  7:47 ` [dpdk-dev] [PATCH 8/8] doc: update release notes for iavf emudev driver Chenbo Xia
2020-12-18  9:53 ` [dpdk-dev] [PATCH 0/8] Introduce emudev library and " David Marchand
2020-12-19  6:11   ` Xia, Chenbo
2020-12-21  9:52     ` Maxime Coquelin
2020-12-21 12:01       ` Maxime Coquelin
2020-12-22  3:09         ` Xia, Chenbo
2020-12-22  8:48           ` Maxime Coquelin
2020-12-23  5:28             ` Xia, Chenbo
2020-12-19  6:27 ` [dpdk-dev] [PATCH v2 " Chenbo Xia
2020-12-19  6:27   ` [dpdk-dev] [PATCH v2 1/8] lib: introduce emudev library Chenbo Xia
2020-12-19  6:28   ` [dpdk-dev] [PATCH v2 2/8] doc: add emudev library guide Chenbo Xia
2020-12-19  6:28   ` [dpdk-dev] [PATCH v2 3/8] emu: introduce emulated iavf driver Chenbo Xia
2020-12-19  6:28   ` [dpdk-dev] [PATCH v2 4/8] emu/iavf: add vfio-user device register and unregister Chenbo Xia
2021-01-04  6:45     ` Wu, Jingjing
2021-01-05  1:26       ` Xia, Chenbo
2021-01-05 13:41     ` Wu, Jingjing
2021-01-06  7:41       ` Xia, Chenbo
2020-12-19  6:28   ` [dpdk-dev] [PATCH v2 5/8] emu/iavf: add resource management and internal logic of iavf Chenbo Xia
2020-12-29  6:05     ` Wu, Jingjing
2020-12-30  1:59       ` Xia, Chenbo
2020-12-19  6:28   ` [dpdk-dev] [PATCH v2 6/8] emu/iavf: add emudev operations to fit in emudev framework Chenbo Xia
2020-12-19  6:28   ` [dpdk-dev] [PATCH v2 7/8] test/emudev: introduce functional test Chenbo Xia
2020-12-19  6:28   ` [dpdk-dev] [PATCH v2 8/8] doc: update release notes for iavf emudev driver Chenbo Xia
2021-01-13 16:52   ` [dpdk-dev] [PATCH v2 0/8] Introduce emudev library and " Thomas Monjalon
2021-01-14  1:35     ` Xia, Chenbo
2021-01-14  6:25   ` [dpdk-dev] [PATCH v3 " Chenbo Xia
2021-01-14  6:25     ` [dpdk-dev] [PATCH v3 1/8] lib: introduce emudev library Chenbo Xia
2021-01-14  6:25     ` [dpdk-dev] [PATCH v3 2/8] doc: add emudev library guide Chenbo Xia
2021-01-14  6:25     ` [dpdk-dev] [PATCH v3 3/8] emu: introduce emulated iavf driver Chenbo Xia
2021-01-14  6:25     ` [dpdk-dev] [PATCH v3 4/8] emu/iavf: add vfio-user device register and unregister Chenbo Xia
2021-01-14  6:25     ` [dpdk-dev] [PATCH v3 5/8] emu/iavf: add resource management and internal logic of iavf Chenbo Xia
2021-01-14  6:25     ` [dpdk-dev] [PATCH v3 6/8] emu/iavf: add emudev operations to fit in emudev framework Chenbo Xia
2021-01-14  6:25     ` [dpdk-dev] [PATCH v3 7/8] test/emudev: introduce functional test Chenbo Xia
2021-01-14  6:25     ` [dpdk-dev] [PATCH v3 8/8] doc: update release notes for iavf emudev driver Chenbo Xia
2024-02-12 22:49     ` [dpdk-dev] [PATCH v3 0/8] Introduce emudev library and " Stephen Hemminger
2023-06-14 19:47 ` [dpdk-dev] [PATCH " Stephen Hemminger

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=MN2PR11MB3807154E1C372EC8002C0C0DF7AF0@MN2PR11MB3807.namprd11.prod.outlook.com \
    --to=beilei.xing@intel.com \
    --cc=chenbo.xia@intel.com \
    --cc=cunming.liang@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=miao.li@intel.com \
    --cc=stephen@networkplumber.org \
    --cc=thomas@monjalon.net \
    --cc=xiuchun.lu@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
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).