xref: /openbmc/linux/drivers/s390/scsi/zfcp_fsf.h (revision a17c7846)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21da177e4SLinus Torvalds /*
3553448f6SChristof Schmitt  * zfcp device driver
41da177e4SLinus Torvalds  *
5553448f6SChristof Schmitt  * Interface to the FSF support functions.
61da177e4SLinus Torvalds  *
7a17c7846SJens Remus  * Copyright IBM Corp. 2002, 2020
81da177e4SLinus Torvalds  */
91da177e4SLinus Torvalds 
101da177e4SLinus Torvalds #ifndef FSF_H
111da177e4SLinus Torvalds #define FSF_H
121da177e4SLinus Torvalds 
1345633fdcSChristof Schmitt #include <linux/pfn.h>
14d46f384aSChristof Schmitt #include <linux/scatterlist.h>
15800c0cadSChristof Schmitt #include <scsi/libfc.h>
1645633fdcSChristof Schmitt 
1706506d00SAndreas Herrmann #define FSF_QTCB_CURRENT_VERSION		0x00000001
181da177e4SLinus Torvalds 
191da177e4SLinus Torvalds /* FSF commands */
201da177e4SLinus Torvalds #define	FSF_QTCB_FCP_CMND			0x00000001
211da177e4SLinus Torvalds #define	FSF_QTCB_ABORT_FCP_CMND			0x00000002
221da177e4SLinus Torvalds #define	FSF_QTCB_OPEN_PORT_WITH_DID		0x00000005
231da177e4SLinus Torvalds #define	FSF_QTCB_OPEN_LUN			0x00000006
241da177e4SLinus Torvalds #define	FSF_QTCB_CLOSE_LUN			0x00000007
251da177e4SLinus Torvalds #define	FSF_QTCB_CLOSE_PORT			0x00000008
261da177e4SLinus Torvalds #define	FSF_QTCB_CLOSE_PHYSICAL_PORT		0x00000009
271da177e4SLinus Torvalds #define	FSF_QTCB_SEND_ELS			0x0000000B
281da177e4SLinus Torvalds #define	FSF_QTCB_SEND_GENERIC			0x0000000C
291da177e4SLinus Torvalds #define	FSF_QTCB_EXCHANGE_CONFIG_DATA		0x0000000D
301da177e4SLinus Torvalds #define	FSF_QTCB_EXCHANGE_PORT_DATA		0x0000000E
311da177e4SLinus Torvalds #define FSF_QTCB_DOWNLOAD_CONTROL_FILE		0x00000012
321da177e4SLinus Torvalds #define FSF_QTCB_UPLOAD_CONTROL_FILE		0x00000013
331da177e4SLinus Torvalds 
341da177e4SLinus Torvalds /* FSF QTCB types */
351da177e4SLinus Torvalds #define FSF_IO_COMMAND				0x00000001
361da177e4SLinus Torvalds #define FSF_SUPPORT_COMMAND			0x00000002
371da177e4SLinus Torvalds #define FSF_CONFIG_COMMAND			0x00000003
381da177e4SLinus Torvalds #define FSF_PORT_COMMAND			0x00000004
391da177e4SLinus Torvalds 
4006506d00SAndreas Herrmann /* FSF protocol states */
411da177e4SLinus Torvalds #define FSF_PROT_GOOD				0x00000001
421da177e4SLinus Torvalds #define FSF_PROT_QTCB_VERSION_ERROR		0x00000010
431da177e4SLinus Torvalds #define FSF_PROT_SEQ_NUMB_ERROR			0x00000020
441da177e4SLinus Torvalds #define FSF_PROT_UNSUPP_QTCB_TYPE		0x00000040
451da177e4SLinus Torvalds #define FSF_PROT_HOST_CONNECTION_INITIALIZING	0x00000080
461da177e4SLinus Torvalds #define FSF_PROT_FSF_STATUS_PRESENTED		0x00000100
471da177e4SLinus Torvalds #define FSF_PROT_DUPLICATE_REQUEST_ID		0x00000200
481da177e4SLinus Torvalds #define FSF_PROT_LINK_DOWN                      0x00000400
491da177e4SLinus Torvalds #define FSF_PROT_REEST_QUEUE                    0x00000800
501da177e4SLinus Torvalds #define FSF_PROT_ERROR_STATE			0x01000000
511da177e4SLinus Torvalds 
5206506d00SAndreas Herrmann /* FSF states */
531da177e4SLinus Torvalds #define FSF_GOOD				0x00000000
541da177e4SLinus Torvalds #define FSF_PORT_ALREADY_OPEN			0x00000001
551da177e4SLinus Torvalds #define FSF_LUN_ALREADY_OPEN			0x00000002
561da177e4SLinus Torvalds #define FSF_PORT_HANDLE_NOT_VALID		0x00000003
571da177e4SLinus Torvalds #define FSF_LUN_HANDLE_NOT_VALID		0x00000004
581da177e4SLinus Torvalds #define FSF_HANDLE_MISMATCH			0x00000005
591da177e4SLinus Torvalds #define FSF_SERVICE_CLASS_NOT_SUPPORTED		0x00000006
601da177e4SLinus Torvalds #define FSF_FCPLUN_NOT_VALID			0x00000009
611da177e4SLinus Torvalds #define FSF_LUN_SHARING_VIOLATION               0x00000012
621da177e4SLinus Torvalds #define FSF_FCP_COMMAND_DOES_NOT_EXIST		0x00000022
631da177e4SLinus Torvalds #define FSF_DIRECTION_INDICATOR_NOT_VALID	0x00000030
641da177e4SLinus Torvalds #define FSF_CMND_LENGTH_NOT_VALID		0x00000033
651da177e4SLinus Torvalds #define FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED	0x00000040
661da177e4SLinus Torvalds #define FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED	0x00000041
671da177e4SLinus Torvalds #define FSF_ELS_COMMAND_REJECTED		0x00000050
681da177e4SLinus Torvalds #define FSF_GENERIC_COMMAND_REJECTED		0x00000051
691da177e4SLinus Torvalds #define FSF_PORT_BOXED				0x00000059
701da177e4SLinus Torvalds #define FSF_LUN_BOXED				0x0000005A
711da177e4SLinus Torvalds #define FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE	0x0000005B
721da177e4SLinus Torvalds #define FSF_PAYLOAD_SIZE_MISMATCH		0x00000060
731da177e4SLinus Torvalds #define FSF_REQUEST_SIZE_TOO_LARGE		0x00000061
741da177e4SLinus Torvalds #define FSF_RESPONSE_SIZE_TOO_LARGE		0x00000062
751da177e4SLinus Torvalds #define FSF_SBAL_MISMATCH			0x00000063
76ef3eb71dSFelix Beck #define FSF_INCONSISTENT_PROT_DATA		0x00000070
77ef3eb71dSFelix Beck #define FSF_INVALID_PROT_PARM			0x00000071
78ef3eb71dSFelix Beck #define FSF_BLOCK_GUARD_CHECK_FAILURE		0x00000081
79ef3eb71dSFelix Beck #define FSF_APP_TAG_CHECK_FAILURE		0x00000082
80ef3eb71dSFelix Beck #define FSF_REF_TAG_CHECK_FAILURE		0x00000083
811da177e4SLinus Torvalds #define FSF_ADAPTER_STATUS_AVAILABLE		0x000000AD
8256d23ed7SSteffen Maier #define FSF_FCP_RSP_AVAILABLE			0x000000AF
831da177e4SLinus Torvalds #define FSF_UNKNOWN_COMMAND			0x000000E2
841da177e4SLinus Torvalds #define FSF_UNKNOWN_OP_SUBTYPE                  0x000000E3
851da177e4SLinus Torvalds #define FSF_INVALID_COMMAND_OPTION              0x000000E5
861da177e4SLinus Torvalds 
878a36e453SMaxim Shchetynin #define FSF_PROT_STATUS_QUAL_SIZE		16
881da177e4SLinus Torvalds #define FSF_STATUS_QUALIFIER_SIZE		16
891da177e4SLinus Torvalds 
901da177e4SLinus Torvalds /* FSF status qualifier, recommendations */
911da177e4SLinus Torvalds #define FSF_SQ_NO_RECOM				0x00
921da177e4SLinus Torvalds #define FSF_SQ_FCP_RSP_AVAILABLE		0x01
931da177e4SLinus Torvalds #define FSF_SQ_RETRY_IF_POSSIBLE		0x02
941da177e4SLinus Torvalds #define FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED	0x03
951da177e4SLinus Torvalds #define FSF_SQ_INVOKE_LINK_TEST_PROCEDURE	0x04
961da177e4SLinus Torvalds #define FSF_SQ_COMMAND_ABORTED			0x06
971da177e4SLinus Torvalds #define FSF_SQ_NO_RETRY_POSSIBLE		0x07
981da177e4SLinus Torvalds 
991da177e4SLinus Torvalds /* FSF status qualifier (most significant 4 bytes), local link down */
100aef4a983SMaxim Shchetynin #define FSF_PSQ_LINK_NO_LIGHT			0x00000004
101aef4a983SMaxim Shchetynin #define FSF_PSQ_LINK_WRAP_PLUG			0x00000008
102aef4a983SMaxim Shchetynin #define FSF_PSQ_LINK_NO_FCP			0x00000010
103aef4a983SMaxim Shchetynin #define FSF_PSQ_LINK_FIRMWARE_UPDATE		0x00000020
104aef4a983SMaxim Shchetynin #define FSF_PSQ_LINK_INVALID_WWPN		0x00000100
105aef4a983SMaxim Shchetynin #define FSF_PSQ_LINK_NO_NPIV_SUPPORT		0x00000200
106aef4a983SMaxim Shchetynin #define FSF_PSQ_LINK_NO_FCP_RESOURCES		0x00000400
107aef4a983SMaxim Shchetynin #define FSF_PSQ_LINK_NO_FABRIC_RESOURCES	0x00000800
108aef4a983SMaxim Shchetynin #define FSF_PSQ_LINK_FABRIC_LOGIN_UNABLE	0x00001000
109aef4a983SMaxim Shchetynin #define FSF_PSQ_LINK_WWPN_ASSIGNMENT_CORRUPTED	0x00002000
110aef4a983SMaxim Shchetynin #define FSF_PSQ_LINK_MODE_TABLE_CURRUPTED	0x00004000
111aef4a983SMaxim Shchetynin #define FSF_PSQ_LINK_NO_WWPN_ASSIGNMENT		0x00008000
1121da177e4SLinus Torvalds 
1131da177e4SLinus Torvalds /* payload size in status read buffer */
1141da177e4SLinus Torvalds #define FSF_STATUS_READ_PAYLOAD_SIZE		4032
1151da177e4SLinus Torvalds 
1161da177e4SLinus Torvalds /* number of status read buffers that should be sent by ULP */
1171da177e4SLinus Torvalds #define FSF_STATUS_READS_RECOM			16
1181da177e4SLinus Torvalds 
1191da177e4SLinus Torvalds /* status types in status read buffer */
1201da177e4SLinus Torvalds #define FSF_STATUS_READ_PORT_CLOSED		0x00000001
1211da177e4SLinus Torvalds #define FSF_STATUS_READ_INCOMING_ELS		0x00000002
1221da177e4SLinus Torvalds #define FSF_STATUS_READ_SENSE_DATA_AVAIL        0x00000003
1231da177e4SLinus Torvalds #define FSF_STATUS_READ_BIT_ERROR_THRESHOLD	0x00000004
124aef4a983SMaxim Shchetynin #define FSF_STATUS_READ_LINK_DOWN		0x00000005
1251da177e4SLinus Torvalds #define FSF_STATUS_READ_LINK_UP          	0x00000006
1269eb69affSMaxim Shchetynin #define FSF_STATUS_READ_NOTIFICATION_LOST	0x00000009
127aef4a983SMaxim Shchetynin #define FSF_STATUS_READ_FEATURE_UPDATE_ALERT	0x0000000C
1281da177e4SLinus Torvalds 
129aef4a983SMaxim Shchetynin /* status subtypes for link down */
130aef4a983SMaxim Shchetynin #define FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK	0x00000000
131aef4a983SMaxim Shchetynin #define FSF_STATUS_READ_SUB_FDISC_FAILED	0x00000001
132aef4a983SMaxim Shchetynin #define FSF_STATUS_READ_SUB_FIRMWARE_UPDATE	0x00000002
133aef4a983SMaxim Shchetynin 
1349eb69affSMaxim Shchetynin /* status subtypes for unsolicited status notification lost */
1359eb69affSMaxim Shchetynin #define FSF_STATUS_READ_SUB_INCOMING_ELS	0x00000001
1361da177e4SLinus Torvalds 
1371da177e4SLinus Torvalds /* topologie that is detected by the adapter */
1381da177e4SLinus Torvalds #define FSF_TOPO_P2P				0x00000001
1391da177e4SLinus Torvalds #define FSF_TOPO_FABRIC				0x00000002
1401da177e4SLinus Torvalds #define FSF_TOPO_AL				0x00000003
1411da177e4SLinus Torvalds 
1421da177e4SLinus Torvalds /* data direction for FCP commands */
1431da177e4SLinus Torvalds #define FSF_DATADIR_WRITE			0x00000001
1441da177e4SLinus Torvalds #define FSF_DATADIR_READ			0x00000002
1451da177e4SLinus Torvalds #define FSF_DATADIR_CMND			0x00000004
146ef3eb71dSFelix Beck #define FSF_DATADIR_DIF_WRITE_INSERT		0x00000009
147ef3eb71dSFelix Beck #define FSF_DATADIR_DIF_READ_STRIP		0x0000000a
148ef3eb71dSFelix Beck #define FSF_DATADIR_DIF_WRITE_CONVERT		0x0000000b
149ef3eb71dSFelix Beck #define FSF_DATADIR_DIF_READ_CONVERT		0X0000000c
150ef3eb71dSFelix Beck 
151ef3eb71dSFelix Beck /* data protection control flags */
152ef3eb71dSFelix Beck #define FSF_APP_TAG_CHECK_ENABLE		0x10
1531da177e4SLinus Torvalds 
1541da177e4SLinus Torvalds /* fc service class */
1551da177e4SLinus Torvalds #define FSF_CLASS_3				0x00000003
1561da177e4SLinus Torvalds 
1571da177e4SLinus Torvalds /* logging space behind QTCB */
1581da177e4SLinus Torvalds #define FSF_QTCB_LOG_SIZE			1024
1591da177e4SLinus Torvalds 
1601da177e4SLinus Torvalds /* channel features */
1619eb69affSMaxim Shchetynin #define FSF_FEATURE_NOTIFICATION_LOST		0x00000008
1621da177e4SLinus Torvalds #define FSF_FEATURE_HBAAPI_MANAGEMENT           0x00000010
16339eb7e9aSChristof Schmitt #define FSF_FEATURE_ELS_CT_CHAINED_SBALS	0x00000020
164aef4a983SMaxim Shchetynin #define FSF_FEATURE_UPDATE_ALERT		0x00000100
1656d9d63b9SSwen Schillig #define FSF_FEATURE_MEASUREMENT_DATA		0x00000200
166a10a61e8SBenjamin Block #define FSF_FEATURE_REQUEST_SFP_DATA		0x00000200
167a10a61e8SBenjamin Block #define FSF_FEATURE_REPORT_SFP_DATA		0x00000800
168a17c7846SJens Remus #define FSF_FEATURE_FC_SECURITY			0x00001000
169ef3eb71dSFelix Beck #define FSF_FEATURE_DIF_PROT_TYPE1		0x00010000
170ef3eb71dSFelix Beck #define FSF_FEATURE_DIX_PROT_TCPIP		0x00020000
171aef4a983SMaxim Shchetynin 
172aef4a983SMaxim Shchetynin /* host connection features */
173aef4a983SMaxim Shchetynin #define FSF_FEATURE_NPIV_MODE			0x00000001
1741da177e4SLinus Torvalds 
1751da177e4SLinus Torvalds /* option */
1761da177e4SLinus Torvalds #define FSF_OPEN_LUN_SUPPRESS_BOXING		0x00000001
1771da177e4SLinus Torvalds 
178a17c7846SJens Remus /* FC security algorithms */
179a17c7846SJens Remus #define FSF_FC_SECURITY_AUTH			0x00000001
180a17c7846SJens Remus #define FSF_FC_SECURITY_ENC_FCSP2		0x00000002
181a17c7846SJens Remus #define FSF_FC_SECURITY_ENC_ERAS		0x00000004
182a17c7846SJens Remus 
1831da177e4SLinus Torvalds struct fsf_queue_designator {
1841da177e4SLinus Torvalds 	u8  cssid;
1851da177e4SLinus Torvalds 	u8  chpid;
1861da177e4SLinus Torvalds 	u8  hla;
1871da177e4SLinus Torvalds 	u8  ua;
1881da177e4SLinus Torvalds 	u32 res1;
1891da177e4SLinus Torvalds } __attribute__ ((packed));
1901da177e4SLinus Torvalds 
1911da177e4SLinus Torvalds struct fsf_bit_error_payload {
1921da177e4SLinus Torvalds 	u32 res1;
1931da177e4SLinus Torvalds 	u32 link_failure_error_count;
1941da177e4SLinus Torvalds 	u32 loss_of_sync_error_count;
1951da177e4SLinus Torvalds 	u32 loss_of_signal_error_count;
1961da177e4SLinus Torvalds 	u32 primitive_sequence_error_count;
1971da177e4SLinus Torvalds 	u32 invalid_transmission_word_error_count;
1981da177e4SLinus Torvalds 	u32 crc_error_count;
1991da177e4SLinus Torvalds 	u32 primitive_sequence_event_timeout_count;
2001da177e4SLinus Torvalds 	u32 elastic_buffer_overrun_error_count;
2011da177e4SLinus Torvalds 	u32 fcal_arbitration_timeout_count;
2021da177e4SLinus Torvalds 	u32 advertised_receive_b2b_credit;
2031da177e4SLinus Torvalds 	u32 current_receive_b2b_credit;
2041da177e4SLinus Torvalds 	u32 advertised_transmit_b2b_credit;
2051da177e4SLinus Torvalds 	u32 current_transmit_b2b_credit;
2061da177e4SLinus Torvalds } __attribute__ ((packed));
2071da177e4SLinus Torvalds 
208aef4a983SMaxim Shchetynin struct fsf_link_down_info {
209aef4a983SMaxim Shchetynin 	u32 error_code;
210aef4a983SMaxim Shchetynin 	u32 res1;
211aef4a983SMaxim Shchetynin 	u8 res2[2];
212aef4a983SMaxim Shchetynin 	u8 primary_status;
213aef4a983SMaxim Shchetynin 	u8 ioerr_code;
214aef4a983SMaxim Shchetynin 	u8 action_code;
215aef4a983SMaxim Shchetynin 	u8 reason_code;
216aef4a983SMaxim Shchetynin 	u8 explanation_code;
217aef4a983SMaxim Shchetynin 	u8 vendor_specific_code;
2181da177e4SLinus Torvalds } __attribute__ ((packed));
2191da177e4SLinus Torvalds 
220c41f8cbdSSwen Schillig struct fsf_status_read_buffer {
221c41f8cbdSSwen Schillig 	u32 status_type;
222c41f8cbdSSwen Schillig 	u32 status_subtype;
223c41f8cbdSSwen Schillig 	u32 length;
224c41f8cbdSSwen Schillig 	u32 res1;
225c41f8cbdSSwen Schillig 	struct fsf_queue_designator queue_designator;
226800c0cadSChristof Schmitt 	u8 res2;
227800c0cadSChristof Schmitt 	u8 d_id[3];
228c41f8cbdSSwen Schillig 	u32 class;
229c41f8cbdSSwen Schillig 	u64 fcp_lun;
230c41f8cbdSSwen Schillig 	u8  res3[24];
231c41f8cbdSSwen Schillig 	union {
232c41f8cbdSSwen Schillig 		u8  data[FSF_STATUS_READ_PAYLOAD_SIZE];
233c41f8cbdSSwen Schillig 		u32 word[FSF_STATUS_READ_PAYLOAD_SIZE/sizeof(u32)];
234c41f8cbdSSwen Schillig 		struct fsf_link_down_info link_down_info;
235c41f8cbdSSwen Schillig 		struct fsf_bit_error_payload bit_error;
236c41f8cbdSSwen Schillig 	} payload;
237c41f8cbdSSwen Schillig } __attribute__ ((packed));
238c41f8cbdSSwen Schillig 
239c41f8cbdSSwen Schillig struct fsf_qual_version_error {
240c41f8cbdSSwen Schillig 	u32 fsf_version;
241c41f8cbdSSwen Schillig 	u32 res1[3];
242c41f8cbdSSwen Schillig } __attribute__ ((packed));
243c41f8cbdSSwen Schillig 
244c41f8cbdSSwen Schillig struct fsf_qual_sequence_error {
245c41f8cbdSSwen Schillig 	u32 exp_req_seq_no;
246c41f8cbdSSwen Schillig 	u32 res1[3];
247c41f8cbdSSwen Schillig } __attribute__ ((packed));
248c41f8cbdSSwen Schillig 
249c9615858SChristof Schmitt struct fsf_qual_latency_info {
250c9615858SChristof Schmitt 	u32 channel_lat;
251c9615858SChristof Schmitt 	u32 fabric_lat;
252c9615858SChristof Schmitt 	u8 res1[8];
253c9615858SChristof Schmitt } __attribute__ ((packed));
254c9615858SChristof Schmitt 
2551da177e4SLinus Torvalds union fsf_prot_status_qual {
256553448f6SChristof Schmitt 	u32 word[FSF_PROT_STATUS_QUAL_SIZE / sizeof(u32)];
2578a36e453SMaxim Shchetynin 	u64 doubleword[FSF_PROT_STATUS_QUAL_SIZE / sizeof(u64)];
2581da177e4SLinus Torvalds 	struct fsf_qual_version_error   version_error;
2591da177e4SLinus Torvalds 	struct fsf_qual_sequence_error  sequence_error;
260aef4a983SMaxim Shchetynin 	struct fsf_link_down_info link_down_info;
261c9615858SChristof Schmitt 	struct fsf_qual_latency_info latency_info;
2621da177e4SLinus Torvalds } __attribute__ ((packed));
2631da177e4SLinus Torvalds 
2641da177e4SLinus Torvalds struct fsf_qtcb_prefix {
2651da177e4SLinus Torvalds 	u64 req_id;
2661da177e4SLinus Torvalds 	u32 qtcb_version;
2671da177e4SLinus Torvalds 	u32 ulp_info;
2681da177e4SLinus Torvalds 	u32 qtcb_type;
2691da177e4SLinus Torvalds 	u32 req_seq_no;
2701da177e4SLinus Torvalds 	u32 prot_status;
2711da177e4SLinus Torvalds 	union fsf_prot_status_qual prot_status_qual;
2721da177e4SLinus Torvalds 	u8  res1[20];
2731da177e4SLinus Torvalds } __attribute__ ((packed));
2741da177e4SLinus Torvalds 
2756d9d63b9SSwen Schillig struct fsf_statistics_info {
2766d9d63b9SSwen Schillig 	u64 input_req;
2776d9d63b9SSwen Schillig 	u64 output_req;
2786d9d63b9SSwen Schillig 	u64 control_req;
2796d9d63b9SSwen Schillig 	u64 input_mb;
2806d9d63b9SSwen Schillig 	u64 output_mb;
2816d9d63b9SSwen Schillig 	u64 seconds_act;
2826d9d63b9SSwen Schillig } __attribute__ ((packed));
2836d9d63b9SSwen Schillig 
2841da177e4SLinus Torvalds union fsf_status_qual {
2851da177e4SLinus Torvalds 	u8  byte[FSF_STATUS_QUALIFIER_SIZE];
2861da177e4SLinus Torvalds 	u16 halfword[FSF_STATUS_QUALIFIER_SIZE / sizeof (u16)];
2871da177e4SLinus Torvalds 	u32 word[FSF_STATUS_QUALIFIER_SIZE / sizeof (u32)];
2888a36e453SMaxim Shchetynin 	u64 doubleword[FSF_STATUS_QUALIFIER_SIZE / sizeof(u64)];
2891da177e4SLinus Torvalds 	struct fsf_queue_designator fsf_queue_designator;
290aef4a983SMaxim Shchetynin 	struct fsf_link_down_info link_down_info;
2911da177e4SLinus Torvalds } __attribute__ ((packed));
2921da177e4SLinus Torvalds 
2931da177e4SLinus Torvalds struct fsf_qtcb_header {
2941da177e4SLinus Torvalds 	u64 req_handle;
2951da177e4SLinus Torvalds 	u32 fsf_command;
2961da177e4SLinus Torvalds 	u32 res1;
2971da177e4SLinus Torvalds 	u32 port_handle;
2981da177e4SLinus Torvalds 	u32 lun_handle;
2991da177e4SLinus Torvalds 	u32 res2;
3001da177e4SLinus Torvalds 	u32 fsf_status;
3011da177e4SLinus Torvalds 	union fsf_status_qual fsf_status_qual;
3021da177e4SLinus Torvalds 	u8  res3[28];
3031da177e4SLinus Torvalds 	u16 log_start;
3041da177e4SLinus Torvalds 	u16 log_length;
3051da177e4SLinus Torvalds 	u8  res4[16];
3061da177e4SLinus Torvalds } __attribute__ ((packed));
3071da177e4SLinus Torvalds 
30839eb7e9aSChristof Schmitt #define FSF_PLOGI_MIN_LEN	112
3091da177e4SLinus Torvalds 
3101da177e4SLinus Torvalds #define FSF_FCP_CMND_SIZE	288
3111da177e4SLinus Torvalds #define FSF_FCP_RSP_SIZE	128
3121da177e4SLinus Torvalds 
3131da177e4SLinus Torvalds struct fsf_qtcb_bottom_io {
3141da177e4SLinus Torvalds 	u32 data_direction;
3151da177e4SLinus Torvalds 	u32 service_class;
316ef3eb71dSFelix Beck 	u8  res1;
317ef3eb71dSFelix Beck 	u8  data_prot_flags;
318ef3eb71dSFelix Beck 	u16 app_tag_value;
319ef3eb71dSFelix Beck 	u32 ref_tag_value;
3201da177e4SLinus Torvalds 	u32 fcp_cmnd_length;
321ef3eb71dSFelix Beck 	u32 data_block_length;
322ef3eb71dSFelix Beck 	u32 prot_data_length;
323ef3eb71dSFelix Beck 	u8  res2[4];
324df00d7b8SSteffen Maier 	union {
325df00d7b8SSteffen Maier 		u8		byte[FSF_FCP_CMND_SIZE];
326df00d7b8SSteffen Maier 		struct fcp_cmnd iu;
327df00d7b8SSteffen Maier 	}   fcp_cmnd;
328df00d7b8SSteffen Maier 	union {
329df00d7b8SSteffen Maier 		u8			 byte[FSF_FCP_RSP_SIZE];
330df00d7b8SSteffen Maier 		struct fcp_resp_with_ext iu;
331df00d7b8SSteffen Maier 	}   fcp_rsp;
3321da177e4SLinus Torvalds 	u8  res3[64];
3331da177e4SLinus Torvalds } __attribute__ ((packed));
3341da177e4SLinus Torvalds 
3351da177e4SLinus Torvalds struct fsf_qtcb_bottom_support {
3361da177e4SLinus Torvalds 	u32 operation_subtype;
337800c0cadSChristof Schmitt 	u8  res1[13];
338800c0cadSChristof Schmitt 	u8 d_id[3];
3391da177e4SLinus Torvalds 	u32 option;
3401da177e4SLinus Torvalds 	u64 fcp_lun;
3411da177e4SLinus Torvalds 	u64 res2;
3421da177e4SLinus Torvalds 	u64 req_handle;
3431da177e4SLinus Torvalds 	u32 service_class;
3441da177e4SLinus Torvalds 	u8  res3[3];
3451da177e4SLinus Torvalds 	u8  timeout;
3461da177e4SLinus Torvalds         u32 lun_access_info;
347a17c7846SJens Remus 	u32 connection_info;
348a17c7846SJens Remus 	u8  res4[176];
3491da177e4SLinus Torvalds 	u32 els1_length;
3501da177e4SLinus Torvalds 	u32 els2_length;
3511da177e4SLinus Torvalds 	u32 req_buf_length;
3521da177e4SLinus Torvalds 	u32 resp_buf_length;
3531da177e4SLinus Torvalds 	u8  els[256];
3541da177e4SLinus Torvalds } __attribute__ ((packed));
3551da177e4SLinus Torvalds 
356faf4cd85SChristof Schmitt #define ZFCP_FSF_TIMER_INT_MASK	0x3FFF
357faf4cd85SChristof Schmitt 
3581da177e4SLinus Torvalds struct fsf_qtcb_bottom_config {
3591da177e4SLinus Torvalds 	u32 lic_version;
3601da177e4SLinus Torvalds 	u32 feature_selection;
3611da177e4SLinus Torvalds 	u32 high_qtcb_version;
3621da177e4SLinus Torvalds 	u32 low_qtcb_version;
3631da177e4SLinus Torvalds 	u32 max_qtcb_size;
3641da177e4SLinus Torvalds 	u32 max_data_transfer_size;
365aef4a983SMaxim Shchetynin 	u32 adapter_features;
366aef4a983SMaxim Shchetynin 	u32 connection_features;
3671da177e4SLinus Torvalds 	u32 fc_topology;
36816dad279SJens Remus 	u32 fc_link_speed;	/* one of ZFCP_FSF_PORTSPEED_* */
3691da177e4SLinus Torvalds 	u32 adapter_type;
370800c0cadSChristof Schmitt 	u8 res0;
371800c0cadSChristof Schmitt 	u8 peer_d_id[3];
37264deb6efSChristof Schmitt 	u16 status_read_buf_num;
373c9615858SChristof Schmitt 	u16 timer_interval;
374800c0cadSChristof Schmitt 	u8 res2[9];
375800c0cadSChristof Schmitt 	u8 s_id[3];
3769d05ce2cSChristof Schmitt 	u8 nport_serv_param[128];
3771da177e4SLinus Torvalds 	u8 res3[8];
3781da177e4SLinus Torvalds 	u32 adapter_ports;
3791da177e4SLinus Torvalds 	u32 hardware_version;
3801da177e4SLinus Torvalds 	u8 serial_number[32];
3819d05ce2cSChristof Schmitt 	u8 plogi_payload[112];
3826d9d63b9SSwen Schillig 	struct fsf_statistics_info stat_info;
3836d9d63b9SSwen Schillig 	u8 res4[112];
3841da177e4SLinus Torvalds } __attribute__ ((packed));
3851da177e4SLinus Torvalds 
3861da177e4SLinus Torvalds struct fsf_qtcb_bottom_port {
387aef4a983SMaxim Shchetynin 	u64 wwpn;
3881da177e4SLinus Torvalds 	u32 fc_port_id;
3891da177e4SLinus Torvalds 	u32 port_type;
3901da177e4SLinus Torvalds 	u32 port_state;
3911da177e4SLinus Torvalds 	u32 class_of_service;	/* should be 0x00000006 for class 2 and 3 */
3921da177e4SLinus Torvalds 	u8 supported_fc4_types[32]; /* should be 0x00000100 for scsi fcp */
3931da177e4SLinus Torvalds 	u8 active_fc4_types[32];
39416dad279SJens Remus 	u32 supported_speed;	/* any combination of ZFCP_FSF_PORTSPEED_* */
3951da177e4SLinus Torvalds 	u32 maximum_frame_size;	/* fixed value of 2112 */
3961da177e4SLinus Torvalds 	u64 seconds_since_last_reset;
3971da177e4SLinus Torvalds 	u64 tx_frames;
3981da177e4SLinus Torvalds 	u64 tx_words;
3991da177e4SLinus Torvalds 	u64 rx_frames;
4001da177e4SLinus Torvalds 	u64 rx_words;
4011da177e4SLinus Torvalds 	u64 lip;		/* 0 */
4021da177e4SLinus Torvalds 	u64 nos;		/* currently 0 */
4031da177e4SLinus Torvalds 	u64 error_frames;	/* currently 0 */
4041da177e4SLinus Torvalds 	u64 dumped_frames;	/* currently 0 */
4051da177e4SLinus Torvalds 	u64 link_failure;
4061da177e4SLinus Torvalds 	u64 loss_of_sync;
4071da177e4SLinus Torvalds 	u64 loss_of_signal;
4081da177e4SLinus Torvalds 	u64 psp_error_counts;
4091da177e4SLinus Torvalds 	u64 invalid_tx_words;
4101da177e4SLinus Torvalds 	u64 invalid_crcs;
4111da177e4SLinus Torvalds 	u64 input_requests;
4121da177e4SLinus Torvalds 	u64 output_requests;
4131da177e4SLinus Torvalds 	u64 control_requests;
4141da177e4SLinus Torvalds 	u64 input_mb;		/* where 1 MByte == 1.000.000 Bytes */
4151da177e4SLinus Torvalds 	u64 output_mb;		/* where 1 MByte == 1.000.000 Bytes */
4166d9d63b9SSwen Schillig 	u8 cp_util;
4176d9d63b9SSwen Schillig 	u8 cb_util;
4186d9d63b9SSwen Schillig 	u8 a_util;
419a10a61e8SBenjamin Block 	u8 res2;
420a10a61e8SBenjamin Block 	u16 temperature;
421a10a61e8SBenjamin Block 	u16 vcc;
422a10a61e8SBenjamin Block 	u16 tx_bias;
423a10a61e8SBenjamin Block 	u16 tx_power;
424a10a61e8SBenjamin Block 	u16 rx_power;
425a10a61e8SBenjamin Block 	union {
426a10a61e8SBenjamin Block 		u16 raw;
427a10a61e8SBenjamin Block 		struct {
428a10a61e8SBenjamin Block 			u16 fec_active		:1;
429a10a61e8SBenjamin Block 			u16:7;
430a10a61e8SBenjamin Block 			u16 connector_type	:2;
431a10a61e8SBenjamin Block 			u16 sfp_invalid		:1;
432a10a61e8SBenjamin Block 			u16 optical_port	:1;
433a10a61e8SBenjamin Block 			u16 port_tx_type	:4;
434a10a61e8SBenjamin Block 		};
435a10a61e8SBenjamin Block 	} sfp_flags;
436a17c7846SJens Remus 	u32 fc_security_algorithms;
437a17c7846SJens Remus 	u8 res3[236];
4381da177e4SLinus Torvalds } __attribute__ ((packed));
4391da177e4SLinus Torvalds 
4401da177e4SLinus Torvalds union fsf_qtcb_bottom {
4411da177e4SLinus Torvalds 	struct fsf_qtcb_bottom_io      io;
4421da177e4SLinus Torvalds 	struct fsf_qtcb_bottom_support support;
4431da177e4SLinus Torvalds 	struct fsf_qtcb_bottom_config  config;
4441da177e4SLinus Torvalds 	struct fsf_qtcb_bottom_port port;
4451da177e4SLinus Torvalds };
4461da177e4SLinus Torvalds 
4471da177e4SLinus Torvalds struct fsf_qtcb {
4481da177e4SLinus Torvalds 	struct fsf_qtcb_prefix prefix;
4491da177e4SLinus Torvalds 	struct fsf_qtcb_header header;
4501da177e4SLinus Torvalds 	union  fsf_qtcb_bottom bottom;
4511da177e4SLinus Torvalds 	u8 log[FSF_QTCB_LOG_SIZE];
4521da177e4SLinus Torvalds } __attribute__ ((packed));
4531da177e4SLinus Torvalds 
4540997f1c5SStefan Raspl struct zfcp_blk_drv_data {
4550997f1c5SStefan Raspl #define ZFCP_BLK_DRV_DATA_MAGIC			0x1
4560997f1c5SStefan Raspl 	u32 magic;
4570997f1c5SStefan Raspl #define ZFCP_BLK_LAT_VALID			0x1
4580997f1c5SStefan Raspl #define ZFCP_BLK_REQ_ERROR			0x2
4590997f1c5SStefan Raspl 	u16 flags;
4600997f1c5SStefan Raspl 	u8 inb_usage;
4610997f1c5SStefan Raspl 	u8 outb_usage;
4620997f1c5SStefan Raspl 	u64 channel_lat;
4630997f1c5SStefan Raspl 	u64 fabric_lat;
4640997f1c5SStefan Raspl } __attribute__ ((packed));
4650997f1c5SStefan Raspl 
4667c7dc196SChristof Schmitt /**
4677c7dc196SChristof Schmitt  * struct zfcp_fsf_ct_els - zfcp data for ct or els request
468623cd180SSteffen Maier  * @req: scatter-gather list for request, points to &zfcp_fc_req.sg_req or BSG
469623cd180SSteffen Maier  * @resp: scatter-gather list for response, points to &zfcp_fc_req.sg_rsp or BSG
4707c7dc196SChristof Schmitt  * @handler: handler function (called for response to the request)
4717c7dc196SChristof Schmitt  * @handler_data: data passed to handler function
4727c7dc196SChristof Schmitt  * @port: Optional pointer to port for zfcp internal ELS (only test link ADISC)
4737c7dc196SChristof Schmitt  * @status: used to pass error status to calling function
474771bf035SSteffen Maier  * @d_id: Destination ID of either open WKA port for CT or of D_ID for ELS
4757c7dc196SChristof Schmitt  */
4767c7dc196SChristof Schmitt struct zfcp_fsf_ct_els {
4777c7dc196SChristof Schmitt 	struct scatterlist *req;
4787c7dc196SChristof Schmitt 	struct scatterlist *resp;
4797c7dc196SChristof Schmitt 	void (*handler)(void *);
4807c7dc196SChristof Schmitt 	void *handler_data;
4817c7dc196SChristof Schmitt 	struct zfcp_port *port;
4827c7dc196SChristof Schmitt 	int status;
483771bf035SSteffen Maier 	u32 d_id;
4847c7dc196SChristof Schmitt };
4857c7dc196SChristof Schmitt 
4861da177e4SLinus Torvalds #endif				/* FSF_H */
487