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

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


  • To: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • From: "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Date: Tue, 9 Jul 2024 03:35:57 +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=O9gW7fR8eSICDQIfmHec3S38yz13C4jhgvYXpd6VyxM=; b=eE/vtET2WLwLxd3n0Ccptjwy4z6x4H/+DMlH1slL/Cu9gCJfjw8TI+9kqozFzdz8pc8j6b2F4cmPl8NozlgSgist2cCYqCnOjYFubiSezxRq58n4OxCGQOKtDgvsLHZld3YNw678JoOUFWEAEBmL7aKnBzfWF8DcIlYQXLRidbwAEn5V1qLB6VcN6jwD07oPNoAsJm7k0sSoeznWFuOsHvyl1zVQljg52mIZep03jfgdYRfkMRuzWEJi/U9CjcAJYbgm7k4s6fa5kXCeJEjixDJMRhy+k2xOlv2sW8C8cBJNyj9kMASN58jLGfLUjLF8RzahDWEfqWpL67rY6JQTdg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W3OpSaE+PXLT17IXNx80wAn4gjLbmVjuC1COvAc3ThKKqGUwSi8/8aK/R6NUD6w1i9UgdledJYDZsTR0q7hRhl8JlHdhsE/U9wI6xPqIRF994T1QWnCP/+yzPjFSyuVQI32L/Fx+i9guoghMYzORUcm3beESG3sl5DpBhVGZHnT1mUm/6I2Ivt0J1wVBDA2C3jib2atxoJf/VH/+7dS9MhG76KxxDDBOvp9o7yexmQbPsVGNffwK1uA5ri+xcOTSA14osxdzkU9yFkBnEZZPl8Ia+sLBOcu3RxhwcZkT2MRY0HWT7URAUOXVaQotj0fVhMjWguPAMhg0WNJrbjECcQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, 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>, "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
  • Delivery-date: Tue, 09 Jul 2024 03:36:14 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHa0Svedv1p7hOYckC70HcmNEElN7Hs0raAgAFpqwA=
  • Thread-topic: [RFC XEN PATCH v12 6/7] tools: Add new function to get gsi from dev

On 2024/7/8 21:27, Anthony PERARD wrote:
> On Mon, Jul 08, 2024 at 07:41:23PM +0800, Jiqian Chen wrote:
>> diff --git a/tools/libs/ctrl/xc_physdev.c b/tools/libs/ctrl/xc_physdev.c
>> index e9fcd755fa62..54edb0f3c0dc 100644
>> --- 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_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);
> 
> 
> You could reuse the already opened fd from libxencall:
>     xencall_fd(xch->xcall)
Do I need to check it this fd<0?

> 
>> +
>> +    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);
> 
> I think this would be better implemented in Linux only C file instead of
> using #define. There's already "xc_linux.c" which is probably good
> enough to be used here.
> 
> Implementation for other OS would just set errno to ENOSYS and
> return -1.
Thanks, will change in next version.

> 
> 

-- 
Best regards,
Jiqian Chen.

 


Rackspace

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