blob: 4d39ce6c687a50ff5c0c1cc4b38e9cdb2c5069ac [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* -*- linux-c -*-
2 * drivers/char/vio.h
3 *
4 * iSeries Virtual I/O Message Path header
5 *
6 * Authors: Dave Boutcher <boutcher@us.ibm.com>
7 * Ryan Arnold <ryanarn@us.ibm.com>
8 * Colin Devilbiss <devilbis@us.ibm.com>
9 *
10 * (C) Copyright 2000 IBM Corporation
Stephen Rothwellfcee3892005-06-21 17:15:34 -070011 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070012 * This header file is used by the iSeries virtual I/O device
13 * drivers. It defines the interfaces to the common functions
14 * (implemented in drivers/char/viopath.h) as well as defining
Stephen Rothwellfcee3892005-06-21 17:15:34 -070015 * common functions and structures. Currently (at the time I
Linus Torvalds1da177e2005-04-16 15:20:36 -070016 * wrote this comment) the iSeries virtual I/O device drivers
Stephen Rothwellfcee3892005-06-21 17:15:34 -070017 * that use this are
18 * drivers/block/viodasd.c
Linus Torvalds1da177e2005-04-16 15:20:36 -070019 * drivers/char/viocons.c
20 * drivers/char/viotape.c
21 * drivers/cdrom/viocd.c
22 *
23 * The iSeries virtual ethernet support (veth.c) uses a whole
24 * different set of functions.
Stephen Rothwellfcee3892005-06-21 17:15:34 -070025 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 * This program is free software; you can redistribute it and/or
27 * modify it under the terms of the GNU General Public License as
28 * published by the Free Software Foundation; either version 2 of the
29 * License, or (at your option) anyu later version.
30 *
31 * This program is distributed in the hope that it will be useful, but
Stephen Rothwellfcee3892005-06-21 17:15:34 -070032 * WITHOUT ANY WARRANTY; without even the implied warranty of
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Stephen Rothwellfcee3892005-06-21 17:15:34 -070034 * General Public License for more details.
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 *
Stephen Rothwellfcee3892005-06-21 17:15:34 -070036 * You should have received a copy of the GNU General Public License
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 * along with this program; if not, write to the Free Software Foundation,
38 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
39 *
40 */
41#ifndef _ISERIES_VIO_H
42#define _ISERIES_VIO_H
43
44#include <asm/iSeries/HvTypes.h>
Kelly Dalye45423e2005-11-02 12:08:31 +110045#include <asm/iseries/hv_lp_event.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
Stephen Rothwellfcee3892005-06-21 17:15:34 -070047/*
48 * iSeries virtual I/O events use the subtype field in
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 * HvLpEvent to figure out what kind of vio event is coming
50 * in. We use a table to route these, and this defines
51 * the maximum number of distinct subtypes
52 */
53#define VIO_MAX_SUBTYPES 8
54
Stephen Rothwellfcee3892005-06-21 17:15:34 -070055/*
56 * Each subtype can register a handler to process their events.
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 * The handler must have this interface.
58 */
59typedef void (vio_event_handler_t) (struct HvLpEvent * event);
60
Stephen Rothwell6b7feec2005-06-21 17:15:35 -070061extern int viopath_open(HvLpIndex remoteLp, int subtype, int numReq);
62extern int viopath_close(HvLpIndex remoteLp, int subtype, int numReq);
63extern int vio_setHandler(int subtype, vio_event_handler_t * beh);
64extern int vio_clearHandler(int subtype);
65extern int viopath_isactive(HvLpIndex lp);
66extern HvLpInstanceId viopath_sourceinst(HvLpIndex lp);
67extern HvLpInstanceId viopath_targetinst(HvLpIndex lp);
68extern void vio_set_hostlp(void);
69extern void *vio_get_event_buffer(int subtype);
70extern void vio_free_event_buffer(int subtype, void *buffer);
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
72extern HvLpIndex viopath_hostLp;
73extern HvLpIndex viopath_ourLp;
74
Stephen Rothwellfcee3892005-06-21 17:15:34 -070075#define VIOCHAR_MAX_DATA 200
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
Stephen Rothwellfcee3892005-06-21 17:15:34 -070077#define VIOMAJOR_SUBTYPE_MASK 0xff00
78#define VIOMINOR_SUBTYPE_MASK 0x00ff
79#define VIOMAJOR_SUBTYPE_SHIFT 8
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
Stephen Rothwellfcee3892005-06-21 17:15:34 -070081#define VIOVERSION 0x0101
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
83/*
84 * This is the general structure for VIO errors; each module should have
85 * a table of them, and each table should be terminated by an entry of
86 * { 0, 0, NULL }. Then, to find a specific error message, a module
87 * should pass its local table and the return code.
88 */
89struct vio_error_entry {
90 u16 rc;
91 int errno;
92 const char *msg;
93};
Stephen Rothwellfcee3892005-06-21 17:15:34 -070094extern const struct vio_error_entry *vio_lookup_rc(
95 const struct vio_error_entry *local_table, u16 rc);
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
97enum viosubtypes {
98 viomajorsubtype_monitor = 0x0100,
99 viomajorsubtype_blockio = 0x0200,
100 viomajorsubtype_chario = 0x0300,
101 viomajorsubtype_config = 0x0400,
102 viomajorsubtype_cdio = 0x0500,
103 viomajorsubtype_tape = 0x0600,
104 viomajorsubtype_scsi = 0x0700
105};
106
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107enum vioconfigsubtype {
108 vioconfigget = 0x0001,
109};
110
111enum viorc {
112 viorc_good = 0x0000,
113 viorc_noConnection = 0x0001,
114 viorc_noReceiver = 0x0002,
115 viorc_noBufferAvailable = 0x0003,
116 viorc_invalidMessageType = 0x0004,
117 viorc_invalidRange = 0x0201,
118 viorc_invalidToken = 0x0202,
119 viorc_DMAError = 0x0203,
120 viorc_useError = 0x0204,
121 viorc_releaseError = 0x0205,
122 viorc_invalidDisk = 0x0206,
123 viorc_openRejected = 0x0301
124};
125
126struct device;
127
128extern struct device *iSeries_vio_dev;
129
130#endif /* _ISERIES_VIO_H */