Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  *  Copyright (c) 2008 Silicon Graphics, Inc.  All Rights Reserved.
0003  *
0004  *  This program is free software; you can redistribute it and/or modify
0005  *  it under the terms of the GNU Lesser General Public License as published by
0006  *  the Free Software Foundation; either version 2.1 of the License, or
0007  *  (at your option) any later version.
0008  *
0009  *  This program is distributed in the hope that it will be useful,
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *  GNU Lesser General Public License for more details.
0013  *
0014  *  You should have received a copy of the GNU Lesser General Public License
0015  *  along with this program; if not, write to the Free Software
0016  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
0017  */
0018 
0019 #ifndef __GRULIB_H__
0020 #define __GRULIB_H__
0021 
0022 #define GRU_BASENAME        "gru"
0023 #define GRU_FULLNAME        "/dev/gru"
0024 #define GRU_IOCTL_NUM        'G'
0025 
0026 /*
0027  * Maximum number of GRU segments that a user can have open
0028  * ZZZ temp - set high for testing. Revisit.
0029  */
0030 #define GRU_MAX_OPEN_CONTEXTS       32
0031 
0032 /* Set Number of Request Blocks */
0033 #define GRU_CREATE_CONTEXT      _IOWR(GRU_IOCTL_NUM, 1, void *)
0034 
0035 /*  Set Context Options */
0036 #define GRU_SET_CONTEXT_OPTION      _IOWR(GRU_IOCTL_NUM, 4, void *)
0037 
0038 /* Fetch exception detail */
0039 #define GRU_USER_GET_EXCEPTION_DETAIL   _IOWR(GRU_IOCTL_NUM, 6, void *)
0040 
0041 /* For user call_os handling - normally a TLB fault */
0042 #define GRU_USER_CALL_OS        _IOWR(GRU_IOCTL_NUM, 8, void *)
0043 
0044 /* For user unload context */
0045 #define GRU_USER_UNLOAD_CONTEXT     _IOWR(GRU_IOCTL_NUM, 9, void *)
0046 
0047 /* For dumpping GRU chiplet state */
0048 #define GRU_DUMP_CHIPLET_STATE      _IOWR(GRU_IOCTL_NUM, 11, void *)
0049 
0050 /* For getting gseg statistics */
0051 #define GRU_GET_GSEG_STATISTICS     _IOWR(GRU_IOCTL_NUM, 12, void *)
0052 
0053 /* For user TLB flushing (primarily for tests) */
0054 #define GRU_USER_FLUSH_TLB      _IOWR(GRU_IOCTL_NUM, 50, void *)
0055 
0056 /* Get some config options (primarily for tests & emulator) */
0057 #define GRU_GET_CONFIG_INFO     _IOWR(GRU_IOCTL_NUM, 51, void *)
0058 
0059 /* Various kernel self-tests */
0060 #define GRU_KTEST           _IOWR(GRU_IOCTL_NUM, 52, void *)
0061 
0062 #define CONTEXT_WINDOW_BYTES(th)        (GRU_GSEG_PAGESIZE * (th))
0063 #define THREAD_POINTER(p, th)       (p + GRU_GSEG_PAGESIZE * (th))
0064 #define GSEG_START(cb)          ((void *)((unsigned long)(cb) & ~(GRU_GSEG_PAGESIZE - 1)))
0065 
0066 struct gru_get_gseg_statistics_req {
0067     unsigned long           gseg;
0068     struct gru_gseg_statistics  stats;
0069 };
0070 
0071 /*
0072  * Structure used to pass TLB flush parameters to the driver
0073  */
0074 struct gru_create_context_req {
0075     unsigned long       gseg;
0076     unsigned int        data_segment_bytes;
0077     unsigned int        control_blocks;
0078     unsigned int        maximum_thread_count;
0079     unsigned int        options;
0080     unsigned char       tlb_preload_count;
0081 };
0082 
0083 /*
0084  * Structure used to pass unload context parameters to the driver
0085  */
0086 struct gru_unload_context_req {
0087     unsigned long   gseg;
0088 };
0089 
0090 /*
0091  * Structure used to set context options
0092  */
0093 enum {sco_gseg_owner, sco_cch_req_slice, sco_blade_chiplet};
0094 struct gru_set_context_option_req {
0095     unsigned long   gseg;
0096     int     op;
0097     int     val0;
0098     long        val1;
0099 };
0100 
0101 /*
0102  * Structure used to pass TLB flush parameters to the driver
0103  */
0104 struct gru_flush_tlb_req {
0105     unsigned long   gseg;
0106     unsigned long   vaddr;
0107     size_t      len;
0108 };
0109 
0110 /*
0111  * Structure used to pass TLB flush parameters to the driver
0112  */
0113 enum {dcs_pid, dcs_gid};
0114 struct gru_dump_chiplet_state_req {
0115     unsigned int    op;
0116     unsigned int    gid;
0117     int     ctxnum;
0118     char        data_opt;
0119     char        lock_cch;
0120     char        flush_cbrs;
0121     char        fill[10];
0122     pid_t       pid;
0123     void        *buf;
0124     size_t      buflen;
0125     /* ---- output --- */
0126     unsigned int    num_contexts;
0127 };
0128 
0129 #define GRU_DUMP_MAGIC  0x3474ab6c
0130 struct gru_dump_context_header {
0131     unsigned int    magic;
0132     unsigned int    gid;
0133     unsigned char   ctxnum;
0134     unsigned char   cbrcnt;
0135     unsigned char   dsrcnt;
0136     pid_t       pid;
0137     unsigned long   vaddr;
0138     int     cch_locked;
0139     unsigned long   data[];
0140 };
0141 
0142 /*
0143  * GRU configuration info (temp - for testing)
0144  */
0145 struct gru_config_info {
0146     int     cpus;
0147     int     blades;
0148     int     nodes;
0149     int     chiplets;
0150     int     fill[16];
0151 };
0152 
0153 #endif /* __GRULIB_H__ */