af71809828dd1cb01e747629a2909fa2c2f62a62
[linux-2.6-block.git] / drivers / staging / unisys / visorbus / visorbus_private.h
1 /* visorchipset.h
2  *
3  * Copyright (C) 2010 - 2013 UNISYS CORPORATION
4  * All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or (at
9  * your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
14  * NON INFRINGEMENT.  See the GNU General Public License for more
15  * details.
16  */
17
18 #ifndef __VISORCHIPSET_H__
19 #define __VISORCHIPSET_H__
20
21 #include <linux/uuid.h>
22
23 #include "channel.h"
24 #include "controlvmchannel.h"
25 #include "vbusdeviceinfo.h"
26 #include "vbushelper.h"
27
28 struct visorchannel;
29
30 /** Attributes for a particular Supervisor device.
31  *  Any visorchipset client can query these attributes using
32  *  visorchipset_get_client_device_info() or
33  *  visorchipset_get_server_device_info().
34  */
35 struct visorchipset_device_info {
36         struct list_head entry;
37         u32 bus_no;
38         u32 dev_no;
39         uuid_le dev_inst_uuid;
40         struct visorchipset_state state;
41         struct visorchannel *visorchannel;
42         uuid_le channel_type_guid;
43         u32 reserved1;          /* control_vm_id */
44         u64 reserved2;
45         u32 switch_no;          /* when devState.attached==1 */
46         u32 internal_port_no;   /* when devState.attached==1 */
47         struct controlvm_message_header *pending_msg_hdr;/* CONTROLVM_MESSAGE */
48         /** For private use by the bus driver */
49         void *bus_driver_context;
50 };
51
52 /** Attributes for a particular Supervisor bus.
53  *  (For a service partition acting as the server for buses/devices, there
54  *  is a 1-to-1 relationship between busses and guest partitions.)
55  *  Any visorchipset client can query these attributes using
56  *  visorchipset_get_client_bus_info() or visorchipset_get_bus_info().
57  */
58 struct visorchipset_bus_info {
59         struct list_head entry;
60         u32 bus_no;
61         struct visorchipset_state state;
62         struct visorchannel *visorchannel;
63         uuid_le partition_uuid;
64         u64 partition_handle;
65         u8 *name;               /* UTF8 */
66         u8 *description;        /* UTF8 */
67         u64 reserved1;
68         u32 reserved2;
69         struct controlvm_message_header *pending_msg_hdr;/* CONTROLVM MsgHdr */
70         /** For private use by the bus driver */
71         void *bus_driver_context;
72 };
73
74 /*  These functions will be called from within visorchipset when certain
75  *  events happen.  (The implementation of these functions is outside of
76  *  visorchipset.)
77  */
78 struct visorchipset_busdev_notifiers {
79         void (*bus_create)(struct visorchipset_bus_info *bus_info);
80         void (*bus_destroy)(struct visorchipset_bus_info *bus_info);
81         void (*device_create)(struct visorchipset_device_info *bus_info);
82         void (*device_destroy)(struct visorchipset_device_info *bus_info);
83         void (*device_pause)(struct visorchipset_device_info *bus_info);
84         void (*device_resume)(struct visorchipset_device_info *bus_info);
85 };
86
87 /*  These functions live inside visorchipset, and will be called to indicate
88  *  responses to specific events (by code outside of visorchipset).
89  *  For now, the value for each response is simply either:
90  *       0 = it worked
91  *      -1 = it failed
92  */
93 struct visorchipset_busdev_responders {
94         void (*bus_create)(struct visorchipset_bus_info *p, int response);
95         void (*bus_destroy)(struct visorchipset_bus_info *p, int response);
96         void (*device_create)(struct visorchipset_device_info *p, int response);
97         void (*device_destroy)(struct visorchipset_device_info *p,
98                                int response);
99         void (*device_pause)(struct visorchipset_device_info *p, int response);
100         void (*device_resume)(struct visorchipset_device_info *p, int response);
101 };
102
103 /** Register functions (in the bus driver) to get called by visorchipset
104  *  whenever a bus or device appears for which this guest is to be the
105  *  client for.  visorchipset will fill in <responders>, to indicate
106  *  functions the bus driver should call to indicate message responses.
107  */
108 void
109 visorchipset_register_busdev(
110                         struct visorchipset_busdev_notifiers *notifiers,
111                         struct visorchipset_busdev_responders *responders,
112                         struct ultra_vbus_deviceinfo *driver_info);
113
114 bool visorchipset_get_bus_info(u32 bus_no,
115                                struct visorchipset_bus_info *bus_info);
116 bool visorchipset_get_device_info(u32 bus_no, u32 dev_no,
117                                   struct visorchipset_device_info *dev_info);
118 bool visorchipset_set_bus_context(struct visorchipset_bus_info *bus_info,
119                                   void *context);
120
121 /* visorbus init and exit functions */
122 int visorbus_init(void);
123 void visorbus_exit(void);
124 #endif