blob: adafd9ca3e3e18b7f5c9ec17e3aebaab1ea6e2e4 [file] [log] [blame]
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301/**
Ketan Mukadamc4f39bd2015-07-04 04:12:33 +05302 * Copyright (C) 2005 - 2015 Emulex
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05303 * 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:
Minh Tran4627de92015-05-14 23:16:17 -070011 * linux-drivers@avagotech.com
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053012 *
Ketan Mukadamc4f39bd2015-07-04 04:12:33 +053013 * Emulex
Jayamohan Kallickal255fa9a2011-03-25 14:23:57 -070014 * 3333 Susan Street
15 * Costa Mesa, CA 92626
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053016 */
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.
Jayamohan Kallickal2f635882012-04-03 23:41:45 -050026 * The commands are serviced by the ARM processor in the OneConnect's MPU.
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053027 */
28struct be_sge {
Jayamohan Kallickal39033412014-08-08 00:59:58 -040029 __le32 pa_lo;
30 __le32 pa_hi;
31 __le32 len;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053032};
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 {
Jayamohan Kallickal843ae752013-09-28 15:35:44 -070043#define EMBED_MBX_MAX_PAYLOAD_SIZE 220
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053044 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)
Jayamohan Kallickal457ff3b2010-07-22 04:16:00 +053051#define CQE_FLAGS_COMPLETED_MASK (1 << 28)
52#define CQE_FLAGS_CONSUMED_MASK (1 << 27)
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053053
54/* Completion Status */
55#define MCC_STATUS_SUCCESS 0x0
Jayamohan Kallickala8081e32013-04-05 20:38:22 -070056#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
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053060
Jitendra Bhivare67296ad2016-02-04 15:49:10 +053061#define CQE_STATUS_COMPL_MASK 0xFFFF
62#define CQE_STATUS_COMPL_SHIFT 0 /* bits 0 - 15 */
63#define CQE_STATUS_EXTD_MASK 0xFFFF
64#define CQE_STATUS_EXTD_SHIFT 16 /* bits 31 - 16 */
John Soni Josee175def2012-10-20 04:45:40 +053065#define CQE_STATUS_ADDL_MASK 0xFF00
Jitendra Bhivare67296ad2016-02-04 15:49:10 +053066#define CQE_STATUS_ADDL_SHIFT 8
67#define CQE_STATUS_MASK 0xFF
John Soni Josee175def2012-10-20 04:45:40 +053068#define CQE_STATUS_WRB_MASK 0xFF0000
69#define CQE_STATUS_WRB_SHIFT 16
Jitendra Bhivare67296ad2016-02-04 15:49:10 +053070
John Soni Josee175def2012-10-20 04:45:40 +053071#define BEISCSI_HOST_MBX_TIMEOUT (110 * 1000)
72#define BEISCSI_FW_MBX_TIMEOUT 100
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053073
John Soni Joseeaae5262012-10-20 04:43:44 +053074/* MBOX Command VER */
Jayamohan Kallickalb3c202d2014-05-05 21:41:27 -040075#define MBX_CMD_VER1 0x01
John Soni Joseeaae5262012-10-20 04:43:44 +053076#define MBX_CMD_VER2 0x02
77
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053078struct be_mcc_compl {
79 u32 status; /* dword 0 */
80 u32 tag0; /* dword 1 */
81 u32 tag1; /* dword 2 */
82 u32 flags; /* dword 3 */
83};
84
85/********* Mailbox door bell *************/
86/**
87 * Used for driver communication with the FW.
88 * The software must write this register twice to post any command. First,
89 * it writes the register with hi=1 and the upper bits of the physical address
90 * for the MAILBOX structure. Software must poll the ready bit until this
91 * is acknowledged. Then, sotware writes the register with hi=0 with the lower
92 * bits in the address. It must poll the ready bit until the command is
93 * complete. Upon completion, the MAILBOX will contain a valid completion
94 * queue entry.
95 */
96#define MPU_MAILBOX_DB_OFFSET 0x160
97#define MPU_MAILBOX_DB_RDY_MASK 0x1 /* bit 0 */
98#define MPU_MAILBOX_DB_HI_MASK 0x2 /* bit 1 */
99
100/********** MPU semphore ******************/
101#define MPU_EP_SEMAPHORE_OFFSET 0xac
102#define EP_SEMAPHORE_POST_STAGE_MASK 0x0000FFFF
103#define EP_SEMAPHORE_POST_ERR_MASK 0x1
104#define EP_SEMAPHORE_POST_ERR_SHIFT 31
105
106/********** MCC door bell ************/
107#define DB_MCCQ_OFFSET 0x140
Jayamohan Kallickale08b3c82014-01-29 02:16:42 -0500108#define DB_MCCQ_RING_ID_MASK 0xFFFF /* bits 0 - 15 */
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530109/* Number of entries posted */
110#define DB_MCCQ_NUM_POSTED_SHIFT 16 /* bits 16 - 29 */
111
112/* MPU semphore POST stage values */
113#define POST_STAGE_ARMFW_RDY 0xc000 /* FW is done with POST */
114
115/**
116 * When the async bit of mcc_compl is set, the last 4 bytes of
117 * mcc_compl is interpreted as follows:
118 */
119#define ASYNC_TRAILER_EVENT_CODE_SHIFT 8 /* bits 8 - 15 */
120#define ASYNC_TRAILER_EVENT_CODE_MASK 0xFF
121#define ASYNC_EVENT_CODE_LINK_STATE 0x1
Jayamohan Kallickala3d313e2014-08-08 01:00:00 -0400122#define ASYNC_EVENT_CODE_ISCSI 0x4
Jitendra Bhivare53aefe22016-01-20 14:10:53 +0530123#define ASYNC_EVENT_CODE_SLI 0x11
Jayamohan Kallickala3d313e2014-08-08 01:00:00 -0400124
125#define ASYNC_TRAILER_EVENT_TYPE_SHIFT 16 /* bits 16 - 23 */
Jitendra Bhivare53aefe22016-01-20 14:10:53 +0530126#define ASYNC_TRAILER_EVENT_TYPE_MASK 0xFF
127
128/* iSCSI events */
Jayamohan Kallickala3d313e2014-08-08 01:00:00 -0400129#define ASYNC_EVENT_NEW_ISCSI_TGT_DISC 0x4
130#define ASYNC_EVENT_NEW_ISCSI_CONN 0x5
131#define ASYNC_EVENT_NEW_TCP_CONN 0x7
132
Jitendra Bhivare53aefe22016-01-20 14:10:53 +0530133/* SLI events */
134#define ASYNC_SLI_EVENT_TYPE_MISCONFIGURED 0x9
135#define ASYNC_SLI_LINK_EFFECT_VALID(le) (le & 0x80)
136#define ASYNC_SLI_LINK_EFFECT_SEV(le) ((le >> 1) & 0x03)
137#define ASYNC_SLI_LINK_EFFECT_STATE(le) (le & 0x01)
138
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530139struct be_async_event_trailer {
140 u32 code;
141};
142
143enum {
144 ASYNC_EVENT_LINK_DOWN = 0x0,
Jayamohan Kallickal6ea9b3b2013-04-05 20:38:30 -0700145 ASYNC_EVENT_LINK_UP = 0x1,
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530146};
147
148/**
149 * When the event code of an async trailer is link-state, the mcc_compl
150 * must be interpreted as follows
151 */
152struct be_async_event_link_state {
153 u8 physical_port;
154 u8 port_link_status;
Jitendra Bhivare9c4f8b02016-01-20 14:10:59 +0530155/**
156 * ASYNC_EVENT_LINK_DOWN 0x0
157 * ASYNC_EVENT_LINK_UP 0x1
158 * ASYNC_EVENT_LINK_LOGICAL_DOWN 0x2
159 * ASYNC_EVENT_LINK_LOGICAL_UP 0x3
160 */
161#define BE_ASYNC_LINK_UP_MASK 0x01
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530162 u8 port_duplex;
Jitendra Bhivare9c4f8b02016-01-20 14:10:59 +0530163 u8 port_speed;
Jitendra Bhivare048084c2016-01-20 14:10:58 +0530164/* BE2ISCSI_LINK_SPEED_ZERO 0x00 - no link */
165#define BE2ISCSI_LINK_SPEED_10MBPS 0x01
166#define BE2ISCSI_LINK_SPEED_100MBPS 0x02
167#define BE2ISCSI_LINK_SPEED_1GBPS 0x03
168#define BE2ISCSI_LINK_SPEED_10GBPS 0x04
169#define BE2ISCSI_LINK_SPEED_25GBPS 0x06
170#define BE2ISCSI_LINK_SPEED_40GBPS 0x07
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530171 u8 port_fault;
Jitendra Bhivare048084c2016-01-20 14:10:58 +0530172 u8 event_reason;
173 u16 qos_link_speed;
174 u32 event_tag;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530175 struct be_async_event_trailer trailer;
176} __packed;
177
Jitendra Bhivare53aefe22016-01-20 14:10:53 +0530178/**
179 * When async-trailer is SLI event, mcc_compl is interpreted as
180 */
181struct be_async_event_sli {
182 u32 event_data1;
183 u32 event_data2;
184 u32 reserved;
185 u32 trailer;
186} __packed;
187
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530188struct be_mcc_mailbox {
189 struct be_mcc_wrb wrb;
190 struct be_mcc_compl compl;
191};
192
193/* Type of subsystems supported by FW */
194#define CMD_SUBSYSTEM_COMMON 0x1
195#define CMD_SUBSYSTEM_ISCSI 0x2
196#define CMD_SUBSYSTEM_ETH 0x3
197#define CMD_SUBSYSTEM_ISCSI_INI 0x6
198#define CMD_COMMON_TCP_UPLOAD 0x1
199
200/**
201 * List of common opcodes subsystem CMD_SUBSYSTEM_COMMON
202 * These opcodes are unique for each subsystem defined above
203 */
204#define OPCODE_COMMON_CQ_CREATE 12
205#define OPCODE_COMMON_EQ_CREATE 13
Jayamohan Kallickal457ff3b2010-07-22 04:16:00 +0530206#define OPCODE_COMMON_MCC_CREATE 21
Jitendra Bhivare53aefe22016-01-20 14:10:53 +0530207#define OPCODE_COMMON_MCC_CREATE_EXT 90
Jayamohan Kallickal15a90fe2013-09-28 15:35:38 -0700208#define OPCODE_COMMON_ADD_TEMPLATE_HEADER_BUFFERS 24
209#define OPCODE_COMMON_REMOVE_TEMPLATE_HEADER_BUFFERS 25
Jayamohan Kallickal457ff3b2010-07-22 04:16:00 +0530210#define OPCODE_COMMON_GET_CNTL_ATTRIBUTES 32
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530211#define OPCODE_COMMON_GET_FW_VERSION 35
212#define OPCODE_COMMON_MODIFY_EQ_DELAY 41
213#define OPCODE_COMMON_FIRMWARE_CONFIG 42
Jayamohan Kallickal457ff3b2010-07-22 04:16:00 +0530214#define OPCODE_COMMON_MCC_DESTROY 53
215#define OPCODE_COMMON_CQ_DESTROY 54
216#define OPCODE_COMMON_EQ_DESTROY 55
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530217#define OPCODE_COMMON_QUERY_FIRMWARE_CONFIG 58
218#define OPCODE_COMMON_FUNCTION_RESET 61
Jitendra Bhivare53aefe22016-01-20 14:10:53 +0530219#define OPCODE_COMMON_GET_PORT_NAME 77
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530220
221/**
222 * LIST of opcodes that are common between Initiator and Target
223 * used by CMD_SUBSYSTEM_ISCSI
224 * These opcodes are unique for each subsystem defined above
225 */
226#define OPCODE_COMMON_ISCSI_CFG_POST_SGL_PAGES 2
227#define OPCODE_COMMON_ISCSI_CFG_REMOVE_SGL_PAGES 3
228#define OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG 7
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530229#define OPCODE_COMMON_ISCSI_NTWK_SET_VLAN 14
Mike Christie0e438952012-04-03 23:41:51 -0500230#define OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR 17
231#define OPCODE_COMMON_ISCSI_NTWK_REL_STATELESS_IP_ADDR 18
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530232#define OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR 21
233#define OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY 22
234#define OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY 23
235#define OPCODE_COMMON_ISCSI_NTWK_GET_ALL_IF_ID 24
236#define OPCODE_COMMON_ISCSI_NTWK_GET_IF_INFO 25
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530237#define OPCODE_COMMON_ISCSI_SET_FRAGNUM_BITS_FOR_SGL_CRA 61
238#define OPCODE_COMMON_ISCSI_DEFQ_CREATE 64
Jayamohan Kallickal457ff3b2010-07-22 04:16:00 +0530239#define OPCODE_COMMON_ISCSI_DEFQ_DESTROY 65
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530240#define OPCODE_COMMON_ISCSI_WRBQ_CREATE 66
Jayamohan Kallickal457ff3b2010-07-22 04:16:00 +0530241#define OPCODE_COMMON_ISCSI_WRBQ_DESTROY 67
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530242
243struct be_cmd_req_hdr {
244 u8 opcode; /* dword 0 */
245 u8 subsystem; /* dword 0 */
246 u8 port_number; /* dword 0 */
247 u8 domain; /* dword 0 */
248 u32 timeout; /* dword 1 */
249 u32 request_length; /* dword 2 */
John Soni Joseeaae5262012-10-20 04:43:44 +0530250 u8 version; /* dword 3 */
251 u8 rsvd0[3]; /* dword 3 */
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530252};
253
254struct be_cmd_resp_hdr {
255 u32 info; /* dword 0 */
256 u32 status; /* dword 1 */
257 u32 response_length; /* dword 2 */
258 u32 actual_resp_len; /* dword 3 */
259};
260
261struct phys_addr {
262 u32 lo;
263 u32 hi;
264};
265
Jayamohan Kallickal15a90fe2013-09-28 15:35:38 -0700266struct virt_addr {
267 u32 lo;
268 u32 hi;
269};
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530270/**************************
271 * BE Command definitions *
272 **************************/
273
274/**
275 * Pseudo amap definition in which each bit of the actual structure is defined
276 * as a byte - used to calculate offset/shift/mask of each field
277 */
278struct amap_eq_context {
279 u8 cidx[13]; /* dword 0 */
280 u8 rsvd0[3]; /* dword 0 */
281 u8 epidx[13]; /* dword 0 */
282 u8 valid; /* dword 0 */
283 u8 rsvd1; /* dword 0 */
284 u8 size; /* dword 0 */
285 u8 pidx[13]; /* dword 1 */
286 u8 rsvd2[3]; /* dword 1 */
287 u8 pd[10]; /* dword 1 */
288 u8 count[3]; /* dword 1 */
289 u8 solevent; /* dword 1 */
290 u8 stalled; /* dword 1 */
291 u8 armed; /* dword 1 */
292 u8 rsvd3[4]; /* dword 2 */
293 u8 func[8]; /* dword 2 */
294 u8 rsvd4; /* dword 2 */
295 u8 delaymult[10]; /* dword 2 */
296 u8 rsvd5[2]; /* dword 2 */
297 u8 phase[2]; /* dword 2 */
298 u8 nodelay; /* dword 2 */
299 u8 rsvd6[4]; /* dword 2 */
300 u8 rsvd7[32]; /* dword 3 */
301} __packed;
302
303struct be_cmd_req_eq_create {
304 struct be_cmd_req_hdr hdr; /* dw[4] */
305 u16 num_pages; /* sword */
306 u16 rsvd0; /* sword */
307 u8 context[sizeof(struct amap_eq_context) / 8]; /* dw[4] */
308 struct phys_addr pages[8];
309} __packed;
310
311struct be_cmd_resp_eq_create {
312 struct be_cmd_resp_hdr resp_hdr;
313 u16 eq_id; /* sword */
314 u16 rsvd0; /* sword */
315} __packed;
316
Jayamohan Kallickal73af08e2014-05-05 21:41:26 -0400317struct be_set_eqd {
318 u32 eq_id;
319 u32 phase;
320 u32 delay_multiplier;
321} __packed;
322
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530323struct mgmt_chap_format {
324 u32 flags;
325 u8 intr_chap_name[256];
326 u8 intr_secret[16];
327 u8 target_chap_name[256];
328 u8 target_secret[16];
329 u16 intr_chap_name_length;
330 u16 intr_secret_length;
331 u16 target_chap_name_length;
332 u16 target_secret_length;
333} __packed;
334
335struct mgmt_auth_method_format {
336 u8 auth_method_type;
337 u8 padding[3];
338 struct mgmt_chap_format chap;
339} __packed;
340
John Soni Jose3f4134c2015-04-25 08:18:13 +0530341struct be_cmd_req_logout_fw_sess {
342 struct be_cmd_req_hdr hdr; /* dw[4] */
343 uint32_t session_handle;
344} __packed;
345
346struct be_cmd_resp_logout_fw_sess {
347 struct be_cmd_resp_hdr hdr; /* dw[4] */
348#define BEISCSI_MGMT_SESSION_CLOSE 0x20
349 uint32_t session_status;
350} __packed;
351
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530352struct mgmt_conn_login_options {
353 u8 flags;
354 u8 header_digest;
355 u8 data_digest;
356 u8 rsvd0;
357 u32 max_recv_datasegment_len_ini;
358 u32 max_recv_datasegment_len_tgt;
359 u32 tcp_mss;
360 u32 tcp_window_size;
361 struct mgmt_auth_method_format auth_data;
362} __packed;
363
Mike Christie0e438952012-04-03 23:41:51 -0500364struct ip_addr_format {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530365 u16 size_of_structure;
366 u8 reserved;
367 u8 ip_type;
Mike Christie0e438952012-04-03 23:41:51 -0500368 u8 addr[16];
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530369 u32 rsvd0;
370} __packed;
371
Mike Christie0e438952012-04-03 23:41:51 -0500372struct mgmt_conn_info {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530373 u32 connection_handle;
374 u32 connection_status;
375 u16 src_port;
376 u16 dest_port;
377 u16 dest_port_redirected;
378 u16 cid;
379 u32 estimated_throughput;
Mike Christie0e438952012-04-03 23:41:51 -0500380 struct ip_addr_format src_ipaddr;
381 struct ip_addr_format dest_ipaddr;
382 struct ip_addr_format dest_ipaddr_redirected;
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530383 struct mgmt_conn_login_options negotiated_login_options;
384} __packed;
385
386struct mgmt_session_login_options {
387 u8 flags;
388 u8 error_recovery_level;
389 u16 rsvd0;
390 u32 first_burst_length;
391 u32 max_burst_length;
392 u16 max_connections;
393 u16 max_outstanding_r2t;
394 u16 default_time2wait;
395 u16 default_time2retain;
396} __packed;
397
398struct mgmt_session_info {
399 u32 session_handle;
400 u32 status;
401 u8 isid[6];
402 u16 tsih;
403 u32 session_flags;
404 u16 conn_count;
405 u16 pad;
406 u8 target_name[224];
407 u8 initiator_iscsiname[224];
408 struct mgmt_session_login_options negotiated_login_options;
409 struct mgmt_conn_info conn_list[1];
410} __packed;
411
Mike Christie0e438952012-04-03 23:41:51 -0500412struct be_cmd_get_session_req {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530413 struct be_cmd_req_hdr hdr;
414 u32 session_handle;
415} __packed;
416
Mike Christie0e438952012-04-03 23:41:51 -0500417struct be_cmd_get_session_resp {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530418 struct be_cmd_resp_hdr hdr;
419 struct mgmt_session_info session_info;
420} __packed;
421
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530422struct mac_addr {
Mike Christie0e438952012-04-03 23:41:51 -0500423 u16 size_of_structure;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530424 u8 addr[ETH_ALEN];
425} __packed;
426
Mike Christie0e438952012-04-03 23:41:51 -0500427struct be_cmd_get_boot_target_req {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530428 struct be_cmd_req_hdr hdr;
429} __packed;
430
Mike Christie0e438952012-04-03 23:41:51 -0500431struct be_cmd_get_boot_target_resp {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530432 struct be_cmd_resp_hdr hdr;
433 u32 boot_session_count;
434 int boot_session_handle;
435};
436
John Soni Jose9aef4202012-08-20 23:00:08 +0530437struct be_cmd_reopen_session_req {
438 struct be_cmd_req_hdr hdr;
439#define BE_REOPEN_ALL_SESSIONS 0x00
440#define BE_REOPEN_BOOT_SESSIONS 0x01
441#define BE_REOPEN_A_SESSION 0x02
442 u16 reopen_type;
443 u16 rsvd;
444 u32 session_handle;
445} __packed;
446
447struct be_cmd_reopen_session_resp {
448 struct be_cmd_resp_hdr hdr;
449 u32 rsvd;
450 u32 session_handle;
451} __packed;
452
453
Mike Christie0e438952012-04-03 23:41:51 -0500454struct be_cmd_mac_query_req {
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530455 struct be_cmd_req_hdr hdr;
456 u8 type;
457 u8 permanent;
458 u16 if_id;
459} __packed;
460
Mike Christie0e438952012-04-03 23:41:51 -0500461struct be_cmd_get_mac_resp {
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530462 struct be_cmd_resp_hdr hdr;
463 struct mac_addr mac;
464};
465
Mike Christie0e438952012-04-03 23:41:51 -0500466struct be_ip_addr_subnet_format {
467 u16 size_of_structure;
468 u8 ip_type;
469 u8 ipv6_prefix_length;
470 u8 addr[16];
471 u8 subnet_mask[16];
472 u32 rsvd0;
473} __packed;
474
475struct be_cmd_get_if_info_req {
476 struct be_cmd_req_hdr hdr;
477 u32 interface_hndl;
478 u32 ip_type;
479} __packed;
480
481struct be_cmd_get_if_info_resp {
482 struct be_cmd_req_hdr hdr;
483 u32 interface_hndl;
484 u32 vlan_priority;
485 u32 ip_addr_count;
486 u32 dhcp_state;
487 struct be_ip_addr_subnet_format ip_addr;
488} __packed;
489
490struct be_ip_addr_record {
491 u32 action;
492 u32 interface_hndl;
493 struct be_ip_addr_subnet_format ip_addr;
494 u32 status;
495} __packed;
496
497struct be_ip_addr_record_params {
498 u32 record_entry_count;
499 struct be_ip_addr_record ip_record;
500} __packed;
501
502struct be_cmd_set_ip_addr_req {
503 struct be_cmd_req_hdr hdr;
504 struct be_ip_addr_record_params ip_params;
505} __packed;
506
507
508struct be_cmd_set_dhcp_req {
509 struct be_cmd_req_hdr hdr;
510 u32 interface_hndl;
511 u32 ip_type;
512 u32 flags;
513 u32 retry_count;
514} __packed;
515
516struct be_cmd_rel_dhcp_req {
517 struct be_cmd_req_hdr hdr;
518 u32 interface_hndl;
519 u32 ip_type;
520} __packed;
521
522struct be_cmd_set_def_gateway_req {
523 struct be_cmd_req_hdr hdr;
524 u32 action;
525 struct ip_addr_format ip_addr;
526} __packed;
527
528struct be_cmd_get_def_gateway_req {
529 struct be_cmd_req_hdr hdr;
530 u32 ip_type;
531} __packed;
532
533struct be_cmd_get_def_gateway_resp {
534 struct be_cmd_req_hdr hdr;
535 struct ip_addr_format ip_addr;
536} __packed;
537
John Soni Jose6f722382012-08-20 23:00:43 +0530538#define BEISCSI_VLAN_DISABLE 0xFFFF
539struct be_cmd_set_vlan_req {
540 struct be_cmd_req_hdr hdr;
541 u32 interface_hndl;
542 u32 vlan_priority;
543} __packed;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530544/******************** Create CQ ***************************/
545/**
546 * Pseudo amap definition in which each bit of the actual structure is defined
547 * as a byte - used to calculate offset/shift/mask of each field
548 */
549struct amap_cq_context {
550 u8 cidx[11]; /* dword 0 */
551 u8 rsvd0; /* dword 0 */
552 u8 coalescwm[2]; /* dword 0 */
553 u8 nodelay; /* dword 0 */
554 u8 epidx[11]; /* dword 0 */
555 u8 rsvd1; /* dword 0 */
556 u8 count[2]; /* dword 0 */
557 u8 valid; /* dword 0 */
558 u8 solevent; /* dword 0 */
559 u8 eventable; /* dword 0 */
560 u8 pidx[11]; /* dword 1 */
561 u8 rsvd2; /* dword 1 */
562 u8 pd[10]; /* dword 1 */
563 u8 eqid[8]; /* dword 1 */
564 u8 stalled; /* dword 1 */
565 u8 armed; /* dword 1 */
566 u8 rsvd3[4]; /* dword 2 */
567 u8 func[8]; /* dword 2 */
568 u8 rsvd4[20]; /* dword 2 */
569 u8 rsvd5[32]; /* dword 3 */
570} __packed;
571
John Soni Joseeaae5262012-10-20 04:43:44 +0530572struct amap_cq_context_v2 {
573 u8 rsvd0[12]; /* dword 0 */
574 u8 coalescwm[2]; /* dword 0 */
575 u8 nodelay; /* dword 0 */
576 u8 rsvd1[12]; /* dword 0 */
577 u8 count[2]; /* dword 0 */
578 u8 valid; /* dword 0 */
579 u8 rsvd2; /* dword 0 */
580 u8 eventable; /* dword 0 */
581 u8 eqid[16]; /* dword 1 */
582 u8 rsvd3[15]; /* dword 1 */
583 u8 armed; /* dword 1 */
584 u8 cqecount[16];/* dword 2 */
585 u8 rsvd4[16]; /* dword 2 */
586 u8 rsvd5[32]; /* dword 3 */
587};
588
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530589struct be_cmd_req_cq_create {
590 struct be_cmd_req_hdr hdr;
591 u16 num_pages;
John Soni Joseeaae5262012-10-20 04:43:44 +0530592 u8 page_size;
593 u8 rsvd0;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530594 u8 context[sizeof(struct amap_cq_context) / 8];
595 struct phys_addr pages[4];
596} __packed;
597
598struct be_cmd_resp_cq_create {
599 struct be_cmd_resp_hdr hdr;
600 u16 cq_id;
601 u16 rsvd0;
602} __packed;
603
604/******************** Create MCCQ ***************************/
605/**
606 * Pseudo amap definition in which each bit of the actual structure is defined
607 * as a byte - used to calculate offset/shift/mask of each field
608 */
609struct amap_mcc_context {
610 u8 con_index[14];
611 u8 rsvd0[2];
612 u8 ring_size[4];
613 u8 fetch_wrb;
614 u8 fetch_r2t;
615 u8 cq_id[10];
616 u8 prod_index[14];
617 u8 fid[8];
618 u8 pdid[9];
619 u8 valid;
620 u8 rsvd1[32];
621 u8 rsvd2[32];
622} __packed;
623
Jitendra Bhivare53aefe22016-01-20 14:10:53 +0530624struct be_cmd_req_mcc_create_ext {
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530625 struct be_cmd_req_hdr hdr;
626 u16 num_pages;
627 u16 rsvd0;
Jitendra Bhivare53aefe22016-01-20 14:10:53 +0530628 u32 async_evt_bitmap;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530629 u8 context[sizeof(struct amap_mcc_context) / 8];
630 struct phys_addr pages[8];
631} __packed;
632
633struct be_cmd_resp_mcc_create {
634 struct be_cmd_resp_hdr hdr;
635 u16 id;
636 u16 rsvd0;
637} __packed;
638
639/******************** Q Destroy ***************************/
640/* Type of Queue to be destroyed */
641enum {
642 QTYPE_EQ = 1,
643 QTYPE_CQ,
644 QTYPE_MCCQ,
645 QTYPE_WRBQ,
646 QTYPE_DPDUQ,
647 QTYPE_SGL
648};
649
650struct be_cmd_req_q_destroy {
651 struct be_cmd_req_hdr hdr;
652 u16 id;
653 u16 bypass_flush; /* valid only for rx q destroy */
654} __packed;
655
656struct macaddr {
657 u8 byte[ETH_ALEN];
658};
659
660struct be_cmd_req_mcast_mac_config {
661 struct be_cmd_req_hdr hdr;
662 u16 num_mac;
663 u8 promiscuous;
664 u8 interface_id;
665 struct macaddr mac[32];
666} __packed;
667
668static inline void *embedded_payload(struct be_mcc_wrb *wrb)
669{
670 return wrb->payload.embedded_payload;
671}
672
673static inline struct be_sge *nonembedded_sgl(struct be_mcc_wrb *wrb)
674{
675 return &wrb->payload.sgl[0];
676}
677
678/******************** Modify EQ Delay *******************/
679struct be_cmd_req_modify_eq_delay {
680 struct be_cmd_req_hdr hdr;
Jayamohan Kallickal39033412014-08-08 00:59:58 -0400681 __le32 num_eq;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530682 struct {
Jayamohan Kallickal39033412014-08-08 00:59:58 -0400683 __le32 eq_id;
684 __le32 phase;
685 __le32 delay_multiplier;
Jayamohan Kallickal73af08e2014-05-05 21:41:26 -0400686 } delay[MAX_CPUS];
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530687} __packed;
688
689/******************** Get MAC ADDR *******************/
690
Mike Christie0e438952012-04-03 23:41:51 -0500691struct be_cmd_get_nic_conf_resp {
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530692 struct be_cmd_resp_hdr hdr;
693 u32 nic_port_count;
694 u32 speed;
695 u32 max_speed;
696 u32 link_state;
697 u32 max_frame_size;
698 u16 size_of_structure;
Jitendra Bhivare9c4f8b02016-01-20 14:10:59 +0530699 u8 mac_address[ETH_ALEN];
700} __packed;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530701
John Soni Jose21771992012-04-03 23:41:49 -0500702#define BEISCSI_ALIAS_LEN 32
703
704struct be_cmd_hba_name {
705 struct be_cmd_req_hdr hdr;
706 u16 flags;
707 u16 rsvd0;
708 u8 initiator_name[ISCSI_NAME_LEN];
709 u8 initiator_alias[BEISCSI_ALIAS_LEN];
710} __packed;
711
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530712int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl,
713 struct be_queue_info *eq, int eq_delay);
714
715int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl,
716 struct be_queue_info *cq, struct be_queue_info *eq,
717 bool sol_evts, bool no_delay,
718 int num_cqe_dma_coalesce);
719
720int beiscsi_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q,
721 int type);
Jayamohan Kallickal35e66012009-10-23 11:53:49 +0530722int beiscsi_cmd_mccq_create(struct beiscsi_hba *phba,
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530723 struct be_queue_info *mccq,
724 struct be_queue_info *cq);
725
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530726int be_poll_mcc(struct be_ctrl_info *ctrl);
Jayamohan Kallickal03a12312010-07-22 04:17:16 +0530727int mgmt_check_supported_fw(struct be_ctrl_info *ctrl,
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530728 struct beiscsi_hba *phba);
John Soni Jose21771992012-04-03 23:41:49 -0500729unsigned int be_cmd_get_initname(struct beiscsi_hba *phba);
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530730
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530731void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag);
John Soni Josee175def2012-10-20 04:45:40 +0530732
Jayamohan Kallickal73af08e2014-05-05 21:41:26 -0400733int be_cmd_modify_eq_delay(struct beiscsi_hba *phba, struct be_set_eqd *,
734 int num);
John Soni Josee175def2012-10-20 04:45:40 +0530735int beiscsi_mccq_compl(struct beiscsi_hba *phba,
Jayamohan Kallickal1957aa72014-01-29 02:16:39 -0500736 uint32_t tag, struct be_mcc_wrb **wrb,
737 struct be_dma_mem *mbx_cmd_mem);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530738/*ISCSI Functuions */
739int be_cmd_fw_initialize(struct be_ctrl_info *ctrl);
Jayamohan Kallickal0283fbb2013-04-05 20:38:21 -0700740int be_cmd_fw_uninit(struct be_ctrl_info *ctrl);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530741
742struct be_mcc_wrb *wrb_from_mbox(struct be_dma_mem *mbox_mem);
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530743struct be_mcc_wrb *wrb_from_mccq(struct beiscsi_hba *phba);
Jitendra Bhivarecdde6682016-01-20 14:10:47 +0530744int be_mcc_notify_wait(struct beiscsi_hba *phba, unsigned int tag);
745void be_mcc_notify(struct beiscsi_hba *phba, unsigned int tag);
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530746unsigned int alloc_mcc_tag(struct beiscsi_hba *phba);
Jitendra Bhivare53aefe22016-01-20 14:10:53 +0530747void beiscsi_process_async_event(struct beiscsi_hba *phba,
748 struct be_mcc_compl *compl);
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530749int be_mcc_compl_process_isr(struct be_ctrl_info *ctrl,
750 struct be_mcc_compl *compl);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530751
752int be_mbox_notify(struct be_ctrl_info *ctrl);
753
754int be_cmd_create_default_pdu_queue(struct be_ctrl_info *ctrl,
755 struct be_queue_info *cq,
756 struct be_queue_info *dq, int length,
Jayamohan Kallickal8a86e832013-09-28 15:35:45 -0700757 int entry_size, uint8_t is_header,
758 uint8_t ulp_num);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530759
Jayamohan Kallickal15a90fe2013-09-28 15:35:38 -0700760int be_cmd_iscsi_post_template_hdr(struct be_ctrl_info *ctrl,
761 struct be_dma_mem *q_mem);
762
763int be_cmd_iscsi_remove_template_hdr(struct be_ctrl_info *ctrl);
764
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530765int be_cmd_iscsi_post_sgl_pages(struct be_ctrl_info *ctrl,
766 struct be_dma_mem *q_mem, u32 page_offset,
767 u32 num_pages);
768
Jayamohan Kallickale5285862011-10-07 19:31:08 -0500769int beiscsi_cmd_reset_function(struct beiscsi_hba *phba);
770
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530771int be_cmd_wrbq_create(struct be_ctrl_info *ctrl, struct be_dma_mem *q_mem,
Jayamohan Kallickal4eea99d2013-09-28 15:35:48 -0700772 struct be_queue_info *wrbq,
773 struct hwi_wrb_context *pwrb_context,
774 uint8_t ulp_num);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530775
John Soni Jose6f722382012-08-20 23:00:43 +0530776/* Configuration Functions */
777int be_cmd_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag);
778
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530779struct be_default_pdu_context {
780 u32 dw[4];
781} __packed;
782
783struct amap_be_default_pdu_context {
784 u8 dbuf_cindex[13]; /* dword 0 */
785 u8 rsvd0[3]; /* dword 0 */
786 u8 ring_size[4]; /* dword 0 */
787 u8 ring_state[4]; /* dword 0 */
788 u8 rsvd1[8]; /* dword 0 */
789 u8 dbuf_pindex[13]; /* dword 1 */
790 u8 rsvd2; /* dword 1 */
791 u8 pci_func_id[8]; /* dword 1 */
792 u8 rx_pdid[9]; /* dword 1 */
793 u8 rx_pdid_valid; /* dword 1 */
794 u8 default_buffer_size[16]; /* dword 2 */
795 u8 cq_id_recv[10]; /* dword 2 */
796 u8 rx_pdid_not_valid; /* dword 2 */
797 u8 rsvd3[5]; /* dword 2 */
798 u8 rsvd4[32]; /* dword 3 */
799} __packed;
800
Jayamohan Kallickalef9e1b92013-04-05 20:38:27 -0700801struct amap_default_pdu_context_ext {
802 u8 rsvd0[16]; /* dword 0 */
803 u8 ring_size[4]; /* dword 0 */
804 u8 rsvd1[12]; /* dword 0 */
805 u8 rsvd2[22]; /* dword 1 */
806 u8 rx_pdid[9]; /* dword 1 */
807 u8 rx_pdid_valid; /* dword 1 */
808 u8 default_buffer_size[16]; /* dword 2 */
809 u8 cq_id_recv[16]; /* dword 2 */
810 u8 rsvd3[32]; /* dword 3 */
811} __packed;
812
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530813struct be_defq_create_req {
814 struct be_cmd_req_hdr hdr;
815 u16 num_pages;
816 u8 ulp_num;
Jayamohan Kallickal8a86e832013-09-28 15:35:45 -0700817#define BEISCSI_DUAL_ULP_AWARE_BIT 0 /* Byte 3 - Bit 0 */
818#define BEISCSI_BIND_Q_TO_ULP_BIT 1 /* Byte 3 - Bit 1 */
819 u8 dua_feature;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530820 struct be_default_pdu_context context;
821 struct phys_addr pages[8];
822} __packed;
823
824struct be_defq_create_resp {
825 struct be_cmd_req_hdr hdr;
826 u16 id;
Jayamohan Kallickal8a86e832013-09-28 15:35:45 -0700827 u8 rsvd0;
828 u8 ulp_num;
829 u32 doorbell_offset;
830 u16 register_set;
831 u16 doorbell_format;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530832} __packed;
833
Jayamohan Kallickal15a90fe2013-09-28 15:35:38 -0700834struct be_post_template_pages_req {
835 struct be_cmd_req_hdr hdr;
836 u16 num_pages;
837#define BEISCSI_TEMPLATE_HDR_TYPE_ISCSI 0x1
838 u16 type;
839 struct phys_addr scratch_pa;
840 struct virt_addr scratch_va;
841 struct virt_addr pages_va;
842 struct phys_addr pages[16];
843} __packed;
844
845struct be_remove_template_pages_req {
846 struct be_cmd_req_hdr hdr;
847 u16 type;
848 u16 rsvd0;
849} __packed;
850
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530851struct be_post_sgl_pages_req {
852 struct be_cmd_req_hdr hdr;
853 u16 num_pages;
854 u16 page_offset;
855 u32 rsvd0;
856 struct phys_addr pages[26];
857 u32 rsvd1;
858} __packed;
859
860struct be_wrbq_create_req {
861 struct be_cmd_req_hdr hdr;
862 u16 num_pages;
863 u8 ulp_num;
Jayamohan Kallickal4eea99d2013-09-28 15:35:48 -0700864 u8 dua_feature;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530865 struct phys_addr pages[8];
866} __packed;
867
868struct be_wrbq_create_resp {
869 struct be_cmd_resp_hdr resp_hdr;
870 u16 cid;
Jayamohan Kallickal4eea99d2013-09-28 15:35:48 -0700871 u8 rsvd0;
872 u8 ulp_num;
873 u32 doorbell_offset;
874 u16 register_set;
875 u16 doorbell_format;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530876} __packed;
877
878#define SOL_CID_MASK 0x0000FFC0
879#define SOL_CODE_MASK 0x0000003F
880#define SOL_WRB_INDEX_MASK 0x00FF0000
881#define SOL_CMD_WND_MASK 0xFF000000
882#define SOL_RES_CNT_MASK 0x7FFFFFFF
883#define SOL_EXP_CMD_SN_MASK 0xFFFFFFFF
884#define SOL_HW_STS_MASK 0x000000FF
885#define SOL_STS_MASK 0x0000FF00
886#define SOL_RESP_MASK 0x00FF0000
887#define SOL_FLAGS_MASK 0x7F000000
888#define SOL_S_MASK 0x80000000
889
890struct sol_cqe {
891 u32 dw[4];
892};
893
894struct amap_sol_cqe {
895 u8 hw_sts[8]; /* dword 0 */
896 u8 i_sts[8]; /* dword 0 */
897 u8 i_resp[8]; /* dword 0 */
898 u8 i_flags[7]; /* dword 0 */
899 u8 s; /* dword 0 */
900 u8 i_exp_cmd_sn[32]; /* dword 1 */
901 u8 code[6]; /* dword 2 */
902 u8 cid[10]; /* dword 2 */
903 u8 wrb_index[8]; /* dword 2 */
904 u8 i_cmd_wnd[8]; /* dword 2 */
905 u8 i_res_cnt[31]; /* dword 3 */
906 u8 valid; /* dword 3 */
907} __packed;
908
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530909#define SOL_ICD_INDEX_MASK 0x0003FFC0
910struct amap_sol_cqe_ring {
911 u8 hw_sts[8]; /* dword 0 */
912 u8 i_sts[8]; /* dword 0 */
913 u8 i_resp[8]; /* dword 0 */
914 u8 i_flags[7]; /* dword 0 */
915 u8 s; /* dword 0 */
916 u8 i_exp_cmd_sn[32]; /* dword 1 */
917 u8 code[6]; /* dword 2 */
918 u8 icd_index[12]; /* dword 2 */
919 u8 rsvd[6]; /* dword 2 */
920 u8 i_cmd_wnd[8]; /* dword 2 */
921 u8 i_res_cnt[31]; /* dword 3 */
922 u8 valid; /* dword 3 */
923} __packed;
924
John Soni Jose73133262012-10-20 04:44:49 +0530925struct amap_sol_cqe_v2 {
926 u8 hw_sts[8]; /* dword 0 */
927 u8 i_sts[8]; /* dword 0 */
928 u8 wrb_index[16]; /* dword 0 */
929 u8 i_exp_cmd_sn[32]; /* dword 1 */
930 u8 code[6]; /* dword 2 */
931 u8 cmd_cmpl; /* dword 2 */
932 u8 rsvd0; /* dword 2 */
933 u8 i_cmd_wnd[8]; /* dword 2 */
934 u8 cid[13]; /* dword 2 */
935 u8 u; /* dword 2 */
936 u8 o; /* dword 2 */
937 u8 s; /* dword 2 */
938 u8 i_res_cnt[31]; /* dword 3 */
939 u8 valid; /* dword 3 */
940} __packed;
941
942struct common_sol_cqe {
943 u32 exp_cmdsn;
944 u32 res_cnt;
945 u16 wrb_index;
946 u16 cid;
947 u8 hw_sts;
948 u8 cmd_wnd;
949 u8 res_flag; /* the s feild of structure */
950 u8 i_resp; /* for skh if cmd_complete is set then i_sts is response */
951 u8 i_flags; /* for skh or the u and o feilds */
952 u8 i_sts; /* for skh if cmd_complete is not-set then i_sts is status */
953};
954
955/*** iSCSI ack/driver message completions ***/
956struct amap_it_dmsg_cqe {
957 u8 ack_num[32]; /* DWORD 0 */
958 u8 pdu_bytes_rcvd[32]; /* DWORD 1 */
959 u8 code[6]; /* DWORD 2 */
960 u8 cid[10]; /* DWORD 2 */
961 u8 wrb_idx[8]; /* DWORD 2 */
962 u8 rsvd0[8]; /* DWORD 2*/
963 u8 rsvd1[31]; /* DWORD 3*/
964 u8 valid; /* DWORD 3 */
965} __packed;
966
967struct amap_it_dmsg_cqe_v2 {
968 u8 ack_num[32]; /* DWORD 0 */
969 u8 pdu_bytes_rcvd[32]; /* DWORD 1 */
970 u8 code[6]; /* DWORD 2 */
971 u8 rsvd0[10]; /* DWORD 2 */
972 u8 wrb_idx[16]; /* DWORD 2 */
973 u8 rsvd1[16]; /* DWORD 3 */
974 u8 cid[13]; /* DWORD 3 */
975 u8 rsvd2[2]; /* DWORD 3 */
976 u8 valid; /* DWORD 3 */
977} __packed;
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530978
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530979
980/**
981 * Post WRB Queue Doorbell Register used by the host Storage
982 * stack to notify the
983 * controller of a posted Work Request Block
984 */
Jayamohan Kallickalef9e1b92013-04-05 20:38:27 -0700985#define DB_WRB_POST_CID_MASK 0xFFFF /* bits 0 - 16 */
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530986#define DB_DEF_PDU_WRB_INDEX_MASK 0xFF /* bits 0 - 9 */
987
988#define DB_DEF_PDU_WRB_INDEX_SHIFT 16
989#define DB_DEF_PDU_NUM_POSTED_SHIFT 24
990
991struct fragnum_bits_for_sgl_cra_in {
992 struct be_cmd_req_hdr hdr;
993 u32 num_bits;
994} __packed;
995
996struct iscsi_cleanup_req {
997 struct be_cmd_req_hdr hdr;
998 u16 chute;
999 u8 hdr_ring_id;
1000 u8 data_ring_id;
1001
1002} __packed;
1003
1004struct eq_delay {
1005 u32 eq_id;
1006 u32 phase;
1007 u32 delay_multiplier;
1008} __packed;
1009
1010struct be_eq_delay_params_in {
1011 struct be_cmd_req_hdr hdr;
1012 u32 num_eq;
1013 struct eq_delay delay[8];
1014} __packed;
1015
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301016struct tcp_connect_and_offload_in {
1017 struct be_cmd_req_hdr hdr;
Mike Christie0e438952012-04-03 23:41:51 -05001018 struct ip_addr_format ip_address;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301019 u16 tcp_port;
1020 u16 cid;
1021 u16 cq_id;
1022 u16 defq_id;
1023 struct phys_addr dataout_template_pa;
1024 u16 hdr_ring_id;
1025 u16 data_ring_id;
1026 u8 do_offload;
1027 u8 rsvd0[3];
1028} __packed;
1029
Jayamohan Kallickalb3c202d2014-05-05 21:41:27 -04001030struct tcp_connect_and_offload_in_v1 {
1031 struct be_cmd_req_hdr hdr;
1032 struct ip_addr_format ip_address;
1033 u16 tcp_port;
1034 u16 cid;
1035 u16 cq_id;
1036 u16 defq_id;
1037 struct phys_addr dataout_template_pa;
1038 u16 hdr_ring_id;
1039 u16 data_ring_id;
1040 u8 do_offload;
1041 u8 ifd_state;
1042 u8 rsvd0[2];
1043 u16 tcp_window_size;
1044 u8 tcp_window_scale_count;
1045 u8 rsvd1;
1046 u32 tcp_mss:24;
1047 u8 rsvd2;
1048} __packed;
1049
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301050struct tcp_connect_and_offload_out {
1051 struct be_cmd_resp_hdr hdr;
1052 u32 connection_handle;
1053 u16 cid;
1054 u16 rsvd0;
1055
1056} __packed;
1057
1058struct be_mcc_wrb_context {
1059 struct MCC_WRB *wrb;
1060 int *users_final_status;
1061} __packed;
1062
Jayamohan Kallickale08b3c82014-01-29 02:16:42 -05001063#define DB_DEF_PDU_RING_ID_MASK 0x3FFF /* bits 0 - 13 */
1064#define DB_DEF_PDU_CQPROC_MASK 0x3FFF /* bits 16 - 29 */
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301065#define DB_DEF_PDU_REARM_SHIFT 14
1066#define DB_DEF_PDU_EVENT_SHIFT 15
1067#define DB_DEF_PDU_CQPROC_SHIFT 16
1068
1069struct dmsg_cqe {
1070 u32 dw[4];
1071} __packed;
1072
1073struct tcp_upload_params_in {
1074 struct be_cmd_req_hdr hdr;
1075 u16 id;
1076 u16 upload_type;
1077 u32 reset_seq;
1078} __packed;
1079
1080struct tcp_upload_params_out {
1081 u32 dw[32];
1082} __packed;
1083
1084union tcp_upload_params {
1085 struct tcp_upload_params_in request;
1086 struct tcp_upload_params_out response;
1087} __packed;
1088
1089struct be_ulp_fw_cfg {
Jayamohan Kallickal843ae752013-09-28 15:35:44 -07001090#define BEISCSI_ULP_ISCSI_INI_MODE 0x10
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301091 u32 ulp_mode;
1092 u32 etx_base;
1093 u32 etx_count;
1094 u32 sq_base;
1095 u32 sq_count;
1096 u32 rq_base;
1097 u32 rq_count;
1098 u32 dq_base;
1099 u32 dq_count;
1100 u32 lro_base;
1101 u32 lro_count;
1102 u32 icd_base;
1103 u32 icd_count;
1104};
1105
Jayamohan Kallickal843ae752013-09-28 15:35:44 -07001106struct be_ulp_chain_icd {
1107 u32 chain_base;
1108 u32 chain_count;
1109};
1110
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301111struct be_fw_cfg {
1112 struct be_cmd_req_hdr hdr;
1113 u32 be_config_number;
1114 u32 asic_revision;
1115 u32 phys_port;
Jayamohan Kallickal843ae752013-09-28 15:35:44 -07001116#define BEISCSI_FUNC_ISCSI_INI_MODE 0x10
1117#define BEISCSI_FUNC_DUA_MODE 0x800
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301118 u32 function_mode;
1119 struct be_ulp_fw_cfg ulp[2];
1120 u32 function_caps;
Jayamohan Kallickal843ae752013-09-28 15:35:44 -07001121 u32 cqid_base;
1122 u32 cqid_count;
1123 u32 eqid_base;
1124 u32 eqid_count;
1125 struct be_ulp_chain_icd chain_icd[2];
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301126} __packed;
1127
Mike Christie0e438952012-04-03 23:41:51 -05001128struct be_cmd_get_all_if_id_req {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301129 struct be_cmd_req_hdr hdr;
1130 u32 if_count;
1131 u32 if_hndl_list[1];
1132} __packed;
1133
Jitendra Bhivare53aefe22016-01-20 14:10:53 +05301134struct be_cmd_get_port_name {
1135 union {
1136 struct be_cmd_req_hdr req_hdr;
1137 struct be_cmd_resp_hdr resp_hdr;
1138 } h;
1139 union {
1140 struct {
1141 u32 reserved;
1142 } req;
1143 struct {
1144 u32 port_names;
1145 } resp;
1146 } p;
1147} __packed;
1148
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301149#define ISCSI_OPCODE_SCSI_DATA_OUT 5
John Soni Josec62eef02012-04-03 23:41:52 -05001150#define OPCODE_COMMON_NTWK_LINK_STATUS_QUERY 5
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301151#define OPCODE_COMMON_MODIFY_EQ_DELAY 41
1152#define OPCODE_COMMON_ISCSI_CLEANUP 59
1153#define OPCODE_COMMON_TCP_UPLOAD 56
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301154#define OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD 70
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301155#define OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS 1
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301156#define OPCODE_ISCSI_INI_CFG_GET_HBA_NAME 6
1157#define OPCODE_ISCSI_INI_CFG_SET_HBA_NAME 7
1158#define OPCODE_ISCSI_INI_SESSION_GET_A_SESSION 14
John Soni Jose3f4134c2015-04-25 08:18:13 +05301159#define OPCODE_ISCSI_INI_SESSION_LOGOUT_TARGET 24
John Soni Jose9aef4202012-08-20 23:00:08 +05301160#define OPCODE_ISCSI_INI_DRIVER_REOPEN_ALL_SESSIONS 36
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301161#define OPCODE_ISCSI_INI_DRIVER_OFFLOAD_SESSION 41
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301162#define OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION 42
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301163#define OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET 52
Jayamohan Kallickalffce3e22012-04-03 23:41:50 -05001164#define OPCODE_COMMON_WRITE_FLASH 96
1165#define OPCODE_COMMON_READ_FLASH 97
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301166
1167/* --- CMD_ISCSI_INVALIDATE_CONNECTION_TYPE --- */
1168#define CMD_ISCSI_COMMAND_INVALIDATE 1
1169#define CMD_ISCSI_CONNECTION_INVALIDATE 0x8001
1170#define CMD_ISCSI_CONNECTION_ISSUE_TCP_RST 0x8002
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301171
1172#define INI_WR_CMD 1 /* Initiator write command */
1173#define INI_TMF_CMD 2 /* Initiator TMF command */
1174#define INI_NOPOUT_CMD 3 /* Initiator; Send a NOP-OUT */
1175#define INI_RD_CMD 5 /* Initiator requesting to send
1176 * a read command
1177 */
1178#define TGT_CTX_UPDT_CMD 7 /* Target context update */
1179#define TGT_STS_CMD 8 /* Target R2T and other BHS
1180 * where only the status number
1181 * need to be updated
1182 */
1183#define TGT_DATAIN_CMD 9 /* Target Data-Ins in response
1184 * to read command
1185 */
1186#define TGT_SOS_PDU 10 /* Target:standalone status
1187 * response
1188 */
1189#define TGT_DM_CMD 11 /* Indicates that the bhs
1190 * preparedby
1191 * driver should not be touched
1192 */
1193/* --- CMD_CHUTE_TYPE --- */
1194#define CMD_CONNECTION_CHUTE_0 1
1195#define CMD_CONNECTION_CHUTE_1 2
1196#define CMD_CONNECTION_CHUTE_2 3
1197
1198#define EQ_MAJOR_CODE_COMPLETION 0
1199
1200#define CMD_ISCSI_SESSION_DEL_CFG_FROM_FLASH 0
1201#define CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH 1
1202
1203/* --- CONNECTION_UPLOAD_PARAMS --- */
1204/* These parameters are used to define the type of upload desired. */
1205#define CONNECTION_UPLOAD_GRACEFUL 1 /* Graceful upload */
1206#define CONNECTION_UPLOAD_ABORT_RESET 2 /* Abortive upload with
1207 * reset
1208 */
1209#define CONNECTION_UPLOAD_ABORT 3 /* Abortive upload without
1210 * reset
1211 */
1212#define CONNECTION_UPLOAD_ABORT_WITH_SEQ 4 /* Abortive upload with reset,
1213 * sequence number by driver */
1214
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301215/* Returns the number of items in the field array. */
1216#define BE_NUMBER_OF_FIELD(_type_, _field_) \
1217 (FIELD_SIZEOF(_type_, _field_)/sizeof((((_type_ *)0)->_field_[0])))\
1218
1219/**
1220 * Different types of iSCSI completions to host driver for both initiator
1221 * and taget mode
1222 * of operation.
1223 */
1224#define SOL_CMD_COMPLETE 1 /* Solicited command completed
1225 * normally
1226 */
1227#define SOL_CMD_KILLED_DATA_DIGEST_ERR 2 /* Solicited command got
1228 * invalidated internally due
1229 * to Data Digest error
1230 */
1231#define CXN_KILLED_PDU_SIZE_EXCEEDS_DSL 3 /* Connection got invalidated
1232 * internally
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001233 * due to a received PDU
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301234 * size > DSL
1235 */
1236#define CXN_KILLED_BURST_LEN_MISMATCH 4 /* Connection got invalidated
1237 * internally due ti received
1238 * PDU sequence size >
1239 * FBL/MBL.
1240 */
1241#define CXN_KILLED_AHS_RCVD 5 /* Connection got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001242 * internally due to a received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301243 * PDU Hdr that has
1244 * AHS */
1245#define CXN_KILLED_HDR_DIGEST_ERR 6 /* Connection got invalidated
1246 * internally due to Hdr Digest
1247 * error
1248 */
1249#define CXN_KILLED_UNKNOWN_HDR 7 /* Connection got invalidated
1250 * internally
1251 * due to a bad opcode in the
1252 * pdu hdr
1253 */
1254#define CXN_KILLED_STALE_ITT_TTT_RCVD 8 /* Connection got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001255 * internally due to a received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301256 * ITT/TTT that does not belong
1257 * to this Connection
1258 */
1259#define CXN_KILLED_INVALID_ITT_TTT_RCVD 9 /* Connection got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001260 * internally due to received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301261 * ITT/TTT value > Max
1262 * Supported ITTs/TTTs
1263 */
1264#define CXN_KILLED_RST_RCVD 10 /* Connection got invalidated
1265 * internally due to an
1266 * incoming TCP RST
1267 */
1268#define CXN_KILLED_TIMED_OUT 11 /* Connection got invalidated
1269 * internally due to timeout on
1270 * tcp segment 12 retransmit
1271 * attempts failed
1272 */
1273#define CXN_KILLED_RST_SENT 12 /* Connection got invalidated
1274 * internally due to TCP RST
1275 * sent by the Tx side
1276 */
1277#define CXN_KILLED_FIN_RCVD 13 /* Connection got invalidated
1278 * internally due to an
1279 * incoming TCP FIN.
1280 */
1281#define CXN_KILLED_BAD_UNSOL_PDU_RCVD 14 /* Connection got invalidated
1282 * internally due to bad
1283 * unsolicited PDU Unsolicited
1284 * PDUs are PDUs with
1285 * ITT=0xffffffff
1286 */
1287#define CXN_KILLED_BAD_WRB_INDEX_ERROR 15 /* Connection got invalidated
1288 * internally due to bad WRB
1289 * index.
1290 */
1291#define CXN_KILLED_OVER_RUN_RESIDUAL 16 /* Command got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001292 * internally due to received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301293 * command has residual
1294 * over run bytes.
1295 */
1296#define CXN_KILLED_UNDER_RUN_RESIDUAL 17 /* Command got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001297 * internally due to received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301298 * command has residual under
1299 * run bytes.
1300 */
1301#define CMD_KILLED_INVALID_STATSN_RCVD 18 /* Command got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001302 * internally due to a received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301303 * PDU has an invalid StatusSN
1304 */
1305#define CMD_KILLED_INVALID_R2T_RCVD 19 /* Command got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001306 * internally due to a received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301307 * an R2T with some invalid
1308 * fields in it
1309 */
1310#define CMD_CXN_KILLED_LUN_INVALID 20 /* Command got invalidated
1311 * internally due to received
1312 * PDU has an invalid LUN.
1313 */
1314#define CMD_CXN_KILLED_ICD_INVALID 21 /* Command got invalidated
1315 * internally due to the
1316 * corresponding ICD not in a
1317 * valid state
1318 */
1319#define CMD_CXN_KILLED_ITT_INVALID 22 /* Command got invalidated due
1320 * to received PDU has an
1321 * invalid ITT.
1322 */
1323#define CMD_CXN_KILLED_SEQ_OUTOFORDER 23 /* Command got invalidated due
1324 * to received sequence buffer
1325 * offset is out of order.
1326 */
1327#define CMD_CXN_KILLED_INVALID_DATASN_RCVD 24 /* Command got invalidated
1328 * internally due to a
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001329 * received PDU has an invalid
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301330 * DataSN
1331 */
1332#define CXN_INVALIDATE_NOTIFY 25 /* Connection invalidation
1333 * completion notify.
1334 */
1335#define CXN_INVALIDATE_INDEX_NOTIFY 26 /* Connection invalidation
1336 * completion
1337 * with data PDU index.
1338 */
1339#define CMD_INVALIDATED_NOTIFY 27 /* Command invalidation
1340 * completionnotifify.
1341 */
1342#define UNSOL_HDR_NOTIFY 28 /* Unsolicited header notify.*/
1343#define UNSOL_DATA_NOTIFY 29 /* Unsolicited data notify.*/
Jayamohan Kallickal457ff3b2010-07-22 04:16:00 +05301344#define UNSOL_DATA_DIGEST_ERROR_NOTIFY 30 /* Unsolicited data digest
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301345 * error notify.
1346 */
1347#define DRIVERMSG_NOTIFY 31 /* TCP acknowledge based
1348 * notification.
1349 */
1350#define CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN 32 /* Connection got invalidated
1351 * internally due to command
1352 * and data are not on same
1353 * connection.
1354 */
1355#define SOL_CMD_KILLED_DIF_ERR 33 /* Solicited command got
1356 * invalidated internally due
1357 * to DIF error
1358 */
1359#define CXN_KILLED_SYN_RCVD 34 /* Connection got invalidated
1360 * internally due to incoming
1361 * TCP SYN
1362 */
1363#define CXN_KILLED_IMM_DATA_RCVD 35 /* Connection got invalidated
1364 * internally due to an
1365 * incoming Unsolicited PDU
1366 * that has immediate data on
1367 * the cxn
1368 */
1369
Jayamohan Kallickale9b91192010-07-22 04:24:53 +05301370int beiscsi_pci_soft_reset(struct beiscsi_hba *phba);
1371int be_chk_reset_complete(struct beiscsi_hba *phba);
1372
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301373void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len,
1374 bool embedded, u8 sge_cnt);
1375
1376void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr,
1377 u8 subsystem, u8 opcode, int cmd_len);
1378
Jitendra Bhivarecdaa4de2016-01-20 14:10:51 +05301379void beiscsi_fail_session(struct iscsi_cls_session *cls_session);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301380#endif /* !BEISCSI_CMDS_H */