18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify 58c2ecf20Sopenharmony_ci * it under the terms of the GNU Lesser General Public License as published by 68c2ecf20Sopenharmony_ci * the Free Software Foundation; either version 2.1 of the License, or 78c2ecf20Sopenharmony_ci * (at your option) any later version. 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * This program is distributed in the hope that it will be useful, 108c2ecf20Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 118c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 128c2ecf20Sopenharmony_ci * GNU Lesser General Public License for more details. 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * You should have received a copy of the GNU Lesser General Public License 158c2ecf20Sopenharmony_ci * along with this program; if not, write to the Free Software 168c2ecf20Sopenharmony_ci * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 178c2ecf20Sopenharmony_ci */ 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#ifndef __GRULIB_H__ 208c2ecf20Sopenharmony_ci#define __GRULIB_H__ 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#define GRU_BASENAME "gru" 238c2ecf20Sopenharmony_ci#define GRU_FULLNAME "/dev/gru" 248c2ecf20Sopenharmony_ci#define GRU_IOCTL_NUM 'G' 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci/* 278c2ecf20Sopenharmony_ci * Maximum number of GRU segments that a user can have open 288c2ecf20Sopenharmony_ci * ZZZ temp - set high for testing. Revisit. 298c2ecf20Sopenharmony_ci */ 308c2ecf20Sopenharmony_ci#define GRU_MAX_OPEN_CONTEXTS 32 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci/* Set Number of Request Blocks */ 338c2ecf20Sopenharmony_ci#define GRU_CREATE_CONTEXT _IOWR(GRU_IOCTL_NUM, 1, void *) 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci/* Set Context Options */ 368c2ecf20Sopenharmony_ci#define GRU_SET_CONTEXT_OPTION _IOWR(GRU_IOCTL_NUM, 4, void *) 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci/* Fetch exception detail */ 398c2ecf20Sopenharmony_ci#define GRU_USER_GET_EXCEPTION_DETAIL _IOWR(GRU_IOCTL_NUM, 6, void *) 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci/* For user call_os handling - normally a TLB fault */ 428c2ecf20Sopenharmony_ci#define GRU_USER_CALL_OS _IOWR(GRU_IOCTL_NUM, 8, void *) 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci/* For user unload context */ 458c2ecf20Sopenharmony_ci#define GRU_USER_UNLOAD_CONTEXT _IOWR(GRU_IOCTL_NUM, 9, void *) 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci/* For dumpping GRU chiplet state */ 488c2ecf20Sopenharmony_ci#define GRU_DUMP_CHIPLET_STATE _IOWR(GRU_IOCTL_NUM, 11, void *) 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci/* For getting gseg statistics */ 518c2ecf20Sopenharmony_ci#define GRU_GET_GSEG_STATISTICS _IOWR(GRU_IOCTL_NUM, 12, void *) 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci/* For user TLB flushing (primarily for tests) */ 548c2ecf20Sopenharmony_ci#define GRU_USER_FLUSH_TLB _IOWR(GRU_IOCTL_NUM, 50, void *) 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci/* Get some config options (primarily for tests & emulator) */ 578c2ecf20Sopenharmony_ci#define GRU_GET_CONFIG_INFO _IOWR(GRU_IOCTL_NUM, 51, void *) 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci/* Various kernel self-tests */ 608c2ecf20Sopenharmony_ci#define GRU_KTEST _IOWR(GRU_IOCTL_NUM, 52, void *) 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci#define CONTEXT_WINDOW_BYTES(th) (GRU_GSEG_PAGESIZE * (th)) 638c2ecf20Sopenharmony_ci#define THREAD_POINTER(p, th) (p + GRU_GSEG_PAGESIZE * (th)) 648c2ecf20Sopenharmony_ci#define GSEG_START(cb) ((void *)((unsigned long)(cb) & ~(GRU_GSEG_PAGESIZE - 1))) 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_cistruct gru_get_gseg_statistics_req { 678c2ecf20Sopenharmony_ci unsigned long gseg; 688c2ecf20Sopenharmony_ci struct gru_gseg_statistics stats; 698c2ecf20Sopenharmony_ci}; 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci/* 728c2ecf20Sopenharmony_ci * Structure used to pass TLB flush parameters to the driver 738c2ecf20Sopenharmony_ci */ 748c2ecf20Sopenharmony_cistruct gru_create_context_req { 758c2ecf20Sopenharmony_ci unsigned long gseg; 768c2ecf20Sopenharmony_ci unsigned int data_segment_bytes; 778c2ecf20Sopenharmony_ci unsigned int control_blocks; 788c2ecf20Sopenharmony_ci unsigned int maximum_thread_count; 798c2ecf20Sopenharmony_ci unsigned int options; 808c2ecf20Sopenharmony_ci unsigned char tlb_preload_count; 818c2ecf20Sopenharmony_ci}; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci/* 848c2ecf20Sopenharmony_ci * Structure used to pass unload context parameters to the driver 858c2ecf20Sopenharmony_ci */ 868c2ecf20Sopenharmony_cistruct gru_unload_context_req { 878c2ecf20Sopenharmony_ci unsigned long gseg; 888c2ecf20Sopenharmony_ci}; 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci/* 918c2ecf20Sopenharmony_ci * Structure used to set context options 928c2ecf20Sopenharmony_ci */ 938c2ecf20Sopenharmony_cienum {sco_gseg_owner, sco_cch_req_slice, sco_blade_chiplet}; 948c2ecf20Sopenharmony_cistruct gru_set_context_option_req { 958c2ecf20Sopenharmony_ci unsigned long gseg; 968c2ecf20Sopenharmony_ci int op; 978c2ecf20Sopenharmony_ci int val0; 988c2ecf20Sopenharmony_ci long val1; 998c2ecf20Sopenharmony_ci}; 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci/* 1028c2ecf20Sopenharmony_ci * Structure used to pass TLB flush parameters to the driver 1038c2ecf20Sopenharmony_ci */ 1048c2ecf20Sopenharmony_cistruct gru_flush_tlb_req { 1058c2ecf20Sopenharmony_ci unsigned long gseg; 1068c2ecf20Sopenharmony_ci unsigned long vaddr; 1078c2ecf20Sopenharmony_ci size_t len; 1088c2ecf20Sopenharmony_ci}; 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci/* 1118c2ecf20Sopenharmony_ci * Structure used to pass TLB flush parameters to the driver 1128c2ecf20Sopenharmony_ci */ 1138c2ecf20Sopenharmony_cienum {dcs_pid, dcs_gid}; 1148c2ecf20Sopenharmony_cistruct gru_dump_chiplet_state_req { 1158c2ecf20Sopenharmony_ci unsigned int op; 1168c2ecf20Sopenharmony_ci unsigned int gid; 1178c2ecf20Sopenharmony_ci int ctxnum; 1188c2ecf20Sopenharmony_ci char data_opt; 1198c2ecf20Sopenharmony_ci char lock_cch; 1208c2ecf20Sopenharmony_ci char flush_cbrs; 1218c2ecf20Sopenharmony_ci char fill[10]; 1228c2ecf20Sopenharmony_ci pid_t pid; 1238c2ecf20Sopenharmony_ci void *buf; 1248c2ecf20Sopenharmony_ci size_t buflen; 1258c2ecf20Sopenharmony_ci /* ---- output --- */ 1268c2ecf20Sopenharmony_ci unsigned int num_contexts; 1278c2ecf20Sopenharmony_ci}; 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci#define GRU_DUMP_MAGIC 0x3474ab6c 1308c2ecf20Sopenharmony_cistruct gru_dump_context_header { 1318c2ecf20Sopenharmony_ci unsigned int magic; 1328c2ecf20Sopenharmony_ci unsigned int gid; 1338c2ecf20Sopenharmony_ci unsigned char ctxnum; 1348c2ecf20Sopenharmony_ci unsigned char cbrcnt; 1358c2ecf20Sopenharmony_ci unsigned char dsrcnt; 1368c2ecf20Sopenharmony_ci pid_t pid; 1378c2ecf20Sopenharmony_ci unsigned long vaddr; 1388c2ecf20Sopenharmony_ci int cch_locked; 1398c2ecf20Sopenharmony_ci unsigned long data[]; 1408c2ecf20Sopenharmony_ci}; 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci/* 1438c2ecf20Sopenharmony_ci * GRU configuration info (temp - for testing) 1448c2ecf20Sopenharmony_ci */ 1458c2ecf20Sopenharmony_cistruct gru_config_info { 1468c2ecf20Sopenharmony_ci int cpus; 1478c2ecf20Sopenharmony_ci int blades; 1488c2ecf20Sopenharmony_ci int nodes; 1498c2ecf20Sopenharmony_ci int chiplets; 1508c2ecf20Sopenharmony_ci int fill[16]; 1518c2ecf20Sopenharmony_ci}; 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci#endif /* __GRULIB_H__ */ 154