xref: /linux/drivers/scsi/qla2xxx/qla_edif_bsg.h (revision 2f5fab1b)
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 	struct {
93 #ifdef __BIG_ENDIAN
94 		uint8_t domain;
95 		uint8_t area;
96 		uint8_t al_pa;
97 #elif defined(__LITTLE_ENDIAN)
98 		uint8_t al_pa;
99 		uint8_t area;
100 		uint8_t domain;
101 #else
102 #error "__BIG_ENDIAN or __LITTLE_ENDIAN must be defined!"
103 #endif
104 		uint8_t rsvd_1;
105 	} remote_pid;
106 	uint8_t		version;
107 	uint8_t		pad[VND_CMD_PAD_SIZE];
108 	uint8_t		reserved[VND_CMD_APP_RESERVED_SIZE];
109 } __packed;
110 
111 struct app_pinfo {
112 	port_id_t remote_pid;
113 	uint8_t	remote_wwpn[WWN_SIZE];
114 	uint8_t	remote_type;
115 #define	VND_CMD_RTYPE_UNKNOWN		0
116 #define	VND_CMD_RTYPE_TARGET		1
117 #define	VND_CMD_RTYPE_INITIATOR		2
118 	uint8_t	remote_state;
119 	uint8_t	auth_state;
120 	uint8_t	version;
121 	uint8_t	pad[VND_CMD_PAD_SIZE];
122 	uint8_t	reserved[VND_CMD_APP_RESERVED_SIZE];
123 } __packed;
124 
125 /* AUTH States */
126 #define	VND_CMD_AUTH_STATE_UNDEF	0
127 #define	VND_CMD_AUTH_STATE_SESSION_SHUTDOWN	1
128 #define	VND_CMD_AUTH_STATE_NEEDED	2
129 #define	VND_CMD_AUTH_STATE_ELS_RCVD	3
130 #define	VND_CMD_AUTH_STATE_SAUPDATE_COMPL 4
131 
132 struct app_pinfo_reply {
133 	uint8_t		port_count;
134 	uint8_t		version;
135 	uint8_t		pad[VND_CMD_PAD_SIZE];
136 	uint8_t		reserved[VND_CMD_APP_RESERVED_SIZE];
137 	struct app_pinfo ports[];
138 } __packed;
139 
140 struct app_sinfo_req {
141 	struct app_id	app_info;
142 	uint8_t		num_ports;
143 	uint8_t		version;
144 	uint8_t		pad[VND_CMD_PAD_SIZE];
145 	uint8_t		reserved[VND_CMD_APP_RESERVED_SIZE];
146 } __packed;
147 
148 struct app_sinfo {
149 	uint8_t	remote_wwpn[WWN_SIZE];
150 	int64_t	rekey_count;
151 	uint8_t	rekey_mode;
152 	int64_t	tx_bytes;
153 	int64_t	rx_bytes;
154 } __packed;
155 
156 struct app_stats_reply {
157 	uint8_t		elem_count;
158 	uint8_t		version;
159 	uint8_t		pad[VND_CMD_PAD_SIZE];
160 	uint8_t		reserved[VND_CMD_APP_RESERVED_SIZE];
161 	struct app_sinfo elem[];
162 } __packed;
163 
164 struct qla_sa_update_frame {
165 	struct app_id	app_info;
166 	uint16_t	flags;
167 #define SAU_FLG_INV		0x01	/* delete key */
168 #define SAU_FLG_TX		0x02	/* 1=tx, 0 = rx */
169 #define SAU_FLG_FORCE_DELETE	0x08
170 #define SAU_FLG_GMAC_MODE	0x20	/*
171 					 * GMAC mode is cleartext for the IO
172 					 * (i.e. NULL encryption)
173 					 */
174 #define SAU_FLG_KEY128          0x40
175 #define SAU_FLG_KEY256          0x80
176 	uint16_t        fast_sa_index:10,
177 			reserved:6;
178 	uint32_t	salt;
179 	uint32_t	spi;
180 	uint8_t		sa_key[32];
181 	uint8_t		node_name[WWN_SIZE];
182 	uint8_t		port_name[WWN_SIZE];
183 	port_id_t	port_id;
184 	uint8_t		version;
185 	uint8_t		pad[VND_CMD_PAD_SIZE];
186 	uint8_t		reserved2[VND_CMD_APP_RESERVED_SIZE];
187 } __packed;
188 
189 #define	QL_VND_SC_UNDEF		0
190 #define	QL_VND_SC_SA_UPDATE	1
191 #define	QL_VND_SC_APP_START	2
192 #define	QL_VND_SC_APP_STOP	3
193 #define	QL_VND_SC_AUTH_OK	4
194 #define	QL_VND_SC_AUTH_FAIL	5
195 #define	QL_VND_SC_REKEY_CONFIG	6
196 #define	QL_VND_SC_GET_FCINFO	7
197 #define	QL_VND_SC_GET_STATS	8
198 #define QL_VND_SC_AEN_COMPLETE  9
199 #define QL_VND_SC_READ_DBELL	10
200 
201 /*
202  * bsg caller to provide empty buffer for doorbell events.
203  *
204  * sg_io_v4.din_xferp  = empty buffer for door bell events
205  * sg_io_v4.dout_xferp = struct edif_read_dbell *buf
206  */
207 struct edif_read_dbell {
208 	struct app_id app_info;
209 	uint8_t version;
210 	uint8_t pad[VND_CMD_PAD_SIZE];
211 	uint8_t reserved[VND_CMD_APP_RESERVED_SIZE];
212 };
213 
214 
215 /* Application interface data structure for rtn data */
216 #define	EXT_DEF_EVENT_DATA_SIZE	64
217 struct edif_app_dbell {
218 	uint32_t	event_code;
219 	uint32_t	event_data_size;
220 	union  {
221 		port_id_t	port_id;
222 		uint8_t		event_data[EXT_DEF_EVENT_DATA_SIZE];
223 	};
224 } __packed;
225 
226 struct edif_sa_update_aen {
227 	port_id_t port_id;
228 	uint32_t key_type;	/* Tx (1) or RX (2) */
229 	uint32_t status;	/* 0 succes,  1 failed, 2 timeout , 3 error */
230 	uint8_t	version;
231 	uint8_t	pad[VND_CMD_PAD_SIZE];
232 	uint8_t	reserved[VND_CMD_APP_RESERVED_SIZE];
233 } __packed;
234 
235 #define	QL_VND_SA_STAT_SUCCESS	0
236 #define	QL_VND_SA_STAT_FAILED	1
237 #define	QL_VND_SA_STAT_TIMEOUT	2
238 #define	QL_VND_SA_STAT_ERROR	3
239 
240 #define	QL_VND_RX_SA_KEY	1
241 #define	QL_VND_TX_SA_KEY	2
242 
243 /* App defines for plogi auth'd ok and plogi auth bad requests */
244 struct auth_complete_cmd {
245 	struct app_id app_info;
246 #define PL_TYPE_WWPN    1
247 #define PL_TYPE_DID     2
248 	uint32_t    type;
249 	union {
250 		uint8_t  wwpn[WWN_SIZE];
251 		port_id_t d_id;
252 	} u;
253 	uint8_t	version;
254 	uint8_t	pad[VND_CMD_PAD_SIZE];
255 	uint8_t	reserved[VND_CMD_APP_RESERVED_SIZE];
256 } __packed;
257 
258 struct aen_complete_cmd {
259 	struct app_id app_info;
260 	port_id_t   port_id;
261 	uint32_t    event_code;
262 	uint8_t     version;
263 	uint8_t     pad[VND_CMD_PAD_SIZE];
264 	uint8_t     reserved[VND_CMD_APP_RESERVED_SIZE];
265 } __packed;
266 
267 #define RX_DELAY_DELETE_TIMEOUT 20
268 
269 #define FCH_EVT_VENDOR_UNIQUE_VPORT_DOWN  1
270 
271 #endif	/* QLA_EDIF_BSG_H */
272