blob: e5a405b8d4613dda99ac336b8a790bb44afce3ac [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* -*- linux-c -*-
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 *
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 Rothwellfcee3892005-06-21 17:15:34 -070010 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070011 * 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 Rothwellfcee3892005-06-21 17:15:34 -070014 * common functions and structures. Currently (at the time I
Linus Torvalds1da177e2005-04-16 15:20:36 -070015 * wrote this comment) the iSeries virtual I/O device drivers
Stephen Rothwellfcee3892005-06-21 17:15:34 -070016 * that use this are
17 * drivers/block/viodasd.c
Linus Torvalds1da177e2005-04-16 15:20:36 -070018 * 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 Rothwellfcee3892005-06-21 17:15:34 -070024 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 * 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 Rothwellfcee3892005-06-21 17:15:34 -070031 * WITHOUT ANY WARRANTY; without even the implied warranty of
Linus Torvalds1da177e2005-04-16 15:20:36 -070032 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Stephen Rothwellfcee3892005-06-21 17:15:34 -070033 * General Public License for more details.
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 *
Stephen Rothwellfcee3892005-06-21 17:15:34 -070035 * You should have received a copy of the GNU General Public License
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 * 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 Dalyecb3ca272005-11-02 15:53:01 +110040#ifndef _ASM_POWERPC_ISERIES_VIO_H
41#define _ASM_POWERPC_ISERIES_VIO_H
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
Kelly Daly1ec65d72005-11-02 13:46:07 +110043#include <asm/iseries/hv_types.h>
Kelly Dalye45423e2005-11-02 12:08:31 +110044#include <asm/iseries/hv_lp_event.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070045
Stephen Rothwellfcee3892005-06-21 17:15:34 -070046/*
47 * iSeries virtual I/O events use the subtype field in
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 * 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 Rothwellb833b482007-10-11 14:57:26 +100054struct 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
68enum 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 Rothwellfcee3892005-06-21 17:15:34 -070078/*
79 * Each subtype can register a handler to process their events.
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 * The handler must have this interface.
81 */
82typedef void (vio_event_handler_t) (struct HvLpEvent * event);
83
Stephen Rothwell6b7feec2005-06-21 17:15:35 -070084extern int viopath_open(HvLpIndex remoteLp, int subtype, int numReq);
85extern int viopath_close(HvLpIndex remoteLp, int subtype, int numReq);
86extern int vio_setHandler(int subtype, vio_event_handler_t * beh);
87extern int vio_clearHandler(int subtype);
88extern int viopath_isactive(HvLpIndex lp);
89extern HvLpInstanceId viopath_sourceinst(HvLpIndex lp);
90extern HvLpInstanceId viopath_targetinst(HvLpIndex lp);
91extern void vio_set_hostlp(void);
92extern void *vio_get_event_buffer(int subtype);
93extern void vio_free_event_buffer(int subtype, void *buffer);
Linus Torvalds1da177e2005-04-16 15:20:36 -070094
95extern HvLpIndex viopath_hostLp;
96extern HvLpIndex viopath_ourLp;
97
Stephen Rothwellfcee3892005-06-21 17:15:34 -070098#define VIOCHAR_MAX_DATA 200
Linus Torvalds1da177e2005-04-16 15:20:36 -070099
Stephen Rothwellfcee3892005-06-21 17:15:34 -0700100#define VIOMAJOR_SUBTYPE_MASK 0xff00
101#define VIOMINOR_SUBTYPE_MASK 0x00ff
102#define VIOMAJOR_SUBTYPE_SHIFT 8
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103
Stephen Rothwellfcee3892005-06-21 17:15:34 -0700104#define VIOVERSION 0x0101
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105
106/*
107 * This is the general structure for VIO errors; each module should have
108 * a table of them, and each table should be terminated by an entry of
109 * { 0, 0, NULL }. Then, to find a specific error message, a module
110 * should pass its local table and the return code.
111 */
112struct vio_error_entry {
113 u16 rc;
114 int errno;
115 const char *msg;
116};
Stephen Rothwellfcee3892005-06-21 17:15:34 -0700117extern const struct vio_error_entry *vio_lookup_rc(
118 const struct vio_error_entry *local_table, u16 rc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119
120enum viosubtypes {
121 viomajorsubtype_monitor = 0x0100,
122 viomajorsubtype_blockio = 0x0200,
123 viomajorsubtype_chario = 0x0300,
124 viomajorsubtype_config = 0x0400,
125 viomajorsubtype_cdio = 0x0500,
126 viomajorsubtype_tape = 0x0600,
127 viomajorsubtype_scsi = 0x0700
128};
129
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130enum vioconfigsubtype {
131 vioconfigget = 0x0001,
132};
133
134enum viorc {
135 viorc_good = 0x0000,
136 viorc_noConnection = 0x0001,
137 viorc_noReceiver = 0x0002,
138 viorc_noBufferAvailable = 0x0003,
139 viorc_invalidMessageType = 0x0004,
140 viorc_invalidRange = 0x0201,
141 viorc_invalidToken = 0x0202,
142 viorc_DMAError = 0x0203,
143 viorc_useError = 0x0204,
144 viorc_releaseError = 0x0205,
145 viorc_invalidDisk = 0x0206,
146 viorc_openRejected = 0x0301
147};
148
Stephen Rothwell8bff05b2006-07-13 18:51:22 +1000149/*
150 * The structure of the events that flow between us and OS/400 for chario
151 * events. You can't mess with this unless the OS/400 side changes too.
152 */
153struct viocharlpevent {
154 struct HvLpEvent event;
155 u32 reserved;
156 u16 version;
157 u16 subtype_result_code;
158 u8 virtual_device;
159 u8 len;
160 u8 data[VIOCHAR_MAX_DATA];
161};
162
163#define VIOCHAR_WINDOW 10
164
165enum viocharsubtype {
166 viocharopen = 0x0001,
167 viocharclose = 0x0002,
168 viochardata = 0x0003,
169 viocharack = 0x0004,
170 viocharconfig = 0x0005
171};
172
173enum viochar_rc {
174 viochar_rc_ebusy = 1
175};
176
Kelly Dalyecb3ca272005-11-02 15:53:01 +1100177#endif /* _ASM_POWERPC_ISERIES_VIO_H */