/* SPDX-License-Identifier: GPL-2.0-only *//* * Copyright(c) 2007 Intel Corporation. All rights reserved. * * Maintained at www.Open-FCoE.org */ #ifndef _LIBFC_H_#define _LIBFC_H_ #include <linux/timer.h>#include <linux/if.h>#include <linux/percpu.h>#include <linux/refcount.h> #include <scsi/scsi_transport.h>#include <scsi/scsi_transport_fc.h>#include <scsi/scsi_bsg_fc.h> #include <scsi/fc/fc_fcp.h>#include <scsi/fc/fc_ns.h>#include <scsi/fc/fc_ms.h>#include <scsi/fc/fc_els.h>#include <scsi/fc/fc_gs.h> #include <scsi/fc_frame.h> #define FC_FC4_PROV_SIZE (FC_TYPE_FCP + 1) /* size of tables */ /* * libfc error codes */#define FC_NO_ERR 0 /* no error */#define FC_EX_TIMEOUT 1 /* Exchange timeout */#define FC_EX_CLOSED 2 /* Exchange closed */#define FC_EX_ALLOC_ERR 3 /* Exchange allocation failed */#define FC_EX_XMIT_ERR 4 /* Exchange transmit failed */#define FC_EX_ELS_RJT 5 /* ELS rejected */#define FC_EX_INV_LOGIN 6 /* Login not completed */#define FC_EX_SEQ_ERR 6 /* Exchange sequence error */ /** * enum fc_lport_state - Local port states * @LPORT_ST_DISABLED: Disabled * @LPORT_ST_FLOGI: Fabric login (FLOGI) sent * @LPORT_ST_DNS: Waiting for name server remote port to become ready * @LPORT_ST_RNN_ID: Register port name by ID (RNN_ID) sent * @LPORT_ST_RSNN_NN: Waiting for host symbolic node name * @LPORT_ST_RSPN_ID: Waiting for host symbolic port name * @LPORT_ST_RFT_ID: Register Fibre Channel types by ID (RFT_ID) sent * @LPORT_ST_RFF_ID: Register FC-4 Features by ID (RFF_ID) sent * @LPORT_ST_FDMI: Waiting for mgmt server rport to become ready * @LPORT_ST_RHBA: Register HBA * @LPORT_ST_RPA: Register Port Attributes * @LPORT_ST_DHBA: Deregister HBA * @LPORT_ST_DPRT: Deregister Port * @LPORT_ST_SCR: State Change Register (SCR) sent * @LPORT_ST_READY: Ready for use * @LPORT_ST_LOGO: Local port logout (LOGO) sent * @LPORT_ST_RESET: Local port reset */enum fc_lport_state { LPORT_ST_DISABLED = 0, LPORT_ST_FLOGI, LPORT_ST_DNS, LPORT_ST_RNN_ID, LPORT_ST_RSNN_NN, LPORT_ST_RSPN_ID, LPORT_ST_RFT_ID, LPORT_ST_RFF_ID, LPORT_ST_FDMI, LPORT_ST_RHBA, LPORT_ST_RPA, LPORT_ST_DHBA, LPORT_ST_DPRT, LPORT_ST_SCR, LPORT_ST_READY, LPORT_ST_LOGO, LPORT_ST_RESET}; enum fc_disc_event { DISC_EV_NONE = 0, DISC_EV_SUCCESS, DISC_EV_FAILED}; /** * enum fc_rport_state - Remote port states * @RPORT_ST_INIT: Initialized * @RPORT_ST_FLOGI: Waiting for FLOGI completion for point-to-multipoint * @RPORT_ST_PLOGI_WAIT: Waiting for peer to login for point-to-multipoint * @RPORT_ST_PLOGI: Waiting for PLOGI completion * @RPORT_ST_PRLI: Waiting for PRLI completion * @RPORT_ST_RTV: Waiting for RTV completion * @RPORT_ST_READY: Ready for use * @RPORT_ST_ADISC: Discover Address sent * @RPORT_ST_DELETE: Remote port being deleted*/enum fc_rport_state { RPORT_ST_INIT, RPORT_ST_FLOGI, RPORT_ST_PLOGI_WAIT, RPORT_ST_PLOGI, RPORT_ST_PRLI, RPORT_ST_RTV, RPORT_ST_READY, RPORT_ST_ADISC, RPORT_ST_DELETE,}; /** * struct fc_disc_port - temporary discovery port to hold rport identifiers * @lp: Fibre Channel host port instance * @peers: Node for list management during discovery and RSCN processing * @rport_work: Work struct for starting the rport state machine * @port_id: Port ID of the discovered port */struct fc_disc_port { struct fc_lport *lp; struct list_head peers; struct work_struct rport_work; u32 port_id;}; /** * enum fc_rport_event - Remote port events * @RPORT_EV_NONE: No event * @RPORT_EV_READY: Remote port is ready for use * @RPORT_EV_FAILED: State machine failed, remote port is not ready * @RPORT_EV_STOP: Remote port has been stopped * @RPORT_EV_LOGO: Remote port logout (LOGO) sent */enum fc_rport_event { RPORT_EV_NONE = 0, RPORT_EV_READY, RPORT_EV_FAILED, RPORT_EV_STOP, RPORT_EV_LOGO}; struct fc_rport_priv; /** * struct fc_rport_operations - Operations for a remote port * @event_callback: Function to be called for remote port events */struct fc_rport_operations { void (*event_callback)(struct fc_lport *, struct fc_rport_priv *, enum fc_rport_event);}; /** * struct fc_rport_libfc_priv - libfc internal information about a remote port * @local_port: The associated local port * @rp_state: Indicates READY for I/O or DELETE when blocked * @flags: REC and RETRY supported flags * @e_d_tov: Error detect timeout value (in msec) * @r_a_tov: Resource allocation timeout value (in msec) */struct fc_rport_libfc_priv { struct fc_lport *local_port; enum fc_rport_state rp_state; u16 flags; #define FC_RP_FLAGS_REC_SUPPORTED (1 << 0) #define FC_RP_FLAGS_RETRY (1 << 1) #define FC_RP_STARTED (1 << 2) #define FC_RP_FLAGS_CONF_REQ (1 << 3) unsigned int e_d_tov; unsigned int r_a_tov;}; /** * struct fc_rport_priv - libfc remote port and discovery info * @local_port: The associated local port * @rport: The FC transport remote port * @kref: Reference counter * @rp_state: Enumeration that tracks progress of PLOGI, PRLI, * and RTV exchanges * @ids: The remote port identifiers and roles * @flags: STARTED, REC and RETRY_SUPPORTED flags * @max_seq: Maximum number of concurrent sequences * @disc_id: The discovery identifier * @maxframe_size: The maximum frame size * @retries: The retry count for the current state * @major_retries: The retry count for the entire PLOGI/PRLI state machine * @e_d_tov: Error detect timeout value (in msec) * @r_a_tov: Resource allocation timeout value (in msec) * @rp_mutex: The mutex that protects the remote port * @retry_work: Handle for retries * @lld_event_callback: Callback when READY, FAILED or LOGO states complete * @prli_count: Count of open PRLI sessions in providers * @rcu: Structure used for freeing in an RCU-safe manner */struct fc_rport_priv { struct fc_lport *local_port; struct fc_rport *rport; struct kref kref; enum fc_rport_state rp_state; struct fc_rport_identifiers ids; u16 flags; u16 max_seq; u16 disc_id; u16 maxframe_size; unsigned int retries; unsigned int major_retries; unsigned int e_d_tov; unsigned int r_a_tov; struct mutex rp_mutex; struct delayed_work retry_work; enum fc_rport_event event; struct fc_rport_operations *ops; struct list_head peers; struct work_struct event_work; u32 supported_classes; u16 prli_count; struct rcu_head rcu; u16 sp_features; u8 spp_type; void (*lld_event_callback)(struct fc_lport *, struct fc_rport_priv *, enum fc_rport_event);}; /** * struct fc_stats - fc stats structure * @SecondsSinceLastReset: Seconds since the last reset * @TxFrames: Number of transmitted frames * @TxWords: Number of transmitted words * @RxFrames: Number of received frames * @RxWords: Number of received words * @ErrorFrames: Number of received error frames * @DumpedFrames: Number of dumped frames * @FcpPktAllocFails: Number of fcp packet allocation failures * @FcpPktAborts: Number of fcp packet aborts * @FcpFrameAllocFails: Number of fcp frame allocation failures * @LinkFailureCount: Number of link failures * @LossOfSignalCount: Number for signal losses * @InvalidTxWordCount: Number of invalid transmitted words * @InvalidCRCCount: Number of invalid CRCs * @InputRequests: Number of input requests * @OutputRequests: Number of output requests * @ControlRequests: Number of control requests * @InputBytes: Number of received bytes * @OutputBytes: Number of transmitted bytes * @VLinkFailureCount: Number of virtual link failures * @MissDiscAdvCount: Number of missing FIP discovery advertisement */struct fc_stats { u64 SecondsSinceLastReset; u64 TxFrames; u64 TxWords; u64 RxFrames; u64 RxWords; u64 ErrorFrames; u64 DumpedFrames; u64 FcpPktAllocFails; u64 FcpPktAborts; u64 FcpFrameAllocFails; u64 LinkFailureCount; u64 LossOfSignalCount; u64 InvalidTxWordCount; u64 InvalidCRCCount; u64 InputRequests; u64 OutputRequests; u64 ControlRequests; u64 InputBytes; u64 OutputBytes; u64 VLinkFailureCount; u64 MissDiscAdvCount;}; /** * struct fc_seq_els_data - ELS data used for passing ELS specific responses * @reason: The reason for rejection * @explan: The explanation of the rejection * * Mainly used by the exchange manager layer. */struct fc_seq_els_data { enum fc_els_rjt_reason reason; enum fc_els_rjt_explan explan;}; /** * struct fc_fcp_pkt - FCP request structure (one for each scsi_cmnd request) * @lp: The associated local port * @state: The state of the I/O * @ref_cnt: Reference count * @scsi_pkt_lock: Lock to protect the SCSI packet (must be taken before the * host_lock if both are to be held at the same time) * @cmd: The SCSI command (set and clear with the host_lock held) * @list: Tracks queued commands (accessed with the host_lock held) * @timer: The command timer * @tm_done: Completion indicator * @wait_for_comp: Indicator to wait for completion of the I/O (in jiffies) * @timer_delay: FCP packet timer delay in jiffies * @data_len: The length of the data * @cdb_cmd: The CDB command * @xfer_len: The transfer length * @xfer_ddp: Indicates if this transfer used DDP (XID of the exchange * will be set here if DDP was setup) * @xfer_contig_end: The offset into the buffer if the buffer is contiguous * (Tx and Rx) * @max_payload: The maximum payload size (in bytes) * @io_status: SCSI result (upper 24 bits) * @cdb_status: CDB status * @status_code: FCP I/O status * @scsi_comp_flags: Completion flags (bit 3 Underrun bit 2: overrun) * @req_flags: Request flags (bit 0: read bit:1 write) * @scsi_resid: SCSI residule length * @rport: The remote port that the SCSI command is targeted at * @seq_ptr: The sequence that will carry the SCSI command * @recov_retry: Number of recovery retries * @recov_seq: The sequence for REC or SRR */struct fc_fcp_pkt { spinlock_t scsi_pkt_lock; refcount_t ref_cnt; /* SCSI command and data transfer information */ u32 data_len; /* SCSI I/O related information */ struct scsi_cmnd *cmd; struct list_head list; /* Housekeeping information */ struct fc_lport *lp; u8 state; /* SCSI/FCP return status */ u8 cdb_status; u8 status_code; u8 scsi_comp_flags; u32 io_status; u32 req_flags; u32 scsi_resid; /* Transport related veriables */ size_t xfer_len; struct fcp_cmnd cdb_cmd; u32 xfer_contig_end; u16 max_payload; u16 xfer_ddp; /* Associated structures */ struct fc_rport *rport; struct fc_seq *seq_ptr; /* Timeout/error related information */ struct timer_list timer; int wait_for_comp; int timer_delay; u32 recov_retry; struct fc_seq *recov_seq; struct completion tm_done;} ____cacheline_aligned_in_smp; /* * @fsp should be tested and set under the scsi_pkt_queue lock */struct libfc_cmd_priv { struct fc_fcp_pkt *fsp; u32 resid_len; u8 status;}; /* * Structure and function definitions for managing Fibre Channel Exchanges * and Sequences * * fc_exch holds state for one exchange and links to its active sequence. * * fc_seq holds the state for an individual sequence. */ struct fc_exch_mgr;struct fc_exch_mgr_anchor;extern u16 fc_cpu_mask; /* cpu mask for possible cpus */ /** * struct fc_seq - FC sequence * @id: The sequence ID * @ssb_stat: Status flags for the sequence status block (SSB) * @cnt: Number of frames sent so far * @rec_data: FC-4 value for REC */struct fc_seq { u8 id; u16 ssb_stat; u16 cnt; u32 rec_data;}; #define FC_EX_DONE (1 << 0) /* ep is completed */#define FC_EX_RST_CLEANUP (1 << 1) /* reset is forcing completion */#define FC_EX_QUARANTINE (1 << 2) /* exch is quarantined */ /** * struct fc_exch - Fibre Channel Exchange * @em: Exchange manager * @pool: Exchange pool * @state: The exchange's state * @xid: The exchange ID * @ex_list: Handle used by the EM to track free exchanges * @ex_lock: Lock that protects the exchange * @ex_refcnt: Reference count * @timeout_work: Handle for timeout handler * @lp: The local port that this exchange is on * @oxid: Originator's exchange ID * @rxid: Responder's exchange ID * @oid: Originator's FCID * @sid: Source FCID * @did: Destination FCID * @esb_stat: ESB exchange status * @r_a_tov: Resource allocation time out value (in msecs) * @seq_id: The next sequence ID to use * @encaps: encapsulation information for lower-level driver * @f_ctl: F_CTL flags for the sequence * @fh_type: The frame type * @class: The class of service * @seq: The sequence in use on this exchange * @resp_active: Number of tasks that are concurrently executing @resp(). * @resp_task: If @resp_active > 0, either the task executing @resp(), the * task that has been interrupted to execute the soft-IRQ * executing @resp() or NULL if more than one task is executing * @resp concurrently. * @resp_wq: Waitqueue for the tasks waiting on @resp_active. * @resp: Callback for responses on this exchange * @destructor: Called when destroying the exchange * @arg: Passed as a void pointer to the resp() callback * * Locking notes: The ex_lock protects following items: * state, esb_stat, f_ctl, seq.ssb_stat * seq_id * sequence allocation */struct fc_exch { spinlock_t ex_lock; atomic_t ex_refcnt; enum fc_class class; struct fc_exch_mgr *em; struct fc_exch_pool *pool; struct list_head ex_list; struct fc_lport *lp; u32 esb_stat; u8 state; u8 fh_type; u8 seq_id; u8 encaps; u16 xid; u16 oxid; u16 rxid; u32 oid; u32 sid; u32 did; u32 r_a_tov; u32 f_ctl; struct fc_seq seq; int resp_active; struct task_struct *resp_task; wait_queue_head_t resp_wq; void (*resp)(struct fc_seq *, struct fc_frame *, void *); void *arg; void (*destructor)(struct fc_seq *, void *); struct delayed_work timeout_work;} ____cacheline_aligned_in_smp;#define fc_seq_exch(sp) container_of(sp, struct fc_exch, seq) struct libfc_function_template { /* * Interface to send a FC frame * * STATUS: REQUIRED */ int (*frame_send)(struct fc_lport *, struct fc_frame *); /* * Interface to send ELS/CT frames * * STATUS: OPTIONAL */ struct fc_seq *(*elsct_send)(struct fc_lport *, u32 did, struct fc_frame *, unsigned int op, void (*resp)(struct fc_seq *, struct fc_frame *, void *arg), void *arg, u32 timer_msec); /* * Sets up the DDP context for a given exchange id on the given * scatterlist if LLD supports DDP for large receive. * * STATUS: OPTIONAL */ int (*ddp_setup)(struct fc_lport *, u16, struct scatterlist *, unsigned int); /* * Completes the DDP transfer and returns the length of data DDPedLines 1–500 of 1031. Load more
/* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright(c) 2007 Intel Corporation. All rights reserved. * * Maintained at www.Open-FCoE.org */ #ifndef _LIBFC_H_ #define _LIBFC_H_ #include <linux/timer.h> #include <linux/if.h> #include <linux/percpu.h> #include <linux/refcount.h> #include <scsi/scsi_transport.h> #include <scsi/scsi_transport_fc.h> #include <scsi/scsi_bsg_fc.h> #include <scsi/fc/fc_fcp.h> #include <scsi/fc/fc_ns.h> #include <scsi/fc/fc_ms.h> #include <scsi/fc/fc_els.h> #include <scsi/fc/fc_gs.h> #include <scsi/fc_frame.h> #define FC_FC4_PROV_SIZE (FC_TYPE_FCP + 1) /* size of tables */ /* * libfc error codes */ #define FC_NO_ERR 0 /* no error */ #define FC_EX_TIMEOUT 1 /* Exchange timeout */ #define FC_EX_CLOSED 2 /* Exchange closed */ #define FC_EX_ALLOC_ERR 3 /* Exchange allocation failed */ #define FC_EX_XMIT_ERR 4 /* Exchange transmit failed */ #define FC_EX_ELS_RJT 5 /* ELS rejected */ #define FC_EX_INV_LOGIN 6 /* Login not completed */ #define FC_EX_SEQ_ERR 6 /* Exchange sequence error */ /** * enum fc_lport_state - Local port states * @LPORT_ST_DISABLED: Disabled * @LPORT_ST_FLOGI: Fabric login (FLOGI) sent * @LPORT_ST_DNS: Waiting for name server remote port to become ready * @LPORT_ST_RNN_ID: Register port name by ID (RNN_ID) sent * @LPORT_ST_RSNN_NN: Waiting for host symbolic node name * @LPORT_ST_RSPN_ID: Waiting for host symbolic port name * @LPORT_ST_RFT_ID: Register Fibre Channel types by ID (RFT_ID) sent * @LPORT_ST_RFF_ID: Register FC-4 Features by ID (RFF_ID) sent * @LPORT_ST_FDMI: Waiting for mgmt server rport to become ready * @LPORT_ST_RHBA: Register HBA * @LPORT_ST_RPA: Register Port Attributes * @LPORT_ST_DHBA: Deregister HBA * @LPORT_ST_DPRT: Deregister Port * @LPORT_ST_SCR: State Change Register (SCR) sent * @LPORT_ST_READY: Ready for use * @LPORT_ST_LOGO: Local port logout (LOGO) sent * @LPORT_ST_RESET: Local port reset */ enum fc_lport_state { LPORT_ST_DISABLED = 0, LPORT_ST_FLOGI, LPORT_ST_DNS, LPORT_ST_RNN_ID, LPORT_ST_RSNN_NN, LPORT_ST_RSPN_ID, LPORT_ST_RFT_ID, LPORT_ST_RFF_ID, LPORT_ST_FDMI, LPORT_ST_RHBA, LPORT_ST_RPA, LPORT_ST_DHBA, LPORT_ST_DPRT, LPORT_ST_SCR, LPORT_ST_READY, LPORT_ST_LOGO, LPORT_ST_RESET }; enum fc_disc_event { DISC_EV_NONE = 0, DISC_EV_SUCCESS, DISC_EV_FAILED }; /** * enum fc_rport_state - Remote port states * @RPORT_ST_INIT: Initialized * @RPORT_ST_FLOGI: Waiting for FLOGI completion for point-to-multipoint * @RPORT_ST_PLOGI_WAIT: Waiting for peer to login for point-to-multipoint * @RPORT_ST_PLOGI: Waiting for PLOGI completion * @RPORT_ST_PRLI: Waiting for PRLI completion * @RPORT_ST_RTV: Waiting for RTV completion * @RPORT_ST_READY: Ready for use * @RPORT_ST_ADISC: Discover Address sent * @RPORT_ST_DELETE: Remote port being deleted */ enum fc_rport_state { RPORT_ST_INIT, RPORT_ST_FLOGI, RPORT_ST_PLOGI_WAIT, RPORT_ST_PLOGI, RPORT_ST_PRLI, RPORT_ST_RTV, RPORT_ST_READY, RPORT_ST_ADISC, RPORT_ST_DELETE, }; /** * struct fc_disc_port - temporary discovery port to hold rport identifiers * @lp: Fibre Channel host port instance * @peers: Node for list management during discovery and RSCN processing * @rport_work: Work struct for starting the rport state machine * @port_id: Port ID of the discovered port */ struct fc_disc_port { struct fc_lport *lp; struct list_head peers; struct work_struct rport_work; u32 port_id; }; /** * enum fc_rport_event - Remote port events * @RPORT_EV_NONE: No event * @RPORT_EV_READY: Remote port is ready for use * @RPORT_EV_FAILED: State machine failed, remote port is not ready * @RPORT_EV_STOP: Remote port has been stopped * @RPORT_EV_LOGO: Remote port logout (LOGO) sent */ enum fc_rport_event { RPORT_EV_NONE = 0, RPORT_EV_READY, RPORT_EV_FAILED, RPORT_EV_STOP, RPORT_EV_LOGO }; struct fc_rport_priv; /** * struct fc_rport_operations - Operations for a remote port * @event_callback: Function to be called for remote port events */ struct fc_rport_operations { void (*event_callback)(struct fc_lport *, struct fc_rport_priv *, enum fc_rport_event); }; /** * struct fc_rport_libfc_priv - libfc internal information about a remote port * @local_port: The associated local port * @rp_state: Indicates READY for I/O or DELETE when blocked * @flags: REC and RETRY supported flags * @e_d_tov: Error detect timeout value (in msec) * @r_a_tov: Resource allocation timeout value (in msec) */ struct fc_rport_libfc_priv { struct fc_lport *local_port; enum fc_rport_state rp_state; u16 flags; #define FC_RP_FLAGS_REC_SUPPORTED (1 << 0) #define FC_RP_FLAGS_RETRY (1 << 1) #define FC_RP_STARTED (1 << 2) #define FC_RP_FLAGS_CONF_REQ (1 << 3) unsigned int e_d_tov; unsigned int r_a_tov; }; /** * struct fc_rport_priv - libfc remote port and discovery info * @local_port: The associated local port * @rport: The FC transport remote port * @kref: Reference counter * @rp_state: Enumeration that tracks progress of PLOGI, PRLI, * and RTV exchanges * @ids: The remote port identifiers and roles * @flags: STARTED, REC and RETRY_SUPPORTED flags * @max_seq: Maximum number of concurrent sequences * @disc_id: The discovery identifier * @maxframe_size: The maximum frame size * @retries: The retry count for the current state * @major_retries: The retry count for the entire PLOGI/PRLI state machine * @e_d_tov: Error detect timeout value (in msec) * @r_a_tov: Resource allocation timeout value (in msec) * @rp_mutex: The mutex that protects the remote port * @retry_work: Handle for retries * @lld_event_callback: Callback when READY, FAILED or LOGO states complete * @prli_count: Count of open PRLI sessions in providers * @rcu: Structure used for freeing in an RCU-safe manner */ struct fc_rport_priv { struct fc_lport *local_port; struct fc_rport *rport; struct kref kref; enum fc_rport_state rp_state; struct fc_rport_identifiers ids; u16 flags; u16 max_seq; u16 disc_id; u16 maxframe_size; unsigned int retries; unsigned int major_retries; unsigned int e_d_tov; unsigned int r_a_tov; struct mutex rp_mutex; struct delayed_work retry_work; enum fc_rport_event event; struct fc_rport_operations *ops; struct list_head peers; struct work_struct event_work; u32 supported_classes; u16 prli_count; struct rcu_head rcu; u16 sp_features; u8 spp_type; void (*lld_event_callback)(struct fc_lport *, struct fc_rport_priv *, enum fc_rport_event); }; /** * struct fc_stats - fc stats structure * @SecondsSinceLastReset: Seconds since the last reset * @TxFrames: Number of transmitted frames * @TxWords: Number of transmitted words * @RxFrames: Number of received frames * @RxWords: Number of received words * @ErrorFrames: Number of received error frames * @DumpedFrames: Number of dumped frames * @FcpPktAllocFails: Number of fcp packet allocation failures * @FcpPktAborts: Number of fcp packet aborts * @FcpFrameAllocFails: Number of fcp frame allocation failures * @LinkFailureCount: Number of link failures * @LossOfSignalCount: Number for signal losses * @InvalidTxWordCount: Number of invalid transmitted words * @InvalidCRCCount: Number of invalid CRCs * @InputRequests: Number of input requests * @OutputRequests: Number of output requests * @ControlRequests: Number of control requests * @InputBytes: Number of received bytes * @OutputBytes: Number of transmitted bytes * @VLinkFailureCount: Number of virtual link failures * @MissDiscAdvCount: Number of missing FIP discovery advertisement */ struct fc_stats { u64 SecondsSinceLastReset; u64 TxFrames; u64 TxWords; u64 RxFrames; u64 RxWords; u64 ErrorFrames; u64 DumpedFrames; u64 FcpPktAllocFails; u64 FcpPktAborts; u64 FcpFrameAllocFails; u64 LinkFailureCount; u64 LossOfSignalCount; u64 InvalidTxWordCount; u64 InvalidCRCCount; u64 InputRequests; u64 OutputRequests; u64 ControlRequests; u64 InputBytes; u64 OutputBytes; u64 VLinkFailureCount; u64 MissDiscAdvCount; }; /** * struct fc_seq_els_data - ELS data used for passing ELS specific responses * @reason: The reason for rejection * @explan: The explanation of the rejection * * Mainly used by the exchange manager layer. */ struct fc_seq_els_data { enum fc_els_rjt_reason reason; enum fc_els_rjt_explan explan; }; /** * struct fc_fcp_pkt - FCP request structure (one for each scsi_cmnd request) * @lp: The associated local port * @state: The state of the I/O * @ref_cnt: Reference count * @scsi_pkt_lock: Lock to protect the SCSI packet (must be taken before the * host_lock if both are to be held at the same time) * @cmd: The SCSI command (set and clear with the host_lock held) * @list: Tracks queued commands (accessed with the host_lock held) * @timer: The command timer * @tm_done: Completion indicator * @wait_for_comp: Indicator to wait for completion of the I/O (in jiffies) * @timer_delay: FCP packet timer delay in jiffies * @data_len: The length of the data * @cdb_cmd: The CDB command * @xfer_len: The transfer length * @xfer_ddp: Indicates if this transfer used DDP (XID of the exchange * will be set here if DDP was setup) * @xfer_contig_end: The offset into the buffer if the buffer is contiguous * (Tx and Rx) * @max_payload: The maximum payload size (in bytes) * @io_status: SCSI result (upper 24 bits) * @cdb_status: CDB status * @status_code: FCP I/O status * @scsi_comp_flags: Completion flags (bit 3 Underrun bit 2: overrun) * @req_flags: Request flags (bit 0: read bit:1 write) * @scsi_resid: SCSI residule length * @rport: The remote port that the SCSI command is targeted at * @seq_ptr: The sequence that will carry the SCSI command * @recov_retry: Number of recovery retries * @recov_seq: The sequence for REC or SRR */ struct fc_fcp_pkt { spinlock_t scsi_pkt_lock; refcount_t ref_cnt; /* SCSI command and data transfer information */ u32 data_len; /* SCSI I/O related information */ struct scsi_cmnd *cmd; struct list_head list; /* Housekeeping information */ struct fc_lport *lp; u8 state; /* SCSI/FCP return status */ u8 cdb_status; u8 status_code; u8 scsi_comp_flags; u32 io_status; u32 req_flags; u32 scsi_resid; /* Transport related veriables */ size_t xfer_len; struct fcp_cmnd cdb_cmd; u32 xfer_contig_end; u16 max_payload; u16 xfer_ddp; /* Associated structures */ struct fc_rport *rport; struct fc_seq *seq_ptr; /* Timeout/error related information */ struct timer_list timer; int wait_for_comp; int timer_delay; u32 recov_retry; struct fc_seq *recov_seq; struct completion tm_done; } ____cacheline_aligned_in_smp; /* * @fsp should be tested and set under the scsi_pkt_queue lock */ struct libfc_cmd_priv { struct fc_fcp_pkt *fsp; u32 resid_len; u8 status; }; /* * Structure and function definitions for managing Fibre Channel Exchanges * and Sequences * * fc_exch holds state for one exchange and links to its active sequence. * * fc_seq holds the state for an individual sequence. */ struct fc_exch_mgr; struct fc_exch_mgr_anchor; extern u16 fc_cpu_mask; /* cpu mask for possible cpus */ /** * struct fc_seq - FC sequence * @id: The sequence ID * @ssb_stat: Status flags for the sequence status block (SSB) * @cnt: Number of frames sent so far * @rec_data: FC-4 value for REC */ struct fc_seq { u8 id; u16 ssb_stat; u16 cnt; u32 rec_data; }; #define FC_EX_DONE (1 << 0) /* ep is completed */ #define FC_EX_RST_CLEANUP (1 << 1) /* reset is forcing completion */ #define FC_EX_QUARANTINE (1 << 2) /* exch is quarantined */ /** * struct fc_exch - Fibre Channel Exchange * @em: Exchange manager * @pool: Exchange pool * @state: The exchange's state * @xid: The exchange ID * @ex_list: Handle used by the EM to track free exchanges * @ex_lock: Lock that protects the exchange * @ex_refcnt: Reference count * @timeout_work: Handle for timeout handler * @lp: The local port that this exchange is on * @oxid: Originator's exchange ID * @rxid: Responder's exchange ID * @oid: Originator's FCID * @sid: Source FCID * @did: Destination FCID * @esb_stat: ESB exchange status * @r_a_tov: Resource allocation time out value (in msecs) * @seq_id: The next sequence ID to use * @encaps: encapsulation information for lower-level driver * @f_ctl: F_CTL flags for the sequence * @fh_type: The frame type * @class: The class of service * @seq: The sequence in use on this exchange * @resp_active: Number of tasks that are concurrently executing @resp(). * @resp_task: If @resp_active > 0, either the task executing @resp(), the * task that has been interrupted to execute the soft-IRQ * executing @resp() or NULL if more than one task is executing * @resp concurrently. * @resp_wq: Waitqueue for the tasks waiting on @resp_active. * @resp: Callback for responses on this exchange * @destructor: Called when destroying the exchange * @arg: Passed as a void pointer to the resp() callback * * Locking notes: The ex_lock protects following items: * state, esb_stat, f_ctl, seq.ssb_stat * seq_id * sequence allocation */ struct fc_exch { spinlock_t ex_lock; atomic_t ex_refcnt; enum fc_class class; struct fc_exch_mgr *em; struct fc_exch_pool *pool; struct list_head ex_list; struct fc_lport *lp; u32 esb_stat; u8 state; u8 fh_type; u8 seq_id; u8 encaps; u16 xid; u16 oxid; u16 rxid; u32 oid; u32 sid; u32 did; u32 r_a_tov; u32 f_ctl; struct fc_seq seq; int resp_active; struct task_struct *resp_task; wait_queue_head_t resp_wq; void (*resp)(struct fc_seq *, struct fc_frame *, void *); void *arg; void (*destructor)(struct fc_seq *, void *); struct delayed_work timeout_work; } ____cacheline_aligned_in_smp; #define fc_seq_exch(sp) container_of(sp, struct fc_exch, seq) struct libfc_function_template { /* * Interface to send a FC frame * * STATUS: REQUIRED */ int (*frame_send)(struct fc_lport *, struct fc_frame *); /* * Interface to send ELS/CT frames * * STATUS: OPTIONAL */ struct fc_seq *(*elsct_send)(struct fc_lport *, u32 did, struct fc_frame *, unsigned int op, void (*resp)(struct fc_seq *, struct fc_frame *, void *arg), void *arg, u32 timer_msec); /* * Sets up the DDP context for a given exchange id on the given * scatterlist if LLD supports DDP for large receive. * * STATUS: OPTIONAL */ int (*ddp_setup)(struct fc_lport *, u16, struct scatterlist *, unsigned int); /* * Completes the DDP transfer and returns the length of data DDPed