1 | /* $Id: VSCSIInternal.h 66058 2017-03-13 11:53:11Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Virtual SCSI driver: Internal defines
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2016 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 | #ifndef ___VSCSIInternal_h
|
---|
18 | #define ___VSCSIInternal_h
|
---|
19 |
|
---|
20 | #include <VBox/vscsi.h>
|
---|
21 | #include <VBox/scsi.h>
|
---|
22 | #include <VBox/scsiinline.h>
|
---|
23 | #include <iprt/memcache.h>
|
---|
24 | #include <iprt/sg.h>
|
---|
25 | #include <iprt/list.h>
|
---|
26 |
|
---|
27 | #include "VSCSIVpdPages.h"
|
---|
28 |
|
---|
29 | /** Pointer to an internal virtual SCSI device. */
|
---|
30 | typedef VSCSIDEVICEINT *PVSCSIDEVICEINT;
|
---|
31 | /** Pointer to an internal virtual SCSI device LUN. */
|
---|
32 | typedef VSCSILUNINT *PVSCSILUNINT;
|
---|
33 | /** Pointer to an internal virtual SCSI device LUN pointer. */
|
---|
34 | typedef PVSCSILUNINT *PPVSCSILUNINT;
|
---|
35 | /** Pointer to a virtual SCSI LUN descriptor. */
|
---|
36 | typedef struct VSCSILUNDESC *PVSCSILUNDESC;
|
---|
37 | /** Pointer to a virtual SCSI request. */
|
---|
38 | typedef VSCSIREQINT *PVSCSIREQINT;
|
---|
39 | /** Pointer to a virtual SCSI I/O request. */
|
---|
40 | typedef VSCSIIOREQINT *PVSCSIIOREQINT;
|
---|
41 | /** Pointer to virtual SCSI sense data state. */
|
---|
42 | typedef struct VSCSISENSE *PVSCSISENSE;
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * Virtual SCSI sense data handling.
|
---|
46 | */
|
---|
47 | typedef struct VSCSISENSE
|
---|
48 | {
|
---|
49 | /** Buffer holding the sense data. */
|
---|
50 | uint8_t abSenseBuf[32];
|
---|
51 | } VSCSISENSE;
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * Virtual SCSI device.
|
---|
55 | */
|
---|
56 | typedef struct VSCSIDEVICEINT
|
---|
57 | {
|
---|
58 | /** Request completion callback */
|
---|
59 | PFNVSCSIREQCOMPLETED pfnVScsiReqCompleted;
|
---|
60 | /** Opaque user data. */
|
---|
61 | void *pvVScsiDeviceUser;
|
---|
62 | /** Number of LUNs currently attached. */
|
---|
63 | uint32_t cLunsAttached;
|
---|
64 | /** How many LUNs are fitting in the array. */
|
---|
65 | uint32_t cLunsMax;
|
---|
66 | /** Request cache */
|
---|
67 | RTMEMCACHE hCacheReq;
|
---|
68 | /** Sense data handling. */
|
---|
69 | VSCSISENSE VScsiSense;
|
---|
70 | /** Pointer to the array of LUN handles.
|
---|
71 | * The index is the LUN id. */
|
---|
72 | PPVSCSILUNINT papVScsiLun;
|
---|
73 | } VSCSIDEVICEINT;
|
---|
74 |
|
---|
75 | /**
|
---|
76 | * Virtual SCSI device LUN.
|
---|
77 | */
|
---|
78 | typedef struct VSCSILUNINT
|
---|
79 | {
|
---|
80 | /** Pointer to the parent SCSI device. */
|
---|
81 | PVSCSIDEVICEINT pVScsiDevice;
|
---|
82 | /** Opaque user data */
|
---|
83 | void *pvVScsiLunUser;
|
---|
84 | /** I/O callback table */
|
---|
85 | PVSCSILUNIOCALLBACKS pVScsiLunIoCallbacks;
|
---|
86 | /** Pointer to the LUN type descriptor. */
|
---|
87 | PVSCSILUNDESC pVScsiLunDesc;
|
---|
88 | /** Flag indicating whether LUN is ready. */
|
---|
89 | bool fReady;
|
---|
90 | /** Flag indicating media presence in LUN. */
|
---|
91 | bool fMediaPresent;
|
---|
92 | /** Flags of supported features. */
|
---|
93 | uint64_t fFeatures;
|
---|
94 | /** I/O request processing data */
|
---|
95 | struct
|
---|
96 | {
|
---|
97 | /** Number of outstanding tasks on this LUN. */
|
---|
98 | volatile uint32_t cReqOutstanding;
|
---|
99 | } IoReq;
|
---|
100 | } VSCSILUNINT;
|
---|
101 |
|
---|
102 | /**
|
---|
103 | * Virtual SCSI request.
|
---|
104 | */
|
---|
105 | typedef struct VSCSIREQINT
|
---|
106 | {
|
---|
107 | /** The LUN the request is for. */
|
---|
108 | uint32_t iLun;
|
---|
109 | /** The CDB */
|
---|
110 | uint8_t *pbCDB;
|
---|
111 | /** Size of the CDB */
|
---|
112 | size_t cbCDB;
|
---|
113 | /** S/G buffer. */
|
---|
114 | RTSGBUF SgBuf;
|
---|
115 | /** Pointer to the sense buffer. */
|
---|
116 | uint8_t *pbSense;
|
---|
117 | /** Size of the sense buffer */
|
---|
118 | size_t cbSense;
|
---|
119 | /** Opaque user data associated with this request */
|
---|
120 | void *pvVScsiReqUser;
|
---|
121 | /** Transfer size determined from the CDB. */
|
---|
122 | size_t cbXfer;
|
---|
123 | /** Pointer to the opaque data which may be allocated by the LUN
|
---|
124 | * the request is for. */
|
---|
125 | void *pvLun;
|
---|
126 | } VSCSIREQINT;
|
---|
127 |
|
---|
128 | /**
|
---|
129 | * Virtual SCSI I/O request.
|
---|
130 | */
|
---|
131 | typedef struct VSCSIIOREQINT
|
---|
132 | {
|
---|
133 | /** The associated request. */
|
---|
134 | PVSCSIREQINT pVScsiReq;
|
---|
135 | /** Lun for this I/O request. */
|
---|
136 | PVSCSILUNINT pVScsiLun;
|
---|
137 | /** Transfer direction */
|
---|
138 | VSCSIIOREQTXDIR enmTxDir;
|
---|
139 | /** Direction dependent data. */
|
---|
140 | union
|
---|
141 | {
|
---|
142 | /** Read/Write request. */
|
---|
143 | struct
|
---|
144 | {
|
---|
145 | /** Start offset */
|
---|
146 | uint64_t uOffset;
|
---|
147 | /** Number of bytes to transfer */
|
---|
148 | size_t cbTransfer;
|
---|
149 | /** Number of bytes the S/G list holds */
|
---|
150 | size_t cbSeg;
|
---|
151 | /** Number of segments. */
|
---|
152 | unsigned cSeg;
|
---|
153 | /** Segment array. */
|
---|
154 | PCRTSGSEG paSeg;
|
---|
155 | } Io;
|
---|
156 | /** Unmap request. */
|
---|
157 | struct
|
---|
158 | {
|
---|
159 | /** Array of ranges to unmap. */
|
---|
160 | PRTRANGE paRanges;
|
---|
161 | /** Number of ranges. */
|
---|
162 | unsigned cRanges;
|
---|
163 | } Unmap;
|
---|
164 | } u;
|
---|
165 | } VSCSIIOREQINT;
|
---|
166 |
|
---|
167 | /**
|
---|
168 | * VPD page pool.
|
---|
169 | */
|
---|
170 | typedef struct VSCSIVPDPOOL
|
---|
171 | {
|
---|
172 | /** List of registered pages (VSCSIVPDPAGE). */
|
---|
173 | RTLISTANCHOR ListPages;
|
---|
174 | } VSCSIVPDPOOL;
|
---|
175 | /** Pointer to the VSCSI VPD page pool. */
|
---|
176 | typedef VSCSIVPDPOOL *PVSCSIVPDPOOL;
|
---|
177 |
|
---|
178 | /**
|
---|
179 | * Supported operation code information entry.
|
---|
180 | */
|
---|
181 | typedef struct VSCSILUNSUPOPC
|
---|
182 | {
|
---|
183 | /** The operation code. */
|
---|
184 | uint8_t u8Opc;
|
---|
185 | /** Service action code if required as indicated by
|
---|
186 | * VSCSI_LUN_SUP_OPC_SVC_ACTION_REQUIRED */
|
---|
187 | uint16_t u16SvcAction;
|
---|
188 | /** Flags. */
|
---|
189 | uint32_t fFlags;
|
---|
190 | /** Readable description for the op code. */
|
---|
191 | const char *pszOpc;
|
---|
192 | /** The length of the CDB for this operation code. */
|
---|
193 | uint8_t cbCdb;
|
---|
194 | /** Pointer to the CDB usage data. */
|
---|
195 | uint8_t *pbCdbUsage;
|
---|
196 | /* The operation specific valuefor the timeout descriptor. */
|
---|
197 | uint8_t u8OpcTimeoutSpec;
|
---|
198 | /** The nominal processing timeout in seconds. */
|
---|
199 | uint16_t cNominalProcessingTimeout;
|
---|
200 | /** The recommend timeout in seconds. */
|
---|
201 | uint16_t cRecommendTimeout;
|
---|
202 | } VSCSILUNSUPOPC;
|
---|
203 | /** Pointer to a operation code information entry. */
|
---|
204 | typedef VSCSILUNSUPOPC *PVSCSILUNSUPOPC;
|
---|
205 | /** Pointer to a const operation code information entry. */
|
---|
206 | typedef const VSCSILUNSUPOPC *PCVSCSILUNSUPOPC;
|
---|
207 |
|
---|
208 | /** @name Flags for the supported operation code infromation entries.
|
---|
209 | * @{ */
|
---|
210 | /** Flag indicating wheter the service action member is valid and should be
|
---|
211 | * evaluated to find the desired opcode information. */
|
---|
212 | #define VSCSI_LUN_SUP_OPC_SVC_ACTION_REQUIRED RT_BIT_32(0)
|
---|
213 | /** Flag whether the values for the timeout descriptor are valid. */
|
---|
214 | #define VSCSI_LUN_SUP_OPC_TIMEOUT_DESC_VALID RT_BIT_32(1)
|
---|
215 | /** @} */
|
---|
216 |
|
---|
217 | /** @name Support macros to create supported operation code information entries.
|
---|
218 | * @{ */
|
---|
219 | #define VSCSI_LUN_SUP_OPC(a_u8Opc, a_pszOpc, a_cbCdb, a_pbCdbUsage) \
|
---|
220 | { a_u8Opc, 0, 0, a_pszOpc, a_cbCdb, a_pbCdbUsage, 0, 0, 0}
|
---|
221 | #define VSCSI_LUN_SUP_OPC_SVC(a_u8Opc, a_u16SvcAction, a_pszOpc, a_cbCdb, a_pbCdbUsage) \
|
---|
222 | { a_u8Opc, a_u16SvcAction, VSCSI_LUN_SUP_OPC_SVC_ACTION_REQUIRED, a_pszOpc, a_cbCdb, a_pbCdbUsage, 0, 0, 0}
|
---|
223 | /** @} */
|
---|
224 |
|
---|
225 | /**
|
---|
226 | * Virtual SCSI LUN descriptor.
|
---|
227 | */
|
---|
228 | typedef struct VSCSILUNDESC
|
---|
229 | {
|
---|
230 | /** Device type this descriptor emulates. */
|
---|
231 | VSCSILUNTYPE enmLunType;
|
---|
232 | /** Descriptor name */
|
---|
233 | const char *pcszDescName;
|
---|
234 | /** LUN type size */
|
---|
235 | size_t cbLun;
|
---|
236 | /** Number of entries in the supported operation codes array. */
|
---|
237 | uint32_t cSupOpcInfo;
|
---|
238 | /** Pointer to the array of supported operation codes for the
|
---|
239 | * REPORT RUPPORTED OPERATION CODES command handled by the generic
|
---|
240 | * device driver - optional.
|
---|
241 | */
|
---|
242 | PCVSCSILUNSUPOPC paSupOpcInfo;
|
---|
243 |
|
---|
244 | /**
|
---|
245 | * Initialise a Lun instance.
|
---|
246 | *
|
---|
247 | * @returns VBox status code.
|
---|
248 | * @param pVScsiLun The SCSI LUN instance.
|
---|
249 | */
|
---|
250 | DECLR3CALLBACKMEMBER(int, pfnVScsiLunInit, (PVSCSILUNINT pVScsiLun));
|
---|
251 |
|
---|
252 | /**
|
---|
253 | * Destroy a Lun instance.
|
---|
254 | *
|
---|
255 | * @returns VBox status code.
|
---|
256 | * @param pVScsiLun The SCSI LUN instance.
|
---|
257 | */
|
---|
258 | DECLR3CALLBACKMEMBER(int, pfnVScsiLunDestroy, (PVSCSILUNINT pVScsiLun));
|
---|
259 |
|
---|
260 | /**
|
---|
261 | * Processes a SCSI request.
|
---|
262 | *
|
---|
263 | * @returns VBox status code.
|
---|
264 | * @param pVScsiLun The SCSI LUN instance.
|
---|
265 | * @param pVScsiReq The SCSi request to process.
|
---|
266 | */
|
---|
267 | DECLR3CALLBACKMEMBER(int, pfnVScsiLunReqProcess, (PVSCSILUNINT pVScsiLun, PVSCSIREQINT pVScsiReq));
|
---|
268 |
|
---|
269 | /**
|
---|
270 | * Frees additional allocated resources for the given request if it was allocated before.
|
---|
271 | *
|
---|
272 | * @returns void.
|
---|
273 | * @param pVScsiLun The SCSI LUN instance.
|
---|
274 | * @param pVScsiReq The SCSI request.
|
---|
275 | * @param pvScsiReqLun The opaque data allocated previously.
|
---|
276 | */
|
---|
277 | DECLR3CALLBACKMEMBER(void, pfnVScsiLunReqFree, (PVSCSILUNINT pVScsiLun, PVSCSIREQINT pVScsiReq,
|
---|
278 | void *pvScsiReqLun));
|
---|
279 |
|
---|
280 | /**
|
---|
281 | * Informs about a medium being inserted - optional.
|
---|
282 | *
|
---|
283 | * @returns VBox status code.
|
---|
284 | * @param pVScsiLun The SCSI LUN instance.
|
---|
285 | */
|
---|
286 | DECLR3CALLBACKMEMBER(int, pfnVScsiLunMediumInserted, (PVSCSILUNINT pVScsiLun));
|
---|
287 |
|
---|
288 | /**
|
---|
289 | * Informs about a medium being removed - optional.
|
---|
290 | *
|
---|
291 | * @returns VBox status code.
|
---|
292 | * @param pVScsiLun The SCSI LUN instance.
|
---|
293 | */
|
---|
294 | DECLR3CALLBACKMEMBER(int, pfnVScsiLunMediumRemoved, (PVSCSILUNINT pVScsiLun));
|
---|
295 |
|
---|
296 | } VSCSILUNDESC;
|
---|
297 |
|
---|
298 | /** Maximum number of LUNs a device can have. */
|
---|
299 | #define VSCSI_DEVICE_LUN_MAX 128
|
---|
300 |
|
---|
301 | /**
|
---|
302 | * Completes a SCSI request and calls the completion handler.
|
---|
303 | *
|
---|
304 | * @returns nothing.
|
---|
305 | * @param pVScsiDevice The virtual SCSI device.
|
---|
306 | * @param pVScsiReq The request which completed.
|
---|
307 | * @param rcScsiCode The status code
|
---|
308 | * One of the SCSI_STATUS_* #defines.
|
---|
309 | * @param fRedoPossible Flag whether redo is possible.
|
---|
310 | * @param rcReq Informational return code of the request.
|
---|
311 | */
|
---|
312 | void vscsiDeviceReqComplete(PVSCSIDEVICEINT pVScsiDevice, PVSCSIREQINT pVScsiReq,
|
---|
313 | int rcScsiCode, bool fRedoPossible, int rcReq);
|
---|
314 |
|
---|
315 | /**
|
---|
316 | * Init the sense data state.
|
---|
317 | *
|
---|
318 | * @returns nothing.
|
---|
319 | * @param pVScsiSense The SCSI sense data state to init.
|
---|
320 | */
|
---|
321 | void vscsiSenseInit(PVSCSISENSE pVScsiSense);
|
---|
322 |
|
---|
323 | /**
|
---|
324 | * Sets a ok sense code.
|
---|
325 | *
|
---|
326 | * @returns SCSI status code.
|
---|
327 | * @param pVScsiSense The SCSI sense state to use.
|
---|
328 | * @param pVScsiReq The SCSI request.
|
---|
329 | */
|
---|
330 | int vscsiReqSenseOkSet(PVSCSISENSE pVScsiSense, PVSCSIREQINT pVScsiReq);
|
---|
331 |
|
---|
332 | /**
|
---|
333 | * Sets an error sense code.
|
---|
334 | *
|
---|
335 | * @returns SCSI status code.
|
---|
336 | * @param pVScsiSense The SCSI sense state to use.
|
---|
337 | * @param pVScsiReq The SCSI request.
|
---|
338 | * @param uSCSISenseKey The SCSI sense key to set.
|
---|
339 | * @param uSCSIASC The ASC value.
|
---|
340 | * @param uSCSIASC The ASCQ value.
|
---|
341 | */
|
---|
342 | int vscsiReqSenseErrorSet(PVSCSISENSE pVScsiSense, PVSCSIREQINT pVScsiReq, uint8_t uSCSISenseKey,
|
---|
343 | uint8_t uSCSIASC, uint8_t uSCSIASCQ);
|
---|
344 |
|
---|
345 | /**
|
---|
346 | * Sets an error sense code with additional information.
|
---|
347 | *
|
---|
348 | * @returns SCSI status code.
|
---|
349 | * @param pVScsiSense The SCSI sense state to use.
|
---|
350 | * @param pVScsiReq The SCSI request.
|
---|
351 | * @param uSCSISenseKey The SCSI sense key to set.
|
---|
352 | * @param uSCSIASC The ASC value.
|
---|
353 | * @param uSCSIASC The ASCQ value.
|
---|
354 | * @param uInfo The 32-bit sense information.
|
---|
355 | */
|
---|
356 | int vscsiReqSenseErrorInfoSet(PVSCSISENSE pVScsiSense, PVSCSIREQINT pVScsiReq, uint8_t uSCSISenseKey,
|
---|
357 | uint8_t uSCSIASC, uint8_t uSCSIASCQ, uint32_t uInfo);
|
---|
358 |
|
---|
359 | /**
|
---|
360 | * Process a request sense command.
|
---|
361 | *
|
---|
362 | * @returns SCSI status code.
|
---|
363 | * @param pVScsiSense The SCSI sense state to use.
|
---|
364 | * @param pVScsiReq The SCSI request.
|
---|
365 | */
|
---|
366 | int vscsiReqSenseCmd(PVSCSISENSE pVScsiSense, PVSCSIREQINT pVScsiReq);
|
---|
367 |
|
---|
368 | /**
|
---|
369 | * Inits the VPD page pool.
|
---|
370 | *
|
---|
371 | * @returns VBox status code.
|
---|
372 | * @param pVScsiVpdPool The VPD page pool to initialize.
|
---|
373 | */
|
---|
374 | int vscsiVpdPagePoolInit(PVSCSIVPDPOOL pVScsiVpdPool);
|
---|
375 |
|
---|
376 | /**
|
---|
377 | * Destroys the given VPD page pool freeing all pages in it.
|
---|
378 | *
|
---|
379 | * @returns nothing.
|
---|
380 | * @param pVScsiVpdPool The VPD page pool to destroy.
|
---|
381 | */
|
---|
382 | void vscsiVpdPagePoolDestroy(PVSCSIVPDPOOL pVScsiVpdPool);
|
---|
383 |
|
---|
384 | /**
|
---|
385 | * Allocates a new page in the VPD page pool with the given number.
|
---|
386 | *
|
---|
387 | * @returns VBox status code.
|
---|
388 | * @retval VERR_ALREADY_EXIST if the page number is in use.
|
---|
389 | * @param pVScsiVpdPool The VPD page pool the page will belong to.
|
---|
390 | * @param uPage The page number, must be unique.
|
---|
391 | * @param cbPage Size of the page in bytes.
|
---|
392 | * @param ppbPage Where to store the pointer to the raw page data on success.
|
---|
393 | */
|
---|
394 | int vscsiVpdPagePoolAllocNewPage(PVSCSIVPDPOOL pVScsiVpdPool, uint8_t uPage, size_t cbPage, uint8_t **ppbPage);
|
---|
395 |
|
---|
396 | /**
|
---|
397 | * Queries the given page from the pool and cpies it to the buffer given
|
---|
398 | * by the SCSI request.
|
---|
399 | *
|
---|
400 | * @returns VBox status code.
|
---|
401 | * @retval VERR_NOT_FOUND if the page is not in the pool.
|
---|
402 | * @param pVScsiVpdPool The VPD page pool to use.
|
---|
403 | * @param pVScsiReq The SCSI request.
|
---|
404 | * @param uPage Page to query.
|
---|
405 | */
|
---|
406 | int vscsiVpdPagePoolQueryPage(PVSCSIVPDPOOL pVScsiVpdPool, PVSCSIREQINT pVScsiReq, uint8_t uPage);
|
---|
407 |
|
---|
408 | /**
|
---|
409 | * Inits the I/O request related state for the LUN.
|
---|
410 | *
|
---|
411 | * @returns VBox status code.
|
---|
412 | * @param pVScsiLun The LUN instance.
|
---|
413 | */
|
---|
414 | int vscsiIoReqInit(PVSCSILUNINT pVScsiLun);
|
---|
415 |
|
---|
416 | /**
|
---|
417 | * Enqueues a new flush request
|
---|
418 | *
|
---|
419 | * @returns VBox status code.
|
---|
420 | * @param pVScsiLun The LUN instance which issued the request.
|
---|
421 | * @param pVScsiReq The virtual SCSI request associated with the flush.
|
---|
422 | */
|
---|
423 | int vscsiIoReqFlushEnqueue(PVSCSILUNINT pVScsiLun, PVSCSIREQINT pVScsiReq);
|
---|
424 |
|
---|
425 | /**
|
---|
426 | * Enqueue a new data transfer request.
|
---|
427 | *
|
---|
428 | * @returns VBox status code.
|
---|
429 | * @param pVScsiLun The LUN instance which issued the request.
|
---|
430 | * @param pVScsiReq The virtual SCSI request associated with the transfer.
|
---|
431 | * @param enmTxDir Transfer direction.
|
---|
432 | * @param uOffset Start offset of the transfer.
|
---|
433 | * @param cbTransfer Number of bytes to transfer.
|
---|
434 | */
|
---|
435 | int vscsiIoReqTransferEnqueue(PVSCSILUNINT pVScsiLun, PVSCSIREQINT pVScsiReq,
|
---|
436 | VSCSIIOREQTXDIR enmTxDir, uint64_t uOffset,
|
---|
437 | size_t cbTransfer);
|
---|
438 |
|
---|
439 | /**
|
---|
440 | * Enqueue a new data transfer request - extended variant.
|
---|
441 | *
|
---|
442 | * @returns VBox status code.
|
---|
443 | * @param pVScsiLun The LUN instance which issued the request.
|
---|
444 | * @param pVScsiReq The virtual SCSI request associated with the transfer.
|
---|
445 | * @param enmTxDir Transfer direction.
|
---|
446 | * @param uOffset Start offset of the transfer.
|
---|
447 | * @param paSegs Pointer to the array holding the memory buffer segments.
|
---|
448 | * @param cSegs Number of segments in the array.
|
---|
449 | * @param cbTransfer Number of bytes to transfer.
|
---|
450 | */
|
---|
451 | int vscsiIoReqTransferEnqueueEx(PVSCSILUNINT pVScsiLun, PVSCSIREQINT pVScsiReq,
|
---|
452 | VSCSIIOREQTXDIR enmTxDir, uint64_t uOffset,
|
---|
453 | PCRTSGSEG paSegs, unsigned cSegs, size_t cbTransfer);
|
---|
454 |
|
---|
455 | /**
|
---|
456 | * Enqueue a new unmap request.
|
---|
457 | *
|
---|
458 | * @returns VBox status code.
|
---|
459 | * @param pVScsiLun The LUN instance which issued the request.
|
---|
460 | * @param pVScsiReq The virtual SCSI request associated with the transfer.
|
---|
461 | * @param paRanges The array of ranges to unmap.
|
---|
462 | * @param cRanges Number of ranges in the array.
|
---|
463 | */
|
---|
464 | int vscsiIoReqUnmapEnqueue(PVSCSILUNINT pVScsiLun, PVSCSIREQINT pVScsiReq,
|
---|
465 | PRTRANGE paRanges, unsigned cRanges);
|
---|
466 |
|
---|
467 | /**
|
---|
468 | * Returns the current number of outstanding tasks on the given LUN.
|
---|
469 | *
|
---|
470 | * @returns Number of outstanding tasks.
|
---|
471 | * @param pVScsiLun The LUN to check.
|
---|
472 | */
|
---|
473 | uint32_t vscsiIoReqOutstandingCountGet(PVSCSILUNINT pVScsiLun);
|
---|
474 |
|
---|
475 | /**
|
---|
476 | * Sets the transfer size for the given request.
|
---|
477 | *
|
---|
478 | * @returns nothing.
|
---|
479 | * @param pVScsiReq The SCSI request.
|
---|
480 | * @param cbXfer The transfer size for the request.
|
---|
481 | */
|
---|
482 | DECLINLINE(void) vscsiReqSetXferSize(PVSCSIREQINT pVScsiReq, size_t cbXfer)
|
---|
483 | {
|
---|
484 | pVScsiReq->cbXfer = cbXfer;
|
---|
485 | }
|
---|
486 |
|
---|
487 | /**
|
---|
488 | * Wrapper for the set I/O request allocation size I/O callback.
|
---|
489 | *
|
---|
490 | * @returns VBox status code.
|
---|
491 | * @param pVScsiLun The LUN.
|
---|
492 | * @param cbVScsiIoReqAlloc The additional size for the request to allocate.
|
---|
493 | */
|
---|
494 | DECLINLINE(int) vscsiLunReqAllocSizeSet(PVSCSILUNINT pVScsiLun, size_t cbVScsiIoReqAlloc)
|
---|
495 | {
|
---|
496 | return pVScsiLun->pVScsiLunIoCallbacks->pfnVScsiLunReqAllocSizeSet(pVScsiLun,
|
---|
497 | pVScsiLun->pvVScsiLunUser,
|
---|
498 | cbVScsiIoReqAlloc);
|
---|
499 | }
|
---|
500 |
|
---|
501 | /**
|
---|
502 | * Wrapper for the allocate I/O request I/O callback.
|
---|
503 | *
|
---|
504 | * @returns VBox status code.
|
---|
505 | * @param pVScsiLun The LUN.
|
---|
506 | * @param u64Tag A unique tag to assign to the request.
|
---|
507 | * @param ppVScsiIoReq Where to store the pointer to the request on success.
|
---|
508 | */
|
---|
509 | DECLINLINE(int) vscsiLunReqAlloc(PVSCSILUNINT pVScsiLun, uint64_t u64Tag, PVSCSIIOREQINT *ppVScsiIoReq)
|
---|
510 | {
|
---|
511 | return pVScsiLun->pVScsiLunIoCallbacks->pfnVScsiLunReqAlloc(pVScsiLun,
|
---|
512 | pVScsiLun->pvVScsiLunUser,
|
---|
513 | u64Tag, ppVScsiIoReq);
|
---|
514 | }
|
---|
515 |
|
---|
516 | /**
|
---|
517 | * Wrapper for the free I/O request I/O callback.
|
---|
518 | *
|
---|
519 | * @returns VBox status code.
|
---|
520 | * @param pVScsiLun The LUN.
|
---|
521 | * @param pVScsiIoReq The request to free.
|
---|
522 | */
|
---|
523 | DECLINLINE(int) vscsiLunReqFree(PVSCSILUNINT pVScsiLun, PVSCSIIOREQINT pVScsiIoReq)
|
---|
524 | {
|
---|
525 | return pVScsiLun->pVScsiLunIoCallbacks->pfnVScsiLunReqFree(pVScsiLun,
|
---|
526 | pVScsiLun->pvVScsiLunUser,
|
---|
527 | pVScsiIoReq);
|
---|
528 | }
|
---|
529 |
|
---|
530 | /**
|
---|
531 | * Wrapper for the get medium size I/O callback.
|
---|
532 | *
|
---|
533 | * @returns VBox status code.
|
---|
534 | * @param pVScsiLun The LUN.
|
---|
535 | * @param pcbSize Where to store the size on success.
|
---|
536 | */
|
---|
537 | DECLINLINE(int) vscsiLunMediumGetSize(PVSCSILUNINT pVScsiLun, uint64_t *pcbSize)
|
---|
538 | {
|
---|
539 | return pVScsiLun->pVScsiLunIoCallbacks->pfnVScsiLunMediumGetSize(pVScsiLun,
|
---|
540 | pVScsiLun->pvVScsiLunUser,
|
---|
541 | pcbSize);
|
---|
542 | }
|
---|
543 |
|
---|
544 | /**
|
---|
545 | * Wrapper for the get medium sector size I/O callback.
|
---|
546 | *
|
---|
547 | * @returns VBox status code.
|
---|
548 | * @param pVScsiLun The LUN.
|
---|
549 | * @param pcbSectorSize Where to store the sector size on success.
|
---|
550 | */
|
---|
551 | DECLINLINE(int) vscsiLunMediumGetSectorSize(PVSCSILUNINT pVScsiLun, uint32_t *pcbSectorSize)
|
---|
552 | {
|
---|
553 | return pVScsiLun->pVScsiLunIoCallbacks->pfnVScsiLunMediumGetSectorSize(pVScsiLun,
|
---|
554 | pVScsiLun->pvVScsiLunUser,
|
---|
555 | pcbSectorSize);
|
---|
556 | }
|
---|
557 |
|
---|
558 | /**
|
---|
559 | * Wrapper for the get medium lock/unlock I/O callback.
|
---|
560 | *
|
---|
561 | * @returns VBox status code.
|
---|
562 | * @param pVScsiLun The LUN.
|
---|
563 | * @param bool The new medium lock state.
|
---|
564 | */
|
---|
565 | DECLINLINE(int) vscsiLunMediumSetLock(PVSCSILUNINT pVScsiLun, bool fLocked)
|
---|
566 | {
|
---|
567 | return pVScsiLun->pVScsiLunIoCallbacks->pfnVScsiLunMediumSetLock(pVScsiLun,
|
---|
568 | pVScsiLun->pvVScsiLunUser,
|
---|
569 | fLocked);
|
---|
570 | }
|
---|
571 |
|
---|
572 | /**
|
---|
573 | * Wrapper for the eject medium I/O callback.
|
---|
574 | *
|
---|
575 | * @returns VBox status code.
|
---|
576 | * @param pVScsiLun The LUN.
|
---|
577 | */
|
---|
578 | DECLINLINE(int) vscsiLunMediumEject(PVSCSILUNINT pVScsiLun)
|
---|
579 | {
|
---|
580 | return pVScsiLun->pVScsiLunIoCallbacks->pfnVScsiLunMediumEject(pVScsiLun,
|
---|
581 | pVScsiLun->pvVScsiLunUser);
|
---|
582 | }
|
---|
583 |
|
---|
584 | /**
|
---|
585 | * Wrapper for the I/O request enqueue I/O callback.
|
---|
586 | *
|
---|
587 | * @returns VBox status code.
|
---|
588 | * @param pVScsiLun The LUN.
|
---|
589 | * @param pVScsiIoReq The I/O request to enqueue.
|
---|
590 | */
|
---|
591 | DECLINLINE(int) vscsiLunReqTransferEnqueue(PVSCSILUNINT pVScsiLun, PVSCSIIOREQINT pVScsiIoReq)
|
---|
592 | {
|
---|
593 | return pVScsiLun->pVScsiLunIoCallbacks->pfnVScsiLunReqTransferEnqueue(pVScsiLun,
|
---|
594 | pVScsiLun->pvVScsiLunUser,
|
---|
595 | pVScsiIoReq);
|
---|
596 | }
|
---|
597 |
|
---|
598 | /**
|
---|
599 | * Wrapper for the get feature flags I/O callback.
|
---|
600 | *
|
---|
601 | * @returns VBox status code.
|
---|
602 | * @param pVScsiLun The LUN.
|
---|
603 | * @param pVScsiIoReq The I/O request to enqueue.
|
---|
604 | */
|
---|
605 | DECLINLINE(int) vscsiLunGetFeatureFlags(PVSCSILUNINT pVScsiLun, uint64_t *pfFeatures)
|
---|
606 | {
|
---|
607 | return pVScsiLun->pVScsiLunIoCallbacks->pfnVScsiLunGetFeatureFlags(pVScsiLun,
|
---|
608 | pVScsiLun->pvVScsiLunUser,
|
---|
609 | pfFeatures);
|
---|
610 | }
|
---|
611 |
|
---|
612 | /**
|
---|
613 | * Wrapper around vscsiReqSenseOkSet()
|
---|
614 | */
|
---|
615 | DECLINLINE(int) vscsiLunReqSenseOkSet(PVSCSILUNINT pVScsiLun, PVSCSIREQINT pVScsiReq)
|
---|
616 | {
|
---|
617 | return vscsiReqSenseOkSet(&pVScsiLun->pVScsiDevice->VScsiSense, pVScsiReq);
|
---|
618 | }
|
---|
619 |
|
---|
620 | /**
|
---|
621 | * Wrapper around vscsiReqSenseErrorSet()
|
---|
622 | */
|
---|
623 | DECLINLINE(int) vscsiLunReqSenseErrorSet(PVSCSILUNINT pVScsiLun, PVSCSIREQINT pVScsiReq, uint8_t uSCSISenseKey, uint8_t uSCSIASC, uint8_t uSCSIASCQ)
|
---|
624 | {
|
---|
625 | return vscsiReqSenseErrorSet(&pVScsiLun->pVScsiDevice->VScsiSense, pVScsiReq, uSCSISenseKey, uSCSIASC, uSCSIASCQ);
|
---|
626 | }
|
---|
627 |
|
---|
628 | /**
|
---|
629 | * Wrapper around vscsiReqSenseErrorInfoSet()
|
---|
630 | */
|
---|
631 | DECLINLINE(int) vscsiLunReqSenseErrorInfoSet(PVSCSILUNINT pVScsiLun, PVSCSIREQINT pVScsiReq, uint8_t uSCSISenseKey, uint8_t uSCSIASC, uint8_t uSCSIASCQ, uint32_t uInfo)
|
---|
632 | {
|
---|
633 | return vscsiReqSenseErrorInfoSet(&pVScsiLun->pVScsiDevice->VScsiSense, pVScsiReq, uSCSISenseKey, uSCSIASC, uSCSIASCQ, uInfo);
|
---|
634 | }
|
---|
635 |
|
---|
636 | #endif /* ___VSCSIInternal_h */
|
---|
637 |
|
---|