zfcp_fsf.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * zfcp device driver
  4. *
  5. * Interface to the FSF support functions.
  6. *
  7. * Copyright IBM Corp. 2002, 2020
  8. */
  9. #ifndef FSF_H
  10. #define FSF_H
  11. #include <linux/pfn.h>
  12. #include <linux/scatterlist.h>
  13. #include <scsi/libfc.h>
  14. #define FSF_QTCB_CURRENT_VERSION 0x00000001
  15. /* FSF commands */
  16. #define FSF_QTCB_FCP_CMND 0x00000001
  17. #define FSF_QTCB_ABORT_FCP_CMND 0x00000002
  18. #define FSF_QTCB_OPEN_PORT_WITH_DID 0x00000005
  19. #define FSF_QTCB_OPEN_LUN 0x00000006
  20. #define FSF_QTCB_CLOSE_LUN 0x00000007
  21. #define FSF_QTCB_CLOSE_PORT 0x00000008
  22. #define FSF_QTCB_CLOSE_PHYSICAL_PORT 0x00000009
  23. #define FSF_QTCB_SEND_ELS 0x0000000B
  24. #define FSF_QTCB_SEND_GENERIC 0x0000000C
  25. #define FSF_QTCB_EXCHANGE_CONFIG_DATA 0x0000000D
  26. #define FSF_QTCB_EXCHANGE_PORT_DATA 0x0000000E
  27. #define FSF_QTCB_DOWNLOAD_CONTROL_FILE 0x00000012
  28. #define FSF_QTCB_UPLOAD_CONTROL_FILE 0x00000013
  29. /* FSF QTCB types */
  30. #define FSF_IO_COMMAND 0x00000001
  31. #define FSF_SUPPORT_COMMAND 0x00000002
  32. #define FSF_CONFIG_COMMAND 0x00000003
  33. #define FSF_PORT_COMMAND 0x00000004
  34. /* FSF protocol states */
  35. #define FSF_PROT_GOOD 0x00000001
  36. #define FSF_PROT_QTCB_VERSION_ERROR 0x00000010
  37. #define FSF_PROT_SEQ_NUMB_ERROR 0x00000020
  38. #define FSF_PROT_UNSUPP_QTCB_TYPE 0x00000040
  39. #define FSF_PROT_HOST_CONNECTION_INITIALIZING 0x00000080
  40. #define FSF_PROT_FSF_STATUS_PRESENTED 0x00000100
  41. #define FSF_PROT_DUPLICATE_REQUEST_ID 0x00000200
  42. #define FSF_PROT_LINK_DOWN 0x00000400
  43. #define FSF_PROT_REEST_QUEUE 0x00000800
  44. #define FSF_PROT_ERROR_STATE 0x01000000
  45. /* FSF states */
  46. #define FSF_GOOD 0x00000000
  47. #define FSF_PORT_ALREADY_OPEN 0x00000001
  48. #define FSF_LUN_ALREADY_OPEN 0x00000002
  49. #define FSF_PORT_HANDLE_NOT_VALID 0x00000003
  50. #define FSF_LUN_HANDLE_NOT_VALID 0x00000004
  51. #define FSF_HANDLE_MISMATCH 0x00000005
  52. #define FSF_SERVICE_CLASS_NOT_SUPPORTED 0x00000006
  53. #define FSF_FCPLUN_NOT_VALID 0x00000009
  54. #define FSF_LUN_SHARING_VIOLATION 0x00000012
  55. #define FSF_FCP_COMMAND_DOES_NOT_EXIST 0x00000022
  56. #define FSF_DIRECTION_INDICATOR_NOT_VALID 0x00000030
  57. #define FSF_CMND_LENGTH_NOT_VALID 0x00000033
  58. #define FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED 0x00000040
  59. #define FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED 0x00000041
  60. #define FSF_ELS_COMMAND_REJECTED 0x00000050
  61. #define FSF_GENERIC_COMMAND_REJECTED 0x00000051
  62. #define FSF_PORT_BOXED 0x00000059
  63. #define FSF_LUN_BOXED 0x0000005A
  64. #define FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE 0x0000005B
  65. #define FSF_PAYLOAD_SIZE_MISMATCH 0x00000060
  66. #define FSF_REQUEST_SIZE_TOO_LARGE 0x00000061
  67. #define FSF_RESPONSE_SIZE_TOO_LARGE 0x00000062
  68. #define FSF_SBAL_MISMATCH 0x00000063
  69. #define FSF_INCONSISTENT_PROT_DATA 0x00000070
  70. #define FSF_INVALID_PROT_PARM 0x00000071
  71. #define FSF_BLOCK_GUARD_CHECK_FAILURE 0x00000081
  72. #define FSF_APP_TAG_CHECK_FAILURE 0x00000082
  73. #define FSF_REF_TAG_CHECK_FAILURE 0x00000083
  74. #define FSF_SECURITY_ERROR 0x00000090
  75. #define FSF_ADAPTER_STATUS_AVAILABLE 0x000000AD
  76. #define FSF_FCP_RSP_AVAILABLE 0x000000AF
  77. #define FSF_UNKNOWN_COMMAND 0x000000E2
  78. #define FSF_UNKNOWN_OP_SUBTYPE 0x000000E3
  79. #define FSF_INVALID_COMMAND_OPTION 0x000000E5
  80. #define FSF_PROT_STATUS_QUAL_SIZE 16
  81. #define FSF_STATUS_QUALIFIER_SIZE 16
  82. /* FSF status qualifier, recommendations */
  83. #define FSF_SQ_NO_RECOM 0x00
  84. #define FSF_SQ_FCP_RSP_AVAILABLE 0x01
  85. #define FSF_SQ_RETRY_IF_POSSIBLE 0x02
  86. #define FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED 0x03
  87. #define FSF_SQ_INVOKE_LINK_TEST_PROCEDURE 0x04
  88. #define FSF_SQ_COMMAND_ABORTED 0x06
  89. #define FSF_SQ_NO_RETRY_POSSIBLE 0x07
  90. /* FSF status qualifier (most significant 4 bytes), local link down */
  91. #define FSF_PSQ_LINK_NO_LIGHT 0x00000004
  92. #define FSF_PSQ_LINK_WRAP_PLUG 0x00000008
  93. #define FSF_PSQ_LINK_NO_FCP 0x00000010
  94. #define FSF_PSQ_LINK_FIRMWARE_UPDATE 0x00000020
  95. #define FSF_PSQ_LINK_INVALID_WWPN 0x00000100
  96. #define FSF_PSQ_LINK_NO_NPIV_SUPPORT 0x00000200
  97. #define FSF_PSQ_LINK_NO_FCP_RESOURCES 0x00000400
  98. #define FSF_PSQ_LINK_NO_FABRIC_RESOURCES 0x00000800
  99. #define FSF_PSQ_LINK_FABRIC_LOGIN_UNABLE 0x00001000
  100. #define FSF_PSQ_LINK_WWPN_ASSIGNMENT_CORRUPTED 0x00002000
  101. #define FSF_PSQ_LINK_MODE_TABLE_CURRUPTED 0x00004000
  102. #define FSF_PSQ_LINK_NO_WWPN_ASSIGNMENT 0x00008000
  103. /* FSF status qualifier, security error */
  104. #define FSF_SQ_SECURITY_REQUIRED 0x00000001
  105. #define FSF_SQ_SECURITY_TIMEOUT 0x00000002
  106. #define FSF_SQ_SECURITY_KM_UNAVAILABLE 0x00000003
  107. #define FSF_SQ_SECURITY_RKM_UNAVAILABLE 0x00000004
  108. #define FSF_SQ_SECURITY_AUTH_FAILURE 0x00000005
  109. #define FSF_SQ_SECURITY_ENC_FAILURE 0x00000010
  110. /* payload size in status read buffer */
  111. #define FSF_STATUS_READ_PAYLOAD_SIZE 4032
  112. /* number of status read buffers that should be sent by ULP */
  113. #define FSF_STATUS_READS_RECOM 16
  114. /* status types in status read buffer */
  115. #define FSF_STATUS_READ_PORT_CLOSED 0x00000001
  116. #define FSF_STATUS_READ_INCOMING_ELS 0x00000002
  117. #define FSF_STATUS_READ_SENSE_DATA_AVAIL 0x00000003
  118. #define FSF_STATUS_READ_BIT_ERROR_THRESHOLD 0x00000004
  119. #define FSF_STATUS_READ_LINK_DOWN 0x00000005
  120. #define FSF_STATUS_READ_LINK_UP 0x00000006
  121. #define FSF_STATUS_READ_NOTIFICATION_LOST 0x00000009
  122. #define FSF_STATUS_READ_FEATURE_UPDATE_ALERT 0x0000000C
  123. /* status subtypes for link down */
  124. #define FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK 0x00000000
  125. #define FSF_STATUS_READ_SUB_FDISC_FAILED 0x00000001
  126. #define FSF_STATUS_READ_SUB_FIRMWARE_UPDATE 0x00000002
  127. /* status subtypes for unsolicited status notification lost */
  128. #define FSF_STATUS_READ_SUB_INCOMING_ELS 0x00000001
  129. /* topologie that is detected by the adapter */
  130. #define FSF_TOPO_P2P 0x00000001
  131. #define FSF_TOPO_FABRIC 0x00000002
  132. #define FSF_TOPO_AL 0x00000003
  133. /* data direction for FCP commands */
  134. #define FSF_DATADIR_WRITE 0x00000001
  135. #define FSF_DATADIR_READ 0x00000002
  136. #define FSF_DATADIR_CMND 0x00000004
  137. #define FSF_DATADIR_DIF_WRITE_INSERT 0x00000009
  138. #define FSF_DATADIR_DIF_READ_STRIP 0x0000000a
  139. #define FSF_DATADIR_DIF_WRITE_CONVERT 0x0000000b
  140. #define FSF_DATADIR_DIF_READ_CONVERT 0X0000000c
  141. /* data protection control flags */
  142. #define FSF_APP_TAG_CHECK_ENABLE 0x10
  143. /* fc service class */
  144. #define FSF_CLASS_3 0x00000003
  145. /* logging space behind QTCB */
  146. #define FSF_QTCB_LOG_SIZE 1024
  147. /* channel features */
  148. #define FSF_FEATURE_NOTIFICATION_LOST 0x00000008
  149. #define FSF_FEATURE_HBAAPI_MANAGEMENT 0x00000010
  150. #define FSF_FEATURE_ELS_CT_CHAINED_SBALS 0x00000020
  151. #define FSF_FEATURE_UPDATE_ALERT 0x00000100
  152. #define FSF_FEATURE_MEASUREMENT_DATA 0x00000200
  153. #define FSF_FEATURE_REQUEST_SFP_DATA 0x00000200
  154. #define FSF_FEATURE_REPORT_SFP_DATA 0x00000800
  155. #define FSF_FEATURE_FC_SECURITY 0x00001000
  156. #define FSF_FEATURE_DIF_PROT_TYPE1 0x00010000
  157. #define FSF_FEATURE_DIX_PROT_TCPIP 0x00020000
  158. /* host connection features */
  159. #define FSF_FEATURE_NPIV_MODE 0x00000001
  160. /* option */
  161. #define FSF_OPEN_LUN_SUPPRESS_BOXING 0x00000001
  162. /* FC security algorithms */
  163. #define FSF_FC_SECURITY_AUTH 0x00000001
  164. #define FSF_FC_SECURITY_ENC_FCSP2 0x00000002
  165. #define FSF_FC_SECURITY_ENC_ERAS 0x00000004
  166. struct fsf_queue_designator {
  167. u8 cssid;
  168. u8 chpid;
  169. u8 hla;
  170. u8 ua;
  171. u32 res1;
  172. } __attribute__ ((packed));
  173. struct fsf_bit_error_payload {
  174. u32 res1;
  175. u32 link_failure_error_count;
  176. u32 loss_of_sync_error_count;
  177. u32 loss_of_signal_error_count;
  178. u32 primitive_sequence_error_count;
  179. u32 invalid_transmission_word_error_count;
  180. u32 crc_error_count;
  181. u32 primitive_sequence_event_timeout_count;
  182. u32 elastic_buffer_overrun_error_count;
  183. u32 fcal_arbitration_timeout_count;
  184. u32 advertised_receive_b2b_credit;
  185. u32 current_receive_b2b_credit;
  186. u32 advertised_transmit_b2b_credit;
  187. u32 current_transmit_b2b_credit;
  188. } __attribute__ ((packed));
  189. struct fsf_link_down_info {
  190. u32 error_code;
  191. u32 res1;
  192. u8 res2[2];
  193. u8 primary_status;
  194. u8 ioerr_code;
  195. u8 action_code;
  196. u8 reason_code;
  197. u8 explanation_code;
  198. u8 vendor_specific_code;
  199. } __attribute__ ((packed));
  200. struct fsf_status_read_buffer {
  201. u32 status_type;
  202. u32 status_subtype;
  203. u32 length;
  204. u32 res1;
  205. struct fsf_queue_designator queue_designator;
  206. u8 res2;
  207. u8 d_id[3];
  208. u32 class;
  209. u64 fcp_lun;
  210. u8 res3[24];
  211. union {
  212. u8 data[FSF_STATUS_READ_PAYLOAD_SIZE];
  213. u32 word[FSF_STATUS_READ_PAYLOAD_SIZE/sizeof(u32)];
  214. struct fsf_link_down_info link_down_info;
  215. struct fsf_bit_error_payload bit_error;
  216. } payload;
  217. } __attribute__ ((packed));
  218. struct fsf_qual_version_error {
  219. u32 fsf_version;
  220. u32 res1[3];
  221. } __attribute__ ((packed));
  222. struct fsf_qual_sequence_error {
  223. u32 exp_req_seq_no;
  224. u32 res1[3];
  225. } __attribute__ ((packed));
  226. struct fsf_qual_latency_info {
  227. u32 channel_lat;
  228. u32 fabric_lat;
  229. u8 res1[8];
  230. } __attribute__ ((packed));
  231. union fsf_prot_status_qual {
  232. u32 word[FSF_PROT_STATUS_QUAL_SIZE / sizeof(u32)];
  233. u64 doubleword[FSF_PROT_STATUS_QUAL_SIZE / sizeof(u64)];
  234. struct fsf_qual_version_error version_error;
  235. struct fsf_qual_sequence_error sequence_error;
  236. struct fsf_link_down_info link_down_info;
  237. struct fsf_qual_latency_info latency_info;
  238. } __attribute__ ((packed));
  239. struct fsf_qtcb_prefix {
  240. u64 req_id;
  241. u32 qtcb_version;
  242. u32 ulp_info;
  243. u32 qtcb_type;
  244. u32 req_seq_no;
  245. u32 prot_status;
  246. union fsf_prot_status_qual prot_status_qual;
  247. u8 res1[20];
  248. } __attribute__ ((packed));
  249. struct fsf_statistics_info {
  250. u64 input_req;
  251. u64 output_req;
  252. u64 control_req;
  253. u64 input_mb;
  254. u64 output_mb;
  255. u64 seconds_act;
  256. } __attribute__ ((packed));
  257. union fsf_status_qual {
  258. u8 byte[FSF_STATUS_QUALIFIER_SIZE];
  259. u16 halfword[FSF_STATUS_QUALIFIER_SIZE / sizeof (u16)];
  260. u32 word[FSF_STATUS_QUALIFIER_SIZE / sizeof (u32)];
  261. u64 doubleword[FSF_STATUS_QUALIFIER_SIZE / sizeof(u64)];
  262. struct fsf_queue_designator fsf_queue_designator;
  263. struct fsf_link_down_info link_down_info;
  264. } __attribute__ ((packed));
  265. struct fsf_qtcb_header {
  266. u64 req_handle;
  267. u32 fsf_command;
  268. u32 res1;
  269. u32 port_handle;
  270. u32 lun_handle;
  271. u32 res2;
  272. u32 fsf_status;
  273. union fsf_status_qual fsf_status_qual;
  274. u8 res3[28];
  275. u16 log_start;
  276. u16 log_length;
  277. u8 res4[16];
  278. } __attribute__ ((packed));
  279. #define FSF_PLOGI_MIN_LEN 112
  280. #define FSF_FCP_CMND_SIZE 288
  281. #define FSF_FCP_RSP_SIZE 128
  282. struct fsf_qtcb_bottom_io {
  283. u32 data_direction;
  284. u32 service_class;
  285. u8 res1;
  286. u8 data_prot_flags;
  287. u16 app_tag_value;
  288. u32 ref_tag_value;
  289. u32 fcp_cmnd_length;
  290. u32 data_block_length;
  291. u32 prot_data_length;
  292. u8 res2[4];
  293. union {
  294. u8 byte[FSF_FCP_CMND_SIZE];
  295. struct fcp_cmnd iu;
  296. } fcp_cmnd;
  297. union {
  298. u8 byte[FSF_FCP_RSP_SIZE];
  299. struct fcp_resp_with_ext iu;
  300. } fcp_rsp;
  301. u8 res3[64];
  302. } __attribute__ ((packed));
  303. struct fsf_qtcb_bottom_support {
  304. u32 operation_subtype;
  305. u8 res1[13];
  306. u8 d_id[3];
  307. u32 option;
  308. u64 fcp_lun;
  309. u64 res2;
  310. u64 req_handle;
  311. u32 service_class;
  312. u8 res3[3];
  313. u8 timeout;
  314. u32 lun_access_info;
  315. u32 connection_info;
  316. u8 res4[176];
  317. u32 els1_length;
  318. u32 els2_length;
  319. u32 req_buf_length;
  320. u32 resp_buf_length;
  321. u8 els[256];
  322. } __attribute__ ((packed));
  323. #define ZFCP_FSF_TIMER_INT_MASK 0x3FFF
  324. struct fsf_qtcb_bottom_config {
  325. u32 lic_version;
  326. u32 feature_selection;
  327. u32 high_qtcb_version;
  328. u32 low_qtcb_version;
  329. u32 max_qtcb_size;
  330. u32 max_data_transfer_size;
  331. u32 adapter_features;
  332. u32 connection_features;
  333. u32 fc_topology;
  334. u32 fc_link_speed; /* one of ZFCP_FSF_PORTSPEED_* */
  335. u32 adapter_type;
  336. u8 res0;
  337. u8 peer_d_id[3];
  338. u16 status_read_buf_num;
  339. u16 timer_interval;
  340. u8 res2[9];
  341. u8 s_id[3];
  342. u8 nport_serv_param[128];
  343. u8 res3[8];
  344. u32 adapter_ports;
  345. u32 hardware_version;
  346. u8 serial_number[32];
  347. u8 plogi_payload[112];
  348. struct fsf_statistics_info stat_info;
  349. u8 res4[112];
  350. } __attribute__ ((packed));
  351. struct fsf_qtcb_bottom_port {
  352. u64 wwpn;
  353. u32 fc_port_id;
  354. u32 port_type;
  355. u32 port_state;
  356. u32 class_of_service; /* should be 0x00000006 for class 2 and 3 */
  357. u8 supported_fc4_types[32]; /* should be 0x00000100 for scsi fcp */
  358. u8 active_fc4_types[32];
  359. u32 supported_speed; /* any combination of ZFCP_FSF_PORTSPEED_* */
  360. u32 maximum_frame_size; /* fixed value of 2112 */
  361. u64 seconds_since_last_reset;
  362. u64 tx_frames;
  363. u64 tx_words;
  364. u64 rx_frames;
  365. u64 rx_words;
  366. u64 lip; /* 0 */
  367. u64 nos; /* currently 0 */
  368. u64 error_frames; /* currently 0 */
  369. u64 dumped_frames; /* currently 0 */
  370. u64 link_failure;
  371. u64 loss_of_sync;
  372. u64 loss_of_signal;
  373. u64 psp_error_counts;
  374. u64 invalid_tx_words;
  375. u64 invalid_crcs;
  376. u64 input_requests;
  377. u64 output_requests;
  378. u64 control_requests;
  379. u64 input_mb; /* where 1 MByte == 1.000.000 Bytes */
  380. u64 output_mb; /* where 1 MByte == 1.000.000 Bytes */
  381. u8 cp_util;
  382. u8 cb_util;
  383. u8 a_util;
  384. u8 res2;
  385. s16 temperature;
  386. u16 vcc;
  387. u16 tx_bias;
  388. u16 tx_power;
  389. u16 rx_power;
  390. union {
  391. u16 raw;
  392. struct {
  393. u16 fec_active :1;
  394. u16:7;
  395. u16 connector_type :2;
  396. u16 sfp_invalid :1;
  397. u16 optical_port :1;
  398. u16 port_tx_type :4;
  399. };
  400. } sfp_flags;
  401. u32 fc_security_algorithms;
  402. u8 res3[236];
  403. } __attribute__ ((packed));
  404. union fsf_qtcb_bottom {
  405. struct fsf_qtcb_bottom_io io;
  406. struct fsf_qtcb_bottom_support support;
  407. struct fsf_qtcb_bottom_config config;
  408. struct fsf_qtcb_bottom_port port;
  409. };
  410. struct fsf_qtcb {
  411. struct fsf_qtcb_prefix prefix;
  412. struct fsf_qtcb_header header;
  413. union fsf_qtcb_bottom bottom;
  414. u8 log[FSF_QTCB_LOG_SIZE];
  415. } __attribute__ ((packed));
  416. struct zfcp_blk_drv_data {
  417. #define ZFCP_BLK_DRV_DATA_MAGIC 0x1
  418. u32 magic;
  419. #define ZFCP_BLK_LAT_VALID 0x1
  420. #define ZFCP_BLK_REQ_ERROR 0x2
  421. u16 flags;
  422. u8 inb_usage;
  423. u8 outb_usage;
  424. u64 channel_lat;
  425. u64 fabric_lat;
  426. } __attribute__ ((packed));
  427. /**
  428. * struct zfcp_fsf_ct_els - zfcp data for ct or els request
  429. * @req: scatter-gather list for request, points to &zfcp_fc_req.sg_req or BSG
  430. * @resp: scatter-gather list for response, points to &zfcp_fc_req.sg_rsp or BSG
  431. * @handler: handler function (called for response to the request)
  432. * @handler_data: data passed to handler function
  433. * @port: Optional pointer to port for zfcp internal ELS (only test link ADISC)
  434. * @status: used to pass error status to calling function
  435. * @d_id: Destination ID of either open WKA port for CT or of D_ID for ELS
  436. */
  437. struct zfcp_fsf_ct_els {
  438. struct scatterlist *req;
  439. struct scatterlist *resp;
  440. void (*handler)(void *);
  441. void *handler_data;
  442. struct zfcp_port *port;
  443. int status;
  444. u32 d_id;
  445. };
  446. #endif /* FSF_H */