VirtualBox

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

Last change on this file since 96407 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 25.5 KB
Line 
1/* $Id: VSCSIInternal.h 96407 2022-08-22 17:43:14Z vboxsync $ */
2/** @file
3 * Virtual SCSI driver: Internal defines
4 */
5
6/*
7 * Copyright (C) 2006-2022 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 * @returns nothing.
324 * @param pVScsiDevice The virtual SCSI device.
325 * @param pVScsiReq The request which completed.
326 * @param rcScsiCode The status code
327 * One of the SCSI_STATUS_* #defines.
328 * @param fRedoPossible Flag whether redo is possible.
329 * @param rcReq Informational return code of the request.
330 */
331void vscsiDeviceReqComplete(PVSCSIDEVICEINT pVScsiDevice, PVSCSIREQINT pVScsiReq,
332 int rcScsiCode, bool fRedoPossible, int rcReq);
333
334/**
335 * Init the sense data state.
336 *
337 * @returns nothing.
338 * @param pVScsiSense The SCSI sense data state to init.
339 */
340void vscsiSenseInit(PVSCSISENSE pVScsiSense);
341
342/**
343 * Sets a ok sense code.
344 *
345 * @returns SCSI status code.
346 * @param pVScsiSense The SCSI sense state to use.
347 * @param pVScsiReq The SCSI request.
348 */
349int vscsiReqSenseOkSet(PVSCSISENSE pVScsiSense, PVSCSIREQINT pVScsiReq);
350
351/**
352 * Sets an error sense code.
353 *
354 * @returns SCSI status code.
355 * @param pVScsiSense The SCSI sense state to use.
356 * @param pVScsiReq The SCSI request.
357 * @param uSCSISenseKey The SCSI sense key to set.
358 * @param uSCSIASC The ASC value.
359 * @param uSCSIASC The ASCQ value.
360 */
361int vscsiReqSenseErrorSet(PVSCSISENSE pVScsiSense, PVSCSIREQINT pVScsiReq, uint8_t uSCSISenseKey,
362 uint8_t uSCSIASC, uint8_t uSCSIASCQ);
363
364/**
365 * Sets an error sense code with additional information.
366 *
367 * @returns SCSI status code.
368 * @param pVScsiSense The SCSI sense state to use.
369 * @param pVScsiReq The SCSI request.
370 * @param uSCSISenseKey The SCSI sense key to set.
371 * @param uSCSIASC The ASC value.
372 * @param uSCSIASC The ASCQ value.
373 * @param uInfo The 32-bit sense information.
374 */
375int vscsiReqSenseErrorInfoSet(PVSCSISENSE pVScsiSense, PVSCSIREQINT pVScsiReq, uint8_t uSCSISenseKey,
376 uint8_t uSCSIASC, uint8_t uSCSIASCQ, uint32_t uInfo);
377
378/**
379 * Process a request sense command.
380 *
381 * @returns SCSI status code.
382 * @param pVScsiSense The SCSI sense state to use.
383 * @param pVScsiReq The SCSI request.
384 */
385int vscsiReqSenseCmd(PVSCSISENSE pVScsiSense, PVSCSIREQINT pVScsiReq);
386
387/**
388 * Inits the VPD page pool.
389 *
390 * @returns VBox status code.
391 * @param pVScsiVpdPool The VPD page pool to initialize.
392 */
393int vscsiVpdPagePoolInit(PVSCSIVPDPOOL pVScsiVpdPool);
394
395/**
396 * Destroys the given VPD page pool freeing all pages in it.
397 *
398 * @returns nothing.
399 * @param pVScsiVpdPool The VPD page pool to destroy.
400 */
401void vscsiVpdPagePoolDestroy(PVSCSIVPDPOOL pVScsiVpdPool);
402
403/**
404 * Allocates a new page in the VPD page pool with the given number.
405 *
406 * @returns VBox status code.
407 * @retval VERR_ALREADY_EXIST if the page number is in use.
408 * @param pVScsiVpdPool The VPD page pool the page will belong to.
409 * @param uPage The page number, must be unique.
410 * @param cbPage Size of the page in bytes.
411 * @param ppbPage Where to store the pointer to the raw page data on success.
412 */
413int vscsiVpdPagePoolAllocNewPage(PVSCSIVPDPOOL pVScsiVpdPool, uint8_t uPage, size_t cbPage, uint8_t **ppbPage);
414
415/**
416 * Queries the given page from the pool and cpies it to the buffer given
417 * by the SCSI request.
418 *
419 * @returns VBox status code.
420 * @retval VERR_NOT_FOUND if the page is not in the pool.
421 * @param pVScsiVpdPool The VPD page pool to use.
422 * @param pVScsiReq The SCSI request.
423 * @param uPage Page to query.
424 */
425int vscsiVpdPagePoolQueryPage(PVSCSIVPDPOOL pVScsiVpdPool, PVSCSIREQINT pVScsiReq, uint8_t uPage);
426
427/**
428 * Inits the I/O request related state for the LUN.
429 *
430 * @returns VBox status code.
431 * @param pVScsiLun The LUN instance.
432 */
433int vscsiIoReqInit(PVSCSILUNINT pVScsiLun);
434
435/**
436 * Enqueues a new flush request
437 *
438 * @returns VBox status code.
439 * @param pVScsiLun The LUN instance which issued the request.
440 * @param pVScsiReq The virtual SCSI request associated with the flush.
441 */
442int vscsiIoReqFlushEnqueue(PVSCSILUNINT pVScsiLun, PVSCSIREQINT pVScsiReq);
443
444/**
445 * Enqueue a new data transfer request.
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 cbTransfer Number of bytes to transfer.
453 */
454int vscsiIoReqTransferEnqueue(PVSCSILUNINT pVScsiLun, PVSCSIREQINT pVScsiReq,
455 VSCSIIOREQTXDIR enmTxDir, uint64_t uOffset,
456 size_t cbTransfer);
457
458/**
459 * Enqueue a new data transfer request - extended variant.
460 *
461 * @returns VBox status code.
462 * @param pVScsiLun The LUN instance which issued the request.
463 * @param pVScsiReq The virtual SCSI request associated with the transfer.
464 * @param enmTxDir Transfer direction.
465 * @param uOffset Start offset of the transfer.
466 * @param paSegs Pointer to the array holding the memory buffer segments.
467 * @param cSegs Number of segments in the array.
468 * @param cbTransfer Number of bytes to transfer.
469 */
470int vscsiIoReqTransferEnqueueEx(PVSCSILUNINT pVScsiLun, PVSCSIREQINT pVScsiReq,
471 VSCSIIOREQTXDIR enmTxDir, uint64_t uOffset,
472 PCRTSGSEG paSegs, unsigned cSegs, size_t cbTransfer);
473
474/**
475 * Enqueue a new unmap request.
476 *
477 * @returns VBox status code.
478 * @param pVScsiLun The LUN instance which issued the request.
479 * @param pVScsiReq The virtual SCSI request associated with the transfer.
480 * @param paRanges The array of ranges to unmap.
481 * @param cRanges Number of ranges in the array.
482 */
483int vscsiIoReqUnmapEnqueue(PVSCSILUNINT pVScsiLun, PVSCSIREQINT pVScsiReq,
484 PRTRANGE paRanges, unsigned cRanges);
485
486/**
487 * Returns the current number of outstanding tasks on the given LUN.
488 *
489 * @returns Number of outstanding tasks.
490 * @param pVScsiLun The LUN to check.
491 */
492uint32_t vscsiIoReqOutstandingCountGet(PVSCSILUNINT pVScsiLun);
493
494/**
495 * Sets the transfer size for the given request.
496 *
497 * @returns nothing.
498 * @param pVScsiReq The SCSI request.
499 * @param cbXfer The transfer size for the request.
500 */
501DECLINLINE(void) vscsiReqSetXferSize(PVSCSIREQINT pVScsiReq, size_t cbXfer)
502{
503 pVScsiReq->cbXfer = cbXfer;
504}
505
506/**
507 * Sets the transfer direction for the given request.
508 *
509 * @returns nothing.
510 * @param pVScsiReq The SCSI request.
511 * @param cbXfer The transfer size for the request.
512 */
513DECLINLINE(void) vscsiReqSetXferDir(PVSCSIREQINT pVScsiReq, VSCSIXFERDIR enmXferDir)
514{
515 pVScsiReq->enmXferDir = enmXferDir;
516}
517
518/**
519 * Wrapper for the set I/O request allocation size I/O callback.
520 *
521 * @returns VBox status code.
522 * @param pVScsiLun The LUN.
523 * @param cbVScsiIoReqAlloc The additional size for the request to allocate.
524 */
525DECLINLINE(int) vscsiLunReqAllocSizeSet(PVSCSILUNINT pVScsiLun, size_t cbVScsiIoReqAlloc)
526{
527 return pVScsiLun->pVScsiLunIoCallbacks->pfnVScsiLunReqAllocSizeSet(pVScsiLun,
528 pVScsiLun->pvVScsiLunUser,
529 cbVScsiIoReqAlloc);
530}
531
532/**
533 * Wrapper for the allocate I/O request I/O callback.
534 *
535 * @returns VBox status code.
536 * @param pVScsiLun The LUN.
537 * @param u64Tag A unique tag to assign to the request.
538 * @param ppVScsiIoReq Where to store the pointer to the request on success.
539 */
540DECLINLINE(int) vscsiLunReqAlloc(PVSCSILUNINT pVScsiLun, uint64_t u64Tag, PVSCSIIOREQINT *ppVScsiIoReq)
541{
542 return pVScsiLun->pVScsiLunIoCallbacks->pfnVScsiLunReqAlloc(pVScsiLun,
543 pVScsiLun->pvVScsiLunUser,
544 u64Tag, ppVScsiIoReq);
545}
546
547/**
548 * Wrapper for the free I/O request I/O callback.
549 *
550 * @returns VBox status code.
551 * @param pVScsiLun The LUN.
552 * @param pVScsiIoReq The request to free.
553 */
554DECLINLINE(int) vscsiLunReqFree(PVSCSILUNINT pVScsiLun, PVSCSIIOREQINT pVScsiIoReq)
555{
556 return pVScsiLun->pVScsiLunIoCallbacks->pfnVScsiLunReqFree(pVScsiLun,
557 pVScsiLun->pvVScsiLunUser,
558 pVScsiIoReq);
559}
560
561/**
562 * Wrapper for the get medium region count I/O callback.
563 *
564 * @returns Number of regions for the underlying medium.
565 * @param pVScsiLun The LUN.
566 */
567DECLINLINE(uint32_t) vscsiLunMediumGetRegionCount(PVSCSILUNINT pVScsiLun)
568{
569 return pVScsiLun->pVScsiLunIoCallbacks->pfnVScsiLunMediumGetRegionCount(pVScsiLun,
570 pVScsiLun->pvVScsiLunUser);
571}
572
573/**
574 * Wrapper for the query medium region properties I/O callback.
575 *
576 * @returns VBox status code.
577 * @param pVScsiLun The LUN.
578 * @param uRegion The region index to query the properties of.
579 * @param pu64LbaStart Where to store the starting LBA for the region on success.
580 * @param pcBlocks Where to store the number of blocks for the region on success.
581 * @param pcbBlock Where to store the size of one block in bytes on success.
582 * @param penmDataForm WHere to store the data form for the region on success.
583 */
584DECLINLINE(int) vscsiLunMediumQueryRegionProperties(PVSCSILUNINT pVScsiLun, uint32_t uRegion,
585 uint64_t *pu64LbaStart, uint64_t *pcBlocks,
586 uint64_t *pcbBlock, PVDREGIONDATAFORM penmDataForm)
587{
588 return pVScsiLun->pVScsiLunIoCallbacks->pfnVScsiLunMediumQueryRegionProperties(pVScsiLun,
589 pVScsiLun->pvVScsiLunUser,
590 uRegion, pu64LbaStart,
591 pcBlocks, pcbBlock,
592 penmDataForm);
593}
594
595/**
596 * Wrapper for the query medium region properties for LBA I/O callback.
597 *
598 * @returns VBox status code.
599 * @param pVScsiLun The LUN.
600 * @param uRegion The region index to query the properties of.
601 * @param pu64LbaStart Where to store the starting LBA for the region on success.
602 * @param pcBlocks Where to store the number of blocks for the region on success.
603 * @param pcbBlock Where to store the size of one block in bytes on success.
604 * @param penmDataForm WHere to store the data form for the region on success.
605 */
606DECLINLINE(int) vscsiLunMediumQueryRegionPropertiesForLba(PVSCSILUNINT pVScsiLun, uint64_t u64LbaStart, uint32_t *puRegion,
607 uint64_t *pcBlocks, uint64_t *pcbBlock,
608 PVDREGIONDATAFORM penmDataForm)
609{
610 return pVScsiLun->pVScsiLunIoCallbacks->pfnVScsiLunMediumQueryRegionPropertiesForLba(pVScsiLun,
611 pVScsiLun->pvVScsiLunUser,
612 u64LbaStart, puRegion,
613 pcBlocks, pcbBlock,
614 penmDataForm);
615}
616
617/**
618 * Wrapper for the get medium lock/unlock I/O callback.
619 *
620 * @returns VBox status code.
621 * @param pVScsiLun The LUN.
622 * @param bool The new medium lock state.
623 */
624DECLINLINE(int) vscsiLunMediumSetLock(PVSCSILUNINT pVScsiLun, bool fLocked)
625{
626 return pVScsiLun->pVScsiLunIoCallbacks->pfnVScsiLunMediumSetLock(pVScsiLun,
627 pVScsiLun->pvVScsiLunUser,
628 fLocked);
629}
630
631/**
632 * Wrapper for the eject medium I/O callback.
633 *
634 * @returns VBox status code.
635 * @param pVScsiLun The LUN.
636 */
637DECLINLINE(int) vscsiLunMediumEject(PVSCSILUNINT pVScsiLun)
638{
639 return pVScsiLun->pVScsiLunIoCallbacks->pfnVScsiLunMediumEject(pVScsiLun,
640 pVScsiLun->pvVScsiLunUser);
641}
642
643/**
644 * Wrapper for the I/O request enqueue I/O callback.
645 *
646 * @returns VBox status code.
647 * @param pVScsiLun The LUN.
648 * @param pVScsiIoReq The I/O request to enqueue.
649 */
650DECLINLINE(int) vscsiLunReqTransferEnqueue(PVSCSILUNINT pVScsiLun, PVSCSIIOREQINT pVScsiIoReq)
651{
652 return pVScsiLun->pVScsiLunIoCallbacks->pfnVScsiLunReqTransferEnqueue(pVScsiLun,
653 pVScsiLun->pvVScsiLunUser,
654 pVScsiIoReq);
655}
656
657/**
658 * Wrapper for the get feature flags I/O callback.
659 *
660 * @returns VBox status code.
661 * @param pVScsiLun The LUN.
662 * @param pfFeatures Where to sthre supported flags on success.
663 */
664DECLINLINE(int) vscsiLunGetFeatureFlags(PVSCSILUNINT pVScsiLun, uint64_t *pfFeatures)
665{
666 return pVScsiLun->pVScsiLunIoCallbacks->pfnVScsiLunGetFeatureFlags(pVScsiLun,
667 pVScsiLun->pvVScsiLunUser,
668 pfFeatures);
669}
670
671/**
672 * Wrapper for the query INQUIRY strings I/O callback.
673 *
674 * @returns VBox status code.
675 * @param pVScsiLun The LUN.
676 * @param ppszVendorId Where to store the pointer to the vendor ID string to report.
677 * @param ppszProductId Where to store the pointer to the product ID string to report.
678 * @param ppszProductLevel Where to store the pointer to the revision string to report.
679 */
680DECLINLINE(int) vscsiLunQueryInqStrings(PVSCSILUNINT pVScsiLun, const char **ppszVendorId,
681 const char **ppszProductId, const char **ppszProductLevel)
682{
683 if (pVScsiLun->pVScsiLunIoCallbacks->pfnVScsiLunQueryInqStrings)
684 {
685 return pVScsiLun->pVScsiLunIoCallbacks->pfnVScsiLunQueryInqStrings(pVScsiLun,
686 pVScsiLun->pvVScsiLunUser,
687 ppszVendorId, ppszProductId,
688 ppszProductLevel);
689 }
690
691 return VERR_NOT_FOUND;
692}
693
694/**
695 * Wrapper around vscsiReqSenseOkSet()
696 */
697DECLINLINE(int) vscsiLunReqSenseOkSet(PVSCSILUNINT pVScsiLun, PVSCSIREQINT pVScsiReq)
698{
699 return vscsiReqSenseOkSet(&pVScsiLun->pVScsiDevice->VScsiSense, pVScsiReq);
700}
701
702/**
703 * Wrapper around vscsiReqSenseErrorSet()
704 */
705DECLINLINE(int) vscsiLunReqSenseErrorSet(PVSCSILUNINT pVScsiLun, PVSCSIREQINT pVScsiReq, uint8_t uSCSISenseKey, uint8_t uSCSIASC, uint8_t uSCSIASCQ)
706{
707 return vscsiReqSenseErrorSet(&pVScsiLun->pVScsiDevice->VScsiSense, pVScsiReq, uSCSISenseKey, uSCSIASC, uSCSIASCQ);
708}
709
710/**
711 * Wrapper around vscsiReqSenseErrorInfoSet()
712 */
713DECLINLINE(int) vscsiLunReqSenseErrorInfoSet(PVSCSILUNINT pVScsiLun, PVSCSIREQINT pVScsiReq, uint8_t uSCSISenseKey, uint8_t uSCSIASC, uint8_t uSCSIASCQ, uint32_t uInfo)
714{
715 return vscsiReqSenseErrorInfoSet(&pVScsiLun->pVScsiDevice->VScsiSense, pVScsiReq, uSCSISenseKey, uSCSIASC, uSCSIASCQ, uInfo);
716}
717
718#endif /* !VBOX_INCLUDED_SRC_Storage_VSCSI_VSCSIInternal_h */
719
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