xref: /illumos-gate/usr/src/lib/sun_fc/common/Sun_fcGetFcpTargetMappingV2.cc (revision e4d060fb4c00d44cd578713eb9a921f594b733b8)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 
27 
28 #include "Handle.h"
29 #include "HBA.h"
30 #include "HBAPort.h"
31 #include "Trace.h"
32 #include "Exceptions.h"
33 #include "sun_fc.h"
34 #include <sys/types.h>
35 #include <sys/mkdev.h>
36 #include <sys/stat.h>
37 #include <fcntl.h>
38 #include <unistd.h>
39 #include <stropts.h>
40 #ifdef	__cplusplus
41 extern "C" {
42 #endif
43 
44 /**
45  * @memo	    Retrieves the mapping between FCP targets and OS
46  *		    SCSI information
47  * @return	    HBA_STATUS_OK if userMappings contains valid response data
48  * @return	    HBA_STATUS_ERROR if an error was encountered.  The
49  *		    contents of userMappings is undefined
50  * @param	    handle The HBA to fetch mappings on
51  * @param	    portWWN The HBA Port to fetch mappings on
52  * @param	    userMappings a pre-allocated user structure to store
53  *		    the mappings within.  NumberOfEntries must be set
54  *		    to indicate the size of the allocated buffer.
55  *
56  */
57 HBA_STATUS Sun_fcGetFcpTargetMappingV2(HBA_HANDLE handle, HBA_WWN portWWN,
58 	    PHBA_FCPTARGETMAPPINGV2 userMappings) {
59 	Trace log("Sun_fcGetFcpTargetMappingV2");
60 
61 	try {
62 	    Handle *myHandle = Handle::findHandle(handle);
63 	    HBA *hba = myHandle->getHBA();
64 	    HBAPort *port = hba->getPort(wwnConversion(portWWN.wwn));
65 	    port->getTargetMappings(userMappings);
66 	    return (HBA_STATUS_OK);
67 	} catch (HBAException &e) {
68 	    return (e.getErrorCode());
69 	} catch (...) {
70 	    log.internalError(
71 		"Uncaught exception");
72 	    return (HBA_STATUS_ERROR);
73 	}
74 }
75 #ifdef	__cplusplus
76 }
77 #endif
78