DPDK patches and discussions
 help / color / mirror / Atom feed
From: Vijay Kumar Srivastava <vsrivast@xilinx.com>
To: "Mattias Rönnblom" <hofors@lysator.liu.se>,
	"dev@dpdk.org" <dev@dpdk.org>
Cc: "maxime.coquelin@redhat.com" <maxime.coquelin@redhat.com>,
	"chenbo.xia@intel.com" <chenbo.xia@intel.com>,
	"andrew.rybchenko@oktetlabs.ru" <andrew.rybchenko@oktetlabs.ru>,
	Praveen Kumar Jain <praveenj@xilinx.com>
Subject: Re: [dpdk-dev] [PATCH v3 01/10] vdpa/sfc: introduce Xilinx vDPA driver
Date: Mon, 1 Nov 2021 08:13:50 +0000	[thread overview]
Message-ID: <SJ0PR02MB73276C1266F030868F8169E8B98A9@SJ0PR02MB7327.namprd02.prod.outlook.com> (raw)
In-Reply-To: <4c336c1a-bc2a-4b10-4353-530f06547505@lysator.liu.se>

Hi Mattias,

>-----Original Message-----
>From: Mattias Rönnblom <hofors@lysator.liu.se>
>Sent: Saturday, October 30, 2021 1:38 AM
>To: Vijay Kumar Srivastava <vsrivast@xilinx.com>; dev@dpdk.org
>Cc: maxime.coquelin@redhat.com; chenbo.xia@intel.com; 
>andrew.rybchenko@oktetlabs.ru; Vijay Kumar Srivastava 
><vsrivast@xilinx.com>
>Subject: Re: [dpdk-dev] [PATCH v3 01/10] vdpa/sfc: introduce Xilinx 
>vDPA driver
>
>On 2021-10-29 16:46, Vijay Srivastava wrote:
>> From: Vijay Kumar Srivastava <vsrivast@xilinx.com>

