blob: e033b36df7e0b876156cdd84edb90cc039e3e2f4 [file] [log] [blame]
Jack Steiner13d19492008-07-29 22:33:55 -07001/*
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
19#ifndef __GRULIB_H__
20#define __GRULIB_H__
21
22#define GRU_BASENAME "gru"
23#define GRU_FULLNAME "/dev/gru"
24#define GRU_IOCTL_NUM 'G'
25
26/*
27 * Maximum number of GRU segments that a user can have open
28 * ZZZ temp - set high for testing. Revisit.
29 */
30#define GRU_MAX_OPEN_CONTEXTS 32
31
32/* Set Number of Request Blocks */
33#define GRU_CREATE_CONTEXT _IOWR(GRU_IOCTL_NUM, 1, void *)
34
Jack Steiner92b39382009-06-17 16:28:32 -070035/* Set Context Options */
36#define GRU_SET_CONTEXT_OPTION _IOWR(GRU_IOCTL_NUM, 4, void *)
Jack Steiner13d19492008-07-29 22:33:55 -070037
38/* Fetch exception detail */
39#define GRU_USER_GET_EXCEPTION_DETAIL _IOWR(GRU_IOCTL_NUM, 6, void *)
40
41/* For user call_os handling - normally a TLB fault */
42#define GRU_USER_CALL_OS _IOWR(GRU_IOCTL_NUM, 8, void *)
43
44/* For user unload context */
45#define GRU_USER_UNLOAD_CONTEXT _IOWR(GRU_IOCTL_NUM, 9, void *)
46
Jack Steiner9cc9b052009-06-17 16:28:19 -070047/* For dumpping GRU chiplet state */
48#define GRU_DUMP_CHIPLET_STATE _IOWR(GRU_IOCTL_NUM, 11, void *)
49
Jack Steiner7e796a72009-06-17 16:28:30 -070050/* For getting gseg statistics */
51#define GRU_GET_GSEG_STATISTICS _IOWR(GRU_IOCTL_NUM, 12, void *)
52
Jack Steiner13d19492008-07-29 22:33:55 -070053/* For user TLB flushing (primarily for tests) */
54#define GRU_USER_FLUSH_TLB _IOWR(GRU_IOCTL_NUM, 50, void *)
55
56/* Get some config options (primarily for tests & emulator) */
57#define GRU_GET_CONFIG_INFO _IOWR(GRU_IOCTL_NUM, 51, void *)
58
Jack Steinereb5bd5e2009-06-17 16:28:26 -070059/* Various kernel self-tests */
60#define GRU_KTEST _IOWR(GRU_IOCTL_NUM, 52, void *)
61
Jack Steiner13d19492008-07-29 22:33:55 -070062#define CONTEXT_WINDOW_BYTES(th) (GRU_GSEG_PAGESIZE * (th))
63#define THREAD_POINTER(p, th) (p + GRU_GSEG_PAGESIZE * (th))
Jack Steiner7e796a72009-06-17 16:28:30 -070064#define GSEG_START(cb) ((void *)((unsigned long)(cb) & ~(GRU_GSEG_PAGESIZE - 1)))
65
66/*
67 * Statictics kept on a per-GTS basis.
68 */
69struct gts_statistics {
70 unsigned long fmm_tlbdropin;
71 unsigned long upm_tlbdropin;
72 unsigned long context_stolen;
73};
74
75struct gru_get_gseg_statistics_req {
76 unsigned long gseg;
77 struct gts_statistics stats;
78};
Jack Steiner13d19492008-07-29 22:33:55 -070079
80/*
81 * Structure used to pass TLB flush parameters to the driver
82 */
83struct gru_create_context_req {
84 unsigned long gseg;
85 unsigned int data_segment_bytes;
86 unsigned int control_blocks;
87 unsigned int maximum_thread_count;
88 unsigned int options;
89};
90
91/*
92 * Structure used to pass unload context parameters to the driver
93 */
94struct gru_unload_context_req {
95 unsigned long gseg;
96};
97
98/*
Jack Steiner92b39382009-06-17 16:28:32 -070099 * Structure used to set context options
100 */
Jack Steiner518e5cd2009-12-15 16:48:04 -0800101enum {sco_gseg_owner, sco_cch_req_slice, sco_blade_chiplet};
Jack Steiner92b39382009-06-17 16:28:32 -0700102struct gru_set_context_option_req {
103 unsigned long gseg;
104 int op;
Jack Steiner518e5cd2009-12-15 16:48:04 -0800105 int val0;
106 long val1;
Jack Steiner92b39382009-06-17 16:28:32 -0700107};
108
109/*
Jack Steiner13d19492008-07-29 22:33:55 -0700110 * Structure used to pass TLB flush parameters to the driver
111 */
112struct gru_flush_tlb_req {
113 unsigned long gseg;
114 unsigned long vaddr;
115 size_t len;
116};
117
118/*
Jack Steiner9cc9b052009-06-17 16:28:19 -0700119 * Structure used to pass TLB flush parameters to the driver
120 */
121enum {dcs_pid, dcs_gid};
122struct gru_dump_chiplet_state_req {
123 unsigned int op;
Jack Steiner2b702b22009-06-17 16:28:34 -0700124 unsigned int gid;
Jack Steiner9cc9b052009-06-17 16:28:19 -0700125 int ctxnum;
126 char data_opt;
127 char lock_cch;
Jack Steinerb8229be2009-12-15 16:48:09 -0800128 char flush_cbrs;
129 char fill[10];
Jack Steiner9cc9b052009-06-17 16:28:19 -0700130 pid_t pid;
131 void *buf;
132 size_t buflen;
133 /* ---- output --- */
134 unsigned int num_contexts;
135};
136
137#define GRU_DUMP_MAGIC 0x3474ab6c
138struct gru_dump_context_header {
139 unsigned int magic;
Jack Steiner2b702b22009-06-17 16:28:34 -0700140 unsigned int gid;
Jack Steiner9cc9b052009-06-17 16:28:19 -0700141 unsigned char ctxnum;
142 unsigned char cbrcnt;
143 unsigned char dsrcnt;
144 pid_t pid;
145 unsigned long vaddr;
146 int cch_locked;
147 unsigned long data[0];
148};
149
150/*
Jack Steiner13d19492008-07-29 22:33:55 -0700151 * GRU configuration info (temp - for testing)
152 */
153struct gru_config_info {
154 int cpus;
155 int blades;
156 int nodes;
157 int chiplets;
158 int fill[16];
159};
160
161#endif /* __GRULIB_H__ */