aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/unisys/include/uisqueue.h
blob: 08ba16ea840ee5087a633840fd5fba15d26daf90 (plain) (blame)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
/* uisqueue.h
 *
 * Copyright (C) 2010 - 2013 UNISYS CORPORATION
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
 * NON INFRINGEMENT.  See the GNU General Public License for more
 * details.
 */

/*
 * Unisys IO Virtualization header NOTE: This file contains only Linux
 * specific structs.  All OS-independent structs are in iochannel.h.xx
 */

#ifndef __UISQUEUE_H__
#define __UISQUEUE_H__

#include "linux/version.h"
#include "iochannel.h"
#include <linux/atomic.h>
#include <linux/semaphore.h>
#include <linux/uuid.h>

#include "controlvmchannel.h"
#include "controlvmcompletionstatus.h"

struct uisqueue_info {
	struct channel_header __iomem *chan;
	/* channel containing queues in which scsi commands &
	 * responses are queued
	 */
	u64 packets_sent;
	u64 packets_received;
	u64 interrupts_sent;
	u64 interrupts_received;
	u64 max_not_empty_cnt;
	u64 total_wakeup_cnt;
	u64 non_empty_wakeup_cnt;

	struct {
		struct signal_queue_header reserved1;	/*  */
		struct signal_queue_header reserved2;	/*  */
	} safe_uis_queue;
	unsigned int (*send_int_if_needed)(struct uisqueue_info *info,
					   unsigned int whichcqueue,
					   unsigned char issue_irq_if_empty,
					   u64 irq_handle,
					   unsigned char io_termination);
};

/* uisqueue_put_cmdrsp_with_lock_client queues a commmand or response
 * to the specified queue, at the tail if the queue is full but
 * oktowait == 0, then it return 0 indicating failure.  otherwise it
 * wait for the queue to become non-full. If command is queued, return
 * 1 for success.
 */
#define DONT_ISSUE_INTERRUPT 0
#define ISSUE_INTERRUPT		 1

#define DONT_WAIT			 0
#define OK_TO_WAIT			 1
#define UISLIB_LOCK_PREFIX \
		".section .smp_locks,\"a\"\n"   \
		_ASM_ALIGN "\n"                 \
		_ASM_PTR "661f\n" /* address */ \
		".previous\n"                   \
		"661:\n\tlock; "

unsigned long long uisqueue_interlocked_or(unsigned long long __iomem *tgt,
					   unsigned long long set);
unsigned long long uisqueue_interlocked_and(unsigned long long __iomem *tgt,
					    unsigned long long set);

int uisqueue_put_cmdrsp_with_lock_client(struct uisqueue_info *queueinfo,
					 struct uiscmdrsp *cmdrsp,
					 unsigned int queue,
					 void *insertlock,
					 unsigned char issue_irq_if_empty,
					 u64 irq_handle,
					 char oktowait,
					 u8 *channel_id);

/* uisqueue_get_cmdrsp gets the cmdrsp entry at the head of the queue
 * and copies it to the area pointed by cmdrsp param.
 * returns 0 if queue is empty, 1 otherwise
 */
int

uisqueue_get_cmdrsp(struct uisqueue_info *queueinfo, void *cmdrsp,
		    unsigned int queue);

#define MAX_NAME_SIZE_UISQUEUE 64

struct extport_info {
	u8 valid:1;
	/* if 1, indicates this extport slot is occupied
	 * if 0, indicates that extport slot is unoccupied */

	u32 num_devs_using;
	/* When extport is added, this is set to 0.  For exports
	* located in NETWORK switches:
	* Each time a VNIC, i.e., intport, is added to the switch this
	* is used to assign a pref_pnic for the VNIC and when assigned
	* to a VNIC this counter is incremented. When a VNIC is
	* deleted, the extport corresponding to the VNIC's pref_pnic
	* is located and its num_devs_using is decremented. For VNICs,
	* num_devs_using is basically used to load-balance transmit
	* traffic from VNICs.
	*/

	struct switch_info *swtch;
	struct pci_id pci_id;
	char name[MAX_NAME_SIZE_UISQUEUE];
	union {
		struct vhba_wwnn wwnn;
		unsigned char macaddr[MAX_MACADDR_LEN];
	};
};

struct device_info {
	void __iomem *chanptr;
	u64 channel_addr;
	u64 channel_bytes;
	uuid_le channel_uuid;
	uuid_le instance_uuid;
	struct irq_info intr;
	struct switch_info *swtch;
	char devid[30];		/* "vbus<busno>:dev<devno>" */
	u16 polling;
	struct semaphore interrupt_callback_lock;
	u32 bus_no;
	u32 dev_no;
	int (*interrupt)(void *);
	void *interrupt_context;
	void *private_data;
	struct list_head list_polling_device_channels;
	unsigned long long moved_to_tail_cnt;
	unsigned long long first_busy_cnt;
	unsigned long long last_on_list_cnt;
};

