blob: 6fb9673248b379d6c9413448cb5335c35facd0b7 [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] */
John Soni Jose3f4134c2015-04-25 08:18:13 +0530348 uint32_t session_status;
Jitendra Bhivare50a4b822016-08-19 15:20:12 +0530349#define BE_SESS_STATUS_CLOSE 0x20
John Soni Jose3f4134c2015-04-25 08:18:13 +0530350} __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;
Jitendra Bhivare290aa372016-08-19 15:20:08 +0530368#define BEISCSI_IP_TYPE_V4 0x1
369#define BEISCSI_IP_TYPE_STATIC_V4 0x3
370#define BEISCSI_IP_TYPE_DHCP_V4 0x5
371/* type v4 values < type v6 values */
372#define BEISCSI_IP_TYPE_V6 0x10
373#define BEISCSI_IP_TYPE_ROUTABLE_V6 0x30
374#define BEISCSI_IP_TYPE_LINK_LOCAL_V6 0x50
375#define BEISCSI_IP_TYPE_AUTO_V6 0x90
Mike Christie0e438952012-04-03 23:41:51 -0500376 u8 addr[16];
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530377 u32 rsvd0;
378} __packed;
379
Mike Christie0e438952012-04-03 23:41:51 -0500380struct mgmt_conn_info {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530381 u32 connection_handle;
382 u32 connection_status;
383 u16 src_port;
384 u16 dest_port;
385 u16 dest_port_redirected;
386 u16 cid;
387 u32 estimated_throughput;
Mike Christie0e438952012-04-03 23:41:51 -0500388 struct ip_addr_format src_ipaddr;
389 struct ip_addr_format dest_ipaddr;
390 struct ip_addr_format dest_ipaddr_redirected;
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530391 struct mgmt_conn_login_options negotiated_login_options;
392} __packed;
393
394struct mgmt_session_login_options {
395 u8 flags;
396 u8 error_recovery_level;
397 u16 rsvd0;
398 u32 first_burst_length;
399 u32 max_burst_length;
400 u16 max_connections;
401 u16 max_outstanding_r2t;
402 u16 default_time2wait;
403 u16 default_time2retain;
404} __packed;
405
406struct mgmt_session_info {
407 u32 session_handle;
408 u32 status;
409 u8 isid[6];
410 u16 tsih;
411 u32 session_flags;
412 u16 conn_count;
413 u16 pad;
414 u8 target_name[224];
415 u8 initiator_iscsiname[224];
416 struct mgmt_session_login_options negotiated_login_options;
417 struct mgmt_conn_info conn_list[1];
418} __packed;
419
Mike Christie0e438952012-04-03 23:41:51 -0500420struct be_cmd_get_session_req {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530421 struct be_cmd_req_hdr hdr;
422 u32 session_handle;
423} __packed;
424
Mike Christie0e438952012-04-03 23:41:51 -0500425struct be_cmd_get_session_resp {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530426 struct be_cmd_resp_hdr hdr;
427 struct mgmt_session_info session_info;
428} __packed;
429
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530430struct mac_addr {
Mike Christie0e438952012-04-03 23:41:51 -0500431 u16 size_of_structure;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530432 u8 addr[ETH_ALEN];
433} __packed;
434
Mike Christie0e438952012-04-03 23:41:51 -0500435struct be_cmd_get_boot_target_req {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530436 struct be_cmd_req_hdr hdr;
437} __packed;
438
Mike Christie0e438952012-04-03 23:41:51 -0500439struct be_cmd_get_boot_target_resp {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530440 struct be_cmd_resp_hdr hdr;
Jitendra Bhivare50a4b822016-08-19 15:20:12 +0530441 u32 boot_session_count;
442 u32 boot_session_handle;
443/**
444 * FW returns 0xffffffff if it couldn't establish connection with
445 * configured boot target.
446 */
447#define BE_BOOT_INVALID_SHANDLE 0xffffffff
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530448};
449
John Soni Jose9aef4202012-08-20 23:00:08 +0530450struct be_cmd_reopen_session_req {
451 struct be_cmd_req_hdr hdr;
452#define BE_REOPEN_ALL_SESSIONS 0x00
453#define BE_REOPEN_BOOT_SESSIONS 0x01
454#define BE_REOPEN_A_SESSION 0x02
455 u16 reopen_type;
456 u16 rsvd;
457 u32 session_handle;
458} __packed;
459
460struct be_cmd_reopen_session_resp {
461 struct be_cmd_resp_hdr hdr;
462 u32 rsvd;
463 u32 session_handle;
464} __packed;
465
466
Mike Christie0e438952012-04-03 23:41:51 -0500467struct be_cmd_mac_query_req {
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530468 struct be_cmd_req_hdr hdr;
469 u8 type;
470 u8 permanent;
471 u16 if_id;
472} __packed;
473
Mike Christie0e438952012-04-03 23:41:51 -0500474struct be_cmd_get_mac_resp {
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530475 struct be_cmd_resp_hdr hdr;
476 struct mac_addr mac;
477};
478
Mike Christie0e438952012-04-03 23:41:51 -0500479struct be_ip_addr_subnet_format {
480 u16 size_of_structure;
481 u8 ip_type;
482 u8 ipv6_prefix_length;
483 u8 addr[16];
484 u8 subnet_mask[16];
485 u32 rsvd0;
486} __packed;
487
488struct be_cmd_get_if_info_req {
489 struct be_cmd_req_hdr hdr;
490 u32 interface_hndl;
491 u32 ip_type;
492} __packed;
493
494struct be_cmd_get_if_info_resp {
495 struct be_cmd_req_hdr hdr;
496 u32 interface_hndl;
497 u32 vlan_priority;
498 u32 ip_addr_count;
499 u32 dhcp_state;
500 struct be_ip_addr_subnet_format ip_addr;
501} __packed;
502
503struct be_ip_addr_record {
504 u32 action;
505 u32 interface_hndl;
506 struct be_ip_addr_subnet_format ip_addr;
507 u32 status;
508} __packed;
509
510struct be_ip_addr_record_params {
511 u32 record_entry_count;
512 struct be_ip_addr_record ip_record;
513} __packed;
514
515struct be_cmd_set_ip_addr_req {
516 struct be_cmd_req_hdr hdr;
517 struct be_ip_addr_record_params ip_params;
518} __packed;
519
520
521struct be_cmd_set_dhcp_req {
522 struct be_cmd_req_hdr hdr;
523 u32 interface_hndl;
524 u32 ip_type;
525 u32 flags;
526 u32 retry_count;
527} __packed;
528
529struct be_cmd_rel_dhcp_req {
530 struct be_cmd_req_hdr hdr;
531 u32 interface_hndl;
532 u32 ip_type;
533} __packed;
534
535struct be_cmd_set_def_gateway_req {
536 struct be_cmd_req_hdr hdr;
537 u32 action;
538 struct ip_addr_format ip_addr;
539} __packed;
540
541struct be_cmd_get_def_gateway_req {
542 struct be_cmd_req_hdr hdr;
543 u32 ip_type;
544} __packed;
545
546struct be_cmd_get_def_gateway_resp {
547 struct be_cmd_req_hdr hdr;
548 struct ip_addr_format ip_addr;
549} __packed;
550
John Soni Jose6f722382012-08-20 23:00:43 +0530551#define BEISCSI_VLAN_DISABLE 0xFFFF
552struct be_cmd_set_vlan_req {
553 struct be_cmd_req_hdr hdr;
554 u32 interface_hndl;
555 u32 vlan_priority;
556} __packed;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530557/******************** Create CQ ***************************/
558/**
559 * Pseudo amap definition in which each bit of the actual structure is defined
560 * as a byte - used to calculate offset/shift/mask of each field
561 */
562struct amap_cq_context {
563 u8 cidx[11]; /* dword 0 */
564 u8 rsvd0; /* dword 0 */
565 u8 coalescwm[2]; /* dword 0 */
566 u8 nodelay; /* dword 0 */
567 u8 epidx[11]; /* dword 0 */
568 u8 rsvd1; /* dword 0 */
569 u8 count[2]; /* dword 0 */
570 u8 valid; /* dword 0 */
571 u8 solevent; /* dword 0 */
572 u8 eventable; /* dword 0 */
573 u8 pidx[11]; /* dword 1 */
574 u8 rsvd2; /* dword 1 */
575 u8 pd[10]; /* dword 1 */
576 u8 eqid[8]; /* dword 1 */
577 u8 stalled; /* dword 1 */
578 u8 armed; /* dword 1 */
579 u8 rsvd3[4]; /* dword 2 */
580 u8 func[8]; /* dword 2 */
581 u8 rsvd4[20]; /* dword 2 */
582 u8 rsvd5[32]; /* dword 3 */
583} __packed;
584
John Soni Joseeaae5262012-10-20 04:43:44 +0530585struct amap_cq_context_v2 {
586 u8 rsvd0[12]; /* dword 0 */
587 u8 coalescwm[2]; /* dword 0 */
588 u8 nodelay; /* dword 0 */
589 u8 rsvd1[12]; /* dword 0 */
590 u8 count[2]; /* dword 0 */
591 u8 valid; /* dword 0 */
592 u8 rsvd2; /* dword 0 */
593 u8 eventable; /* dword 0 */
594 u8 eqid[16]; /* dword 1 */
595 u8 rsvd3[15]; /* dword 1 */
596 u8 armed; /* dword 1 */
597 u8 cqecount[16];/* dword 2 */
598 u8 rsvd4[16]; /* dword 2 */
599 u8 rsvd5[32]; /* dword 3 */
600};
601
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530602struct be_cmd_req_cq_create {
603 struct be_cmd_req_hdr hdr;
604 u16 num_pages;
John Soni Joseeaae5262012-10-20 04:43:44 +0530605 u8 page_size;
606 u8 rsvd0;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530607 u8 context[sizeof(struct amap_cq_context) / 8];
608 struct phys_addr pages[4];
609} __packed;
610
611struct be_cmd_resp_cq_create {
612 struct be_cmd_resp_hdr hdr;
613 u16 cq_id;
614 u16 rsvd0;
615} __packed;
616
617/******************** Create MCCQ ***************************/
618/**
619 * Pseudo amap definition in which each bit of the actual structure is defined
620 * as a byte - used to calculate offset/shift/mask of each field
621 */
622struct amap_mcc_context {
623 u8 con_index[14];
624 u8 rsvd0[2];
625 u8 ring_size[4];
626 u8 fetch_wrb;
627 u8 fetch_r2t;
628 u8 cq_id[10];
629 u8 prod_index[14];
630 u8 fid[8];
631 u8 pdid[9];
632 u8 valid;
633 u8 rsvd1[32];
634 u8 rsvd2[32];
635} __packed;
636
Jitendra Bhivare53aefe22016-01-20 14:10:53 +0530637struct be_cmd_req_mcc_create_ext {
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530638 struct be_cmd_req_hdr hdr;
639 u16 num_pages;
640 u16 rsvd0;
Jitendra Bhivare53aefe22016-01-20 14:10:53 +0530641 u32 async_evt_bitmap;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530642 u8 context[sizeof(struct amap_mcc_context) / 8];
643 struct phys_addr pages[8];
644} __packed;
645
646struct be_cmd_resp_mcc_create {
647 struct be_cmd_resp_hdr hdr;
648 u16 id;
649 u16 rsvd0;
650} __packed;
651
652/******************** Q Destroy ***************************/
653/* Type of Queue to be destroyed */
654enum {
655 QTYPE_EQ = 1,
656 QTYPE_CQ,
657 QTYPE_MCCQ,
658 QTYPE_WRBQ,
659 QTYPE_DPDUQ,
660 QTYPE_SGL
661};
662
663struct be_cmd_req_q_destroy {
664 struct be_cmd_req_hdr hdr;
665 u16 id;
666 u16 bypass_flush; /* valid only for rx q destroy */
667} __packed;
668
669struct macaddr {
670 u8 byte[ETH_ALEN];
671};
672
673struct be_cmd_req_mcast_mac_config {
674 struct be_cmd_req_hdr hdr;
675 u16 num_mac;
676 u8 promiscuous;
677 u8 interface_id;
678 struct macaddr mac[32];
679} __packed;
680
681static inline void *embedded_payload(struct be_mcc_wrb *wrb)
682{
683 return wrb->payload.embedded_payload;
684}
685
686static inline struct be_sge *nonembedded_sgl(struct be_mcc_wrb *wrb)
687{
688 return &wrb->payload.sgl[0];
689}
690
691/******************** Modify EQ Delay *******************/
692struct be_cmd_req_modify_eq_delay {
693 struct be_cmd_req_hdr hdr;
Jayamohan Kallickal39033412014-08-08 00:59:58 -0400694 __le32 num_eq;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530695 struct {
Jayamohan Kallickal39033412014-08-08 00:59:58 -0400696 __le32 eq_id;
697 __le32 phase;
698 __le32 delay_multiplier;
Jayamohan Kallickal73af08e2014-05-05 21:41:26 -0400699 } delay[MAX_CPUS];
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530700} __packed;
701
702/******************** Get MAC ADDR *******************/
703
Mike Christie0e438952012-04-03 23:41:51 -0500704struct be_cmd_get_nic_conf_resp {
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530705 struct be_cmd_resp_hdr hdr;
706 u32 nic_port_count;
707 u32 speed;
708 u32 max_speed;
709 u32 link_state;
710 u32 max_frame_size;
711 u16 size_of_structure;
Jitendra Bhivare9c4f8b02016-01-20 14:10:59 +0530712 u8 mac_address[ETH_ALEN];
713} __packed;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530714
John Soni Jose21771992012-04-03 23:41:49 -0500715#define BEISCSI_ALIAS_LEN 32
716
717struct be_cmd_hba_name {
718 struct be_cmd_req_hdr hdr;
719 u16 flags;
720 u16 rsvd0;
721 u8 initiator_name[ISCSI_NAME_LEN];
722 u8 initiator_alias[BEISCSI_ALIAS_LEN];
723} __packed;
724
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530725int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl,
726 struct be_queue_info *eq, int eq_delay);
727
728int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl,
729 struct be_queue_info *cq, struct be_queue_info *eq,
730 bool sol_evts, bool no_delay,
731 int num_cqe_dma_coalesce);
732
733int beiscsi_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q,
734 int type);
Jayamohan Kallickal35e66012009-10-23 11:53:49 +0530735int beiscsi_cmd_mccq_create(struct beiscsi_hba *phba,
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530736 struct be_queue_info *mccq,
737 struct be_queue_info *cq);
738
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530739int be_poll_mcc(struct be_ctrl_info *ctrl);
Jayamohan Kallickal03a12312010-07-22 04:17:16 +0530740int mgmt_check_supported_fw(struct be_ctrl_info *ctrl,
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530741 struct beiscsi_hba *phba);
John Soni Jose21771992012-04-03 23:41:49 -0500742unsigned int be_cmd_get_initname(struct beiscsi_hba *phba);
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530743
Jitendra Bhivare090e2182016-02-04 15:49:17 +0530744void free_mcc_wrb(struct be_ctrl_info *ctrl, unsigned int tag);
John Soni Josee175def2012-10-20 04:45:40 +0530745
Jitendra Bhivare10bcd472016-08-19 15:20:13 +0530746int beiscsi_modify_eq_delay(struct beiscsi_hba *phba, struct be_set_eqd *,
Jayamohan Kallickal73af08e2014-05-05 21:41:26 -0400747 int num);
Jitendra Bhivare88840332016-02-04 15:49:12 +0530748int beiscsi_mccq_compl_wait(struct beiscsi_hba *phba,
Jitendra Bhivare50a4b822016-08-19 15:20:12 +0530749 unsigned int tag,
750 struct be_mcc_wrb **wrb,
Jitendra Bhivare88840332016-02-04 15:49:12 +0530751 struct be_dma_mem *mbx_cmd_mem);
Jitendra Bhivare50a4b822016-08-19 15:20:12 +0530752int __beiscsi_mcc_compl_status(struct beiscsi_hba *phba,
753 unsigned int tag,
754 struct be_mcc_wrb **wrb,
755 struct be_dma_mem *mbx_cmd_mem);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530756/*ISCSI Functuions */
757int be_cmd_fw_initialize(struct be_ctrl_info *ctrl);
Jayamohan Kallickal0283fbb2013-04-05 20:38:21 -0700758int be_cmd_fw_uninit(struct be_ctrl_info *ctrl);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530759
760struct be_mcc_wrb *wrb_from_mbox(struct be_dma_mem *mbox_mem);
Jitendra Bhivare2e4e8f62016-02-04 15:49:11 +0530761int be_mcc_compl_poll(struct beiscsi_hba *phba, unsigned int tag);
Jitendra Bhivarecdde6682016-01-20 14:10:47 +0530762void be_mcc_notify(struct beiscsi_hba *phba, unsigned int tag);
Jitendra Bhivare090e2182016-02-04 15:49:17 +0530763struct be_mcc_wrb *alloc_mcc_wrb(struct beiscsi_hba *phba,
764 unsigned int *ref_tag);
Jitendra Bhivare53aefe22016-01-20 14:10:53 +0530765void beiscsi_process_async_event(struct beiscsi_hba *phba,
766 struct be_mcc_compl *compl);
Jitendra Bhivare2e4e8f62016-02-04 15:49:11 +0530767int beiscsi_process_mcc_compl(struct be_ctrl_info *ctrl,
768 struct be_mcc_compl *compl);
769
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530770
771int be_mbox_notify(struct be_ctrl_info *ctrl);
772
773int be_cmd_create_default_pdu_queue(struct be_ctrl_info *ctrl,
774 struct be_queue_info *cq,
775 struct be_queue_info *dq, int length,
Jayamohan Kallickal8a86e832013-09-28 15:35:45 -0700776 int entry_size, uint8_t is_header,
777 uint8_t ulp_num);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530778
Jayamohan Kallickal15a90fe2013-09-28 15:35:38 -0700779int be_cmd_iscsi_post_template_hdr(struct be_ctrl_info *ctrl,
780 struct be_dma_mem *q_mem);
781
782int be_cmd_iscsi_remove_template_hdr(struct be_ctrl_info *ctrl);
783
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530784int be_cmd_iscsi_post_sgl_pages(struct be_ctrl_info *ctrl,
785 struct be_dma_mem *q_mem, u32 page_offset,
786 u32 num_pages);
787
Jayamohan Kallickale5285862011-10-07 19:31:08 -0500788int beiscsi_cmd_reset_function(struct beiscsi_hba *phba);
789
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530790int be_cmd_wrbq_create(struct be_ctrl_info *ctrl, struct be_dma_mem *q_mem,
Jayamohan Kallickal4eea99d2013-09-28 15:35:48 -0700791 struct be_queue_info *wrbq,
792 struct hwi_wrb_context *pwrb_context,
793 uint8_t ulp_num);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530794
John Soni Jose6f722382012-08-20 23:00:43 +0530795/* Configuration Functions */
796int be_cmd_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag);
797
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530798struct be_default_pdu_context {
799 u32 dw[4];
800} __packed;
801
802struct amap_be_default_pdu_context {
803 u8 dbuf_cindex[13]; /* dword 0 */
804 u8 rsvd0[3]; /* dword 0 */
805 u8 ring_size[4]; /* dword 0 */
806 u8 ring_state[4]; /* dword 0 */
807 u8 rsvd1[8]; /* dword 0 */
808 u8 dbuf_pindex[13]; /* dword 1 */
809 u8 rsvd2; /* dword 1 */
810 u8 pci_func_id[8]; /* dword 1 */
811 u8 rx_pdid[9]; /* dword 1 */
812 u8 rx_pdid_valid; /* dword 1 */
813 u8 default_buffer_size[16]; /* dword 2 */
814 u8 cq_id_recv[10]; /* dword 2 */
815 u8 rx_pdid_not_valid; /* dword 2 */
816 u8 rsvd3[5]; /* dword 2 */
817 u8 rsvd4[32]; /* dword 3 */
818} __packed;
819
Jayamohan Kallickalef9e1b92013-04-05 20:38:27 -0700820struct amap_default_pdu_context_ext {
821 u8 rsvd0[16]; /* dword 0 */
822 u8 ring_size[4]; /* dword 0 */
823 u8 rsvd1[12]; /* dword 0 */
824 u8 rsvd2[22]; /* dword 1 */
825 u8 rx_pdid[9]; /* dword 1 */
826 u8 rx_pdid_valid; /* dword 1 */
827 u8 default_buffer_size[16]; /* dword 2 */
828 u8 cq_id_recv[16]; /* dword 2 */
829 u8 rsvd3[32]; /* dword 3 */
830} __packed;
831
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530832struct be_defq_create_req {
833 struct be_cmd_req_hdr hdr;
834 u16 num_pages;
835 u8 ulp_num;
Jayamohan Kallickal8a86e832013-09-28 15:35:45 -0700836#define BEISCSI_DUAL_ULP_AWARE_BIT 0 /* Byte 3 - Bit 0 */
837#define BEISCSI_BIND_Q_TO_ULP_BIT 1 /* Byte 3 - Bit 1 */
838 u8 dua_feature;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530839 struct be_default_pdu_context context;
840 struct phys_addr pages[8];
841} __packed;
842
843struct be_defq_create_resp {
844 struct be_cmd_req_hdr hdr;
845 u16 id;
Jayamohan Kallickal8a86e832013-09-28 15:35:45 -0700846 u8 rsvd0;
847 u8 ulp_num;
848 u32 doorbell_offset;
849 u16 register_set;
850 u16 doorbell_format;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530851} __packed;
852
Jayamohan Kallickal15a90fe2013-09-28 15:35:38 -0700853struct be_post_template_pages_req {
854 struct be_cmd_req_hdr hdr;
855 u16 num_pages;
856#define BEISCSI_TEMPLATE_HDR_TYPE_ISCSI 0x1
857 u16 type;
858 struct phys_addr scratch_pa;
859 struct virt_addr scratch_va;
860 struct virt_addr pages_va;
861 struct phys_addr pages[16];
862} __packed;
863
864struct be_remove_template_pages_req {
865 struct be_cmd_req_hdr hdr;
866 u16 type;
867 u16 rsvd0;
868} __packed;
869
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530870struct be_post_sgl_pages_req {
871 struct be_cmd_req_hdr hdr;
872 u16 num_pages;
873 u16 page_offset;
874 u32 rsvd0;
875 struct phys_addr pages[26];
876 u32 rsvd1;
877} __packed;
878
879struct be_wrbq_create_req {
880 struct be_cmd_req_hdr hdr;
881 u16 num_pages;
882 u8 ulp_num;
Jayamohan Kallickal4eea99d2013-09-28 15:35:48 -0700883 u8 dua_feature;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530884 struct phys_addr pages[8];
885} __packed;
886
887struct be_wrbq_create_resp {
888 struct be_cmd_resp_hdr resp_hdr;
889 u16 cid;
Jayamohan Kallickal4eea99d2013-09-28 15:35:48 -0700890 u8 rsvd0;
891 u8 ulp_num;
892 u32 doorbell_offset;
893 u16 register_set;
894 u16 doorbell_format;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530895} __packed;
896
897#define SOL_CID_MASK 0x0000FFC0
898#define SOL_CODE_MASK 0x0000003F
899#define SOL_WRB_INDEX_MASK 0x00FF0000
900#define SOL_CMD_WND_MASK 0xFF000000
901#define SOL_RES_CNT_MASK 0x7FFFFFFF
902#define SOL_EXP_CMD_SN_MASK 0xFFFFFFFF
903#define SOL_HW_STS_MASK 0x000000FF
904#define SOL_STS_MASK 0x0000FF00
905#define SOL_RESP_MASK 0x00FF0000
906#define SOL_FLAGS_MASK 0x7F000000
907#define SOL_S_MASK 0x80000000
908
909struct sol_cqe {
910 u32 dw[4];
911};
912
913struct amap_sol_cqe {
914 u8 hw_sts[8]; /* dword 0 */
915 u8 i_sts[8]; /* dword 0 */
916 u8 i_resp[8]; /* dword 0 */
917 u8 i_flags[7]; /* dword 0 */
918 u8 s; /* dword 0 */
919 u8 i_exp_cmd_sn[32]; /* dword 1 */
920 u8 code[6]; /* dword 2 */
921 u8 cid[10]; /* dword 2 */
922 u8 wrb_index[8]; /* dword 2 */
923 u8 i_cmd_wnd[8]; /* dword 2 */
924 u8 i_res_cnt[31]; /* dword 3 */
925 u8 valid; /* dword 3 */
926} __packed;
927
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530928#define SOL_ICD_INDEX_MASK 0x0003FFC0
929struct amap_sol_cqe_ring {
930 u8 hw_sts[8]; /* dword 0 */
931 u8 i_sts[8]; /* dword 0 */
932 u8 i_resp[8]; /* dword 0 */
933 u8 i_flags[7]; /* dword 0 */
934 u8 s; /* dword 0 */
935 u8 i_exp_cmd_sn[32]; /* dword 1 */
936 u8 code[6]; /* dword 2 */
937 u8 icd_index[12]; /* dword 2 */
938 u8 rsvd[6]; /* dword 2 */
939 u8 i_cmd_wnd[8]; /* dword 2 */
940 u8 i_res_cnt[31]; /* dword 3 */
941 u8 valid; /* dword 3 */
942} __packed;
943
John Soni Jose73133262012-10-20 04:44:49 +0530944struct amap_sol_cqe_v2 {
945 u8 hw_sts[8]; /* dword 0 */
946 u8 i_sts[8]; /* dword 0 */
947 u8 wrb_index[16]; /* dword 0 */
948 u8 i_exp_cmd_sn[32]; /* dword 1 */
949 u8 code[6]; /* dword 2 */
950 u8 cmd_cmpl; /* dword 2 */
951 u8 rsvd0; /* dword 2 */
952 u8 i_cmd_wnd[8]; /* dword 2 */
953 u8 cid[13]; /* dword 2 */
954 u8 u; /* dword 2 */
955 u8 o; /* dword 2 */
956 u8 s; /* dword 2 */
957 u8 i_res_cnt[31]; /* dword 3 */
958 u8 valid; /* dword 3 */
959} __packed;
960
961struct common_sol_cqe {
962 u32 exp_cmdsn;
963 u32 res_cnt;
964 u16 wrb_index;
965 u16 cid;
966 u8 hw_sts;
967 u8 cmd_wnd;
968 u8 res_flag; /* the s feild of structure */
969 u8 i_resp; /* for skh if cmd_complete is set then i_sts is response */
970 u8 i_flags; /* for skh or the u and o feilds */
971 u8 i_sts; /* for skh if cmd_complete is not-set then i_sts is status */
972};
973
974/*** iSCSI ack/driver message completions ***/
975struct amap_it_dmsg_cqe {
976 u8 ack_num[32]; /* DWORD 0 */
977 u8 pdu_bytes_rcvd[32]; /* DWORD 1 */
978 u8 code[6]; /* DWORD 2 */
979 u8 cid[10]; /* DWORD 2 */
980 u8 wrb_idx[8]; /* DWORD 2 */
981 u8 rsvd0[8]; /* DWORD 2*/
982 u8 rsvd1[31]; /* DWORD 3*/
983 u8 valid; /* DWORD 3 */
984} __packed;
985
986struct amap_it_dmsg_cqe_v2 {
987 u8 ack_num[32]; /* DWORD 0 */
988 u8 pdu_bytes_rcvd[32]; /* DWORD 1 */
989 u8 code[6]; /* DWORD 2 */
990 u8 rsvd0[10]; /* DWORD 2 */
991 u8 wrb_idx[16]; /* DWORD 2 */
992 u8 rsvd1[16]; /* DWORD 3 */
993 u8 cid[13]; /* DWORD 3 */
994 u8 rsvd2[2]; /* DWORD 3 */
995 u8 valid; /* DWORD 3 */
996} __packed;
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530997
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530998
999/**
1000 * Post WRB Queue Doorbell Register used by the host Storage
1001 * stack to notify the
1002 * controller of a posted Work Request Block
1003 */
Jayamohan Kallickalef9e1b92013-04-05 20:38:27 -07001004#define DB_WRB_POST_CID_MASK 0xFFFF /* bits 0 - 16 */
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301005#define DB_DEF_PDU_WRB_INDEX_MASK 0xFF /* bits 0 - 9 */
1006
1007#define DB_DEF_PDU_WRB_INDEX_SHIFT 16
1008#define DB_DEF_PDU_NUM_POSTED_SHIFT 24
1009
1010struct fragnum_bits_for_sgl_cra_in {
1011 struct be_cmd_req_hdr hdr;
1012 u32 num_bits;
1013} __packed;
1014
1015struct iscsi_cleanup_req {
1016 struct be_cmd_req_hdr hdr;
1017 u16 chute;
1018 u8 hdr_ring_id;
1019 u8 data_ring_id;
1020
1021} __packed;
1022
1023struct eq_delay {
1024 u32 eq_id;
1025 u32 phase;
1026 u32 delay_multiplier;
1027} __packed;
1028
1029struct be_eq_delay_params_in {
1030 struct be_cmd_req_hdr hdr;
1031 u32 num_eq;
1032 struct eq_delay delay[8];
1033} __packed;
1034
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301035struct tcp_connect_and_offload_in {
1036 struct be_cmd_req_hdr hdr;
Mike Christie0e438952012-04-03 23:41:51 -05001037 struct ip_addr_format ip_address;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301038 u16 tcp_port;
1039 u16 cid;
1040 u16 cq_id;
1041 u16 defq_id;
1042 struct phys_addr dataout_template_pa;
1043 u16 hdr_ring_id;
1044 u16 data_ring_id;
1045 u8 do_offload;
1046 u8 rsvd0[3];
1047} __packed;
1048
Jayamohan Kallickalb3c202d2014-05-05 21:41:27 -04001049struct tcp_connect_and_offload_in_v1 {
1050 struct be_cmd_req_hdr hdr;
1051 struct ip_addr_format ip_address;
1052 u16 tcp_port;
1053 u16 cid;
1054 u16 cq_id;
1055 u16 defq_id;
1056 struct phys_addr dataout_template_pa;
1057 u16 hdr_ring_id;
1058 u16 data_ring_id;
1059 u8 do_offload;
1060 u8 ifd_state;
1061 u8 rsvd0[2];
1062 u16 tcp_window_size;
1063 u8 tcp_window_scale_count;
1064 u8 rsvd1;
1065 u32 tcp_mss:24;
1066 u8 rsvd2;
1067} __packed;
1068
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301069struct tcp_connect_and_offload_out {
1070 struct be_cmd_resp_hdr hdr;
1071 u32 connection_handle;
1072 u16 cid;
1073 u16 rsvd0;
1074
1075} __packed;
1076
1077struct be_mcc_wrb_context {
1078 struct MCC_WRB *wrb;
1079 int *users_final_status;
1080} __packed;
1081
Jayamohan Kallickale08b3c82014-01-29 02:16:42 -05001082#define DB_DEF_PDU_RING_ID_MASK 0x3FFF /* bits 0 - 13 */
1083#define DB_DEF_PDU_CQPROC_MASK 0x3FFF /* bits 16 - 29 */
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301084#define DB_DEF_PDU_REARM_SHIFT 14
1085#define DB_DEF_PDU_EVENT_SHIFT 15
1086#define DB_DEF_PDU_CQPROC_SHIFT 16
1087
1088struct dmsg_cqe {
1089 u32 dw[4];
1090} __packed;
1091
1092struct tcp_upload_params_in {
1093 struct be_cmd_req_hdr hdr;
1094 u16 id;
1095 u16 upload_type;
1096 u32 reset_seq;
1097} __packed;
1098
1099struct tcp_upload_params_out {
1100 u32 dw[32];
1101} __packed;
1102
1103union tcp_upload_params {
1104 struct tcp_upload_params_in request;
1105 struct tcp_upload_params_out response;
1106} __packed;
1107
1108struct be_ulp_fw_cfg {
Jayamohan Kallickal843ae752013-09-28 15:35:44 -07001109#define BEISCSI_ULP_ISCSI_INI_MODE 0x10
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301110 u32 ulp_mode;
1111 u32 etx_base;
1112 u32 etx_count;
1113 u32 sq_base;
1114 u32 sq_count;
1115 u32 rq_base;
1116 u32 rq_count;
1117 u32 dq_base;
1118 u32 dq_count;
1119 u32 lro_base;
1120 u32 lro_count;
1121 u32 icd_base;
1122 u32 icd_count;
1123};
1124
Jayamohan Kallickal843ae752013-09-28 15:35:44 -07001125struct be_ulp_chain_icd {
1126 u32 chain_base;
1127 u32 chain_count;
1128};
1129
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301130struct be_fw_cfg {
1131 struct be_cmd_req_hdr hdr;
1132 u32 be_config_number;
1133 u32 asic_revision;
1134 u32 phys_port;
Jayamohan Kallickal843ae752013-09-28 15:35:44 -07001135#define BEISCSI_FUNC_ISCSI_INI_MODE 0x10
1136#define BEISCSI_FUNC_DUA_MODE 0x800
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301137 u32 function_mode;
1138 struct be_ulp_fw_cfg ulp[2];
1139 u32 function_caps;
Jayamohan Kallickal843ae752013-09-28 15:35:44 -07001140 u32 cqid_base;
1141 u32 cqid_count;
1142 u32 eqid_base;
1143 u32 eqid_count;
1144 struct be_ulp_chain_icd chain_icd[2];
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301145} __packed;
1146
Mike Christie0e438952012-04-03 23:41:51 -05001147struct be_cmd_get_all_if_id_req {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301148 struct be_cmd_req_hdr hdr;
1149 u32 if_count;
1150 u32 if_hndl_list[1];
1151} __packed;
1152
Jitendra Bhivare53aefe22016-01-20 14:10:53 +05301153struct be_cmd_get_port_name {
1154 union {
1155 struct be_cmd_req_hdr req_hdr;
1156 struct be_cmd_resp_hdr resp_hdr;
1157 } h;
1158 union {
1159 struct {
1160 u32 reserved;
1161 } req;
1162 struct {
1163 u32 port_names;
1164 } resp;
1165 } p;
1166} __packed;
1167
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301168#define ISCSI_OPCODE_SCSI_DATA_OUT 5
John Soni Josec62eef02012-04-03 23:41:52 -05001169#define OPCODE_COMMON_NTWK_LINK_STATUS_QUERY 5
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301170#define OPCODE_COMMON_MODIFY_EQ_DELAY 41
1171#define OPCODE_COMMON_ISCSI_CLEANUP 59
1172#define OPCODE_COMMON_TCP_UPLOAD 56
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301173#define OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD 70
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301174#define OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS 1
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301175#define OPCODE_ISCSI_INI_CFG_GET_HBA_NAME 6
1176#define OPCODE_ISCSI_INI_CFG_SET_HBA_NAME 7
1177#define OPCODE_ISCSI_INI_SESSION_GET_A_SESSION 14
John Soni Jose3f4134c2015-04-25 08:18:13 +05301178#define OPCODE_ISCSI_INI_SESSION_LOGOUT_TARGET 24
John Soni Jose9aef4202012-08-20 23:00:08 +05301179#define OPCODE_ISCSI_INI_DRIVER_REOPEN_ALL_SESSIONS 36
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301180#define OPCODE_ISCSI_INI_DRIVER_OFFLOAD_SESSION 41
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301181#define OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION 42
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301182#define OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET 52
Jayamohan Kallickalffce3e22012-04-03 23:41:50 -05001183#define OPCODE_COMMON_WRITE_FLASH 96
1184#define OPCODE_COMMON_READ_FLASH 97
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301185
1186/* --- CMD_ISCSI_INVALIDATE_CONNECTION_TYPE --- */
1187#define CMD_ISCSI_COMMAND_INVALIDATE 1
1188#define CMD_ISCSI_CONNECTION_INVALIDATE 0x8001
1189#define CMD_ISCSI_CONNECTION_ISSUE_TCP_RST 0x8002
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301190
1191#define INI_WR_CMD 1 /* Initiator write command */
1192#define INI_TMF_CMD 2 /* Initiator TMF command */
1193#define INI_NOPOUT_CMD 3 /* Initiator; Send a NOP-OUT */
1194#define INI_RD_CMD 5 /* Initiator requesting to send
1195 * a read command
1196 */
1197#define TGT_CTX_UPDT_CMD 7 /* Target context update */
1198#define TGT_STS_CMD 8 /* Target R2T and other BHS
1199 * where only the status number
1200 * need to be updated
1201 */
1202#define TGT_DATAIN_CMD 9 /* Target Data-Ins in response
1203 * to read command
1204 */
1205#define TGT_SOS_PDU 10 /* Target:standalone status
1206 * response
1207 */
1208#define TGT_DM_CMD 11 /* Indicates that the bhs
1209 * preparedby
1210 * driver should not be touched
1211 */
1212/* --- CMD_CHUTE_TYPE --- */
1213#define CMD_CONNECTION_CHUTE_0 1
1214#define CMD_CONNECTION_CHUTE_1 2
1215#define CMD_CONNECTION_CHUTE_2 3
1216
1217#define EQ_MAJOR_CODE_COMPLETION 0
1218
1219#define CMD_ISCSI_SESSION_DEL_CFG_FROM_FLASH 0
1220#define CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH 1
1221
1222/* --- CONNECTION_UPLOAD_PARAMS --- */
1223/* These parameters are used to define the type of upload desired. */
1224#define CONNECTION_UPLOAD_GRACEFUL 1 /* Graceful upload */
1225#define CONNECTION_UPLOAD_ABORT_RESET 2 /* Abortive upload with
1226 * reset
1227 */
1228#define CONNECTION_UPLOAD_ABORT 3 /* Abortive upload without
1229 * reset
1230 */
1231#define CONNECTION_UPLOAD_ABORT_WITH_SEQ 4 /* Abortive upload with reset,
1232 * sequence number by driver */
1233
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301234/* Returns the number of items in the field array. */
1235#define BE_NUMBER_OF_FIELD(_type_, _field_) \
1236 (FIELD_SIZEOF(_type_, _field_)/sizeof((((_type_ *)0)->_field_[0])))\
1237
1238/**
1239 * Different types of iSCSI completions to host driver for both initiator
1240 * and taget mode
1241 * of operation.
1242 */
1243#define SOL_CMD_COMPLETE 1 /* Solicited command completed
1244 * normally
1245 */
1246#define SOL_CMD_KILLED_DATA_DIGEST_ERR 2 /* Solicited command got
1247 * invalidated internally due
1248 * to Data Digest error
1249 */
1250#define CXN_KILLED_PDU_SIZE_EXCEEDS_DSL 3 /* Connection got invalidated
1251 * internally
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001252 * due to a received PDU
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301253 * size > DSL
1254 */
1255#define CXN_KILLED_BURST_LEN_MISMATCH 4 /* Connection got invalidated
1256 * internally due ti received
1257 * PDU sequence size >
1258 * FBL/MBL.
1259 */
1260#define CXN_KILLED_AHS_RCVD 5 /* Connection got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001261 * internally due to a received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301262 * PDU Hdr that has
1263 * AHS */
1264#define CXN_KILLED_HDR_DIGEST_ERR 6 /* Connection got invalidated
1265 * internally due to Hdr Digest
1266 * error
1267 */
1268#define CXN_KILLED_UNKNOWN_HDR 7 /* Connection got invalidated
1269 * internally
1270 * due to a bad opcode in the
1271 * pdu hdr
1272 */
1273#define CXN_KILLED_STALE_ITT_TTT_RCVD 8 /* Connection got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001274 * internally due to a received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301275 * ITT/TTT that does not belong
1276 * to this Connection
1277 */
1278#define CXN_KILLED_INVALID_ITT_TTT_RCVD 9 /* Connection got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001279 * internally due to received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301280 * ITT/TTT value > Max
1281 * Supported ITTs/TTTs
1282 */
1283#define CXN_KILLED_RST_RCVD 10 /* Connection got invalidated
1284 * internally due to an
1285 * incoming TCP RST
1286 */
1287#define CXN_KILLED_TIMED_OUT 11 /* Connection got invalidated
1288 * internally due to timeout on
1289 * tcp segment 12 retransmit
1290 * attempts failed
1291 */
1292#define CXN_KILLED_RST_SENT 12 /* Connection got invalidated
1293 * internally due to TCP RST
1294 * sent by the Tx side
1295 */
1296#define CXN_KILLED_FIN_RCVD 13 /* Connection got invalidated
1297 * internally due to an
1298 * incoming TCP FIN.
1299 */
1300#define CXN_KILLED_BAD_UNSOL_PDU_RCVD 14 /* Connection got invalidated
1301 * internally due to bad
1302 * unsolicited PDU Unsolicited
1303 * PDUs are PDUs with
1304 * ITT=0xffffffff
1305 */
1306#define CXN_KILLED_BAD_WRB_INDEX_ERROR 15 /* Connection got invalidated
1307 * internally due to bad WRB
1308 * index.
1309 */
1310#define CXN_KILLED_OVER_RUN_RESIDUAL 16 /* Command got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001311 * internally due to received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301312 * command has residual
1313 * over run bytes.
1314 */
1315#define CXN_KILLED_UNDER_RUN_RESIDUAL 17 /* Command got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001316 * internally due to received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301317 * command has residual under
1318 * run bytes.
1319 */
1320#define CMD_KILLED_INVALID_STATSN_RCVD 18 /* Command got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001321 * internally due to a received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301322 * PDU has an invalid StatusSN
1323 */
1324#define CMD_KILLED_INVALID_R2T_RCVD 19 /* Command got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001325 * internally due to a received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301326 * an R2T with some invalid
1327 * fields in it
1328 */
1329#define CMD_CXN_KILLED_LUN_INVALID 20 /* Command got invalidated
1330 * internally due to received
1331 * PDU has an invalid LUN.
1332 */
1333#define CMD_CXN_KILLED_ICD_INVALID 21 /* Command got invalidated
1334 * internally due to the
1335 * corresponding ICD not in a
1336 * valid state
1337 */
1338#define CMD_CXN_KILLED_ITT_INVALID 22 /* Command got invalidated due
1339 * to received PDU has an
1340 * invalid ITT.
1341 */
1342#define CMD_CXN_KILLED_SEQ_OUTOFORDER 23 /* Command got invalidated due
1343 * to received sequence buffer
1344 * offset is out of order.
1345 */
1346#define CMD_CXN_KILLED_INVALID_DATASN_RCVD 24 /* Command got invalidated
1347 * internally due to a
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001348 * received PDU has an invalid
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301349 * DataSN
1350 */
1351#define CXN_INVALIDATE_NOTIFY 25 /* Connection invalidation
1352 * completion notify.
1353 */
1354#define CXN_INVALIDATE_INDEX_NOTIFY 26 /* Connection invalidation
1355 * completion
1356 * with data PDU index.
1357 */
1358#define CMD_INVALIDATED_NOTIFY 27 /* Command invalidation
1359 * completionnotifify.
1360 */
1361#define UNSOL_HDR_NOTIFY 28 /* Unsolicited header notify.*/
1362#define UNSOL_DATA_NOTIFY 29 /* Unsolicited data notify.*/
Jayamohan Kallickal457ff3b2010-07-22 04:16:00 +05301363#define UNSOL_DATA_DIGEST_ERROR_NOTIFY 30 /* Unsolicited data digest
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301364 * error notify.
1365 */
1366#define DRIVERMSG_NOTIFY 31 /* TCP acknowledge based
1367 * notification.
1368 */
1369#define CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN 32 /* Connection got invalidated
1370 * internally due to command
1371 * and data are not on same
1372 * connection.
1373 */
1374#define SOL_CMD_KILLED_DIF_ERR 33 /* Solicited command got
1375 * invalidated internally due
1376 * to DIF error
1377 */
1378#define CXN_KILLED_SYN_RCVD 34 /* Connection got invalidated
1379 * internally due to incoming
1380 * TCP SYN
1381 */
1382#define CXN_KILLED_IMM_DATA_RCVD 35 /* Connection got invalidated
1383 * internally due to an
1384 * incoming Unsolicited PDU
1385 * that has immediate data on
1386 * the cxn
1387 */
1388
Jayamohan Kallickale9b91192010-07-22 04:24:53 +05301389int be_chk_reset_complete(struct beiscsi_hba *phba);
1390
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301391void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len,
1392 bool embedded, u8 sge_cnt);
1393
1394void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr,
1395 u8 subsystem, u8 opcode, int cmd_len);
1396
Jitendra Bhivarecdaa4de2016-01-20 14:10:51 +05301397void beiscsi_fail_session(struct iscsi_cls_session *cls_session);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301398#endif /* !BEISCSI_CMDS_H */