Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* -*- linux-c -*- |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * |
| 3 | * iSeries Virtual I/O Message Path header |
| 4 | * |
| 5 | * Authors: Dave Boutcher <boutcher@us.ibm.com> |
| 6 | * Ryan Arnold <ryanarn@us.ibm.com> |
| 7 | * Colin Devilbiss <devilbis@us.ibm.com> |
| 8 | * |
| 9 | * (C) Copyright 2000 IBM Corporation |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame] | 10 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | * This header file is used by the iSeries virtual I/O device |
| 12 | * drivers. It defines the interfaces to the common functions |
| 13 | * (implemented in drivers/char/viopath.h) as well as defining |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame] | 14 | * common functions and structures. Currently (at the time I |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | * wrote this comment) the iSeries virtual I/O device drivers |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame] | 16 | * that use this are |
| 17 | * drivers/block/viodasd.c |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | * drivers/char/viocons.c |
| 19 | * drivers/char/viotape.c |
| 20 | * drivers/cdrom/viocd.c |
| 21 | * |
| 22 | * The iSeries virtual ethernet support (veth.c) uses a whole |
| 23 | * different set of functions. |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame] | 24 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | * This program is free software; you can redistribute it and/or |
| 26 | * modify it under the terms of the GNU General Public License as |
| 27 | * published by the Free Software Foundation; either version 2 of the |
| 28 | * License, or (at your option) anyu later version. |
| 29 | * |
| 30 | * This program is distributed in the hope that it will be useful, but |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame] | 31 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame] | 33 | * General Public License for more details. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | * |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame] | 35 | * You should have received a copy of the GNU General Public License |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | * along with this program; if not, write to the Free Software Foundation, |
| 37 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 38 | * |
| 39 | */ |
Kelly Daly | ecb3ca27 | 2005-11-02 15:53:01 +1100 | [diff] [blame] | 40 | #ifndef _ASM_POWERPC_ISERIES_VIO_H |
| 41 | #define _ASM_POWERPC_ISERIES_VIO_H |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
Kelly Daly | 1ec65d7 | 2005-11-02 13:46:07 +1100 | [diff] [blame] | 43 | #include <asm/iseries/hv_types.h> |
Kelly Daly | e45423e | 2005-11-02 12:08:31 +1100 | [diff] [blame] | 44 | #include <asm/iseries/hv_lp_event.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame] | 46 | /* |
| 47 | * iSeries virtual I/O events use the subtype field in |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | * HvLpEvent to figure out what kind of vio event is coming |
| 49 | * in. We use a table to route these, and this defines |
| 50 | * the maximum number of distinct subtypes |
| 51 | */ |
| 52 | #define VIO_MAX_SUBTYPES 8 |
| 53 | |
Stephen Rothwell | b833b48 | 2007-10-11 14:57:26 +1000 | [diff] [blame] | 54 | struct viocdlpevent { |
| 55 | struct HvLpEvent event; |
| 56 | u32 reserved; |
| 57 | u16 version; |
| 58 | u16 sub_result; |
| 59 | u16 disk; |
| 60 | u16 flags; |
| 61 | u32 token; |
| 62 | u64 offset; /* On open, max number of disks */ |
| 63 | u64 len; /* On open, size of the disk */ |
| 64 | u32 block_size; /* Only set on open */ |
| 65 | u32 media_size; /* Only set on open */ |
| 66 | }; |
| 67 | |
| 68 | enum viocdsubtype { |
| 69 | viocdopen = 0x0001, |
| 70 | viocdclose = 0x0002, |
| 71 | viocdread = 0x0003, |
| 72 | viocdwrite = 0x0004, |
| 73 | viocdlockdoor = 0x0005, |
| 74 | viocdgetinfo = 0x0006, |
| 75 | viocdcheck = 0x0007 |
| 76 | }; |
| 77 | |
Stephen Rothwell | 7465ce0 | 2007-10-11 14:58:31 +1000 | [diff] [blame^] | 78 | struct viotapelpevent { |
| 79 | struct HvLpEvent event; |
| 80 | u32 reserved; |
| 81 | u16 version; |
| 82 | u16 sub_type_result; |
| 83 | u16 tape; |
| 84 | u16 flags; |
| 85 | u32 token; |
| 86 | u64 len; |
| 87 | union { |
| 88 | struct { |
| 89 | u32 tape_op; |
| 90 | u32 count; |
| 91 | } op; |
| 92 | struct { |
| 93 | u32 type; |
| 94 | u32 resid; |
| 95 | u32 dsreg; |
| 96 | u32 gstat; |
| 97 | u32 erreg; |
| 98 | u32 file_no; |
| 99 | u32 block_no; |
| 100 | } get_status; |
| 101 | struct { |
| 102 | u32 block_no; |
| 103 | } get_pos; |
| 104 | } u; |
| 105 | }; |
| 106 | |
| 107 | enum viotapesubtype { |
| 108 | viotapeopen = 0x0001, |
| 109 | viotapeclose = 0x0002, |
| 110 | viotaperead = 0x0003, |
| 111 | viotapewrite = 0x0004, |
| 112 | viotapegetinfo = 0x0005, |
| 113 | viotapeop = 0x0006, |
| 114 | viotapegetpos = 0x0007, |
| 115 | viotapesetpos = 0x0008, |
| 116 | viotapegetstatus = 0x0009 |
| 117 | }; |
| 118 | |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame] | 119 | /* |
| 120 | * Each subtype can register a handler to process their events. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | * The handler must have this interface. |
| 122 | */ |
| 123 | typedef void (vio_event_handler_t) (struct HvLpEvent * event); |
| 124 | |
Stephen Rothwell | 6b7feec | 2005-06-21 17:15:35 -0700 | [diff] [blame] | 125 | extern int viopath_open(HvLpIndex remoteLp, int subtype, int numReq); |
| 126 | extern int viopath_close(HvLpIndex remoteLp, int subtype, int numReq); |
| 127 | extern int vio_setHandler(int subtype, vio_event_handler_t * beh); |
| 128 | extern int vio_clearHandler(int subtype); |
| 129 | extern int viopath_isactive(HvLpIndex lp); |
| 130 | extern HvLpInstanceId viopath_sourceinst(HvLpIndex lp); |
| 131 | extern HvLpInstanceId viopath_targetinst(HvLpIndex lp); |
| 132 | extern void vio_set_hostlp(void); |
| 133 | extern void *vio_get_event_buffer(int subtype); |
| 134 | extern void vio_free_event_buffer(int subtype, void *buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | |
| 136 | extern HvLpIndex viopath_hostLp; |
| 137 | extern HvLpIndex viopath_ourLp; |
| 138 | |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame] | 139 | #define VIOCHAR_MAX_DATA 200 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame] | 141 | #define VIOMAJOR_SUBTYPE_MASK 0xff00 |
| 142 | #define VIOMINOR_SUBTYPE_MASK 0x00ff |
| 143 | #define VIOMAJOR_SUBTYPE_SHIFT 8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame] | 145 | #define VIOVERSION 0x0101 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | |
| 147 | /* |
| 148 | * This is the general structure for VIO errors; each module should have |
| 149 | * a table of them, and each table should be terminated by an entry of |
| 150 | * { 0, 0, NULL }. Then, to find a specific error message, a module |
| 151 | * should pass its local table and the return code. |
| 152 | */ |
| 153 | struct vio_error_entry { |
| 154 | u16 rc; |
| 155 | int errno; |
| 156 | const char *msg; |
| 157 | }; |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame] | 158 | extern const struct vio_error_entry *vio_lookup_rc( |
| 159 | const struct vio_error_entry *local_table, u16 rc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | |
| 161 | enum viosubtypes { |
| 162 | viomajorsubtype_monitor = 0x0100, |
| 163 | viomajorsubtype_blockio = 0x0200, |
| 164 | viomajorsubtype_chario = 0x0300, |
| 165 | viomajorsubtype_config = 0x0400, |
| 166 | viomajorsubtype_cdio = 0x0500, |
| 167 | viomajorsubtype_tape = 0x0600, |
| 168 | viomajorsubtype_scsi = 0x0700 |
| 169 | }; |
| 170 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | enum vioconfigsubtype { |
| 172 | vioconfigget = 0x0001, |
| 173 | }; |
| 174 | |
| 175 | enum viorc { |
| 176 | viorc_good = 0x0000, |
| 177 | viorc_noConnection = 0x0001, |
| 178 | viorc_noReceiver = 0x0002, |
| 179 | viorc_noBufferAvailable = 0x0003, |
| 180 | viorc_invalidMessageType = 0x0004, |
| 181 | viorc_invalidRange = 0x0201, |
| 182 | viorc_invalidToken = 0x0202, |
| 183 | viorc_DMAError = 0x0203, |
| 184 | viorc_useError = 0x0204, |
| 185 | viorc_releaseError = 0x0205, |
| 186 | viorc_invalidDisk = 0x0206, |
| 187 | viorc_openRejected = 0x0301 |
| 188 | }; |
| 189 | |
Stephen Rothwell | 8bff05b | 2006-07-13 18:51:22 +1000 | [diff] [blame] | 190 | /* |
| 191 | * The structure of the events that flow between us and OS/400 for chario |
| 192 | * events. You can't mess with this unless the OS/400 side changes too. |
| 193 | */ |
| 194 | struct viocharlpevent { |
| 195 | struct HvLpEvent event; |
| 196 | u32 reserved; |
| 197 | u16 version; |
| 198 | u16 subtype_result_code; |
| 199 | u8 virtual_device; |
| 200 | u8 len; |
| 201 | u8 data[VIOCHAR_MAX_DATA]; |
| 202 | }; |
| 203 | |
| 204 | #define VIOCHAR_WINDOW 10 |
| 205 | |
| 206 | enum viocharsubtype { |
| 207 | viocharopen = 0x0001, |
| 208 | viocharclose = 0x0002, |
| 209 | viochardata = 0x0003, |
| 210 | viocharack = 0x0004, |
| 211 | viocharconfig = 0x0005 |
| 212 | }; |
| 213 | |
| 214 | enum viochar_rc { |
| 215 | viochar_rc_ebusy = 1 |
| 216 | }; |
| 217 | |
Kelly Daly | ecb3ca27 | 2005-11-02 15:53:01 +1100 | [diff] [blame] | 218 | #endif /* _ASM_POWERPC_ISERIES_VIO_H */ |