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"
29 #include <linux/atomic.h>
30 #include <linux/semaphore.h>
31 #include <linux/uuid.h>
33 #include "controlvmchannel.h"
34 #include "controlvmcompletionstatus.h"
36 struct uisqueue_info
{
37 CHANNEL_HEADER __iomem
*chan
;
38 /* channel containing queues in which scsi commands &
39 * responses are queued
44 u64 interrupts_received
;
45 u64 max_not_empty_cnt
;
47 u64 non_empty_wakeup_cnt
;
50 SIGNAL_QUEUE_HEADER reserved1
; /* */
51 SIGNAL_QUEUE_HEADER reserved2
; /* */
53 unsigned int (*send_int_if_needed
)(struct uisqueue_info
*info
,
54 unsigned int whichcqueue
,
55 unsigned char issue_irq_if_empty
,
57 unsigned char io_termination
);
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
66 #define DONT_ISSUE_INTERRUPT 0
67 #define ISSUE_INTERRUPT 1
71 #define UISLIB_LOCK_PREFIX \
72 ".section .smp_locks,\"a\"\n" \
74 _ASM_PTR "661f\n" /* address */ \
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
);
83 int uisqueue_put_cmdrsp_with_lock_client(struct uisqueue_info
*queueinfo
,
84 struct uiscmdrsp
*cmdrsp
,
87 unsigned char issue_irq_if_empty
,
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
98 uisqueue_get_cmdrsp(struct uisqueue_info
*queueinfo
, void *cmdrsp
,
101 #define MAX_NAME_SIZE_UISQUEUE 64
103 struct extport_info
{
105 /* if 1, indicates this extport slot is occupied
106 * if 0, indicates that extport slot is unoccupied */
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.
120 struct switch_info
*swtch
;
122 char name
[MAX_NAME_SIZE_UISQUEUE
];
124 struct vhba_wwnn wwnn
;
125 unsigned char macaddr
[MAX_MACADDR_LEN
];
130 void __iomem
*chanptr
;
133 uuid_le channel_uuid
;
134 uuid_le instance_uuid
;
135 struct InterruptInfo intr
;
136 struct switch_info
*swtch
;
137 char devid
[30]; /* "vbus<busno>:dev<devno>" */
139 struct semaphore interrupt_callback_lock
;
142 int (*interrupt
)(void *);
143 void *interrupt_context
;
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
;
157 u32 busNo
, deviceCount
;
158 struct device_info
**device
;
159 u64 guestHandle
, recvBusInterruptHandle
;
161 ULTRA_VBUS_CHANNEL_PROTOCOL __iomem
*pBusChannel
;
163 struct proc_dir_entry
*proc_dir
; /* proc/uislib/vbus/<x> */
164 struct proc_dir_entry
*proc_info
; /* proc/uislib/vbus/<x>/info */
166 char partitionName
[99];
167 struct bus_info
*next
;
168 u8 localVnic
; /* 1 if local vnic created internally
169 * by IOVM; 0 otherwise... */
172 #define DEDICATED_SWITCH(s) ((s->extPortCount == 1) && \
173 (s->intPortCount == 1))
175 struct sn_list_entry
{
176 struct uisscsi_dest pdest
; /* scsi bus, target, lun for
178 u8 sernum
[MAX_SERIAL_NUM
]; /* serial num of physical
179 * disk.. The length is always
180 * MAX_SERIAL_NUM, padded with
182 struct sn_list_entry
*next
;
185 struct network_policy
{
188 u32 peerforwarding
:1;
196 * IO messages sent to UisnicControlChanFunc & UissdControlChanFunc by
197 * code that processes the ControlVm channel messages.
201 enum iopart_msg_type
{
204 IOPART_DEL_ALL_VNICS
,
209 IOPART_DEL_ALL_VDISKS_FOR_VHBA
,
210 IOPART_DEL_ALL_VHBAS
,
212 IOPART_DETACH_PHBA
, /* 10 */
219 IOPART_ADD_DEVICE
, /* add generic device */
220 IOPART_DEL_DEVICE
, /* del generic device */
223 struct add_virt_iopart
{
224 void *chanptr
; /* pointer to data channel */
225 u64 guest_handle
; /* used to convert guest physical
226 * address to real physical address
227 * for DMA, for ex. */
228 u64 recv_bus_irq_handle
; /* used to register to receive
229 * bus level interrupts. */
230 struct InterruptInfo intr
; /* contains recv & send
232 /* recvInterruptHandle is used to register to receive
233 * interrupts on the data channel. Used by GuestLinux/Windows
234 * IO drivers to connect to interrupt. sendInterruptHandle is
235 * used by IOPart drivers as parameter to
236 * Issue_VMCALL_IO_QUEUE_TRANSITION to interrupt thread in
237 * guest linux/windows IO drivers when data channel queue for
238 * vhba/vnic goes from EMPTY to NON-EMPTY. */
239 struct switch_info
*swtch
; /* pointer to the virtual
240 * switch to which the vnic is
243 u8 use_g2g_copy
; /* Used to determine if a virtual HBA
244 * needs to use G2G copy. */
254 struct add_vdisk_iopart
{
255 void *chanptr
; /* pointer to data channel */
257 struct uisscsi_dest vdest
; /* scsi bus, target, lun for virt disk */
258 struct uisscsi_dest pdest
; /* scsi bus, target, lun for phys disk */
259 u8 sernum
[MAX_SERIAL_NUM
]; /* serial num of physical disk */
260 u32 serlen
; /* length of serial num */
265 struct del_vdisk_iopart
{
266 void *chanptr
; /* pointer to data channel */
267 struct uisscsi_dest vdest
; /* scsi bus, target, lun for virt disk */
272 struct del_virt_iopart
{
273 void *chanptr
; /* pointer to data channel */
278 struct det_virt_iopart
{ /* detach internal port */
279 void *chanptr
; /* pointer to data channel */
280 struct switch_info
*swtch
;
283 struct paures_vdisk_iopart
{
284 void *chanptr
; /* pointer to data channel */
285 struct uisscsi_dest vdest
; /* scsi bus, target, lun for virt disk */
288 struct add_switch_iopart
{ /* add switch */
289 struct switch_info
*swtch
;
294 struct del_switch_iopart
{ /* destroy switch */
295 struct switch_info
*swtch
;
299 enum iopart_msg_type msgtype
;
301 /* additional params needed by some messages */
303 struct add_virt_iopart add_vhba
;
304 struct add_virt_iopart add_vnic
;
305 struct add_vdisk_iopart add_vdisk
;
306 struct del_virt_iopart del_vhba
;
307 struct del_virt_iopart del_vnic
;
308 struct det_virt_iopart det_vhba
;
309 struct det_virt_iopart det_vnic
;
310 struct del_vdisk_iopart del_vdisk
;
311 struct del_virt_iopart del_all_vdisks_for_vhba
;
312 struct add_virt_iopart add_device
;
313 struct del_virt_iopart del_device
;
314 struct det_virt_iopart det_intport
;
315 struct add_switch_iopart add_switch
;
316 struct del_switch_iopart del_switch
;
317 struct extport_info
*ext_port
; /* for attach or detach
318 * pnic/generic delete all
319 * vhbas/allvnics need no
321 struct paures_vdisk_iopart paures_vdisk
;
326 * Guest messages sent to VirtControlChanFunc by code that processes
327 * the ControlVm channel messages.
339 GUEST_DEL_ALL_VBUSES
, /* deletes all vhbas & vnics on all
340 * buses and deletes all buses */
345 } GUESTPART_MSG_TYPE
;
347 struct add_vbus_guestpart
{
348 void __iomem
*chanptr
; /* pointer to data channel for bus -
350 u32 busNo
; /* bus number to be created/deleted */
351 u32 deviceCount
; /* max num of devices on bus */
352 uuid_le busTypeGuid
; /* indicates type of bus */
353 uuid_le busInstGuid
; /* instance guid for device */
356 struct del_vbus_guestpart
{
357 u32 bus_no
; /* bus number to be deleted */
358 /* once we start using the bus's channel, add can dump busNo
359 * into the channel header and then delete will need only one
360 * parameter, chanptr. */
363 struct add_virt_guestpart
{
364 void __iomem
*chanptr
; /* pointer to data channel */
365 u32 bus_no
; /* bus number for the operation */
366 u32 device_no
; /* number of device on the bus */
367 uuid_le instance_uuid
; /* instance guid for device */
368 struct InterruptInfo intr
; /* recv/send interrupt info */
369 /* recvInterruptHandle contains info needed in order to
370 * register to receive interrupts on the data channel.
371 * sendInterruptHandle contains handle which is provided to
372 * monitor VMCALL that will cause an interrupt to be generated
377 struct pause_virt_guestpart
{
378 void __iomem
*chanptr
; /* pointer to data channel */
381 struct resume_virt_guestpart
{
382 void __iomem
*chanptr
; /* pointer to data channel */
385 struct del_virt_guestpart
{
386 void __iomem
*chanptr
; /* pointer to data channel */
389 struct init_chipset_guestpart
{
390 u32 bus_count
; /* indicates the max number of busses */
391 u32 switch_count
; /* indicates the max number of switches */
395 GUESTPART_MSG_TYPE msgtype
;
397 /* additional params needed by messages */
399 struct add_vbus_guestpart add_vbus
;
400 struct add_virt_guestpart add_vhba
;
401 struct add_virt_guestpart add_vnic
;
402 struct pause_virt_guestpart pause_vhba
;
403 struct pause_virt_guestpart pause_vnic
;
404 struct resume_virt_guestpart resume_vhba
;
405 struct resume_virt_guestpart resume_vnic
;
406 struct del_vbus_guestpart del_vbus
;
407 struct del_virt_guestpart del_vhba
;
408 struct del_virt_guestpart del_vnic
;
409 struct del_vbus_guestpart del_all_vhbas
;
410 struct del_vbus_guestpart del_all_vnics
;
411 /* del_all_vbuses needs no parameters */
413 struct init_chipset_guestpart init_chipset
;
417 #endif /* __UISQUEUE_H__ */