]>
Commit | Line | Data |
---|---|---|
12e364b9 KC |
1 | /* uisqueue.h |
2 | * | |
f6d0c1e6 | 3 | * Copyright (C) 2010 - 2013 UNISYS CORPORATION |
12e364b9 KC |
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 | /* | |
19 | * Unisys IO Virtualization header NOTE: This file contains only Linux | |
20 | * specific structs. All OS-independent structs are in iochannel.h.xx | |
21 | */ | |
22 | ||
23 | #ifndef __UISQUEUE_H__ | |
24 | #define __UISQUEUE_H__ | |
25 | ||
26 | #include "linux/version.h" | |
27 | #include "iochannel.h" | |
28 | #include "uniklog.h" | |
29 | #include <linux/atomic.h> | |
30 | #include <linux/semaphore.h> | |
90addb02 | 31 | #include <linux/uuid.h> |
12e364b9 KC |
32 | |
33 | #include "controlvmchannel.h" | |
34 | #include "controlvmcompletionstatus.h" | |
35 | ||
36 | struct uisqueue_info { | |
9fd1b95a | 37 | struct channel_header __iomem *chan; |
12e364b9 KC |
38 | /* channel containing queues in which scsi commands & |
39 | * responses are queued | |
40 | */ | |
5fc0229a BR |
41 | u64 packets_sent; |
42 | u64 packets_received; | |
43 | u64 interrupts_sent; | |
44 | u64 interrupts_received; | |
45 | u64 max_not_empty_cnt; | |
46 | u64 total_wakeup_cnt; | |
47 | u64 non_empty_wakeup_cnt; | |
12e364b9 KC |
48 | |
49 | struct { | |
e0fed862 BR |
50 | struct signal_queue_header reserved1; /* */ |
51 | struct signal_queue_header reserved2; /* */ | |
12e364b9 KC |
52 | } safe_uis_queue; |
53 | unsigned int (*send_int_if_needed)(struct uisqueue_info *info, | |
54 | unsigned int whichcqueue, | |
82dd8152 BR |
55 | unsigned char issue_irq_if_empty, |
56 | u64 irq_handle, | |
12e364b9 KC |
57 | unsigned char io_termination); |
58 | }; | |
59 | ||
60 | /* uisqueue_put_cmdrsp_with_lock_client queues a commmand or response | |
61 | * to the specified queue, at the tail if the queue is full but | |
62 | * oktowait == 0, then it return 0 indicating failure. otherwise it | |
63 | * wait for the queue to become non-full. If command is queued, return | |
64 | * 1 for success. | |
65 | */ | |
66 | #define DONT_ISSUE_INTERRUPT 0 | |
67 | #define ISSUE_INTERRUPT 1 | |
68 | ||
69 | #define DONT_WAIT 0 | |
70 | #define OK_TO_WAIT 1 | |
71 | #define UISLIB_LOCK_PREFIX \ | |
72 | ".section .smp_locks,\"a\"\n" \ | |
73 | _ASM_ALIGN "\n" \ | |
74 | _ASM_PTR "661f\n" /* address */ \ | |
75 | ".previous\n" \ | |
76 | "661:\n\tlock; " | |
77 | ||
17f5e491 BR |
78 | unsigned long long uisqueue_interlocked_or(unsigned long long __iomem *tgt, |
79 | unsigned long long set); | |
80 | unsigned long long uisqueue_interlocked_and(unsigned long long __iomem *tgt, | |
81 | unsigned long long set); | |
12e364b9 | 82 | |
12e364b9 KC |
83 | int uisqueue_put_cmdrsp_with_lock_client(struct uisqueue_info *queueinfo, |
84 | struct uiscmdrsp *cmdrsp, | |
85 | unsigned int queue, | |
86 | void *insertlock, | |
21f8c6b8 BR |
87 | unsigned char issue_irq_if_empty, |
88 | u64 irq_handle, | |
12e364b9 | 89 | char oktowait, |
21f8c6b8 | 90 | u8 *channel_id); |
12e364b9 KC |
91 | |
92 | /* uisqueue_get_cmdrsp gets the cmdrsp entry at the head of the queue | |
93 | * and copies it to the area pointed by cmdrsp param. | |
94 | * returns 0 if queue is empty, 1 otherwise | |
95 | */ | |
96 | int | |
97 | ||
98 | uisqueue_get_cmdrsp(struct uisqueue_info *queueinfo, void *cmdrsp, | |
99 | unsigned int queue); | |
100 | ||
101 | #define MAX_NAME_SIZE_UISQUEUE 64 | |
102 | ||
103 | struct extport_info { | |
c242233e | 104 | u8 valid:1; |
12e364b9 KC |
105 | /* if 1, indicates this extport slot is occupied |
106 | * if 0, indicates that extport slot is unoccupied */ | |
107 | ||
b3c55b13 | 108 | u32 num_devs_using; |
12e364b9 KC |
109 | /* When extport is added, this is set to 0. For exports |
110 | * located in NETWORK switches: | |
111 | * Each time a VNIC, i.e., intport, is added to the switch this | |
112 | * is used to assign a pref_pnic for the VNIC and when assigned | |
113 | * to a VNIC this counter is incremented. When a VNIC is | |
114 | * deleted, the extport corresponding to the VNIC's pref_pnic | |
115 | * is located and its num_devs_using is decremented. For VNICs, | |
116 | * num_devs_using is basically used to load-balance transmit | |
117 | * traffic from VNICs. | |
118 | */ | |
119 | ||
120 | struct switch_info *swtch; | |
c12ad837 | 121 | struct pci_id pci_id; |
12e364b9 KC |
122 | char name[MAX_NAME_SIZE_UISQUEUE]; |
123 | union { | |
124 | struct vhba_wwnn wwnn; | |
125 | unsigned char macaddr[MAX_MACADDR_LEN]; | |
126 | }; | |
127 | }; | |
128 | ||
129 | struct device_info { | |
8504ff6c | 130 | void __iomem *chanptr; |
f796e84c BR |
131 | u64 channel_addr; |
132 | u64 channel_bytes; | |
133 | uuid_le channel_uuid; | |
134 | uuid_le instance_uuid; | |
4eddbf13 | 135 | struct irq_info intr; |
12e364b9 KC |
136 | struct switch_info *swtch; |
137 | char devid[30]; /* "vbus<busno>:dev<devno>" */ | |
b06bdf7d | 138 | u16 polling; |
12e364b9 | 139 | struct semaphore interrupt_callback_lock; |
f796e84c BR |
140 | u32 bus_no; |
141 | u32 dev_no; | |
12e364b9 KC |
142 | int (*interrupt)(void *); |
143 | void *interrupt_context; | |
144 | void *private_data; | |
145 | struct list_head list_polling_device_channels; | |
146 | unsigned long long moved_to_tail_cnt; | |
147 | unsigned long long first_busy_cnt; | |
148 | unsigned long long last_on_list_cnt; | |
149 | }; | |
150 | ||
0f431ff7 | 151 | enum switch_type { |
12e364b9 KC |
152 | RECOVERY_LAN = 1, |
153 | IB_LAN = 2 | |
0f431ff7 | 154 | }; |
12e364b9 KC |
155 | |
156 | struct bus_info { | |
43ecb9fe | 157 | u32 bus_no, device_count; |
12e364b9 | 158 | struct device_info **device; |
43ecb9fe BR |
159 | u64 guest_handle, recv_bus_irq_handle; |
160 | uuid_le bus_inst_uuid; | |
51121ffc | 161 | struct ultra_vbus_channel_protocol __iomem *bus_channel; |
43ecb9fe | 162 | int bus_channel_bytes; |
12e364b9 KC |
163 | struct proc_dir_entry *proc_dir; /* proc/uislib/vbus/<x> */ |
164 | struct proc_dir_entry *proc_info; /* proc/uislib/vbus/<x>/info */ | |
165 | char name[25]; | |
43ecb9fe | 166 | char partition_name[99]; |
12e364b9 | 167 | struct bus_info *next; |
43ecb9fe | 168 | u8 local_vnic; /* 1 if local vnic created internally |
12e364b9 KC |
169 | * by IOVM; 0 otherwise... */ |
170 | }; | |
171 | ||
12e364b9 KC |
172 | struct sn_list_entry { |
173 | struct uisscsi_dest pdest; /* scsi bus, target, lun for | |
174 | * phys disk */ | |
c242233e | 175 | u8 sernum[MAX_SERIAL_NUM]; /* serial num of physical |
12e364b9 KC |
176 | * disk.. The length is always |
177 | * MAX_SERIAL_NUM, padded with | |
178 | * spaces */ | |
179 | struct sn_list_entry *next; | |
180 | }; | |
181 | ||
12e364b9 KC |
182 | /* |
183 | * IO messages sent to UisnicControlChanFunc & UissdControlChanFunc by | |
184 | * code that processes the ControlVm channel messages. | |
185 | */ | |
186 | ||
0f431ff7 | 187 | enum iopart_msg_type { |
12e364b9 KC |
188 | IOPART_ADD_VNIC, |
189 | IOPART_DEL_VNIC, | |
190 | IOPART_DEL_ALL_VNICS, | |
191 | IOPART_ADD_VHBA, | |
192 | IOPART_ADD_VDISK, | |
193 | IOPART_DEL_VHBA, | |
194 | IOPART_DEL_VDISK, | |
195 | IOPART_DEL_ALL_VDISKS_FOR_VHBA, | |
196 | IOPART_DEL_ALL_VHBAS, | |
197 | IOPART_ATTACH_PHBA, | |
198 | IOPART_DETACH_PHBA, /* 10 */ | |
199 | IOPART_ATTACH_PNIC, | |
200 | IOPART_DETACH_PNIC, | |
201 | IOPART_DETACH_VHBA, | |
202 | IOPART_DETACH_VNIC, | |
203 | IOPART_PAUSE_VDISK, | |
204 | IOPART_RESUME_VDISK, | |
205 | IOPART_ADD_DEVICE, /* add generic device */ | |
206 | IOPART_DEL_DEVICE, /* del generic device */ | |
0f431ff7 | 207 | }; |
12e364b9 KC |
208 | |
209 | struct add_virt_iopart { | |
210 | void *chanptr; /* pointer to data channel */ | |
44589920 | 211 | u64 guest_handle; /* used to convert guest physical |
12e364b9 KC |
212 | * address to real physical address |
213 | * for DMA, for ex. */ | |
44589920 | 214 | u64 recv_bus_irq_handle; /* used to register to receive |
12e364b9 | 215 | * bus level interrupts. */ |
4eddbf13 | 216 | struct irq_info intr; /* contains recv & send |
12e364b9 KC |
217 | * interrupt info */ |
218 | /* recvInterruptHandle is used to register to receive | |
219 | * interrupts on the data channel. Used by GuestLinux/Windows | |
220 | * IO drivers to connect to interrupt. sendInterruptHandle is | |
221 | * used by IOPart drivers as parameter to | |
222 | * Issue_VMCALL_IO_QUEUE_TRANSITION to interrupt thread in | |
223 | * guest linux/windows IO drivers when data channel queue for | |
224 | * vhba/vnic goes from EMPTY to NON-EMPTY. */ | |
225 | struct switch_info *swtch; /* pointer to the virtual | |
226 | * switch to which the vnic is | |
227 | * connected */ | |
228 | ||
44589920 | 229 | u8 use_g2g_copy; /* Used to determine if a virtual HBA |
12e364b9 | 230 | * needs to use G2G copy. */ |
44589920 | 231 | u8 filler[7]; |
12e364b9 | 232 | |
44589920 BR |
233 | u32 bus_no; |
234 | u32 dev_no; | |
12e364b9 KC |
235 | char *params; |
236 | ulong params_bytes; | |
237 | ||
238 | }; | |
239 | ||
240 | struct add_vdisk_iopart { | |
241 | void *chanptr; /* pointer to data channel */ | |
242 | int implicit; | |
243 | struct uisscsi_dest vdest; /* scsi bus, target, lun for virt disk */ | |
244 | struct uisscsi_dest pdest; /* scsi bus, target, lun for phys disk */ | |
c242233e | 245 | u8 sernum[MAX_SERIAL_NUM]; /* serial num of physical disk */ |
b3c55b13 | 246 | u32 serlen; /* length of serial num */ |
12e364b9 KC |
247 | }; |
248 | ||
249 | struct del_vdisk_iopart { | |
250 | void *chanptr; /* pointer to data channel */ | |
251 | struct uisscsi_dest vdest; /* scsi bus, target, lun for virt disk */ | |
12e364b9 KC |
252 | }; |
253 | ||
254 | struct del_virt_iopart { | |
255 | void *chanptr; /* pointer to data channel */ | |
12e364b9 KC |
256 | }; |
257 | ||
258 | struct det_virt_iopart { /* detach internal port */ | |
259 | void *chanptr; /* pointer to data channel */ | |
260 | struct switch_info *swtch; | |
261 | }; | |
262 | ||
263 | struct paures_vdisk_iopart { | |
264 | void *chanptr; /* pointer to data channel */ | |
265 | struct uisscsi_dest vdest; /* scsi bus, target, lun for virt disk */ | |
266 | }; | |
267 | ||
268 | struct add_switch_iopart { /* add switch */ | |
269 | struct switch_info *swtch; | |
270 | char *params; | |
271 | ulong params_bytes; | |
272 | }; | |
273 | ||
274 | struct del_switch_iopart { /* destroy switch */ | |
275 | struct switch_info *swtch; | |
276 | }; | |
277 | ||
278 | struct io_msgs { | |
0f431ff7 | 279 | enum iopart_msg_type msgtype; |
12e364b9 KC |
280 | |
281 | /* additional params needed by some messages */ | |
282 | union { | |
283 | struct add_virt_iopart add_vhba; | |
284 | struct add_virt_iopart add_vnic; | |
285 | struct add_vdisk_iopart add_vdisk; | |
286 | struct del_virt_iopart del_vhba; | |
287 | struct del_virt_iopart del_vnic; | |
288 | struct det_virt_iopart det_vhba; | |
289 | struct det_virt_iopart det_vnic; | |
290 | struct del_vdisk_iopart del_vdisk; | |
291 | struct del_virt_iopart del_all_vdisks_for_vhba; | |
292 | struct add_virt_iopart add_device; | |
293 | struct del_virt_iopart del_device; | |
294 | struct det_virt_iopart det_intport; | |
295 | struct add_switch_iopart add_switch; | |
296 | struct del_switch_iopart del_switch; | |
0014c3cc | 297 | struct extport_info *ext_port; /* for attach or detach |
12e364b9 KC |
298 | * pnic/generic delete all |
299 | * vhbas/allvnics need no | |
300 | * parameters */ | |
301 | struct paures_vdisk_iopart paures_vdisk; | |
302 | }; | |
303 | }; | |
304 | ||
305 | /* | |
306 | * Guest messages sent to VirtControlChanFunc by code that processes | |
307 | * the ControlVm channel messages. | |
308 | */ | |
309 | ||
bae4e2ad | 310 | enum guestpart_msg_type { |
12e364b9 KC |
311 | GUEST_ADD_VBUS, |
312 | GUEST_ADD_VHBA, | |
313 | GUEST_ADD_VNIC, | |
314 | GUEST_DEL_VBUS, | |
315 | GUEST_DEL_VHBA, | |
316 | GUEST_DEL_VNIC, | |
317 | GUEST_DEL_ALL_VHBAS, | |
318 | GUEST_DEL_ALL_VNICS, | |
319 | GUEST_DEL_ALL_VBUSES, /* deletes all vhbas & vnics on all | |
320 | * buses and deletes all buses */ | |
321 | GUEST_PAUSE_VHBA, | |
322 | GUEST_PAUSE_VNIC, | |
323 | GUEST_RESUME_VHBA, | |
324 | GUEST_RESUME_VNIC | |
bae4e2ad | 325 | }; |
12e364b9 KC |
326 | |
327 | struct add_vbus_guestpart { | |
8504ff6c KC |
328 | void __iomem *chanptr; /* pointer to data channel for bus - |
329 | * NOT YET USED */ | |
34e6230b BR |
330 | u32 bus_no; /* bus number to be created/deleted */ |
331 | u32 dev_count; /* max num of devices on bus */ | |
332 | uuid_le bus_uuid; /* indicates type of bus */ | |
333 | uuid_le instance_uuid; /* instance guid for device */ | |
12e364b9 KC |
334 | }; |
335 | ||
336 | struct del_vbus_guestpart { | |
a990356d | 337 | u32 bus_no; /* bus number to be deleted */ |
12e364b9 KC |
338 | /* once we start using the bus's channel, add can dump busNo |
339 | * into the channel header and then delete will need only one | |
340 | * parameter, chanptr. */ | |
341 | }; | |
342 | ||
343 | struct add_virt_guestpart { | |
8504ff6c | 344 | void __iomem *chanptr; /* pointer to data channel */ |
8bd352ef BR |
345 | u32 bus_no; /* bus number for the operation */ |
346 | u32 device_no; /* number of device on the bus */ | |
347 | uuid_le instance_uuid; /* instance guid for device */ | |
4eddbf13 | 348 | struct irq_info intr; /* recv/send interrupt info */ |
12e364b9 KC |
349 | /* recvInterruptHandle contains info needed in order to |
350 | * register to receive interrupts on the data channel. | |
351 | * sendInterruptHandle contains handle which is provided to | |
352 | * monitor VMCALL that will cause an interrupt to be generated | |
353 | * for the other end. | |
354 | */ | |
355 | }; | |
356 | ||
357 | struct pause_virt_guestpart { | |
8504ff6c | 358 | void __iomem *chanptr; /* pointer to data channel */ |
12e364b9 KC |
359 | }; |
360 | ||
361 | struct resume_virt_guestpart { | |
8504ff6c | 362 | void __iomem *chanptr; /* pointer to data channel */ |
12e364b9 KC |
363 | }; |
364 | ||
365 | struct del_virt_guestpart { | |
8504ff6c | 366 | void __iomem *chanptr; /* pointer to data channel */ |
12e364b9 KC |
367 | }; |
368 | ||
369 | struct init_chipset_guestpart { | |
62dd4cf0 BR |
370 | u32 bus_count; /* indicates the max number of busses */ |
371 | u32 switch_count; /* indicates the max number of switches */ | |
12e364b9 KC |
372 | }; |
373 | ||
374 | struct guest_msgs { | |
bae4e2ad | 375 | enum guestpart_msg_type msgtype; |
12e364b9 KC |
376 | |
377 | /* additional params needed by messages */ | |
378 | union { | |
379 | struct add_vbus_guestpart add_vbus; | |
380 | struct add_virt_guestpart add_vhba; | |
381 | struct add_virt_guestpart add_vnic; | |
382 | struct pause_virt_guestpart pause_vhba; | |
383 | struct pause_virt_guestpart pause_vnic; | |
384 | struct resume_virt_guestpart resume_vhba; | |
385 | struct resume_virt_guestpart resume_vnic; | |
386 | struct del_vbus_guestpart del_vbus; | |
387 | struct del_virt_guestpart del_vhba; | |
388 | struct del_virt_guestpart del_vnic; | |
389 | struct del_vbus_guestpart del_all_vhbas; | |
390 | struct del_vbus_guestpart del_all_vnics; | |
391 | /* del_all_vbuses needs no parameters */ | |
392 | }; | |
393 | struct init_chipset_guestpart init_chipset; | |
394 | ||
395 | }; | |
396 | ||
12e364b9 | 397 | #endif /* __UISQUEUE_H__ */ |