blob: cdfbc5c19cf4536b1540a20082f5b73535167fbe [file] [log] [blame]
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301/**
Minh Tran4627de92015-05-14 23:16:17 -07002 * Copyright (C) 2005 - 2015 Avago Technologies
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 *
Minh Tran4627de92015-05-14 23:16:17 -070013 * Avago Technologies
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
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 */
Jayamohan Kallickalb3c202d2014-05-05 21:41:27 -040074#define MBX_CMD_VER1 0x01
John Soni Joseeaae5262012-10-20 04:43:44 +053075#define MBX_CMD_VER2 0x02
76
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053077struct be_mcc_compl {
78 u32 status; /* dword 0 */
79 u32 tag0; /* dword 1 */
80 u32 tag1; /* dword 2 */
81 u32 flags; /* dword 3 */
82};
83
84/********* Mailbox door bell *************/
85/**
86 * Used for driver communication with the FW.
87 * The software must write this register twice to post any command. First,
88 * it writes the register with hi=1 and the upper bits of the physical address
89 * for the MAILBOX structure. Software must poll the ready bit until this
90 * is acknowledged. Then, sotware writes the register with hi=0 with the lower
91 * bits in the address. It must poll the ready bit until the command is
92 * complete. Upon completion, the MAILBOX will contain a valid completion
93 * queue entry.
94 */
95#define MPU_MAILBOX_DB_OFFSET 0x160
96#define MPU_MAILBOX_DB_RDY_MASK 0x1 /* bit 0 */
97#define MPU_MAILBOX_DB_HI_MASK 0x2 /* bit 1 */
98
99/********** MPU semphore ******************/
100#define MPU_EP_SEMAPHORE_OFFSET 0xac
101#define EP_SEMAPHORE_POST_STAGE_MASK 0x0000FFFF
102#define EP_SEMAPHORE_POST_ERR_MASK 0x1
103#define EP_SEMAPHORE_POST_ERR_SHIFT 31
104
105/********** MCC door bell ************/
106#define DB_MCCQ_OFFSET 0x140
Jayamohan Kallickale08b3c82014-01-29 02:16:42 -0500107#define DB_MCCQ_RING_ID_MASK 0xFFFF /* bits 0 - 15 */
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530108/* Number of entries posted */
109#define DB_MCCQ_NUM_POSTED_SHIFT 16 /* bits 16 - 29 */
110
111/* MPU semphore POST stage values */
112#define POST_STAGE_ARMFW_RDY 0xc000 /* FW is done with POST */
113
114/**
115 * When the async bit of mcc_compl is set, the last 4 bytes of
116 * mcc_compl is interpreted as follows:
117 */
118#define ASYNC_TRAILER_EVENT_CODE_SHIFT 8 /* bits 8 - 15 */
119#define ASYNC_TRAILER_EVENT_CODE_MASK 0xFF
120#define ASYNC_EVENT_CODE_LINK_STATE 0x1
Jayamohan Kallickala3d313e2014-08-08 01:00:00 -0400121#define ASYNC_EVENT_CODE_ISCSI 0x4
122
123#define ASYNC_TRAILER_EVENT_TYPE_SHIFT 16 /* bits 16 - 23 */
124#define ASYNC_TRAILER_EVENT_TYPE_MASK 0xF
125#define ASYNC_EVENT_NEW_ISCSI_TGT_DISC 0x4
126#define ASYNC_EVENT_NEW_ISCSI_CONN 0x5
127#define ASYNC_EVENT_NEW_TCP_CONN 0x7
128
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530129struct be_async_event_trailer {
130 u32 code;
131};
132
133enum {
134 ASYNC_EVENT_LINK_DOWN = 0x0,
Jayamohan Kallickal6ea9b3b2013-04-05 20:38:30 -0700135 ASYNC_EVENT_LINK_UP = 0x1,
136 ASYNC_EVENT_LOGICAL = 0x2
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530137};
138
139/**
140 * When the event code of an async trailer is link-state, the mcc_compl
141 * must be interpreted as follows
142 */
143struct be_async_event_link_state {
144 u8 physical_port;
145 u8 port_link_status;
146 u8 port_duplex;
147 u8 port_speed;
Jayamohan Kallickal6ea9b3b2013-04-05 20:38:30 -0700148#define BEISCSI_PHY_LINK_FAULT_NONE 0x00
149#define BEISCSI_PHY_LINK_FAULT_LOCAL 0x01
150#define BEISCSI_PHY_LINK_FAULT_REMOTE 0x02
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530151 u8 port_fault;
152 u8 rsvd0[7];
153 struct be_async_event_trailer trailer;
154} __packed;
155
156struct be_mcc_mailbox {
157 struct be_mcc_wrb wrb;
158 struct be_mcc_compl compl;
159};
160
161/* Type of subsystems supported by FW */
162#define CMD_SUBSYSTEM_COMMON 0x1
163#define CMD_SUBSYSTEM_ISCSI 0x2
164#define CMD_SUBSYSTEM_ETH 0x3
165#define CMD_SUBSYSTEM_ISCSI_INI 0x6
166#define CMD_COMMON_TCP_UPLOAD 0x1
167
168/**
169 * List of common opcodes subsystem CMD_SUBSYSTEM_COMMON
170 * These opcodes are unique for each subsystem defined above
171 */
172#define OPCODE_COMMON_CQ_CREATE 12
173#define OPCODE_COMMON_EQ_CREATE 13
Jayamohan Kallickal457ff3b2010-07-22 04:16:00 +0530174#define OPCODE_COMMON_MCC_CREATE 21
Jayamohan Kallickal15a90fe2013-09-28 15:35:38 -0700175#define OPCODE_COMMON_ADD_TEMPLATE_HEADER_BUFFERS 24
176#define OPCODE_COMMON_REMOVE_TEMPLATE_HEADER_BUFFERS 25
Jayamohan Kallickal457ff3b2010-07-22 04:16:00 +0530177#define OPCODE_COMMON_GET_CNTL_ATTRIBUTES 32
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530178#define OPCODE_COMMON_GET_FW_VERSION 35
179#define OPCODE_COMMON_MODIFY_EQ_DELAY 41
180#define OPCODE_COMMON_FIRMWARE_CONFIG 42
Jayamohan Kallickal457ff3b2010-07-22 04:16:00 +0530181#define OPCODE_COMMON_MCC_DESTROY 53
182#define OPCODE_COMMON_CQ_DESTROY 54
183#define OPCODE_COMMON_EQ_DESTROY 55
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530184#define OPCODE_COMMON_QUERY_FIRMWARE_CONFIG 58
185#define OPCODE_COMMON_FUNCTION_RESET 61
186
187/**
188 * LIST of opcodes that are common between Initiator and Target
189 * used by CMD_SUBSYSTEM_ISCSI
190 * These opcodes are unique for each subsystem defined above
191 */
192#define OPCODE_COMMON_ISCSI_CFG_POST_SGL_PAGES 2
193#define OPCODE_COMMON_ISCSI_CFG_REMOVE_SGL_PAGES 3
194#define OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG 7
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530195#define OPCODE_COMMON_ISCSI_NTWK_SET_VLAN 14
Mike Christie0e438952012-04-03 23:41:51 -0500196#define OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR 17
197#define OPCODE_COMMON_ISCSI_NTWK_REL_STATELESS_IP_ADDR 18
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530198#define OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR 21
199#define OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY 22
200#define OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY 23
201#define OPCODE_COMMON_ISCSI_NTWK_GET_ALL_IF_ID 24
202#define OPCODE_COMMON_ISCSI_NTWK_GET_IF_INFO 25
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530203#define OPCODE_COMMON_ISCSI_SET_FRAGNUM_BITS_FOR_SGL_CRA 61
204#define OPCODE_COMMON_ISCSI_DEFQ_CREATE 64
Jayamohan Kallickal457ff3b2010-07-22 04:16:00 +0530205#define OPCODE_COMMON_ISCSI_DEFQ_DESTROY 65
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530206#define OPCODE_COMMON_ISCSI_WRBQ_CREATE 66
Jayamohan Kallickal457ff3b2010-07-22 04:16:00 +0530207#define OPCODE_COMMON_ISCSI_WRBQ_DESTROY 67
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530208
209struct be_cmd_req_hdr {
210 u8 opcode; /* dword 0 */
211 u8 subsystem; /* dword 0 */
212 u8 port_number; /* dword 0 */
213 u8 domain; /* dword 0 */
214 u32 timeout; /* dword 1 */
215 u32 request_length; /* dword 2 */
John Soni Joseeaae5262012-10-20 04:43:44 +0530216 u8 version; /* dword 3 */
217 u8 rsvd0[3]; /* dword 3 */
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530218};
219
220struct be_cmd_resp_hdr {
221 u32 info; /* dword 0 */
222 u32 status; /* dword 1 */
223 u32 response_length; /* dword 2 */
224 u32 actual_resp_len; /* dword 3 */
225};
226
227struct phys_addr {
228 u32 lo;
229 u32 hi;
230};
231
Jayamohan Kallickal15a90fe2013-09-28 15:35:38 -0700232struct virt_addr {
233 u32 lo;
234 u32 hi;
235};
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530236/**************************
237 * BE Command definitions *
238 **************************/
239
240/**
241 * Pseudo amap definition in which each bit of the actual structure is defined
242 * as a byte - used to calculate offset/shift/mask of each field
243 */
244struct amap_eq_context {
245 u8 cidx[13]; /* dword 0 */
246 u8 rsvd0[3]; /* dword 0 */
247 u8 epidx[13]; /* dword 0 */
248 u8 valid; /* dword 0 */
249 u8 rsvd1; /* dword 0 */
250 u8 size; /* dword 0 */
251 u8 pidx[13]; /* dword 1 */
252 u8 rsvd2[3]; /* dword 1 */
253 u8 pd[10]; /* dword 1 */
254 u8 count[3]; /* dword 1 */
255 u8 solevent; /* dword 1 */
256 u8 stalled; /* dword 1 */
257 u8 armed; /* dword 1 */
258 u8 rsvd3[4]; /* dword 2 */
259 u8 func[8]; /* dword 2 */
260 u8 rsvd4; /* dword 2 */
261 u8 delaymult[10]; /* dword 2 */
262 u8 rsvd5[2]; /* dword 2 */
263 u8 phase[2]; /* dword 2 */
264 u8 nodelay; /* dword 2 */
265 u8 rsvd6[4]; /* dword 2 */
266 u8 rsvd7[32]; /* dword 3 */
267} __packed;
268
269struct be_cmd_req_eq_create {
270 struct be_cmd_req_hdr hdr; /* dw[4] */
271 u16 num_pages; /* sword */
272 u16 rsvd0; /* sword */
273 u8 context[sizeof(struct amap_eq_context) / 8]; /* dw[4] */
274 struct phys_addr pages[8];
275} __packed;
276
277struct be_cmd_resp_eq_create {
278 struct be_cmd_resp_hdr resp_hdr;
279 u16 eq_id; /* sword */
280 u16 rsvd0; /* sword */
281} __packed;
282
Jayamohan Kallickal73af08e2014-05-05 21:41:26 -0400283struct be_set_eqd {
284 u32 eq_id;
285 u32 phase;
286 u32 delay_multiplier;
287} __packed;
288
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530289struct mgmt_chap_format {
290 u32 flags;
291 u8 intr_chap_name[256];
292 u8 intr_secret[16];
293 u8 target_chap_name[256];
294 u8 target_secret[16];
295 u16 intr_chap_name_length;
296 u16 intr_secret_length;
297 u16 target_chap_name_length;
298 u16 target_secret_length;
299} __packed;
300
301struct mgmt_auth_method_format {
302 u8 auth_method_type;
303 u8 padding[3];
304 struct mgmt_chap_format chap;
305} __packed;
306
John Soni Jose3f4134c2015-04-25 08:18:13 +0530307struct be_cmd_req_logout_fw_sess {
308 struct be_cmd_req_hdr hdr; /* dw[4] */
309 uint32_t session_handle;
310} __packed;
311
312struct be_cmd_resp_logout_fw_sess {
313 struct be_cmd_resp_hdr hdr; /* dw[4] */
314#define BEISCSI_MGMT_SESSION_CLOSE 0x20
315 uint32_t session_status;
316} __packed;
317
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530318struct mgmt_conn_login_options {
319 u8 flags;
320 u8 header_digest;
321 u8 data_digest;
322 u8 rsvd0;
323 u32 max_recv_datasegment_len_ini;
324 u32 max_recv_datasegment_len_tgt;
325 u32 tcp_mss;
326 u32 tcp_window_size;
327 struct mgmt_auth_method_format auth_data;
328} __packed;
329
Mike Christie0e438952012-04-03 23:41:51 -0500330struct ip_addr_format {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530331 u16 size_of_structure;
332 u8 reserved;
333 u8 ip_type;
Mike Christie0e438952012-04-03 23:41:51 -0500334 u8 addr[16];
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530335 u32 rsvd0;
336} __packed;
337
Mike Christie0e438952012-04-03 23:41:51 -0500338struct mgmt_conn_info {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530339 u32 connection_handle;
340 u32 connection_status;
341 u16 src_port;
342 u16 dest_port;
343 u16 dest_port_redirected;
344 u16 cid;
345 u32 estimated_throughput;
Mike Christie0e438952012-04-03 23:41:51 -0500346 struct ip_addr_format src_ipaddr;
347 struct ip_addr_format dest_ipaddr;
348 struct ip_addr_format dest_ipaddr_redirected;
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530349 struct mgmt_conn_login_options negotiated_login_options;
350} __packed;
351
352struct mgmt_session_login_options {
353 u8 flags;
354 u8 error_recovery_level;
355 u16 rsvd0;
356 u32 first_burst_length;
357 u32 max_burst_length;
358 u16 max_connections;
359 u16 max_outstanding_r2t;
360 u16 default_time2wait;
361 u16 default_time2retain;
362} __packed;
363
364struct mgmt_session_info {
365 u32 session_handle;
366 u32 status;
367 u8 isid[6];
368 u16 tsih;
369 u32 session_flags;
370 u16 conn_count;
371 u16 pad;
372 u8 target_name[224];
373 u8 initiator_iscsiname[224];
374 struct mgmt_session_login_options negotiated_login_options;
375 struct mgmt_conn_info conn_list[1];
376} __packed;
377
Mike Christie0e438952012-04-03 23:41:51 -0500378struct be_cmd_get_session_req {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530379 struct be_cmd_req_hdr hdr;
380 u32 session_handle;
381} __packed;
382
Mike Christie0e438952012-04-03 23:41:51 -0500383struct be_cmd_get_session_resp {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530384 struct be_cmd_resp_hdr hdr;
385 struct mgmt_session_info session_info;
386} __packed;
387
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530388struct mac_addr {
Mike Christie0e438952012-04-03 23:41:51 -0500389 u16 size_of_structure;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530390 u8 addr[ETH_ALEN];
391} __packed;
392
Mike Christie0e438952012-04-03 23:41:51 -0500393struct be_cmd_get_boot_target_req {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530394 struct be_cmd_req_hdr hdr;
395} __packed;
396
Mike Christie0e438952012-04-03 23:41:51 -0500397struct be_cmd_get_boot_target_resp {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530398 struct be_cmd_resp_hdr hdr;
399 u32 boot_session_count;
400 int boot_session_handle;
401};
402
John Soni Jose9aef4202012-08-20 23:00:08 +0530403struct be_cmd_reopen_session_req {
404 struct be_cmd_req_hdr hdr;
405#define BE_REOPEN_ALL_SESSIONS 0x00
406#define BE_REOPEN_BOOT_SESSIONS 0x01
407#define BE_REOPEN_A_SESSION 0x02
408 u16 reopen_type;
409 u16 rsvd;
410 u32 session_handle;
411} __packed;
412
413struct be_cmd_reopen_session_resp {
414 struct be_cmd_resp_hdr hdr;
415 u32 rsvd;
416 u32 session_handle;
417} __packed;
418
419
Mike Christie0e438952012-04-03 23:41:51 -0500420struct be_cmd_mac_query_req {
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530421 struct be_cmd_req_hdr hdr;
422 u8 type;
423 u8 permanent;
424 u16 if_id;
425} __packed;
426
Mike Christie0e438952012-04-03 23:41:51 -0500427struct be_cmd_get_mac_resp {
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530428 struct be_cmd_resp_hdr hdr;
429 struct mac_addr mac;
430};
431
Mike Christie0e438952012-04-03 23:41:51 -0500432struct be_ip_addr_subnet_format {
433 u16 size_of_structure;
434 u8 ip_type;
435 u8 ipv6_prefix_length;
436 u8 addr[16];
437 u8 subnet_mask[16];
438 u32 rsvd0;
439} __packed;
440
441struct be_cmd_get_if_info_req {
442 struct be_cmd_req_hdr hdr;
443 u32 interface_hndl;
444 u32 ip_type;
445} __packed;
446
447struct be_cmd_get_if_info_resp {
448 struct be_cmd_req_hdr hdr;
449 u32 interface_hndl;
450 u32 vlan_priority;
451 u32 ip_addr_count;
452 u32 dhcp_state;
453 struct be_ip_addr_subnet_format ip_addr;
454} __packed;
455
456struct be_ip_addr_record {
457 u32 action;
458 u32 interface_hndl;
459 struct be_ip_addr_subnet_format ip_addr;
460 u32 status;
461} __packed;
462
463struct be_ip_addr_record_params {
464 u32 record_entry_count;
465 struct be_ip_addr_record ip_record;
466} __packed;
467
468struct be_cmd_set_ip_addr_req {
469 struct be_cmd_req_hdr hdr;
470 struct be_ip_addr_record_params ip_params;
471} __packed;
472
473
474struct be_cmd_set_dhcp_req {
475 struct be_cmd_req_hdr hdr;
476 u32 interface_hndl;
477 u32 ip_type;
478 u32 flags;
479 u32 retry_count;
480} __packed;
481
482struct be_cmd_rel_dhcp_req {
483 struct be_cmd_req_hdr hdr;
484 u32 interface_hndl;
485 u32 ip_type;
486} __packed;
487
488struct be_cmd_set_def_gateway_req {
489 struct be_cmd_req_hdr hdr;
490 u32 action;
491 struct ip_addr_format ip_addr;
492} __packed;
493
494struct be_cmd_get_def_gateway_req {
495 struct be_cmd_req_hdr hdr;
496 u32 ip_type;
497} __packed;
498
499struct be_cmd_get_def_gateway_resp {
500 struct be_cmd_req_hdr hdr;
501 struct ip_addr_format ip_addr;
502} __packed;
503
John Soni Jose6f722382012-08-20 23:00:43 +0530504#define BEISCSI_VLAN_DISABLE 0xFFFF
505struct be_cmd_set_vlan_req {
506 struct be_cmd_req_hdr hdr;
507 u32 interface_hndl;
508 u32 vlan_priority;
509} __packed;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530510/******************** Create CQ ***************************/
511/**
512 * Pseudo amap definition in which each bit of the actual structure is defined
513 * as a byte - used to calculate offset/shift/mask of each field
514 */
515struct amap_cq_context {
516 u8 cidx[11]; /* dword 0 */
517 u8 rsvd0; /* dword 0 */
518 u8 coalescwm[2]; /* dword 0 */
519 u8 nodelay; /* dword 0 */
520 u8 epidx[11]; /* dword 0 */
521 u8 rsvd1; /* dword 0 */
522 u8 count[2]; /* dword 0 */
523 u8 valid; /* dword 0 */
524 u8 solevent; /* dword 0 */
525 u8 eventable; /* dword 0 */
526 u8 pidx[11]; /* dword 1 */
527 u8 rsvd2; /* dword 1 */
528 u8 pd[10]; /* dword 1 */
529 u8 eqid[8]; /* dword 1 */
530 u8 stalled; /* dword 1 */
531 u8 armed; /* dword 1 */
532 u8 rsvd3[4]; /* dword 2 */
533 u8 func[8]; /* dword 2 */
534 u8 rsvd4[20]; /* dword 2 */
535 u8 rsvd5[32]; /* dword 3 */
536} __packed;
537
John Soni Joseeaae5262012-10-20 04:43:44 +0530538struct amap_cq_context_v2 {
539 u8 rsvd0[12]; /* dword 0 */
540 u8 coalescwm[2]; /* dword 0 */
541 u8 nodelay; /* dword 0 */
542 u8 rsvd1[12]; /* dword 0 */
543 u8 count[2]; /* dword 0 */
544 u8 valid; /* dword 0 */
545 u8 rsvd2; /* dword 0 */
546 u8 eventable; /* dword 0 */
547 u8 eqid[16]; /* dword 1 */
548 u8 rsvd3[15]; /* dword 1 */
549 u8 armed; /* dword 1 */
550 u8 cqecount[16];/* dword 2 */
551 u8 rsvd4[16]; /* dword 2 */
552 u8 rsvd5[32]; /* dword 3 */
553};
554
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530555struct be_cmd_req_cq_create {
556 struct be_cmd_req_hdr hdr;
557 u16 num_pages;
John Soni Joseeaae5262012-10-20 04:43:44 +0530558 u8 page_size;
559 u8 rsvd0;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530560 u8 context[sizeof(struct amap_cq_context) / 8];
561 struct phys_addr pages[4];
562} __packed;
563
564struct be_cmd_resp_cq_create {
565 struct be_cmd_resp_hdr hdr;
566 u16 cq_id;
567 u16 rsvd0;
568} __packed;
569
570/******************** Create MCCQ ***************************/
571/**
572 * Pseudo amap definition in which each bit of the actual structure is defined
573 * as a byte - used to calculate offset/shift/mask of each field
574 */
575struct amap_mcc_context {
576 u8 con_index[14];
577 u8 rsvd0[2];
578 u8 ring_size[4];
579 u8 fetch_wrb;
580 u8 fetch_r2t;
581 u8 cq_id[10];
582 u8 prod_index[14];
583 u8 fid[8];
584 u8 pdid[9];
585 u8 valid;
586 u8 rsvd1[32];
587 u8 rsvd2[32];
588} __packed;
589
590struct be_cmd_req_mcc_create {
591 struct be_cmd_req_hdr hdr;
592 u16 num_pages;
593 u16 rsvd0;
594 u8 context[sizeof(struct amap_mcc_context) / 8];
595 struct phys_addr pages[8];
596} __packed;
597
598struct be_cmd_resp_mcc_create {
599 struct be_cmd_resp_hdr hdr;
600 u16 id;
601 u16 rsvd0;
602} __packed;
603
604/******************** Q Destroy ***************************/
605/* Type of Queue to be destroyed */
606enum {
607 QTYPE_EQ = 1,
608 QTYPE_CQ,
609 QTYPE_MCCQ,
610 QTYPE_WRBQ,
611 QTYPE_DPDUQ,
612 QTYPE_SGL
613};
614
615struct be_cmd_req_q_destroy {
616 struct be_cmd_req_hdr hdr;
617 u16 id;
618 u16 bypass_flush; /* valid only for rx q destroy */
619} __packed;
620
621struct macaddr {
622 u8 byte[ETH_ALEN];
623};
624
625struct be_cmd_req_mcast_mac_config {
626 struct be_cmd_req_hdr hdr;
627 u16 num_mac;
628 u8 promiscuous;
629 u8 interface_id;
630 struct macaddr mac[32];
631} __packed;
632
633static inline void *embedded_payload(struct be_mcc_wrb *wrb)
634{
635 return wrb->payload.embedded_payload;
636}
637
638static inline struct be_sge *nonembedded_sgl(struct be_mcc_wrb *wrb)
639{
640 return &wrb->payload.sgl[0];
641}
642
643/******************** Modify EQ Delay *******************/
644struct be_cmd_req_modify_eq_delay {
645 struct be_cmd_req_hdr hdr;
Jayamohan Kallickal39033412014-08-08 00:59:58 -0400646 __le32 num_eq;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530647 struct {
Jayamohan Kallickal39033412014-08-08 00:59:58 -0400648 __le32 eq_id;
649 __le32 phase;
650 __le32 delay_multiplier;
Jayamohan Kallickal73af08e2014-05-05 21:41:26 -0400651 } delay[MAX_CPUS];
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530652} __packed;
653
654/******************** Get MAC ADDR *******************/
655
656#define ETH_ALEN 6
657
Mike Christie0e438952012-04-03 23:41:51 -0500658struct be_cmd_get_nic_conf_req {
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530659 struct be_cmd_req_hdr hdr;
660 u32 nic_port_count;
661 u32 speed;
662 u32 max_speed;
663 u32 link_state;
664 u32 max_frame_size;
665 u16 size_of_structure;
666 u8 mac_address[ETH_ALEN];
667 u32 rsvd[23];
668};
669
Mike Christie0e438952012-04-03 23:41:51 -0500670struct be_cmd_get_nic_conf_resp {
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530671 struct be_cmd_resp_hdr hdr;
672 u32 nic_port_count;
673 u32 speed;
674 u32 max_speed;
675 u32 link_state;
676 u32 max_frame_size;
677 u16 size_of_structure;
678 u8 mac_address[6];
679 u32 rsvd[23];
680};
681
John Soni Jose21771992012-04-03 23:41:49 -0500682#define BEISCSI_ALIAS_LEN 32
683
684struct be_cmd_hba_name {
685 struct be_cmd_req_hdr hdr;
686 u16 flags;
687 u16 rsvd0;
688 u8 initiator_name[ISCSI_NAME_LEN];
689 u8 initiator_alias[BEISCSI_ALIAS_LEN];
690} __packed;
691
John Soni Josec62eef02012-04-03 23:41:52 -0500692struct be_cmd_ntwk_link_status_req {
693 struct be_cmd_req_hdr hdr;
694 u32 rsvd0;
695} __packed;
696
697/*** Port Speed Values ***/
698#define BE2ISCSI_LINK_SPEED_ZERO 0x00
699#define BE2ISCSI_LINK_SPEED_10MBPS 0x01
700#define BE2ISCSI_LINK_SPEED_100MBPS 0x02
701#define BE2ISCSI_LINK_SPEED_1GBPS 0x03
702#define BE2ISCSI_LINK_SPEED_10GBPS 0x04
703struct be_cmd_ntwk_link_status_resp {
704 struct be_cmd_resp_hdr hdr;
705 u8 phys_port;
706 u8 mac_duplex;
707 u8 mac_speed;
708 u8 mac_fault;
709 u8 mgmt_mac_duplex;
710 u8 mgmt_mac_speed;
711 u16 qos_link_speed;
712 u32 logical_link_speed;
713} __packed;
John Soni Jose21771992012-04-03 23:41:49 -0500714
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530715int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl,
716 struct be_queue_info *eq, int eq_delay);
717
718int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl,
719 struct be_queue_info *cq, struct be_queue_info *eq,
720 bool sol_evts, bool no_delay,
721 int num_cqe_dma_coalesce);
722
723int beiscsi_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q,
724 int type);
Jayamohan Kallickal35e66012009-10-23 11:53:49 +0530725int beiscsi_cmd_mccq_create(struct beiscsi_hba *phba,
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530726 struct be_queue_info *mccq,
727 struct be_queue_info *cq);
728
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530729int be_poll_mcc(struct be_ctrl_info *ctrl);
Jayamohan Kallickal03a12312010-07-22 04:17:16 +0530730int mgmt_check_supported_fw(struct be_ctrl_info *ctrl,
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530731 struct beiscsi_hba *phba);
John Soni Jose21771992012-04-03 23:41:49 -0500732unsigned int be_cmd_get_initname(struct beiscsi_hba *phba);
John Soni Josec62eef02012-04-03 23:41:52 -0500733unsigned int be_cmd_get_port_speed(struct beiscsi_hba *phba);
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +0530734
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530735void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag);
John Soni Josee175def2012-10-20 04:45:40 +0530736
Jayamohan Kallickal73af08e2014-05-05 21:41:26 -0400737int be_cmd_modify_eq_delay(struct beiscsi_hba *phba, struct be_set_eqd *,
738 int num);
John Soni Josee175def2012-10-20 04:45:40 +0530739int beiscsi_mccq_compl(struct beiscsi_hba *phba,
Jayamohan Kallickal1957aa72014-01-29 02:16:39 -0500740 uint32_t tag, struct be_mcc_wrb **wrb,
741 struct be_dma_mem *mbx_cmd_mem);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530742/*ISCSI Functuions */
743int be_cmd_fw_initialize(struct be_ctrl_info *ctrl);
Jayamohan Kallickal0283fbb2013-04-05 20:38:21 -0700744int be_cmd_fw_uninit(struct be_ctrl_info *ctrl);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530745
746struct be_mcc_wrb *wrb_from_mbox(struct be_dma_mem *mbox_mem);
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530747struct be_mcc_wrb *wrb_from_mccq(struct beiscsi_hba *phba);
748int be_mcc_notify_wait(struct beiscsi_hba *phba);
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530749void be_mcc_notify(struct beiscsi_hba *phba);
750unsigned int alloc_mcc_tag(struct beiscsi_hba *phba);
751void beiscsi_async_link_state_process(struct beiscsi_hba *phba,
752 struct be_async_event_link_state *evt);
753int be_mcc_compl_process_isr(struct be_ctrl_info *ctrl,
754 struct be_mcc_compl *compl);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530755
756int be_mbox_notify(struct be_ctrl_info *ctrl);
757
758int be_cmd_create_default_pdu_queue(struct be_ctrl_info *ctrl,
759 struct be_queue_info *cq,
760 struct be_queue_info *dq, int length,
Jayamohan Kallickal8a86e832013-09-28 15:35:45 -0700761 int entry_size, uint8_t is_header,
762 uint8_t ulp_num);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530763
Jayamohan Kallickal15a90fe2013-09-28 15:35:38 -0700764int be_cmd_iscsi_post_template_hdr(struct be_ctrl_info *ctrl,
765 struct be_dma_mem *q_mem);
766
767int be_cmd_iscsi_remove_template_hdr(struct be_ctrl_info *ctrl);
768
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530769int be_cmd_iscsi_post_sgl_pages(struct be_ctrl_info *ctrl,
770 struct be_dma_mem *q_mem, u32 page_offset,
771 u32 num_pages);
772
Jayamohan Kallickale5285862011-10-07 19:31:08 -0500773int beiscsi_cmd_reset_function(struct beiscsi_hba *phba);
774
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530775int be_cmd_wrbq_create(struct be_ctrl_info *ctrl, struct be_dma_mem *q_mem,
Jayamohan Kallickal4eea99d2013-09-28 15:35:48 -0700776 struct be_queue_info *wrbq,
777 struct hwi_wrb_context *pwrb_context,
778 uint8_t ulp_num);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530779
Jayamohan Kallickal756d29c2010-01-05 05:10:46 +0530780bool is_link_state_evt(u32 trailer);
781
John Soni Jose6f722382012-08-20 23:00:43 +0530782/* Configuration Functions */
783int be_cmd_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag);
784
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530785struct be_default_pdu_context {
786 u32 dw[4];
787} __packed;
788
789struct amap_be_default_pdu_context {
790 u8 dbuf_cindex[13]; /* dword 0 */
791 u8 rsvd0[3]; /* dword 0 */
792 u8 ring_size[4]; /* dword 0 */
793 u8 ring_state[4]; /* dword 0 */
794 u8 rsvd1[8]; /* dword 0 */
795 u8 dbuf_pindex[13]; /* dword 1 */
796 u8 rsvd2; /* dword 1 */
797 u8 pci_func_id[8]; /* dword 1 */
798 u8 rx_pdid[9]; /* dword 1 */
799 u8 rx_pdid_valid; /* dword 1 */
800 u8 default_buffer_size[16]; /* dword 2 */
801 u8 cq_id_recv[10]; /* dword 2 */
802 u8 rx_pdid_not_valid; /* dword 2 */
803 u8 rsvd3[5]; /* dword 2 */
804 u8 rsvd4[32]; /* dword 3 */
805} __packed;
806
Jayamohan Kallickalef9e1b92013-04-05 20:38:27 -0700807struct amap_default_pdu_context_ext {
808 u8 rsvd0[16]; /* dword 0 */
809 u8 ring_size[4]; /* dword 0 */
810 u8 rsvd1[12]; /* dword 0 */
811 u8 rsvd2[22]; /* dword 1 */
812 u8 rx_pdid[9]; /* dword 1 */
813 u8 rx_pdid_valid; /* dword 1 */
814 u8 default_buffer_size[16]; /* dword 2 */
815 u8 cq_id_recv[16]; /* dword 2 */
816 u8 rsvd3[32]; /* dword 3 */
817} __packed;
818
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530819struct be_defq_create_req {
820 struct be_cmd_req_hdr hdr;
821 u16 num_pages;
822 u8 ulp_num;
Jayamohan Kallickal8a86e832013-09-28 15:35:45 -0700823#define BEISCSI_DUAL_ULP_AWARE_BIT 0 /* Byte 3 - Bit 0 */
824#define BEISCSI_BIND_Q_TO_ULP_BIT 1 /* Byte 3 - Bit 1 */
825 u8 dua_feature;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530826 struct be_default_pdu_context context;
827 struct phys_addr pages[8];
828} __packed;
829
830struct be_defq_create_resp {
831 struct be_cmd_req_hdr hdr;
832 u16 id;
Jayamohan Kallickal8a86e832013-09-28 15:35:45 -0700833 u8 rsvd0;
834 u8 ulp_num;
835 u32 doorbell_offset;
836 u16 register_set;
837 u16 doorbell_format;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530838} __packed;
839
Jayamohan Kallickal15a90fe2013-09-28 15:35:38 -0700840struct be_post_template_pages_req {
841 struct be_cmd_req_hdr hdr;
842 u16 num_pages;
843#define BEISCSI_TEMPLATE_HDR_TYPE_ISCSI 0x1
844 u16 type;
845 struct phys_addr scratch_pa;
846 struct virt_addr scratch_va;
847 struct virt_addr pages_va;
848 struct phys_addr pages[16];
849} __packed;
850
851struct be_remove_template_pages_req {
852 struct be_cmd_req_hdr hdr;
853 u16 type;
854 u16 rsvd0;
855} __packed;
856
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530857struct be_post_sgl_pages_req {
858 struct be_cmd_req_hdr hdr;
859 u16 num_pages;
860 u16 page_offset;
861 u32 rsvd0;
862 struct phys_addr pages[26];
863 u32 rsvd1;
864} __packed;
865
866struct be_wrbq_create_req {
867 struct be_cmd_req_hdr hdr;
868 u16 num_pages;
869 u8 ulp_num;
Jayamohan Kallickal4eea99d2013-09-28 15:35:48 -0700870 u8 dua_feature;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530871 struct phys_addr pages[8];
872} __packed;
873
874struct be_wrbq_create_resp {
875 struct be_cmd_resp_hdr resp_hdr;
876 u16 cid;
Jayamohan Kallickal4eea99d2013-09-28 15:35:48 -0700877 u8 rsvd0;
878 u8 ulp_num;
879 u32 doorbell_offset;
880 u16 register_set;
881 u16 doorbell_format;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530882} __packed;
883
884#define SOL_CID_MASK 0x0000FFC0
885#define SOL_CODE_MASK 0x0000003F
886#define SOL_WRB_INDEX_MASK 0x00FF0000
887#define SOL_CMD_WND_MASK 0xFF000000
888#define SOL_RES_CNT_MASK 0x7FFFFFFF
889#define SOL_EXP_CMD_SN_MASK 0xFFFFFFFF
890#define SOL_HW_STS_MASK 0x000000FF
891#define SOL_STS_MASK 0x0000FF00
892#define SOL_RESP_MASK 0x00FF0000
893#define SOL_FLAGS_MASK 0x7F000000
894#define SOL_S_MASK 0x80000000
895
896struct sol_cqe {
897 u32 dw[4];
898};
899
900struct amap_sol_cqe {
901 u8 hw_sts[8]; /* dword 0 */
902 u8 i_sts[8]; /* dword 0 */
903 u8 i_resp[8]; /* dword 0 */
904 u8 i_flags[7]; /* dword 0 */
905 u8 s; /* dword 0 */
906 u8 i_exp_cmd_sn[32]; /* dword 1 */
907 u8 code[6]; /* dword 2 */
908 u8 cid[10]; /* dword 2 */
909 u8 wrb_index[8]; /* dword 2 */
910 u8 i_cmd_wnd[8]; /* dword 2 */
911 u8 i_res_cnt[31]; /* dword 3 */
912 u8 valid; /* dword 3 */
913} __packed;
914
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530915#define SOL_ICD_INDEX_MASK 0x0003FFC0
916struct amap_sol_cqe_ring {
917 u8 hw_sts[8]; /* dword 0 */
918 u8 i_sts[8]; /* dword 0 */
919 u8 i_resp[8]; /* dword 0 */
920 u8 i_flags[7]; /* dword 0 */
921 u8 s; /* dword 0 */
922 u8 i_exp_cmd_sn[32]; /* dword 1 */
923 u8 code[6]; /* dword 2 */
924 u8 icd_index[12]; /* dword 2 */
925 u8 rsvd[6]; /* dword 2 */
926 u8 i_cmd_wnd[8]; /* dword 2 */
927 u8 i_res_cnt[31]; /* dword 3 */
928 u8 valid; /* dword 3 */
929} __packed;
930
John Soni Jose73133262012-10-20 04:44:49 +0530931struct amap_sol_cqe_v2 {
932 u8 hw_sts[8]; /* dword 0 */
933 u8 i_sts[8]; /* dword 0 */
934 u8 wrb_index[16]; /* dword 0 */
935 u8 i_exp_cmd_sn[32]; /* dword 1 */
936 u8 code[6]; /* dword 2 */
937 u8 cmd_cmpl; /* dword 2 */
938 u8 rsvd0; /* dword 2 */
939 u8 i_cmd_wnd[8]; /* dword 2 */
940 u8 cid[13]; /* dword 2 */
941 u8 u; /* dword 2 */
942 u8 o; /* dword 2 */
943 u8 s; /* dword 2 */
944 u8 i_res_cnt[31]; /* dword 3 */
945 u8 valid; /* dword 3 */
946} __packed;
947
948struct common_sol_cqe {
949 u32 exp_cmdsn;
950 u32 res_cnt;
951 u16 wrb_index;
952 u16 cid;
953 u8 hw_sts;
954 u8 cmd_wnd;
955 u8 res_flag; /* the s feild of structure */
956 u8 i_resp; /* for skh if cmd_complete is set then i_sts is response */
957 u8 i_flags; /* for skh or the u and o feilds */
958 u8 i_sts; /* for skh if cmd_complete is not-set then i_sts is status */
959};
960
961/*** iSCSI ack/driver message completions ***/
962struct amap_it_dmsg_cqe {
963 u8 ack_num[32]; /* DWORD 0 */
964 u8 pdu_bytes_rcvd[32]; /* DWORD 1 */
965 u8 code[6]; /* DWORD 2 */
966 u8 cid[10]; /* DWORD 2 */
967 u8 wrb_idx[8]; /* DWORD 2 */
968 u8 rsvd0[8]; /* DWORD 2*/
969 u8 rsvd1[31]; /* DWORD 3*/
970 u8 valid; /* DWORD 3 */
971} __packed;
972
973struct amap_it_dmsg_cqe_v2 {
974 u8 ack_num[32]; /* DWORD 0 */
975 u8 pdu_bytes_rcvd[32]; /* DWORD 1 */
976 u8 code[6]; /* DWORD 2 */
977 u8 rsvd0[10]; /* DWORD 2 */
978 u8 wrb_idx[16]; /* DWORD 2 */
979 u8 rsvd1[16]; /* DWORD 3 */
980 u8 cid[13]; /* DWORD 3 */
981 u8 rsvd2[2]; /* DWORD 3 */
982 u8 valid; /* DWORD 3 */
983} __packed;
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530984
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530985
986/**
987 * Post WRB Queue Doorbell Register used by the host Storage
988 * stack to notify the
989 * controller of a posted Work Request Block
990 */
Jayamohan Kallickalef9e1b92013-04-05 20:38:27 -0700991#define DB_WRB_POST_CID_MASK 0xFFFF /* bits 0 - 16 */
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530992#define DB_DEF_PDU_WRB_INDEX_MASK 0xFF /* bits 0 - 9 */
993
994#define DB_DEF_PDU_WRB_INDEX_SHIFT 16
995#define DB_DEF_PDU_NUM_POSTED_SHIFT 24
996
997struct fragnum_bits_for_sgl_cra_in {
998 struct be_cmd_req_hdr hdr;
999 u32 num_bits;
1000} __packed;
1001
1002struct iscsi_cleanup_req {
1003 struct be_cmd_req_hdr hdr;
1004 u16 chute;
1005 u8 hdr_ring_id;
1006 u8 data_ring_id;
1007
1008} __packed;
1009
1010struct eq_delay {
1011 u32 eq_id;
1012 u32 phase;
1013 u32 delay_multiplier;
1014} __packed;
1015
1016struct be_eq_delay_params_in {
1017 struct be_cmd_req_hdr hdr;
1018 u32 num_eq;
1019 struct eq_delay delay[8];
1020} __packed;
1021
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301022struct tcp_connect_and_offload_in {
1023 struct be_cmd_req_hdr hdr;
Mike Christie0e438952012-04-03 23:41:51 -05001024 struct ip_addr_format ip_address;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301025 u16 tcp_port;
1026 u16 cid;
1027 u16 cq_id;
1028 u16 defq_id;
1029 struct phys_addr dataout_template_pa;
1030 u16 hdr_ring_id;
1031 u16 data_ring_id;
1032 u8 do_offload;
1033 u8 rsvd0[3];
1034} __packed;
1035
Jayamohan Kallickalb3c202d2014-05-05 21:41:27 -04001036struct tcp_connect_and_offload_in_v1 {
1037 struct be_cmd_req_hdr hdr;
1038 struct ip_addr_format ip_address;
1039 u16 tcp_port;
1040 u16 cid;
1041 u16 cq_id;
1042 u16 defq_id;
1043 struct phys_addr dataout_template_pa;
1044 u16 hdr_ring_id;
1045 u16 data_ring_id;
1046 u8 do_offload;
1047 u8 ifd_state;
1048 u8 rsvd0[2];
1049 u16 tcp_window_size;
1050 u8 tcp_window_scale_count;
1051 u8 rsvd1;
1052 u32 tcp_mss:24;
1053 u8 rsvd2;
1054} __packed;
1055
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301056struct tcp_connect_and_offload_out {
1057 struct be_cmd_resp_hdr hdr;
1058 u32 connection_handle;
1059 u16 cid;
1060 u16 rsvd0;
1061
1062} __packed;
1063
1064struct be_mcc_wrb_context {
1065 struct MCC_WRB *wrb;
1066 int *users_final_status;
1067} __packed;
1068
Jayamohan Kallickale08b3c82014-01-29 02:16:42 -05001069#define DB_DEF_PDU_RING_ID_MASK 0x3FFF /* bits 0 - 13 */
1070#define DB_DEF_PDU_CQPROC_MASK 0x3FFF /* bits 16 - 29 */
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301071#define DB_DEF_PDU_REARM_SHIFT 14
1072#define DB_DEF_PDU_EVENT_SHIFT 15
1073#define DB_DEF_PDU_CQPROC_SHIFT 16
1074
1075struct dmsg_cqe {
1076 u32 dw[4];
1077} __packed;
1078
1079struct tcp_upload_params_in {
1080 struct be_cmd_req_hdr hdr;
1081 u16 id;
1082 u16 upload_type;
1083 u32 reset_seq;
1084} __packed;
1085
1086struct tcp_upload_params_out {
1087 u32 dw[32];
1088} __packed;
1089
1090union tcp_upload_params {
1091 struct tcp_upload_params_in request;
1092 struct tcp_upload_params_out response;
1093} __packed;
1094
1095struct be_ulp_fw_cfg {
Jayamohan Kallickal843ae752013-09-28 15:35:44 -07001096#define BEISCSI_ULP_ISCSI_INI_MODE 0x10
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301097 u32 ulp_mode;
1098 u32 etx_base;
1099 u32 etx_count;
1100 u32 sq_base;
1101 u32 sq_count;
1102 u32 rq_base;
1103 u32 rq_count;
1104 u32 dq_base;
1105 u32 dq_count;
1106 u32 lro_base;
1107 u32 lro_count;
1108 u32 icd_base;
1109 u32 icd_count;
1110};
1111
Jayamohan Kallickal843ae752013-09-28 15:35:44 -07001112struct be_ulp_chain_icd {
1113 u32 chain_base;
1114 u32 chain_count;
1115};
1116
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301117struct be_fw_cfg {
1118 struct be_cmd_req_hdr hdr;
1119 u32 be_config_number;
1120 u32 asic_revision;
1121 u32 phys_port;
Jayamohan Kallickal843ae752013-09-28 15:35:44 -07001122#define BEISCSI_FUNC_ISCSI_INI_MODE 0x10
1123#define BEISCSI_FUNC_DUA_MODE 0x800
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301124 u32 function_mode;
1125 struct be_ulp_fw_cfg ulp[2];
1126 u32 function_caps;
Jayamohan Kallickal843ae752013-09-28 15:35:44 -07001127 u32 cqid_base;
1128 u32 cqid_count;
1129 u32 eqid_base;
1130 u32 eqid_count;
1131 struct be_ulp_chain_icd chain_icd[2];
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301132} __packed;
1133
Mike Christie0e438952012-04-03 23:41:51 -05001134struct be_cmd_get_all_if_id_req {
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301135 struct be_cmd_req_hdr hdr;
1136 u32 if_count;
1137 u32 if_hndl_list[1];
1138} __packed;
1139
1140#define ISCSI_OPCODE_SCSI_DATA_OUT 5
John Soni Josec62eef02012-04-03 23:41:52 -05001141#define OPCODE_COMMON_NTWK_LINK_STATUS_QUERY 5
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301142#define OPCODE_COMMON_MODIFY_EQ_DELAY 41
1143#define OPCODE_COMMON_ISCSI_CLEANUP 59
1144#define OPCODE_COMMON_TCP_UPLOAD 56
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301145#define OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD 70
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301146#define OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS 1
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301147#define OPCODE_ISCSI_INI_CFG_GET_HBA_NAME 6
1148#define OPCODE_ISCSI_INI_CFG_SET_HBA_NAME 7
1149#define OPCODE_ISCSI_INI_SESSION_GET_A_SESSION 14
John Soni Jose3f4134c2015-04-25 08:18:13 +05301150#define OPCODE_ISCSI_INI_SESSION_LOGOUT_TARGET 24
John Soni Jose9aef4202012-08-20 23:00:08 +05301151#define OPCODE_ISCSI_INI_DRIVER_REOPEN_ALL_SESSIONS 36
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301152#define OPCODE_ISCSI_INI_DRIVER_OFFLOAD_SESSION 41
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301153#define OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION 42
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301154#define OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET 52
Jayamohan Kallickalffce3e22012-04-03 23:41:50 -05001155#define OPCODE_COMMON_WRITE_FLASH 96
1156#define OPCODE_COMMON_READ_FLASH 97
Jayamohan Kallickalc7acc5b2010-07-22 04:29:18 +05301157
1158/* --- CMD_ISCSI_INVALIDATE_CONNECTION_TYPE --- */
1159#define CMD_ISCSI_COMMAND_INVALIDATE 1
1160#define CMD_ISCSI_CONNECTION_INVALIDATE 0x8001
1161#define CMD_ISCSI_CONNECTION_ISSUE_TCP_RST 0x8002
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301162
1163#define INI_WR_CMD 1 /* Initiator write command */
1164#define INI_TMF_CMD 2 /* Initiator TMF command */
1165#define INI_NOPOUT_CMD 3 /* Initiator; Send a NOP-OUT */
1166#define INI_RD_CMD 5 /* Initiator requesting to send
1167 * a read command
1168 */
1169#define TGT_CTX_UPDT_CMD 7 /* Target context update */
1170#define TGT_STS_CMD 8 /* Target R2T and other BHS
1171 * where only the status number
1172 * need to be updated
1173 */
1174#define TGT_DATAIN_CMD 9 /* Target Data-Ins in response
1175 * to read command
1176 */
1177#define TGT_SOS_PDU 10 /* Target:standalone status
1178 * response
1179 */
1180#define TGT_DM_CMD 11 /* Indicates that the bhs
1181 * preparedby
1182 * driver should not be touched
1183 */
1184/* --- CMD_CHUTE_TYPE --- */
1185#define CMD_CONNECTION_CHUTE_0 1
1186#define CMD_CONNECTION_CHUTE_1 2
1187#define CMD_CONNECTION_CHUTE_2 3
1188
1189#define EQ_MAJOR_CODE_COMPLETION 0
1190
1191#define CMD_ISCSI_SESSION_DEL_CFG_FROM_FLASH 0
1192#define CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH 1
1193
1194/* --- CONNECTION_UPLOAD_PARAMS --- */
1195/* These parameters are used to define the type of upload desired. */
1196#define CONNECTION_UPLOAD_GRACEFUL 1 /* Graceful upload */
1197#define CONNECTION_UPLOAD_ABORT_RESET 2 /* Abortive upload with
1198 * reset
1199 */
1200#define CONNECTION_UPLOAD_ABORT 3 /* Abortive upload without
1201 * reset
1202 */
1203#define CONNECTION_UPLOAD_ABORT_WITH_SEQ 4 /* Abortive upload with reset,
1204 * sequence number by driver */
1205
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301206/* Returns the number of items in the field array. */
1207#define BE_NUMBER_OF_FIELD(_type_, _field_) \
1208 (FIELD_SIZEOF(_type_, _field_)/sizeof((((_type_ *)0)->_field_[0])))\
1209
1210/**
1211 * Different types of iSCSI completions to host driver for both initiator
1212 * and taget mode
1213 * of operation.
1214 */
1215#define SOL_CMD_COMPLETE 1 /* Solicited command completed
1216 * normally
1217 */
1218#define SOL_CMD_KILLED_DATA_DIGEST_ERR 2 /* Solicited command got
1219 * invalidated internally due
1220 * to Data Digest error
1221 */
1222#define CXN_KILLED_PDU_SIZE_EXCEEDS_DSL 3 /* Connection got invalidated
1223 * internally
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001224 * due to a received PDU
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301225 * size > DSL
1226 */
1227#define CXN_KILLED_BURST_LEN_MISMATCH 4 /* Connection got invalidated
1228 * internally due ti received
1229 * PDU sequence size >
1230 * FBL/MBL.
1231 */
1232#define CXN_KILLED_AHS_RCVD 5 /* Connection got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001233 * internally due to a received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301234 * PDU Hdr that has
1235 * AHS */
1236#define CXN_KILLED_HDR_DIGEST_ERR 6 /* Connection got invalidated
1237 * internally due to Hdr Digest
1238 * error
1239 */
1240#define CXN_KILLED_UNKNOWN_HDR 7 /* Connection got invalidated
1241 * internally
1242 * due to a bad opcode in the
1243 * pdu hdr
1244 */
1245#define CXN_KILLED_STALE_ITT_TTT_RCVD 8 /* Connection got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001246 * internally due to a received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301247 * ITT/TTT that does not belong
1248 * to this Connection
1249 */
1250#define CXN_KILLED_INVALID_ITT_TTT_RCVD 9 /* Connection got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001251 * internally due to received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301252 * ITT/TTT value > Max
1253 * Supported ITTs/TTTs
1254 */
1255#define CXN_KILLED_RST_RCVD 10 /* Connection got invalidated
1256 * internally due to an
1257 * incoming TCP RST
1258 */
1259#define CXN_KILLED_TIMED_OUT 11 /* Connection got invalidated
1260 * internally due to timeout on
1261 * tcp segment 12 retransmit
1262 * attempts failed
1263 */
1264#define CXN_KILLED_RST_SENT 12 /* Connection got invalidated
1265 * internally due to TCP RST
1266 * sent by the Tx side
1267 */
1268#define CXN_KILLED_FIN_RCVD 13 /* Connection got invalidated
1269 * internally due to an
1270 * incoming TCP FIN.
1271 */
1272#define CXN_KILLED_BAD_UNSOL_PDU_RCVD 14 /* Connection got invalidated
1273 * internally due to bad
1274 * unsolicited PDU Unsolicited
1275 * PDUs are PDUs with
1276 * ITT=0xffffffff
1277 */
1278#define CXN_KILLED_BAD_WRB_INDEX_ERROR 15 /* Connection got invalidated
1279 * internally due to bad WRB
1280 * index.
1281 */
1282#define CXN_KILLED_OVER_RUN_RESIDUAL 16 /* Command got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001283 * internally due to received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301284 * command has residual
1285 * over run bytes.
1286 */
1287#define CXN_KILLED_UNDER_RUN_RESIDUAL 17 /* Command got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001288 * internally due to received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301289 * command has residual under
1290 * run bytes.
1291 */
1292#define CMD_KILLED_INVALID_STATSN_RCVD 18 /* Command got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001293 * internally due to a received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301294 * PDU has an invalid StatusSN
1295 */
1296#define CMD_KILLED_INVALID_R2T_RCVD 19 /* Command got invalidated
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001297 * internally due to a received
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301298 * an R2T with some invalid
1299 * fields in it
1300 */
1301#define CMD_CXN_KILLED_LUN_INVALID 20 /* Command got invalidated
1302 * internally due to received
1303 * PDU has an invalid LUN.
1304 */
1305#define CMD_CXN_KILLED_ICD_INVALID 21 /* Command got invalidated
1306 * internally due to the
1307 * corresponding ICD not in a
1308 * valid state
1309 */
1310#define CMD_CXN_KILLED_ITT_INVALID 22 /* Command got invalidated due
1311 * to received PDU has an
1312 * invalid ITT.
1313 */
1314#define CMD_CXN_KILLED_SEQ_OUTOFORDER 23 /* Command got invalidated due
1315 * to received sequence buffer
1316 * offset is out of order.
1317 */
1318#define CMD_CXN_KILLED_INVALID_DATASN_RCVD 24 /* Command got invalidated
1319 * internally due to a
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001320 * received PDU has an invalid
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301321 * DataSN
1322 */
1323#define CXN_INVALIDATE_NOTIFY 25 /* Connection invalidation
1324 * completion notify.
1325 */
1326#define CXN_INVALIDATE_INDEX_NOTIFY 26 /* Connection invalidation
1327 * completion
1328 * with data PDU index.
1329 */
1330#define CMD_INVALIDATED_NOTIFY 27 /* Command invalidation
1331 * completionnotifify.
1332 */
1333#define UNSOL_HDR_NOTIFY 28 /* Unsolicited header notify.*/
1334#define UNSOL_DATA_NOTIFY 29 /* Unsolicited data notify.*/
Jayamohan Kallickal457ff3b2010-07-22 04:16:00 +05301335#define UNSOL_DATA_DIGEST_ERROR_NOTIFY 30 /* Unsolicited data digest
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301336 * error notify.
1337 */
1338#define DRIVERMSG_NOTIFY 31 /* TCP acknowledge based
1339 * notification.
1340 */
1341#define CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN 32 /* Connection got invalidated
1342 * internally due to command
1343 * and data are not on same
1344 * connection.
1345 */
1346#define SOL_CMD_KILLED_DIF_ERR 33 /* Solicited command got
1347 * invalidated internally due
1348 * to DIF error
1349 */
1350#define CXN_KILLED_SYN_RCVD 34 /* Connection got invalidated
1351 * internally due to incoming
1352 * TCP SYN
1353 */
1354#define CXN_KILLED_IMM_DATA_RCVD 35 /* Connection got invalidated
1355 * internally due to an
1356 * incoming Unsolicited PDU
1357 * that has immediate data on
1358 * the cxn
1359 */
1360
Jayamohan Kallickale9b91192010-07-22 04:24:53 +05301361int beiscsi_pci_soft_reset(struct beiscsi_hba *phba);
1362int be_chk_reset_complete(struct beiscsi_hba *phba);
1363
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301364void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len,
1365 bool embedded, u8 sge_cnt);
1366
1367void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr,
1368 u8 subsystem, u8 opcode, int cmd_len);
1369
Jayamohan Kallickal9343be72014-01-29 02:16:43 -05001370void be2iscsi_fail_session(struct iscsi_cls_session *cls_session);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301371#endif /* !BEISCSI_CMDS_H */