/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * FiberChannel transport specific attributes exported to sysfs. * * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved. * Copyright (C) 2004-2007 James Smart, Emulex Corporation * Rewrite for host, target, device, and remote port attributes, * statistics, and service functions...
*/ #ifndef SCSI_TRANSPORT_FC_H #define SCSI_TRANSPORT_FC_H
/* * FC Port definitions - Following FC HBAAPI guidelines * * Note: Not all binary values for the different fields match HBAAPI. * Instead, we use densely packed ordinal values or enums. * We get away with this as we never present the actual binary values * externally. For sysfs, we always present the string that describes * the value. Thus, an admin doesn't need a magic HBAAPI decoder ring * to understand the values. The HBAAPI user-space library is free to * convert the strings into the HBAAPI-specified binary values. * * Note: Not all HBAAPI-defined values are contained in the definitions * below. Those not appropriate to an fc_host (e.g. FCP initiator) have * been removed.
*/
/* * fc_port_type: If you alter this, you also need to alter scsi_transport_fc.c * (for the ascii descriptions).
*/ enum fc_port_type {
FC_PORTTYPE_UNKNOWN,
FC_PORTTYPE_OTHER,
FC_PORTTYPE_NOTPRESENT,
FC_PORTTYPE_NPORT, /* Attached to FPort */
FC_PORTTYPE_NLPORT, /* (Public) Loop w/ FLPort */
FC_PORTTYPE_LPORT, /* (Private) Loop w/o FLPort */
FC_PORTTYPE_PTP, /* Point to Point w/ another NPort */
FC_PORTTYPE_NPIV, /* VPORT based on NPIV */
};
/* * fc_port_state: If you alter this, you also need to alter scsi_transport_fc.c * (for the ascii descriptions).
*/ enum fc_port_state {
FC_PORTSTATE_UNKNOWN,
FC_PORTSTATE_NOTPRESENT,
FC_PORTSTATE_ONLINE,
FC_PORTSTATE_OFFLINE, /* User has taken Port Offline */
FC_PORTSTATE_BLOCKED,
FC_PORTSTATE_BYPASSED,
FC_PORTSTATE_DIAGNOSTICS,
FC_PORTSTATE_LINKDOWN,
FC_PORTSTATE_ERROR,
FC_PORTSTATE_LOOPBACK,
FC_PORTSTATE_DELETED,
FC_PORTSTATE_MARGINAL,
};
/* * fc_vport_state: If you alter this, you also need to alter * scsi_transport_fc.c (for the ascii descriptions).
*/ enum fc_vport_state {
FC_VPORT_UNKNOWN,
FC_VPORT_ACTIVE,
FC_VPORT_DISABLED,
FC_VPORT_LINKDOWN,
FC_VPORT_INITIALIZING,
FC_VPORT_NO_FABRIC_SUPP,
FC_VPORT_NO_FABRIC_RSCS,
FC_VPORT_FABRIC_LOGOUT,
FC_VPORT_FABRIC_REJ_WWN,
FC_VPORT_FAILED,
};
/* * FC Classes of Service * Note: values are not enumerated, as they can be "or'd" together * for reporting (e.g. report supported_classes). If you alter this list, * you also need to alter scsi_transport_fc.c (for the ascii descriptions).
*/ #define FC_COS_UNSPECIFIED 0 #define FC_COS_CLASS1 2 #define FC_COS_CLASS2 4 #define FC_COS_CLASS3 8 #define FC_COS_CLASS4 0x10 #define FC_COS_CLASS6 0x40
/* * FC Port Speeds * Note: values are not enumerated, as they can be "or'd" together * for reporting (e.g. report supported_speeds). If you alter this list, * you also need to alter scsi_transport_fc.c (for the ascii descriptions).
*/ #define FC_PORTSPEED_UNKNOWN 0 /* Unknown - transceiver
incapable of reporting */ #define FC_PORTSPEED_1GBIT 1 #define FC_PORTSPEED_2GBIT 2 #define FC_PORTSPEED_10GBIT 4 #define FC_PORTSPEED_4GBIT 8 #define FC_PORTSPEED_8GBIT 0x10 #define FC_PORTSPEED_16GBIT 0x20 #define FC_PORTSPEED_32GBIT 0x40 #define FC_PORTSPEED_20GBIT 0x80 #define FC_PORTSPEED_40GBIT 0x100 #define FC_PORTSPEED_50GBIT 0x200 #define FC_PORTSPEED_100GBIT 0x400 #define FC_PORTSPEED_25GBIT 0x800 #define FC_PORTSPEED_64GBIT 0x1000 #define FC_PORTSPEED_128GBIT 0x2000 #define FC_PORTSPEED_256GBIT 0x4000 #define FC_PORTSPEED_NOT_NEGOTIATED (1 << 15) /* Speed not established */
/* * fc_tgtid_binding_type: If you alter this, you also need to alter * scsi_transport_fc.c (for the ascii descriptions).
*/ enum fc_tgtid_binding_type {
FC_TGTID_BIND_NONE,
FC_TGTID_BIND_BY_WWPN,
FC_TGTID_BIND_BY_WWNN,
FC_TGTID_BIND_BY_ID,
};
/* * FC Port Roles * Note: values are not enumerated, as they can be "or'd" together * for reporting (e.g. report roles). If you alter this list, * you also need to alter scsi_transport_fc.c (for the ascii descriptions).
*/ #define FC_PORT_ROLE_UNKNOWN 0x00 #define FC_PORT_ROLE_FCP_TARGET 0x01 #define FC_PORT_ROLE_FCP_INITIATOR 0x02 #define FC_PORT_ROLE_IP_PORT 0x04 #define FC_PORT_ROLE_FCP_DUMMY_INITIATOR 0x08 #define FC_PORT_ROLE_NVME_INITIATOR 0x10 #define FC_PORT_ROLE_NVME_TARGET 0x20 #define FC_PORT_ROLE_NVME_DISCOVERY 0x40
/* The following are for compatibility */ #define FC_RPORT_ROLE_UNKNOWN FC_PORT_ROLE_UNKNOWN #define FC_RPORT_ROLE_FCP_TARGET FC_PORT_ROLE_FCP_TARGET #define FC_RPORT_ROLE_FCP_INITIATOR FC_PORT_ROLE_FCP_INITIATOR #define FC_RPORT_ROLE_IP_PORT FC_PORT_ROLE_IP_PORT
/* Macro for use in defining Virtual Port attributes */ #define FC_VPORT_ATTR(_name,_mode,_show,_store) \ struct device_attribute dev_attr_vport_##_name = \
__ATTR(_name,_mode,_show,_store)
/* * fc_vport_identifiers: This set of data contains all elements * to uniquely identify and instantiate a FC virtual port. * * Notes: * symbolic_name: The driver is to append the symbolic_name string data * to the symbolic_node_name data that it generates by default. * the resulting combination should then be registered with the switch. * It is expected that things like Xen may stuff a VM title into * this field.
*/ #define FC_VPORT_SYMBOLIC_NAMELEN 64 struct fc_vport_identifiers {
u64 node_name;
u64 port_name;
u32 roles; bool disable; enum fc_port_type vport_type; /* only FC_PORTTYPE_NPIV allowed */ char symbolic_name[FC_VPORT_SYMBOLIC_NAMELEN];
};
/* * FC Virtual Port Attributes * * This structure exists for each FC port is a virtual FC port. Virtual * ports share the physical link with the Physical port. Each virtual * ports has a unique presence on the SAN, and may be instantiated via * NPIV, Virtual Fabrics, or via additional ALPAs. As the vport is a * unique presence, each vport has it's own view of the fabric, * authentication privilege, and priorities. * * A virtual port may support 1 or more FC4 roles. Typically it is a * FCP Initiator. It could be a FCP Target, or exist sole for an IP over FC * roles. FC port attributes for the vport will be reported on any * fc_host class object allocated for an FCP Initiator. * * -- * * Fixed attributes are not expected to change. The driver is * expected to set these values after receiving the fc_vport structure * via the vport_create() call from the transport. * The transport fully manages all get functions w/o driver interaction. * * Dynamic attributes are expected to change. The driver participates * in all get/set operations via functions provided by the driver. * * Private attributes are transport-managed values. They are fully * managed by the transport w/o driver interaction.
*/
/* Error return codes for vport_create() callback */ #define VPCERR_UNSUPPORTED -ENOSYS /* no driver/adapter
support */ #define VPCERR_BAD_WWN -ENOTUNIQ /* driver validation
of WWNs failed */ #define VPCERR_NO_FABRIC_SUPP -EOPNOTSUPP /* Fabric connection is loop or the Fabric Port does
not support NPIV */
/* * fc_rport_identifiers: This set of data contains all elements * to uniquely identify a remote FC port. The driver uses this data * to report the existence of a remote FC port in the topology. Internally, * the transport uses this data for attributes and to manage consistent * target id bindings.
*/ struct fc_rport_identifiers {
u64 node_name;
u64 port_name;
u32 port_id;
u32 roles;
};
/* Macro for use in defining Remote Port attributes */ #define FC_RPORT_ATTR(_name,_mode,_show,_store) \ struct device_attribute dev_attr_rport_##_name = \
__ATTR(_name,_mode,_show,_store)
/* * FC Remote Port Attributes * * This structure exists for each remote FC port that a LLDD notifies * the subsystem of. A remote FC port may or may not be a SCSI Target, * also be a SCSI initiator, IP endpoint, etc. As such, the remote * port is considered a separate entity, independent of "role" (such * as scsi target). * * -- * * Attributes are based on HBAAPI V2.0 definitions. Only those * attributes that are determinable by the local port (aka Host) * are contained. * * Fixed attributes are not expected to change. The driver is * expected to set these values after successfully calling * fc_remote_port_add(). The transport fully manages all get functions * w/o driver interaction. * * Dynamic attributes are expected to change. The driver participates * in all get/set operations via functions provided by the driver. * * Private attributes are transport-managed values. They are fully * managed by the transport w/o driver interaction.
*/
/* * FC SCSI Target Attributes * * The SCSI Target is considered an extension of a remote port (as * a remote port can be more than a SCSI Target). Within the scsi * subsystem, we leave the Target as a separate entity. Doing so * provides backward compatibility with prior FC transport api's, * and lets remote ports be handled entirely within the FC transport * and independently from the scsi subsystem. The drawback is that * some data will be duplicated.
*/
/* fc exches statistics */
u64 fc_no_free_exch; /* no free exch memory */
u64 fc_no_free_exch_xid; /* no free exch id */
u64 fc_xid_not_found; /* exch not found for a response */
u64 fc_xid_busy; /* exch exist for new a request */
u64 fc_seq_not_found; /* seq is not found for exchange */
u64 fc_non_bls_resp; /* a non BLS response frame with
a sequence responder in new exch */ /* Host Congestion Signals */
u64 cn_sig_warn;
u64 cn_sig_alarm;
};
/* * FC Event Codes - Polled and Async, following FC HBAAPI v2.0 guidelines
*/
/* * fc_host_event_code: If you alter this, you also need to alter * scsi_transport_fc.c (for the ascii descriptions).
*/ enum fc_host_event_code {
FCH_EVT_LIP = 0x1,
FCH_EVT_LINKUP = 0x2,
FCH_EVT_LINKDOWN = 0x3,
FCH_EVT_LIPRESET = 0x4,
FCH_EVT_RSCN = 0x5,
FCH_EVT_ADAPTER_CHANGE = 0x103,
FCH_EVT_PORT_UNKNOWN = 0x200,
FCH_EVT_PORT_OFFLINE = 0x201,
FCH_EVT_PORT_ONLINE = 0x202,
FCH_EVT_PORT_FABRIC = 0x204,
FCH_EVT_LINK_UNKNOWN = 0x500,
FCH_EVT_LINK_FPIN = 0x501,
FCH_EVT_LINK_FPIN_ACK = 0x502,
FCH_EVT_VENDOR_UNIQUE = 0xffff,
};
/* * FC Local Port (Host) Attributes * * Attributes are based on HBAAPI V2.0 definitions. * Note: OSDeviceName is determined by user-space library * * Fixed attributes are not expected to change. The driver is * expected to set these values after successfully calling scsi_add_host(). * The transport fully manages all get functions w/o driver interaction. * * Dynamic attributes are expected to change. The driver participates * in all get/set operations via functions provided by the driver. * * Private attributes are transport-managed values. They are fully * managed by the transport w/o driver interaction.
*/
/* The functions by which the transport class and the driver communicate */ struct fc_function_template { void (*get_rport_dev_loss_tmo)(struct fc_rport *); void (*set_rport_dev_loss_tmo)(struct fc_rport *, u32);
void (*set_vport_symbolic_name)(struct fc_vport *); int (*vport_create)(struct fc_vport *, bool); int (*vport_disable)(struct fc_vport *, bool); int (*vport_delete)(struct fc_vport *);
/* bsg support */
u32 max_bsg_segments; int (*bsg_request)(struct bsg_job *); int (*bsg_timeout)(struct bsg_job *);
/* allocation lengths for host-specific data */
u32 dd_fcrport_size;
u32 dd_fcvport_size;
u32 dd_bsg_size;
/* * The driver sets these to tell the transport class it * wants the attributes displayed in sysfs. If the show_ flag * is not set, the attribute will be private to the transport * class
*/
/* * target dynamic attributes * These should all be "1" if the driver uses the remote port * add/delete functions (so attributes reflect rport values).
*/ unsignedlong show_starget_node_name:1; unsignedlong show_starget_port_name:1; unsignedlong show_starget_port_id:1;
/** * fc_remote_port_chkready - called to validate the remote port state * prior to initiating io to the port. * @rport: remote port to be checked * * Returns: a scsi result code that can be returned by the LLDD.
**/ staticinlineint
fc_remote_port_chkready(struct fc_rport *rport)
{ int result;
switch (rport->port_state) { case FC_PORTSTATE_ONLINE: case FC_PORTSTATE_MARGINAL: if (rport->roles & FC_PORT_ROLE_FCP_TARGET)
result = 0; elseif (rport->flags & FC_RPORT_DEVLOSS_PENDING)
result = DID_IMM_RETRY << 16; else
result = DID_NO_CONNECT << 16; break; case FC_PORTSTATE_BLOCKED: if (rport->flags & FC_RPORT_FAST_FAIL_TIMEDOUT)
result = DID_TRANSPORT_FAILFAST << 16; else
result = DID_IMM_RETRY << 16; break; default:
result = DID_NO_CONNECT << 16; break;
} return result;
}
/** * fc_vport_set_state() - called to set a vport's state. Saves the old state, * excepting the transitory states of initializing and sending the ELS * traffic to instantiate the vport on the link. * * Assumes the driver has surrounded this with the proper locking to ensure * a coherent state change. * * @vport: virtual port whose state is changing * @new_state: new state
**/ staticinlinevoid
fc_vport_set_state(struct fc_vport *vport, enum fc_vport_state new_state)
{ if ((new_state != FC_VPORT_UNKNOWN) &&
(new_state != FC_VPORT_INITIALIZING))
vport->vport_last_state = vport->vport_state;
vport->vport_state = new_state;
}
struct scsi_transport_template *fc_attach_transport( struct fc_function_template *); void fc_release_transport(struct scsi_transport_template *); void fc_remove_host(struct Scsi_Host *); struct fc_rport *fc_remote_port_add(struct Scsi_Host *shost, int channel, struct fc_rport_identifiers *ids); void fc_remote_port_delete(struct fc_rport *rport); void fc_remote_port_rolechg(struct fc_rport *rport, u32 roles); int scsi_is_fc_rport(conststruct device *);
u32 fc_get_event_number(void); void fc_host_post_event(struct Scsi_Host *shost, u32 event_number, enum fc_host_event_code event_code, u32 event_data); void fc_host_post_vendor_event(struct Scsi_Host *shost, u32 event_number,
u32 data_len, char *data_buf, u64 vendor_id); struct fc_rport *fc_find_rport_by_wwpn(struct Scsi_Host *shost, u64 wwpn); void fc_host_post_fc_event(struct Scsi_Host *shost, u32 event_number, enum fc_host_event_code event_code,
u32 data_len, char *data_buf, u64 vendor_id); /* Note: when specifying vendor_id to fc_host_post_vendor_event() * or fc_host_post_fc_event(), be sure to read the Vendor Type * and ID formatting requirements specified in scsi_netlink.h * Note: when calling fc_host_post_fc_event(), vendor_id may be * specified as 0.
*/ void fc_host_fpin_rcv(struct Scsi_Host *shost, u32 fpin_len, char *fpin_buf,
u8 event_acknowledge); struct fc_vport *fc_vport_create(struct Scsi_Host *shost, int channel, struct fc_vport_identifiers *); int fc_vport_terminate(struct fc_vport *vport); int fc_block_rport(struct fc_rport *rport); int fc_block_scsi_eh(struct scsi_cmnd *cmnd); enum scsi_timeout_action fc_eh_timed_out(struct scsi_cmnd *scmd); bool fc_eh_should_retry_cmd(struct scsi_cmnd *scmd);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.