vio.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /* -*- linux-c -*-
  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
  10. *
  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
  14. * common functions and structures. Currently (at the time I
  15. * wrote this comment) the iSeries virtual I/O device drivers
  16. * that use this are
  17. * drivers/block/viodasd.c
  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.
  24. *
  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
  31. * WITHOUT ANY WARRANTY; without even the implied warranty of
  32. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  33. * General Public License for more details.
  34. *
  35. * You should have received a copy of the GNU General Public License
  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. */
  40. #ifndef _ASM_POWERPC_ISERIES_VIO_H
  41. #define _ASM_POWERPC_ISERIES_VIO_H
  42. #include <asm/iseries/hv_types.h>
  43. #include <asm/iseries/hv_lp_event.h>
  44. /*
  45. * iSeries virtual I/O events use the subtype field in
  46. * HvLpEvent to figure out what kind of vio event is coming
  47. * in. We use a table to route these, and this defines
  48. * the maximum number of distinct subtypes
  49. */
  50. #define VIO_MAX_SUBTYPES 8
  51. #define VIOMAXBLOCKDMA 12
  52. struct open_data {
  53. u64 disk_size;
  54. u16 max_disk;
  55. u16 cylinders;
  56. u16 tracks;
  57. u16 sectors;
  58. u16 bytes_per_sector;
  59. };
  60. struct rw_data {
  61. u64 offset;
  62. struct {
  63. u32 token;
  64. u32 reserved;
  65. u64 len;
  66. } dma_info[VIOMAXBLOCKDMA];
  67. };
  68. struct vioblocklpevent {
  69. struct HvLpEvent event;
  70. u32 reserved;
  71. u16 version;
  72. u16 sub_result;
  73. u16 disk;
  74. u16 flags;
  75. union {
  76. struct open_data open_data;
  77. struct rw_data rw_data;
  78. u64 changed;
  79. } u;
  80. };
  81. #define vioblockflags_ro 0x0001
  82. enum vioblocksubtype {
  83. vioblockopen = 0x0001,
  84. vioblockclose = 0x0002,
  85. vioblockread = 0x0003,
  86. vioblockwrite = 0x0004,
  87. vioblockflush = 0x0005,
  88. vioblockcheck = 0x0007
  89. };
  90. struct viocdlpevent {
  91. struct HvLpEvent event;
  92. u32 reserved;
  93. u16 version;
  94. u16 sub_result;
  95. u16 disk;
  96. u16 flags;
  97. u32 token;
  98. u64 offset; /* On open, max number of disks */
  99. u64 len; /* On open, size of the disk */
  100. u32 block_size; /* Only set on open */
  101. u32 media_size; /* Only set on open */
  102. };
  103. enum viocdsubtype {
  104. viocdopen = 0x0001,
  105. viocdclose = 0x0002,
  106. viocdread = 0x0003,
  107. viocdwrite = 0x0004,
  108. viocdlockdoor = 0x0005,
  109. viocdgetinfo = 0x0006,
  110. viocdcheck = 0x0007
  111. };
  112. struct viotapelpevent {
  113. struct HvLpEvent event;
  114. u32 reserved;
  115. u16 version;
  116. u16 sub_type_result;
  117. u16 tape;
  118. u16 flags;
  119. u32 token;
  120. u64 len;
  121. union {
  122. struct {
  123. u32 tape_op;
  124. u32 count;
  125. } op;
  126. struct {
  127. u32 type;
  128. u32 resid;
  129. u32 dsreg;
  130. u32 gstat;
  131. u32 erreg;
  132. u32 file_no;
  133. u32 block_no;
  134. } get_status;
  135. struct {
  136. u32 block_no;
  137. } get_pos;
  138. } u;
  139. };
  140. enum viotapesubtype {
  141. viotapeopen = 0x0001,
  142. viotapeclose = 0x0002,
  143. viotaperead = 0x0003,
  144. viotapewrite = 0x0004,
  145. viotapegetinfo = 0x0005,
  146. viotapeop = 0x0006,
  147. viotapegetpos = 0x0007,
  148. viotapesetpos = 0x0008,
  149. viotapegetstatus = 0x0009
  150. };
  151. /*
  152. * Each subtype can register a handler to process their events.
  153. * The handler must have this interface.
  154. */
  155. typedef void (vio_event_handler_t) (struct HvLpEvent * event);
  156. extern int viopath_open(HvLpIndex remoteLp, int subtype, int numReq);
  157. extern int viopath_close(HvLpIndex remoteLp, int subtype, int numReq);
  158. extern int vio_setHandler(int subtype, vio_event_handler_t * beh);
  159. extern int vio_clearHandler(int subtype);
  160. extern int viopath_isactive(HvLpIndex lp);
  161. extern HvLpInstanceId viopath_sourceinst(HvLpIndex lp);
  162. extern HvLpInstanceId viopath_targetinst(HvLpIndex lp);
  163. extern void vio_set_hostlp(void);
  164. extern void *vio_get_event_buffer(int subtype);
  165. extern void vio_free_event_buffer(int subtype, void *buffer);
  166. extern struct vio_dev *vio_create_viodasd(u32 unit);
  167. extern HvLpIndex viopath_hostLp;
  168. extern HvLpIndex viopath_ourLp;
  169. #define VIOCHAR_MAX_DATA 200
  170. #define VIOMAJOR_SUBTYPE_MASK 0xff00
  171. #define VIOMINOR_SUBTYPE_MASK 0x00ff
  172. #define VIOMAJOR_SUBTYPE_SHIFT 8
  173. #define VIOVERSION 0x0101
  174. /*
  175. * This is the general structure for VIO errors; each module should have
  176. * a table of them, and each table should be terminated by an entry of
  177. * { 0, 0, NULL }. Then, to find a specific error message, a module
  178. * should pass its local table and the return code.
  179. */
  180. struct vio_error_entry {
  181. u16 rc;
  182. int errno;
  183. const char *msg;
  184. };
  185. extern const struct vio_error_entry *vio_lookup_rc(
  186. const struct vio_error_entry *local_table, u16 rc);
  187. enum viosubtypes {
  188. viomajorsubtype_monitor = 0x0100,
  189. viomajorsubtype_blockio = 0x0200,
  190. viomajorsubtype_chario = 0x0300,
  191. viomajorsubtype_config = 0x0400,
  192. viomajorsubtype_cdio = 0x0500,
  193. viomajorsubtype_tape = 0x0600,
  194. viomajorsubtype_scsi = 0x0700
  195. };
  196. enum vioconfigsubtype {
  197. vioconfigget = 0x0001,
  198. };
  199. enum viorc {
  200. viorc_good = 0x0000,
  201. viorc_noConnection = 0x0001,
  202. viorc_noReceiver = 0x0002,
  203. viorc_noBufferAvailable = 0x0003,
  204. viorc_invalidMessageType = 0x0004,
  205. viorc_invalidRange = 0x0201,
  206. viorc_invalidToken = 0x0202,
  207. viorc_DMAError = 0x0203,
  208. viorc_useError = 0x0204,
  209. viorc_releaseError = 0x0205,
  210. viorc_invalidDisk = 0x0206,
  211. viorc_openRejected = 0x0301
  212. };
  213. /*
  214. * The structure of the events that flow between us and OS/400 for chario
  215. * events. You can't mess with this unless the OS/400 side changes too.
  216. */
  217. struct viocharlpevent {
  218. struct HvLpEvent event;
  219. u32 reserved;
  220. u16 version;
  221. u16 subtype_result_code;
  222. u8 virtual_device;
  223. u8 len;
  224. u8 data[VIOCHAR_MAX_DATA];
  225. };
  226. #define VIOCHAR_WINDOW 10
  227. enum viocharsubtype {
  228. viocharopen = 0x0001,
  229. viocharclose = 0x0002,
  230. viochardata = 0x0003,
  231. viocharack = 0x0004,
  232. viocharconfig = 0x0005
  233. };
  234. enum viochar_rc {
  235. viochar_rc_ebusy = 1
  236. };
  237. #endif /* _ASM_POWERPC_ISERIES_VIO_H */