1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28#ifndef _AP_BUS_H_
29#define _AP_BUS_H_
30
31#include <linux/device.h>
32#include <linux/mod_devicetable.h>
33#include <linux/types.h>
34
35#define AP_DEVICES 64
36#define AP_DOMAINS 16
37#define AP_MAX_RESET 90
38#define AP_RESET_TIMEOUT (HZ/2)
39#define AP_CONFIG_TIME 30
40#define AP_POLL_TIME 1
41
42extern int ap_domain_index;
43
44
45
46
47
48typedef unsigned int ap_qid_t;
49
50#define AP_MKQID(_device,_queue) (((_device) & 63) << 8 | ((_queue) & 15))
51#define AP_QID_DEVICE(_qid) (((_qid) >> 8) & 63)
52#define AP_QID_QUEUE(_qid) ((_qid) & 15)
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68struct ap_queue_status {
69 unsigned int queue_empty : 1;
70 unsigned int replies_waiting : 1;
71 unsigned int queue_full : 1;
72 unsigned int pad1 : 4;
73 unsigned int int_enabled : 1;
74 unsigned int response_code : 8;
75 unsigned int pad2 : 16;
76} __packed;
77
78#define AP_QUEUE_STATUS_INVALID \
79 { 1, 1, 1, 0xF, 1, 0xFF, 0xFFFF }
80
81static inline
82int ap_queue_status_invalid_test(struct ap_queue_status *status)
83{
84 struct ap_queue_status invalid = AP_QUEUE_STATUS_INVALID;
85 return !(memcmp(status, &invalid, sizeof(struct ap_queue_status)));
86}
87
88#define MAX_AP_FACILITY 31
89
90static inline int test_ap_facility(unsigned int function, unsigned int nr)
91{
92 if (nr > MAX_AP_FACILITY)
93 return 0;
94 return function & (unsigned int)(0x80000000 >> nr);
95}
96
97#define AP_RESPONSE_NORMAL 0x00
98#define AP_RESPONSE_Q_NOT_AVAIL 0x01
99#define AP_RESPONSE_RESET_IN_PROGRESS 0x02
100#define AP_RESPONSE_DECONFIGURED 0x03
101#define AP_RESPONSE_CHECKSTOPPED 0x04
102#define AP_RESPONSE_BUSY 0x05
103#define AP_RESPONSE_INVALID_ADDRESS 0x06
104#define AP_RESPONSE_OTHERWISE_CHANGED 0x07
105#define AP_RESPONSE_Q_FULL 0x10
106#define AP_RESPONSE_NO_PENDING_REPLY 0x10
107#define AP_RESPONSE_INDEX_TOO_BIG 0x11
108#define AP_RESPONSE_NO_FIRST_PART 0x13
109#define AP_RESPONSE_MESSAGE_TOO_BIG 0x15
110#define AP_RESPONSE_REQ_FAC_NOT_INST 0x16
111
112
113
114
115#define AP_DEVICE_TYPE_PCICC 3
116#define AP_DEVICE_TYPE_PCICA 4
117#define AP_DEVICE_TYPE_PCIXCC 5
118#define AP_DEVICE_TYPE_CEX2A 6
119#define AP_DEVICE_TYPE_CEX2C 7
120#define AP_DEVICE_TYPE_CEX3A 8
121#define AP_DEVICE_TYPE_CEX3C 9
122
123
124
125
126#define AP_RESET_IGNORE 0
127#define AP_RESET_ARMED 1
128#define AP_RESET_DO 2
129
130struct ap_device;
131struct ap_message;
132
133struct ap_driver {
134 struct device_driver driver;
135 struct ap_device_id *ids;
136
137 int (*probe)(struct ap_device *);
138 void (*remove)(struct ap_device *);
139
140 void (*receive)(struct ap_device *, struct ap_message *,
141 struct ap_message *);
142 int request_timeout;
143};
144
145#define to_ap_drv(x) container_of((x), struct ap_driver, driver)
146
147int ap_driver_register(struct ap_driver *, struct module *, char *);
148void ap_driver_unregister(struct ap_driver *);
149
150struct ap_device {
151 struct device device;
152 struct ap_driver *drv;
153 spinlock_t lock;
154 struct list_head list;
155
156 ap_qid_t qid;
157 int queue_depth;
158 int device_type;
159 int unregistered;
160 struct timer_list timeout;
161 int reset;
162
163 int queue_count;
164
165 struct list_head pendingq;
166 int pendingq_count;
167 struct list_head requestq;
168 int requestq_count;
169 int total_request_count;
170
171 struct ap_message *reply;
172
173 void *private;
174};
175
176#define to_ap_dev(x) container_of((x), struct ap_device, device)
177
178struct ap_message {
179 struct list_head list;
180 unsigned long long psmid;
181 void *message;
182 size_t length;
183
184 void *private;
185 unsigned int special:1;
186};
187
188#define AP_DEVICE(dt) \
189 .dev_type=(dt), \
190 .match_flags=AP_DEVICE_ID_MATCH_DEVICE_TYPE,
191
192
193
194
195
196
197static inline void ap_init_message(struct ap_message *ap_msg)
198{
199 ap_msg->psmid = 0;
200 ap_msg->length = 0;
201 ap_msg->special = 0;
202}
203
204
205
206
207
208
209int ap_send(ap_qid_t, unsigned long long, void *, size_t);
210int ap_recv(ap_qid_t, unsigned long long *, void *, size_t);
211
212void ap_queue_message(struct ap_device *ap_dev, struct ap_message *ap_msg);
213void ap_cancel_message(struct ap_device *ap_dev, struct ap_message *ap_msg);
214void ap_flush_queue(struct ap_device *ap_dev);
215
216int ap_module_init(void);
217void ap_module_exit(void);
218
219int ap_4096_commands_available(ap_qid_t qid);
220
221#endif
222