grulib.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. struct gru_get_gseg_statistics_req {
  52. unsigned long gseg;
  53. struct gru_gseg_statistics stats;
  54. };
  55. /*
  56. * Structure used to pass TLB flush parameters to the driver
  57. */
  58. struct gru_create_context_req {
  59. unsigned long gseg;
  60. unsigned int data_segment_bytes;
  61. unsigned int control_blocks;
  62. unsigned int maximum_thread_count;
  63. unsigned int options;
  64. unsigned char tlb_preload_count;
  65. };
  66. /*
  67. * Structure used to pass unload context parameters to the driver
  68. */
  69. struct gru_unload_context_req {
  70. unsigned long gseg;
  71. };
  72. /*
  73. * Structure used to set context options
  74. */
  75. enum {sco_gseg_owner, sco_cch_req_slice, sco_blade_chiplet};
  76. struct gru_set_context_option_req {
  77. unsigned long gseg;
  78. int op;
  79. int val0;
  80. long val1;
  81. };
  82. /*
  83. * Structure used to pass TLB flush parameters to the driver
  84. */
  85. struct gru_flush_tlb_req {
  86. unsigned long gseg;
  87. unsigned long vaddr;
  88. size_t len;
  89. };
  90. /*
  91. * Structure used to pass TLB flush parameters to the driver
  92. */
  93. enum {dcs_pid, dcs_gid};
  94. struct gru_dump_chiplet_state_req {
  95. unsigned int op;
  96. unsigned int gid;
  97. int ctxnum;
  98. char data_opt;
  99. char lock_cch;
  100. char flush_cbrs;
  101. char fill[10];
  102. pid_t pid;
  103. void *buf;
  104. size_t buflen;
  105. /* ---- output --- */
  106. unsigned int num_contexts;
  107. };
  108. #define GRU_DUMP_MAGIC 0x3474ab6c
  109. struct gru_dump_context_header {
  110. unsigned int magic;
  111. unsigned int gid;
  112. unsigned char ctxnum;
  113. unsigned char cbrcnt;
  114. unsigned char dsrcnt;
  115. pid_t pid;
  116. unsigned long vaddr;
  117. int cch_locked;
  118. unsigned long data[0];
  119. };
  120. /*
  121. * GRU configuration info (temp - for testing)
  122. */
  123. struct gru_config_info {
  124. int cpus;
  125. int blades;
  126. int nodes;
  127. int chiplets;
  128. int fill[16];
  129. };
  130. #endif /* __GRULIB_H__ */