[PATCH 04/18] qapi/common: Drop temporary 'prefix'

Markus Armbruster posted 18 patches 3 months, 3 weeks ago
[PATCH 04/18] qapi/common: Drop temporary 'prefix'
Posted by Markus Armbruster 3 months, 3 weeks ago
Recent commit "qapi: Smarter camel_to_upper() to reduce need for
'prefix'" added a temporary 'prefix' to delay changing the generated
code.

Revert it.  This improves OffAutoPCIBAR's generated enumeration
constant prefix from OFF_AUTOPCIBAR_OFF to OFF_AUTO_PCIBAR_OFF.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 qapi/common.json |  1 -
 hw/vfio/pci.c    | 10 +++++-----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/qapi/common.json b/qapi/common.json
index 25726d3113..7558ce5430 100644
--- a/qapi/common.json
+++ b/qapi/common.json
@@ -92,7 +92,6 @@
 # Since: 2.12
 ##
 { 'enum': 'OffAutoPCIBAR',
-  'prefix': 'OFF_AUTOPCIBAR',   # TODO drop
   'data': [ 'off', 'auto', 'bar0', 'bar1', 'bar2', 'bar3', 'bar4', 'bar5' ] }
 
 ##
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 2407720c35..0a99e55247 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -1452,7 +1452,7 @@ static bool vfio_pci_relocate_msix(VFIOPCIDevice *vdev, Error **errp)
     int target_bar = -1;
     size_t msix_sz;
 
