blob: cd4410f934c7b611c86cd78d4f6550af83b60c02 [file] [log] [blame]
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301/**
Jayamohan Kallickal533c1652013-04-05 20:38:34 -07002 * Copyright (C) 2005 - 2013 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:
Jayamohan Kallickal255fa9a2011-03-25 14:23:57 -070011 * linux-drivers@emulex.com
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053012 *
Jayamohan Kallickal255fa9a2011-03-25 14:23:57 -070013 * Emulex
14 * 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 {
29 u32 pa_lo;
30 u32 pa_hi;
31 u32 len;
32};
33
34#define MCC_WRB_SGE_CNT_SHIFT 3 /* bits 3 - 7 of dword 0 */
35#define MCC_WRB_SGE_CNT_MASK 0x1F /* bits 3 - 7 of dword 0 */
36struct be_mcc_wrb {
37 u32 embedded; /* dword 0 */
38 u32 payload_length; /* dword 1 */
39 u32 tag0; /* dword 2 */
40 u32 tag1; /* dword 3 */
41 u32 rsvd; /* dword 4 */
42 union {
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
61#define CQE_STATUS_COMPL_MASK 0xFFFF
62#define CQE_STATUS_COMPL_SHIFT 0 /* bits 0 - 15 */
63#define CQE_STATUS_EXTD_MASK 0xFFFF
Jayamohan Kallickalb38c1e82010-07-22 04:28:13 +053064#define CQE_STATUS_EXTD_SHIFT 16 /* bits 0 - 15 */
John Soni Josee175def2012-10-20 04:45:40 +053065#define CQE_STATUS_ADDL_MASK 0xFF00
66#define CQE_STATUS_MASK 0xFF
67#define CQE_STATUS_ADDL_SHIFT 0x08
68#define CQE_STATUS_WRB_MASK 0xFF0000
69#define CQE_STATUS_WRB_SHIFT 16
70#define BEISCSI_HOST_MBX_TIMEOUT (110 * 1000)
71#define BEISCSI_FW_MBX_TIMEOUT 100
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053072
John Soni Joseeaae5262012-10-20 04:43:44 +053073/* MBOX Command VER */
74#define MBX_CMD_VER2 0x02
75
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053076struct be_mcc_compl {
77 u32 status; /* dword 0 */
78 u32 tag0; /* dword 1 */
79 u32 tag1; /* dword 2 */
80 u32 flags; /* dword 3 */
81};
82
83/********* Mailbox door bell *************/
84/**
85 * Used for driver communication with the FW.
86 * The software must write this register twice to post any command. First,
87 * it writes the register with hi=1 and the upper bits of the physical address
88 * for the MAILBOX structure. Software must poll the ready bit until this
89 * is acknowledged. Then, sotware writes the register with hi=0 with the lower
90 * bits in the address. It must poll the ready bit until the command is
91 * complete. Upon completion, the MAILBOX will contain a valid completion
92 * queue entry.
93 */
94#define MPU_MAILBOX_DB_OFFSET 0x160
95#define MPU_MAILBOX_DB_RDY_MASK 0x1 /* bit 0 */
96#define MPU_MAILBOX_DB_HI_MASK 0x2 /* bit 1 */
97
98/********** MPU semphore ******************/
99#define MPU_EP_SEMAPHORE_OFFSET 0xac
100#define EP_SEMAPHORE_POST_STAGE_MASK 0x0000FFFF
101#define EP_SEMAPHORE_POST_ERR_MASK 0x1
102#define EP_SEMAPHORE_POST_ERR_SHIFT 31
103
104/********** MCC door bell ************/
105#define DB_MCCQ_OFFSET 0x140
Jayamohan Kallickale08b3c82014-01-29 02:16:42 -0500106#define DB_MCCQ_RING_ID_MASK 0xFFFF /* bits 0 - 15 */
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530107/* Number of entries posted */
108#define DB_MCCQ_NUM_POSTED_SHIFT 16 /* bits 16 - 29 */
109
110/* MPU semphore POST stage values */
111#define POST_STAGE_ARMFW_RDY 0xc000 /* FW is done with POST */
112
113/**
114 * When the async bit of mcc_compl is set, the last 4 bytes of
115 * mcc_compl is interpreted as follows:
116 */
117#define ASYNC_TRAILER_EVENT_CODE_SHIFT 8 /* bits 8 - 15 */
118#define ASYNC_TRAILER_EVENT_CODE_MASK 0xFF
119#define ASYNC_EVENT_CODE_LINK_STATE 0x1
120struct be_async_event_trailer {
121 u32 code;
122};
123
124enum {
125 ASYNC_EVENT_LINK_DOWN = 0x0,
Jayamohan Kallickal6ea9b3b2013-04-05 20:38:30 -0700126 ASYNC_EVENT_LINK_UP = 0x1,
127 ASYNC_EVENT_LOGICAL = 0x2
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530128};
129
130/**
131 * When the event code of an async trailer is link-state, the mcc_compl
132 * must be interpreted as follows
133 */
134struct be_async_event_link_state {
135 u8 physical_port;
136 u8 port_link_status;
137 u8 port_duplex;
138 u8 port_speed;
Jayamohan Kallickal6ea9b3b2013-04-05 20:38:30 -0700139#define BEISCSI_PHY_LINK_FAULT_NONE 0x00
140#define BEISCSI_PHY_LINK_FAULT_LOCAL 0x01
141#define BEISCSI_PHY_LINK_FAULT_REMOTE 0x02
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530142 u8 port_fault;
143 u8 rsvd0[7];
144 struct be_async_event_trailer trailer;
145} __packed;
146
147struct be_mcc_mailbox {
148 struct be_mcc_wrb wrb;
149 struct be_mcc_compl compl;
150};
151
152/* Type of subsystems supported by FW */
153#define CMD_SUBSYSTEM_COMMON 0x1
154#define CMD_SUBSYSTEM_ISCSI 0x2
155#define CMD_SUBSYSTEM_ETH 0x3
156#define CMD_SUBSYSTEM_ISCSI_INI 0x6
157#define CMD_COMMON_TCP_UPLOAD 0x1
158
159/**
160 * List of common opcodes subsystem CMD_SUBSYSTEM_COMMON
161 * These opcodes are unique for each subsystem defined above
162 */
163#define OPCODE_COMMON_CQ_CREATE 12
164#define OPCODE_COMMON_EQ_CREATE 13
Jayamohan Kallickal457ff3b2010-07-22 04:16:00 +0530165#define OPCODE_COMMON_MCC_CREATE 21
Jayamohan Kallickal15a90fe2013-09-28 15:35:38 -0700166#define OPCODE_COMMON_ADD_TEMPLATE_HEADER_BUFFERS 24
167#define OPCODE_COMMON_REMOVE_TEMPLATE_HEADER_BUFFERS 25
Jayamohan Kallickal457ff3b2010-07-22 04:16:00 +0530168#define OPCODE_COMMON_GET_CNTL_ATTRIBUTES 32
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530169#define OPCODE_COMMON_GET_FW_VERSION 35
170#define OPCODE_COMMON_MODIFY_EQ_DELAY 41
171#define OPCODE_COMMON_FIRMWARE_CONFIG 42
Jayamohan Kallickal457ff3b2010-07-22 04:16:00 +0530172#define OPCODE_COMMON_MCC_DESTROY 53
173#define OPCODE_COMMON_CQ_DESTROY 54
174#define OPCODE_COMMON_EQ_DESTROY 55
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530175#define OPCODE_COMMON_QUERY_FIRMWARE_CONFIG 58
176#define OPCODE_COMMON_FUNCTION_RESET 61
177
178/**
179 * LIST of opcodes that are common between Initiator and Target
180 * used by CMD_SUBSYSTEM_ISCSI
181 * These opcodes are unique for each subsystem defined above
182 */
183#define OPCODE_COMMON_ISCSI_CFG_POST_SGL_PAGES 2
184#define OPCODE_COMMON_ISCSI_CFG_REMOVE_SGL_PAGES 3
185#define OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG 7
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530186#define OPCODE_COMMON_ISCSI_NTWK_SET_VLAN 14
Mike Christie0e438952012-04-03 23:41:51 -0500187#define OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR 17
188#define OPCODE_COMMON_ISCSI_NTWK_REL_STATELESS_IP_ADDR 18
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530189#define OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR 21
190#define OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY 22
191#define OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY 23
192#define OPCODE_COMMON_ISCSI_NTWK_GET_ALL_IF_ID 24
193#define OPCODE_COMMON_ISCSI_NTWK_GET_IF_INFO 25
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530194#define OPCODE_COMMON_ISCSI_SET_FRAGNUM_BITS_FOR_SGL_CRA 61
195#define OPCODE_COMMON_ISCSI_DEFQ_CREATE 64
Jayamohan Kallickal457ff3b2010-07-22 04:16:00 +0530196#define OPCODE_COMMON_ISCSI_DEFQ_DESTROY 65
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530197#define OPCODE_COMMON_ISCSI_WRBQ_CREATE 66
Jayamohan Kallickal457ff3b2010-07-22 04:16:00 +0530198#define OPCODE_COMMON_ISCSI_WRBQ_DESTROY 67
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530199
200struct be_cmd_req_hdr {
201 u8 opcode; /* dword 0 */
202 u8 subsystem; /* dword 0 */
203 u8 port_number; /* dword 0 */
204 u8 domain; /* dword 0 */
205 u32 timeout; /* dword 1 */
206 u32 request_length; /* dword 2 */
John Soni Joseeaae5262012-10-20 04:43:44 +0530207 u8 version; /* dword 3 */
208 u8 rsvd0[3]; /* dword 3 */
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530209};
210
211struct be_cmd_resp_hdr {
212 u32 info; /* dword 0 */
213 u32 status; /* dword 1 */
214 u32 response_length; /* dword 2 */
215 u32 actual_resp_len; /* dword 3 */
216};
217
218struct phys_addr {
219 u32 lo;
220 u32 hi;
221};
222
Jayamohan Kallickal15a90fe2013-09-28 15:35:38 -0700223struct virt_addr {
224 u32 lo;
225 u32 hi;
226};
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530227/**************************
228 * BE Command definitions *
229 **************************/
230
231/**
232 * Pseudo amap definition in which each bit of the actual structure is defined
233 * as a byte - used to calculate offset/shift/mask of each field
234 */
235struct amap_eq_context {
236 u8 cidx[13]; /* dword 0 */
237 u8 rsvd0[3]; /* dword 0 */
238 u8 epidx[13]; /* dword 0 */
239 u8 valid; /* dword 0 */
240 u8 rsvd1; /* dword 0 */
241 u8 size; /* dword 0 */
242 u8 pidx[13]; /* dword 1 */
243 u8 rsvd2[3]; /* dword 1 */
244 u8 pd[10]; /* dword 1 */
245 u8 count[3]; /* dword 1 */
246 u8 solevent; /* dword 1 */
247 u8 stalled; /* dword 1 */
248 u8 armed; /* dword 1 */
249 u8 rsvd3[4]; /* dword 2 */
250 u8 func[8]; /* dword 2 */
251 u8 rsvd4; /* dword 2 */
252 u8 delaymult[10]; /* dword 2 */
253 u8 rsvd5[2]; /* dword 2 */
254 u8 phase[2]; /* dword 2 */
255 u8 nodelay; /* dword 2 */
256 u8 rsvd6[4]; /* dword 2 */
257 u8 rsvd7[32]; /* dword 3 */
258} __packed;
259
260struct be_cmd_req_eq_create {
261 struct be_cmd_req_hdr hdr; /* dw[4] */
262 u16 num_pages; /* sword */
263 u16 rsvd0; /* sword */
264 u8 context[sizeof(struct amap_eq_context) / 8]; /* dw[4] */
265 struct phys_addr pages[8];
266} __packed;
267
268struct be_cmd_resp_eq_create {
269 struct be_cmd_resp_hdr resp_hdr;
270 u16 eq_id; /* sword */
271 u16 rsvd0; /* sword */
272} __packed;
273
Jayamohan Kallickal73af08e2014-05-05 21:41:26 -0400274struct be_set_eqd {
275 u32 eq_id;
276 u32 phase;
277 u32 delay_multiplier;
278} __packed;
279
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530280struct mgmt_chap_format {
281 u32 flags;
282 u8 intr_chap_name[256];
283 u8 intr_secret[16];
284 u8 target_chap_name[256];
285 u8 target_secret[16];
286 u16 intr_chap_name_length;
287 u16 intr_secret_length;
288 u16 target_chap_name_length;
289 u16 target_secret_length;
290} __packed;
291
292struct mgmt_auth_method_format {
293 u8 auth_method_type;
294 u8 padding[3];
295 struct mgmt_chap_format chap;
296} __packed;
297
298struct mgmt_conn_login_options {
299 u8 flags;
300 u8 header_digest;
301 u8 data_digest;
302 u8 rsvd0;
303 u32 max_recv_datasegment_len_ini;
304 u32 max_recv_datasegment_len_tgt;
305 u32 tcp_mss;
306 u32 tcp_window_size;
307 struct mgmt_auth_method_format auth_data;
308} __packed;
309
Mike Christie0e438952012-04-03 23:41:51 -0500310struct ip_addr_format {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530311 u16 size_of_structure;
312 u8 reserved;
313 u8 ip_type;
Mike Christie0e438952012-04-03 23:41:51 -0500314 u8 addr[16];
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530315 u32 rsvd0;
316} __packed;
317
Mike Christie0e438952012-04-03 23:41:51 -0500318struct mgmt_conn_info {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530319 u32 connection_handle;
320 u32 connection_status;
321 u16 src_port;
322 u16 dest_port;
323 u16 dest_port_redirected;
324 u16 cid;
325 u32 estimated_throughput;
Mike Christie0e438952012-04-03 23:41:51 -0500326 struct ip_addr_format src_ipaddr;
327 struct ip_addr_format dest_ipaddr;
328 struct ip_addr_format dest_ipaddr_redirected;
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530329 struct mgmt_conn_login_options negotiated_login_options;
330} __packed;
331
332struct mgmt_session_login_options {
333 u8 flags;
334 u8 error_recovery_level;
335 u16 rsvd0;
336 u32 first_burst_length;
337 u32 max_burst_length;
338 u16 max_connections;
339 u16 max_outstanding_r2t;
340 u16 default_time2wait;
341 u16 default_time2retain;
342} __packed;
343
344struct mgmt_session_info {
345 u32 session_handle;
346 u32 status;
347 u8 isid[6];
348 u16 tsih;
349 u32 session_flags;
350 u16 conn_count;
351 u16 pad;
352 u8 target_name[224];
353 u8 initiator_iscsiname[224];
354 struct mgmt_session_login_options negotiated_login_options;
355 struct mgmt_conn_info conn_list[1];
356} __packed;
357
Mike Christie0e438952012-04-03 23:41:51 -0500358struct be_cmd_get_session_req {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530359 struct be_cmd_req_hdr hdr;
360 u32 session_handle;
361} __packed;
362
Mike Christie0e438952012-04-03 23:41:51 -0500363struct be_cmd_get_session_resp {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530364 struct be_cmd_resp_hdr hdr;
365 struct mgmt_session_info session_info;
366} __packed;
367
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530368struct mac_addr {
Mike Christie0e438952012-04-03 23:41:51 -0500369 u16 size_of_structure;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530370 u8 addr[ETH_ALEN];
371} __packed;
372
Mike Christie0e438952012-04-03 23:41:51 -0500373struct be_cmd_get_boot_target_req {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530374 struct be_cmd_req_hdr hdr;
375} __packed;
376
Mike Christie0e438952012-04-03 23:41:51 -0500377struct be_cmd_get_boot_target_resp {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530378 struct be_cmd_resp_hdr hdr;
379 u32 boot_session_count;
380 int boot_session_handle;
381};
382
John Soni Jose9aef4202012-08-20 23:00:08 +0530383struct be_cmd_reopen_session_req {
384 struct be_cmd_req_hdr hdr;
385#define BE_REOPEN_ALL_SESSIONS 0x00
386#define BE_REOPEN_BOOT_SESSIONS 0x01
387#define BE_REOPEN_A_SESSION 0x02
388 u16 reopen_type;
389 u16 rsvd;
390 u32 session_handle;
391} __packed;
392
393struct be_cmd_reopen_session_resp {
394 struct be_cmd_resp_hdr hdr;
395 u32 rsvd;
396 u32 session_handle;
397} __packed;
398
399
Mike Christie0e438952012-04-03 23:41:51 -0500400struct be_cmd_mac_query_req {
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530401 struct be_cmd_req_hdr hdr;
402 u8 type;
403 u8 permanent;
404 u16 if_id;
405} __packed;
406
Mike Christie0e438952012-04-03 23:41:51 -0500407struct be_cmd_get_mac_resp {
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530408 struct be_cmd_resp_hdr hdr;
409 struct mac_addr mac;
410};
411
Mike Christie0e438952012-04-03 23:41:51 -0500412struct be_ip_addr_subnet_format {
413 u16 size_of_structure;
414 u8 ip_type;
415 u8 ipv6_prefix_length;
416 u8 addr[16];
417 u8 subnet_mask[16];
418 u32 rsvd0;
419} __packed;
420
421struct be_cmd_get_if_info_req {
422 struct be_cmd_req_hdr hdr;
423 u32 interface_hndl;
424 u32 ip_type;
425} __packed;
426
427struct be_cmd_get_if_info_resp {
428 struct be_cmd_req_hdr hdr;
429 u32 interface_hndl;
430 u32 vlan_priority;
431 u32 ip_addr_count;
432 u32 dhcp_state;
433 struct be_ip_addr_subnet_format ip_addr;
434} __packed;
435
436struct be_ip_addr_record {
437 u32 action;
438 u32 interface_hndl;
439 struct be_ip_addr_subnet_format ip_addr;
440 u32 status;
441} __packed;
442
443struct be_ip_addr_record_params {
444 u32 record_entry_count;
445 struct be_ip_addr_record ip_record;
446} __packed;
447
448struct be_cmd_set_ip_addr_req {
449 struct be_cmd_req_hdr hdr;
450 struct be_ip_addr_record_params ip_params;
451} __packed;
452
453
454struct be_cmd_set_dhcp_req {
455 struct be_cmd_req_hdr hdr;
456 u32 interface_hndl;
457 u32 ip_type;
458 u32 flags;
459 u32 retry_count;
460} __packed;
461
462struct be_cmd_rel_dhcp_req {
463 struct be_cmd_req_hdr hdr;
464 u32 interface_hndl;
465 u32 ip_type;
466} __packed;
467
468struct be_cmd_set_def_gateway_req {
469 struct be_cmd_req_hdr hdr;
470 u32 action;
471 struct ip_addr_format ip_addr;
472} __packed;
473
474struct be_cmd_get_def_gateway_req {
475 struct be_cmd_req_hdr hdr;
476 u32 ip_type;
477} __packed;
478
479struct be_cmd_get_def_gateway_resp {
480 struct be_cmd_req_hdr hdr;
481 struct ip_addr_format ip_addr;
482} __packed;
483
John Soni Jose6f72238e2012-08-20 23:00:43 +0530484#define BEISCSI_VLAN_DISABLE 0xFFFF
485struct be_cmd_set_vlan_req {
486 struct be_cmd_req_hdr hdr;
487 u32 interface_hndl;
488 u32 vlan_priority;
489} __packed;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530490/******************** Create CQ ***************************/
491/**
492 * Pseudo amap definition in which each bit of the actual structure is defined
493 * as a byte - used to calculate offset/shift/mask of each field
494 */
495struct amap_cq_context {
496 u8 cidx[11]; /* dword 0 */
497 u8 rsvd0; /* dword 0 */
498 u8 coalescwm[2]; /* dword 0 */
499 u8 nodelay; /* dword 0 */
500 u8 epidx[11]; /* dword 0 */
501 u8 rsvd1; /* dword 0 */
502 u8 count[2]; /* dword 0 */
503 u8 valid; /* dword 0 */
504 u8 solevent; /* dword 0 */
505 u8 eventable; /* dword 0 */
506 u8 pidx[11]; /* dword 1 */
507 u8 rsvd2; /* dword 1 */
508 u8 pd[10]; /* dword 1 */
509 u8 eqid[8]; /* dword 1 */
510 u8 stalled; /* dword 1 */
511 u8 armed; /* dword 1 */
512 u8 rsvd3[4]; /* dword 2 */
513 u8 func[8]; /* dword 2 */
514 u8 rsvd4[20]; /* dword 2 */
515 u8 rsvd5[32]; /* dword 3 */
516} __packed;
517
John Soni Joseeaae5262012-10-20 04:43:44 +0530518struct amap_cq_context_v2 {
519 u8 rsvd0[12]; /* dword 0 */
520 u8 coalescwm[2]; /* dword 0 */
521 u8 nodelay; /* dword 0 */
522 u8 rsvd1[12]; /* dword 0 */
523 u8 count[2]; /* dword 0 */
524 u8 valid; /* dword 0 */
525 u8 rsvd2; /* dword 0 */
526 u8 eventable; /* dword 0 */
527 u8 eqid[16]; /* dword 1 */
528 u8 rsvd3[15]; /* dword 1 */
529 u8 armed; /* dword 1 */
530 u8 cqecount[16];/* dword 2 */
531 u8 rsvd4[16]; /* dword 2 */
532 u8 rsvd5[32]; /* dword 3 */
533};
534
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530535struct be_cmd_req_cq_create {
536 struct be_cmd_req_hdr hdr;
537 u16 num_pages;
John Soni Joseeaae5262012-10-20 04:43:44 +0530538 u8 page_size;
539 u8 rsvd0;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530540 u8 context[sizeof(struct amap_cq_context) / 8];
541 struct phys_addr pages[4];
542} __packed;
543
544struct be_cmd_resp_cq_create {
545 struct be_cmd_resp_hdr hdr;
546 u16 cq_id;
547 u16 rsvd0;
548} __packed;
549
550/******************** Create MCCQ ***************************/
551/**
552 * Pseudo amap definition in which each bit of the actual structure is defined
553 * as a byte - used to calculate offset/shift/mask of each field
554 */
555struct amap_mcc_context {
556 u8 con_index[14];
557 u8 rsvd0[2];
558 u8 ring_size[4];
559 u8 fetch_wrb;
560 u8 fetch_r2t;
561 u8 cq_id[10];
562 u8 prod_index[14];
563 u8 fid[8];
564 u8 pdid[9];
565 u8 valid;
566 u8 rsvd1[32];
567 u8 rsvd2[32];
568} __packed;
569
570struct be_cmd_req_mcc_create {
571 struct be_cmd_req_hdr hdr;
572 u16 num_pages;
573 u16 rsvd0;
574 u8 context[sizeof(struct amap_mcc_context) / 8];
575 struct phys_addr pages[8];
576} __packed;
577
578struct be_cmd_resp_mcc_create {
579 struct be_cmd_resp_hdr hdr;
580 u16 id;
581 u16 rsvd0;
582} __packed;
583
584/******************** Q Destroy ***************************/
585/* Type of Queue to be destroyed */
586enum {
587 QTYPE_EQ = 1,
588 QTYPE_CQ,
589 QTYPE_MCCQ,
590 QTYPE_WRBQ,
591 QTYPE_DPDUQ,
592 QTYPE_SGL
593};
594
595struct be_cmd_req_q_destroy {
596 struct be_cmd_req_hdr hdr;
597 u16 id;
598 u16 bypass_flush; /* valid only for rx q destroy */
599} __packed;
600
601struct macaddr {
602 u8 byte[ETH_ALEN];
603};
604
605struct be_cmd_req_mcast_mac_config {
606 struct be_cmd_req_hdr hdr;
607 u16 num_mac;
608 u8 promiscuous;
609 u8 interface_id;
610 struct macaddr mac[32];
611} __packed;
612
613static inline void *embedded_payload(struct be_mcc_wrb *wrb)
614{
615 return wrb->payload.embedded_payload;
616}
617
618static inline struct be_sge *nonembedded_sgl(struct be_mcc_wrb *wrb)
619{
620 return &wrb->payload.sgl[0];
621}
622
623/******************** Modify EQ Delay *******************/
624struct be_cmd_req_modify_eq_delay {
625 struct be_cmd_req_hdr hdr;
626 u32 num_eq;
627 struct {
628 u32 eq_id;
629 u32 phase;
630 u32 delay_multiplier;
Jayamohan Kallickal73af08e2014-05-05 21:41:26 -0400631 } delay[MAX_CPUS];
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530632} __packed;
633
634/******************** Get MAC ADDR *******************/
635
636#define ETH_ALEN 6
637
Mike Christie0e438952012-04-03 23:41:51 -0500638struct be_cmd_get_nic_conf_req {
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530639 struct be_cmd_req_hdr hdr;
640 u32 nic_port_count;
641 u32 speed;
642 u32 max_speed;
643 u32 link_state;
644 u32 max_frame_size;
645 u16 size_of_structure;
646 u8 mac_address[ETH_ALEN];
647 u32 rsvd[23];
648};
649
Mike Christie0e438952012-04-03 23:41:51 -0500650struct be_cmd_get_nic_conf_resp {
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530651 struct be_cmd_resp_hdr hdr;
652 u32 nic_port_count;
653 u32 speed;
654 u32 max_speed;
655 u32 link_state;
656 u32 max_frame_size;
657 u16 size_of_structure;
658 u8 mac_address[6];
659 u32 rsvd[23];
660};
661
John Soni Jose21771992012-04-03 23:41:49 -0500662#define BEISCSI_ALIAS_LEN 32
663
664struct be_cmd_hba_name {
665 struct be_cmd_req_hdr hdr;
666 u16 flags;
667 u16 rsvd0;
668 u8 initiator_name[ISCSI_NAME_LEN];
669 u8 initiator_alias[BEISCSI_ALIAS_LEN];
670} __packed;
671
John Soni Josec62eef02012-04-03 23:41:52 -0500672struct be_cmd_ntwk_link_status_req {
673 struct be_cmd_req_hdr hdr;
674 u32 rsvd0;
675} __packed;
676
677/*** Port Speed Values ***/
678#define BE2ISCSI_LINK_SPEED_ZERO 0x00
679#define BE2ISCSI_LINK_SPEED_10MBPS 0x01
680#define BE2ISCSI_LINK_SPEED_100MBPS 0x02
681#define BE2ISCSI_LINK_SPEED_1GBPS 0x03
682#define BE2ISCSI_LINK_SPEED_10GBPS 0x04
683struct be_cmd_ntwk_link_status_resp {
684 struct be_cmd_resp_hdr hdr;
685 u8 phys_port;
686 u8 mac_duplex;
687 u8 mac_speed;
688 u8 mac_fault;
689 u8 mgmt_mac_duplex;
690 u8 mgmt_mac_speed;
691 u16 qos_link_speed;
692 u32 logical_link_speed;
693} __packed;
John Soni Jose21771992012-04-03 23:41:49 -0500694
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530695int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl,
696 struct be_queue_info *eq, int eq_delay);
697
698int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl,
699 struct be_queue_info *cq, struct be_queue_info *eq,
700 bool sol_evts, bool no_delay,
701 int num_cqe_dma_coalesce);
702
703int beiscsi_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q,
704 int type);
Jayamohan Kallickal35e66012009-10-23 11:53:49 +0530705int beiscsi_cmd_mccq_create(struct beiscsi_hba *phba,
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530706 struct be_queue_info *mccq,
707 struct be_queue_info *cq);
708
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530709int be_poll_mcc(struct be_ctrl_info *ctrl);
Jayamohan Kallickal03a12312010-07-22 04:17:16 +0530710int mgmt_check_supported_fw(struct be_ctrl_info *ctrl,
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530711 struct beiscsi_hba *phba);
John Soni Jose21771992012-04-03 23:41:49 -0500712unsigned int be_cmd_get_initname(struct beiscsi_hba *phba);
John Soni Josec62eef02012-04-03 23:41:52 -0500713unsigned int be_cmd_get_port_speed(struct beiscsi_hba *phba);
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530714
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530715void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag);
John Soni Josee175def2012-10-20 04:45:40 +0530716
Jayamohan Kallickal73af08e2014-05-05 21:41:26 -0400717int be_cmd_modify_eq_delay(struct beiscsi_hba *phba, struct be_set_eqd *,
718 int num);
John Soni Josee175def2012-10-20 04:45:40 +0530719int beiscsi_mccq_compl(struct beiscsi_hba *phba,
Jayamohan Kallickal1957aa72014-01-29 02:16:39 -0500720 uint32_t tag, struct be_mcc_wrb **wrb,
721 struct be_dma_mem *mbx_cmd_mem);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530722/*ISCSI Functuions */
723int be_cmd_fw_initialize(struct be_ctrl_info *ctrl);
Jayamohan Kallickal0283fbb2013-04-05 20:38:21 -0700724int be_cmd_fw_uninit(struct be_ctrl_info *ctrl);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530725
726struct be_mcc_wrb *wrb_from_mbox(struct be_dma_mem *mbox_mem);
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530727struct be_mcc_wrb *wrb_from_mccq(struct beiscsi_hba *phba);
728int be_mcc_notify_wait(struct beiscsi_hba *phba);
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530729void be_mcc_notify(struct beiscsi_hba *phba);
730unsigned int alloc_mcc_tag(struct beiscsi_hba *phba);
731void beiscsi_async_link_state_process(struct beiscsi_hba *phba,
732 struct be_async_event_link_state *evt);
733int be_mcc_compl_process_isr(struct be_ctrl_info *ctrl,
734 struct be_mcc_compl *compl);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530735
736int be_mbox_notify(struct be_ctrl_info *ctrl);
737
738int be_cmd_create_default_pdu_queue(struct be_ctrl_info *ctrl,
739 struct be_queue_info *cq,
740 struct be_queue_info *dq, int length,
Jayamohan Kallickal8a86e832013-09-28 15:35:45 -0700741 int entry_size, uint8_t is_header,
742 uint8_t ulp_num);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530743
Jayamohan Kallickal15a90fe2013-09-28 15:35:38 -0700744int be_cmd_iscsi_post_template_hdr(struct be_ctrl_info *ctrl,
745 struct be_dma_mem *q_mem);
746
747int be_cmd_iscsi_remove_template_hdr(struct be_ctrl_info *ctrl);
748
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530749int be_cmd_iscsi_post_sgl_pages(struct be_ctrl_info *ctrl,
750 struct be_dma_mem *q_mem, u32 page_offset,
751 u32 num_pages);
752
Jayamohan Kallickale5285862011-10-07 19:31:08 -0500753int beiscsi_cmd_reset_function(struct beiscsi_hba *phba);
754
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530755int be_cmd_wrbq_create(struct be_ctrl_info *ctrl, struct be_dma_mem *q_mem,
Jayamohan Kallickal4eea99d2013-09-28 15:35:48 -0700756 struct be_queue_info *wrbq,
757 struct hwi_wrb_context *pwrb_context,
758 uint8_t ulp_num);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530759
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530760bool is_link_state_evt(u32 trailer);
761
John Soni Jose6f72238e2012-08-20 23:00:43 +0530762/* Configuration Functions */
763int be_cmd_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag);
764
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530765struct be_default_pdu_context {
766 u32 dw[4];
767} __packed;
768
769struct amap_be_default_pdu_context {
770 u8 dbuf_cindex[13]; /* dword 0 */
771 u8 rsvd0[3]; /* dword 0 */
772 u8 ring_size[4]; /* dword 0 */
773 u8 ring_state[4]; /* dword 0 */
774 u8 rsvd1[8]; /* dword 0 */
775 u8 dbuf_pindex[13]; /* dword 1 */
776 u8 rsvd2; /* dword 1 */
777 u8 pci_func_id[8]; /* dword 1 */
778 u8 rx_pdid[9]; /* dword 1 */
779 u8 rx_pdid_valid; /* dword 1 */
780 u8 default_buffer_size[16]; /* dword 2 */
781 u8 cq_id_recv[10]; /* dword 2 */
782 u8 rx_pdid_not_valid; /* dword 2 */
783 u8 rsvd3[5]; /* dword 2 */
784 u8 rsvd4[32]; /* dword 3 */
785} __packed;
786
Jayamohan Kallickalef9e1b92013-04-05 20:38:27 -0700787struct amap_default_pdu_context_ext {
788 u8 rsvd0[16]; /* dword 0 */
789 u8 ring_size[4]; /* dword 0 */
790 u8 rsvd1[12]; /* dword 0 */
791 u8 rsvd2[22]; /* 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[16]; /* dword 2 */
796 u8 rsvd3[32]; /* dword 3 */
797} __packed;
798
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530799struct be_defq_create_req {
800 struct be_cmd_req_hdr hdr;
801 u16 num_pages;
802 u8 ulp_num;
Jayamohan Kallickal8a86e832013-09-28 15:35:45 -0700803#define BEISCSI_DUAL_ULP_AWARE_BIT 0 /* Byte 3 - Bit 0 */
804#define BEISCSI_BIND_Q_TO_ULP_BIT 1 /* Byte 3 - Bit 1 */
805 u8 dua_feature;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530806 struct be_default_pdu_context context;
807 struct phys_addr pages[8];
808} __packed;
809
810struct be_defq_create_resp {
811 struct be_cmd_req_hdr hdr;
812 u16 id;
Jayamohan Kallickal8a86e832013-09-28 15:35:45 -0700813 u8 rsvd0;
814 u8 ulp_num;
815 u32 doorbell_offset;
816 u16 register_set;
817 u16 doorbell_format;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530818} __packed;
819
Jayamohan Kallickal15a90fe2013-09-28 15:35:38 -0700820struct be_post_template_pages_req {
821 struct be_cmd_req_hdr hdr;
822 u16 num_pages;
823#define BEISCSI_TEMPLATE_HDR_TYPE_ISCSI 0x1
824 u16 type;
825 struct phys_addr scratch_pa;
826 struct virt_addr scratch_va;
827 struct virt_addr pages_va;
828 struct phys_addr pages[16];
829} __packed;
830
831struct be_remove_template_pages_req {
832 struct be_cmd_req_hdr hdr;
833 u16 type;
834 u16 rsvd0;
835} __packed;
836
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530837struct be_post_sgl_pages_req {
838 struct be_cmd_req_hdr hdr;
839 u16 num_pages;
840 u16 page_offset;
841 u32 rsvd0;
842 struct phys_addr pages[26];
843 u32 rsvd1;
844} __packed;
845
846struct be_wrbq_create_req {
847 struct be_cmd_req_hdr hdr;
848 u16 num_pages;
849 u8 ulp_num;
Jayamohan Kallickal4eea99d2013-09-28 15:35:48 -0700850 u8 dua_feature;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530851 struct phys_addr pages[8];
852} __packed;
853
854struct be_wrbq_create_resp {
855 struct be_cmd_resp_hdr resp_hdr;
856 u16 cid;
Jayamohan Kallickal4eea99d2013-09-28 15:35:48 -0700857 u8 rsvd0;
858 u8 ulp_num;
859 u32 doorbell_offset;
860 u16 register_set;
861 u16 doorbell_format;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530862} __packed;
863
864#define SOL_CID_MASK 0x0000FFC0
865#define SOL_CODE_MASK 0x0000003F
866#define SOL_WRB_INDEX_MASK 0x00FF0000
867#define SOL_CMD_WND_MASK 0xFF000000
868#define SOL_RES_CNT_MASK 0x7FFFFFFF
869#define SOL_EXP_CMD_SN_MASK 0xFFFFFFFF
870#define SOL_HW_STS_MASK 0x000000FF
871#define SOL_STS_MASK 0x0000FF00
872#define SOL_RESP_MASK 0x00FF0000
873#define SOL_FLAGS_MASK 0x7F000000
874#define SOL_S_MASK 0x80000000
875
876struct sol_cqe {
877 u32 dw[4];
878};
879
880struct amap_sol_cqe {
881 u8 hw_sts[8]; /* dword 0 */
882 u8 i_sts[8]; /* dword 0 */
883 u8 i_resp[8]; /* dword 0 */
884 u8 i_flags[7]; /* dword 0 */
885 u8 s; /* dword 0 */
886 u8 i_exp_cmd_sn[32]; /* dword 1 */
887 u8 code[6]; /* dword 2 */
888 u8 cid[10]; /* dword 2 */
889 u8 wrb_index[8]; /* dword 2 */
890 u8 i_cmd_wnd[8]; /* dword 2 */
891 u8 i_res_cnt[31]; /* dword 3 */
892 u8 valid; /* dword 3 */
893} __packed;
894
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530895#define SOL_ICD_INDEX_MASK 0x0003FFC0
896struct amap_sol_cqe_ring {
897 u8 hw_sts[8]; /* dword 0 */
898 u8 i_sts[8]; /* dword 0 */
899 u8 i_resp[8]; /* dword 0 */
900 u8 i_flags[7]; /* dword 0 */
901 u8 s; /* dword 0 */
902 u8 i_exp_cmd_sn[32]; /* dword 1 */
903 u8 code[6]; /* dword 2 */
904 u8 icd_index[12]; /* dword 2 */
905 u8 rsvd[6]; /* dword 2 */
906 u8 i_cmd_wnd[8]; /* dword 2 */
907 u8 i_res_cnt[31]; /* dword 3 */
908 u8 valid; /* dword 3 */
909} __packed;
910
John Soni Jose73133262012-10-20 04:44:49 +0530911struct amap_sol_cqe_v2 {
912 u8 hw_sts[8]; /* dword 0 */
913 u8 i_sts[8]; /* dword 0 */
914 u8 wrb_index[16]; /* dword 0 */
915 u8 i_exp_cmd_sn[32]; /* dword 1 */
916 u8 code[6]; /* dword 2 */
917 u8 cmd_cmpl; /* dword 2 */
918 u8 rsvd0; /* dword 2 */
919 u8 i_cmd_wnd[8]; /* dword 2 */
920 u8 cid[13]; /* dword 2 */
921 u8 u; /* dword 2 */
922 u8 o; /* dword 2 */
923 u8 s; /* dword 2 */
924 u8 i_res_cnt[31]; /* dword 3 */
925 u8 valid; /* dword 3 */
926} __packed;
927
928struct common_sol_cqe {
929 u32 exp_cmdsn;
930 u32 res_cnt;
931 u16 wrb_index;
932 u16 cid;
933 u8 hw_sts;
934 u8 cmd_wnd;
935 u8 res_flag; /* the s feild of structure */
936 u8 i_resp; /* for skh if cmd_complete is set then i_sts is response */
937 u8 i_flags; /* for skh or the u and o feilds */
938 u8 i_sts; /* for skh if cmd_complete is not-set then i_sts is status */
939};
940
941/*** iSCSI ack/driver message completions ***/
942struct amap_it_dmsg_cqe {
943 u8 ack_num[32]; /* DWORD 0 */
944 u8 pdu_bytes_rcvd[32]; /* DWORD 1 */
945 u8 code[6]; /* DWORD 2 */
946 u8 cid[10]; /* DWORD 2 */
947 u8 wrb_idx[8]; /* DWORD 2 */
948 u8 rsvd0[8]; /* DWORD 2*/
949 u8 rsvd1[31]; /* DWORD 3*/
950 u8 valid; /* DWORD 3 */
951} __packed;
952
953struct amap_it_dmsg_cqe_v2 {
954 u8 ack_num[32]; /* DWORD 0 */
955 u8 pdu_bytes_rcvd[32]; /* DWORD 1 */
956 u8 code[6]; /* DWORD 2 */
957 u8 rsvd0[10]; /* DWORD 2 */
958 u8 wrb_idx[16]; /* DWORD 2 */
959 u8 rsvd1[16]; /* DWORD 3 */
960 u8 cid[13]; /* DWORD 3 */
961 u8 rsvd2[2]; /* DWORD 3 */
962 u8 valid; /* DWORD 3 */
963} __packed;
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530964
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530965
966/**
967 * Post WRB Queue Doorbell Register used by the host Storage
968 * stack to notify the
969 * controller of a posted Work Request Block
970 */
Jayamohan Kallickalef9e1b92013-04-05 20:38:27 -0700971#define DB_WRB_POST_CID_MASK 0xFFFF /* bits 0 - 16 */
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530972#define DB_DEF_PDU_WRB_INDEX_MASK 0xFF /* bits 0 - 9 */
973
974#define DB_DEF_PDU_WRB_INDEX_SHIFT 16
975#define DB_DEF_PDU_NUM_POSTED_SHIFT 24
976
977struct fragnum_bits_for_sgl_cra_in {
978 struct be_cmd_req_hdr hdr;
979 u32 num_bits;
980} __packed;
981
982struct iscsi_cleanup_req {
983 struct be_cmd_req_hdr hdr;
984 u16 chute;
985 u8 hdr_ring_id;
986 u8 data_ring_id;
987
988} __packed;
989
990struct eq_delay {
991 u32 eq_id;
992 u32 phase;
993 u32 delay_multiplier;
994} __packed;
995
996struct be_eq_delay_params_in {
997 struct be_cmd_req_hdr hdr;
998 u32 num_eq;
999 struct eq_delay delay[8];
1000} __packed;
1001
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301002struct tcp_connect_and_offload_in {
1003 struct be_cmd_req_hdr hdr;
Mike Christie0e438952012-04-03 23:41:51 -05001004 struct ip_addr_format ip_address;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301005 u16 tcp_port;
1006 u16 cid;
1007 u16 cq_id;
1008 u16 defq_id;
1009 struct phys_addr dataout_template_pa;
1010 u16 hdr_ring_id;
1011 u16 data_ring_id;
1012 u8 do_offload;
1013 u8 rsvd0[3];
1014} __packed;
1015
1016struct tcp_connect_and_offload_out {
1017 struct be_cmd_resp_hdr hdr;
1018 u32 connection_handle;
1019 u16 cid;
1020 u16 rsvd0;
1021
1022} __packed;
1023
1024struct be_mcc_wrb_context {
1025 struct MCC_WRB *wrb;
1026 int *users_final_status;
1027} __packed;
1028
Jayamohan Kallickale08b3c82014-01-29 02:16:42 -05001029#define DB_DEF_PDU_RING_ID_MASK 0x3FFF /* bits 0 - 13 */
1030#define DB_DEF_PDU_CQPROC_MASK 0x3FFF /* bits 16 - 29 */
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301031#define DB_DEF_PDU_REARM_SHIFT 14
1032#define DB_DEF_PDU_EVENT_SHIFT 15
1033#define DB_DEF_PDU_CQPROC_SHIFT 16
1034
1035struct dmsg_cqe {
1036 u32 dw[4];
1037} __packed;
1038
1039struct tcp_upload_params_in {
1040 struct be_cmd_req_hdr hdr;
1041 u16 id;
1042 u16 upload_type;
1043 u32 reset_seq;
1044} __packed;
1045
1046struct tcp_upload_params_out {
1047 u32 dw[32];
1048} __packed;
1049
1050union tcp_upload_params {
1051 struct tcp_upload_params_in request;
1052 struct tcp_upload_params_out response;
1053} __packed;
1054
1055struct be_ulp_fw_cfg {
Jayamohan Kallickal843ae752013-09-28 15:35:44 -07001056#define BEISCSI_ULP_ISCSI_INI_MODE 0x10
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301057 u32 ulp_mode;
1058 u32 etx_base;
1059 u32 etx_count;
1060 u32 sq_base;
1061 u32 sq_count;
1062 u32 rq_base;
1063 u32 rq_count;
1064 u32 dq_base;
1065 u32 dq_count;
1066 u32 lro_base;
1067 u32 lro_count;
1068 u32 icd_base;
1069 u32 icd_count;
1070};
1071
Jayamohan Kallickal843ae752013-09-28 15:35:44 -07001072struct be_ulp_chain_icd {
1073 u32 chain_base;
1074 u32 chain_count;
1075};
1076
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301077struct be_fw_cfg {
1078 struct be_cmd_req_hdr hdr;
1079 u32 be_config_number;
1080 u32 asic_revision;
1081 u32 phys_port;
Jayamohan Kallickal843ae752013-09-28 15:35:44 -07001082#define BEISCSI_FUNC_ISCSI_INI_MODE 0x10
1083#define BEISCSI_FUNC_DUA_MODE 0x800
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301084 u32 function_mode;
1085 struct be_ulp_fw_cfg ulp[2];
1086 u32 function_caps;
Jayamohan Kallickal843ae752013-09-28 15:35:44 -07001087 u32 cqid_base;
1088 u32 cqid_count;
1089 u32 eqid_base;
1090 u32 eqid_count;
1091 struct be_ulp_chain_icd chain_icd[2];
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301092} __packed;
1093
Mike Christie0e438952012-04-03 23:41:51 -05001094struct be_cmd_get_all_if_id_req {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301095 struct be_cmd_req_hdr hdr;
1096 u32 if_count;
1097 u32 if_hndl_list[1];
1098} __packed;
1099
1100#define ISCSI_OPCODE_SCSI_DATA_OUT 5
John Soni Josec62eef02012-04-03 23:41:52 -05001101#define OPCODE_COMMON_NTWK_LINK_STATUS_QUERY 5
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301102#define OPCODE_COMMON_MODIFY_EQ_DELAY 41
1103#define OPCODE_COMMON_ISCSI_CLEANUP 59
1104#define OPCODE_COMMON_TCP_UPLOAD 56
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301105#define OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD 70
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301106#define OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS 1
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301107#define OPCODE_ISCSI_INI_CFG_GET_HBA_NAME 6
1108#define OPCODE_ISCSI_INI_CFG_SET_HBA_NAME 7
1109#define OPCODE_ISCSI_INI_SESSION_GET_A_SESSION 14
John Soni Jose9aef4202012-08-20 23:00:08 +05301110#define OPCODE_ISCSI_INI_DRIVER_REOPEN_ALL_SESSIONS 36
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301111#define OPCODE_ISCSI_INI_DRIVER_OFFLOAD_SESSION 41
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301112#define OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION 42
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301113#define OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET 52
Jayamohan Kallickalffce3e22012-04-03 23:41:50 -05001114#define OPCODE_COMMON_WRITE_FLASH 96
1115#define OPCODE_COMMON_READ_FLASH 97
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301116
1117/* --- CMD_ISCSI_INVALIDATE_CONNECTION_TYPE --- */
1118#define CMD_ISCSI_COMMAND_INVALIDATE 1
1119#define CMD_ISCSI_CONNECTION_INVALIDATE 0x8001
1120#define CMD_ISCSI_CONNECTION_ISSUE_TCP_RST 0x8002
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301121
1122#define INI_WR_CMD 1 /* Initiator write command */
1123#define INI_TMF_CMD 2 /* Initiator TMF command */
1124#define INI_NOPOUT_CMD 3 /* Initiator; Send a NOP-OUT */
1125#define INI_RD_CMD 5 /* Initiator requesting to send
1126 * a read command
1127 */
1128#define TGT_CTX_UPDT_CMD 7 /* Target context update */
1129#define TGT_STS_CMD 8 /* Target R2T and other BHS
1130 * where only the status number
1131 * need to be updated
1132 */
1133#define TGT_DATAIN_CMD 9 /* Target Data-Ins in response
1134 * to read command
1135 */
1136#define TGT_SOS_PDU 10 /* Target:standalone status
1137 * response
1138 */
1139#define TGT_DM_CMD 11 /* Indicates that the bhs
1140 * preparedby
1141 * driver should not be touched
1142 */
1143/* --- CMD_CHUTE_TYPE --- */
1144#define CMD_CONNECTION_CHUTE_0 1
1145#define CMD_CONNECTION_CHUTE_1 2
1146#define CMD_CONNECTION_CHUTE_2 3
1147
1148#define EQ_MAJOR_CODE_COMPLETION 0
1149
1150#define CMD_ISCSI_SESSION_DEL_CFG_FROM_FLASH 0
1151#define CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH 1
1152
1153/* --- CONNECTION_UPLOAD_PARAMS --- */
1154/* These parameters are used to define the type of upload desired. */
1155#define CONNECTION_UPLOAD_GRACEFUL 1 /* Graceful upload */
1156#define CONNECTION_UPLOAD_ABORT_RESET 2 /* Abortive upload with
1157 * reset
1158 */
1159#define CONNECTION_UPLOAD_ABORT 3 /* Abortive upload without
1160 * reset
1161 */
1162#define CONNECTION_UPLOAD_ABORT_WITH_SEQ 4 /* Abortive upload with reset,
1163 * sequence number by driver */
1164
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301165/* Returns the number of items in the field array. */
1166#define BE_NUMBER_OF_FIELD(_type_, _field_) \
1167 (FIELD_SIZEOF(_type_, _field_)/sizeof((((_type_ *)0)->_field_[0])))\
1168
1169/**
1170 * Different types of iSCSI completions to host driver for both initiator
1171 * and taget mode
1172 * of operation.
1173 */
1174#define SOL_CMD_COMPLETE 1 /* Solicited command completed
1175 * normally
1176 */
1177#define SOL_CMD_KILLED_DATA_DIGEST_ERR 2 /* Solicited command got
1178 * invalidated internally due
1179 * to Data Digest error
1180 */
1181#define CXN_KILLED_PDU_SIZE_EXCEEDS_DSL 3 /* Connection got invalidated
1182 * internally
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001183 * due to a received PDU
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301184 * size > DSL
1185 */
1186#define CXN_KILLED_BURST_LEN_MISMATCH 4 /* Connection got invalidated
1187 * internally due ti received
1188 * PDU sequence size >
1189 * FBL/MBL.
1190 */
1191#define CXN_KILLED_AHS_RCVD 5 /* Connection got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001192 * internally due to a received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301193 * PDU Hdr that has
1194 * AHS */
1195#define CXN_KILLED_HDR_DIGEST_ERR 6 /* Connection got invalidated
1196 * internally due to Hdr Digest
1197 * error
1198 */
1199#define CXN_KILLED_UNKNOWN_HDR 7 /* Connection got invalidated
1200 * internally
1201 * due to a bad opcode in the
1202 * pdu hdr
1203 */
1204#define CXN_KILLED_STALE_ITT_TTT_RCVD 8 /* Connection got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001205 * internally due to a received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301206 * ITT/TTT that does not belong
1207 * to this Connection
1208 */
1209#define CXN_KILLED_INVALID_ITT_TTT_RCVD 9 /* Connection got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001210 * internally due to received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301211 * ITT/TTT value > Max
1212 * Supported ITTs/TTTs
1213 */
1214#define CXN_KILLED_RST_RCVD 10 /* Connection got invalidated
1215 * internally due to an
1216 * incoming TCP RST
1217 */
1218#define CXN_KILLED_TIMED_OUT 11 /* Connection got invalidated
1219 * internally due to timeout on
1220 * tcp segment 12 retransmit
1221 * attempts failed
1222 */
1223#define CXN_KILLED_RST_SENT 12 /* Connection got invalidated
1224 * internally due to TCP RST
1225 * sent by the Tx side
1226 */
1227#define CXN_KILLED_FIN_RCVD 13 /* Connection got invalidated
1228 * internally due to an
1229 * incoming TCP FIN.
1230 */
1231#define CXN_KILLED_BAD_UNSOL_PDU_RCVD 14 /* Connection got invalidated
1232 * internally due to bad
1233 * unsolicited PDU Unsolicited
1234 * PDUs are PDUs with
1235 * ITT=0xffffffff
1236 */
1237#define CXN_KILLED_BAD_WRB_INDEX_ERROR 15 /* Connection got invalidated
1238 * internally due to bad WRB
1239 * index.
1240 */
1241#define CXN_KILLED_OVER_RUN_RESIDUAL 16 /* Command got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001242 * internally due to received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301243 * command has residual
1244 * over run bytes.
1245 */
1246#define CXN_KILLED_UNDER_RUN_RESIDUAL 17 /* Command got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001247 * internally due to received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301248 * command has residual under
1249 * run bytes.
1250 */
1251#define CMD_KILLED_INVALID_STATSN_RCVD 18 /* Command got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001252 * internally due to a received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301253 * PDU has an invalid StatusSN
1254 */
1255#define CMD_KILLED_INVALID_R2T_RCVD 19 /* Command got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001256 * internally due to a received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301257 * an R2T with some invalid
1258 * fields in it
1259 */
1260#define CMD_CXN_KILLED_LUN_INVALID 20 /* Command got invalidated
1261 * internally due to received
1262 * PDU has an invalid LUN.
1263 */
1264#define CMD_CXN_KILLED_ICD_INVALID 21 /* Command got invalidated
1265 * internally due to the
1266 * corresponding ICD not in a
1267 * valid state
1268 */
1269#define CMD_CXN_KILLED_ITT_INVALID 22 /* Command got invalidated due
1270 * to received PDU has an
1271 * invalid ITT.
1272 */
1273#define CMD_CXN_KILLED_SEQ_OUTOFORDER 23 /* Command got invalidated due
1274 * to received sequence buffer
1275 * offset is out of order.
1276 */
1277#define CMD_CXN_KILLED_INVALID_DATASN_RCVD 24 /* Command got invalidated
1278 * internally due to a
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001279 * received PDU has an invalid
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301280 * DataSN
1281 */
1282#define CXN_INVALIDATE_NOTIFY 25 /* Connection invalidation
1283 * completion notify.
1284 */
1285#define CXN_INVALIDATE_INDEX_NOTIFY 26 /* Connection invalidation
1286 * completion
1287 * with data PDU index.
1288 */
1289#define CMD_INVALIDATED_NOTIFY 27 /* Command invalidation
1290 * completionnotifify.
1291 */
1292#define UNSOL_HDR_NOTIFY 28 /* Unsolicited header notify.*/
1293#define UNSOL_DATA_NOTIFY 29 /* Unsolicited data notify.*/
Jayamohan Kallickal457ff3b2010-07-22 04:16:00 +05301294#define UNSOL_DATA_DIGEST_ERROR_NOTIFY 30 /* Unsolicited data digest
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301295 * error notify.
1296 */
1297#define DRIVERMSG_NOTIFY 31 /* TCP acknowledge based
1298 * notification.
1299 */
1300#define CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN 32 /* Connection got invalidated
1301 * internally due to command
1302 * and data are not on same
1303 * connection.
1304 */
1305#define SOL_CMD_KILLED_DIF_ERR 33 /* Solicited command got
1306 * invalidated internally due
1307 * to DIF error
1308 */
1309#define CXN_KILLED_SYN_RCVD 34 /* Connection got invalidated
1310 * internally due to incoming
1311 * TCP SYN
1312 */
1313#define CXN_KILLED_IMM_DATA_RCVD 35 /* Connection got invalidated
1314 * internally due to an
1315 * incoming Unsolicited PDU
1316 * that has immediate data on
1317 * the cxn
1318 */
1319
Jayamohan Kallickale9b91192010-07-22 04:24:53 +05301320int beiscsi_pci_soft_reset(struct beiscsi_hba *phba);
1321int be_chk_reset_complete(struct beiscsi_hba *phba);
1322
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301323void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len,
1324 bool embedded, u8 sge_cnt);
1325
1326void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr,
1327 u8 subsystem, u8 opcode, int cmd_len);
1328
Jayamohan Kallickal9343be72014-01-29 02:16:43 -05001329void be2iscsi_fail_session(struct iscsi_cls_session *cls_session);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301330#endif /* !BEISCSI_CMDS_H */