linux/drivers/vfio/pci/qat/main.c

// SPDX-License-Identifier: GPL-2.0-only
/* Copyright(c) 2024 Intel Corporation */

#include <linux/anon_inodes.h>
#include <linux/container_of.h>
#include <linux/device.h>
#include <linux/file.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/pci.h>
#include <linux/sizes.h>
#include <linux/types.h>
#include <linux/uaccess.h>
#include <linux/vfio_pci_core.h>
#include <linux/qat/qat_mig_dev.h>

/*
 * The migration data of each Intel QAT VF device is encapsulated into a
 * 4096 bytes block. The data consists of two parts.
 * The first is a pre-configured set of attributes of the VF being migrated,
 * which are only set when it is created. This can be migrated during pre-copy
 * stage and used for a device compatibility check.
 * The second is the VF state. This includes the required MMIO regions and
 * the shadow states maintained by the QAT PF driver. This part can only be
 * saved when the VF is fully quiesced and be migrated during stop-copy stage.
 * Both these 2 parts of data are saved in hierarchical structures including
 * a preamble section and several raw state sections.
 * When the pre-configured part of the migration data is fully retrieved from
 * user space, the preamble section are used to validate the correctness of
 * the data blocks and check the version compatibility. The raw state sections
 * are then used to do a device compatibility check.
 * When the device transits from RESUMING state, the VF states are extracted
 * from the raw state sections of the VF state part of the migration data and
 * then loaded into the device.
 */

struct qat_vf_migration_file {};

struct qat_vf_core_device {};

static int qat_vf_pci_open_device(struct vfio_device *core_vdev)
{}

static void qat_vf_disable_fd(struct qat_vf_migration_file *migf)
{}

static void qat_vf_disable_fds(struct qat_vf_core_device *qat_vdev)
{}

static void qat_vf_pci_close_device(struct vfio_device *core_vdev)
{}

static long qat_vf_precopy_ioctl(struct file *filp, unsigned int cmd,
				 unsigned long arg)
{}

static ssize_t qat_vf_save_read(struct file *filp, char __user *buf,
				size_t len, loff_t *pos)
{}

static int qat_vf_release_file(struct inode *inode, struct file *filp)
{}

static const struct file_operations qat_vf_save_fops =;

static int qat_vf_save_state(struct qat_vf_core_device *qat_vdev,
			     struct qat_vf_migration_file *migf)
{}

static int qat_vf_save_setup(struct qat_vf_core_device *qat_vdev,
			     struct qat_vf_migration_file *migf)
{}

/*
 * Allocate a file handler for user space and then save the migration data for
 * the device being migrated. If this is called in the pre-copy stage, save the
 * pre-configured device data. Otherwise, if this is called in the stop-copy
 * stage, save the device state. In both cases, update the data size which can
 * then be read from user space.
 */
static struct qat_vf_migration_file *
qat_vf_save_device_data(struct qat_vf_core_device *qat_vdev, bool pre_copy)
{}

static ssize_t qat_vf_resume_write(struct file *filp, const char __user *buf,
				   size_t len, loff_t *pos)
{}

static const struct file_operations qat_vf_resume_fops =;

static struct qat_vf_migration_file *
qat_vf_resume_device_data(struct qat_vf_core_device *qat_vdev)
{}

static int qat_vf_load_device_data(struct qat_vf_core_device *qat_vdev)
{}

static struct file *qat_vf_pci_step_device_state(struct qat_vf_core_device *qat_vdev, u32 new)
{}

static void qat_vf_reset_done(struct qat_vf_core_device *qat_vdev)
{}

static struct file *qat_vf_pci_set_device_state(struct vfio_device *vdev,
						enum vfio_device_mig_state new_state)
{}

static int qat_vf_pci_get_device_state(struct vfio_device *vdev,
				       enum vfio_device_mig_state *curr_state)
{}

static int qat_vf_pci_get_data_size(struct vfio_device *vdev,
				    unsigned long *stop_copy_length)
{}

static const struct vfio_migration_ops qat_vf_pci_mig_ops =;

static void qat_vf_pci_release_dev(struct vfio_device *core_vdev)
{}

static int qat_vf_pci_init_dev(struct vfio_device *core_vdev)
{}

static const struct vfio_device_ops qat_vf_pci_ops =;

static struct qat_vf_core_device *qat_vf_drvdata(struct pci_dev *pdev)
{}

static void qat_vf_pci_aer_reset_done(struct pci_dev *pdev)
{}

static int
qat_vf_vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{}

static void qat_vf_vfio_pci_remove(struct pci_dev *pdev)
{}

static const struct pci_device_id qat_vf_vfio_pci_table[] =;
MODULE_DEVICE_TABLE(pci, qat_vf_vfio_pci_table);

static const struct pci_error_handlers qat_vf_err_handlers =;

static struct pci_driver qat_vf_vfio_pci_driver =;
module_pci_driver();

MODULE_LICENSE();
MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_IMPORT_NS();