-    if (!vdev->msix || vdev->msix_relo == OFF_AUTOPCIBAR_OFF) {
+    if (!vdev->msix || vdev->msix_relo == OFF_AUTO_PCIBAR_OFF) {
         return true;
     }
 
@@ -1464,7 +1464,7 @@ static bool vfio_pci_relocate_msix(VFIOPCIDevice *vdev, Error **errp)
     /* PCI BARs must be a power of 2 */
     msix_sz = pow2ceil(msix_sz);
 
-    if (vdev->msix_relo == OFF_AUTOPCIBAR_AUTO) {
+    if (vdev->msix_relo == OFF_AUTO_PCIBAR_AUTO) {
         /*
          * TODO: Lookup table for known devices.
          *
@@ -1479,7 +1479,7 @@ static bool vfio_pci_relocate_msix(VFIOPCIDevice *vdev, Error **errp)
             return false;
         }
     } else {
-        target_bar = (int)(vdev->msix_relo - OFF_AUTOPCIBAR_BAR0);
+        target_bar = (int)(vdev->msix_relo - OFF_AUTO_PCIBAR_BAR0);
     }
 
     /* I/O port BARs cannot host MSI-X structures */
@@ -1624,7 +1624,7 @@ static bool vfio_msix_early_setup(VFIOPCIDevice *vdev, Error **errp)
         } else if (vfio_pci_is(vdev, PCI_VENDOR_ID_BAIDU,
                                PCI_DEVICE_ID_KUNLUN_VF)) {
             msix->pba_offset = 0xb400;
-        } else if (vdev->msix_relo == OFF_AUTOPCIBAR_OFF) {
+        } else if (vdev->msix_relo == OFF_AUTO_PCIBAR_OFF) {
             error_setg(errp, "hardware reports invalid configuration, "
                        "MSIX PBA outside of specified BAR");
             g_free(msix);
@@ -3403,7 +3403,7 @@ static Property vfio_pci_dev_properties[] = {
                                    nv_gpudirect_clique,
                                    qdev_prop_nv_gpudirect_clique, uint8_t),
     DEFINE_PROP_OFF_AUTO_PCIBAR("x-msix-relocation", VFIOPCIDevice, msix_relo,
-                                OFF_AUTOPCIBAR_OFF),
+                                OFF_AUTO_PCIBAR_OFF),
 #ifdef CONFIG_IOMMUFD
     DEFINE_PROP_LINK("iommufd", VFIOPCIDevice, vbasedev.iommufd,
                      TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *),
-- 
2.45.0
Re: [PATCH 04/18] qapi/common: Drop temporary 'prefix'
Posted by Cédric Le Goater 3 months, 3 weeks ago
On 7/30/24 10:10, Markus Armbruster wrote:
> Recent commit "qapi: Smarter camel_to_upper() to reduce need for
> 'prefix'" added a temporary 'prefix' to delay changing the generated
> code.
> 
> Revert it.  This improves OffAutoPCIBAR's generated enumeration
> constant prefix from OFF_AUTOPCIBAR_OFF to OFF_AUTO_PCIBAR_OFF.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>


Reviewed-by: Cédric Le Goater <clg@redhat.com>

Thanks,

C.


> ---
>   qapi/common.json |  1 -
>   hw/vfio/pci.c    | 10 +++++-----
>   2 files changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/qapi/common.json b/qapi/common.json
> index 25726d3113..7558ce5430 100644
> --- a/qapi/common.json
> +++ b/qapi/common.json
> @@ -92,7 +92,6 @@
>   # Since: 2.12
>   ##
>   { 'enum': 'OffAutoPCIBAR',
> -  'prefix': 'OFF_AUTOPCIBAR',   # TODO drop
>     'data': [ 'off', 'auto', 'bar0', 'bar1', 'bar2', 'bar3', 'bar4', 'bar5' ] }
>   
>   ##
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index 2407720c35..0a99e55247 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -1452,7 +1452,7 @@ static bool vfio_pci_relocate_msix(VFIOPCIDevice *vdev, Error **errp)
>       int target_bar = -1;
>       size_t msix_sz;
>   
> -    if (!vdev->msix || vdev->msix_relo == OFF_AUTOPCIBAR_OFF) {
> +    if (!vdev->msix || vdev->msix_relo == OFF_AUTO_PCIBAR_OFF) {
>           return true;
>       }
>   
> @@ -1464,7 +1464,7 @@ static bool vfio_pci_relocate_msix(VFIOPCIDevice *vdev, Error **errp)
>       /* PCI BARs must be a power of 2 */
>       msix_sz = pow2ceil(msix_sz);
>   
> -    if (vdev->msix_relo == OFF_AUTOPCIBAR_AUTO) {
> +    if (vdev->msix_relo == OFF_AUTO_PCIBAR_AUTO) {
>           /*
>            * TODO: Lookup table for known devices.
>            *
> @@ -1479,7 +1479,7 @@ static bool vfio_pci_relocate_msix(VFIOPCIDevice *vdev, Error **errp)
>               return false;
>           }
>       } else {
> -        target_bar = (int)(vdev->msix_relo - OFF_AUTOPCIBAR_BAR0);
> +        target_bar = (int)(vdev->msix_relo - OFF_AUTO_PCIBAR_BAR0);
>       }
>   
>       /* I/O port BARs cannot host MSI-X structures */
> @@ -1624,7 +1624,7 @@ static bool vfio_msix_early_setup(VFIOPCIDevice *vdev, Error **errp)
>           } else if (vfio_pci_is(vdev, PCI_VENDOR_ID_BAIDU,
>                                  PCI_DEVICE_ID_KUNLUN_VF)) {
>               msix->pba_offset = 0xb400;
> -        } else if (vdev->msix_relo == OFF_AUTOPCIBAR_OFF) {
> +        } else if (vdev->msix_relo == OFF_AUTO_PCIBAR_OFF) {
>               error_setg(errp, "hardware reports invalid configuration, "
>                          "MSIX PBA outside of specified BAR");
>               g_free(msix);
> @@ -3403,7 +3403,7 @@ static Property vfio_pci_dev_properties[] = {
>                                      nv_gpudirect_clique,
>                                      qdev_prop_nv_gpudirect_clique, uint8_t),
>       DEFINE_PROP_OFF_AUTO_PCIBAR("x-msix-relocation", VFIOPCIDevice, msix_relo,
> -                                OFF_AUTOPCIBAR_OFF),
> +                                OFF_AUTO_PCIBAR_OFF),
>   #ifdef CONFIG_IOMMUFD
>       DEFINE_PROP_LINK("iommufd", VFIOPCIDevice, vbasedev.iommufd,
>                        TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *),