VirtualBox

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

Last change on this file since 100942 was 99739, checked in by vboxsync, 21 months ago

*: doxygen corrections (mostly about removing @returns from functions returning void).

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