grulib.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. * Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU Lesser General Public License as published by
  6. * the Free Software Foundation; either version 2.1 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #ifndef __GRULIB_H__
  19. #define __GRULIB_H__
  20. #define GRU_BASENAME "gru"
  21. #define GRU_FULLNAME "/dev/gru"
  22. #define GRU_IOCTL_NUM 'G'
  23. /*
  24. * Maximum number of GRU segments that a user can have open
  25. * ZZZ temp - set high for testing. Revisit.
  26. */
  27. #define GRU_MAX_OPEN_CONTEXTS 32
  28. /* Set Number of Request Blocks */
  29. #define GRU_CREATE_CONTEXT _IOWR(GRU_IOCTL_NUM, 1, void *)
  30. /* Set Context Options */
  31. #define GRU_SET_CONTEXT_OPTION _IOWR(GRU_IOCTL_NUM, 4, void *)
  32. /* Fetch exception detail */
  33. #define GRU_USER_GET_EXCEPTION_DETAIL _IOWR(GRU_IOCTL_NUM, 6, void *)
  34. /* For user call_os handling - normally a TLB fault */
  35. #define GRU_USER_CALL_OS _IOWR(GRU_IOCTL_NUM, 8, void *)
  36. /* For user unload context */
  37. #define GRU_USER_UNLOAD_CONTEXT _IOWR(GRU_IOCTL_NUM, 9, void *)
  38. /* For dumpping GRU chiplet state */
  39. #define GRU_DUMP_CHIPLET_STATE _IOWR(GRU_IOCTL_NUM, 11, void *)
  40. /* For getting gseg statistics */
  41. #define GRU_GET_GSEG_STATISTICS _IOWR(GRU_IOCTL_NUM, 12, void *)
  42. /* For user TLB flushing (primarily for tests) */
  43. #define GRU_USER_FLUSH_TLB _IOWR(GRU_IOCTL_NUM, 50, void *)
  44. /* Get some config options (primarily for tests & emulator) */
  45. #define GRU_GET_CONFIG_INFO _IOWR(GRU_IOCTL_NUM, 51, void *)
  46. /* Various kernel self-tests */
  47. #define GRU_KTEST _IOWR(GRU_IOCTL_NUM, 52, void *)
  48. #define CONTEXT_WINDOW_BYTES(th) (GRU_GSEG_PAGESIZE * (th))
  49. #define THREAD_POINTER(p, th) (p + GRU_GSEG_PAGESIZE * (th))
  50. #define GSEG_START(cb) ((void *)((unsigned long)(cb) & ~(GRU_GSEG_PAGESIZE - 1)))
  51. /*
  52. * Statictics kept on a per-GTS basis.
  53. */
  54. struct gts_statistics {
  55. unsigned long fmm_tlbdropin;
  56. unsigned long upm_tlbdropin;
  57. unsigned long context_stolen;
  58. };
  59. struct gru_get_gseg_statistics_req {
  60. unsigned long gseg;
  61. struct gts_statistics stats;
  62. };
  63. /*
  64. * Structure used to pass TLB flush parameters to the driver
  65. */
  66. struct gru_create_context_req {
  67. unsigned long gseg;
  68. unsigned int data_segment_bytes;
  69. unsigned int control_blocks;
  70. unsigned int maximum_thread_count;
  71. unsigned int options;
  72. };
  73. /*
  74. * Structure used to pass unload context parameters to the driver
  75. */
  76. struct gru_unload_context_req {
  77. unsigned long gseg;
  78. };
  79. /*
  80. * Structure used to set context options
  81. */
  82. enum {sco_gseg_owner, sco_cch_req_slice};
  83. struct gru_set_context_option_req {
  84. unsigned long gseg;
  85. int op;
  86. unsigned long val1;
  87. };
  88. /*
  89. * Structure used to pass TLB flush parameters to the driver
  90. */
  91. struct gru_flush_tlb_req {
  92. unsigned long gseg;
  93. unsigned long vaddr;
  94. size_t len;
  95. };
  96. /*
  97. * Structure used to pass TLB flush parameters to the driver
  98. */
  99. enum {dcs_pid, dcs_gid};
  100. struct gru_dump_chiplet_state_req {
  101. unsigned int op;
  102. unsigned int gid;
  103. int ctxnum;
  104. char data_opt;
  105. char lock_cch;
  106. pid_t pid;
  107. void *buf;
  108. size_t buflen;
  109. /* ---- output --- */
  110. unsigned int num_contexts;
  111. };
  112. #define GRU_DUMP_MAGIC 0x3474ab6c
  113. struct gru_dump_context_header {
  114. unsigned int magic;
  115. unsigned int gid;
  116. unsigned char ctxnum;
  117. unsigned char cbrcnt;
  118. unsigned char dsrcnt;
  119. pid_t pid;
  120. unsigned long vaddr;
  121. int cch_locked;
  122. unsigned long data[0];
  123. };
  124. /*
  125. * GRU configuration info (temp - for testing)
  126. */
  127. struct gru_config_info {
  128. int cpus;
  129. int blades;
  130. int nodes;
  131. int chiplets;
  132. int fill[16];
  133. };
  134. #endif /* __GRULIB_H__ */