]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
virtio_pci: move structure to a header
authorMichael S. Tsirkin <mst@redhat.com>
Tue, 31 Oct 2023 16:02:06 +0000 (12:02 -0400)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 1 Nov 2023 13:31:16 +0000 (09:31 -0400)
These are guest/host interfaces, so they belong in the header where e.g.
qemu will know to find them.

Note: we added a new structure as opposed to extending existing one
because someone might be relying on the size of the existing structure
staying unchanged.  Add a warning to avoid using sizeof.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
drivers/virtio/virtio_pci_modern_dev.c
include/linux/virtio_pci_modern.h
include/uapi/linux/virtio_pci.h

index e2a1fe7bb66cc9c4da102f1559da648173c3376f..7de8b1ebabac4217b2240f6d8faaf486b4265f38 100644 (file)
@@ -294,9 +294,10 @@ int vp_modern_probe(struct virtio_pci_modern_device *mdev)
 
        err = -EINVAL;
        mdev->common = vp_modern_map_capability(mdev, common,
-                                     sizeof(struct virtio_pci_common_cfg), 4,
-                                     0, sizeof(struct virtio_pci_modern_common_cfg),
-                                     &mdev->common_len, NULL);
+                             sizeof(struct virtio_pci_common_cfg), 4, 0,
+                             offsetofend(struct virtio_pci_modern_common_cfg,
+                                         queue_reset),
+                             &mdev->common_len, NULL);
        if (!mdev->common)
                goto err_map_common;
        mdev->isr = vp_modern_map_capability(mdev, isr, sizeof(u8), 1,
index d0f2797420f7044616c7c7ef9faccc956acf5a7c..a09e13a577a99a0f91916ad121329dde11f42b1f 100644 (file)
@@ -5,13 +5,6 @@
 #include <linux/pci.h>
 #include <linux/virtio_pci.h>
 
-struct virtio_pci_modern_common_cfg {
-       struct virtio_pci_common_cfg cfg;
-
-       __le16 queue_notify_data;       /* read-write */
-       __le16 queue_reset;             /* read-write */
-};
-
 /**
  * struct virtio_pci_modern_device - info for modern PCI virtio
  * @pci_dev:       Ptr to the PCI device struct
index f703afc7ad31ba0791101585fd95b9a10a48f3ce..44f4dd2add188090ff3b03d859fb4d27009d5479 100644 (file)
@@ -166,6 +166,17 @@ struct virtio_pci_common_cfg {
        __le32 queue_used_hi;           /* read-write */
 };
 
+/*
+ * Warning: do not use sizeof on this: use offsetofend for
+ * specific fields you need.
+ */
+struct virtio_pci_modern_common_cfg {
+       struct virtio_pci_common_cfg cfg;
+
+       __le16 queue_notify_data;       /* read-write */
+       __le16 queue_reset;             /* read-write */
+};
+
 /* Fields in VIRTIO_PCI_CAP_PCI_CFG: */
 struct virtio_pci_cfg_cap {
        struct virtio_pci_cap cap;