Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * zfcp device driver
0004  *
0005  * Interface to the FSF support functions.
0006  *
0007  * Copyright IBM Corp. 2002, 2020
0008  */
0009 
0010 #ifndef FSF_H
0011 #define FSF_H
0012 
0013 #include <linux/pfn.h>
0014 #include <linux/scatterlist.h>
0015 #include <scsi/libfc.h>
0016 
0017 #define FSF_QTCB_CURRENT_VERSION        0x00000001
0018 
0019 /* FSF commands */
0020 #define FSF_QTCB_FCP_CMND           0x00000001
0021 #define FSF_QTCB_ABORT_FCP_CMND         0x00000002
0022 #define FSF_QTCB_OPEN_PORT_WITH_DID     0x00000005
0023 #define FSF_QTCB_OPEN_LUN           0x00000006
0024 #define FSF_QTCB_CLOSE_LUN          0x00000007
0025 #define FSF_QTCB_CLOSE_PORT         0x00000008
0026 #define FSF_QTCB_CLOSE_PHYSICAL_PORT        0x00000009
0027 #define FSF_QTCB_SEND_ELS           0x0000000B
0028 #define FSF_QTCB_SEND_GENERIC           0x0000000C
0029 #define FSF_QTCB_EXCHANGE_CONFIG_DATA       0x0000000D
0030 #define FSF_QTCB_EXCHANGE_PORT_DATA     0x0000000E
0031 #define FSF_QTCB_DOWNLOAD_CONTROL_FILE      0x00000012
0032 #define FSF_QTCB_UPLOAD_CONTROL_FILE        0x00000013
0033 
0034 /* FSF QTCB types */
0035 #define FSF_IO_COMMAND              0x00000001
0036 #define FSF_SUPPORT_COMMAND         0x00000002
0037 #define FSF_CONFIG_COMMAND          0x00000003
0038 #define FSF_PORT_COMMAND            0x00000004
0039 
0040 /* FSF protocol states */
0041 #define FSF_PROT_GOOD               0x00000001
0042 #define FSF_PROT_QTCB_VERSION_ERROR     0x00000010
0043 #define FSF_PROT_SEQ_NUMB_ERROR         0x00000020
0044 #define FSF_PROT_UNSUPP_QTCB_TYPE       0x00000040
0045 #define FSF_PROT_HOST_CONNECTION_INITIALIZING   0x00000080
0046 #define FSF_PROT_FSF_STATUS_PRESENTED       0x00000100
0047 #define FSF_PROT_DUPLICATE_REQUEST_ID       0x00000200
0048 #define FSF_PROT_LINK_DOWN                      0x00000400
0049 #define FSF_PROT_REEST_QUEUE                    0x00000800
0050 #define FSF_PROT_ERROR_STATE            0x01000000
0051 
0052 /* FSF states */
0053 #define FSF_GOOD                0x00000000
0054 #define FSF_PORT_ALREADY_OPEN           0x00000001
0055 #define FSF_LUN_ALREADY_OPEN            0x00000002
0056 #define FSF_PORT_HANDLE_NOT_VALID       0x00000003
0057 #define FSF_LUN_HANDLE_NOT_VALID        0x00000004
0058 #define FSF_HANDLE_MISMATCH         0x00000005
0059 #define FSF_SERVICE_CLASS_NOT_SUPPORTED     0x00000006
0060 #define FSF_FCPLUN_NOT_VALID            0x00000009
0061 #define FSF_LUN_SHARING_VIOLATION               0x00000012
0062 #define FSF_FCP_COMMAND_DOES_NOT_EXIST      0x00000022
0063 #define FSF_DIRECTION_INDICATOR_NOT_VALID   0x00000030
0064 #define FSF_CMND_LENGTH_NOT_VALID       0x00000033
0065 #define FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED    0x00000040
0066 #define FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED 0x00000041
0067 #define FSF_ELS_COMMAND_REJECTED        0x00000050
0068 #define FSF_GENERIC_COMMAND_REJECTED        0x00000051
0069 #define FSF_PORT_BOXED              0x00000059
0070 #define FSF_LUN_BOXED               0x0000005A
0071 #define FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE 0x0000005B
0072 #define FSF_PAYLOAD_SIZE_MISMATCH       0x00000060
0073 #define FSF_REQUEST_SIZE_TOO_LARGE      0x00000061
0074 #define FSF_RESPONSE_SIZE_TOO_LARGE     0x00000062
0075 #define FSF_SBAL_MISMATCH           0x00000063
0076 #define FSF_INCONSISTENT_PROT_DATA      0x00000070
0077 #define FSF_INVALID_PROT_PARM           0x00000071
0078 #define FSF_BLOCK_GUARD_CHECK_FAILURE       0x00000081
0079 #define FSF_APP_TAG_CHECK_FAILURE       0x00000082
0080 #define FSF_REF_TAG_CHECK_FAILURE       0x00000083
0081 #define FSF_SECURITY_ERROR          0x00000090
0082 #define FSF_ADAPTER_STATUS_AVAILABLE        0x000000AD
0083 #define FSF_FCP_RSP_AVAILABLE           0x000000AF
0084 #define FSF_UNKNOWN_COMMAND         0x000000E2
0085 #define FSF_UNKNOWN_OP_SUBTYPE                  0x000000E3
0086 #define FSF_INVALID_COMMAND_OPTION              0x000000E5
0087 
0088 #define FSF_PROT_STATUS_QUAL_SIZE       16
0089 #define FSF_STATUS_QUALIFIER_SIZE       16
0090 
0091 /* FSF status qualifier, recommendations */
0092 #define FSF_SQ_NO_RECOM             0x00
0093 #define FSF_SQ_FCP_RSP_AVAILABLE        0x01
0094 #define FSF_SQ_RETRY_IF_POSSIBLE        0x02
0095 #define FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED   0x03
0096 #define FSF_SQ_INVOKE_LINK_TEST_PROCEDURE   0x04
0097 #define FSF_SQ_COMMAND_ABORTED          0x06
0098 #define FSF_SQ_NO_RETRY_POSSIBLE        0x07
0099 
0100 /* FSF status qualifier (most significant 4 bytes), local link down */
0101 #define FSF_PSQ_LINK_NO_LIGHT           0x00000004
0102 #define FSF_PSQ_LINK_WRAP_PLUG          0x00000008
0103 #define FSF_PSQ_LINK_NO_FCP         0x00000010
0104 #define FSF_PSQ_LINK_FIRMWARE_UPDATE        0x00000020
0105 #define FSF_PSQ_LINK_INVALID_WWPN       0x00000100
0106 #define FSF_PSQ_LINK_NO_NPIV_SUPPORT        0x00000200
0107 #define FSF_PSQ_LINK_NO_FCP_RESOURCES       0x00000400
0108 #define FSF_PSQ_LINK_NO_FABRIC_RESOURCES    0x00000800
0109 #define FSF_PSQ_LINK_FABRIC_LOGIN_UNABLE    0x00001000
0110 #define FSF_PSQ_LINK_WWPN_ASSIGNMENT_CORRUPTED  0x00002000
0111 #define FSF_PSQ_LINK_MODE_TABLE_CURRUPTED   0x00004000
0112 #define FSF_PSQ_LINK_NO_WWPN_ASSIGNMENT     0x00008000
0113 
0114 /* FSF status qualifier, security error */
0115 #define FSF_SQ_SECURITY_REQUIRED        0x00000001
0116 #define FSF_SQ_SECURITY_TIMEOUT         0x00000002
0117 #define FSF_SQ_SECURITY_KM_UNAVAILABLE      0x00000003
0118 #define FSF_SQ_SECURITY_RKM_UNAVAILABLE     0x00000004
0119 #define FSF_SQ_SECURITY_AUTH_FAILURE        0x00000005
0120 #define FSF_SQ_SECURITY_ENC_FAILURE     0x00000010
0121 
0122 /* payload size in status read buffer */
0123 #define FSF_STATUS_READ_PAYLOAD_SIZE        4032
0124 
0125 /* number of status read buffers that should be sent by ULP */
0126 #define FSF_STATUS_READS_RECOM          16
0127 
0128 /* status types in status read buffer */
0129 #define FSF_STATUS_READ_PORT_CLOSED     0x00000001
0130 #define FSF_STATUS_READ_INCOMING_ELS        0x00000002
0131 #define FSF_STATUS_READ_SENSE_DATA_AVAIL        0x00000003
0132 #define FSF_STATUS_READ_BIT_ERROR_THRESHOLD 0x00000004
0133 #define FSF_STATUS_READ_LINK_DOWN       0x00000005
0134 #define FSF_STATUS_READ_LINK_UP             0x00000006
0135 #define FSF_STATUS_READ_NOTIFICATION_LOST   0x00000009
0136 #define FSF_STATUS_READ_FEATURE_UPDATE_ALERT    0x0000000C
0137 #define FSF_STATUS_READ_VERSION_CHANGE      0x0000000D
0138 
0139 /* status subtypes for link down */
0140 #define FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK    0x00000000
0141 #define FSF_STATUS_READ_SUB_FDISC_FAILED    0x00000001
0142 #define FSF_STATUS_READ_SUB_FIRMWARE_UPDATE 0x00000002
0143 
0144 /* status subtypes for unsolicited status notification lost */
0145 #define FSF_STATUS_READ_SUB_INCOMING_ELS    0x00000001
0146 #define FSF_STATUS_READ_SUB_VERSION_CHANGE  0x00000100
0147 
0148 /* status subtypes for version change */
0149 #define FSF_STATUS_READ_SUB_LIC_CHANGE      0x00000001
0150 
0151 /* topologie that is detected by the adapter */
0152 #define FSF_TOPO_P2P                0x00000001
0153 #define FSF_TOPO_FABRIC             0x00000002
0154 #define FSF_TOPO_AL             0x00000003
0155 
0156 /* data direction for FCP commands */
0157 #define FSF_DATADIR_WRITE           0x00000001
0158 #define FSF_DATADIR_READ            0x00000002
0159 #define FSF_DATADIR_CMND            0x00000004
0160 #define FSF_DATADIR_DIF_WRITE_INSERT        0x00000009
0161 #define FSF_DATADIR_DIF_READ_STRIP      0x0000000a
0162 #define FSF_DATADIR_DIF_WRITE_CONVERT       0x0000000b
0163 #define FSF_DATADIR_DIF_READ_CONVERT        0X0000000c
0164 
0165 /* data protection control flags */
0166 #define FSF_APP_TAG_CHECK_ENABLE        0x10
0167 
0168 /* fc service class */
0169 #define FSF_CLASS_3             0x00000003
0170 
0171 /* logging space behind QTCB */
0172 #define FSF_QTCB_LOG_SIZE           1024
0173 
0174 /* channel features */
0175 #define FSF_FEATURE_NOTIFICATION_LOST       0x00000008
0176 #define FSF_FEATURE_HBAAPI_MANAGEMENT           0x00000010
0177 #define FSF_FEATURE_ELS_CT_CHAINED_SBALS    0x00000020
0178 #define FSF_FEATURE_UPDATE_ALERT        0x00000100
0179 #define FSF_FEATURE_MEASUREMENT_DATA        0x00000200
0180 #define FSF_FEATURE_REQUEST_SFP_DATA        0x00000200
0181 #define FSF_FEATURE_REPORT_SFP_DATA     0x00000800
0182 #define FSF_FEATURE_FC_SECURITY         0x00001000
0183 #define FSF_FEATURE_DIF_PROT_TYPE1      0x00010000
0184 #define FSF_FEATURE_DIX_PROT_TCPIP      0x00020000
0185 
0186 /* host connection features */
0187 #define FSF_FEATURE_NPIV_MODE           0x00000001
0188 
0189 /* option */
0190 #define FSF_OPEN_LUN_SUPPRESS_BOXING        0x00000001
0191 
0192 /* FC security algorithms */
0193 #define FSF_FC_SECURITY_AUTH            0x00000001
0194 #define FSF_FC_SECURITY_ENC_FCSP2       0x00000002
0195 #define FSF_FC_SECURITY_ENC_ERAS        0x00000004
0196 
0197 struct fsf_queue_designator {
0198     u8  cssid;
0199     u8  chpid;
0200     u8  hla;
0201     u8  ua;
0202     u32 res1;
0203 } __attribute__ ((packed));
0204 
0205 struct fsf_bit_error_payload {
0206     u32 res1;
0207     u32 link_failure_error_count;
0208     u32 loss_of_sync_error_count;
0209     u32 loss_of_signal_error_count;
0210     u32 primitive_sequence_error_count;
0211     u32 invalid_transmission_word_error_count;
0212     u32 crc_error_count;
0213     u32 primitive_sequence_event_timeout_count;
0214     u32 elastic_buffer_overrun_error_count;
0215     u32 fcal_arbitration_timeout_count;
0216     u32 advertised_receive_b2b_credit;
0217     u32 current_receive_b2b_credit;
0218     u32 advertised_transmit_b2b_credit;
0219     u32 current_transmit_b2b_credit;
0220 } __attribute__ ((packed));
0221 
0222 struct fsf_link_down_info {
0223     u32 error_code;
0224     u32 res1;
0225     u8 res2[2];
0226     u8 primary_status;
0227     u8 ioerr_code;
0228     u8 action_code;
0229     u8 reason_code;
0230     u8 explanation_code;
0231     u8 vendor_specific_code;
0232 } __attribute__ ((packed));
0233 
0234 struct fsf_version_change {
0235     u32 current_version;
0236     u32 previous_version;
0237 } __packed;
0238 
0239 struct fsf_status_read_buffer {
0240     u32 status_type;
0241     u32 status_subtype;
0242     u32 length;
0243     u32 res1;
0244     struct fsf_queue_designator queue_designator;
0245     u8 res2;
0246     u8 d_id[3];
0247     u32 class;
0248     u64 fcp_lun;
0249     u8  res3[24];
0250     union {
0251         u8  data[FSF_STATUS_READ_PAYLOAD_SIZE];
0252         u32 word[FSF_STATUS_READ_PAYLOAD_SIZE/sizeof(u32)];
0253         struct fsf_link_down_info link_down_info;
0254         struct fsf_bit_error_payload bit_error;
0255         struct fsf_version_change version_change;
0256     } payload;
0257 } __attribute__ ((packed));
0258 
0259 struct fsf_qual_version_error {
0260     u32 fsf_version;
0261     u32 res1[3];
0262 } __attribute__ ((packed));
0263 
0264 struct fsf_qual_sequence_error {
0265     u32 exp_req_seq_no;
0266     u32 res1[3];
0267 } __attribute__ ((packed));
0268 
0269 struct fsf_qual_latency_info {
0270     u32 channel_lat;
0271     u32 fabric_lat;
0272     u8 res1[8];
0273 } __attribute__ ((packed));
0274 
0275 union fsf_prot_status_qual {
0276     u32 word[FSF_PROT_STATUS_QUAL_SIZE / sizeof(u32)];
0277     u64 doubleword[FSF_PROT_STATUS_QUAL_SIZE / sizeof(u64)];
0278     struct fsf_qual_version_error   version_error;
0279     struct fsf_qual_sequence_error  sequence_error;
0280     struct fsf_link_down_info link_down_info;
0281     struct fsf_qual_latency_info latency_info;
0282 } __attribute__ ((packed));
0283 
0284 struct fsf_qtcb_prefix {
0285     u64 req_id;
0286     u32 qtcb_version;
0287     u32 ulp_info;
0288     u32 qtcb_type;
0289     u32 req_seq_no;
0290     u32 prot_status;
0291     union fsf_prot_status_qual prot_status_qual;
0292     u8  res1[20];
0293 } __attribute__ ((packed));
0294 
0295 struct fsf_statistics_info {
0296     u64 input_req;
0297     u64 output_req;
0298     u64 control_req;
0299     u64 input_mb;
0300     u64 output_mb;
0301     u64 seconds_act;
0302 } __attribute__ ((packed));
0303 
0304 union fsf_status_qual {
0305     u8  byte[FSF_STATUS_QUALIFIER_SIZE];
0306     u16 halfword[FSF_STATUS_QUALIFIER_SIZE / sizeof (u16)];
0307     u32 word[FSF_STATUS_QUALIFIER_SIZE / sizeof (u32)];
0308     u64 doubleword[FSF_STATUS_QUALIFIER_SIZE / sizeof(u64)];
0309     struct fsf_queue_designator fsf_queue_designator;
0310     struct fsf_link_down_info link_down_info;
0311 } __attribute__ ((packed));
0312 
0313 struct fsf_qtcb_header {
0314     u64 req_handle;
0315     u32 fsf_command;
0316     u32 res1;
0317     u32 port_handle;
0318     u32 lun_handle;
0319     u32 res2;
0320     u32 fsf_status;
0321     union fsf_status_qual fsf_status_qual;
0322     u8  res3[28];
0323     u16 log_start;
0324     u16 log_length;
0325     u8  res4[16];
0326 } __attribute__ ((packed));
0327 
0328 #define FSF_PLOGI_MIN_LEN   112
0329 
0330 #define FSF_FCP_CMND_SIZE   288
0331 #define FSF_FCP_RSP_SIZE    128
0332 
0333 struct fsf_qtcb_bottom_io {
0334     u32 data_direction;
0335     u32 service_class;
0336     u8  res1;
0337     u8  data_prot_flags;
0338     u16 app_tag_value;
0339     u32 ref_tag_value;
0340     u32 fcp_cmnd_length;
0341     u32 data_block_length;
0342     u32 prot_data_length;
0343     u8  res2[4];
0344     union {
0345         u8      byte[FSF_FCP_CMND_SIZE];
0346         struct fcp_cmnd iu;
0347     }   fcp_cmnd;
0348     union {
0349         u8           byte[FSF_FCP_RSP_SIZE];
0350         struct fcp_resp_with_ext iu;
0351     }   fcp_rsp;
0352     u8  res3[64];
0353 } __attribute__ ((packed));
0354 
0355 struct fsf_qtcb_bottom_support {
0356     u32 operation_subtype;
0357     u8  res1[13];
0358     u8 d_id[3];
0359     u32 option;
0360     u64 fcp_lun;
0361     u64 res2;
0362     u64 req_handle;
0363     u32 service_class;
0364     u8  res3[3];
0365     u8  timeout;
0366         u32 lun_access_info;
0367     u32 connection_info;
0368     u8  res4[176];
0369     u32 els1_length;
0370     u32 els2_length;
0371     u32 req_buf_length;
0372     u32 resp_buf_length;
0373     u8  els[256];
0374 } __attribute__ ((packed));
0375 
0376 #define ZFCP_FSF_TIMER_INT_MASK 0x3FFF
0377 
0378 struct fsf_qtcb_bottom_config {
0379     u32 lic_version;
0380     u32 feature_selection;
0381     u32 high_qtcb_version;
0382     u32 low_qtcb_version;
0383     u32 max_qtcb_size;
0384     u32 max_data_transfer_size;
0385     u32 adapter_features;
0386     u32 connection_features;
0387     u32 fc_topology;
0388     u32 fc_link_speed;  /* one of ZFCP_FSF_PORTSPEED_* */
0389     u32 adapter_type;
0390     u8 res0;
0391     u8 peer_d_id[3];
0392     u16 status_read_buf_num;
0393     u16 timer_interval;
0394     u8 res2[9];
0395     u8 s_id[3];
0396     u8 nport_serv_param[128];
0397     u8 res3[8];
0398     u32 adapter_ports;
0399     u32 hardware_version;
0400     u8 serial_number[32];
0401     u8 plogi_payload[112];
0402     struct fsf_statistics_info stat_info;
0403     u8 res4[112];
0404 } __attribute__ ((packed));
0405 
0406 struct fsf_qtcb_bottom_port {
0407     u64 wwpn;
0408     u32 fc_port_id;
0409     u32 port_type;
0410     u32 port_state;
0411     u32 class_of_service;   /* should be 0x00000006 for class 2 and 3 */
0412     u8 supported_fc4_types[32]; /* should be 0x00000100 for scsi fcp */
0413     u8 active_fc4_types[32];
0414     u32 supported_speed;    /* any combination of ZFCP_FSF_PORTSPEED_* */
0415     u32 maximum_frame_size; /* fixed value of 2112 */
0416     u64 seconds_since_last_reset;
0417     u64 tx_frames;
0418     u64 tx_words;
0419     u64 rx_frames;
0420     u64 rx_words;
0421     u64 lip;        /* 0 */
0422     u64 nos;        /* currently 0 */
0423     u64 error_frames;   /* currently 0 */
0424     u64 dumped_frames;  /* currently 0 */
0425     u64 link_failure;
0426     u64 loss_of_sync;
0427     u64 loss_of_signal;
0428     u64 psp_error_counts;
0429     u64 invalid_tx_words;
0430     u64 invalid_crcs;
0431     u64 input_requests;
0432     u64 output_requests;
0433     u64 control_requests;
0434     u64 input_mb;       /* where 1 MByte == 1.000.000 Bytes */
0435     u64 output_mb;      /* where 1 MByte == 1.000.000 Bytes */
0436     u8 cp_util;
0437     u8 cb_util;
0438     u8 a_util;
0439     u8 res2;
0440     s16 temperature;
0441     u16 vcc;
0442     u16 tx_bias;
0443     u16 tx_power;
0444     u16 rx_power;
0445     union {
0446         u16 raw;
0447         struct {
0448             u16 fec_active      :1;
0449             u16:7;
0450             u16 connector_type  :2;
0451             u16 sfp_invalid     :1;
0452             u16 optical_port    :1;
0453             u16 port_tx_type    :4;
0454         };
0455     } sfp_flags;
0456     u32 fc_security_algorithms;
0457     u8 res3[236];
0458 } __attribute__ ((packed));
0459 
0460 union fsf_qtcb_bottom {
0461     struct fsf_qtcb_bottom_io      io;
0462     struct fsf_qtcb_bottom_support support;
0463     struct fsf_qtcb_bottom_config  config;
0464     struct fsf_qtcb_bottom_port port;
0465 };
0466 
0467 struct fsf_qtcb {
0468     struct fsf_qtcb_prefix prefix;
0469     struct fsf_qtcb_header header;
0470     union  fsf_qtcb_bottom bottom;
0471     u8 log[FSF_QTCB_LOG_SIZE];
0472 } __attribute__ ((packed));
0473 
0474 struct zfcp_blk_drv_data {
0475 #define ZFCP_BLK_DRV_DATA_MAGIC         0x1
0476     u32 magic;
0477 #define ZFCP_BLK_LAT_VALID          0x1
0478 #define ZFCP_BLK_REQ_ERROR          0x2
0479     u16 flags;
0480     u8 inb_usage;
0481     u8 outb_usage;
0482     u64 channel_lat;
0483     u64 fabric_lat;
0484 } __attribute__ ((packed));
0485 
0486 /**
0487  * struct zfcp_fsf_ct_els - zfcp data for ct or els request
0488  * @req: scatter-gather list for request, points to &zfcp_fc_req.sg_req or BSG
0489  * @resp: scatter-gather list for response, points to &zfcp_fc_req.sg_rsp or BSG
0490  * @handler: handler function (called for response to the request)
0491  * @handler_data: data passed to handler function
0492  * @port: Optional pointer to port for zfcp internal ELS (only test link ADISC)
0493  * @status: used to pass error status to calling function
0494  * @d_id: Destination ID of either open WKA port for CT or of D_ID for ELS
0495  */
0496 struct zfcp_fsf_ct_els {
0497     struct scatterlist *req;
0498     struct scatterlist *resp;
0499     void (*handler)(void *);
0500     void *handler_data;
0501     struct zfcp_port *port;
0502     int status;
0503     u32 d_id;
0504 };
0505 
0506 #endif              /* FSF_H */