Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vdpa: add get_config_size callback in vdpa_config_ops

This new callback is used to get the size of the configuration space
of vDPA devices.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://lore.kernel.org/r/20210315163450.254396-9-sgarzare@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>

authored by

Stefano Garzarella and committed by
Michael S. Tsirkin
442706f9 bc433e5e

+33
+6
drivers/vdpa/ifcvf/ifcvf_main.c
··· 351 351 return IFCVF_QUEUE_ALIGNMENT; 352 352 } 353 353 354 + static size_t ifcvf_vdpa_get_config_size(struct vdpa_device *vdpa_dev) 355 + { 356 + return sizeof(struct virtio_net_config); 357 + } 358 + 354 359 static void ifcvf_vdpa_get_config(struct vdpa_device *vdpa_dev, 355 360 unsigned int offset, 356 361 void *buf, unsigned int len) ··· 416 411 .get_device_id = ifcvf_vdpa_get_device_id, 417 412 .get_vendor_id = ifcvf_vdpa_get_vendor_id, 418 413 .get_vq_align = ifcvf_vdpa_get_vq_align, 414 + .get_config_size = ifcvf_vdpa_get_config_size, 419 415 .get_config = ifcvf_vdpa_get_config, 420 416 .set_config = ifcvf_vdpa_set_config, 421 417 .set_config_cb = ifcvf_vdpa_set_config_cb,
+6
drivers/vdpa/mlx5/net/mlx5_vnet.c
··· 1809 1809 ndev->mvdev.status |= VIRTIO_CONFIG_S_FAILED; 1810 1810 } 1811 1811 1812 + static size_t mlx5_vdpa_get_config_size(struct vdpa_device *vdev) 1813 + { 1814 + return sizeof(struct virtio_net_config); 1815 + } 1816 + 1812 1817 static void mlx5_vdpa_get_config(struct vdpa_device *vdev, unsigned int offset, void *buf, 1813 1818 unsigned int len) 1814 1819 { ··· 1900 1895 .get_vendor_id = mlx5_vdpa_get_vendor_id, 1901 1896 .get_status = mlx5_vdpa_get_status, 1902 1897 .set_status = mlx5_vdpa_set_status, 1898 + .get_config_size = mlx5_vdpa_get_config_size, 1903 1899 .get_config = mlx5_vdpa_get_config, 1904 1900 .set_config = mlx5_vdpa_set_config, 1905 1901 .get_generation = mlx5_vdpa_get_generation,
+9
drivers/vdpa/vdpa_sim/vdpa_sim.c
··· 462 462 spin_unlock(&vdpasim->lock); 463 463 } 464 464 465 + static size_t vdpasim_get_config_size(struct vdpa_device *vdpa) 466 + { 467 + struct vdpasim *vdpasim = vdpa_to_sim(vdpa); 468 + 469 + return vdpasim->dev_attr.config_size; 470 + } 471 + 465 472 static void vdpasim_get_config(struct vdpa_device *vdpa, unsigned int offset, 466 473 void *buf, unsigned int len) 467 474 { ··· 605 598 .get_vendor_id = vdpasim_get_vendor_id, 606 599 .get_status = vdpasim_get_status, 607 600 .set_status = vdpasim_set_status, 601 + .get_config_size = vdpasim_get_config_size, 608 602 .get_config = vdpasim_get_config, 609 603 .set_config = vdpasim_set_config, 610 604 .get_generation = vdpasim_get_generation, ··· 633 625 .get_vendor_id = vdpasim_get_vendor_id, 634 626 .get_status = vdpasim_get_status, 635 627 .set_status = vdpasim_set_status, 628 + .get_config_size = vdpasim_get_config_size, 636 629 .get_config = vdpasim_get_config, 637 630 .set_config = vdpasim_set_config, 638 631 .get_generation = vdpasim_get_generation,
+8
drivers/vdpa/virtio_pci/vp_vdpa.c
··· 296 296 return PAGE_SIZE; 297 297 } 298 298 299 + static size_t vp_vdpa_get_config_size(struct vdpa_device *vdpa) 300 + { 301 + struct virtio_pci_modern_device *mdev = vdpa_to_mdev(vdpa); 302 + 303 + return mdev->device_len; 304 + } 305 + 299 306 static void vp_vdpa_get_config(struct vdpa_device *vdpa, 300 307 unsigned int offset, 301 308 void *buf, unsigned int len) ··· 376 369 .get_device_id = vp_vdpa_get_device_id, 377 370 .get_vendor_id = vp_vdpa_get_vendor_id, 378 371 .get_vq_align = vp_vdpa_get_vq_align, 372 + .get_config_size = vp_vdpa_get_config_size, 379 373 .get_config = vp_vdpa_get_config, 380 374 .set_config = vp_vdpa_set_config, 381 375 .set_config_cb = vp_vdpa_set_config_cb,
+4
include/linux/vdpa.h
··· 150 150 * @set_status: Set the device status 151 151 * @vdev: vdpa device 152 152 * @status: virtio device status 153 + * @get_config_size: Get the size of the configuration space 154 + * @vdev: vdpa device 155 + * Returns size_t: configuration size 153 156 * @get_config: Read from device specific configuration space 154 157 * @vdev: vdpa device 155 158 * @offset: offset from the beginning of ··· 234 231 u32 (*get_vendor_id)(struct vdpa_device *vdev); 235 232 u8 (*get_status)(struct vdpa_device *vdev); 236 233 void (*set_status)(struct vdpa_device *vdev, u8 status); 234 + size_t (*get_config_size)(struct vdpa_device *vdev); 237 235 void (*get_config)(struct vdpa_device *vdev, unsigned int offset, 238 236 void *buf, unsigned int len); 239 237 void (*set_config)(struct vdpa_device *vdev, unsigned int offset,