xref: /linux/drivers/scsi/elx/efct/efct_xport.h (revision 762f99f4f3cb41a775b5157dd761217beba65873)
1*4df84e84SJames Smart /* SPDX-License-Identifier: GPL-2.0 */
2*4df84e84SJames Smart /*
3*4df84e84SJames Smart  * Copyright (C) 2021 Broadcom. All Rights Reserved. The term
4*4df84e84SJames Smart  * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
5*4df84e84SJames Smart  */
6*4df84e84SJames Smart 
7*4df84e84SJames Smart #if !defined(__EFCT_XPORT_H__)
8*4df84e84SJames Smart #define __EFCT_XPORT_H__
9*4df84e84SJames Smart 
10*4df84e84SJames Smart enum efct_xport_ctrl {
11*4df84e84SJames Smart 	EFCT_XPORT_PORT_ONLINE = 1,
12*4df84e84SJames Smart 	EFCT_XPORT_PORT_OFFLINE,
13*4df84e84SJames Smart 	EFCT_XPORT_SHUTDOWN,
14*4df84e84SJames Smart 	EFCT_XPORT_POST_NODE_EVENT,
15*4df84e84SJames Smart 	EFCT_XPORT_WWNN_SET,
16*4df84e84SJames Smart 	EFCT_XPORT_WWPN_SET,
17*4df84e84SJames Smart };
18*4df84e84SJames Smart 
19*4df84e84SJames Smart enum efct_xport_status {
20*4df84e84SJames Smart 	EFCT_XPORT_PORT_STATUS,
21*4df84e84SJames Smart 	EFCT_XPORT_CONFIG_PORT_STATUS,
22*4df84e84SJames Smart 	EFCT_XPORT_LINK_SPEED,
23*4df84e84SJames Smart 	EFCT_XPORT_IS_SUPPORTED_LINK_SPEED,
24*4df84e84SJames Smart 	EFCT_XPORT_LINK_STATISTICS,
25*4df84e84SJames Smart 	EFCT_XPORT_LINK_STAT_RESET,
26*4df84e84SJames Smart 	EFCT_XPORT_IS_QUIESCED
27*4df84e84SJames Smart };
28*4df84e84SJames Smart 
29*4df84e84SJames Smart struct efct_xport_link_stats {
30*4df84e84SJames Smart 	bool		rec;
31*4df84e84SJames Smart 	bool		gec;
32*4df84e84SJames Smart 	bool		w02of;
33*4df84e84SJames Smart 	bool		w03of;
34*4df84e84SJames Smart 	bool		w04of;
35*4df84e84SJames Smart 	bool		w05of;
36*4df84e84SJames Smart 	bool		w06of;
37*4df84e84SJames Smart 	bool		w07of;
38*4df84e84SJames Smart 	bool		w08of;
39*4df84e84SJames Smart 	bool		w09of;
40*4df84e84SJames Smart 	bool		w10of;
41*4df84e84SJames Smart 	bool		w11of;
42*4df84e84SJames Smart 	bool		w12of;
43*4df84e84SJames Smart 	bool		w13of;
44*4df84e84SJames Smart 	bool		w14of;
45*4df84e84SJames Smart 	bool		w15of;
46*4df84e84SJames Smart 	bool		w16of;
47*4df84e84SJames Smart 	bool		w17of;
48*4df84e84SJames Smart 	bool		w18of;
49*4df84e84SJames Smart 	bool		w19of;
50*4df84e84SJames Smart 	bool		w20of;
51*4df84e84SJames Smart 	bool		w21of;
52*4df84e84SJames Smart 	bool		clrc;
53*4df84e84SJames Smart 	bool		clof1;
54*4df84e84SJames Smart 	u32		link_failure_error_count;
55*4df84e84SJames Smart 	u32		loss_of_sync_error_count;
56*4df84e84SJames Smart 	u32		loss_of_signal_error_count;
57*4df84e84SJames Smart 	u32		primitive_sequence_error_count;
58*4df84e84SJames Smart 	u32		invalid_transmission_word_error_count;
59*4df84e84SJames Smart 	u32		crc_error_count;
60*4df84e84SJames Smart 	u32		primitive_sequence_event_timeout_count;
61*4df84e84SJames Smart 	u32		elastic_buffer_overrun_error_count;
62*4df84e84SJames Smart 	u32		arbitration_fc_al_timeout_count;
63*4df84e84SJames Smart 	u32		advertised_receive_bufftor_to_buffer_credit;
64*4df84e84SJames Smart 	u32		current_receive_buffer_to_buffer_credit;
65*4df84e84SJames Smart 	u32		advertised_transmit_buffer_to_buffer_credit;
66*4df84e84SJames Smart 	u32		current_transmit_buffer_to_buffer_credit;
67*4df84e84SJames Smart 	u32		received_eofa_count;
68*4df84e84SJames Smart 	u32		received_eofdti_count;
69*4df84e84SJames Smart 	u32		received_eofni_count;
70*4df84e84SJames Smart 	u32		received_soff_count;
71*4df84e84SJames Smart 	u32		received_dropped_no_aer_count;
72*4df84e84SJames Smart 	u32		received_dropped_no_available_rpi_resources_count;
73*4df84e84SJames Smart 	u32		received_dropped_no_available_xri_resources_count;
74*4df84e84SJames Smart };
75*4df84e84SJames Smart 
76*4df84e84SJames Smart struct efct_xport_host_stats {
77*4df84e84SJames Smart 	bool		cc;
78*4df84e84SJames Smart 	u32		transmit_kbyte_count;
79*4df84e84SJames Smart 	u32		receive_kbyte_count;
80*4df84e84SJames Smart 	u32		transmit_frame_count;
81*4df84e84SJames Smart 	u32		receive_frame_count;
82*4df84e84SJames Smart 	u32		transmit_sequence_count;
83*4df84e84SJames Smart 	u32		receive_sequence_count;
84*4df84e84SJames Smart 	u32		total_exchanges_originator;
85*4df84e84SJames Smart 	u32		total_exchanges_responder;
86*4df84e84SJames Smart 	u32		receive_p_bsy_count;
87*4df84e84SJames Smart 	u32		receive_f_bsy_count;
88*4df84e84SJames Smart 	u32		dropped_frames_due_to_no_rq_buffer_count;
89*4df84e84SJames Smart 	u32		empty_rq_timeout_count;
90*4df84e84SJames Smart 	u32		dropped_frames_due_to_no_xri_count;
91*4df84e84SJames Smart 	u32		empty_xri_pool_count;
92*4df84e84SJames Smart };
93*4df84e84SJames Smart 
94*4df84e84SJames Smart struct efct_xport_host_statistics {
95*4df84e84SJames Smart 	struct completion		done;
96*4df84e84SJames Smart 	struct efct_xport_link_stats	link_stats;
97*4df84e84SJames Smart 	struct efct_xport_host_stats	host_stats;
98*4df84e84SJames Smart };
99*4df84e84SJames Smart 
100*4df84e84SJames Smart union efct_xport_stats_u {
101*4df84e84SJames Smart 	u32	value;
102*4df84e84SJames Smart 	struct efct_xport_host_statistics stats;
103*4df84e84SJames Smart };
104*4df84e84SJames Smart 
105*4df84e84SJames Smart struct efct_xport_fcp_stats {
106*4df84e84SJames Smart 	u64		input_bytes;
107*4df84e84SJames Smart 	u64		output_bytes;
108*4df84e84SJames Smart 	u64		input_requests;
109*4df84e84SJames Smart 	u64		output_requests;
110*4df84e84SJames Smart 	u64		control_requests;
111*4df84e84SJames Smart };
112*4df84e84SJames Smart 
113*4df84e84SJames Smart struct efct_xport {
114*4df84e84SJames Smart 	struct efct		*efct;
115*4df84e84SJames Smart 	/* wwpn requested by user for primary nport */
116*4df84e84SJames Smart 	u64			req_wwpn;
117*4df84e84SJames Smart 	/* wwnn requested by user for primary nport */
118*4df84e84SJames Smart 	u64			req_wwnn;
119*4df84e84SJames Smart 
120*4df84e84SJames Smart 	/* Nodes */
121*4df84e84SJames Smart 	/* number of allocated nodes */
122*4df84e84SJames Smart 	u32			nodes_count;
123*4df84e84SJames Smart 	/* used to track how often IO pool is empty */
124*4df84e84SJames Smart 	atomic_t		io_alloc_failed_count;
125*4df84e84SJames Smart 	/* array of pointers to nodes */
126*4df84e84SJames Smart 	struct efc_node		**nodes;
127*4df84e84SJames Smart 
128*4df84e84SJames Smart 	/* Io pool and counts */
129*4df84e84SJames Smart 	/* pointer to IO pool */
130*4df84e84SJames Smart 	struct efct_io_pool	*io_pool;
131*4df84e84SJames Smart 	/* lock for io_pending_list */
132*4df84e84SJames Smart 	spinlock_t		io_pending_lock;
133*4df84e84SJames Smart 	/* list of IOs waiting for HW resources
134*4df84e84SJames Smart 	 *  lock: xport->io_pending_lock
135*4df84e84SJames Smart 	 *  link: efct_io_s->io_pending_link
136*4df84e84SJames Smart 	 */
137*4df84e84SJames Smart 	struct list_head	io_pending_list;
138*4df84e84SJames Smart 	/* count of totals IOS allocated */
139*4df84e84SJames Smart 	atomic_t		io_total_alloc;
140*4df84e84SJames Smart 	/* count of totals IOS free'd */
141*4df84e84SJames Smart 	atomic_t		io_total_free;
142*4df84e84SJames Smart 	/* count of totals IOS that were pended */
143*4df84e84SJames Smart 	atomic_t		io_total_pending;
144*4df84e84SJames Smart 	/* count of active IOS */
145*4df84e84SJames Smart 	atomic_t		io_active_count;
146*4df84e84SJames Smart 	/* count of pending IOS */
147*4df84e84SJames Smart 	atomic_t		io_pending_count;
148*4df84e84SJames Smart 	/* non-zero if efct_scsi_check_pending is executing */
149*4df84e84SJames Smart 	atomic_t		io_pending_recursing;
150*4df84e84SJames Smart 
151*4df84e84SJames Smart 	/* Port */
152*4df84e84SJames Smart 	/* requested link state */
153*4df84e84SJames Smart 	u32			configured_link_state;
154*4df84e84SJames Smart 
155*4df84e84SJames Smart 	/* Timer for Statistics */
156*4df84e84SJames Smart 	struct timer_list	stats_timer;
157*4df84e84SJames Smart 	union efct_xport_stats_u fc_xport_stats;
158*4df84e84SJames Smart 	struct efct_xport_fcp_stats fcp_stats;
159*4df84e84SJames Smart };
160*4df84e84SJames Smart 
161*4df84e84SJames Smart struct efct_rport_data {
162*4df84e84SJames Smart 	struct efc_node		*node;
163*4df84e84SJames Smart };
164*4df84e84SJames Smart 
165*4df84e84SJames Smart struct efct_xport *
166*4df84e84SJames Smart efct_xport_alloc(struct efct *efct);
167*4df84e84SJames Smart int
168*4df84e84SJames Smart efct_xport_attach(struct efct_xport *xport);
169*4df84e84SJames Smart int
170*4df84e84SJames Smart efct_xport_initialize(struct efct_xport *xport);
171*4df84e84SJames Smart void
172*4df84e84SJames Smart efct_xport_detach(struct efct_xport *xport);
173*4df84e84SJames Smart int
174*4df84e84SJames Smart efct_xport_control(struct efct_xport *xport, enum efct_xport_ctrl cmd, ...);
175*4df84e84SJames Smart int
176*4df84e84SJames Smart efct_xport_status(struct efct_xport *xport, enum efct_xport_status cmd,
177*4df84e84SJames Smart 		  union efct_xport_stats_u *result);
178*4df84e84SJames Smart void
179*4df84e84SJames Smart efct_xport_free(struct efct_xport *xport);
180*4df84e84SJames Smart 
181*4df84e84SJames Smart struct scsi_transport_template *efct_attach_fc_transport(void);
182*4df84e84SJames Smart struct scsi_transport_template *efct_attach_vport_fc_transport(void);
183*4df84e84SJames Smart void
184*4df84e84SJames Smart efct_release_fc_transport(struct scsi_transport_template *transport_template);
185*4df84e84SJames Smart 
186*4df84e84SJames Smart #endif /* __EFCT_XPORT_H__ */
187