4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
32 #include "Exceptions.h"
36 #define BUSY_SLEEP 1000000 /* 1/100 second */
37 #define BUSY_RETRY_TIMER 5000000000ULL /* Retry for 5 seconds */
43 * @memo Send a SCSI inquiry to a remote WWN
44 * @return HBA_STATUS_OK or other error code
45 * scsiStatus should be checked to ensure SCSI command
47 * @param handle The HBA to operate on
48 * @param portWWN Indicates the HBA port to send command through
49 * @param targetPortWWN Indicates the target to send command to
50 * @param fcLun Indicates the target unit to send command to
51 * @param cdb1 The first CDB byte
52 * @param cdb2 The second CDB byte
53 * @param responseBuffer User-allocated response buffer
54 * @param responseSize Size of User-allocated response buffer
55 * @param scsiStatus User-allocated scsi status byte
57 * @doc This routine will attempt a limited number of retries
58 * When busy or again errors are encountered.
61 Sun_fcScsiInquiryV2(HBA_HANDLE handle
, HBA_WWN portWWN
, HBA_WWN targetPortWWN
,
62 HBA_UINT64 fcLun
, HBA_UINT8 cdb1
, HBA_UINT8 cdb2
,
63 void *responseBuffer
, HBA_UINT32
*responseSize
,
64 HBA_UINT8
*scsiStatus
,
65 void *senseBuffer
, HBA_UINT32
*senseSize
) {
66 Trace
log("Sun_fcScsiInquiryV2");
68 hrtime_t start
= gethrtime();
69 hrtime_t end
= start
+ BUSY_RETRY_TIMER
;
70 for (hrtime_t cur
= start
; cur
< end
; cur
= gethrtime()) {
72 Handle
*myHandle
= Handle::findHandle(handle
);
73 HBA
*hba
= myHandle
->getHBA();
74 HBAPort
*port
= hba
->getPort(wwnConversion(portWWN
.wwn
));
76 port
->sendScsiInquiry(wwnConversion(targetPortWWN
.wwn
), fcLun
,
77 cdb1
, cdb2
, responseBuffer
, responseSize
,
78 scsiStatus
, senseBuffer
, senseSize
);
79 return (HBA_STATUS_OK
);
80 } catch (BusyException
&e
) {
83 } catch (TryAgainException
&e
) {
86 } catch (HBAException
&e
) {
87 return (e
.getErrorCode());
90 "Uncaught exception");
91 return (HBA_STATUS_ERROR
);