VirtualBox

source: vbox/trunk/src/VBox/Devices/Storage/VSCSI/VSCSIInternal.h@ 76553

Last change on this file since 76553 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette