Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  * Copyright(c) 2007 Intel Corporation. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  * Maintained at www.Open-FCoE.org
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8) #ifndef _LIBFC_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9) #define _LIBFC_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12) #include <linux/if.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13) #include <linux/percpu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14) #include <linux/refcount.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16) #include <scsi/scsi_transport.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17) #include <scsi/scsi_transport_fc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18) #include <scsi/scsi_bsg_fc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20) #include <scsi/fc/fc_fcp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) #include <scsi/fc/fc_ns.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) #include <scsi/fc/fc_ms.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) #include <scsi/fc/fc_els.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) #include <scsi/fc/fc_gs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) #include <scsi/fc_frame.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) #define	FC_FC4_PROV_SIZE	(FC_TYPE_FCP + 1)	/* size of tables */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31)  * libfc error codes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) #define	FC_NO_ERR	0	/* no error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) #define	FC_EX_TIMEOUT	1	/* Exchange timeout */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) #define	FC_EX_CLOSED	2	/* Exchange closed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) #define FC_EX_ALLOC_ERR	3	/* Exchange allocation failed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) #define FC_EX_XMIT_ERR	4	/* Exchange transmit failed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) #define FC_EX_ELS_RJT	5	/* ELS rejected */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) #define FC_EX_INV_LOGIN	6	/* Login not completed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) #define FC_EX_SEQ_ERR	6	/* Exchange sequence error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43)  * enum fc_lport_state - Local port states
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44)  * @LPORT_ST_DISABLED: Disabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45)  * @LPORT_ST_FLOGI:    Fabric login (FLOGI) sent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46)  * @LPORT_ST_DNS:      Waiting for name server remote port to become ready
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47)  * @LPORT_ST_RPN_ID:   Register port name by ID (RPN_ID) sent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48)  * @LPORT_ST_RFT_ID:   Register Fibre Channel types by ID (RFT_ID) sent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49)  * @LPORT_ST_RFF_ID:   Register FC-4 Features by ID (RFF_ID) sent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50)  * @LPORT_ST_FDMI:     Waiting for mgmt server rport to become ready
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51)  * @LPORT_ST_RHBA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52)  * @LPORT_ST_SCR:      State Change Register (SCR) sent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53)  * @LPORT_ST_READY:    Ready for use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54)  * @LPORT_ST_LOGO:     Local port logout (LOGO) sent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55)  * @LPORT_ST_RESET:    Local port reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) enum fc_lport_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) 	LPORT_ST_DISABLED = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) 	LPORT_ST_FLOGI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) 	LPORT_ST_DNS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) 	LPORT_ST_RNN_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) 	LPORT_ST_RSNN_NN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) 	LPORT_ST_RSPN_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) 	LPORT_ST_RFT_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) 	LPORT_ST_RFF_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) 	LPORT_ST_FDMI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) 	LPORT_ST_RHBA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) 	LPORT_ST_RPA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) 	LPORT_ST_DHBA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) 	LPORT_ST_DPRT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) 	LPORT_ST_SCR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) 	LPORT_ST_READY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) 	LPORT_ST_LOGO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) 	LPORT_ST_RESET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) enum fc_disc_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) 	DISC_EV_NONE = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) 	DISC_EV_SUCCESS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) 	DISC_EV_FAILED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84)  * enum fc_rport_state - Remote port states
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85)  * @RPORT_ST_INIT:    Initialized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86)  * @RPORT_ST_FLOGI:   Waiting for FLOGI completion for point-to-multipoint
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87)  * @RPORT_ST_PLOGI_WAIT:   Waiting for peer to login for point-to-multipoint
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88)  * @RPORT_ST_PLOGI:   Waiting for PLOGI completion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89)  * @RPORT_ST_PRLI:    Waiting for PRLI completion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90)  * @RPORT_ST_RTV:     Waiting for RTV completion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91)  * @RPORT_ST_READY:   Ready for use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92)  * @RPORT_ST_ADISC:   Discover Address sent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93)  * @RPORT_ST_DELETE:  Remote port being deleted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) enum fc_rport_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) 	RPORT_ST_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) 	RPORT_ST_FLOGI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) 	RPORT_ST_PLOGI_WAIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) 	RPORT_ST_PLOGI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) 	RPORT_ST_PRLI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) 	RPORT_ST_RTV,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) 	RPORT_ST_READY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) 	RPORT_ST_ADISC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) 	RPORT_ST_DELETE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108)  * struct fc_disc_port - temporary discovery port to hold rport identifiers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109)  * @lp:         Fibre Channel host port instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110)  * @peers:      Node for list management during discovery and RSCN processing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111)  * @rport_work: Work struct for starting the rport state machine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112)  * @port_id:    Port ID of the discovered port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) struct fc_disc_port {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) 	struct fc_lport    *lp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) 	struct list_head   peers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 	struct work_struct rport_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) 	u32		   port_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122)  * enum fc_rport_event - Remote port events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123)  * @RPORT_EV_NONE:   No event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124)  * @RPORT_EV_READY:  Remote port is ready for use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125)  * @RPORT_EV_FAILED: State machine failed, remote port is not ready
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126)  * @RPORT_EV_STOP:   Remote port has been stopped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127)  * @RPORT_EV_LOGO:   Remote port logout (LOGO) sent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) enum fc_rport_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) 	RPORT_EV_NONE = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) 	RPORT_EV_READY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) 	RPORT_EV_FAILED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) 	RPORT_EV_STOP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) 	RPORT_EV_LOGO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) struct fc_rport_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140)  * struct fc_rport_operations - Operations for a remote port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141)  * @event_callback: Function to be called for remote port events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) struct fc_rport_operations {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) 	void (*event_callback)(struct fc_lport *, struct fc_rport_priv *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) 			       enum fc_rport_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149)  * struct fc_rport_libfc_priv - libfc internal information about a remote port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150)  * @local_port: The associated local port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151)  * @rp_state:   Indicates READY for I/O or DELETE when blocked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152)  * @flags:      REC and RETRY supported flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153)  * @e_d_tov:    Error detect timeout value (in msec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154)  * @r_a_tov:    Resource allocation timeout value (in msec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) struct fc_rport_libfc_priv {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) 	struct fc_lport		   *local_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) 	enum fc_rport_state	   rp_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 	u16			   flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) 	#define FC_RP_FLAGS_REC_SUPPORTED	(1 << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) 	#define FC_RP_FLAGS_RETRY		(1 << 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) 	#define FC_RP_STARTED			(1 << 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) 	#define FC_RP_FLAGS_CONF_REQ		(1 << 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) 	unsigned int		   e_d_tov;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) 	unsigned int		   r_a_tov;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169)  * struct fc_rport_priv - libfc remote port and discovery info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170)  * @local_port:     The associated local port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171)  * @rport:          The FC transport remote port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172)  * @kref:           Reference counter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173)  * @rp_state:       Enumeration that tracks progress of PLOGI, PRLI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174)  *                  and RTV exchanges
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175)  * @ids:            The remote port identifiers and roles
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176)  * @flags:          STARTED, REC and RETRY_SUPPORTED flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177)  * @max_seq:        Maximum number of concurrent sequences
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178)  * @disc_id:        The discovery identifier
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179)  * @maxframe_size:  The maximum frame size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180)  * @retries:        The retry count for the current state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181)  * @major_retries:  The retry count for the entire PLOGI/PRLI state machine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182)  * @e_d_tov:        Error detect timeout value (in msec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183)  * @r_a_tov:        Resource allocation timeout value (in msec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184)  * @rp_mutex:       The mutex that protects the remote port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185)  * @retry_work:     Handle for retries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186)  * @event_callback: Callback when READY, FAILED or LOGO states complete
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187)  * @prli_count:     Count of open PRLI sessions in providers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188)  * @rcu:	    Structure used for freeing in an RCU-safe manner
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) struct fc_rport_priv {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 	struct fc_lport		    *local_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 	struct fc_rport		    *rport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) 	struct kref		    kref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) 	enum fc_rport_state	    rp_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) 	struct fc_rport_identifiers ids;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) 	u16			    flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) 	u16			    max_seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) 	u16			    disc_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) 	u16			    maxframe_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) 	unsigned int		    retries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) 	unsigned int		    major_retries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) 	unsigned int		    e_d_tov;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) 	unsigned int		    r_a_tov;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) 	struct mutex		    rp_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) 	struct delayed_work	    retry_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 	enum fc_rport_event	    event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) 	struct fc_rport_operations  *ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) 	struct list_head	    peers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) 	struct work_struct	    event_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) 	u32			    supported_classes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) 	u16			    prli_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) 	struct rcu_head		    rcu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) 	u16			    sp_features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 	u8			    spp_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) 	void			    (*lld_event_callback)(struct fc_lport *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) 						      struct fc_rport_priv *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) 						      enum fc_rport_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221)  * struct fc_stats - fc stats structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222)  * @SecondsSinceLastReset: Seconds since the last reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223)  * @TxFrames:              Number of transmitted frames
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224)  * @TxWords:               Number of transmitted words
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225)  * @RxFrames:              Number of received frames
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226)  * @RxWords:               Number of received words
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227)  * @ErrorFrames:           Number of received error frames
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228)  * @DumpedFrames:          Number of dumped frames
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229)  * @FcpPktAllocFails:      Number of fcp packet allocation failures
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230)  * @FcpPktAborts:          Number of fcp packet aborts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231)  * @FcpFrameAllocFails:    Number of fcp frame allocation failures
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232)  * @LinkFailureCount:      Number of link failures
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233)  * @LossOfSignalCount:     Number for signal losses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234)  * @InvalidTxWordCount:    Number of invalid transmitted words
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235)  * @InvalidCRCCount:       Number of invalid CRCs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236)  * @InputRequests:         Number of input requests
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237)  * @OutputRequests:        Number of output requests
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238)  * @ControlRequests:       Number of control requests
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239)  * @InputBytes:            Number of received bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240)  * @OutputBytes:           Number of transmitted bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241)  * @VLinkFailureCount:     Number of virtual link failures
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242)  * @MissDiscAdvCount:      Number of missing FIP discovery advertisement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) struct fc_stats {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 	u64		SecondsSinceLastReset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) 	u64		TxFrames;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 	u64		TxWords;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) 	u64		RxFrames;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 	u64		RxWords;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 	u64		ErrorFrames;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 	u64		DumpedFrames;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 	u64		FcpPktAllocFails;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 	u64		FcpPktAborts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 	u64		FcpFrameAllocFails;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 	u64		LinkFailureCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) 	u64		LossOfSignalCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 	u64		InvalidTxWordCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) 	u64		InvalidCRCCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 	u64		InputRequests;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) 	u64		OutputRequests;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) 	u64		ControlRequests;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) 	u64		InputBytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) 	u64		OutputBytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) 	u64		VLinkFailureCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) 	u64		MissDiscAdvCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269)  * struct fc_seq_els_data - ELS data used for passing ELS specific responses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270)  * @reason: The reason for rejection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271)  * @explan: The explanation of the rejection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273)  * Mainly used by the exchange manager layer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) struct fc_seq_els_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) 	enum fc_els_rjt_reason reason;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) 	enum fc_els_rjt_explan explan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281)  * struct fc_fcp_pkt - FCP request structure (one for each scsi_cmnd request)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282)  * @lp:              The associated local port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283)  * @state:           The state of the I/O
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284)  * @ref_cnt:         Reference count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285)  * @scsi_pkt_lock:   Lock to protect the SCSI packet (must be taken before the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286)  *                   host_lock if both are to be held at the same time)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287)  * @cmd:             The SCSI command (set and clear with the host_lock held)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288)  * @list:            Tracks queued commands (accessed with the host_lock held)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289)  * @timer:           The command timer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290)  * @tm_done:         Completion indicator
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291)  * @wait_for_comp:   Indicator to wait for completion of the I/O (in jiffies)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292)  * @data_len:        The length of the data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293)  * @cdb_cmd:         The CDB command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294)  * @xfer_len:        The transfer length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295)  * @xfer_ddp:        Indicates if this transfer used DDP (XID of the exchange
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296)  *                   will be set here if DDP was setup)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297)  * @xfer_contig_end: The offset into the buffer if the buffer is contiguous
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298)  *                   (Tx and Rx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299)  * @max_payload:     The maximum payload size (in bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300)  * @io_status:       SCSI result (upper 24 bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301)  * @cdb_status:      CDB status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302)  * @status_code:     FCP I/O status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303)  * @scsi_comp_flags: Completion flags (bit 3 Underrun bit 2: overrun)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304)  * @req_flags:       Request flags (bit 0: read bit:1 write)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305)  * @scsi_resid:      SCSI residule length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306)  * @rport:           The remote port that the SCSI command is targeted at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307)  * @seq_ptr:         The sequence that will carry the SCSI command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308)  * @recov_retry:     Number of recovery retries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309)  * @recov_seq:       The sequence for REC or SRR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) struct fc_fcp_pkt {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 	spinlock_t	  scsi_pkt_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 	refcount_t	  ref_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 	/* SCSI command and data transfer information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 	u32		  data_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 	/* SCSI I/O related information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) 	struct scsi_cmnd  *cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 	struct list_head  list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) 	/* Housekeeping information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) 	struct fc_lport   *lp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) 	u8		  state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 	/* SCSI/FCP return status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) 	u8		  cdb_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 	u8		  status_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 	u8		  scsi_comp_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 	u32		  io_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) 	u32		  req_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 	u32		  scsi_resid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) 	/* Transport related veriables */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 	size_t		  xfer_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 	struct fcp_cmnd   cdb_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 	u32		  xfer_contig_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) 	u16		  max_payload;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 	u16		  xfer_ddp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 	/* Associated structures */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 	struct fc_rport	  *rport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 	struct fc_seq	  *seq_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 	/* Timeout/error related information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 	struct timer_list timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 	int		  wait_for_comp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 	int		  timer_delay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 	u32		  recov_retry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 	struct fc_seq	  *recov_seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 	struct completion tm_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) } ____cacheline_aligned_in_smp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355)  * Structure and function definitions for managing Fibre Channel Exchanges
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356)  * and Sequences
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358)  * fc_exch holds state for one exchange and links to its active sequence.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360)  * fc_seq holds the state for an individual sequence.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) struct fc_exch_mgr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) struct fc_exch_mgr_anchor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) extern u16 fc_cpu_mask;	/* cpu mask for possible cpus */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368)  * struct fc_seq - FC sequence
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369)  * @id:       The sequence ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370)  * @ssb_stat: Status flags for the sequence status block (SSB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371)  * @cnt:      Number of frames sent so far
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372)  * @rec_data: FC-4 value for REC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) struct fc_seq {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 	u8  id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 	u16 ssb_stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 	u16 cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 	u32 rec_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) #define FC_EX_DONE		(1 << 0) /* ep is completed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) #define FC_EX_RST_CLEANUP	(1 << 1) /* reset is forcing completion */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) #define FC_EX_QUARANTINE	(1 << 2) /* exch is quarantined */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386)  * struct fc_exch - Fibre Channel Exchange
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387)  * @em:           Exchange manager
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388)  * @pool:         Exchange pool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389)  * @state:        The exchange's state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390)  * @xid:          The exchange ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391)  * @ex_list:      Handle used by the EM to track free exchanges
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392)  * @ex_lock:      Lock that protects the exchange
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393)  * @ex_refcnt:    Reference count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394)  * @timeout_work: Handle for timeout handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395)  * @lp:           The local port that this exchange is on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396)  * @oxid:         Originator's exchange ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397)  * @rxid:         Responder's exchange ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398)  * @oid:          Originator's FCID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399)  * @sid:          Source FCID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400)  * @did:          Destination FCID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401)  * @esb_stat:     ESB exchange status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402)  * @r_a_tov:      Resouce allocation time out value (in msecs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403)  * @seq_id:       The next sequence ID to use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404)  * @encaps:       encapsulation information for lower-level driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405)  * @f_ctl:        F_CTL flags for the sequence
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406)  * @fh_type:      The frame type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407)  * @class:        The class of service
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408)  * @seq:          The sequence in use on this exchange
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409)  * @resp_active:  Number of tasks that are concurrently executing @resp().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410)  * @resp_task:    If @resp_active > 0, either the task executing @resp(), the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411)  *                task that has been interrupted to execute the soft-IRQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412)  *                executing @resp() or NULL if more than one task is executing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413)  *                @resp concurrently.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414)  * @resp_wq:      Waitqueue for the tasks waiting on @resp_active.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415)  * @resp:         Callback for responses on this exchange
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416)  * @destructor:   Called when destroying the exchange
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417)  * @arg:          Passed as a void pointer to the resp() callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419)  * Locking notes: The ex_lock protects following items:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420)  *	state, esb_stat, f_ctl, seq.ssb_stat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421)  *	seq_id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422)  *	sequence allocation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) struct fc_exch {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 	spinlock_t	    ex_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 	atomic_t	    ex_refcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 	enum fc_class	    class;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 	struct fc_exch_mgr  *em;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 	struct fc_exch_pool *pool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) 	struct list_head    ex_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 	struct fc_lport	    *lp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) 	u32		    esb_stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) 	u8		    state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 	u8		    fh_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 	u8		    seq_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 	u8		    encaps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) 	u16		    xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) 	u16		    oxid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) 	u16		    rxid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) 	u32		    oid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 	u32		    sid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) 	u32		    did;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 	u32		    r_a_tov;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 	u32		    f_ctl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) 	struct fc_seq       seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) 	int		    resp_active;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 	struct task_struct  *resp_task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 	wait_queue_head_t   resp_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) 	void		    (*resp)(struct fc_seq *, struct fc_frame *, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) 	void		    *arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) 	void		    (*destructor)(struct fc_seq *, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) 	struct delayed_work timeout_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) } ____cacheline_aligned_in_smp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) #define	fc_seq_exch(sp) container_of(sp, struct fc_exch, seq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) struct libfc_function_template {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) 	 * Interface to send a FC frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) 	 * STATUS: REQUIRED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 	int (*frame_send)(struct fc_lport *, struct fc_frame *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) 	 * Interface to send ELS/CT frames
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) 	 * STATUS: OPTIONAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) 	struct fc_seq *(*elsct_send)(struct fc_lport *, u32 did,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) 				     struct fc_frame *, unsigned int op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 				     void (*resp)(struct fc_seq *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) 					     struct fc_frame *, void *arg),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 				     void *arg, u32 timer_msec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 	 * Sets up the DDP context for a given exchange id on the given
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) 	 * scatterlist if LLD supports DDP for large receive.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) 	 * STATUS: OPTIONAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) 	int (*ddp_setup)(struct fc_lport *, u16, struct scatterlist *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) 			 unsigned int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 	 * Completes the DDP transfer and returns the length of data DDPed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) 	 * for the given exchange id.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 	 * STATUS: OPTIONAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 	int (*ddp_done)(struct fc_lport *, u16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 	 * Sets up the DDP context for a given exchange id on the given
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 	 * scatterlist if LLD supports DDP for target.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 	 * STATUS: OPTIONAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 	int (*ddp_target)(struct fc_lport *, u16, struct scatterlist *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) 			  unsigned int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 	 * Allow LLD to fill its own Link Error Status Block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 	 * STATUS: OPTIONAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) 	void (*get_lesb)(struct fc_lport *, struct fc_els_lesb *lesb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) 	 * Reset an exchange manager, completing all sequences and exchanges.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) 	 * If s_id is non-zero, reset only exchanges originating from that FID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 	 * If d_id is non-zero, reset only exchanges sending to that FID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 	 * STATUS: OPTIONAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 	void (*exch_mgr_reset)(struct fc_lport *, u32 s_id, u32 d_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 	 * Set the local port FC_ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 	 * This may be provided by the LLD to allow it to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 	 * notified when the local port is assigned a FC-ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 	 * The frame, if non-NULL, is the incoming frame with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 	 * FLOGI LS_ACC or FLOGI, and may contain the granted MAC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 	 * address for the LLD.  The frame pointer may be NULL if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 	 * no MAC is associated with this assignment (LOGO or PLOGI).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) 	 * If FC_ID is non-zero, r_a_tov and e_d_tov must be valid.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) 	 * Note: this is called with the local port mutex held.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) 	 * STATUS: OPTIONAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 	void (*lport_set_port_id)(struct fc_lport *, u32 port_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) 				  struct fc_frame *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) 	 * Callback routine after the remote port is logged in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) 	 * STATUS: OPTIONAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 	void (*rport_event_callback)(struct fc_lport *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 				     struct fc_rport_priv *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) 				     enum fc_rport_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 	 * Send a fcp cmd from fsp pkt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 	 * Called with the SCSI host lock unlocked and irqs disabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) 	 * The resp handler is called when FCP_RSP received.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 	 * STATUS: OPTIONAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) 	int (*fcp_cmd_send)(struct fc_lport *, struct fc_fcp_pkt *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) 			    void (*resp)(struct fc_seq *, struct fc_frame *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) 					 void *));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) 	 * Cleanup the FCP layer, used during link down and reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) 	 * STATUS: OPTIONAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) 	void (*fcp_cleanup)(struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 	 * Abort all I/O on a local port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 	 * STATUS: OPTIONAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 	void (*fcp_abort_io)(struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 	 * Receive a request for the discovery layer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 	 * STATUS: OPTIONAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 	void (*disc_recv_req)(struct fc_lport *, struct fc_frame *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 	 * Start discovery for a local port.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 	 * STATUS: OPTIONAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 	void (*disc_start)(void (*disc_callback)(struct fc_lport *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 						 enum fc_disc_event),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 			   struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 	 * Stop discovery for a given lport. This will remove
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 	 * all discovered rports
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) 	 * STATUS: OPTIONAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) 	void (*disc_stop) (struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) 	 * Stop discovery for a given lport. This will block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 	 * until all discovered rports are deleted from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 	 * FC transport class
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 	 * STATUS: OPTIONAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 	void (*disc_stop_final) (struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605)  * struct fc_disc - Discovery context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606)  * @retry_count:   Number of retries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607)  * @pending:       1 if discovery is pending, 0 if not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608)  * @requested:     1 if discovery has been requested, 0 if not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609)  * @seq_count:     Number of sequences used for discovery
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610)  * @buf_len:       Length of the discovery buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611)  * @disc_id:       Discovery ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612)  * @rports:        List of discovered remote ports
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613)  * @priv:          Private pointer for use by discovery code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614)  * @disc_mutex:    Mutex that protects the discovery context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615)  * @partial_buf:   Partial name buffer (if names are returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616)  *                 in multiple frames)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617)  * @disc_work:     handle for delayed work context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618)  * @disc_callback: Callback routine called when discovery completes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) struct fc_disc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 	unsigned char	      retry_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 	unsigned char	      pending;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 	unsigned char	      requested;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 	unsigned short	      seq_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 	unsigned char	      buf_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) 	u16		      disc_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 	struct list_head      rports;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 	void		      *priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 	struct mutex	      disc_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) 	struct fc_gpn_ft_resp partial_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) 	struct delayed_work   disc_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) 	void (*disc_callback)(struct fc_lport *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 			      enum fc_disc_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639)  * Local port notifier and events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) extern struct blocking_notifier_head fc_lport_notifier_head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) enum fc_lport_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 	FC_LPORT_EV_ADD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) 	FC_LPORT_EV_DEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648)  * struct fc_lport - Local port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649)  * @host:                  The SCSI host associated with a local port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650)  * @ema_list:              Exchange manager anchor list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651)  * @dns_rdata:             The directory server remote port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652)  * @ms_rdata:		   The management server remote port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653)  * @ptp_rdata:             Point to point remote port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654)  * @scsi_priv:             FCP layer internal data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655)  * @disc:                  Discovery context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656)  * @vports:                Child vports if N_Port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657)  * @vport:                 Parent vport if VN_Port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658)  * @tt:                    Libfc function template
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659)  * @link_up:               Link state (1 = link up, 0 = link down)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660)  * @qfull:                 Queue state (1 queue is full, 0 queue is not full)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661)  * @state:                 Identifies the state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662)  * @boot_time:             Timestamp indicating when the local port came online
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663)  * @host_stats:            SCSI host statistics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664)  * @stats:                 FC local port stats (TODO separate libfc LLD stats)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665)  * @retry_count:           Number of retries in the current state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666)  * @port_id:               FC Port ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667)  * @wwpn:                  World Wide Port Name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668)  * @wwnn:                  World Wide Node Name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669)  * @service_params:        Common service parameters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670)  * @e_d_tov:               Error detection timeout value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671)  * @r_a_tov:               Resouce allocation timeout value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672)  * @rnid_gen:              RNID information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673)  * @sg_supp:               Indicates if scatter gather is supported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674)  * @seq_offload:           Indicates if sequence offload is supported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675)  * @crc_offload:           Indicates if CRC offload is supported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676)  * @lro_enabled:           Indicates if large receive offload is supported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677)  * @does_npiv:             Supports multiple vports
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678)  * @npiv_enabled:          Switch/fabric allows NPIV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679)  * @mfs:                   The maximum Fibre Channel payload size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680)  * @max_retry_count:       The maximum retry attempts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681)  * @max_rport_retry_count: The maximum remote port retry attempts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682)  * @rport_priv_size:       Size needed by driver after struct fc_rport_priv
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683)  * @lro_xid:               The maximum XID for LRO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684)  * @lso_max:               The maximum large offload send size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685)  * @fcts:                  FC-4 type mask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686)  * @lp_mutex:              Mutex to protect the local port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687)  * @list:                  Linkage on list of vport peers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688)  * @retry_work:            Handle to local port for delayed retry context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689)  * @prov:		   Pointers available for use by passive FC-4 providers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690)  * @lport_list:            Linkage on module-wide list of local ports
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) struct fc_lport {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 	/* Associations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 	struct Scsi_Host	       *host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 	struct list_head	       ema_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 	struct fc_rport_priv	       *dns_rdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 	struct fc_rport_priv	       *ms_rdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 	struct fc_rport_priv	       *ptp_rdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 	void			       *scsi_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 	struct fc_disc		       disc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 	/* Virtual port information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) 	struct list_head	       vports;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 	struct fc_vport		       *vport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 	/* Operational Information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 	struct libfc_function_template tt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 	u8			       link_up;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 	u8			       qfull;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) 	u16			       vlan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 	enum fc_lport_state	       state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) 	unsigned long		       boot_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) 	struct fc_host_statistics      host_stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) 	struct fc_stats	__percpu       *stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) 	u8			       retry_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 	/* Fabric information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) 	u32			       port_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) 	u64			       wwpn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) 	u64			       wwnn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) 	unsigned int		       service_params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) 	unsigned int		       e_d_tov;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) 	unsigned int		       r_a_tov;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 	struct fc_els_rnid_gen	       rnid_gen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 	/* Capabilities */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 	u32			       sg_supp:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 	u32			       seq_offload:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) 	u32			       crc_offload:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) 	u32			       lro_enabled:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 	u32			       does_npiv:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 	u32			       npiv_enabled:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) 	u32			       point_to_multipoint:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 	u32			       fdmi_enabled:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) 	u32			       mfs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 	u8			       max_retry_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 	u8			       max_rport_retry_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 	u16			       rport_priv_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 	u16			       link_speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 	u16			       link_supported_speeds;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 	u16			       lro_xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 	unsigned int		       lso_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 	struct fc_ns_fts	       fcts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 	/* Miscellaneous */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 	struct mutex		       lp_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 	struct list_head	       list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 	struct delayed_work	       retry_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 	void			       *prov[FC_FC4_PROV_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 	struct list_head	       lport_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754)  * struct fc4_prov - FC-4 provider registration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755)  * @prli:               Handler for incoming PRLI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756)  * @prlo:               Handler for session reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757)  * @recv:		Handler for incoming request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758)  * @module:		Pointer to module.  May be NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) struct fc4_prov {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) 	int (*prli)(struct fc_rport_priv *, u32 spp_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 		    const struct fc_els_spp *spp_in,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) 		    struct fc_els_spp *spp_out);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) 	void (*prlo)(struct fc_rport_priv *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 	void (*recv)(struct fc_lport *, struct fc_frame *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 	struct module *module;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770)  * Register FC-4 provider with libfc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) int fc_fc4_register_provider(enum fc_fh_type type, struct fc4_prov *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) void fc_fc4_deregister_provider(enum fc_fh_type type, struct fc4_prov *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776)  * FC_LPORT HELPER FUNCTIONS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777)  *****************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780)  * fc_lport_test_ready() - Determine if a local port is in the READY state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781)  * @lport: The local port to test
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) static inline int fc_lport_test_ready(struct fc_lport *lport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 	return lport->state == LPORT_ST_READY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789)  * fc_set_wwnn() - Set the World Wide Node Name of a local port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790)  * @lport: The local port whose WWNN is to be set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791)  * @wwnn:  The new WWNN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) static inline void fc_set_wwnn(struct fc_lport *lport, u64 wwnn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) 	lport->wwnn = wwnn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799)  * fc_set_wwpn() - Set the World Wide Port Name of a local port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800)  * @lport: The local port whose WWPN is to be set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801)  * @wwpn:  The new WWPN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) static inline void fc_set_wwpn(struct fc_lport *lport, u64 wwpn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 	lport->wwpn = wwpn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809)  * fc_lport_state_enter() - Change a local port's state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810)  * @lport: The local port whose state is to change
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811)  * @state: The new state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) static inline void fc_lport_state_enter(struct fc_lport *lport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 					enum fc_lport_state state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 	if (state != lport->state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) 		lport->retry_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 	lport->state = state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822)  * fc_lport_init_stats() - Allocate per-CPU statistics for a local port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823)  * @lport: The local port whose statistics are to be initialized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) static inline int fc_lport_init_stats(struct fc_lport *lport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 	lport->stats = alloc_percpu(struct fc_stats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 	if (!lport->stats)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834)  * fc_lport_free_stats() - Free memory for a local port's statistics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835)  * @lport: The local port whose statistics are to be freed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) static inline void fc_lport_free_stats(struct fc_lport *lport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 	free_percpu(lport->stats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843)  * lport_priv() - Return the private data from a local port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844)  * @lport: The local port whose private data is to be retreived
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) static inline void *lport_priv(const struct fc_lport *lport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 	return (void *)(lport + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852)  * libfc_host_alloc() - Allocate a Scsi_Host with room for a local port and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853)  *                      LLD private data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854)  * @sht:       The SCSI host template
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855)  * @priv_size: Size of private data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857)  * Returns: libfc lport
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) static inline struct fc_lport *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) libfc_host_alloc(struct scsi_host_template *sht, int priv_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 	struct fc_lport *lport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 	struct Scsi_Host *shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 	shost = scsi_host_alloc(sht, sizeof(*lport) + priv_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) 	if (!shost)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 	lport = shost_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 	lport->host = shost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) 	INIT_LIST_HEAD(&lport->ema_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 	INIT_LIST_HEAD(&lport->vports);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 	return lport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876)  * FC_FCP HELPER FUNCTIONS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877)  *****************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) static inline bool fc_fcp_is_read(const struct fc_fcp_pkt *fsp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) 	if (fsp && fsp->cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) 		return fsp->cmd->sc_data_direction == DMA_FROM_DEVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) 	return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886)  * LOCAL PORT LAYER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887)  *****************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) int fc_lport_init(struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) int fc_lport_destroy(struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) int fc_fabric_logoff(struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) int fc_fabric_login(struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) void __fc_linkup(struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) void fc_linkup(struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) void __fc_linkdown(struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) void fc_linkdown(struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) void fc_vport_setlink(struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) void fc_vports_linkchange(struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) int fc_lport_config(struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) int fc_lport_reset(struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) void fc_lport_recv(struct fc_lport *lport, struct fc_frame *fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) int fc_set_mfs(struct fc_lport *, u32 mfs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) struct fc_lport *libfc_vport_create(struct fc_vport *, int privsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) struct fc_lport *fc_vport_id_lookup(struct fc_lport *, u32 port_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) int fc_lport_bsg_request(struct bsg_job *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) void fc_lport_set_local_id(struct fc_lport *, u32 port_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) void fc_lport_iterate(void (*func)(struct fc_lport *, void *), void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909)  * REMOTE PORT LAYER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910)  *****************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) void fc_rport_terminate_io(struct fc_rport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) struct fc_rport_priv *fc_rport_lookup(const struct fc_lport *lport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) 				      u32 port_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) struct fc_rport_priv *fc_rport_create(struct fc_lport *, u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) void fc_rport_destroy(struct kref *kref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) int fc_rport_login(struct fc_rport_priv *rdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) int fc_rport_logoff(struct fc_rport_priv *rdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) void fc_rport_recv_req(struct fc_lport *lport, struct fc_frame *fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) void fc_rport_flush_queue(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922)  * DISCOVERY LAYER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923)  *****************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) void fc_disc_init(struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) void fc_disc_config(struct fc_lport *, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) static inline struct fc_lport *fc_disc_lport(struct fc_disc *disc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 	return container_of(disc, struct fc_lport, disc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933)  * FCP LAYER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934)  *****************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) int fc_fcp_init(struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) void fc_fcp_destroy(struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939)  * SCSI INTERACTION LAYER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940)  *****************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) int fc_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) int fc_eh_abort(struct scsi_cmnd *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) int fc_eh_device_reset(struct scsi_cmnd *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) int fc_eh_host_reset(struct scsi_cmnd *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) int fc_slave_alloc(struct scsi_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948)  * ELS/CT interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949)  *****************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) int fc_elsct_init(struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) struct fc_seq *fc_elsct_send(struct fc_lport *, u32 did,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 				    struct fc_frame *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 				    unsigned int op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 				    void (*resp)(struct fc_seq *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 						 struct fc_frame *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 						 void *arg),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 				    void *arg, u32 timer_msec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) void fc_lport_flogi_resp(struct fc_seq *, struct fc_frame *, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) void fc_lport_logo_resp(struct fc_seq *, struct fc_frame *, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) void fc_fill_reply_hdr(struct fc_frame *, const struct fc_frame *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) 		       enum fc_rctl, u32 parm_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) void fc_fill_hdr(struct fc_frame *, const struct fc_frame *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) 		 enum fc_rctl, u32 f_ctl, u16 seq_cnt, u32 parm_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967)  * EXCHANGE MANAGER LAYER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968)  *****************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) int fc_exch_init(struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) void fc_exch_update_stats(struct fc_lport *lport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) struct fc_seq *fc_exch_seq_send(struct fc_lport *lport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) 				struct fc_frame *fp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 				void (*resp)(struct fc_seq *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) 					     struct fc_frame *fp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) 					     void *arg),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 				void (*destructor)(struct fc_seq *, void *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) 				void *arg, u32 timer_msec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) void fc_seq_els_rsp_send(struct fc_frame *, enum fc_els_cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) 			 struct fc_seq_els_data *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) struct fc_seq *fc_seq_start_next(struct fc_seq *sp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) void fc_seq_set_resp(struct fc_seq *sp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 		     void (*resp)(struct fc_seq *, struct fc_frame *, void *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 		     void *arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) struct fc_seq *fc_seq_assign(struct fc_lport *lport, struct fc_frame *fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) void fc_seq_release(struct fc_seq *sp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) struct fc_exch_mgr_anchor *fc_exch_mgr_add(struct fc_lport *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 					   struct fc_exch_mgr *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 					   bool (*match)(struct fc_frame *));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) void fc_exch_mgr_del(struct fc_exch_mgr_anchor *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) int fc_exch_mgr_list_clone(struct fc_lport *src, struct fc_lport *dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) struct fc_exch_mgr *fc_exch_mgr_alloc(struct fc_lport *, enum fc_class class,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) 				      u16 min_xid, u16 max_xid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) 				      bool (*match)(struct fc_frame *));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) void fc_exch_mgr_free(struct fc_lport *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) void fc_exch_recv(struct fc_lport *, struct fc_frame *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) void fc_exch_mgr_reset(struct fc_lport *, u32 s_id, u32 d_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) int fc_seq_send(struct fc_lport *lport, struct fc_seq *sp, struct fc_frame *fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) int fc_seq_exch_abort(const struct fc_seq *, unsigned int timer_msec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) void fc_exch_done(struct fc_seq *sp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002)  * Functions for fc_functions_template
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) void fc_get_host_speed(struct Scsi_Host *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) void fc_get_host_port_state(struct Scsi_Host *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) void fc_set_rport_loss_tmo(struct fc_rport *, u32 timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) #endif /* _LIBFC_H_ */