enum switch_type {
	RECOVERY_LAN = 1,
	IB_LAN = 2
};

struct bus_info {
	u32 bus_no, device_count;
	struct device_info **device;
	u64 guest_handle, recv_bus_irq_handle;
	uuid_le bus_inst_uuid;
	struct ultra_vbus_channel_protocol __iomem *bus_channel;
	int bus_channel_bytes;
	struct proc_dir_entry *proc_dir;	/* proc/uislib/vbus/<x> */
	struct proc_dir_entry *proc_info;	/* proc/uislib/vbus/<x>/info */
	char name[25];
	char partition_name[99];
	struct bus_info *next;
	u8 local_vnic;		/* 1 if local vnic created internally
				 * by IOVM; 0 otherwise... */
};

struct sn_list_entry {
	struct uisscsi_dest pdest;	/* scsi bus, target, lun for
					 * phys disk */
	u8 sernum[MAX_SERIAL_NUM];	/* serial num of physical
					 * disk.. The length is always
					 * MAX_SERIAL_NUM, padded with
					 * spaces */
	struct sn_list_entry *next;
};

/*
 * IO messages sent to UisnicControlChanFunc & UissdControlChanFunc by
 * code that processes the ControlVm channel messages.
 */

enum iopart_msg_type {
	IOPART_ADD_VNIC,
	IOPART_DEL_VNIC,
	IOPART_DEL_ALL_VNICS,
	IOPART_ADD_VHBA,
	IOPART_ADD_VDISK,
	IOPART_DEL_VHBA,
	IOPART_DEL_VDISK,
	IOPART_DEL_ALL_VDISKS_FOR_VHBA,
	IOPART_DEL_ALL_VHBAS,
	IOPART_ATTACH_PHBA,
	IOPART_DETACH_PHBA,	/* 10 */
	IOPART_ATTACH_PNIC,
	IOPART_DETACH_PNIC,
	IOPART_DETACH_VHBA,
	IOPART_DETACH_VNIC,
	IOPART_PAUSE_VDISK,
	IOPART_RESUME_VDISK,
	IOPART_ADD_DEVICE,	/* add generic device */
	IOPART_DEL_DEVICE,	/* del generic device */
};

struct add_virt_iopart {
	void *chanptr;		/* pointer to data channel */
	u64 guest_handle;	/* used to convert guest physical
				 * address to real physical address
				 * for DMA, for ex. */
	u64 recv_bus_irq_handle;	/* used to register to receive
					 * bus level interrupts. */
	struct irq_info intr;	/* contains recv & send
					 * interrupt info */
	/* recvInterruptHandle is used to register to receive
	* interrupts on the data channel. Used by GuestLinux/Windows
	* IO drivers to connect to interrupt.  sendInterruptHandle is
	* used by IOPart drivers as parameter to
	* Issue_VMCALL_IO_QUEUE_TRANSITION to interrupt thread in
	* guest linux/windows IO drivers when data channel queue for
	* vhba/vnic goes from EMPTY to NON-EMPTY. */
	struct switch_info *swtch;	/* pointer to the virtual
					 * switch to which the vnic is
					 * connected */

	u8 use_g2g_copy;	/* Used to determine if a virtual HBA
				 * needs to use G2G copy. */
	u8 filler[7];

	u32 bus_no;
	u32 dev_no;
	char *params;
	ulong params_bytes;

};

struct add_vdisk_iopart {
	void *chanptr;		      /* pointer to data channel */
	int implicit;
	struct uisscsi_dest vdest;    /* scsi bus, target, lun for virt disk */
	struct uisscsi_dest pdest;    /* scsi bus, target, lun for phys disk */
	u8 sernum[MAX_SERIAL_NUM];    /* serial num of physical disk */
	u32 serlen;		      /* length of serial num */
};

struct del_vdisk_iopart {
	void *chanptr;		     /* pointer to data channel */
	struct uisscsi_dest vdest;   /* scsi bus, target, lun for virt disk */
};

struct del_virt_iopart {
	void *chanptr;		     /* pointer to data channel */
};

struct det_virt_iopart {	     /* detach internal port */
	void *chanptr;		     /* pointer to data channel */
	struct switch_info *swtch;
};

