xref: /openbmc/linux/drivers/scsi/be2iscsi/be_cmds.h (revision 711aab1d)
1 /*
2  * Copyright 2017 Broadcom. All Rights Reserved.
3  * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License version 2
7  * as published by the Free Software Foundation. The full GNU General
8  * Public License is included in this distribution in the file called COPYING.
9  *
10  * Contact Information:
11  * linux-drivers@broadcom.com
12  *
13  */
14 
15 #ifndef BEISCSI_CMDS_H
16 #define BEISCSI_CMDS_H
17 
18 /**
19  * The driver sends configuration and managements command requests to the
20  * firmware in the BE. These requests are communicated to the processor
21  * using Work Request Blocks (WRBs) submitted to the MCC-WRB ring or via one
22  * WRB inside a MAILBOX.
23  * The commands are serviced by the ARM processor in the OneConnect's MPU.
24  */
25 struct be_sge {
26 	__le32 pa_lo;
27 	__le32 pa_hi;
28 	__le32 len;
29 };
30 
31 struct be_mcc_wrb {
32 	u32 emb_sgecnt_special;	/* dword 0 */
33 	/* bits 0 - embedded    */
34 	/* bits 1 - 2 reserved	*/
35 	/* bits 3 - 7 sge count	*/
36 	/* bits 8 - 23 reserved	*/
37 	/* bits 24 - 31 special	*/
38 #define MCC_WRB_EMBEDDED_MASK 1
39 #define MCC_WRB_SGE_CNT_SHIFT 3
40 #define MCC_WRB_SGE_CNT_MASK 0x1F
41 	u32 payload_length;	/* dword 1 */
42 	u32 tag0;		/* dword 2 */
43 	u32 tag1;		/* dword 3 */
44 	u32 rsvd;		/* dword 4 */
45 	union {
46 #define EMBED_MBX_MAX_PAYLOAD_SIZE  220
47 		u8 embedded_payload[236];	/* used by embedded cmds */
48 		struct be_sge sgl[19];	/* used by non-embedded cmds */
49 	} payload;
50 };
51 
52 #define CQE_FLAGS_VALID_MASK (1 << 31)
53 #define CQE_FLAGS_ASYNC_MASK (1 << 30)
54 #define CQE_FLAGS_COMPLETED_MASK	(1 << 28)
55 #define CQE_FLAGS_CONSUMED_MASK		(1 << 27)
56 
57 /* Completion Status */
58 #define MCC_STATUS_SUCCESS 0x0
59 #define MCC_STATUS_FAILED 0x1
60 #define MCC_STATUS_ILLEGAL_REQUEST 0x2
61 #define MCC_STATUS_ILLEGAL_FIELD 0x3
62 #define MCC_STATUS_INSUFFICIENT_BUFFER 0x4
63 #define MCC_STATUS_INVALID_LENGTH 0x74
64 
65 #define CQE_STATUS_COMPL_MASK	0xFFFF
66 #define CQE_STATUS_COMPL_SHIFT	0		/* bits 0 - 15 */
67 #define CQE_STATUS_EXTD_MASK	0xFFFF
68 #define CQE_STATUS_EXTD_SHIFT	16		/* bits 31 - 16 */
69 #define CQE_STATUS_ADDL_MASK	0xFF00
70 #define CQE_STATUS_ADDL_SHIFT	8
71 #define CQE_STATUS_MASK		0xFF
72 #define CQE_STATUS_WRB_MASK	0xFF0000
73 #define CQE_STATUS_WRB_SHIFT	16
74 
75 #define BEISCSI_HOST_MBX_TIMEOUT (110 * 1000)
76 #define BEISCSI_FW_MBX_TIMEOUT	100
77 
78 /* MBOX Command VER */
79 #define MBX_CMD_VER1	0x01
80 #define MBX_CMD_VER2	0x02
81 
82 struct be_mcc_compl {
83 	u32 status;		/* dword 0 */
84 	u32 tag0;		/* dword 1 */
85 	u32 tag1;		/* dword 2 */
86 	u32 flags;		/* dword 3 */
87 };
88 
89 /********* Mailbox door bell *************/
90 /**
91  * Used for driver communication with the FW.
92  * The software must write this register twice to post any command. First,
93  * it writes the register with hi=1 and the upper bits of the physical address
94  * for the MAILBOX structure. Software must poll the ready bit until this
95  * is acknowledged. Then, sotware writes the register with hi=0 with the lower
96  * bits in the address. It must poll the ready bit until the command is
97  * complete. Upon completion, the MAILBOX will contain a valid completion
98  * queue entry.
99  */
100 #define MPU_MAILBOX_DB_OFFSET	0x160
101 #define MPU_MAILBOX_DB_RDY_MASK	0x1	/* bit 0 */
102 #define MPU_MAILBOX_DB_HI_MASK	0x2	/* bit 1 */
103 
104 /********** MPU semphore: used for SH & BE ******************/
105 #define SLIPORT_SOFTRESET_OFFSET		0x5c	/* CSR BAR offset */
106 #define SLIPORT_SEMAPHORE_OFFSET_BEx		0xac	/* CSR BAR offset */
107 #define SLIPORT_SEMAPHORE_OFFSET_SH		0x94	/* PCI-CFG offset */
108 #define POST_STAGE_MASK				0x0000FFFF
109 #define POST_ERROR_BIT				0x80000000
110 #define POST_ERR_RECOVERY_CODE_MASK		0xF000
111 
112 /* Soft Reset register masks */
113 #define SLIPORT_SOFTRESET_SR_MASK		0x00000080	/* SR bit */
114 
115 /* MPU semphore POST stage values */
116 #define POST_STAGE_AWAITING_HOST_RDY	0x1 /* FW awaiting goahead from host */
117 #define POST_STAGE_HOST_RDY		0x2 /* Host has given go-ahed to FW */
118 #define POST_STAGE_BE_RESET		0x3 /* Host wants to reset chip */
119 #define POST_STAGE_ARMFW_RDY		0xC000 /* FW is done with POST */
120 #define POST_STAGE_RECOVERABLE_ERR	0xE000 /* Recoverable err detected */
121 
122 /********** MCC door bell ************/
123 #define DB_MCCQ_OFFSET 0x140
124 #define DB_MCCQ_RING_ID_MASK 0xFFFF		/* bits 0 - 15 */
125 /* Number of entries posted */
126 #define DB_MCCQ_NUM_POSTED_SHIFT 16		/* bits 16 - 29 */
127 
128 /**
129  * When the async bit of mcc_compl is set, the last 4 bytes of
130  * mcc_compl is interpreted as follows:
131  */
132 #define ASYNC_TRAILER_EVENT_CODE_SHIFT	8	/* bits 8 - 15 */
133 #define ASYNC_TRAILER_EVENT_CODE_MASK	0xFF
134 #define ASYNC_EVENT_CODE_LINK_STATE	0x1
135 #define ASYNC_EVENT_CODE_ISCSI		0x4
136 #define ASYNC_EVENT_CODE_SLI		0x11
137 
138 #define ASYNC_TRAILER_EVENT_TYPE_SHIFT	16	/* bits 16 - 23 */
139 #define ASYNC_TRAILER_EVENT_TYPE_MASK	0xFF
140 
141 /* iSCSI events */
142 #define ASYNC_EVENT_NEW_ISCSI_TGT_DISC	0x4
143 #define ASYNC_EVENT_NEW_ISCSI_CONN	0x5
144 #define ASYNC_EVENT_NEW_TCP_CONN	0x7
145 
146 /* SLI events */
147 #define ASYNC_SLI_EVENT_TYPE_MISCONFIGURED	0x9
148 #define ASYNC_SLI_LINK_EFFECT_VALID(le)		(le & 0x80)
149 #define ASYNC_SLI_LINK_EFFECT_SEV(le)		((le >> 1)  & 0x03)
150 #define ASYNC_SLI_LINK_EFFECT_STATE(le)		(le & 0x01)
151 
152 struct be_async_event_trailer {
153 	u32 code;
154 };
155 
156 enum {
157 	ASYNC_EVENT_LINK_DOWN = 0x0,
158 	ASYNC_EVENT_LINK_UP = 0x1,
159 };
160 
161 /**
162  * When the event code of an async trailer is link-state, the mcc_compl
163  * must be interpreted as follows
164  */
165 struct be_async_event_link_state {
166 	u8 physical_port;
167 	u8 port_link_status;
168 /**
169  * ASYNC_EVENT_LINK_DOWN		0x0
170  * ASYNC_EVENT_LINK_UP			0x1
171  * ASYNC_EVENT_LINK_LOGICAL_DOWN	0x2
172  * ASYNC_EVENT_LINK_LOGICAL_UP		0x3
173  */
174 #define BE_ASYNC_LINK_UP_MASK		0x01
175 	u8 port_duplex;
176 	u8 port_speed;
177 /* BE2ISCSI_LINK_SPEED_ZERO	0x00 - no link */
178 #define BE2ISCSI_LINK_SPEED_10MBPS	0x01
179 #define BE2ISCSI_LINK_SPEED_100MBPS	0x02
180 #define BE2ISCSI_LINK_SPEED_1GBPS	0x03
181 #define BE2ISCSI_LINK_SPEED_10GBPS	0x04
182 #define BE2ISCSI_LINK_SPEED_25GBPS	0x06
183 #define BE2ISCSI_LINK_SPEED_40GBPS	0x07
184 	u8 port_fault;
185 	u8 event_reason;
186 	u16 qos_link_speed;
187 	u32 event_tag;
188 	struct be_async_event_trailer trailer;
189 } __packed;
190 
191 /**
192  * When async-trailer is SLI event, mcc_compl is interpreted as
193  */
194 struct be_async_event_sli {
195 	u32 event_data1;
196 	u32 event_data2;
197 	u32 reserved;
198 	u32 trailer;
199 } __packed;
200 
201 struct be_mcc_mailbox {
202 	struct be_mcc_wrb wrb;
203 	struct be_mcc_compl compl;
204 };
205 
206 /* Type of subsystems supported by FW */
207 #define CMD_SUBSYSTEM_COMMON    0x1
208 #define CMD_SUBSYSTEM_ISCSI     0x2
209 #define CMD_SUBSYSTEM_ETH       0x3
210 #define CMD_SUBSYSTEM_ISCSI_INI 0x6
211 #define CMD_COMMON_TCP_UPLOAD   0x1
212 
213 /**
214  * List of common opcodes subsystem  CMD_SUBSYSTEM_COMMON
215  * These opcodes are unique for each subsystem defined above
216  */
217 #define OPCODE_COMMON_CQ_CREATE				12
218 #define OPCODE_COMMON_EQ_CREATE				13
219 #define OPCODE_COMMON_MCC_CREATE			21
220 #define OPCODE_COMMON_MCC_CREATE_EXT			90
221 #define OPCODE_COMMON_ADD_TEMPLATE_HEADER_BUFFERS	24
222 #define OPCODE_COMMON_REMOVE_TEMPLATE_HEADER_BUFFERS	25
223 #define OPCODE_COMMON_GET_CNTL_ATTRIBUTES		32
224 #define OPCODE_COMMON_GET_FW_VERSION			35
225 #define OPCODE_COMMON_MODIFY_EQ_DELAY			41
226 #define OPCODE_COMMON_FIRMWARE_CONFIG			42
227 #define OPCODE_COMMON_MCC_DESTROY			53
228 #define OPCODE_COMMON_CQ_DESTROY			54
229 #define OPCODE_COMMON_EQ_DESTROY			55
230 #define OPCODE_COMMON_QUERY_FIRMWARE_CONFIG		58
231 #define OPCODE_COMMON_FUNCTION_RESET			61
232 #define OPCODE_COMMON_GET_PORT_NAME			77
233 #define OPCODE_COMMON_SET_FEATURES			191
234 
235 /**
236  * LIST of opcodes that are common between Initiator and Target
237  * used by CMD_SUBSYSTEM_ISCSI
238  * These opcodes are unique for each subsystem defined above
239  */
240 #define OPCODE_COMMON_ISCSI_CFG_POST_SGL_PAGES		2
241 #define OPCODE_COMMON_ISCSI_CFG_REMOVE_SGL_PAGES        3
242 #define OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG		7
243 #define OPCODE_COMMON_ISCSI_NTWK_SET_VLAN		14
244 #define OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR	17
245 #define OPCODE_COMMON_ISCSI_NTWK_REL_STATELESS_IP_ADDR	18
246 #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR		21
247 #define OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY	22
248 #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY 23
249 #define OPCODE_COMMON_ISCSI_NTWK_GET_ALL_IF_ID		24
250 #define OPCODE_COMMON_ISCSI_NTWK_GET_IF_INFO		25
251 #define OPCODE_COMMON_ISCSI_SET_FRAGNUM_BITS_FOR_SGL_CRA 61
252 #define OPCODE_COMMON_ISCSI_DEFQ_CREATE                 64
253 #define OPCODE_COMMON_ISCSI_DEFQ_DESTROY		65
254 #define OPCODE_COMMON_ISCSI_WRBQ_CREATE			66
255 #define OPCODE_COMMON_ISCSI_WRBQ_DESTROY		67
256 
257 struct be_cmd_req_hdr {
258 	u8 opcode;		/* dword 0 */
259 	u8 subsystem;		/* dword 0 */
260 	u8 port_number;		/* dword 0 */
261 	u8 domain;		/* dword 0 */
262 	u32 timeout;		/* dword 1 */
263 	u32 request_length;	/* dword 2 */
264 	u8 version;		/* dword 3 */
265 	u8 rsvd0[3];		/* dword 3 */
266 };
267 
268 struct be_cmd_resp_hdr {
269 	u32 info;		/* dword 0 */
270 	u32 status;		/* dword 1 */
271 	u32 response_length;	/* dword 2 */
272 	u32 actual_resp_len;	/* dword 3 */
273 };
274 
275 struct phys_addr {
276 	u32 lo;
277 	u32 hi;
278 };
279 
280 struct virt_addr {
281 	u32 lo;
282 	u32 hi;
283 };
284 /**************************
285  * BE Command definitions *
286  **************************/
287 
288 /**
289  * Pseudo amap definition in which each bit of the actual structure is defined
290  * as a byte - used to calculate offset/shift/mask of each field
291  */
292 struct amap_eq_context {
293 	u8 cidx[13];		/* dword 0 */
294 	u8 rsvd0[3];		/* dword 0 */
295 	u8 epidx[13];		/* dword 0 */
296 	u8 valid;		/* dword 0 */
297 	u8 rsvd1;		/* dword 0 */
298 	u8 size;		/* dword 0 */
299 	u8 pidx[13];		/* dword 1 */
300 	u8 rsvd2[3];		/* dword 1 */
301 	u8 pd[10];		/* dword 1 */
302 	u8 count[3];		/* dword 1 */
303 	u8 solevent;		/* dword 1 */
304 	u8 stalled;		/* dword 1 */
305 	u8 armed;		/* dword 1 */
306 	u8 rsvd3[4];		/* dword 2 */
307 	u8 func[8];		/* dword 2 */
308 	u8 rsvd4;		/* dword 2 */
309 	u8 delaymult[10];	/* dword 2 */
310 	u8 rsvd5[2];		/* dword 2 */
311 	u8 phase[2];		/* dword 2 */
312 	u8 nodelay;		/* dword 2 */
313 	u8 rsvd6[4];		/* dword 2 */
314 	u8 rsvd7[32];		/* dword 3 */
315 } __packed;
316 
317 struct be_cmd_req_eq_create {
318 	struct be_cmd_req_hdr hdr;	/* dw[4] */
319 	u16 num_pages;		/* sword */
320 	u16 rsvd0;		/* sword */
321 	u8 context[sizeof(struct amap_eq_context) / 8];	/* dw[4] */
322 	struct phys_addr pages[8];
323 } __packed;
324 
325 struct be_cmd_resp_eq_create {
326 	struct be_cmd_resp_hdr resp_hdr;
327 	u16 eq_id;		/* sword */
328 	u16 rsvd0;		/* sword */
329 } __packed;
330 
331 struct be_set_eqd {
332 	u32 eq_id;
333 	u32 phase;
334 	u32 delay_multiplier;
335 } __packed;
336 
337 struct mgmt_chap_format {
338 	u32 flags;
339 	u8  intr_chap_name[256];
340 	u8  intr_secret[16];
341 	u8  target_chap_name[256];
342 	u8  target_secret[16];
343 	u16 intr_chap_name_length;
344 	u16 intr_secret_length;
345 	u16 target_chap_name_length;
346 	u16 target_secret_length;
347 } __packed;
348 
349 struct mgmt_auth_method_format {
350 	u8	auth_method_type;
351 	u8	padding[3];
352 	struct	mgmt_chap_format chap;
353 } __packed;
354 
355 struct be_cmd_req_logout_fw_sess {
356 	struct be_cmd_req_hdr hdr;	/* dw[4] */
357 	uint32_t session_handle;
358 } __packed;
359 
360 struct be_cmd_resp_logout_fw_sess {
361 	struct be_cmd_resp_hdr hdr;	/* dw[4] */
362 	uint32_t session_status;
363 #define BE_SESS_STATUS_CLOSE		0x20
364 } __packed;
365 
366 struct mgmt_conn_login_options {
367 	u8 flags;
368 	u8 header_digest;
369 	u8 data_digest;
370 	u8 rsvd0;
371 	u32 max_recv_datasegment_len_ini;
372 	u32 max_recv_datasegment_len_tgt;
373 	u32 tcp_mss;
374 	u32 tcp_window_size;
375 	struct	mgmt_auth_method_format auth_data;
376 } __packed;
377 
378 struct ip_addr_format {
379 	u16 size_of_structure;
380 	u8 reserved;
381 	u8 ip_type;
382 #define BEISCSI_IP_TYPE_V4		0x1
383 #define BEISCSI_IP_TYPE_STATIC_V4	0x3
384 #define BEISCSI_IP_TYPE_DHCP_V4		0x5
385 /* type v4 values < type v6 values */
386 #define BEISCSI_IP_TYPE_V6		0x10
387 #define BEISCSI_IP_TYPE_ROUTABLE_V6	0x30
388 #define BEISCSI_IP_TYPE_LINK_LOCAL_V6	0x50
389 #define BEISCSI_IP_TYPE_AUTO_V6		0x90
390 	u8 addr[16];
391 	u32 rsvd0;
392 } __packed;
393 
394 struct mgmt_conn_info {
395 	u32	connection_handle;
396 	u32	connection_status;
397 	u16	src_port;
398 	u16	dest_port;
399 	u16	dest_port_redirected;
400 	u16	cid;
401 	u32	estimated_throughput;
402 	struct	ip_addr_format	src_ipaddr;
403 	struct	ip_addr_format	dest_ipaddr;
404 	struct	ip_addr_format	dest_ipaddr_redirected;
405 	struct	mgmt_conn_login_options	negotiated_login_options;
406 } __packed;
407 
408 struct mgmt_session_login_options {
409 	u8	flags;
410 	u8	error_recovery_level;
411 	u16	rsvd0;
412 	u32	first_burst_length;
413 	u32	max_burst_length;
414 	u16	max_connections;
415 	u16	max_outstanding_r2t;
416 	u16	default_time2wait;
417 	u16	default_time2retain;
418 } __packed;
419 
420 struct mgmt_session_info {
421 	u32	session_handle;
422 	u32	status;
423 	u8	isid[6];
424 	u16	tsih;
425 	u32	session_flags;
426 	u16	conn_count;
427 	u16	pad;
428 	u8	target_name[224];
429 	u8	initiator_iscsiname[224];
430 	struct	mgmt_session_login_options negotiated_login_options;
431 	struct	mgmt_conn_info	conn_list[1];
432 } __packed;
433 
434 struct be_cmd_get_session_req {
435 	struct be_cmd_req_hdr hdr;
436 	u32 session_handle;
437 } __packed;
438 
439 struct be_cmd_get_session_resp {
440 	struct be_cmd_resp_hdr hdr;
441 	struct mgmt_session_info session_info;
442 } __packed;
443 
444 struct mac_addr {
445 	u16 size_of_structure;
446 	u8 addr[ETH_ALEN];
447 } __packed;
448 
449 struct be_cmd_get_boot_target_req {
450 	struct be_cmd_req_hdr hdr;
451 } __packed;
452 
453 struct be_cmd_get_boot_target_resp {
454 	struct be_cmd_resp_hdr hdr;
455 	u32 boot_session_count;
456 	u32 boot_session_handle;
457 /**
458  * FW returns 0xffffffff if it couldn't establish connection with
459  * configured boot target.
460  */
461 #define BE_BOOT_INVALID_SHANDLE	0xffffffff
462 };
463 
464 struct be_cmd_reopen_session_req {
465 	struct be_cmd_req_hdr hdr;
466 #define BE_REOPEN_ALL_SESSIONS  0x00
467 #define BE_REOPEN_BOOT_SESSIONS 0x01
468 #define BE_REOPEN_A_SESSION     0x02
469 	u16 reopen_type;
470 	u16 rsvd;
471 	u32 session_handle;
472 } __packed;
473 
474 struct be_cmd_reopen_session_resp {
475 	struct be_cmd_resp_hdr hdr;
476 	u32 rsvd;
477 	u32 session_handle;
478 } __packed;
479 
480 
481 struct be_cmd_mac_query_req {
482 	struct be_cmd_req_hdr hdr;
483 	u8 type;
484 	u8 permanent;
485 	u16 if_id;
486 } __packed;
487 
488 struct be_cmd_get_mac_resp {
489 	struct be_cmd_resp_hdr hdr;
490 	struct mac_addr mac;
491 };
492 
493 struct be_ip_addr_subnet_format {
494 	u16 size_of_structure;
495 	u8 ip_type;
496 	u8 ipv6_prefix_length;
497 	u8 addr[16];
498 	u8 subnet_mask[16];
499 	u32 rsvd0;
500 } __packed;
501 
502 struct be_cmd_get_if_info_req {
503 	struct be_cmd_req_hdr hdr;
504 	u32 interface_hndl;
505 	u32 ip_type;
506 } __packed;
507 
508 struct be_cmd_get_if_info_resp {
509 	struct be_cmd_req_hdr hdr;
510 	u32 interface_hndl;
511 	u32 vlan_priority;
512 	u32 ip_addr_count;
513 	u32 dhcp_state;
514 	struct be_ip_addr_subnet_format ip_addr;
515 } __packed;
516 
517 struct be_ip_addr_record {
518 	u32 action;
519 	u32 interface_hndl;
520 	struct be_ip_addr_subnet_format ip_addr;
521 	u32 status;
522 } __packed;
523 
524 struct be_ip_addr_record_params {
525 	u32 record_entry_count;
526 	struct be_ip_addr_record ip_record;
527 } __packed;
528 
529 struct be_cmd_set_ip_addr_req {
530 	struct be_cmd_req_hdr hdr;
531 	struct be_ip_addr_record_params ip_params;
532 } __packed;
533 
534 
535 struct be_cmd_set_dhcp_req {
536 	struct be_cmd_req_hdr hdr;
537 	u32 interface_hndl;
538 	u32 ip_type;
539 	u32 flags;
540 	u32 retry_count;
541 } __packed;
542 
543 struct be_cmd_rel_dhcp_req {
544 	struct be_cmd_req_hdr hdr;
545 	u32 interface_hndl;
546 	u32 ip_type;
547 } __packed;
548 
549 struct be_cmd_set_def_gateway_req {
550 	struct be_cmd_req_hdr hdr;
551 	u32 action;
552 	struct ip_addr_format ip_addr;
553 } __packed;
554 
555 struct be_cmd_get_def_gateway_req {
556 	struct be_cmd_req_hdr hdr;
557 	u32 ip_type;
558 } __packed;
559 
560 struct be_cmd_get_def_gateway_resp {
561 	struct be_cmd_req_hdr hdr;
562 	struct ip_addr_format ip_addr;
563 } __packed;
564 
565 #define BEISCSI_VLAN_DISABLE	0xFFFF
566 struct be_cmd_set_vlan_req {
567 	struct be_cmd_req_hdr hdr;
568 	u32 interface_hndl;
569 	u32 vlan_priority;
570 } __packed;
571 /******************** Create CQ ***************************/
572 /**
573  * Pseudo amap definition in which each bit of the actual structure is defined
574  * as a byte - used to calculate offset/shift/mask of each field
575  */
576 struct amap_cq_context {
577 	u8 cidx[11];		/* dword 0 */
578 	u8 rsvd0;		/* dword 0 */
579 	u8 coalescwm[2];	/* dword 0 */
580 	u8 nodelay;		/* dword 0 */
581 	u8 epidx[11];		/* dword 0 */
582 	u8 rsvd1;		/* dword 0 */
583 	u8 count[2];		/* dword 0 */
584 	u8 valid;		/* dword 0 */
585 	u8 solevent;		/* dword 0 */
586 	u8 eventable;		/* dword 0 */
587 	u8 pidx[11];		/* dword 1 */
588 	u8 rsvd2;		/* dword 1 */
589 	u8 pd[10];		/* dword 1 */
590 	u8 eqid[8];		/* dword 1 */
591 	u8 stalled;		/* dword 1 */
592 	u8 armed;		/* dword 1 */
593 	u8 rsvd3[4];		/* dword 2 */
594 	u8 func[8];		/* dword 2 */
595 	u8 rsvd4[20];		/* dword 2 */
596 	u8 rsvd5[32];		/* dword 3 */
597 } __packed;
598 
599 struct amap_cq_context_v2 {
600 	u8 rsvd0[12];   /* dword 0 */
601 	u8 coalescwm[2];    /* dword 0 */
602 	u8 nodelay;     /* dword 0 */
603 	u8 rsvd1[12];   /* dword 0 */
604 	u8 count[2];    /* dword 0 */
605 	u8 valid;       /* dword 0 */
606 	u8 rsvd2;       /* dword 0 */
607 	u8 eventable;   /* dword 0 */
608 	u8 eqid[16];    /* dword 1 */
609 	u8 rsvd3[15];   /* dword 1 */
610 	u8 armed;       /* dword 1 */
611 	u8 cqecount[16];/* dword 2 */
612 	u8 rsvd4[16];   /* dword 2 */
613 	u8 rsvd5[32];   /* dword 3 */
614 };
615 
616 struct be_cmd_req_cq_create {
617 	struct be_cmd_req_hdr hdr;
618 	u16 num_pages;
619 	u8 page_size;
620 	u8 rsvd0;
621 	u8 context[sizeof(struct amap_cq_context) / 8];
622 	struct phys_addr pages[4];
623 } __packed;
624 
625 struct be_cmd_resp_cq_create {
626 	struct be_cmd_resp_hdr hdr;
627 	u16 cq_id;
628 	u16 rsvd0;
629 } __packed;
630 
631 /******************** Create MCCQ ***************************/
632 /**
633  * Pseudo amap definition in which each bit of the actual structure is defined
634  * as a byte - used to calculate offset/shift/mask of each field
635  */
636 struct amap_mcc_context {
637 	u8 con_index[14];
638 	u8 rsvd0[2];
639 	u8 ring_size[4];
640 	u8 fetch_wrb;
641 	u8 fetch_r2t;
642 	u8 cq_id[10];
643 	u8 prod_index[14];
644 	u8 fid[8];
645 	u8 pdid[9];
646 	u8 valid;
647 	u8 rsvd1[32];
648 	u8 rsvd2[32];
649 } __packed;
650 
651 struct be_cmd_req_mcc_create_ext {
652 	struct be_cmd_req_hdr hdr;
653 	u16 num_pages;
654 	u16 rsvd0;
655 	u32 async_evt_bitmap;
656 	u8 context[sizeof(struct amap_mcc_context) / 8];
657 	struct phys_addr pages[8];
658 } __packed;
659 
660 struct be_cmd_resp_mcc_create {
661 	struct be_cmd_resp_hdr hdr;
662 	u16 id;
663 	u16 rsvd0;
664 } __packed;
665 
666 /******************** Q Destroy  ***************************/
667 /* Type of Queue to be destroyed */
668 enum {
669 	QTYPE_EQ = 1,
670 	QTYPE_CQ,
671 	QTYPE_MCCQ,
672 	QTYPE_WRBQ,
673 	QTYPE_DPDUQ,
674 	QTYPE_SGL
675 };
676 
677 struct be_cmd_req_q_destroy {
678 	struct be_cmd_req_hdr hdr;
679 	u16 id;
680 	u16 bypass_flush;	/* valid only for rx q destroy */
681 } __packed;
682 
683 struct macaddr {
684 	u8 byte[ETH_ALEN];
685 };
686 
687 struct be_cmd_req_mcast_mac_config {
688 	struct be_cmd_req_hdr hdr;
689 	u16 num_mac;
690 	u8 promiscuous;
691 	u8 interface_id;
692 	struct macaddr mac[32];
693 } __packed;
694 
695 static inline void *embedded_payload(struct be_mcc_wrb *wrb)
696 {
697 	return wrb->payload.embedded_payload;
698 }
699 
700 static inline struct be_sge *nonembedded_sgl(struct be_mcc_wrb *wrb)
701 {
702 	return &wrb->payload.sgl[0];
703 }
704 
705 /******************** Modify EQ Delay *******************/
706 struct be_cmd_req_modify_eq_delay {
707 	struct be_cmd_req_hdr hdr;
708 	__le32 num_eq;
709 	struct {
710 		__le32 eq_id;
711 		__le32 phase;
712 		__le32 delay_multiplier;
713 	} delay[MAX_CPUS];
714 } __packed;
715 
716 /******************** Get MAC ADDR *******************/
717 
718 struct be_cmd_get_nic_conf_resp {
719 	struct be_cmd_resp_hdr hdr;
720 	u32 nic_port_count;
721 	u32 speed;
722 	u32 max_speed;
723 	u32 link_state;
724 	u32 max_frame_size;
725 	u16 size_of_structure;
726 	u8 mac_address[ETH_ALEN];
727 } __packed;
728 
729 /******************** Get HBA NAME *******************/
730 
731 struct be_cmd_hba_name {
732 	struct be_cmd_req_hdr hdr;
733 	u16 flags;
734 	u16 rsvd0;
735 	u8 initiator_name[ISCSI_NAME_LEN];
736 #define BE_INI_ALIAS_LEN 32
737 	u8 initiator_alias[BE_INI_ALIAS_LEN];
738 } __packed;
739 
740 /******************** COMMON SET Features *******************/
741 #define BE_CMD_SET_FEATURE_UER	0x10
742 #define BE_CMD_UER_SUPP_BIT	0x1
743 struct be_uer_req {
744 	u32 uer;
745 	u32 rsvd;
746 };
747 
748 struct be_uer_resp {
749 	u32 uer;
750 	u16 ue2rp;
751 	u16 ue2sr;
752 };
753 
754 struct be_cmd_set_features {
755 	union {
756 		struct be_cmd_req_hdr req_hdr;
757 		struct be_cmd_resp_hdr resp_hdr;
758 	} h;
759 	u32 feature;
760 	u32 param_len;
761 	union {
762 		struct be_uer_req req;
763 		struct be_uer_resp resp;
764 		u32 rsvd[2];
765 	} param;
766 } __packed;
767 
768 int beiscsi_cmd_function_reset(struct beiscsi_hba *phba);
769 
770 int beiscsi_cmd_special_wrb(struct be_ctrl_info *ctrl, u32 load);
771 
772 int beiscsi_check_fw_rdy(struct beiscsi_hba *phba);
773 
774 int beiscsi_init_sliport(struct beiscsi_hba *phba);
775 
776 int beiscsi_cmd_iscsi_cleanup(struct beiscsi_hba *phba, unsigned short ulp_num);
777 
778 int beiscsi_detect_ue(struct beiscsi_hba *phba);
779 
780 int beiscsi_detect_tpe(struct beiscsi_hba *phba);
781 
782 int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl,
783 			  struct be_queue_info *eq, int eq_delay);
784 
785 int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl,
786 			  struct be_queue_info *cq, struct be_queue_info *eq,
787 			  bool sol_evts, bool no_delay,
788 			  int num_cqe_dma_coalesce);
789 
790 int beiscsi_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q,
791 			  int type);
792 int beiscsi_cmd_mccq_create(struct beiscsi_hba *phba,
793 			struct be_queue_info *mccq,
794 			struct be_queue_info *cq);
795 
796 unsigned int be_cmd_get_initname(struct beiscsi_hba *phba);
797 
798 void free_mcc_wrb(struct be_ctrl_info *ctrl, unsigned int tag);
799 
800 int beiscsi_modify_eq_delay(struct beiscsi_hba *phba, struct be_set_eqd *,
801 			    int num);
802 int beiscsi_mccq_compl_wait(struct beiscsi_hba *phba,
803 			    unsigned int tag,
804 			    struct be_mcc_wrb **wrb,
805 			    struct be_dma_mem *mbx_cmd_mem);
806 int __beiscsi_mcc_compl_status(struct beiscsi_hba *phba,
807 			       unsigned int tag,
808 			       struct be_mcc_wrb **wrb,
809 			       struct be_dma_mem *mbx_cmd_mem);
810 struct be_mcc_wrb *wrb_from_mbox(struct be_dma_mem *mbox_mem);
811 void be_mcc_notify(struct beiscsi_hba *phba, unsigned int tag);
812 struct be_mcc_wrb *alloc_mcc_wrb(struct beiscsi_hba *phba,
813 				 unsigned int *ref_tag);
814 void beiscsi_process_async_event(struct beiscsi_hba *phba,
815 				struct be_mcc_compl *compl);
816 int beiscsi_process_mcc_compl(struct be_ctrl_info *ctrl,
817 			      struct be_mcc_compl *compl);
818 
819 int be_cmd_create_default_pdu_queue(struct be_ctrl_info *ctrl,
820 				    struct be_queue_info *cq,
821 				    struct be_queue_info *dq, int length,
822 				    int entry_size, uint8_t is_header,
823 				    uint8_t ulp_num);
824 
825 int be_cmd_iscsi_post_template_hdr(struct be_ctrl_info *ctrl,
826 				    struct be_dma_mem *q_mem);
827 
828 int be_cmd_iscsi_remove_template_hdr(struct be_ctrl_info *ctrl);
829 
830 int be_cmd_iscsi_post_sgl_pages(struct be_ctrl_info *ctrl,
831 				struct be_dma_mem *q_mem, u32 page_offset,
832 				u32 num_pages);
833 
834 int be_cmd_wrbq_create(struct be_ctrl_info *ctrl, struct be_dma_mem *q_mem,
835 		       struct be_queue_info *wrbq,
836 		       struct hwi_wrb_context *pwrb_context,
837 		       uint8_t ulp_num);
838 
839 /* Configuration Functions */
840 int be_cmd_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag);
841 
842 int beiscsi_check_supported_fw(struct be_ctrl_info *ctrl,
843 			       struct beiscsi_hba *phba);
844 
845 int beiscsi_get_fw_config(struct be_ctrl_info *ctrl, struct beiscsi_hba *phba);
846 
847 int beiscsi_get_port_name(struct be_ctrl_info *ctrl, struct beiscsi_hba *phba);
848 
849 int beiscsi_set_uer_feature(struct beiscsi_hba *phba);
850 
851 struct be_default_pdu_context {
852 	u32 dw[4];
853 } __packed;
854 
855 struct amap_be_default_pdu_context {
856 	u8 dbuf_cindex[13];	/* dword 0 */
857 	u8 rsvd0[3];		/* dword 0 */
858 	u8 ring_size[4];	/* dword 0 */
859 	u8 ring_state[4];	/* dword 0 */
860 	u8 rsvd1[8];		/* dword 0 */
861 	u8 dbuf_pindex[13];	/* dword 1 */
862 	u8 rsvd2;		/* dword 1 */
863 	u8 pci_func_id[8];	/* dword 1 */
864 	u8 rx_pdid[9];		/* dword 1 */
865 	u8 rx_pdid_valid;	/* dword 1 */
866 	u8 default_buffer_size[16];	/* dword 2 */
867 	u8 cq_id_recv[10];	/* dword 2 */
868 	u8 rx_pdid_not_valid;	/* dword 2 */
869 	u8 rsvd3[5];		/* dword 2 */
870 	u8 rsvd4[32];		/* dword 3 */
871 } __packed;
872 
873 struct amap_default_pdu_context_ext {
874 	u8 rsvd0[16];   /* dword 0 */
875 	u8 ring_size[4];    /* dword 0 */
876 	u8 rsvd1[12];   /* dword 0 */
877 	u8 rsvd2[22];   /* dword 1 */
878 	u8 rx_pdid[9];  /* dword 1 */
879 	u8 rx_pdid_valid;   /* dword 1 */
880 	u8 default_buffer_size[16]; /* dword 2 */
881 	u8 cq_id_recv[16];  /* dword 2 */
882 	u8 rsvd3[32];   /* dword 3 */
883 } __packed;
884 
885 struct be_defq_create_req {
886 	struct be_cmd_req_hdr hdr;
887 	u16 num_pages;
888 	u8 ulp_num;
889 #define BEISCSI_DUAL_ULP_AWARE_BIT	0	/* Byte 3 - Bit 0 */
890 #define BEISCSI_BIND_Q_TO_ULP_BIT	1	/* Byte 3 - Bit 1 */
891 	u8 dua_feature;
892 	struct be_default_pdu_context context;
893 	struct phys_addr pages[8];
894 } __packed;
895 
896 struct be_defq_create_resp {
897 	struct be_cmd_req_hdr hdr;
898 	u16 id;
899 	u8 rsvd0;
900 	u8 ulp_num;
901 	u32 doorbell_offset;
902 	u16 register_set;
903 	u16 doorbell_format;
904 } __packed;
905 
906 struct be_post_template_pages_req {
907 	struct be_cmd_req_hdr hdr;
908 	u16 num_pages;
909 #define BEISCSI_TEMPLATE_HDR_TYPE_ISCSI	0x1
910 	u16 type;
911 	struct phys_addr scratch_pa;
912 	struct virt_addr scratch_va;
913 	struct virt_addr pages_va;
914 	struct phys_addr pages[16];
915 } __packed;
916 
917 struct be_remove_template_pages_req {
918 	struct be_cmd_req_hdr hdr;
919 	u16 type;
920 	u16 rsvd0;
921 } __packed;
922 
923 struct be_post_sgl_pages_req {
924 	struct be_cmd_req_hdr hdr;
925 	u16 num_pages;
926 	u16 page_offset;
927 	u32 rsvd0;
928 	struct phys_addr pages[26];
929 	u32 rsvd1;
930 } __packed;
931 
932 struct be_wrbq_create_req {
933 	struct be_cmd_req_hdr hdr;
934 	u16 num_pages;
935 	u8 ulp_num;
936 	u8 dua_feature;
937 	struct phys_addr pages[8];
938 } __packed;
939 
940 struct be_wrbq_create_resp {
941 	struct be_cmd_resp_hdr resp_hdr;
942 	u16 cid;
943 	u8 rsvd0;
944 	u8 ulp_num;
945 	u32 doorbell_offset;
946 	u16 register_set;
947 	u16 doorbell_format;
948 } __packed;
949 
950 #define SOL_CID_MASK		0x0000FFC0
951 #define SOL_CODE_MASK		0x0000003F
952 #define SOL_WRB_INDEX_MASK	0x00FF0000
953 #define SOL_CMD_WND_MASK	0xFF000000
954 #define SOL_RES_CNT_MASK	0x7FFFFFFF
955 #define SOL_EXP_CMD_SN_MASK	0xFFFFFFFF
956 #define SOL_HW_STS_MASK		0x000000FF
957 #define SOL_STS_MASK		0x0000FF00
958 #define SOL_RESP_MASK		0x00FF0000
959 #define SOL_FLAGS_MASK		0x7F000000
960 #define SOL_S_MASK		0x80000000
961 
962 struct sol_cqe {
963 	u32 dw[4];
964 };
965 
966 struct amap_sol_cqe {
967 	u8 hw_sts[8];		/* dword 0 */
968 	u8 i_sts[8];		/* dword 0 */
969 	u8 i_resp[8];		/* dword 0 */
970 	u8 i_flags[7];		/* dword 0 */
971 	u8 s;			/* dword 0 */
972 	u8 i_exp_cmd_sn[32];	/* dword 1 */
973 	u8 code[6];		/* dword 2 */
974 	u8 cid[10];		/* dword 2 */
975 	u8 wrb_index[8];	/* dword 2 */
976 	u8 i_cmd_wnd[8];	/* dword 2 */
977 	u8 i_res_cnt[31];	/* dword 3 */
978 	u8 valid;		/* dword 3 */
979 } __packed;
980 
981 #define SOL_ICD_INDEX_MASK	0x0003FFC0
982 struct amap_sol_cqe_ring {
983 	u8 hw_sts[8];		/* dword 0 */
984 	u8 i_sts[8];		/* dword 0 */
985 	u8 i_resp[8];		/* dword 0 */
986 	u8 i_flags[7];		/* dword 0 */
987 	u8 s;			/* dword 0 */
988 	u8 i_exp_cmd_sn[32];	/* dword 1 */
989 	u8 code[6];		/* dword 2 */
990 	u8 icd_index[12];	/* dword 2 */
991 	u8 rsvd[6];		/* dword 2 */
992 	u8 i_cmd_wnd[8];	/* dword 2 */
993 	u8 i_res_cnt[31];	/* dword 3 */
994 	u8 valid;		/* dword 3 */
995 } __packed;
996 
997 struct amap_sol_cqe_v2 {
998 	u8 hw_sts[8];   /* dword 0 */
999 	u8 i_sts[8];    /* dword 0 */
1000 	u8 wrb_index[16];   /* dword 0 */
1001 	u8 i_exp_cmd_sn[32];    /* dword 1 */
1002 	u8 code[6]; /* dword 2 */
1003 	u8 cmd_cmpl;    /* dword 2 */
1004 	u8 rsvd0;   /* dword 2 */
1005 	u8 i_cmd_wnd[8];    /* dword 2 */
1006 	u8 cid[13]; /* dword 2 */
1007 	u8 u;   /* dword 2 */
1008 	u8 o;   /* dword 2 */
1009 	u8 s;   /* dword 2 */
1010 	u8 i_res_cnt[31];   /* dword 3 */
1011 	u8 valid;   /* dword 3 */
1012 } __packed;
1013 
1014 struct common_sol_cqe {
1015 	u32 exp_cmdsn;
1016 	u32 res_cnt;
1017 	u16 wrb_index;
1018 	u16 cid;
1019 	u8 hw_sts;
1020 	u8 cmd_wnd;
1021 	u8 res_flag; /* the s feild of structure */
1022 	u8 i_resp; /* for skh if cmd_complete is set then i_sts is response */
1023 	u8 i_flags; /* for skh or the u and o feilds */
1024 	u8 i_sts; /* for skh if cmd_complete is not-set then i_sts is status */
1025 };
1026 
1027 /*** iSCSI ack/driver message completions ***/
1028 struct amap_it_dmsg_cqe {
1029 	u8 ack_num[32]; /* DWORD 0 */
1030 	u8 pdu_bytes_rcvd[32];  /* DWORD 1 */
1031 	u8 code[6]; /* DWORD 2 */
1032 	u8 cid[10]; /* DWORD 2 */
1033 	u8 wrb_idx[8];  /* DWORD 2 */
1034 	u8 rsvd0[8];    /* DWORD 2*/
1035 	u8 rsvd1[31];   /* DWORD 3*/
1036 	u8 valid;   /* DWORD 3 */
1037 } __packed;
1038 
1039 struct amap_it_dmsg_cqe_v2 {
1040 	u8 ack_num[32]; /* DWORD 0 */
1041 	u8 pdu_bytes_rcvd[32];  /* DWORD 1 */
1042 	u8 code[6]; /* DWORD 2 */
1043 	u8 rsvd0[10];   /* DWORD 2 */
1044 	u8 wrb_idx[16]; /* DWORD 2 */
1045 	u8 rsvd1[16];   /* DWORD 3 */
1046 	u8 cid[13]; /* DWORD 3 */
1047 	u8 rsvd2[2];    /* DWORD 3 */
1048 	u8 valid;   /* DWORD 3 */
1049 } __packed;
1050 
1051 
1052 /**
1053  * Post WRB Queue Doorbell Register used by the host Storage
1054  * stack to notify the
1055  * controller of a posted Work Request Block
1056  */
1057 #define DB_WRB_POST_CID_MASK		0xFFFF	/* bits 0 - 16 */
1058 #define DB_DEF_PDU_WRB_INDEX_MASK	0xFF	/* bits 0 - 9 */
1059 
1060 #define DB_DEF_PDU_WRB_INDEX_SHIFT	16
1061 #define DB_DEF_PDU_NUM_POSTED_SHIFT	24
1062 
1063 struct fragnum_bits_for_sgl_cra_in {
1064 	struct be_cmd_req_hdr hdr;
1065 	u32 num_bits;
1066 } __packed;
1067 
1068 struct iscsi_cleanup_req {
1069 	struct be_cmd_req_hdr hdr;
1070 	u16 chute;
1071 	u8 hdr_ring_id;
1072 	u8 data_ring_id;
1073 } __packed;
1074 
1075 struct iscsi_cleanup_req_v1 {
1076 	struct be_cmd_req_hdr hdr;
1077 	u16 chute;
1078 	u16 rsvd1;
1079 	u16 hdr_ring_id;
1080 	u16 rsvd2;
1081 	u16 data_ring_id;
1082 	u16 rsvd3;
1083 } __packed;
1084 
1085 struct eq_delay {
1086 	u32 eq_id;
1087 	u32 phase;
1088 	u32 delay_multiplier;
1089 } __packed;
1090 
1091 struct be_eq_delay_params_in {
1092 	struct be_cmd_req_hdr hdr;
1093 	u32 num_eq;
1094 	struct eq_delay delay[8];
1095 } __packed;
1096 
1097 struct tcp_connect_and_offload_in {
1098 	struct be_cmd_req_hdr hdr;
1099 	struct ip_addr_format ip_address;
1100 	u16 tcp_port;
1101 	u16 cid;
1102 	u16 cq_id;
1103 	u16 defq_id;
1104 	struct phys_addr dataout_template_pa;
1105 	u16 hdr_ring_id;
1106 	u16 data_ring_id;
1107 	u8 do_offload;
1108 	u8 rsvd0[3];
1109 } __packed;
1110 
1111 struct tcp_connect_and_offload_in_v1 {
1112 	struct be_cmd_req_hdr hdr;
1113 	struct ip_addr_format ip_address;
1114 	u16 tcp_port;
1115 	u16 cid;
1116 	u16 cq_id;
1117 	u16 defq_id;
1118 	struct phys_addr dataout_template_pa;
1119 	u16 hdr_ring_id;
1120 	u16 data_ring_id;
1121 	u8 do_offload;
1122 	u8 ifd_state;
1123 	u8 rsvd0[2];
1124 	u16 tcp_window_size;
1125 	u8 tcp_window_scale_count;
1126 	u8 rsvd1;
1127 	u32 tcp_mss:24;
1128 	u8 rsvd2;
1129 } __packed;
1130 
1131 struct tcp_connect_and_offload_out {
1132 	struct be_cmd_resp_hdr hdr;
1133 	u32 connection_handle;
1134 	u16 cid;
1135 	u16 rsvd0;
1136 
1137 } __packed;
1138 
1139 #define DB_DEF_PDU_RING_ID_MASK	0x3FFF	/* bits 0 - 13 */
1140 #define DB_DEF_PDU_CQPROC_MASK		0x3FFF	/* bits 16 - 29 */
1141 #define DB_DEF_PDU_REARM_SHIFT		14
1142 #define DB_DEF_PDU_EVENT_SHIFT		15
1143 #define DB_DEF_PDU_CQPROC_SHIFT		16
1144 
1145 struct be_invalidate_connection_params_in {
1146 	struct be_cmd_req_hdr hdr;
1147 	u32 session_handle;
1148 	u16 cid;
1149 	u16 unused;
1150 #define BE_CLEANUP_TYPE_INVALIDATE	0x8001
1151 #define BE_CLEANUP_TYPE_ISSUE_TCP_RST	0x8002
1152 	u16 cleanup_type;
1153 	u16 save_cfg;
1154 } __packed;
1155 
1156 struct be_invalidate_connection_params_out {
1157 	u32 session_handle;
1158 	u16 cid;
1159 	u16 unused;
1160 } __packed;
1161 
1162 union be_invalidate_connection_params {
1163 	struct be_invalidate_connection_params_in req;
1164 	struct be_invalidate_connection_params_out resp;
1165 } __packed;
1166 
1167 struct be_tcp_upload_params_in {
1168 	struct be_cmd_req_hdr hdr;
1169 	u16 id;
1170 #define BE_UPLOAD_TYPE_GRACEFUL		1
1171 /* abortive upload with reset */
1172 #define BE_UPLOAD_TYPE_ABORT_RESET	2
1173 /* abortive upload without reset */
1174 #define BE_UPLOAD_TYPE_ABORT		3
1175 /* abortive upload with reset, sequence number by driver */
1176 #define BE_UPLOAD_TYPE_ABORT_WITH_SEQ	4
1177 	u16 upload_type;
1178 	u32 reset_seq;
1179 } __packed;
1180 
1181 struct be_tcp_upload_params_out {
1182 	u32 dw[32];
1183 } __packed;
1184 
1185 union be_tcp_upload_params {
1186 	struct be_tcp_upload_params_in request;
1187 	struct be_tcp_upload_params_out response;
1188 } __packed;
1189 
1190 struct be_ulp_fw_cfg {
1191 #define BEISCSI_ULP_ISCSI_INI_MODE	0x10
1192 	u32 ulp_mode;
1193 	u32 etx_base;
1194 	u32 etx_count;
1195 	u32 sq_base;
1196 	u32 sq_count;
1197 	u32 rq_base;
1198 	u32 rq_count;
1199 	u32 dq_base;
1200 	u32 dq_count;
1201 	u32 lro_base;
1202 	u32 lro_count;
1203 	u32 icd_base;
1204 	u32 icd_count;
1205 };
1206 
1207 struct be_ulp_chain_icd {
1208 	u32 chain_base;
1209 	u32 chain_count;
1210 };
1211 
1212 struct be_fw_cfg {
1213 	struct be_cmd_req_hdr hdr;
1214 	u32 be_config_number;
1215 	u32 asic_revision;
1216 	u32 phys_port;
1217 #define BEISCSI_FUNC_ISCSI_INI_MODE	0x10
1218 #define BEISCSI_FUNC_DUA_MODE	0x800
1219 	u32 function_mode;
1220 	struct be_ulp_fw_cfg ulp[2];
1221 	u32 function_caps;
1222 	u32 cqid_base;
1223 	u32 cqid_count;
1224 	u32 eqid_base;
1225 	u32 eqid_count;
1226 	struct be_ulp_chain_icd chain_icd[2];
1227 } __packed;
1228 
1229 struct be_cmd_get_all_if_id_req {
1230 	struct be_cmd_req_hdr hdr;
1231 	u32 if_count;
1232 	u32 if_hndl_list[1];
1233 } __packed;
1234 
1235 struct be_cmd_get_port_name {
1236 	union {
1237 		struct be_cmd_req_hdr req_hdr;
1238 		struct be_cmd_resp_hdr resp_hdr;
1239 	} h;
1240 	union {
1241 		struct {
1242 			u32 reserved;
1243 		} req;
1244 		struct {
1245 			u32 port_names;
1246 		} resp;
1247 	} p;
1248 } __packed;
1249 
1250 #define ISCSI_OPCODE_SCSI_DATA_OUT		5
1251 #define OPCODE_COMMON_NTWK_LINK_STATUS_QUERY 5
1252 #define OPCODE_COMMON_MODIFY_EQ_DELAY		41
1253 #define OPCODE_COMMON_ISCSI_CLEANUP		59
1254 #define	OPCODE_COMMON_TCP_UPLOAD		56
1255 #define OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD 70
1256 #define OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS 1
1257 #define OPCODE_ISCSI_INI_CFG_GET_HBA_NAME	6
1258 #define OPCODE_ISCSI_INI_CFG_SET_HBA_NAME	7
1259 #define OPCODE_ISCSI_INI_SESSION_GET_A_SESSION  14
1260 #define OPCODE_ISCSI_INI_SESSION_LOGOUT_TARGET	 24
1261 #define OPCODE_ISCSI_INI_DRIVER_REOPEN_ALL_SESSIONS 36
1262 #define OPCODE_ISCSI_INI_DRIVER_OFFLOAD_SESSION 41
1263 #define OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION 42
1264 #define OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET	52
1265 #define OPCODE_COMMON_WRITE_FLASH		96
1266 #define OPCODE_COMMON_READ_FLASH		97
1267 
1268 #define CMD_ISCSI_COMMAND_INVALIDATE		1
1269 
1270 #define INI_WR_CMD			1	/* Initiator write command */
1271 #define INI_TMF_CMD			2	/* Initiator TMF command */
1272 #define INI_NOPOUT_CMD			3	/* Initiator; Send a NOP-OUT */
1273 #define INI_RD_CMD			5	/* Initiator requesting to send
1274 						 * a read command
1275 						 */
1276 #define TGT_CTX_UPDT_CMD		7	/* Target context update */
1277 #define TGT_STS_CMD			8	/* Target R2T and other BHS
1278 						 * where only the status number
1279 						 * need to be updated
1280 						 */
1281 #define TGT_DATAIN_CMD			9	/* Target Data-Ins in response
1282 						 * to read command
1283 						 */
1284 #define TGT_SOS_PDU			10	/* Target:standalone status
1285 						 * response
1286 						 */
1287 #define TGT_DM_CMD			11	/* Indicates that the bhs
1288 						 *  preparedby
1289 						 * driver should not be touched
1290 						 */
1291 
1292 /* Returns the number of items in the field array. */
1293 #define BE_NUMBER_OF_FIELD(_type_, _field_)	\
1294 	(FIELD_SIZEOF(_type_, _field_)/sizeof((((_type_ *)0)->_field_[0])))\
1295 
1296 /**
1297  * Different types of iSCSI completions to host driver for both initiator
1298  * and taget mode
1299  * of operation.
1300  */
1301 #define SOL_CMD_COMPLETE		1	/* Solicited command completed
1302 						 * normally
1303 						 */
1304 #define SOL_CMD_KILLED_DATA_DIGEST_ERR  2	/* Solicited command got
1305 						 * invalidated internally due
1306 						 * to Data Digest error
1307 						 */
1308 #define CXN_KILLED_PDU_SIZE_EXCEEDS_DSL 3	/* Connection got invalidated
1309 						 * internally
1310 						 * due to a received PDU
1311 						 * size > DSL
1312 						 */
1313 #define CXN_KILLED_BURST_LEN_MISMATCH   4	/* Connection got invalidated
1314 						 * internally due ti received
1315 						 * PDU sequence size >
1316 						 * FBL/MBL.
1317 						 */
1318 #define CXN_KILLED_AHS_RCVD		5	/* Connection got invalidated
1319 						 * internally due to a received
1320 						 * PDU Hdr that has
1321 						 * AHS */
1322 #define CXN_KILLED_HDR_DIGEST_ERR	6	/* Connection got invalidated
1323 						 * internally due to Hdr Digest
1324 						 * error
1325 						 */
1326 #define CXN_KILLED_UNKNOWN_HDR		7	/* Connection got invalidated
1327 						 *  internally
1328 						 * due to a bad opcode in the
1329 						 * pdu hdr
1330 						 */
1331 #define CXN_KILLED_STALE_ITT_TTT_RCVD	8	/* Connection got invalidated
1332 						 * internally due to a received
1333 						 * ITT/TTT that does not belong
1334 						 * to this Connection
1335 						 */
1336 #define CXN_KILLED_INVALID_ITT_TTT_RCVD 9	/* Connection got invalidated
1337 						 * internally due to received
1338 						 * ITT/TTT value > Max
1339 						 * Supported ITTs/TTTs
1340 						 */
1341 #define CXN_KILLED_RST_RCVD		10	/* Connection got invalidated
1342 						 * internally due to an
1343 						 * incoming TCP RST
1344 						 */
1345 #define CXN_KILLED_TIMED_OUT		11	/* Connection got invalidated
1346 						 * internally due to timeout on
1347 						 * tcp segment 12 retransmit
1348 						 * attempts failed
1349 						 */
1350 #define CXN_KILLED_RST_SENT		12	/* Connection got invalidated
1351 						 * internally due to TCP RST
1352 						 * sent by the Tx side
1353 						 */
1354 #define CXN_KILLED_FIN_RCVD		13	/* Connection got invalidated
1355 						 * internally due to an
1356 						 * incoming TCP FIN.
1357 						 */
1358 #define CXN_KILLED_BAD_UNSOL_PDU_RCVD	14	/* Connection got invalidated
1359 						 * internally due to bad
1360 						 * unsolicited PDU Unsolicited
1361 						 * PDUs are PDUs with
1362 						 * ITT=0xffffffff
1363 						 */
1364 #define CXN_KILLED_BAD_WRB_INDEX_ERROR	15	/* Connection got invalidated
1365 						 * internally due to bad WRB
1366 						 * index.
1367 						 */
1368 #define CXN_KILLED_OVER_RUN_RESIDUAL	16	/* Command got invalidated
1369 						 * internally due to received
1370 						 * command has residual
1371 						 * over run bytes.
1372 						 */
1373 #define CXN_KILLED_UNDER_RUN_RESIDUAL	17	/* Command got invalidated
1374 						 * internally due to received
1375 						 * command has residual under
1376 						 * run bytes.
1377 						 */
1378 #define CMD_KILLED_INVALID_STATSN_RCVD	18	/* Command got invalidated
1379 						 * internally due to a received
1380 						 * PDU has an invalid StatusSN
1381 						 */
1382 #define CMD_KILLED_INVALID_R2T_RCVD	19	/* Command got invalidated
1383 						 * internally due to a received
1384 						 * an R2T with some invalid
1385 						 * fields in it
1386 						 */
1387 #define CMD_CXN_KILLED_LUN_INVALID	20	/* Command got invalidated
1388 						 * internally due to received
1389 						 * PDU has an invalid LUN.
1390 						 */
1391 #define CMD_CXN_KILLED_ICD_INVALID	21	/* Command got invalidated
1392 						 * internally due to the
1393 						 * corresponding ICD not in a
1394 						 * valid state
1395 						 */
1396 #define CMD_CXN_KILLED_ITT_INVALID	22	/* Command got invalidated due
1397 						 *  to received PDU has an
1398 						 *  invalid ITT.
1399 						 */
1400 #define CMD_CXN_KILLED_SEQ_OUTOFORDER	23	/* Command got invalidated due
1401 						 * to received sequence buffer
1402 						 * offset is out of order.
1403 						 */
1404 #define CMD_CXN_KILLED_INVALID_DATASN_RCVD 24	/* Command got invalidated
1405 						 * internally due to a
1406 						 * received PDU has an invalid
1407 						 * DataSN
1408 						 */
1409 #define CXN_INVALIDATE_NOTIFY		25	/* Connection invalidation
1410 						 * completion notify.
1411 						 */
1412 #define CXN_INVALIDATE_INDEX_NOTIFY	26	/* Connection invalidation
1413 						 * completion
1414 						 * with data PDU index.
1415 						 */
1416 #define CMD_INVALIDATED_NOTIFY		27	/* Command invalidation
1417 						 * completionnotifify.
1418 						 */
1419 #define UNSOL_HDR_NOTIFY		28	/* Unsolicited header notify.*/
1420 #define UNSOL_DATA_NOTIFY		29	/* Unsolicited data notify.*/
1421 #define UNSOL_DATA_DIGEST_ERROR_NOTIFY	30	/* Unsolicited data digest
1422 						 * error notify.
1423 						 */
1424 #define DRIVERMSG_NOTIFY		31	/* TCP acknowledge based
1425 						 * notification.
1426 						 */
1427 #define CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN 32 /* Connection got invalidated
1428 						  * internally due to command
1429 						  * and data are not on same
1430 						  * connection.
1431 						  */
1432 #define SOL_CMD_KILLED_DIF_ERR		33	/* Solicited command got
1433 						 *  invalidated internally due
1434 						 *  to DIF error
1435 						 */
1436 #define CXN_KILLED_SYN_RCVD		34	/* Connection got invalidated
1437 						 * internally due to incoming
1438 						 * TCP SYN
1439 						 */
1440 #define CXN_KILLED_IMM_DATA_RCVD	35	/* Connection got invalidated
1441 						 * internally due to an
1442 						 * incoming Unsolicited PDU
1443 						 * that has immediate data on
1444 						 * the cxn
1445 						 */
1446 
1447 void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len,
1448 			bool embedded, u8 sge_cnt);
1449 
1450 void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr,
1451 			u8 subsystem, u8 opcode, int cmd_len);
1452 #endif /* !BEISCSI_CMDS_H */
1453