Path: blob/master/include/scsi/scsi_transport_fc.h
10820 views
/*1* FiberChannel transport specific attributes exported to sysfs.2*3* Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License as published by7* the Free Software Foundation; either version 2 of the License, or8* (at your option) any later version.9*10* This program is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13* GNU General Public License for more details.14*15* You should have received a copy of the GNU General Public License16* along with this program; if not, write to the Free Software17* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA18*19* ========20*21* Copyright (C) 2004-2007 James Smart, Emulex Corporation22* Rewrite for host, target, device, and remote port attributes,23* statistics, and service functions...24*25*/26#ifndef SCSI_TRANSPORT_FC_H27#define SCSI_TRANSPORT_FC_H2829#include <linux/sched.h>30#include <scsi/scsi.h>31#include <scsi/scsi_netlink.h>3233struct scsi_transport_template;3435/*36* FC Port definitions - Following FC HBAAPI guidelines37*38* Note: Not all binary values for the different fields match HBAAPI.39* Instead, we use densely packed ordinal values or enums.40* We get away with this as we never present the actual binary values41* externally. For sysfs, we always present the string that describes42* the value. Thus, an admin doesn't need a magic HBAAPI decoder ring43* to understand the values. The HBAAPI user-space library is free to44* convert the strings into the HBAAPI-specified binary values.45*46* Note: Not all HBAAPI-defined values are contained in the definitions47* below. Those not appropriate to an fc_host (e.g. FCP initiator) have48* been removed.49*/5051/*52* fc_port_type: If you alter this, you also need to alter scsi_transport_fc.c53* (for the ascii descriptions).54*/55enum fc_port_type {56FC_PORTTYPE_UNKNOWN,57FC_PORTTYPE_OTHER,58FC_PORTTYPE_NOTPRESENT,59FC_PORTTYPE_NPORT, /* Attached to FPort */60FC_PORTTYPE_NLPORT, /* (Public) Loop w/ FLPort */61FC_PORTTYPE_LPORT, /* (Private) Loop w/o FLPort */62FC_PORTTYPE_PTP, /* Point to Point w/ another NPort */63FC_PORTTYPE_NPIV, /* VPORT based on NPIV */64};656667/*68* fc_port_state: If you alter this, you also need to alter scsi_transport_fc.c69* (for the ascii descriptions).70*/71enum fc_port_state {72FC_PORTSTATE_UNKNOWN,73FC_PORTSTATE_NOTPRESENT,74FC_PORTSTATE_ONLINE,75FC_PORTSTATE_OFFLINE, /* User has taken Port Offline */76FC_PORTSTATE_BLOCKED,77FC_PORTSTATE_BYPASSED,78FC_PORTSTATE_DIAGNOSTICS,79FC_PORTSTATE_LINKDOWN,80FC_PORTSTATE_ERROR,81FC_PORTSTATE_LOOPBACK,82FC_PORTSTATE_DELETED,83};848586/*87* fc_vport_state: If you alter this, you also need to alter88* scsi_transport_fc.c (for the ascii descriptions).89*/90enum fc_vport_state {91FC_VPORT_UNKNOWN,92FC_VPORT_ACTIVE,93FC_VPORT_DISABLED,94FC_VPORT_LINKDOWN,95FC_VPORT_INITIALIZING,96FC_VPORT_NO_FABRIC_SUPP,97FC_VPORT_NO_FABRIC_RSCS,98FC_VPORT_FABRIC_LOGOUT,99FC_VPORT_FABRIC_REJ_WWN,100FC_VPORT_FAILED,101};102103104105/*106* FC Classes of Service107* Note: values are not enumerated, as they can be "or'd" together108* for reporting (e.g. report supported_classes). If you alter this list,109* you also need to alter scsi_transport_fc.c (for the ascii descriptions).110*/111#define FC_COS_UNSPECIFIED 0112#define FC_COS_CLASS1 2113#define FC_COS_CLASS2 4114#define FC_COS_CLASS3 8115#define FC_COS_CLASS4 0x10116#define FC_COS_CLASS6 0x40117118/*119* FC Port Speeds120* Note: values are not enumerated, as they can be "or'd" together121* for reporting (e.g. report supported_speeds). If you alter this list,122* you also need to alter scsi_transport_fc.c (for the ascii descriptions).123*/124#define FC_PORTSPEED_UNKNOWN 0 /* Unknown - transceiver125incapable of reporting */126#define FC_PORTSPEED_1GBIT 1127#define FC_PORTSPEED_2GBIT 2128#define FC_PORTSPEED_4GBIT 4129#define FC_PORTSPEED_10GBIT 8130#define FC_PORTSPEED_8GBIT 0x10131#define FC_PORTSPEED_16GBIT 0x20132#define FC_PORTSPEED_NOT_NEGOTIATED (1 << 15) /* Speed not established */133134/*135* fc_tgtid_binding_type: If you alter this, you also need to alter136* scsi_transport_fc.c (for the ascii descriptions).137*/138enum fc_tgtid_binding_type {139FC_TGTID_BIND_NONE,140FC_TGTID_BIND_BY_WWPN,141FC_TGTID_BIND_BY_WWNN,142FC_TGTID_BIND_BY_ID,143};144145/*146* FC Port Roles147* Note: values are not enumerated, as they can be "or'd" together148* for reporting (e.g. report roles). If you alter this list,149* you also need to alter scsi_transport_fc.c (for the ascii descriptions).150*/151#define FC_PORT_ROLE_UNKNOWN 0x00152#define FC_PORT_ROLE_FCP_TARGET 0x01153#define FC_PORT_ROLE_FCP_INITIATOR 0x02154#define FC_PORT_ROLE_IP_PORT 0x04155156/* The following are for compatibility */157#define FC_RPORT_ROLE_UNKNOWN FC_PORT_ROLE_UNKNOWN158#define FC_RPORT_ROLE_FCP_TARGET FC_PORT_ROLE_FCP_TARGET159#define FC_RPORT_ROLE_FCP_INITIATOR FC_PORT_ROLE_FCP_INITIATOR160#define FC_RPORT_ROLE_IP_PORT FC_PORT_ROLE_IP_PORT161162163/* Macro for use in defining Virtual Port attributes */164#define FC_VPORT_ATTR(_name,_mode,_show,_store) \165struct device_attribute dev_attr_vport_##_name = \166__ATTR(_name,_mode,_show,_store)167168/*169* fc_vport_identifiers: This set of data contains all elements170* to uniquely identify and instantiate a FC virtual port.171*172* Notes:173* symbolic_name: The driver is to append the symbolic_name string data174* to the symbolic_node_name data that it generates by default.175* the resulting combination should then be registered with the switch.176* It is expected that things like Xen may stuff a VM title into177* this field.178*/179#define FC_VPORT_SYMBOLIC_NAMELEN 64180struct fc_vport_identifiers {181u64 node_name;182u64 port_name;183u32 roles;184bool disable;185enum fc_port_type vport_type; /* only FC_PORTTYPE_NPIV allowed */186char symbolic_name[FC_VPORT_SYMBOLIC_NAMELEN];187};188189/*190* FC Virtual Port Attributes191*192* This structure exists for each FC port is a virtual FC port. Virtual193* ports share the physical link with the Physical port. Each virtual194* ports has a unique presence on the SAN, and may be instantiated via195* NPIV, Virtual Fabrics, or via additional ALPAs. As the vport is a196* unique presence, each vport has it's own view of the fabric,197* authentication privilege, and priorities.198*199* A virtual port may support 1 or more FC4 roles. Typically it is a200* FCP Initiator. It could be a FCP Target, or exist sole for an IP over FC201* roles. FC port attributes for the vport will be reported on any202* fc_host class object allocated for an FCP Initiator.203*204* --205*206* Fixed attributes are not expected to change. The driver is207* expected to set these values after receiving the fc_vport structure208* via the vport_create() call from the transport.209* The transport fully manages all get functions w/o driver interaction.210*211* Dynamic attributes are expected to change. The driver participates212* in all get/set operations via functions provided by the driver.213*214* Private attributes are transport-managed values. They are fully215* managed by the transport w/o driver interaction.216*/217218struct fc_vport {219/* Fixed Attributes */220221/* Dynamic Attributes */222223/* Private (Transport-managed) Attributes */224enum fc_vport_state vport_state;225enum fc_vport_state vport_last_state;226u64 node_name;227u64 port_name;228u32 roles;229u32 vport_id; /* Admin Identifier for the vport */230enum fc_port_type vport_type;231char symbolic_name[FC_VPORT_SYMBOLIC_NAMELEN];232233/* exported data */234void *dd_data; /* Used for driver-specific storage */235236/* internal data */237struct Scsi_Host *shost; /* Physical Port Parent */238unsigned int channel;239u32 number;240u8 flags;241struct list_head peers;242struct device dev;243struct work_struct vport_delete_work;244} __attribute__((aligned(sizeof(unsigned long))));245246/* bit field values for struct fc_vport "flags" field: */247#define FC_VPORT_CREATING 0x01248#define FC_VPORT_DELETING 0x02249#define FC_VPORT_DELETED 0x04250#define FC_VPORT_DEL 0x06 /* Any DELETE state */251252#define dev_to_vport(d) \253container_of(d, struct fc_vport, dev)254#define transport_class_to_vport(dev) \255dev_to_vport(dev->parent)256#define vport_to_shost(v) \257(v->shost)258#define vport_to_shost_channel(v) \259(v->channel)260#define vport_to_parent(v) \261(v->dev.parent)262263264/* Error return codes for vport_create() callback */265#define VPCERR_UNSUPPORTED -ENOSYS /* no driver/adapter266support */267#define VPCERR_BAD_WWN -ENOTUNIQ /* driver validation268of WWNs failed */269#define VPCERR_NO_FABRIC_SUPP -EOPNOTSUPP /* Fabric connection270is loop or the271Fabric Port does272not support NPIV */273274/*275* fc_rport_identifiers: This set of data contains all elements276* to uniquely identify a remote FC port. The driver uses this data277* to report the existence of a remote FC port in the topology. Internally,278* the transport uses this data for attributes and to manage consistent279* target id bindings.280*/281struct fc_rport_identifiers {282u64 node_name;283u64 port_name;284u32 port_id;285u32 roles;286};287288289/* Macro for use in defining Remote Port attributes */290#define FC_RPORT_ATTR(_name,_mode,_show,_store) \291struct device_attribute dev_attr_rport_##_name = \292__ATTR(_name,_mode,_show,_store)293294295/*296* FC Remote Port Attributes297*298* This structure exists for each remote FC port that a LLDD notifies299* the subsystem of. A remote FC port may or may not be a SCSI Target,300* also be a SCSI initiator, IP endpoint, etc. As such, the remote301* port is considered a separate entity, independent of "role" (such302* as scsi target).303*304* --305*306* Attributes are based on HBAAPI V2.0 definitions. Only those307* attributes that are determinable by the local port (aka Host)308* are contained.309*310* Fixed attributes are not expected to change. The driver is311* expected to set these values after successfully calling312* fc_remote_port_add(). The transport fully manages all get functions313* w/o driver interaction.314*315* Dynamic attributes are expected to change. The driver participates316* in all get/set operations via functions provided by the driver.317*318* Private attributes are transport-managed values. They are fully319* managed by the transport w/o driver interaction.320*/321322struct fc_rport { /* aka fc_starget_attrs */323/* Fixed Attributes */324u32 maxframe_size;325u32 supported_classes;326327/* Dynamic Attributes */328u32 dev_loss_tmo; /* Remote Port loss timeout in seconds. */329330/* Private (Transport-managed) Attributes */331u64 node_name;332u64 port_name;333u32 port_id;334u32 roles;335enum fc_port_state port_state; /* Will only be ONLINE or UNKNOWN */336u32 scsi_target_id;337u32 fast_io_fail_tmo;338339/* exported data */340void *dd_data; /* Used for driver-specific storage */341342/* internal data */343unsigned int channel;344u32 number;345u8 flags;346struct list_head peers;347struct device dev;348struct delayed_work dev_loss_work;349struct work_struct scan_work;350struct delayed_work fail_io_work;351struct work_struct stgt_delete_work;352struct work_struct rport_delete_work;353struct request_queue *rqst_q; /* bsg support */354} __attribute__((aligned(sizeof(unsigned long))));355356/* bit field values for struct fc_rport "flags" field: */357#define FC_RPORT_DEVLOSS_PENDING 0x01358#define FC_RPORT_SCAN_PENDING 0x02359#define FC_RPORT_FAST_FAIL_TIMEDOUT 0x04360#define FC_RPORT_DEVLOSS_CALLBK_DONE 0x08361362#define dev_to_rport(d) \363container_of(d, struct fc_rport, dev)364#define transport_class_to_rport(dev) \365dev_to_rport(dev->parent)366#define rport_to_shost(r) \367dev_to_shost(r->dev.parent)368369/*370* FC SCSI Target Attributes371*372* The SCSI Target is considered an extension of a remote port (as373* a remote port can be more than a SCSI Target). Within the scsi374* subsystem, we leave the Target as a separate entity. Doing so375* provides backward compatibility with prior FC transport api's,376* and lets remote ports be handled entirely within the FC transport377* and independently from the scsi subsystem. The drawback is that378* some data will be duplicated.379*/380381struct fc_starget_attrs { /* aka fc_target_attrs */382/* Dynamic Attributes */383u64 node_name;384u64 port_name;385u32 port_id;386};387388#define fc_starget_node_name(x) \389(((struct fc_starget_attrs *)&(x)->starget_data)->node_name)390#define fc_starget_port_name(x) \391(((struct fc_starget_attrs *)&(x)->starget_data)->port_name)392#define fc_starget_port_id(x) \393(((struct fc_starget_attrs *)&(x)->starget_data)->port_id)394395#define starget_to_rport(s) \396scsi_is_fc_rport(s->dev.parent) ? dev_to_rport(s->dev.parent) : NULL397398399/*400* FC Local Port (Host) Statistics401*/402403/* FC Statistics - Following FC HBAAPI v2.0 guidelines */404struct fc_host_statistics {405/* port statistics */406u64 seconds_since_last_reset;407u64 tx_frames;408u64 tx_words;409u64 rx_frames;410u64 rx_words;411u64 lip_count;412u64 nos_count;413u64 error_frames;414u64 dumped_frames;415u64 link_failure_count;416u64 loss_of_sync_count;417u64 loss_of_signal_count;418u64 prim_seq_protocol_err_count;419u64 invalid_tx_word_count;420u64 invalid_crc_count;421422/* fc4 statistics (only FCP supported currently) */423u64 fcp_input_requests;424u64 fcp_output_requests;425u64 fcp_control_requests;426u64 fcp_input_megabytes;427u64 fcp_output_megabytes;428};429430431/*432* FC Event Codes - Polled and Async, following FC HBAAPI v2.0 guidelines433*/434435/*436* fc_host_event_code: If you alter this, you also need to alter437* scsi_transport_fc.c (for the ascii descriptions).438*/439enum fc_host_event_code {440FCH_EVT_LIP = 0x1,441FCH_EVT_LINKUP = 0x2,442FCH_EVT_LINKDOWN = 0x3,443FCH_EVT_LIPRESET = 0x4,444FCH_EVT_RSCN = 0x5,445FCH_EVT_ADAPTER_CHANGE = 0x103,446FCH_EVT_PORT_UNKNOWN = 0x200,447FCH_EVT_PORT_OFFLINE = 0x201,448FCH_EVT_PORT_ONLINE = 0x202,449FCH_EVT_PORT_FABRIC = 0x204,450FCH_EVT_LINK_UNKNOWN = 0x500,451FCH_EVT_VENDOR_UNIQUE = 0xffff,452};453454455/*456* FC Local Port (Host) Attributes457*458* Attributes are based on HBAAPI V2.0 definitions.459* Note: OSDeviceName is determined by user-space library460*461* Fixed attributes are not expected to change. The driver is462* expected to set these values after successfully calling scsi_add_host().463* The transport fully manages all get functions w/o driver interaction.464*465* Dynamic attributes are expected to change. The driver participates466* in all get/set operations via functions provided by the driver.467*468* Private attributes are transport-managed values. They are fully469* managed by the transport w/o driver interaction.470*/471472#define FC_FC4_LIST_SIZE 32473#define FC_SYMBOLIC_NAME_SIZE 256474#define FC_VERSION_STRING_SIZE 64475#define FC_SERIAL_NUMBER_SIZE 80476477struct fc_host_attrs {478/* Fixed Attributes */479u64 node_name;480u64 port_name;481u64 permanent_port_name;482u32 supported_classes;483u8 supported_fc4s[FC_FC4_LIST_SIZE];484u32 supported_speeds;485u32 maxframe_size;486u16 max_npiv_vports;487char serial_number[FC_SERIAL_NUMBER_SIZE];488489/* Dynamic Attributes */490u32 port_id;491enum fc_port_type port_type;492enum fc_port_state port_state;493u8 active_fc4s[FC_FC4_LIST_SIZE];494u32 speed;495u64 fabric_name;496char symbolic_name[FC_SYMBOLIC_NAME_SIZE];497char system_hostname[FC_SYMBOLIC_NAME_SIZE];498u32 dev_loss_tmo;499500/* Private (Transport-managed) Attributes */501enum fc_tgtid_binding_type tgtid_bind_type;502503/* internal data */504struct list_head rports;505struct list_head rport_bindings;506struct list_head vports;507u32 next_rport_number;508u32 next_target_id;509u32 next_vport_number;510u16 npiv_vports_inuse;511512/* work queues for rport state manipulation */513char work_q_name[20];514struct workqueue_struct *work_q;515char devloss_work_q_name[20];516struct workqueue_struct *devloss_work_q;517518/* bsg support */519struct request_queue *rqst_q;520};521522#define shost_to_fc_host(x) \523((struct fc_host_attrs *)(x)->shost_data)524525#define fc_host_node_name(x) \526(((struct fc_host_attrs *)(x)->shost_data)->node_name)527#define fc_host_port_name(x) \528(((struct fc_host_attrs *)(x)->shost_data)->port_name)529#define fc_host_permanent_port_name(x) \530(((struct fc_host_attrs *)(x)->shost_data)->permanent_port_name)531#define fc_host_supported_classes(x) \532(((struct fc_host_attrs *)(x)->shost_data)->supported_classes)533#define fc_host_supported_fc4s(x) \534(((struct fc_host_attrs *)(x)->shost_data)->supported_fc4s)535#define fc_host_supported_speeds(x) \536(((struct fc_host_attrs *)(x)->shost_data)->supported_speeds)537#define fc_host_maxframe_size(x) \538(((struct fc_host_attrs *)(x)->shost_data)->maxframe_size)539#define fc_host_max_npiv_vports(x) \540(((struct fc_host_attrs *)(x)->shost_data)->max_npiv_vports)541#define fc_host_serial_number(x) \542(((struct fc_host_attrs *)(x)->shost_data)->serial_number)543#define fc_host_port_id(x) \544(((struct fc_host_attrs *)(x)->shost_data)->port_id)545#define fc_host_port_type(x) \546(((struct fc_host_attrs *)(x)->shost_data)->port_type)547#define fc_host_port_state(x) \548(((struct fc_host_attrs *)(x)->shost_data)->port_state)549#define fc_host_active_fc4s(x) \550(((struct fc_host_attrs *)(x)->shost_data)->active_fc4s)551#define fc_host_speed(x) \552(((struct fc_host_attrs *)(x)->shost_data)->speed)553#define fc_host_fabric_name(x) \554(((struct fc_host_attrs *)(x)->shost_data)->fabric_name)555#define fc_host_symbolic_name(x) \556(((struct fc_host_attrs *)(x)->shost_data)->symbolic_name)557#define fc_host_system_hostname(x) \558(((struct fc_host_attrs *)(x)->shost_data)->system_hostname)559#define fc_host_tgtid_bind_type(x) \560(((struct fc_host_attrs *)(x)->shost_data)->tgtid_bind_type)561#define fc_host_rports(x) \562(((struct fc_host_attrs *)(x)->shost_data)->rports)563#define fc_host_rport_bindings(x) \564(((struct fc_host_attrs *)(x)->shost_data)->rport_bindings)565#define fc_host_vports(x) \566(((struct fc_host_attrs *)(x)->shost_data)->vports)567#define fc_host_next_rport_number(x) \568(((struct fc_host_attrs *)(x)->shost_data)->next_rport_number)569#define fc_host_next_target_id(x) \570(((struct fc_host_attrs *)(x)->shost_data)->next_target_id)571#define fc_host_next_vport_number(x) \572(((struct fc_host_attrs *)(x)->shost_data)->next_vport_number)573#define fc_host_npiv_vports_inuse(x) \574(((struct fc_host_attrs *)(x)->shost_data)->npiv_vports_inuse)575#define fc_host_work_q_name(x) \576(((struct fc_host_attrs *)(x)->shost_data)->work_q_name)577#define fc_host_work_q(x) \578(((struct fc_host_attrs *)(x)->shost_data)->work_q)579#define fc_host_devloss_work_q_name(x) \580(((struct fc_host_attrs *)(x)->shost_data)->devloss_work_q_name)581#define fc_host_devloss_work_q(x) \582(((struct fc_host_attrs *)(x)->shost_data)->devloss_work_q)583#define fc_host_dev_loss_tmo(x) \584(((struct fc_host_attrs *)(x)->shost_data)->dev_loss_tmo)585586587struct fc_bsg_buffer {588unsigned int payload_len;589int sg_cnt;590struct scatterlist *sg_list;591};592593/* Values for fc_bsg_job->state_flags (bitflags) */594#define FC_RQST_STATE_INPROGRESS 0595#define FC_RQST_STATE_DONE 1596597struct fc_bsg_job {598struct Scsi_Host *shost;599struct fc_rport *rport;600struct device *dev;601struct request *req;602spinlock_t job_lock;603unsigned int state_flags;604unsigned int ref_cnt;605void (*job_done)(struct fc_bsg_job *);606607struct fc_bsg_request *request;608struct fc_bsg_reply *reply;609unsigned int request_len;610unsigned int reply_len;611/*612* On entry : reply_len indicates the buffer size allocated for613* the reply.614*615* Upon completion : the message handler must set reply_len616* to indicates the size of the reply to be returned to the617* caller.618*/619620/* DMA payloads for the request/response */621struct fc_bsg_buffer request_payload;622struct fc_bsg_buffer reply_payload;623624void *dd_data; /* Used for driver-specific storage */625};626627628/* The functions by which the transport class and the driver communicate */629struct fc_function_template {630void (*get_rport_dev_loss_tmo)(struct fc_rport *);631void (*set_rport_dev_loss_tmo)(struct fc_rport *, u32);632633void (*get_starget_node_name)(struct scsi_target *);634void (*get_starget_port_name)(struct scsi_target *);635void (*get_starget_port_id)(struct scsi_target *);636637void (*get_host_port_id)(struct Scsi_Host *);638void (*get_host_port_type)(struct Scsi_Host *);639void (*get_host_port_state)(struct Scsi_Host *);640void (*get_host_active_fc4s)(struct Scsi_Host *);641void (*get_host_speed)(struct Scsi_Host *);642void (*get_host_fabric_name)(struct Scsi_Host *);643void (*get_host_symbolic_name)(struct Scsi_Host *);644void (*set_host_system_hostname)(struct Scsi_Host *);645646struct fc_host_statistics * (*get_fc_host_stats)(struct Scsi_Host *);647void (*reset_fc_host_stats)(struct Scsi_Host *);648649int (*issue_fc_host_lip)(struct Scsi_Host *);650651void (*dev_loss_tmo_callbk)(struct fc_rport *);652void (*terminate_rport_io)(struct fc_rport *);653654void (*set_vport_symbolic_name)(struct fc_vport *);655int (*vport_create)(struct fc_vport *, bool);656int (*vport_disable)(struct fc_vport *, bool);657int (*vport_delete)(struct fc_vport *);658659/* target-mode drivers' functions */660int (* tsk_mgmt_response)(struct Scsi_Host *, u64, u64, int);661int (* it_nexus_response)(struct Scsi_Host *, u64, int);662663/* bsg support */664int (*bsg_request)(struct fc_bsg_job *);665int (*bsg_timeout)(struct fc_bsg_job *);666667/* allocation lengths for host-specific data */668u32 dd_fcrport_size;669u32 dd_fcvport_size;670u32 dd_bsg_size;671672/*673* The driver sets these to tell the transport class it674* wants the attributes displayed in sysfs. If the show_ flag675* is not set, the attribute will be private to the transport676* class677*/678679/* remote port fixed attributes */680unsigned long show_rport_maxframe_size:1;681unsigned long show_rport_supported_classes:1;682unsigned long show_rport_dev_loss_tmo:1;683684/*685* target dynamic attributes686* These should all be "1" if the driver uses the remote port687* add/delete functions (so attributes reflect rport values).688*/689unsigned long show_starget_node_name:1;690unsigned long show_starget_port_name:1;691unsigned long show_starget_port_id:1;692693/* host fixed attributes */694unsigned long show_host_node_name:1;695unsigned long show_host_port_name:1;696unsigned long show_host_permanent_port_name:1;697unsigned long show_host_supported_classes:1;698unsigned long show_host_supported_fc4s:1;699unsigned long show_host_supported_speeds:1;700unsigned long show_host_maxframe_size:1;701unsigned long show_host_serial_number:1;702/* host dynamic attributes */703unsigned long show_host_port_id:1;704unsigned long show_host_port_type:1;705unsigned long show_host_port_state:1;706unsigned long show_host_active_fc4s:1;707unsigned long show_host_speed:1;708unsigned long show_host_fabric_name:1;709unsigned long show_host_symbolic_name:1;710unsigned long show_host_system_hostname:1;711712unsigned long disable_target_scan:1;713};714715716/**717* fc_remote_port_chkready - called to validate the remote port state718* prior to initiating io to the port.719*720* Returns a scsi result code that can be returned by the LLDD.721*722* @rport: remote port to be checked723**/724static inline int725fc_remote_port_chkready(struct fc_rport *rport)726{727int result;728729switch (rport->port_state) {730case FC_PORTSTATE_ONLINE:731if (rport->roles & FC_PORT_ROLE_FCP_TARGET)732result = 0;733else if (rport->flags & FC_RPORT_DEVLOSS_PENDING)734result = DID_IMM_RETRY << 16;735else736result = DID_NO_CONNECT << 16;737break;738case FC_PORTSTATE_BLOCKED:739if (rport->flags & FC_RPORT_FAST_FAIL_TIMEDOUT)740result = DID_TRANSPORT_FAILFAST << 16;741else742result = DID_IMM_RETRY << 16;743break;744default:745result = DID_NO_CONNECT << 16;746break;747}748return result;749}750751static inline u64 wwn_to_u64(u8 *wwn)752{753return (u64)wwn[0] << 56 | (u64)wwn[1] << 48 |754(u64)wwn[2] << 40 | (u64)wwn[3] << 32 |755(u64)wwn[4] << 24 | (u64)wwn[5] << 16 |756(u64)wwn[6] << 8 | (u64)wwn[7];757}758759static inline void u64_to_wwn(u64 inm, u8 *wwn)760{761wwn[0] = (inm >> 56) & 0xff;762wwn[1] = (inm >> 48) & 0xff;763wwn[2] = (inm >> 40) & 0xff;764wwn[3] = (inm >> 32) & 0xff;765wwn[4] = (inm >> 24) & 0xff;766wwn[5] = (inm >> 16) & 0xff;767wwn[6] = (inm >> 8) & 0xff;768wwn[7] = inm & 0xff;769}770771/**772* fc_vport_set_state() - called to set a vport's state. Saves the old state,773* excepting the transitory states of initializing and sending the ELS774* traffic to instantiate the vport on the link.775*776* Assumes the driver has surrounded this with the proper locking to ensure777* a coherent state change.778*779* @vport: virtual port whose state is changing780* @new_state: new state781**/782static inline void783fc_vport_set_state(struct fc_vport *vport, enum fc_vport_state new_state)784{785if ((new_state != FC_VPORT_UNKNOWN) &&786(new_state != FC_VPORT_INITIALIZING))787vport->vport_last_state = vport->vport_state;788vport->vport_state = new_state;789}790791struct scsi_transport_template *fc_attach_transport(792struct fc_function_template *);793void fc_release_transport(struct scsi_transport_template *);794void fc_remove_host(struct Scsi_Host *);795struct fc_rport *fc_remote_port_add(struct Scsi_Host *shost,796int channel, struct fc_rport_identifiers *ids);797void fc_remote_port_delete(struct fc_rport *rport);798void fc_remote_port_rolechg(struct fc_rport *rport, u32 roles);799int scsi_is_fc_rport(const struct device *);800u32 fc_get_event_number(void);801void fc_host_post_event(struct Scsi_Host *shost, u32 event_number,802enum fc_host_event_code event_code, u32 event_data);803void fc_host_post_vendor_event(struct Scsi_Host *shost, u32 event_number,804u32 data_len, char * data_buf, u64 vendor_id);805/* Note: when specifying vendor_id to fc_host_post_vendor_event()806* be sure to read the Vendor Type and ID formatting requirements807* specified in scsi_netlink.h808*/809struct fc_vport *fc_vport_create(struct Scsi_Host *shost, int channel,810struct fc_vport_identifiers *);811int fc_vport_terminate(struct fc_vport *vport);812int fc_block_scsi_eh(struct scsi_cmnd *cmnd);813814#endif /* SCSI_TRANSPORT_FC_H */815816817