fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
83bf661f7a0eb06268ce891fcad997e6a39830d8duo liu - Sun Microsystems - Beijing China * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
83bf661f7a0eb06268ce891fcad997e6a39830d8duo liu - Sun Microsystems - Beijing ChinagetAdapterPortWWN(HBA_HANDLE handle,HBA_UINT32 index) {
83bf661f7a0eb06268ce891fcad997e6a39830d8duo liu - Sun Microsystems - Beijing China HBAPort *port = hba->getPortByIndex(index);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) { }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @memo Retrieves the mapping between FCP targets and OS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * SCSI information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return HBA_STATUS_OK if the mapping structure contains valid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mapping data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param handle The HBA to fetch mappings for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param mapping The user-allocated mapping structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @doc This routine will call the V2 interface and convert
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the results to the old data structure. It will
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * call the V2 interface for all ports on the HBA.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteSun_fcGetFcpTargetMapping(HBA_HANDLE handle, PHBA_FCPTARGETMAPPING mapping) {
83bf661f7a0eb06268ce891fcad997e6a39830d8duo liu - Sun Microsystems - Beijing China HBA_ADAPTERATTRIBUTES attributes;
352290fbea989358b5153ef1750fc3c3fcdca668duo liu - Sun Microsystems - Beijing China HBA_UINT32 entries = 0;
83bf661f7a0eb06268ce891fcad997e6a39830d8duo liu - Sun Microsystems - Beijing China HBA_UINT32 current = 0;
83bf661f7a0eb06268ce891fcad997e6a39830d8duo liu - Sun Microsystems - Beijing China HBA_UINT32 limit;
352290fbea989358b5153ef1750fc3c3fcdca668duo liu - Sun Microsystems - Beijing China entries = mapping->NumberOfEntries;
83bf661f7a0eb06268ce891fcad997e6a39830d8duo liu - Sun Microsystems - Beijing China /* get adapter attributes for number of ports */
83bf661f7a0eb06268ce891fcad997e6a39830d8duo liu - Sun Microsystems - Beijing China status = Sun_fcGetAdapterAttributes(handle,&attributes);
83bf661f7a0eb06268ce891fcad997e6a39830d8duo liu - Sun Microsystems - Beijing China if (status != HBA_STATUS_OK) {
83bf661f7a0eb06268ce891fcad997e6a39830d8duo liu - Sun Microsystems - Beijing China log.userError("Unable to get adapter attributes");
83bf661f7a0eb06268ce891fcad997e6a39830d8duo liu - Sun Microsystems - Beijing China return HBA_STATUS_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mappingV2 = (PHBA_FCPTARGETMAPPINGV2) new uchar_t[
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (sizeof (HBA_FCPSCSIENTRYV2)*(mapping->NumberOfEntries-1)) +
83bf661f7a0eb06268ce891fcad997e6a39830d8duo liu - Sun Microsystems - Beijing China mapping->NumberOfEntries = 0;
83bf661f7a0eb06268ce891fcad997e6a39830d8duo liu - Sun Microsystems - Beijing China for(port = 0; port < attributes.NumberOfPorts; port++) {
83bf661f7a0eb06268ce891fcad997e6a39830d8duo liu - Sun Microsystems - Beijing China mappingV2->NumberOfEntries = mapping->NumberOfEntries < entries ?
83bf661f7a0eb06268ce891fcad997e6a39830d8duo liu - Sun Microsystems - Beijing China entries - mapping->NumberOfEntries : 0 ;
83bf661f7a0eb06268ce891fcad997e6a39830d8duo liu - Sun Microsystems - Beijing China status = Sun_fcGetFcpTargetMappingV2(handle,
83bf661f7a0eb06268ce891fcad997e6a39830d8duo liu - Sun Microsystems - Beijing China getAdapterPortWWN(handle,port), mappingV2);
83bf661f7a0eb06268ce891fcad997e6a39830d8duo liu - Sun Microsystems - Beijing China mapping->NumberOfEntries += mappingV2->NumberOfEntries;
83bf661f7a0eb06268ce891fcad997e6a39830d8duo liu - Sun Microsystems - Beijing China if (status != HBA_STATUS_OK && status != HBA_STATUS_ERROR_MORE_DATA) {
83bf661f7a0eb06268ce891fcad997e6a39830d8duo liu - Sun Microsystems - Beijing China log.userError("Unable to get mappings for port");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * need to copy from PHBA_FCPTARGETMAPPINGV2 to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * PHBA_FCPTARGETMAPPING
83bf661f7a0eb06268ce891fcad997e6a39830d8duo liu - Sun Microsystems - Beijing China limit = (mapping->NumberOfEntries < entries) ? mapping->NumberOfEntries : entries;
83bf661f7a0eb06268ce891fcad997e6a39830d8duo liu - Sun Microsystems - Beijing China for (count = current; count < limit; count++) {
83bf661f7a0eb06268ce891fcad997e6a39830d8duo liu - Sun Microsystems - Beijing China &mappingV2->entry[count-current].ScsiId,
83bf661f7a0eb06268ce891fcad997e6a39830d8duo liu - Sun Microsystems - Beijing China &mappingV2->entry[count-current].FcpId,