hisi_acc_vfio_pci.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (c) 2021 HiSilicon Ltd. */
  3. #ifndef HISI_ACC_VFIO_PCI_H
  4. #define HISI_ACC_VFIO_PCI_H
  5. #include <linux/hisi_acc_qm.h>
  6. #define MB_POLL_PERIOD_US 10
  7. #define MB_POLL_TIMEOUT_US 1000
  8. #define QM_CACHE_WB_START 0x204
  9. #define QM_CACHE_WB_DONE 0x208
  10. #define QM_MB_CMD_PAUSE_QM 0xe
  11. #define QM_ABNORMAL_INT_STATUS 0x100008
  12. #define QM_IFC_INT_STATUS 0x0028
  13. #define SEC_CORE_INT_STATUS 0x301008
  14. #define HPRE_HAC_INT_STATUS 0x301800
  15. #define HZIP_CORE_INT_STATUS 0x3010AC
  16. #define QM_VFT_CFG_RDY 0x10006c
  17. #define QM_VFT_CFG_OP_WR 0x100058
  18. #define QM_VFT_CFG_TYPE 0x10005c
  19. #define QM_VFT_CFG 0x100060
  20. #define QM_VFT_CFG_OP_ENABLE 0x100054
  21. #define QM_VFT_CFG_DATA_L 0x100064
  22. #define QM_VFT_CFG_DATA_H 0x100068
  23. #define ERROR_CHECK_TIMEOUT 100
  24. #define CHECK_DELAY_TIME 100
  25. #define QM_SQC_VFT_BASE_SHIFT_V2 28
  26. #define QM_SQC_VFT_BASE_MASK_V2 GENMASK(15, 0)
  27. #define QM_SQC_VFT_NUM_SHIFT_V2 45
  28. #define QM_SQC_VFT_NUM_MASK_V2 GENMASK(9, 0)
  29. /* RW regs */
  30. #define QM_REGS_MAX_LEN 7
  31. #define QM_REG_ADDR_OFFSET 0x0004
  32. #define QM_XQC_ADDR_OFFSET 32U
  33. #define QM_VF_AEQ_INT_MASK 0x0004
  34. #define QM_VF_EQ_INT_MASK 0x000c
  35. #define QM_IFC_INT_SOURCE_V 0x0020
  36. #define QM_IFC_INT_MASK 0x0024
  37. #define QM_IFC_INT_SET_V 0x002c
  38. #define QM_QUE_ISO_CFG_V 0x0030
  39. #define QM_PAGE_SIZE 0x0034
  40. #define QM_EQC_DW0 0X8000
  41. #define QM_AEQC_DW0 0X8020
  42. struct acc_vf_data {
  43. #define QM_MATCH_SIZE offsetofend(struct acc_vf_data, qm_rsv_state)
  44. /* QM match information */
  45. #define ACC_DEV_MAGIC 0XCDCDCDCDFEEDAACC
  46. u64 acc_magic;
  47. u32 qp_num;
  48. u32 dev_id;
  49. u32 que_iso_cfg;
  50. u32 qp_base;
  51. u32 vf_qm_state;
  52. /* QM reserved match information */
  53. u32 qm_rsv_state[3];
  54. /* QM RW regs */
  55. u32 aeq_int_mask;
  56. u32 eq_int_mask;
  57. u32 ifc_int_source;
  58. u32 ifc_int_mask;
  59. u32 ifc_int_set;
  60. u32 page_size;
  61. /* QM_EQC_DW has 7 regs */
  62. u32 qm_eqc_dw[7];
  63. /* QM_AEQC_DW has 7 regs */
  64. u32 qm_aeqc_dw[7];
  65. /* QM reserved 5 regs */
  66. u32 qm_rsv_regs[5];
  67. u32 padding;
  68. /* QM memory init information */
  69. u64 eqe_dma;
  70. u64 aeqe_dma;
  71. u64 sqc_dma;
  72. u64 cqc_dma;
  73. };
  74. struct hisi_acc_vf_migration_file {
  75. struct file *filp;
  76. struct mutex lock;
  77. bool disabled;
  78. struct hisi_acc_vf_core_device *hisi_acc_vdev;
  79. struct acc_vf_data vf_data;
  80. size_t total_length;
  81. };
  82. struct hisi_acc_vf_core_device {
  83. struct vfio_pci_core_device core_device;
  84. u8 match_done;
  85. /* For migration state */
  86. struct mutex state_mutex;
  87. enum vfio_device_mig_state mig_state;
  88. struct pci_dev *pf_dev;
  89. struct pci_dev *vf_dev;
  90. struct hisi_qm *pf_qm;
  91. struct hisi_qm vf_qm;
  92. u32 vf_qm_state;
  93. int vf_id;
  94. struct hisi_acc_vf_migration_file *resuming_migf;
  95. struct hisi_acc_vf_migration_file *saving_migf;
  96. };
  97. #endif /* HISI_ACC_VFIO_PCI_H */