>-----Original Message-----
>From: Nicolin Chen <nicol...@nvidia.com>
>Subject: Re: [PATCH 3/5] vfio/iommufd: Implement .get_cap() in
>TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO sub-class
>
>On Fri, Apr 11, 2025 at 06:17:05PM +0800, Zhenzhong Duan wrote:
>> +static int hiod_iommufd_get_vtd_cap(HostIOMMUDevice *hiod,
>> + struct iommu_hw_info_vtd *vtd,
>> + int cap, Error **errp)
>> +{
>> + /* TODO: Check vtd->cap_reg/ecap_reg for capability */
>> + error_setg(errp, "%s: unsupported capability %x", hiod->name, cap);
>> + return -EINVAL;
>> +}
>> +
>> +static int hiod_iommufd_get_vendor_cap(HostIOMMUDevice *hiod,
>> + HostIOMMUDeviceIOMMUFDCaps *caps,
>> + int cap, Error **errp)
>> +{
>> + enum iommu_hw_info_type type = caps->type;
>> +
>> + switch (type) {
>> + case IOMMU_HW_INFO_TYPE_INTEL_VTD:
>> + return hiod_iommufd_get_vtd_cap(hiod, &caps->vendor_caps.vtd,
>> + cap, errp);
>> + case IOMMU_HW_INFO_TYPE_ARM_SMMUV3:
>> + case IOMMU_HW_INFO_TYPE_NONE:
>
>Do we have to keep vendor types in the core?
Either HostIOMMUDevice or VFIODevice, or you have other suggestion?
>
>Can we have another PCI callback like the set_iommu/unset_iommu
>ops to ask vendor code get the cap and return it?
As you said, vendor code can't generate all caps i.e. PASID, any benefit for a
new callback?
Thanks
Zhenzhong