[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC XEN PATCH v11 7/8] tools: Add new function to get gsi from dev


  • To: Anthony PERARD <anthony@xxxxxxxxxxxxxx>
  • From: "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Date: Thu, 4 Jul 2024 03:03:33 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0ZYjynGsoSFoz0htLmbACSNtfQnTyz8AgRZKLv/fBn4=; b=COBGS/mG7eFBEypceJaritB9OJ2/vCbc4fGAjrTyIxyjpzr2jlvGmDbEbyuN7jfNyIhJdWzbHgypfogZ6wyrV1Snw2BYilbzsTK9FDObhGOjkPS4bHRd5VwMrDPt8AHRwCuBGNGAftESGABsttNtJDwTZpCS8/UhaZnLPPECp478PNibqMzovi7S+dEdBkJ7xzDEk98OZ3mXC7ZlaE+XM1Ng3ACfoTaurpfNVxOn9woGPJGfHxbqnjVoD3W7pppWBWa875a0iZ0Er+hX+JhVkt3+vs/o9e2v01ZCVT+/30JEuaCeBRYXEKvB9iXns/AhANdVXzKVwPw37grQlv360w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RdW1GDJJb99V8mQtbx/VAq7Tx1vWoYMydRH5Ybg/3qdqe2isWQ5XPO1zkbxdVJKD8yIDN3o0pXUWJ10qyWMNdDxIVFXu6tjmgdd3XA6X3YewEbtkQrX8pc50BgvRTE3vpsmCdYnrpnoM2y+ugOIvX5Nr7SGut4zw0puIpROzsqSrOQCiqH+LfN+Z1+V3TZIPW09mzGgoQVYr4dth4r2hAhVLR0rn7n7wttSNICSCRUAGWeonA8oLO0uWKSEp2+L1FDdlW4LH0m5hWzM3DoxSyemju3SF+fn4dzQnXFndaWU1DTYzdzIBenRF9MtWb+F6AY5cPPAStpr854gpcWyc8Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <gwd@xxxxxxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, "Daniel P . Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, "Hildebrand, Stewart" <Stewart.Hildebrand@xxxxxxx>, "Huang, Ray" <Ray.Huang@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Delivery-date: Thu, 04 Jul 2024 03:03:48 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHayundYHEz4Kn0sEizSQnui4wvzbHhe8EAgAHYIoCAAxhTAA==
  • Thread-topic: [RFC XEN PATCH v11 7/8] tools: Add new function to get gsi from dev

Hi Anthony,

On 2024/7/2 11:47, Chen, Jiqian wrote:
> On 2024/7/1 15:32, Jan Beulich wrote:
>> On 30.06.2024 14:33, Jiqian Chen wrote:
>>> --- a/tools/libs/ctrl/xc_physdev.c
>>> +++ b/tools/libs/ctrl/xc_physdev.c
>>> @@ -111,3 +111,38 @@ int xc_physdev_unmap_pirq(xc_interface *xch,
>>>      return rc;
>>>  }
>>>  
>>> +int xc_physdev_gsi_from_pcidev(xc_interface *xch, uint32_t sbdf)
>>> +{
>>> +    int rc = -1;
>>> +
>>> +#if defined(__linux__)
>>> +    int fd;
>>> +    privcmd_gsi_from_pcidev_t dev_gsi = {
>>> +        .sbdf = sbdf,
>>> +        .gsi = 0,
>>> +    };
>>> +
>>> +    fd = open("/dev/xen/privcmd", O_RDWR);
>>> +
>>> +    if (fd < 0 && (errno == ENOENT || errno == ENXIO || errno == ENODEV)) {
>>> +        /* Fallback to /proc/xen/privcmd */
>>> +        fd = open("/proc/xen/privcmd", O_RDWR);
>>> +    }
>>> +
>>> +    if (fd < 0) {
>>> +        PERROR("Could not obtain handle on privileged command interface");
>>> +        return rc;
>>> +    }
>>> +
>>> +    rc = ioctl(fd, IOCTL_PRIVCMD_GSI_FROM_PCIDEV, &dev_gsi);
>>> +    close(fd);
>>> +
>>> +    if (rc) {
>>> +        PERROR("Failed to get gsi from dev");
>>> +    } else {
>>> +        rc = dev_gsi.gsi;
>>> +    }
>>> +#endif
>>> +
>>> +    return rc;
>>> +}
>>
>> I realize Anthony had asked to move this out of libxencall, yet doing it like
>> this (without really abstracting away the OS specifics) doesn't look quite
>> right either. In particular the opening of /dev/xen/privcmd looks 
>> questionable
>> to now have yet another instance in yet another library. Couldn't we split
>> osdep_xencall_open(), making available its former half for use here and in 
>> the
>> other two libraries? 
> Hi Anthony, what about your opinion?
What's your opinion about taking " opening of /dev/xen/privcmd " as a single 
function, then use it in this patch and other libraries?

> 
>> Of course that'll still leave the ioctl() invocation, which necessarily is 
>> OS-specific, too.
>>
>> Jan
> 

-- 
Best regards,
Jiqian Chen.

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.