1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#ifndef _VMW_PVSCSI_H_
25#define _VMW_PVSCSI_H_
26
27#include <linux/types.h>
28
29#define PVSCSI_DRIVER_VERSION_STRING "1.0.7.0-k"
30
31#define PVSCSI_MAX_NUM_SG_ENTRIES_PER_SEGMENT 128
32
33#define MASK(n) ((1 << (n)) - 1)
34
35#define PCI_DEVICE_ID_VMWARE_PVSCSI 0x07C0
36
37
38
39
40enum HostBusAdapterStatus {
41 BTSTAT_SUCCESS = 0x00,
42 BTSTAT_LINKED_COMMAND_COMPLETED = 0x0a,
43 BTSTAT_LINKED_COMMAND_COMPLETED_WITH_FLAG = 0x0b,
44 BTSTAT_DATA_UNDERRUN = 0x0c,
45 BTSTAT_SELTIMEO = 0x11,
46 BTSTAT_DATARUN = 0x12,
47 BTSTAT_BUSFREE = 0x13,
48 BTSTAT_INVPHASE = 0x14,
49
50 BTSTAT_LUNMISMATCH = 0x17,
51
52 BTSTAT_INVPARAM = 0x1a,
53
54 BTSTAT_SENSFAILED = 0x1b,
55 BTSTAT_TAGREJECT = 0x1c,
56
57 BTSTAT_BADMSG = 0x1d,
58
59 BTSTAT_HAHARDWARE = 0x20,
60 BTSTAT_NORESPONSE = 0x21,
61
62 BTSTAT_SENTRST = 0x22,
63 BTSTAT_RECVRST = 0x23,
64
65 BTSTAT_DISCONNECT = 0x24,
66
67 BTSTAT_BUSRESET = 0x25,
68 BTSTAT_ABORTQUEUE = 0x26,
69 BTSTAT_HASOFTWARE = 0x27,
70 BTSTAT_HATIMEOUT = 0x30,
71 BTSTAT_SCSIPARITY = 0x34,
72};
73
74
75
76
77enum ScsiDeviceStatus {
78 SDSTAT_GOOD = 0x00,
79 SDSTAT_CHECK = 0x02,
80};
81
82
83
84
85
86
87
88enum PVSCSIRegOffset {
89 PVSCSI_REG_OFFSET_COMMAND = 0x0,
90 PVSCSI_REG_OFFSET_COMMAND_DATA = 0x4,
91 PVSCSI_REG_OFFSET_COMMAND_STATUS = 0x8,
92 PVSCSI_REG_OFFSET_LAST_STS_0 = 0x100,
93 PVSCSI_REG_OFFSET_LAST_STS_1 = 0x104,
94 PVSCSI_REG_OFFSET_LAST_STS_2 = 0x108,
95 PVSCSI_REG_OFFSET_LAST_STS_3 = 0x10c,
96 PVSCSI_REG_OFFSET_INTR_STATUS = 0x100c,
97 PVSCSI_REG_OFFSET_INTR_MASK = 0x2010,
98 PVSCSI_REG_OFFSET_KICK_NON_RW_IO = 0x3014,
99 PVSCSI_REG_OFFSET_DEBUG = 0x3018,
100 PVSCSI_REG_OFFSET_KICK_RW_IO = 0x4018,
101};
102
103
104
105
106
107enum PVSCSICommands {
108 PVSCSI_CMD_FIRST = 0,
109
110 PVSCSI_CMD_ADAPTER_RESET = 1,
111 PVSCSI_CMD_ISSUE_SCSI = 2,
112 PVSCSI_CMD_SETUP_RINGS = 3,
113 PVSCSI_CMD_RESET_BUS = 4,
114 PVSCSI_CMD_RESET_DEVICE = 5,
115 PVSCSI_CMD_ABORT_CMD = 6,
116 PVSCSI_CMD_CONFIG = 7,
117 PVSCSI_CMD_SETUP_MSG_RING = 8,
118 PVSCSI_CMD_DEVICE_UNPLUG = 9,
119 PVSCSI_CMD_SETUP_REQCALLTHRESHOLD = 10,
120
121 PVSCSI_CMD_LAST = 11
122};
123
124
125
126
127
128struct PVSCSICmdDescResetDevice {
129 u32 target;
130 u8 lun[8];
131} __packed;
132
133
134
135
136
137struct PVSCSICmdDescConfigCmd {
138 u64 cmpAddr;
139 u64 configPageAddress;
140 u32 configPageNum;
141 u32 _pad;
142} __packed;
143
144
145
146
147
148struct PVSCSICmdDescSetupReqCall {
149 u32 enable;
150} __packed;
151
152enum PVSCSIConfigPageType {
153 PVSCSI_CONFIG_PAGE_CONTROLLER = 0x1958,
154 PVSCSI_CONFIG_PAGE_PHY = 0x1959,
155 PVSCSI_CONFIG_PAGE_DEVICE = 0x195a,
156};
157
158enum PVSCSIConfigPageAddressType {
159 PVSCSI_CONFIG_CONTROLLER_ADDRESS = 0x2120,
160 PVSCSI_CONFIG_BUSTARGET_ADDRESS = 0x2121,
161 PVSCSI_CONFIG_PHY_ADDRESS = 0x2122,
162};
163
164
165
166
167
168
169
170
171struct PVSCSICmdDescAbortCmd {
172 u64 context;
173 u32 target;
174 u32 _pad;
175} __packed;
176
177
178
179
180
181
182
183
184
185
186
187#define PVSCSI_SETUP_RINGS_MAX_NUM_PAGES 32
188struct PVSCSICmdDescSetupRings {
189 u32 reqRingNumPages;
190 u32 cmpRingNumPages;
191 u64 ringsStatePPN;
192 u64 reqRingPPNs[PVSCSI_SETUP_RINGS_MAX_NUM_PAGES];
193 u64 cmpRingPPNs[PVSCSI_SETUP_RINGS_MAX_NUM_PAGES];
194} __packed;
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215#define PVSCSI_SETUP_MSG_RING_MAX_NUM_PAGES 16
216
217struct PVSCSICmdDescSetupMsgRing {
218 u32 numPages;
219 u32 _pad;
220 u64 ringPPNs[PVSCSI_SETUP_MSG_RING_MAX_NUM_PAGES];
221} __packed;
222
223enum PVSCSIMsgType {
224 PVSCSI_MSG_DEV_ADDED = 0,
225 PVSCSI_MSG_DEV_REMOVED = 1,
226 PVSCSI_MSG_LAST = 2,
227};
228
229
230
231
232
233
234
235
236
237
238struct PVSCSIRingMsgDesc {
239 u32 type;
240 u32 args[31];
241} __packed;
242
243struct PVSCSIMsgDescDevStatusChanged {
244 u32 type;
245 u32 bus;
246 u32 target;
247 u8 lun[8];
248 u32 pad[27];
249} __packed;
250
251
252
253
254
255
256
257
258
259
260
261
262
263struct PVSCSIRingsState {
264 u32 reqProdIdx;
265 u32 reqConsIdx;
266 u32 reqNumEntriesLog2;
267
268 u32 cmpProdIdx;
269 u32 cmpConsIdx;
270 u32 cmpNumEntriesLog2;
271
272 u32 reqCallThreshold;
273
274 u8 _pad[100];
275
276 u32 msgProdIdx;
277 u32 msgConsIdx;
278 u32 msgNumEntriesLog2;
279} __packed;
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#define PVSCSI_FLAG_CMD_WITH_SG_LIST (1 << 0)
318#define PVSCSI_FLAG_CMD_OUT_OF_BAND_CDB (1 << 1)
319#define PVSCSI_FLAG_CMD_DIR_NONE (1 << 2)
320#define PVSCSI_FLAG_CMD_DIR_TOHOST (1 << 3)
321#define PVSCSI_FLAG_CMD_DIR_TODEVICE (1 << 4)
322
323struct PVSCSIRingReqDesc {
324 u64 context;
325 u64 dataAddr;
326 u64 dataLen;
327 u64 senseAddr;
328 u32 senseLen;
329 u32 flags;
330 u8 cdb[16];
331 u8 cdbLen;
332 u8 lun[8];
333 u8 tag;
334 u8 bus;
335 u8 target;
336 u8 vcpuHint;
337 u8 unused[59];
338} __packed;
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356struct PVSCSISGElement {
357 u64 addr;
358 u32 length;
359 u32 flags;
360} __packed;
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376struct PVSCSIRingCmpDesc {
377 u64 context;
378 u64 dataLen;
379 u32 senseLen;
380 u16 hostStatus;
381 u16 scsiStatus;
382 u32 _pad[2];
383} __packed;
384
385struct PVSCSIConfigPageHeader {
386 u32 pageNum;
387 u16 numDwords;
388 u16 hostStatus;
389 u16 scsiStatus;
390 u16 reserved[3];
391} __packed;
392
393struct PVSCSIConfigPageController {
394 struct PVSCSIConfigPageHeader header;
395 u64 nodeWWN;
396 u16 manufacturer[64];
397 u16 serialNumber[64];
398 u16 opromVersion[32];
399 u16 hwVersion[32];
400 u16 firmwareVersion[32];
401 u32 numPhys;
402 u8 useConsecutivePhyWWNs;
403 u8 reserved[3];
404} __packed;
405
406
407
408
409
410#define PVSCSI_INTR_CMPL_0 (1 << 0)
411#define PVSCSI_INTR_CMPL_1 (1 << 1)
412#define PVSCSI_INTR_CMPL_MASK MASK(2)
413
414#define PVSCSI_INTR_MSG_0 (1 << 2)
415#define PVSCSI_INTR_MSG_1 (1 << 3)
416#define PVSCSI_INTR_MSG_MASK (MASK(2) << 2)
417
418#define PVSCSI_INTR_ALL_SUPPORTED MASK(4)
419
420
421
422
423#define PVSCSI_MAX_INTRS 24
424
425
426
427
428
429#define PVSCSI_MAX_NUM_PAGES_REQ_RING PVSCSI_SETUP_RINGS_MAX_NUM_PAGES
430#define PVSCSI_MAX_NUM_PAGES_CMP_RING PVSCSI_SETUP_RINGS_MAX_NUM_PAGES
431#define PVSCSI_MAX_NUM_PAGES_MSG_RING PVSCSI_SETUP_MSG_RING_MAX_NUM_PAGES
432
433#define PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE \
434 (PAGE_SIZE / sizeof(struct PVSCSIRingReqDesc))
435
436#define PVSCSI_MAX_REQ_QUEUE_DEPTH \
437 (PVSCSI_MAX_NUM_PAGES_REQ_RING * PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE)
438
439#define PVSCSI_MEM_SPACE_COMMAND_NUM_PAGES 1
440#define PVSCSI_MEM_SPACE_INTR_STATUS_NUM_PAGES 1
441#define PVSCSI_MEM_SPACE_MISC_NUM_PAGES 2
442#define PVSCSI_MEM_SPACE_KICK_IO_NUM_PAGES 2
443#define PVSCSI_MEM_SPACE_MSIX_NUM_PAGES 2
444
445enum PVSCSIMemSpace {
446 PVSCSI_MEM_SPACE_COMMAND_PAGE = 0,
447 PVSCSI_MEM_SPACE_INTR_STATUS_PAGE = 1,
448 PVSCSI_MEM_SPACE_MISC_PAGE = 2,
449 PVSCSI_MEM_SPACE_KICK_IO_PAGE = 4,
450 PVSCSI_MEM_SPACE_MSIX_TABLE_PAGE = 6,
451 PVSCSI_MEM_SPACE_MSIX_PBA_PAGE = 7,
452};
453
454#define PVSCSI_MEM_SPACE_NUM_PAGES \
455 (PVSCSI_MEM_SPACE_COMMAND_NUM_PAGES + \
456 PVSCSI_MEM_SPACE_INTR_STATUS_NUM_PAGES + \
457 PVSCSI_MEM_SPACE_MISC_NUM_PAGES + \
458 PVSCSI_MEM_SPACE_KICK_IO_NUM_PAGES + \
459 PVSCSI_MEM_SPACE_MSIX_NUM_PAGES)
460
461#define PVSCSI_MEM_SPACE_SIZE (PVSCSI_MEM_SPACE_NUM_PAGES * PAGE_SIZE)
462
463#endif
464