vas.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright 2020-21 IBM Corp.
  4. */
  5. #ifndef _VAS_H
  6. #define _VAS_H
  7. #include <asm/vas.h>
  8. #include <linux/mutex.h>
  9. #include <linux/stringify.h>
  10. /*
  11. * VAS window modify flags
  12. */
  13. #define VAS_MOD_WIN_CLOSE PPC_BIT(0)
  14. #define VAS_MOD_WIN_JOBS_KILL PPC_BIT(1)
  15. #define VAS_MOD_WIN_DR PPC_BIT(3)
  16. #define VAS_MOD_WIN_PR PPC_BIT(4)
  17. #define VAS_MOD_WIN_SF PPC_BIT(5)
  18. #define VAS_MOD_WIN_TA PPC_BIT(6)
  19. #define VAS_MOD_WIN_FLAGS (VAS_MOD_WIN_JOBS_KILL | VAS_MOD_WIN_DR | \
  20. VAS_MOD_WIN_PR | VAS_MOD_WIN_SF)
  21. #define VAS_WIN_ACTIVE 0x0
  22. #define VAS_WIN_CLOSED 0x1
  23. #define VAS_WIN_INACTIVE 0x2 /* Inactive due to HW failure */
  24. /* Process of being modified, deallocated, or quiesced */
  25. #define VAS_WIN_MOD_IN_PROCESS 0x3
  26. #define VAS_COPY_PASTE_USER_MODE 0x00000001
  27. #define VAS_COP_OP_USER_MODE 0x00000010
  28. #define VAS_GZIP_QOS_CAPABILITIES 0x56516F73477A6970
  29. #define VAS_GZIP_DEFAULT_CAPABILITIES 0x56446566477A6970
  30. enum vas_migrate_action {
  31. VAS_SUSPEND,
  32. VAS_RESUME,
  33. };
  34. /*
  35. * Co-processor feature - GZIP QoS windows or GZIP default windows
  36. */
  37. enum vas_cop_feat_type {
  38. VAS_GZIP_QOS_FEAT_TYPE,
  39. VAS_GZIP_DEF_FEAT_TYPE,
  40. VAS_MAX_FEAT_TYPE,
  41. };
  42. /*
  43. * Use to get feature specific capabilities from the
  44. * hypervisor.
  45. */
  46. struct hv_vas_cop_feat_caps {
  47. __be64 descriptor;
  48. u8 win_type; /* Default or QoS type */
  49. u8 user_mode;
  50. __be16 max_lpar_creds;
  51. __be16 max_win_creds;
  52. union {
  53. __be16 reserved;
  54. __be16 def_lpar_creds; /* Used for default capabilities */
  55. };
  56. __be16 target_lpar_creds;
  57. } __packed __aligned(0x1000);
  58. /*
  59. * Feature specific (QoS or default) capabilities.
  60. */
  61. struct vas_cop_feat_caps {
  62. u64 descriptor;
  63. u8 win_type; /* Default or QoS type */
  64. u8 user_mode; /* User mode copy/paste or COP HCALL */
  65. u16 max_lpar_creds; /* Max credits available in LPAR */
  66. /* Max credits can be assigned per window */
  67. u16 max_win_creds;
  68. union {
  69. u16 reserved; /* Used for QoS credit type */
  70. u16 def_lpar_creds; /* Used for default credit type */
  71. };
  72. /* Total LPAR available credits. Can be different from max LPAR */
  73. /* credits due to DLPAR operation */
  74. atomic_t nr_total_credits; /* Total credits assigned to LPAR */
  75. atomic_t nr_used_credits; /* Used credits so far */
  76. };
  77. /*
  78. * Feature (QoS or Default) specific to store capabilities and
  79. * the list of open windows.
  80. */
  81. struct vas_caps {
  82. struct vas_cop_feat_caps caps;
  83. struct list_head list; /* List of open windows */
  84. int nr_close_wins; /* closed windows in the hypervisor for DLPAR */
  85. int nr_open_windows; /* Number of successful open windows */
  86. u8 feat; /* Feature type */
  87. };
  88. /*
  89. * To get window information from the hypervisor.
  90. */
  91. struct hv_vas_win_lpar {
  92. __be16 version;
  93. u8 win_type;
  94. u8 status;
  95. __be16 credits; /* No of credits assigned to this window */
  96. __be16 reserved;
  97. __be32 pid; /* LPAR Process ID */
  98. __be32 tid; /* LPAR Thread ID */
  99. __be64 win_addr; /* Paste address */
  100. __be32 interrupt; /* Interrupt when NX request completes */
  101. __be32 fault; /* Interrupt when NX sees fault */
  102. /* Associativity Domain Identifiers as returned in */
  103. /* H_HOME_NODE_ASSOCIATIVITY */
  104. __be64 domain[6];
  105. __be64 win_util; /* Number of bytes processed */
  106. } __packed __aligned(0x1000);
  107. struct pseries_vas_window {
  108. struct vas_window vas_win;
  109. u64 win_addr; /* Physical paste address */
  110. u8 win_type; /* QoS or Default window */
  111. u32 complete_irq; /* Completion interrupt */
  112. u32 fault_irq; /* Fault interrupt */
  113. u64 domain[6]; /* Associativity domain Ids */
  114. /* this window is allocated */
  115. u64 util;
  116. u32 pid; /* PID associated with this window */
  117. /* List of windows opened which is used for LPM */
  118. struct list_head win_list;
  119. u64 flags;
  120. char *name;
  121. int fault_virq;
  122. atomic_t pending_faults; /* Number of pending faults */
  123. };
  124. int sysfs_add_vas_caps(struct vas_cop_feat_caps *caps);
  125. int vas_reconfig_capabilties(u8 type, int new_nr_creds);
  126. int __init sysfs_pseries_vas_init(struct vas_all_caps *vas_caps);
  127. #ifdef CONFIG_PPC_VAS
  128. int vas_migration_handler(int action);
  129. int pseries_vas_dlpar_cpu(void);
  130. #else
  131. static inline int vas_migration_handler(int action)
  132. {
  133. return 0;
  134. }
  135. static inline int pseries_vas_dlpar_cpu(void)
  136. {
  137. return 0;
  138. }
  139. #endif
  140. #endif /* _VAS_H */