vfio/mlx5: Set the driver DMA logging callbacks
authorYishai Hadas <yishaih@nvidia.com>
Thu, 8 Sep 2022 18:34:48 +0000 (21:34 +0300)
committerAlex Williamson <alex.williamson@redhat.com>
Thu, 8 Sep 2022 18:59:01 +0000 (12:59 -0600)
Now that everything is ready set the driver DMA logging callbacks if
supported by the device.

Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
Link: https://lore.kernel.org/r/20220908183448.195262-11-yishaih@nvidia.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/pci/mlx5/cmd.c
drivers/vfio/pci/mlx5/cmd.h
drivers/vfio/pci/mlx5/main.c

index 3e92b4d..c604b70 100644 (file)
@@ -126,7 +126,8 @@ void mlx5vf_cmd_remove_migratable(struct mlx5vf_pci_core_device *mvdev)
 }
 
 void mlx5vf_cmd_set_migratable(struct mlx5vf_pci_core_device *mvdev,
-                              const struct vfio_migration_ops *mig_ops)
+                              const struct vfio_migration_ops *mig_ops,
+                              const struct vfio_log_ops *log_ops)
 {
        struct pci_dev *pdev = mvdev->core_device.pdev;
        int ret;
@@ -169,6 +170,8 @@ void mlx5vf_cmd_set_migratable(struct mlx5vf_pci_core_device *mvdev,
                VFIO_MIGRATION_P2P;
        mvdev->core_device.vdev.mig_ops = mig_ops;
        init_completion(&mvdev->tracker_comp);
+       if (MLX5_CAP_GEN(mvdev->mdev, adv_virtualization))
+               mvdev->core_device.vdev.log_ops = log_ops;
 
 end:
        mlx5_vf_put_core_dev(mvdev->mdev);
index 8b0ae40..921d572 100644 (file)
@@ -118,7 +118,8 @@ int mlx5vf_cmd_resume_vhca(struct mlx5vf_pci_core_device *mvdev, u16 op_mod);
 int mlx5vf_cmd_query_vhca_migration_state(struct mlx5vf_pci_core_device *mvdev,
                                          size_t *state_size);
 void mlx5vf_cmd_set_migratable(struct mlx5vf_pci_core_device *mvdev,
-                              const struct vfio_migration_ops *mig_ops);
+                              const struct vfio_migration_ops *mig_ops,
+                              const struct vfio_log_ops *log_ops);
 void mlx5vf_cmd_remove_migratable(struct mlx5vf_pci_core_device *mvdev);
 void mlx5vf_cmd_close_migratable(struct mlx5vf_pci_core_device *mvdev);
 int mlx5vf_cmd_save_vhca_state(struct mlx5vf_pci_core_device *mvdev,
index a9b63d1..759a5f5 100644 (file)
@@ -579,6 +579,12 @@ static const struct vfio_migration_ops mlx5vf_pci_mig_ops = {
        .migration_get_state = mlx5vf_pci_get_device_state,
 };
 
+static const struct vfio_log_ops mlx5vf_pci_log_ops = {
+       .log_start = mlx5vf_start_page_tracker,
+       .log_stop = mlx5vf_stop_page_tracker,
+       .log_read_and_clear = mlx5vf_tracker_read_and_clear,
+};
+
 static const struct vfio_device_ops mlx5vf_pci_ops = {
        .name = "mlx5-vfio-pci",
        .open_device = mlx5vf_pci_open_device,
@@ -602,7 +608,8 @@ static int mlx5vf_pci_probe(struct pci_dev *pdev,
        if (!mvdev)
                return -ENOMEM;
        vfio_pci_core_init_device(&mvdev->core_device, pdev, &mlx5vf_pci_ops);
-       mlx5vf_cmd_set_migratable(mvdev, &mlx5vf_pci_mig_ops);
+       mlx5vf_cmd_set_migratable(mvdev, &mlx5vf_pci_mig_ops,
+                                 &mlx5vf_pci_log_ops);
        dev_set_drvdata(&pdev->dev, &mvdev->core_device);
        ret = vfio_pci_core_register_device(&mvdev->core_device);
        if (ret)