xref: /linux/drivers/scsi/qla2xxx/qla_edif_bsg.h (revision a4eb44a6435d6d8f9e642407a4a06f65eb90ca04)
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 /* BSG Vendor specific commands */
11 #define	ELS_MAX_PAYLOAD		2112
12 #ifndef	WWN_SIZE
13 #define WWN_SIZE		8
14 #endif
15 #define	VND_CMD_APP_RESERVED_SIZE	32
16 
17 enum auth_els_sub_cmd {
18 	SEND_ELS = 0,
19 	SEND_ELS_REPLY,
20 	PULL_ELS,
21 };
22 
23 struct extra_auth_els {
24 	enum auth_els_sub_cmd sub_cmd;
25 	uint32_t        extra_rx_xchg_address;
26 	uint8_t         extra_control_flags;
27 #define BSG_CTL_FLAG_INIT       0
28 #define BSG_CTL_FLAG_LS_ACC     1
29 #define BSG_CTL_FLAG_LS_RJT     2
30 #define BSG_CTL_FLAG_TRM        3
31 	uint8_t         extra_rsvd[3];
32 } __packed;
33 
34 struct qla_bsg_auth_els_request {
35 	struct fc_bsg_request r;
36 	struct extra_auth_els e;
37 };
38 
39 struct qla_bsg_auth_els_reply {
40 	struct fc_bsg_reply r;
41 	uint32_t rx_xchg_address;
42 };
43 
44 struct app_id {
45 	int		app_vid;
46 	uint8_t		app_key[32];
47 } __packed;
48 
49 struct app_start_reply {
50 	uint32_t	host_support_edif;
51 	uint32_t	edif_enode_active;
52 	uint32_t	edif_edb_active;
53 	uint32_t	reserved[VND_CMD_APP_RESERVED_SIZE];
54 } __packed;
55 
56 struct app_start {
57 	struct app_id	app_info;
58 	uint32_t	prli_to;
59 	uint32_t	key_shred;
60 	uint8_t         app_start_flags;
61 	uint8_t         reserved[VND_CMD_APP_RESERVED_SIZE - 1];
62 } __packed;
63 
64 struct app_stop {
65 	struct app_id	app_info;
66 	char		buf[16];
67 } __packed;
68 
69 struct app_plogi_reply {
70 	uint32_t	prli_status;
71 	uint8_t		reserved[VND_CMD_APP_RESERVED_SIZE];
72 } __packed;
73 
74 #define	RECFG_TIME	1
75 #define	RECFG_BYTES	2
76 
77 struct app_rekey_cfg {
78 	struct app_id app_info;
79 	uint8_t	 rekey_mode;
80 	port_id_t d_id;
81 	uint8_t	 force;
82 	union {
83 		int64_t bytes;
84 		int64_t time;
85 	} rky_units;
86 
87 	uint8_t		reserved[VND_CMD_APP_RESERVED_SIZE];
88 } __packed;
89 
90 struct app_pinfo_req {
91 	struct app_id app_info;
92 	uint8_t	 num_ports;
93 	port_id_t remote_pid;
94 	uint8_t	 reserved[VND_CMD_APP_RESERVED_SIZE];
95 } __packed;
96 
97 struct app_pinfo {
98 	port_id_t remote_pid;
99 	uint8_t	remote_wwpn[WWN_SIZE];
100 	uint8_t	remote_type;
101 #define	VND_CMD_RTYPE_UNKNOWN		0
102 #define	VND_CMD_RTYPE_TARGET		1
103 #define	VND_CMD_RTYPE_INITIATOR		2
104 	uint8_t	remote_state;
105 	uint8_t	auth_state;
106 	uint8_t	rekey_mode;
107 	int64_t	rekey_count;
108 	int64_t	rekey_config_value;
109 	int64_t	rekey_consumed_value;
110 
111 	uint8_t	reserved[VND_CMD_APP_RESERVED_SIZE];
112 } __packed;
113 
114 /* AUTH States */
115 #define	VND_CMD_AUTH_STATE_UNDEF	0
116 #define	VND_CMD_AUTH_STATE_SESSION_SHUTDOWN	1
117 #define	VND_CMD_AUTH_STATE_NEEDED	2
118 #define	VND_CMD_AUTH_STATE_ELS_RCVD	3
119 #define	VND_CMD_AUTH_STATE_SAUPDATE_COMPL 4
120 
121 struct app_pinfo_reply {
122 	uint8_t		port_count;
123 	uint8_t		reserved[VND_CMD_APP_RESERVED_SIZE];
124 	struct app_pinfo ports[0];
125 } __packed;
126 
127 struct app_sinfo_req {
128 	struct app_id	app_info;
129 	uint8_t		num_ports;
130 	uint8_t		reserved[VND_CMD_APP_RESERVED_SIZE];
131 } __packed;
132 
133 struct app_sinfo {
134 	uint8_t	remote_wwpn[WWN_SIZE];
135 	int64_t	rekey_count;
136 	uint8_t	rekey_mode;
137 	int64_t	tx_bytes;
138 	int64_t	rx_bytes;
139 } __packed;
140 
141 struct app_stats_reply {
142 	uint8_t		elem_count;
143 	struct app_sinfo elem[0];
144 } __packed;
145 
146 struct qla_sa_update_frame {
147 	struct app_id	app_info;
148 	uint16_t	flags;
149 #define SAU_FLG_INV		0x01	/* delete key */
150 #define SAU_FLG_TX		0x02	/* 1=tx, 0 = rx */
151 #define SAU_FLG_FORCE_DELETE	0x08
152 #define SAU_FLG_GMAC_MODE	0x20	/*
153 					 * GMAC mode is cleartext for the IO
154 					 * (i.e. NULL encryption)
155 					 */
156 #define SAU_FLG_KEY128          0x40
157 #define SAU_FLG_KEY256          0x80
158 	uint16_t        fast_sa_index:10,
159 			reserved:6;
160 	uint32_t	salt;
161 	uint32_t	spi;
162 	uint8_t		sa_key[32];
163 	uint8_t		node_name[WWN_SIZE];
164 	uint8_t		port_name[WWN_SIZE];
165 	port_id_t	port_id;
166 } __packed;
167 
168 // used for edif mgmt bsg interface
169 #define	QL_VND_SC_UNDEF		0
170 #define	QL_VND_SC_SA_UPDATE	1
171 #define	QL_VND_SC_APP_START	2
172 #define	QL_VND_SC_APP_STOP	3
173 #define	QL_VND_SC_AUTH_OK	4
174 #define	QL_VND_SC_AUTH_FAIL	5
175 #define	QL_VND_SC_REKEY_CONFIG	6
176 #define	QL_VND_SC_GET_FCINFO	7
177 #define	QL_VND_SC_GET_STATS	8
178 
179 /* Application interface data structure for rtn data */
180 #define	EXT_DEF_EVENT_DATA_SIZE	64
181 struct edif_app_dbell {
182 	uint32_t	event_code;
183 	uint32_t	event_data_size;
184 	union  {
185 		port_id_t	port_id;
186 		uint8_t		event_data[EXT_DEF_EVENT_DATA_SIZE];
187 	};
188 } __packed;
189 
190 struct edif_sa_update_aen {
191 	port_id_t port_id;
192 	uint32_t key_type;	/* Tx (1) or RX (2) */
193 	uint32_t status;	/* 0 succes,  1 failed, 2 timeout , 3 error */
194 	uint8_t		reserved[16];
195 } __packed;
196 
197 #define	QL_VND_SA_STAT_SUCCESS	0
198 #define	QL_VND_SA_STAT_FAILED	1
199 #define	QL_VND_SA_STAT_TIMEOUT	2
200 #define	QL_VND_SA_STAT_ERROR	3
201 
202 #define	QL_VND_RX_SA_KEY	1
203 #define	QL_VND_TX_SA_KEY	2
204 
205 /* App defines for plogi auth'd ok and plogi auth bad requests */
206 struct auth_complete_cmd {
207 	struct app_id app_info;
208 #define PL_TYPE_WWPN    1
209 #define PL_TYPE_DID     2
210 	uint32_t    type;
211 	union {
212 		uint8_t  wwpn[WWN_SIZE];
213 		port_id_t d_id;
214 	} u;
215 	uint32_t reserved[VND_CMD_APP_RESERVED_SIZE];
216 } __packed;
217 
218 #define RX_DELAY_DELETE_TIMEOUT 20
219 
220 #endif	/* QLA_EDIF_BSG_H */
221