^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * This program is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * it under the terms of the GNU Lesser General Public License as published by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * the Free Software Foundation; either version 2.1 of the License, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * (at your option) any later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * This program is distributed in the hope that it will be useful,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * but WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * GNU Lesser General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * You should have received a copy of the GNU Lesser General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * along with this program; if not, write to the Free Software
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #ifndef __GRULIB_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define __GRULIB_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define GRU_BASENAME "gru"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define GRU_FULLNAME "/dev/gru"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define GRU_IOCTL_NUM 'G'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * Maximum number of GRU segments that a user can have open
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * ZZZ temp - set high for testing. Revisit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define GRU_MAX_OPEN_CONTEXTS 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) /* Set Number of Request Blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define GRU_CREATE_CONTEXT _IOWR(GRU_IOCTL_NUM, 1, void *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) /* Set Context Options */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define GRU_SET_CONTEXT_OPTION _IOWR(GRU_IOCTL_NUM, 4, void *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) /* Fetch exception detail */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define GRU_USER_GET_EXCEPTION_DETAIL _IOWR(GRU_IOCTL_NUM, 6, void *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) /* For user call_os handling - normally a TLB fault */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #define GRU_USER_CALL_OS _IOWR(GRU_IOCTL_NUM, 8, void *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) /* For user unload context */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define GRU_USER_UNLOAD_CONTEXT _IOWR(GRU_IOCTL_NUM, 9, void *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /* For dumpping GRU chiplet state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #define GRU_DUMP_CHIPLET_STATE _IOWR(GRU_IOCTL_NUM, 11, void *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) /* For getting gseg statistics */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #define GRU_GET_GSEG_STATISTICS _IOWR(GRU_IOCTL_NUM, 12, void *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /* For user TLB flushing (primarily for tests) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #define GRU_USER_FLUSH_TLB _IOWR(GRU_IOCTL_NUM, 50, void *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) /* Get some config options (primarily for tests & emulator) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #define GRU_GET_CONFIG_INFO _IOWR(GRU_IOCTL_NUM, 51, void *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) /* Various kernel self-tests */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #define GRU_KTEST _IOWR(GRU_IOCTL_NUM, 52, void *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #define CONTEXT_WINDOW_BYTES(th) (GRU_GSEG_PAGESIZE * (th))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #define THREAD_POINTER(p, th) (p + GRU_GSEG_PAGESIZE * (th))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #define GSEG_START(cb) ((void *)((unsigned long)(cb) & ~(GRU_GSEG_PAGESIZE - 1)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct gru_get_gseg_statistics_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) unsigned long gseg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) struct gru_gseg_statistics stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) * Structure used to pass TLB flush parameters to the driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) struct gru_create_context_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) unsigned long gseg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) unsigned int data_segment_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) unsigned int control_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) unsigned int maximum_thread_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) unsigned int options;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) unsigned char tlb_preload_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * Structure used to pass unload context parameters to the driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) struct gru_unload_context_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) unsigned long gseg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) * Structure used to set context options
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) enum {sco_gseg_owner, sco_cch_req_slice, sco_blade_chiplet};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) struct gru_set_context_option_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) unsigned long gseg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) int op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) int val0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) long val1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * Structure used to pass TLB flush parameters to the driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) struct gru_flush_tlb_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) unsigned long gseg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) unsigned long vaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) size_t len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) * Structure used to pass TLB flush parameters to the driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) enum {dcs_pid, dcs_gid};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) struct gru_dump_chiplet_state_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) unsigned int op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) unsigned int gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) int ctxnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) char data_opt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) char lock_cch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) char flush_cbrs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) char fill[10];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) pid_t pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) void *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) size_t buflen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) /* ---- output --- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) unsigned int num_contexts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) #define GRU_DUMP_MAGIC 0x3474ab6c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) struct gru_dump_context_header {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) unsigned int magic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) unsigned int gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) unsigned char ctxnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) unsigned char cbrcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) unsigned char dsrcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) pid_t pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) unsigned long vaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) int cch_locked;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) unsigned long data[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) * GRU configuration info (temp - for testing)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) struct gru_config_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) int cpus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) int blades;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) int nodes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) int chiplets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) int fill[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) #endif /* __GRULIB_H__ */