[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: Tue, 2 Jul 2024 03:47:16 +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=IHdu5GcmkebxRQZ0aYi0oYSvbp/gjzeigQkEObYZF6Y=; b=FkqFC4tXphduiNLaLxR1BMFx4jCvvXbj/EUFUC9l+7CydJkthRFti2tE/G4FPdJuXgTwrxyZNeAG/LPFncmXtT7UhozqIvI8omg2MQETdxgAZ4xLyNuozXpIThH5pvOoEHCDOHwcCzD/ndoJqf6El7dXzK398bFkbrfizvgzzD+OnsYUV8TBi/CMf88quVpg52zy0Cl71rG4+7bug2C5YElEJsnZHFe7WSFpav1Iz3tcd7Pn9jiwOB1fW4nw3xOFu+gLGhtVDCG7L5qk6zhs5kL5mEoRdzAO+2KiKi/m0WgiQqCF3T7TU1aLYI97xKva7U4AD8k5BOhnNUX0L8tKzg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ey4Jx+jcZNoOU9xvd1ke9hOC4XPMfe9A2bX+EM3ypo8Axh9Qbs4BK3TLPU0dmFhH+Y4HggaLtN14WRxJ9RzdXfVxwH7LHK3L673sS32r2vclWOJvjS0bzGHX3/UYf8Q2rNUeoTePSaf3UWQedyy9igtzhbATLrTcswKarnW3PZ10wXUvQtRadGXlUrqLF8ZqtqaYC64/iLNWfBbGLM22y9vDbQ/l0CYGMMgCt957eXm8d5Y/nNf0jkJdMI8O3BeB64KPqkl7DaY80TZr/ReGOJxZ2RiAO6K13olwxmie5b4Sq6ZhOVOnBtZmpOpmqS6AHB0ve8uVm00UN0nOtJSorQ==
- 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: Tue, 02 Jul 2024 03:47:28 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHayundYHEz4Kn0sEizSQnui4wvzbHhe8EAgAHYIoA=
- Thread-topic: [RFC XEN PATCH v11 7/8] tools: Add new function to get gsi from dev
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?
> Of course that'll still leave the ioctl() invocation, which necessarily is
> OS-specific, too.
>
> Jan
--
Best regards,
Jiqian Chen.
|