xe_sriov_vfio.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /* SPDX-License-Identifier: MIT */
  2. /*
  3. * Copyright © 2025 Intel Corporation
  4. */
  5. #ifndef _XE_SRIOV_VFIO_H_
  6. #define _XE_SRIOV_VFIO_H_
  7. #include <linux/types.h>
  8. struct pci_dev;
  9. struct xe_device;
  10. /**
  11. * xe_sriov_vfio_get_pf() - Get PF &xe_device.
  12. * @pdev: the VF &pci_dev device
  13. *
  14. * Return: pointer to PF &xe_device, NULL otherwise.
  15. */
  16. struct xe_device *xe_sriov_vfio_get_pf(struct pci_dev *pdev);
  17. /**
  18. * xe_sriov_vfio_migration_supported() - Check if migration is supported.
  19. * @xe: the PF &xe_device obtained by calling xe_sriov_vfio_get_pf()
  20. *
  21. * Return: true if migration is supported, false otherwise.
  22. */
  23. bool xe_sriov_vfio_migration_supported(struct xe_device *xe);
  24. /**
  25. * xe_sriov_vfio_wait_flr_done() - Wait for VF FLR completion.
  26. * @xe: the PF &xe_device obtained by calling xe_sriov_vfio_get_pf()
  27. * @vfid: the VF identifier (can't be 0)
  28. *
  29. * This function will wait until VF FLR is processed by PF on all tiles (or
  30. * until timeout occurs).
  31. *
  32. * Return: 0 on success or a negative error code on failure.
  33. */
  34. int xe_sriov_vfio_wait_flr_done(struct xe_device *xe, unsigned int vfid);
  35. /**
  36. * xe_sriov_vfio_suspend_device() - Suspend VF.
  37. * @xe: the PF &xe_device obtained by calling xe_sriov_vfio_get_pf()
  38. * @vfid: the VF identifier (can't be 0)
  39. *
  40. * This function will pause VF on all tiles/GTs.
  41. *
  42. * Return: 0 on success or a negative error code on failure.
  43. */
  44. int xe_sriov_vfio_suspend_device(struct xe_device *xe, unsigned int vfid);
  45. /**
  46. * xe_sriov_vfio_resume_device() - Resume VF.
  47. * @xe: the PF &xe_device obtained by calling xe_sriov_vfio_get_pf()
  48. * @vfid: the VF identifier (can't be 0)
  49. *
  50. * This function will resume VF on all tiles.
  51. *
  52. * Return: 0 on success or a negative error code on failure.
  53. */
  54. int xe_sriov_vfio_resume_device(struct xe_device *xe, unsigned int vfid);
  55. /**
  56. * xe_sriov_vfio_stop_copy_enter() - Initiate a VF device migration data save.
  57. * @xe: the PF &xe_device obtained by calling xe_sriov_vfio_get_pf()
  58. * @vfid: the VF identifier (can't be 0)
  59. *
  60. * Return: 0 on success or a negative error code on failure.
  61. */
  62. int xe_sriov_vfio_stop_copy_enter(struct xe_device *xe, unsigned int vfid);
  63. /**
  64. * xe_sriov_vfio_stop_copy_exit() - Finish a VF device migration data save.
  65. * @xe: the PF &xe_device obtained by calling xe_sriov_vfio_get_pf()
  66. * @vfid: the VF identifier (can't be 0)
  67. *
  68. * Return: 0 on success or a negative error code on failure.
  69. */
  70. int xe_sriov_vfio_stop_copy_exit(struct xe_device *xe, unsigned int vfid);
  71. /**
  72. * xe_sriov_vfio_resume_data_enter() - Initiate a VF device migration data restore.
  73. * @xe: the PF &xe_device obtained by calling xe_sriov_vfio_get_pf()
  74. * @vfid: the VF identifier (can't be 0)
  75. *
  76. * Return: 0 on success or a negative error code on failure.
  77. */
  78. int xe_sriov_vfio_resume_data_enter(struct xe_device *xe, unsigned int vfid);
  79. /**
  80. * xe_sriov_vfio_resume_data_exit() - Finish a VF device migration data restore.
  81. * @xe: the PF &xe_device obtained by calling xe_sriov_vfio_get_pf()
  82. * @vfid: the VF identifier (can't be 0)
  83. *
  84. * Return: 0 on success or a negative error code on failure.
  85. */
  86. int xe_sriov_vfio_resume_data_exit(struct xe_device *xe, unsigned int vfid);
  87. /**
  88. * xe_sriov_vfio_error() - Move VF device to error state.
  89. * @xe: the PF &xe_device obtained by calling xe_sriov_vfio_get_pf()
  90. * @vfid: the VF identifier (can't be 0)
  91. *
  92. * Reset is needed to move it out of error state.
  93. *
  94. * Return: 0 on success or a negative error code on failure.
  95. */
  96. int xe_sriov_vfio_error(struct xe_device *xe, unsigned int vfid);
  97. /**
  98. * xe_sriov_vfio_data_read() - Read migration data from the VF device.
  99. * @xe: the PF &xe_device obtained by calling xe_sriov_vfio_get_pf()
  100. * @vfid: the VF identifier (can't be 0)
  101. * @buf: start address of userspace buffer
  102. * @len: requested read size from userspace
  103. *
  104. * Return: number of bytes that has been successfully read,
  105. * 0 if no more migration data is available, -errno on failure.
  106. */
  107. ssize_t xe_sriov_vfio_data_read(struct xe_device *xe, unsigned int vfid,
  108. char __user *buf, size_t len);
  109. /**
  110. * xe_sriov_vfio_data_write() - Write migration data to the VF device.
  111. * @xe: the PF &xe_device obtained by calling xe_sriov_vfio_get_pf()
  112. * @vfid: the VF identifier (can't be 0)
  113. * @buf: start address of userspace buffer
  114. * @len: requested write size from userspace
  115. *
  116. * Return: number of bytes that has been successfully written, -errno on failure.
  117. */
  118. ssize_t xe_sriov_vfio_data_write(struct xe_device *xe, unsigned int vfid,
  119. const char __user *buf, size_t len);
  120. /**
  121. * xe_sriov_vfio_stop_copy_size() - Get a size estimate of VF device migration data.
  122. * @xe: the PF &xe_device obtained by calling xe_sriov_vfio_get_pf()
  123. * @vfid: the VF identifier (can't be 0)
  124. *
  125. * Return: migration data size in bytes or a negative error code on failure.
  126. */
  127. ssize_t xe_sriov_vfio_stop_copy_size(struct xe_device *xe, unsigned int vfid);
  128. #endif