grulib.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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, sco_blade_chiplet};
  83. struct gru_set_context_option_req {
  84. unsigned long gseg;
  85. int op;
  86. int val0;
  87. long val1;
  88. };
  89. /*
  90. * Structure used to pass TLB flush parameters to the driver
  91. */
  92. struct gru_flush_tlb_req {
  93. unsigned long gseg;
  94. unsigned long vaddr;
  95. size_t len;
  96. };
  97. /*
  98. * Structure used to pass TLB flush parameters to the driver
  99. */
  100. enum {dcs_pid, dcs_gid};
  101. struct gru_dump_chiplet_state_req {
  102. unsigned int op;
  103. unsigned int gid;
  104. int ctxnum;
  105. char data_opt;
  106. char lock_cch;
  107. char flush_cbrs;
  108. char fill[10];
  109. pid_t pid;
  110. void *buf;
  111. size_t buflen;
  112. /* ---- output --- */
  113. unsigned int num_contexts;
  114. };
  115. #define GRU_DUMP_MAGIC 0x3474ab6c
  116. struct gru_dump_context_header {
  117. unsigned int magic;
  118. unsigned int gid;
  119. unsigned char ctxnum;
  120. unsigned char cbrcnt;
  121. unsigned char dsrcnt;
  122. pid_t pid;
  123. unsigned long vaddr;
  124. int cch_locked;
  125. unsigned long data[0];
  126. };
  127. /*
  128. * GRU configuration info (temp - for testing)
  129. */
  130. struct gru_config_info {
  131. int cpus;
  132. int blades;
  133. int nodes;
  134. int chiplets;
  135. int fill[16];
  136. };
  137. #endif /* __GRULIB_H__ */