[SNIP]
>>
>> +struct sfc_vdpa_adapter *
>> +sfc_vdpa_get_adapter_by_dev(struct rte_pci_device *pdev) {
>> +	bool found = false;
>> +	struct sfc_vdpa_adapter *sva;
>
>Remove found flag and set sva to NULL here instead.
This flag is needed for the scenario when  pdev != sva->pdev.
In this scenario, sva would be non-null and it should not be returned. 
So I think it's OK to keep this flag. 

>> +
>> +	pthread_mutex_lock(&sfc_vdpa_adapter_list_lock);
>> +
>> +	TAILQ_FOREACH(sva, &sfc_vdpa_adapter_list, next) {
>> +		if (pdev == sva->pdev) {
>> +			found = true;
>> +			break;
>> +		}
>> +	}
>> +
>> +	pthread_mutex_unlock(&sfc_vdpa_adapter_list_lock);
>> +
>> +	return found ? sva : NULL;
>> +}
>> +
>> +static int
>> +sfc_vdpa_vfio_setup(struct sfc_vdpa_adapter *sva) {
>> +	struct rte_pci_device *dev = sva->pdev;
>> +	char dev_name[RTE_DEV_NAME_MAX_LEN] = {0};
>> +	int rc;
>> +
>> +	if (dev == NULL)
>> +		goto fail_inval;
>> +
>> +	rte_pci_device_name(&dev->addr, dev_name,
>RTE_DEV_NAME_MAX_LEN);
>> +
>> +	sva->vfio_container_fd = rte_vfio_container_create();
>> +	if (sva->vfio_container_fd < 0)	{
>> +		sfc_vdpa_err(sva, "failed to create VFIO container");
>> +		goto fail_container_create;
>> +	}
>> +
>> +	rc = rte_vfio_get_group_num(rte_pci_get_sysfs_path(), dev_name,
>> +				    &sva->iommu_group_num);
>> +	if (rc <= 0) {
>
>Only rc < 0 guarantees that rte_errno is set.
rte_vfio_get_group_num retunrs >0 on success 0 for non-existent group or VFIO <0 for errors so used check '(rc <= 0)' looks OK.

>> +		sfc_vdpa_err(sva, "failed to get IOMMU group for %s : %s",
>> +			     dev_name, rte_strerror(-rc));
>> +		goto fail_get_group_num;
>> +	}
>> +
>> +	sva->vfio_group_fd =
>> +		rte_vfio_container_group_bind(sva->vfio_container_fd,
>> +					      sva->iommu_group_num);
>> +	if (sva->vfio_group_fd < 0) {
>> +		sfc_vdpa_err(sva,
>> +			     "failed to bind IOMMU group %d to container %d",
>> +			     sva->iommu_group_num, sva->vfio_container_fd);
>> +		goto fail_group_bind;
>> +	}
>> +
>> +	if (rte_pci_map_device(dev) != 0) {
>> +		sfc_vdpa_err(sva, "failed to map PCI device %s : %s",
>> +			     dev_name, rte_strerror(rte_errno));
>> +		goto fail_pci_map_device;
>> +	}
>> +
>> +	sva->vfio_dev_fd = rte_intr_dev_fd_get(dev->intr_handle);
>> +
>> +	return 0;
>> +
>> +fail_pci_map_device:
>> +	if (rte_vfio_container_group_unbind(sva->vfio_container_fd,
>> +					sva->iommu_group_num) != 0) {
>> +		sfc_vdpa_err(sva,
>> +			     "failed to unbind IOMMU group %d from container
>%d",
>> +			     sva->iommu_group_num, sva->vfio_container_fd);
>> +	}
>> +
>> +fail_group_bind:
>> +fail_get_group_num:
>> +	if (rte_vfio_container_destroy(sva->vfio_container_fd) != 0) {
>
>Don't use braces for single statements, per DPDK coding style.
As per DPDK coding guidelines : 
"Do not use braces ({ and }) for control statements with zero or just a single statement, unless that statement is more 
than a single line in which case the braces are permitted." 

I believe it can be applied here as well as it has more than one line.

Regards,
Vijay

>> +		sfc_vdpa_err(sva, "failed to destroy container %d",
>> +			     sva->vfio_container_fd);
>> +	}

[SNIP]



  reply	other threads:[~2021-11-01  8:13 UTC|newest]

Thread overview: 122+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-06 16:44 [dpdk-dev] [PATCH 00/10] " Vijay Srivastava
2021-07-06 16:44 ` [dpdk-dev] [PATCH 01/10] " Vijay Srivastava
2021-08-11  2:26   ` Xia, Chenbo
2021-08-13  8:38     ` Andrew Rybchenko
2021-08-13  9:23       ` Xia, Chenbo
2021-08-13  9:31         ` Andrew Rybchenko
2021-08-16  1:35           ` Xia, Chenbo
2021-08-13 15:34   ` Stephen Hemminger
2021-08-13 15:36   ` Stephen Hemminger
2021-10-29 11:32     ` Vijay Kumar Srivastava
2021-08-13 15:36   ` Stephen Hemminger
2021-10-28 18:13     ` Vijay Kumar Srivastava
2021-07-06 16:44 ` [dpdk-dev] [PATCH 02/10] vdpa/sfc: add support for device initialization Vijay Srivastava
2021-08-30  9:16   ` Maxime Coquelin
2021-08-30 10:52   ` Xia, Chenbo
2021-09-03 13:19     ` Vijay Kumar Srivastava
2021-09-06  3:02       ` Xia, Chenbo
2021-10-01 17:31         ` Vijay Kumar Srivastava
2021-10-09  3:06           ` Xia, Chenbo
2021-10-18 10:06             ` Vijay Kumar Srivastava
2021-10-19  2:16               ` Xia, Chenbo
2021-10-25  6:11                 ` Vijay Kumar Srivastava
2021-07-06 16:44 ` [dpdk-dev] [PATCH 03/10] vdpa/sfc: add support to get device and protocol features Vijay Srivastava
2021-08-30  9:34   ` Maxime Coquelin
2021-07-06 16:44 ` [dpdk-dev] [PATCH 04/10] vdpa/sfc: get device supported max queue count Vijay Srivastava
2021-08-30  9:35   ` Maxime Coquelin
2021-07-06 16:44 ` [dpdk-dev] [PATCH 05/10] vdpa/sfc: add support to get VFIO device fd Vijay Srivastava
2021-08-30  9:39   ` Maxime Coquelin
2021-07-06 16:44 ` [dpdk-dev] [PATCH 06/10] vdpa/sfc: add support for dev conf and dev close ops Vijay Srivastava
2021-08-30 11:35   ` Maxime Coquelin
2021-09-03 13:22     ` Vijay Kumar Srivastava
2021-07-06 16:44 ` [dpdk-dev] [PATCH 07/10] vdpa/sfc: add support to get queue notify area info Vijay Srivastava
2021-08-30 13:22   ` Maxime Coquelin
2021-07-06 16:44 ` [dpdk-dev] [PATCH 08/10] vdpa/sfc: add support for MAC filter config Vijay Srivastava
2021-08-30 13:47   ` Maxime Coquelin
2021-09-03 13:20     ` Vijay Kumar Srivastava
2021-07-06 16:44 ` [dpdk-dev] [PATCH 09/10] vdpa/sfc: add support to set vring state Vijay Srivastava
2021-08-30 13:58   ` Maxime Coquelin
2021-07-06 16:44 ` [dpdk-dev] [PATCH 10/10] vdpa/sfc: set a multicast filter during vDPA init Vijay Srivastava
2021-07-07  8:30 ` [dpdk-dev] [PATCH 00/10] vdpa/sfc: introduce Xilinx vDPA driver Xia, Chenbo
2021-07-07 11:09 ` Andrew Rybchenko
2021-10-27 13:18 ` Maxime Coquelin
2021-10-27 15:04   ` Andrew Rybchenko
2021-10-27 19:56     ` Maxime Coquelin
2021-10-28 18:01     ` Vijay Kumar Srivastava
2021-10-28  7:54 ` [dpdk-dev] [PATCH v2 " Vijay Srivastava
2021-10-28  7:54   ` [dpdk-dev] [PATCH v2 01/10] " Vijay Srivastava
2021-10-28  8:21     ` Xia, Chenbo
2021-10-28  7:54   ` [dpdk-dev] [PATCH v2 02/10] vdpa/sfc: add support for device initialization Vijay Srivastava
2021-10-28  7:54   ` [dpdk-dev] [PATCH v2 03/10] vdpa/sfc: add support to get device and protocol features Vijay Srivastava
2021-10-28  7:54   ` [dpdk-dev] [PATCH v2 04/10] vdpa/sfc: get device supported max queue count Vijay Srivastava
2021-10-28  7:54   ` [dpdk-dev] [PATCH v2 05/10] vdpa/sfc: add support to get VFIO device fd Vijay Srivastava
2021-10-28  7:54   ` [dpdk-dev] [PATCH v2 06/10] vdpa/sfc: add support for dev conf and dev close ops Vijay Srivastava
2021-10-28  7:54   ` [dpdk-dev] [PATCH v2 07/10] vdpa/sfc: add support to get queue notify area info Vijay Srivastava
2021-10-28  7:54   ` [dpdk-dev] [PATCH v2 08/10] vdpa/sfc: add support for MAC filter config Vijay Srivastava
2021-10-28  7:54   ` [dpdk-dev] [PATCH v2 09/10] vdpa/sfc: add support to set vring state Vijay Srivastava
2021-10-28  7:54   ` [dpdk-dev] [PATCH v2 10/10] vdpa/sfc: set a multicast filter during vDPA init Vijay Srivastava
2021-10-28  8:08   ` [dpdk-dev] [PATCH v2 00/10] vdpa/sfc: introduce Xilinx vDPA driver Xia, Chenbo
2021-10-28  8:11     ` Maxime Coquelin
2021-10-28 14:35   ` Maxime Coquelin
2021-10-28 18:03     ` Vijay Kumar Srivastava
2021-10-29 14:46 ` [dpdk-dev] [PATCH v3 " Vijay Srivastava
2021-10-29 14:46   ` [dpdk-dev] [PATCH v3 01/10] " Vijay Srivastava
2021-10-29 20:07     ` Mattias Rönnblom
2021-11-01  8:13       ` Vijay Kumar Srivastava [this message]
2021-11-01  8:30     ` Xia, Chenbo
2021-11-01  8:59       ` Andrew Rybchenko
2021-11-01  9:10         ` Xia, Chenbo
2021-11-01  9:53       ` Vijay Kumar Srivastava
2021-10-29 14:46   ` [dpdk-dev] [PATCH v3 02/10] vdpa/sfc: add support for device initialization Vijay Srivastava
2021-10-29 20:21     ` Mattias Rönnblom
2021-11-01  8:09       ` Andrew Rybchenko
2021-11-01 11:48     ` Xia, Chenbo
2021-11-02  4:38       ` Vijay Kumar Srivastava
2021-11-02  5:16         ` Xia, Chenbo
2021-11-02  9:50           ` Vijay Kumar Srivastava
2021-11-02  7:42       ` Vijay Kumar Srivastava
2021-11-02  7:50         ` Xia, Chenbo
2021-10-29 14:46   ` [dpdk-dev] [PATCH v3 03/10] vdpa/sfc: add support to get device and protocol features Vijay Srivastava
2021-11-02  7:09     ` Xia, Chenbo
2021-10-29 14:46   ` [dpdk-dev] [PATCH v3 04/10] vdpa/sfc: get device supported max queue count Vijay Srivastava
2021-11-02  7:10     ` Xia, Chenbo
2021-10-29 14:46   ` [dpdk-dev] [PATCH v3 05/10] vdpa/sfc: add support to get VFIO device fd Vijay Srivastava
2021-11-02  7:10     ` Xia, Chenbo
2021-10-29 14:46   ` [dpdk-dev] [PATCH v3 06/10] vdpa/sfc: add support for dev conf and dev close ops Vijay Srivastava
2021-11-02  7:10     ` Xia, Chenbo
2021-10-29 14:46   ` [dpdk-dev] [PATCH v3 07/10] vdpa/sfc: add support to get queue notify area info Vijay Srivastava
2021-11-02  7:35     ` Xia, Chenbo
2021-11-02  9:47       ` Vijay Kumar Srivastava
2021-10-29 14:46   ` [dpdk-dev] [PATCH v3 08/10] vdpa/sfc: add support for MAC filter config Vijay Srivastava
2021-11-02  8:18     ` Xia, Chenbo
2021-10-29 14:46   ` [dpdk-dev] [PATCH v3 09/10] vdpa/sfc: add support to set vring state Vijay Srivastava
2021-11-02  8:18     ` Xia, Chenbo
2021-10-29 14:46   ` [dpdk-dev] [PATCH v3 10/10] vdpa/sfc: set a multicast filter during vDPA init Vijay Srivastava
2021-11-02  8:18     ` Xia, Chenbo
2021-11-03 13:57 ` [dpdk-dev] [PATCH v4 00/10] vdpa/sfc: introduce Xilinx vDPA driver Vijay Srivastava
2021-11-03 13:57   ` [dpdk-dev] [PATCH v4 01/10] " Vijay Srivastava
2021-11-04  9:28     ` Maxime Coquelin
2021-11-05  9:01     ` Ferruh Yigit
2021-11-05  9:03       ` Maxime Coquelin
2021-11-05  9:09         ` Ferruh Yigit
2021-11-05  9:13     ` Ferruh Yigit
2021-11-05  9:28       ` Andrew Rybchenko
2021-11-05  9:40         ` Ferruh Yigit
2021-11-08  9:34           ` Hemant Agrawal
2021-11-05  9:42     ` Ferruh Yigit
2021-11-05 10:07     ` Ferruh Yigit
2021-11-03 13:57   ` [dpdk-dev] [PATCH v4 02/10] vdpa/sfc: add support for device initialization Vijay Srivastava
2021-11-04  9:54     ` Maxime Coquelin
2021-11-03 13:57   ` [dpdk-dev] [PATCH v4 03/10] vdpa/sfc: add support to get device and protocol features Vijay Srivastava
2021-11-03 13:57   ` [dpdk-dev] [PATCH v4 04/10] vdpa/sfc: get device supported max queue count Vijay Srivastava
2021-11-03 13:57   ` [dpdk-dev] [PATCH v4 05/10] vdpa/sfc: add support to get VFIO device fd Vijay Srivastava
2021-11-03 13:57   ` [dpdk-dev] [PATCH v4 06/10] vdpa/sfc: add support for dev conf and dev close ops Vijay Srivastava
2021-11-04 10:15     ` Maxime Coquelin
2021-11-03 13:57   ` [dpdk-dev] [PATCH v4 07/10] vdpa/sfc: add support to get queue notify area info Vijay Srivastava
2021-11-04 10:50     ` Maxime Coquelin
2021-11-03 13:57   ` [dpdk-dev] [PATCH v4 08/10] vdpa/sfc: add support for MAC filter config Vijay Srivastava
2021-11-04 10:58     ` Maxime Coquelin
2021-11-03 13:57   ` [dpdk-dev] [PATCH v4 09/10] vdpa/sfc: add support to set vring state Vijay Srivastava
2021-11-03 13:57   ` [dpdk-dev] [PATCH v4 10/10] vdpa/sfc: set a multicast filter during vDPA init Vijay Srivastava
2021-11-04 11:12     ` Maxime Coquelin
2021-11-04 13:07   ` [dpdk-dev] [PATCH v4 00/10] vdpa/sfc: introduce Xilinx vDPA driver Maxime Coquelin

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=SJ0PR02MB73276C1266F030868F8169E8B98A9@SJ0PR02MB7327.namprd02.prod.outlook.com \
    --to=vsrivast@xilinx.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=chenbo.xia@intel.com \
    --cc=dev@dpdk.org \
    --cc=hofors@lysator.liu.se \
    --cc=maxime.coquelin@redhat.com \
    --cc=praveenj@xilinx.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).