struct paures_vdisk_iopart {
	void *chanptr;		     /* pointer to data channel */
	struct uisscsi_dest vdest;   /* scsi bus, target, lun for virt disk */
};

struct add_switch_iopart {	     /* add switch */
	struct switch_info *swtch;
	char *params;
	ulong params_bytes;
};

struct del_switch_iopart {	     /* destroy switch */
	struct switch_info *swtch;
};

struct io_msgs {
	enum iopart_msg_type msgtype;

	/* additional params needed by some messages */
	union {
		struct add_virt_iopart add_vhba;
		struct add_virt_iopart add_vnic;
		struct add_vdisk_iopart add_vdisk;
		struct del_virt_iopart del_vhba;
		struct del_virt_iopart del_vnic;
		struct det_virt_iopart det_vhba;
		struct det_virt_iopart det_vnic;
		struct del_vdisk_iopart del_vdisk;
		struct del_virt_iopart del_all_vdisks_for_vhba;
		struct add_virt_iopart add_device;
		struct del_virt_iopart del_device;
		struct det_virt_iopart det_intport;
		struct add_switch_iopart add_switch;
		struct del_switch_iopart del_switch;
		struct extport_info *ext_port;	/* for attach or detach
						 * pnic/generic delete all
						 * vhbas/allvnics need no
						 * parameters */
		struct paures_vdisk_iopart paures_vdisk;
	};
};

/*
* Guest messages sent to VirtControlChanFunc by code that processes
* the ControlVm channel messages.
*/

enum guestpart_msg_type {
	GUEST_ADD_VBUS,
	GUEST_ADD_VHBA,
	GUEST_ADD_VNIC,
	GUEST_DEL_VBUS,
	GUEST_DEL_VHBA,
	GUEST_DEL_VNIC,
	GUEST_DEL_ALL_VHBAS,
	GUEST_DEL_ALL_VNICS,
	GUEST_DEL_ALL_VBUSES,	/* deletes all vhbas & vnics on all
				 * buses and deletes all buses */
	GUEST_PAUSE_VHBA,
	GUEST_PAUSE_VNIC,
	GUEST_RESUME_VHBA,
	GUEST_RESUME_VNIC
};

struct add_vbus_guestpart {
	void __iomem *chanptr;		/* pointer to data channel for bus -
					 * NOT YET USED */
	u32 bus_no;		/* bus number to be created/deleted */
	u32 dev_count;	/* max num of devices on bus */
	uuid_le bus_uuid;	/* indicates type of bus */
	uuid_le instance_uuid;	/* instance guid for device */
};

struct del_vbus_guestpart {
	u32 bus_no;		/* bus number to be deleted */
	/* once we start using the bus's channel, add can dump busNo
	* into the channel header and then delete will need only one
	* parameter, chanptr. */
};

struct add_virt_guestpart {
	void __iomem *chanptr;		/* pointer to data channel */
	u32 bus_no;		/* bus number for the operation */
	u32 device_no;		/* number of device on the bus */
	uuid_le instance_uuid;	/* instance guid for device */
	struct irq_info intr;	/* recv/send interrupt info */
	/* recvInterruptHandle contains info needed in order to
	 * register to receive interrupts on the data channel.
	 * sendInterruptHandle contains handle which is provided to
	 * monitor VMCALL that will cause an interrupt to be generated
	 * for the other end.
	 */
};

struct pause_virt_guestpart {
	void __iomem *chanptr;		/* pointer to data channel */
};

struct resume_virt_guestpart {
	void __iomem *chanptr;		/* pointer to data channel */
};

struct del_virt_guestpart {
	void __iomem *chanptr;		/* pointer to data channel */
};

struct init_chipset_guestpart {
	u32 bus_count;		/* indicates the max number of busses */
	u32 switch_count;	/* indicates the max number of switches */
};

struct guest_msgs {
	enum guestpart_msg_type msgtype;

	/* additional params needed by messages */
	union {
		struct add_vbus_guestpart add_vbus;
		struct add_virt_guestpart add_vhba;
		struct add_virt_guestpart add_vnic;
		struct pause_virt_guestpart pause_vhba;
		struct pause_virt_guestpart pause_vnic;
		struct resume_virt_guestpart resume_vhba;
		struct resume_virt_guestpart resume_vnic;
		struct del_vbus_guestpart del_vbus;
		struct del_virt_guestpart del_vhba;
		struct del_virt_guestpart del_vnic;
		struct del_vbus_guestpart del_all_vhbas;
		struct del_vbus_guestpart del_all_vnics;
		/* del_all_vbuses needs no parameters */
	};
	struct init_chipset_guestpart init_chipset;

};

#endif				/* __UISQUEUE_H__ */