| Jack Steiner | 13d1949 | 2008-07-29 22:33:55 -0700 | [diff] [blame] | 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 |  | 
|  | 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 Steiner | 92b3938 | 2009-06-17 16:28:32 -0700 | [diff] [blame] | 35 | /*  Set Context Options */ | 
|  | 36 | #define GRU_SET_CONTEXT_OPTION		_IOWR(GRU_IOCTL_NUM, 4, void *) | 
| Jack Steiner | 13d1949 | 2008-07-29 22:33:55 -0700 | [diff] [blame] | 37 |  | 
|  | 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 Steiner | 9cc9b05 | 2009-06-17 16:28:19 -0700 | [diff] [blame] | 47 | /* For dumpping GRU chiplet state */ | 
|  | 48 | #define GRU_DUMP_CHIPLET_STATE		_IOWR(GRU_IOCTL_NUM, 11, void *) | 
|  | 49 |  | 
| Jack Steiner | 7e796a7 | 2009-06-17 16:28:30 -0700 | [diff] [blame] | 50 | /* For getting gseg statistics */ | 
|  | 51 | #define GRU_GET_GSEG_STATISTICS		_IOWR(GRU_IOCTL_NUM, 12, void *) | 
|  | 52 |  | 
| Jack Steiner | 13d1949 | 2008-07-29 22:33:55 -0700 | [diff] [blame] | 53 | /* 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 Steiner | eb5bd5e | 2009-06-17 16:28:26 -0700 | [diff] [blame] | 59 | /* Various kernel self-tests */ | 
|  | 60 | #define GRU_KTEST			_IOWR(GRU_IOCTL_NUM, 52, void *) | 
|  | 61 |  | 
| Jack Steiner | 13d1949 | 2008-07-29 22:33:55 -0700 | [diff] [blame] | 62 | #define CONTEXT_WINDOW_BYTES(th)        (GRU_GSEG_PAGESIZE * (th)) | 
|  | 63 | #define THREAD_POINTER(p, th)		(p + GRU_GSEG_PAGESIZE * (th)) | 
| Jack Steiner | 7e796a7 | 2009-06-17 16:28:30 -0700 | [diff] [blame] | 64 | #define GSEG_START(cb)			((void *)((unsigned long)(cb) & ~(GRU_GSEG_PAGESIZE - 1))) | 
|  | 65 |  | 
| Jack Steiner | 7e796a7 | 2009-06-17 16:28:30 -0700 | [diff] [blame] | 66 | struct gru_get_gseg_statistics_req { | 
| Jack Steiner | 5958ab8 | 2009-12-15 16:48:18 -0800 | [diff] [blame] | 67 | unsigned long			gseg; | 
|  | 68 | struct gru_gseg_statistics	stats; | 
| Jack Steiner | 7e796a7 | 2009-06-17 16:28:30 -0700 | [diff] [blame] | 69 | }; | 
| Jack Steiner | 13d1949 | 2008-07-29 22:33:55 -0700 | [diff] [blame] | 70 |  | 
|  | 71 | /* | 
|  | 72 | * Structure used to pass TLB flush parameters to the driver | 
|  | 73 | */ | 
|  | 74 | struct gru_create_context_req { | 
|  | 75 | unsigned long		gseg; | 
|  | 76 | unsigned int		data_segment_bytes; | 
|  | 77 | unsigned int		control_blocks; | 
|  | 78 | unsigned int		maximum_thread_count; | 
|  | 79 | unsigned int		options; | 
| Jack Steiner | c550222 | 2009-12-15 16:48:13 -0800 | [diff] [blame] | 80 | unsigned char		tlb_preload_count; | 
| Jack Steiner | 13d1949 | 2008-07-29 22:33:55 -0700 | [diff] [blame] | 81 | }; | 
|  | 82 |  | 
|  | 83 | /* | 
|  | 84 | * Structure used to pass unload context parameters to the driver | 
|  | 85 | */ | 
|  | 86 | struct gru_unload_context_req { | 
|  | 87 | unsigned long	gseg; | 
|  | 88 | }; | 
|  | 89 |  | 
|  | 90 | /* | 
| Jack Steiner | 92b3938 | 2009-06-17 16:28:32 -0700 | [diff] [blame] | 91 | * Structure used to set context options | 
|  | 92 | */ | 
| Jack Steiner | 518e5cd | 2009-12-15 16:48:04 -0800 | [diff] [blame] | 93 | enum {sco_gseg_owner, sco_cch_req_slice, sco_blade_chiplet}; | 
| Jack Steiner | 92b3938 | 2009-06-17 16:28:32 -0700 | [diff] [blame] | 94 | struct gru_set_context_option_req { | 
|  | 95 | unsigned long	gseg; | 
|  | 96 | int		op; | 
| Jack Steiner | 518e5cd | 2009-12-15 16:48:04 -0800 | [diff] [blame] | 97 | int		val0; | 
|  | 98 | long		val1; | 
| Jack Steiner | 92b3938 | 2009-06-17 16:28:32 -0700 | [diff] [blame] | 99 | }; | 
|  | 100 |  | 
|  | 101 | /* | 
| Jack Steiner | 13d1949 | 2008-07-29 22:33:55 -0700 | [diff] [blame] | 102 | * Structure used to pass TLB flush parameters to the driver | 
|  | 103 | */ | 
|  | 104 | struct gru_flush_tlb_req { | 
|  | 105 | unsigned long	gseg; | 
|  | 106 | unsigned long	vaddr; | 
|  | 107 | size_t		len; | 
|  | 108 | }; | 
|  | 109 |  | 
|  | 110 | /* | 
| Jack Steiner | 9cc9b05 | 2009-06-17 16:28:19 -0700 | [diff] [blame] | 111 | * Structure used to pass TLB flush parameters to the driver | 
|  | 112 | */ | 
|  | 113 | enum {dcs_pid, dcs_gid}; | 
|  | 114 | struct gru_dump_chiplet_state_req { | 
|  | 115 | unsigned int	op; | 
| Jack Steiner | 2b702b2 | 2009-06-17 16:28:34 -0700 | [diff] [blame] | 116 | unsigned int	gid; | 
| Jack Steiner | 9cc9b05 | 2009-06-17 16:28:19 -0700 | [diff] [blame] | 117 | int		ctxnum; | 
|  | 118 | char		data_opt; | 
|  | 119 | char		lock_cch; | 
| Jack Steiner | b8229be | 2009-12-15 16:48:09 -0800 | [diff] [blame] | 120 | char		flush_cbrs; | 
|  | 121 | char		fill[10]; | 
| Jack Steiner | 9cc9b05 | 2009-06-17 16:28:19 -0700 | [diff] [blame] | 122 | pid_t		pid; | 
|  | 123 | void		*buf; | 
|  | 124 | size_t		buflen; | 
|  | 125 | /* ---- output --- */ | 
|  | 126 | unsigned int	num_contexts; | 
|  | 127 | }; | 
|  | 128 |  | 
|  | 129 | #define GRU_DUMP_MAGIC	0x3474ab6c | 
|  | 130 | struct gru_dump_context_header { | 
|  | 131 | unsigned int	magic; | 
| Jack Steiner | 2b702b2 | 2009-06-17 16:28:34 -0700 | [diff] [blame] | 132 | unsigned int	gid; | 
| Jack Steiner | 9cc9b05 | 2009-06-17 16:28:19 -0700 | [diff] [blame] | 133 | unsigned char	ctxnum; | 
|  | 134 | unsigned char	cbrcnt; | 
|  | 135 | unsigned char	dsrcnt; | 
|  | 136 | pid_t		pid; | 
|  | 137 | unsigned long	vaddr; | 
|  | 138 | int		cch_locked; | 
|  | 139 | unsigned long	data[0]; | 
|  | 140 | }; | 
|  | 141 |  | 
|  | 142 | /* | 
| Jack Steiner | 13d1949 | 2008-07-29 22:33:55 -0700 | [diff] [blame] | 143 | * GRU configuration info (temp - for testing) | 
|  | 144 | */ | 
|  | 145 | struct gru_config_info { | 
|  | 146 | int		cpus; | 
|  | 147 | int		blades; | 
|  | 148 | int		nodes; | 
|  | 149 | int		chiplets; | 
|  | 150 | int		fill[16]; | 
|  | 151 | }; | 
|  | 152 |  | 
|  | 153 | #endif /* __GRULIB_H__ */ |