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