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.
31 #include "Exceptions.h"
35 #define BUSY_SLEEP 10000 /* 1/10 second */
36 #define BUSY_RETRY_TIMER 5000000000ULL /* Retry for 5 seconds */
42 * @memo Send a SCSI report luns command to a remote WWN
43 * @return HBA_STATUS_OK or other error code
44 * scsiStatus should be checked to ensure SCSI command
46 * @param handle The HBA to operate on
47 * @param portWWN Indicates the HBA port to send command through
48 * @param targetPortWWN Indicates the target to send command to
49 * @param responseBuffer User-allocated response buffer
50 * @param responseSize Size of User-allocated response buffer
51 * @param scsiStatus User-allocated scsi status byte
53 * @doc This routine will attempt a limited number of retries
54 * When busy or again errors are encountered.
56 HBA_STATUS
Sun_fcScsiReportLUNsV2(HBA_HANDLE handle
, HBA_WWN portWWN
,
57 HBA_WWN targetPortWWN
,
58 void *responseBuffer
, HBA_UINT32
*responseSize
,
59 HBA_UINT8
*scsiStatus
,
60 void *senseBuffer
, HBA_UINT32
*senseSize
) {
61 Trace
log("Sun_fcScsiReportLUNsV2");
63 HBA_STATUS status
= HBA_STATUS_OK
;
65 hrtime_t start
= gethrtime();
66 hrtime_t end
= start
+ BUSY_RETRY_TIMER
;
67 for (hrtime_t cur
= start
; cur
< end
; cur
= gethrtime()) {
69 Handle
*myHandle
= Handle::findHandle(handle
);
70 HBA
*hba
= myHandle
->getHBA();
71 HBAPort
*port
= hba
->getPort(wwnConversion(portWWN
.wwn
));
72 port
->sendReportLUNs(wwnConversion(targetPortWWN
.wwn
),
73 responseBuffer
, responseSize
, scsiStatus
,
74 senseBuffer
, senseSize
);
75 return (HBA_STATUS_OK
);
76 } catch (BusyException
&e
) {
78 status
= HBA_STATUS_ERROR_BUSY
;
80 } catch (TryAgainException
&e
) {
82 status
= HBA_STATUS_ERROR_TRY_AGAIN
;
84 } catch (HBAException
&e
) {
85 return (e
.getErrorCode());
88 "Uncaught exception");
89 return (HBA_STATUS_ERROR
);