3 * Copyright (C) 2010 - 2013 UNISYS CORPORATION
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.
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
19 * Unisys IO Virtualization header NOTE: This file contains only Linux
20 * specific structs. All OS-independent structs are in iochannel.h.xx
23 #ifndef __UISQUEUE_H__
24 #define __UISQUEUE_H__
26 #include "linux/version.h"
27 #include "iochannel.h"
28 #include <linux/atomic.h>
29 #include <linux/semaphore.h>
30 #include <linux/uuid.h>
32 #include "controlvmchannel.h"
33 #include "controlvmcompletionstatus.h"
35 struct uisqueue_info {
36 struct channel_header __iomem *chan;
37 /* channel containing queues in which scsi commands &
38 * responses are queued
43 u64 interrupts_received;
44 u64 max_not_empty_cnt;
46 u64 non_empty_wakeup_cnt;
49 struct signal_queue_header reserved1; /* */
50 struct signal_queue_header reserved2; /* */
52 unsigned int (*send_int_if_needed)(struct uisqueue_info *info,
53 unsigned int whichcqueue,
54 unsigned char issue_irq_if_empty,
56 unsigned char io_termination);
59 /* uisqueue_put_cmdrsp_with_lock_client queues a commmand or response
60 * to the specified queue, at the tail if the queue is full but
61 * oktowait == 0, then it return 0 indicating failure. otherwise it
62 * wait for the queue to become non-full. If command is queued, return
65 #define DONT_ISSUE_INTERRUPT 0
66 #define ISSUE_INTERRUPT 1
70 #define UISLIB_LOCK_PREFIX \
71 ".section .smp_locks,\"a\"\n" \
73 _ASM_PTR "661f\n" /* address */ \
77 unsigned long long uisqueue_interlocked_or(unsigned long long __iomem *tgt,
78 unsigned long long set);
79 unsigned long long uisqueue_interlocked_and(unsigned long long __iomem *tgt,
80 unsigned long long set);
82 int uisqueue_put_cmdrsp_with_lock_client(struct uisqueue_info *queueinfo,
83 struct uiscmdrsp *cmdrsp,
86 unsigned char issue_irq_if_empty,
91 /* uisqueue_get_cmdrsp gets the cmdrsp entry at the head of the queue
92 * and copies it to the area pointed by cmdrsp param.
93 * returns 0 if queue is empty, 1 otherwise
97 uisqueue_get_cmdrsp(struct uisqueue_info *queueinfo, void *cmdrsp,
100 #define MAX_NAME_SIZE_UISQUEUE 64
102 struct extport_info {
104 /* if 1, indicates this extport slot is occupied
105 * if 0, indicates that extport slot is unoccupied */
108 /* When extport is added, this is set to 0. For exports
109 * located in NETWORK switches:
110 * Each time a VNIC, i.e., intport, is added to the switch this
111 * is used to assign a pref_pnic for the VNIC and when assigned
112 * to a VNIC this counter is incremented. When a VNIC is
113 * deleted, the extport corresponding to the VNIC's pref_pnic
114 * is located and its num_devs_using is decremented. For VNICs,
115 * num_devs_using is basically used to load-balance transmit
116 * traffic from VNICs.
119 struct switch_info *swtch;
120 struct pci_id pci_id;
121 char name[MAX_NAME_SIZE_UISQUEUE];
123 struct vhba_wwnn wwnn;
124 unsigned char macaddr[MAX_MACADDR_LEN];
129 void __iomem *chanptr;
132 uuid_le channel_uuid;
133 uuid_le instance_uuid;
134 struct irq_info intr;
135 struct switch_info *swtch;
136 char devid[30]; /* "vbus<busno>:dev<devno>" */
138 struct semaphore interrupt_callback_lock;
141 int (*interrupt)(void *);
142 void *interrupt_context;
144 struct list_head list_polling_device_channels;
145 unsigned long long moved_to_tail_cnt;
146 unsigned long long first_busy_cnt;
147 unsigned long long last_on_list_cnt;
156 u32 bus_no, device_count;
157 struct device_info **device;
158 u64 guest_handle, recv_bus_irq_handle;
159 uuid_le bus_inst_uuid;
160 struct ultra_vbus_channel_protocol __iomem *bus_channel;
161 int bus_channel_bytes;
162 struct proc_dir_entry *proc_dir; /* proc/uislib/vbus/<x> */
163 struct proc_dir_entry *proc_info; /* proc/uislib/vbus/<x>/info */
165 char partition_name[99];
166 struct bus_info *next;
167 u8 local_vnic; /* 1 if local vnic created internally
168 * by IOVM; 0 otherwise... */
171 struct sn_list_entry {
172 struct uisscsi_dest pdest; /* scsi bus, target, lun for
174 u8 sernum[MAX_SERIAL_NUM]; /* serial num of physical
175 * disk.. The length is always
176 * MAX_SERIAL_NUM, padded with
178 struct sn_list_entry *next;
182 * IO messages sent to UisnicControlChanFunc & UissdControlChanFunc by
183 * code that processes the ControlVm channel messages.
186 enum iopart_msg_type {
189 IOPART_DEL_ALL_VNICS,
194 IOPART_DEL_ALL_VDISKS_FOR_VHBA,
195 IOPART_DEL_ALL_VHBAS,
197 IOPART_DETACH_PHBA, /* 10 */
204 IOPART_ADD_DEVICE, /* add generic device */
205 IOPART_DEL_DEVICE, /* del generic device */
208 struct add_virt_iopart {
209 void *chanptr; /* pointer to data channel */
210 u64 guest_handle; /* used to convert guest physical
211 * address to real physical address
212 * for DMA, for ex. */
213 u64 recv_bus_irq_handle; /* used to register to receive
214 * bus level interrupts. */
215 struct irq_info intr; /* contains recv & send
217 /* recvInterruptHandle is used to register to receive
218 * interrupts on the data channel. Used by GuestLinux/Windows
219 * IO drivers to connect to interrupt. sendInterruptHandle is
220 * used by IOPart drivers as parameter to
221 * Issue_VMCALL_IO_QUEUE_TRANSITION to interrupt thread in
222 * guest linux/windows IO drivers when data channel queue for
223 * vhba/vnic goes from EMPTY to NON-EMPTY. */
224 struct switch_info *swtch; /* pointer to the virtual
225 * switch to which the vnic is
228 u8 use_g2g_copy; /* Used to determine if a virtual HBA
229 * needs to use G2G copy. */
239 struct add_vdisk_iopart {
240 void *chanptr; /* pointer to data channel */
242 struct uisscsi_dest vdest; /* scsi bus, target, lun for virt disk */
243 struct uisscsi_dest pdest; /* scsi bus, target, lun for phys disk */
244 u8 sernum[MAX_SERIAL_NUM]; /* serial num of physical disk */
245 u32 serlen; /* length of serial num */
248 struct del_vdisk_iopart {
249 void *chanptr; /* pointer to data channel */
250 struct uisscsi_dest vdest; /* scsi bus, target, lun for virt disk */
253 struct del_virt_iopart {
254 void *chanptr; /* pointer to data channel */
257 struct det_virt_iopart { /* detach internal port */
258 void *chanptr; /* pointer to data channel */
259 struct switch_info *swtch;
262 struct paures_vdisk_iopart {
263 void *chanptr; /* pointer to data channel */
264 struct uisscsi_dest vdest; /* scsi bus, target, lun for virt disk */
267 struct add_switch_iopart { /* add switch */
268 struct switch_info *swtch;
273 struct del_switch_iopart { /* destroy switch */
274 struct switch_info *swtch;
278 enum iopart_msg_type msgtype;
280 /* additional params needed by some messages */
282 struct add_virt_iopart add_vhba;
283 struct add_virt_iopart add_vnic;
284 struct add_vdisk_iopart add_vdisk;
285 struct del_virt_iopart del_vhba;
286 struct del_virt_iopart del_vnic;
287 struct det_virt_iopart det_vhba;
288 struct det_virt_iopart det_vnic;
289 struct del_vdisk_iopart del_vdisk;
290 struct del_virt_iopart del_all_vdisks_for_vhba;
291 struct add_virt_iopart add_device;
292 struct del_virt_iopart del_device;
293 struct det_virt_iopart det_intport;
294 struct add_switch_iopart add_switch;
295 struct del_switch_iopart del_switch;
296 struct extport_info *ext_port; /* for attach or detach
297 * pnic/generic delete all
298 * vhbas/allvnics need no
300 struct paures_vdisk_iopart paures_vdisk;
305 * Guest messages sent to VirtControlChanFunc by code that processes
306 * the ControlVm channel messages.
309 enum guestpart_msg_type {
318 GUEST_DEL_ALL_VBUSES, /* deletes all vhbas & vnics on all
319 * buses and deletes all buses */
326 struct add_vbus_guestpart {
327 void __iomem *chanptr; /* pointer to data channel for bus -
329 u32 bus_no; /* bus number to be created/deleted */
330 u32 dev_count; /* max num of devices on bus */
331 uuid_le bus_uuid; /* indicates type of bus */
332 uuid_le instance_uuid; /* instance guid for device */
335 struct del_vbus_guestpart {
336 u32 bus_no; /* bus number to be deleted */
337 /* once we start using the bus's channel, add can dump busNo
338 * into the channel header and then delete will need only one
339 * parameter, chanptr. */
342 struct add_virt_guestpart {
343 void __iomem *chanptr; /* pointer to data channel */
344 u32 bus_no; /* bus number for the operation */
345 u32 device_no; /* number of device on the bus */
346 uuid_le instance_uuid; /* instance guid for device */
347 struct irq_info intr; /* recv/send interrupt info */
348 /* recvInterruptHandle contains info needed in order to
349 * register to receive interrupts on the data channel.
350 * sendInterruptHandle contains handle which is provided to
351 * monitor VMCALL that will cause an interrupt to be generated
356 struct pause_virt_guestpart {
357 void __iomem *chanptr; /* pointer to data channel */
360 struct resume_virt_guestpart {
361 void __iomem *chanptr; /* pointer to data channel */
364 struct del_virt_guestpart {
365 void __iomem *chanptr; /* pointer to data channel */
368 struct init_chipset_guestpart {
369 u32 bus_count; /* indicates the max number of busses */
370 u32 switch_count; /* indicates the max number of switches */
374 enum guestpart_msg_type msgtype;
376 /* additional params needed by messages */
378 struct add_vbus_guestpart add_vbus;
379 struct add_virt_guestpart add_vhba;
380 struct add_virt_guestpart add_vnic;
381 struct pause_virt_guestpart pause_vhba;
382 struct pause_virt_guestpart pause_vnic;
383 struct resume_virt_guestpart resume_vhba;
384 struct resume_virt_guestpart resume_vnic;
385 struct del_vbus_guestpart del_vbus;
386 struct del_virt_guestpart del_vhba;
387 struct del_virt_guestpart del_vnic;
388 struct del_vbus_guestpart del_all_vhbas;
389 struct del_vbus_guestpart del_all_vnics;
390 /* del_all_vbuses needs no parameters */
392 struct init_chipset_guestpart init_chipset;
396 #endif /* __UISQUEUE_H__ */