fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
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 *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
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 *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef _FCINFO_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _FCINFO_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern "C" {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdlib.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <string.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <libintl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <hbaapi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <hbaapi-sun.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <unistd.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/scsi/scsi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/fibre-channel/fcio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <netinet/in.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <inttypes.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <cmdparse.h>
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang#include <locale.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef _BIG_ENDIAN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define htonll(x) (x)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ntohll(x) (x)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define htonll(x) ((((unsigned long long)htonl(x)) << 32) + htonl(x >> 32))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ntohll(x) ((((unsigned long long)ntohl(x)) << 32) + ntohl(x >> 32))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* DEFINES */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* SCSI TARGET TYPES */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SCSI_TARGET_TYPE_UNKNOWN 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SCSI_TARGET_TYPE_NO 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SCSI_TARGET_TYPE_YES 2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEFAULT_LUN_COUNT 1024
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define LUN_SIZE 8
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define LUN_HEADER_SIZE 8
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define LUN_LENGTH LUN_SIZE + LUN_HEADER_SIZE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEFAULT_LUN_LENGTH DEFAULT_LUN_COUNT * \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LUN_SIZE + \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LUN_HEADER_SIZE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define HBA_MAX_RETRIES 20
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PORT_LIST_ALLOC 100
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NPIV_PORT_LIST_LENGTH 255
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NPIV_ADD 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NPIV_REMOVE 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NPIV_SUCCESS 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NPIV_ERROR 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NPIV_ERROR_NOT_FOUND 2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NPIV_ERROR_EXISTS 3
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NPIV_ERROR_SERVICE_NOT_FOUND 4
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NPIV_ERROR_NOMEM 5
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NPIV_ERROR_MEMBER_NOT_FOUND 6
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NPIV_ERROR_BUSY 7
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NPIV_SERVICE "network/npiv_config"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NPIV_PG_NAME "npiv-port-list"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NPIV_PORT_LIST "port_list"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* flags that are needed to be passed into processHBA */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PRINT_LINKSTAT 0x00000001 /* print link statistics information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PRINT_SCSI_TARGET 0x00000010 /* print Scsi target information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PRINT_INITIATOR 0x00000100 /* print intiator port information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PRINT_TARGET 0x00001000 /* print target port information */
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang#define PRINT_FCOE 0x00010000 /* print fcoe port information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* flags for Adpater/port mode */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define INITIATOR_MODE 0x00000001
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define TARGET_MODE 0x00000010
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang/* FCOE */
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang#define FCOE_USER_RAW_FRAME_SIZE 224
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct _tgtPortWWNList {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN portWWN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 scsiOSLun;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct _tgtPortWWNList *next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} tgtPortWWNList;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct _portWWNList {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN portWWN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tgtPortWWNList *tgtPortWWN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct _portWWNList *next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} portWWNList;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Discovered ports structure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct _discoveredDevice {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char OSDeviceName[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portWWNList *HBAPortWWN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char VID[8];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char PID[16];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t inqSuccess;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t dType;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct _discoveredDevice *next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} discoveredDevice;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* globals */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char *cmdName;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* print helper functions */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid printHBAPortInfo(HBA_PORTATTRIBUTES *port,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTERATTRIBUTES *attrs, int mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid printDiscoPortInfo(HBA_PORTATTRIBUTES *discoPort, int scsiTargetType);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid printLUNInfo(struct scsi_inquiry *inq, HBA_UINT32 scsiLUN, char *devpath);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid printPortStat(fc_rls_acc_t *rls_payload);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid printScsiTarget(HBA_WWN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid printStatus(HBA_STATUS status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid printOSDeviceNameInfo(discoveredDevice *devListWalk, boolean_t verbose);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint64_t wwnConversion(uchar_t *wwn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint fc_util_list_hbaport(int wwnCount, char **wwn_argv, cmdOptions_t *options);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint fc_util_list_remoteport(int wwnCount, char **argv, cmdOptions_t *options);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint fc_util_list_logicalunit(int pathCount, char **argv, cmdOptions_t *options);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint fc_util_delete_npivport(int wwnCount, char **argv, cmdOptions_t *options);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint fc_util_create_npivport(int wwnCount, char **argv, cmdOptions_t *options);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint fc_util_create_portlist();
a79493184c9332129c9c91500069322f6f3fafddReedint fc_util_force_lip(int objects, char *argv[]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangint fcoe_adm_create_port(int objects, char *argv[],
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang cmdOptions_t *options);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangint fcoe_adm_delete_port(int objects, char *argv[]);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wangint fcoe_adm_list_ports(cmdOptions_t *options);
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang
2a8164df8a5f42c8a00f10c67d7bc84f80ae9c41Zhong Wang
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _FCINFO_H */