/*1* Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved.2*3* This program is free software; you can redistribute it and/or modify4* it under the terms of the GNU Lesser General Public License as published by5* the Free Software Foundation; either version 2.1 of the License, or6* (at your option) any later version.7*8* This program is distributed in the hope that it will be useful,9* but WITHOUT ANY WARRANTY; without even the implied warranty of10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11* GNU Lesser General Public License for more details.12*13* You should have received a copy of the GNU Lesser General Public License14* along with this program; if not, write to the Free Software15* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA16*/1718#ifndef __GRULIB_H__19#define __GRULIB_H__2021#define GRU_BASENAME "gru"22#define GRU_FULLNAME "/dev/gru"23#define GRU_IOCTL_NUM 'G'2425/*26* Maximum number of GRU segments that a user can have open27* ZZZ temp - set high for testing. Revisit.28*/29#define GRU_MAX_OPEN_CONTEXTS 323031/* Set Number of Request Blocks */32#define GRU_CREATE_CONTEXT _IOWR(GRU_IOCTL_NUM, 1, void *)3334/* Set Context Options */35#define GRU_SET_CONTEXT_OPTION _IOWR(GRU_IOCTL_NUM, 4, void *)3637/* Fetch exception detail */38#define GRU_USER_GET_EXCEPTION_DETAIL _IOWR(GRU_IOCTL_NUM, 6, void *)3940/* For user call_os handling - normally a TLB fault */41#define GRU_USER_CALL_OS _IOWR(GRU_IOCTL_NUM, 8, void *)4243/* For user unload context */44#define GRU_USER_UNLOAD_CONTEXT _IOWR(GRU_IOCTL_NUM, 9, void *)4546/* For dumpping GRU chiplet state */47#define GRU_DUMP_CHIPLET_STATE _IOWR(GRU_IOCTL_NUM, 11, void *)4849/* For getting gseg statistics */50#define GRU_GET_GSEG_STATISTICS _IOWR(GRU_IOCTL_NUM, 12, void *)5152/* For user TLB flushing (primarily for tests) */53#define GRU_USER_FLUSH_TLB _IOWR(GRU_IOCTL_NUM, 50, void *)5455/* Get some config options (primarily for tests & emulator) */56#define GRU_GET_CONFIG_INFO _IOWR(GRU_IOCTL_NUM, 51, void *)5758/* Various kernel self-tests */59#define GRU_KTEST _IOWR(GRU_IOCTL_NUM, 52, void *)6061#define CONTEXT_WINDOW_BYTES(th) (GRU_GSEG_PAGESIZE * (th))62#define THREAD_POINTER(p, th) (p + GRU_GSEG_PAGESIZE * (th))63#define GSEG_START(cb) ((void *)((unsigned long)(cb) & ~(GRU_GSEG_PAGESIZE - 1)))6465struct gru_get_gseg_statistics_req {66unsigned long gseg;67struct gru_gseg_statistics stats;68};6970/*71* Structure used to pass TLB flush parameters to the driver72*/73struct gru_create_context_req {74unsigned long gseg;75unsigned int data_segment_bytes;76unsigned int control_blocks;77unsigned int maximum_thread_count;78unsigned int options;79unsigned char tlb_preload_count;80};8182/*83* Structure used to pass unload context parameters to the driver84*/85struct gru_unload_context_req {86unsigned long gseg;87};8889/*90* Structure used to set context options91*/92enum {sco_gseg_owner, sco_cch_req_slice, sco_blade_chiplet};93struct gru_set_context_option_req {94unsigned long gseg;95int op;96int val0;97long val1;98};99100/*101* Structure used to pass TLB flush parameters to the driver102*/103struct gru_flush_tlb_req {104unsigned long gseg;105unsigned long vaddr;106size_t len;107};108109/*110* Structure used to pass TLB flush parameters to the driver111*/112enum {dcs_pid, dcs_gid};113struct gru_dump_chiplet_state_req {114unsigned int op;115unsigned int gid;116int ctxnum;117char data_opt;118char lock_cch;119char flush_cbrs;120char fill[10];121pid_t pid;122void *buf;123size_t buflen;124/* ---- output --- */125unsigned int num_contexts;126};127128#define GRU_DUMP_MAGIC 0x3474ab6c129struct gru_dump_context_header {130unsigned int magic;131unsigned int gid;132unsigned char ctxnum;133unsigned char cbrcnt;134unsigned char dsrcnt;135pid_t pid;136unsigned long vaddr;137int cch_locked;138unsigned long data[0];139};140141/*142* GRU configuration info (temp - for testing)143*/144struct gru_config_info {145int cpus;146int blades;147int nodes;148int chiplets;149int fill[16];150};151152#endif /* __GRULIB_H__ */153154155