1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Marvell Fibre Channel HBA Driver 4 * Copyright (C) 2018- Marvell 5 * 6 */ 7 #ifndef __QLA_EDIF_BSG_H 8 #define __QLA_EDIF_BSG_H 9 10 #define EDIF_VERSION1 1 11 12 /* BSG Vendor specific commands */ 13 #define ELS_MAX_PAYLOAD 2112 14 #ifndef WWN_SIZE 15 #define WWN_SIZE 8 16 #endif 17 #define VND_CMD_APP_RESERVED_SIZE 28 18 #define VND_CMD_PAD_SIZE 3 19 enum auth_els_sub_cmd { 20 SEND_ELS = 0, 21 SEND_ELS_REPLY, 22 PULL_ELS, 23 }; 24 25 struct extra_auth_els { 26 enum auth_els_sub_cmd sub_cmd; 27 uint32_t extra_rx_xchg_address; 28 uint8_t extra_control_flags; 29 #define BSG_CTL_FLAG_INIT 0 30 #define BSG_CTL_FLAG_LS_ACC 1 31 #define BSG_CTL_FLAG_LS_RJT 2 32 #define BSG_CTL_FLAG_TRM 3 33 uint8_t version; 34 uint8_t pad[2]; 35 uint8_t reserved[VND_CMD_APP_RESERVED_SIZE]; 36 } __packed; 37 38 struct qla_bsg_auth_els_request { 39 struct fc_bsg_request r; 40 struct extra_auth_els e; 41 }; 42 43 struct qla_bsg_auth_els_reply { 44 struct fc_bsg_reply r; 45 uint32_t rx_xchg_address; 46 uint8_t version; 47 uint8_t pad[VND_CMD_PAD_SIZE]; 48 uint8_t reserved[VND_CMD_APP_RESERVED_SIZE]; 49 }; 50 51 struct app_id { 52 int app_vid; 53 uint8_t version; 54 uint8_t pad[VND_CMD_PAD_SIZE]; 55 uint8_t reserved[VND_CMD_APP_RESERVED_SIZE]; 56 } __packed; 57 58 struct app_start_reply { 59 uint32_t host_support_edif; 60 uint32_t edif_enode_active; 61 uint32_t edif_edb_active; 62 uint8_t version; 63 uint8_t pad[VND_CMD_PAD_SIZE]; 64 uint8_t reserved[VND_CMD_APP_RESERVED_SIZE]; 65 } __packed; 66 67 struct app_start { 68 struct app_id app_info; 69 uint8_t app_start_flags; 70 uint8_t version; 71 uint8_t pad[2]; 72 uint8_t reserved[VND_CMD_APP_RESERVED_SIZE]; 73 } __packed; 74 75 struct app_stop { 76 struct app_id app_info; 77 uint8_t version; 78 uint8_t pad[VND_CMD_PAD_SIZE]; 79 uint8_t reserved[VND_CMD_APP_RESERVED_SIZE]; 80 } __packed; 81 82 struct app_plogi_reply { 83 uint32_t prli_status; 84 uint8_t version; 85 uint8_t pad[VND_CMD_PAD_SIZE]; 86 uint8_t reserved[VND_CMD_APP_RESERVED_SIZE]; 87 } __packed; 88 89 struct app_pinfo_req { 90 struct app_id app_info; 91 uint8_t num_ports; 92 port_id_t remote_pid; 93 uint8_t version; 94 uint8_t pad[VND_CMD_PAD_SIZE]; 95 uint8_t reserved[VND_CMD_APP_RESERVED_SIZE]; 96 } __packed; 97 98 struct app_pinfo { 99 port_id_t remote_pid; 100 uint8_t remote_wwpn[WWN_SIZE]; 101 uint8_t remote_type; 102 #define VND_CMD_RTYPE_UNKNOWN 0 103 #define VND_CMD_RTYPE_TARGET 1 104 #define VND_CMD_RTYPE_INITIATOR 2 105 uint8_t remote_state; 106 uint8_t auth_state; 107 uint8_t version; 108 uint8_t pad[VND_CMD_PAD_SIZE]; 109 uint8_t reserved[VND_CMD_APP_RESERVED_SIZE]; 110 } __packed; 111 112 /* AUTH States */ 113 #define VND_CMD_AUTH_STATE_UNDEF 0 114 #define VND_CMD_AUTH_STATE_SESSION_SHUTDOWN 1 115 #define VND_CMD_AUTH_STATE_NEEDED 2 116 #define VND_CMD_AUTH_STATE_ELS_RCVD 3 117 #define VND_CMD_AUTH_STATE_SAUPDATE_COMPL 4 118 119 struct app_pinfo_reply { 120 uint8_t port_count; 121 uint8_t version; 122 uint8_t pad[VND_CMD_PAD_SIZE]; 123 uint8_t reserved[VND_CMD_APP_RESERVED_SIZE]; 124 struct app_pinfo ports[]; 125 } __packed; 126 127 struct app_sinfo_req { 128 struct app_id app_info; 129 uint8_t num_ports; 130 uint8_t version; 131 uint8_t pad[VND_CMD_PAD_SIZE]; 132 uint8_t reserved[VND_CMD_APP_RESERVED_SIZE]; 133 } __packed; 134 135 struct app_sinfo { 136 uint8_t remote_wwpn[WWN_SIZE]; 137 int64_t rekey_count; 138 uint8_t rekey_mode; 139 int64_t tx_bytes; 140 int64_t rx_bytes; 141 } __packed; 142 143 struct app_stats_reply { 144 uint8_t elem_count; 145 uint8_t version; 146 uint8_t pad[VND_CMD_PAD_SIZE]; 147 uint8_t reserved[VND_CMD_APP_RESERVED_SIZE]; 148 struct app_sinfo elem[]; 149 } __packed; 150 151 struct qla_sa_update_frame { 152 struct app_id app_info; 153 uint16_t flags; 154 #define SAU_FLG_INV 0x01 /* delete key */ 155 #define SAU_FLG_TX 0x02 /* 1=tx, 0 = rx */ 156 #define SAU_FLG_FORCE_DELETE 0x08 157 #define SAU_FLG_GMAC_MODE 0x20 /* 158 * GMAC mode is cleartext for the IO 159 * (i.e. NULL encryption) 160 */ 161 #define SAU_FLG_KEY128 0x40 162 #define SAU_FLG_KEY256 0x80 163 uint16_t fast_sa_index:10, 164 reserved:6; 165 uint32_t salt; 166 uint32_t spi; 167 uint8_t sa_key[32]; 168 uint8_t node_name[WWN_SIZE]; 169 uint8_t port_name[WWN_SIZE]; 170 port_id_t port_id; 171 uint8_t version; 172 uint8_t pad[VND_CMD_PAD_SIZE]; 173 uint8_t reserved2[VND_CMD_APP_RESERVED_SIZE]; 174 } __packed; 175 176 #define QL_VND_SC_UNDEF 0 177 #define QL_VND_SC_SA_UPDATE 1 178 #define QL_VND_SC_APP_START 2 179 #define QL_VND_SC_APP_STOP 3 180 #define QL_VND_SC_AUTH_OK 4 181 #define QL_VND_SC_AUTH_FAIL 5 182 #define QL_VND_SC_REKEY_CONFIG 6 183 #define QL_VND_SC_GET_FCINFO 7 184 #define QL_VND_SC_GET_STATS 8 185 #define QL_VND_SC_AEN_COMPLETE 9 186 #define QL_VND_SC_READ_DBELL 10 187 188 /* 189 * bsg caller to provide empty buffer for doorbell events. 190 * 191 * sg_io_v4.din_xferp = empty buffer for door bell events 192 * sg_io_v4.dout_xferp = struct edif_read_dbell *buf 193 */ 194 struct edif_read_dbell { 195 struct app_id app_info; 196 uint8_t version; 197 uint8_t pad[VND_CMD_PAD_SIZE]; 198 uint8_t reserved[VND_CMD_APP_RESERVED_SIZE]; 199 }; 200 201 202 /* Application interface data structure for rtn data */ 203 #define EXT_DEF_EVENT_DATA_SIZE 64 204 struct edif_app_dbell { 205 uint32_t event_code; 206 uint32_t event_data_size; 207 union { 208 port_id_t port_id; 209 uint8_t event_data[EXT_DEF_EVENT_DATA_SIZE]; 210 }; 211 } __packed; 212 213 struct edif_sa_update_aen { 214 port_id_t port_id; 215 uint32_t key_type; /* Tx (1) or RX (2) */ 216 uint32_t status; /* 0 succes, 1 failed, 2 timeout , 3 error */ 217 uint8_t version; 218 uint8_t pad[VND_CMD_PAD_SIZE]; 219 uint8_t reserved[VND_CMD_APP_RESERVED_SIZE]; 220 } __packed; 221 222 #define QL_VND_SA_STAT_SUCCESS 0 223 #define QL_VND_SA_STAT_FAILED 1 224 #define QL_VND_SA_STAT_TIMEOUT 2 225 #define QL_VND_SA_STAT_ERROR 3 226 227 #define QL_VND_RX_SA_KEY 1 228 #define QL_VND_TX_SA_KEY 2 229 230 /* App defines for plogi auth'd ok and plogi auth bad requests */ 231 struct auth_complete_cmd { 232 struct app_id app_info; 233 #define PL_TYPE_WWPN 1 234 #define PL_TYPE_DID 2 235 uint32_t type; 236 union { 237 uint8_t wwpn[WWN_SIZE]; 238 port_id_t d_id; 239 } u; 240 uint8_t version; 241 uint8_t pad[VND_CMD_PAD_SIZE]; 242 uint8_t reserved[VND_CMD_APP_RESERVED_SIZE]; 243 } __packed; 244 245 struct aen_complete_cmd { 246 struct app_id app_info; 247 port_id_t port_id; 248 uint32_t event_code; 249 uint8_t version; 250 uint8_t pad[VND_CMD_PAD_SIZE]; 251 uint8_t reserved[VND_CMD_APP_RESERVED_SIZE]; 252 } __packed; 253 254 #define RX_DELAY_DELETE_TIMEOUT 20 255 256 #define FCH_EVT_VENDOR_UNIQUE_VPORT_DOWN 1 257 258 #endif /* QLA_EDIF_BSG_H */ 259