Merge tag 'please-pull-ia64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git...
[deliverable/linux.git] / drivers / scsi / be2iscsi / be_cmds.h
1 /**
2 * Copyright (C) 2005 - 2011 Emulex
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License version 2
7 * as published by the Free Software Foundation. The full GNU General
8 * Public License is included in this distribution in the file called COPYING.
9 *
10 * Contact Information:
11 * linux-drivers@emulex.com
12 *
13 * Emulex
14 * 3333 Susan Street
15 * Costa Mesa, CA 92626
16 */
17
18 #ifndef BEISCSI_CMDS_H
19 #define BEISCSI_CMDS_H
20
21 /**
22 * The driver sends configuration and managements command requests to the
23 * firmware in the BE. These requests are communicated to the processor
24 * using Work Request Blocks (WRBs) submitted to the MCC-WRB ring or via one
25 * WRB inside a MAILBOX.
26 * The commands are serviced by the ARM processor in the OneConnect's MPU.
27 */
28 struct 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 */
36 struct 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 {
43 u8 embedded_payload[236]; /* used by embedded cmds */
44 struct be_sge sgl[19]; /* used by non-embedded cmds */
45 } payload;
46 };
47
48 #define CQE_FLAGS_VALID_MASK (1 << 31)
49 #define CQE_FLAGS_ASYNC_MASK (1 << 30)
50 #define CQE_FLAGS_COMPLETED_MASK (1 << 28)
51 #define CQE_FLAGS_CONSUMED_MASK (1 << 27)
52
53 /* Completion Status */
54 #define MCC_STATUS_SUCCESS 0x0
55
56 #define CQE_STATUS_COMPL_MASK 0xFFFF
57 #define CQE_STATUS_COMPL_SHIFT 0 /* bits 0 - 15 */
58 #define CQE_STATUS_EXTD_MASK 0xFFFF
59 #define CQE_STATUS_EXTD_SHIFT 16 /* bits 0 - 15 */
60
61 struct be_mcc_compl {
62 u32 status; /* dword 0 */
63 u32 tag0; /* dword 1 */
64 u32 tag1; /* dword 2 */
65 u32 flags; /* dword 3 */
66 };
67
68 /********* Mailbox door bell *************/
69 /**
70 * Used for driver communication with the FW.
71 * The software must write this register twice to post any command. First,
72 * it writes the register with hi=1 and the upper bits of the physical address
73 * for the MAILBOX structure. Software must poll the ready bit until this
74 * is acknowledged. Then, sotware writes the register with hi=0 with the lower
75 * bits in the address. It must poll the ready bit until the command is
76 * complete. Upon completion, the MAILBOX will contain a valid completion
77 * queue entry.
78 */
79 #define MPU_MAILBOX_DB_OFFSET 0x160
80 #define MPU_MAILBOX_DB_RDY_MASK 0x1 /* bit 0 */
81 #define MPU_MAILBOX_DB_HI_MASK 0x2 /* bit 1 */
82
83 /********** MPU semphore ******************/
84 #define MPU_EP_SEMAPHORE_OFFSET 0xac
85 #define EP_SEMAPHORE_POST_STAGE_MASK 0x0000FFFF
86 #define EP_SEMAPHORE_POST_ERR_MASK 0x1
87 #define EP_SEMAPHORE_POST_ERR_SHIFT 31
88
89 /********** MCC door bell ************/
90 #define DB_MCCQ_OFFSET 0x140
91 #define DB_MCCQ_RING_ID_MASK 0x7FF /* bits 0 - 10 */
92 /* Number of entries posted */
93 #define DB_MCCQ_NUM_POSTED_SHIFT 16 /* bits 16 - 29 */
94
95 /* MPU semphore POST stage values */
96 #define POST_STAGE_ARMFW_RDY 0xc000 /* FW is done with POST */
97
98 /**
99 * When the async bit of mcc_compl is set, the last 4 bytes of
100 * mcc_compl is interpreted as follows:
101 */
102 #define ASYNC_TRAILER_EVENT_CODE_SHIFT 8 /* bits 8 - 15 */
103 #define ASYNC_TRAILER_EVENT_CODE_MASK 0xFF
104 #define ASYNC_EVENT_CODE_LINK_STATE 0x1
105 struct be_async_event_trailer {
106 u32 code;
107 };
108
109 enum {
110 ASYNC_EVENT_LINK_DOWN = 0x0,
111 ASYNC_EVENT_LINK_UP = 0x1
112 };
113
114 /**
115 * When the event code of an async trailer is link-state, the mcc_compl
116 * must be interpreted as follows
117 */
118 struct be_async_event_link_state {
119 u8 physical_port;
120 u8 port_link_status;
121 u8 port_duplex;
122 u8 port_speed;
123 u8 port_fault;
124 u8 rsvd0[7];
125 struct be_async_event_trailer trailer;
126 } __packed;
127
128 struct be_mcc_mailbox {
129 struct be_mcc_wrb wrb;
130 struct be_mcc_compl compl;
131 };
132
133 /* Type of subsystems supported by FW */
134 #define CMD_SUBSYSTEM_COMMON 0x1
135 #define CMD_SUBSYSTEM_ISCSI 0x2
136 #define CMD_SUBSYSTEM_ETH 0x3
137 #define CMD_SUBSYSTEM_ISCSI_INI 0x6
138 #define CMD_COMMON_TCP_UPLOAD 0x1
139
140 /**
141 * List of common opcodes subsystem CMD_SUBSYSTEM_COMMON
142 * These opcodes are unique for each subsystem defined above
143 */
144 #define OPCODE_COMMON_CQ_CREATE 12
145 #define OPCODE_COMMON_EQ_CREATE 13
146 #define OPCODE_COMMON_MCC_CREATE 21
147 #define OPCODE_COMMON_GET_CNTL_ATTRIBUTES 32
148 #define OPCODE_COMMON_GET_FW_VERSION 35
149 #define OPCODE_COMMON_MODIFY_EQ_DELAY 41
150 #define OPCODE_COMMON_FIRMWARE_CONFIG 42
151 #define OPCODE_COMMON_MCC_DESTROY 53
152 #define OPCODE_COMMON_CQ_DESTROY 54
153 #define OPCODE_COMMON_EQ_DESTROY 55
154 #define OPCODE_COMMON_QUERY_FIRMWARE_CONFIG 58
155 #define OPCODE_COMMON_FUNCTION_RESET 61
156
157 /**
158 * LIST of opcodes that are common between Initiator and Target
159 * used by CMD_SUBSYSTEM_ISCSI
160 * These opcodes are unique for each subsystem defined above
161 */
162 #define OPCODE_COMMON_ISCSI_CFG_POST_SGL_PAGES 2
163 #define OPCODE_COMMON_ISCSI_CFG_REMOVE_SGL_PAGES 3
164 #define OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG 7
165 #define OPCODE_COMMON_ISCSI_NTWK_SET_VLAN 14
166 #define OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR 17
167 #define OPCODE_COMMON_ISCSI_NTWK_REL_STATELESS_IP_ADDR 18
168 #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR 21
169 #define OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY 22
170 #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY 23
171 #define OPCODE_COMMON_ISCSI_NTWK_GET_ALL_IF_ID 24
172 #define OPCODE_COMMON_ISCSI_NTWK_GET_IF_INFO 25
173 #define OPCODE_COMMON_ISCSI_SET_FRAGNUM_BITS_FOR_SGL_CRA 61
174 #define OPCODE_COMMON_ISCSI_DEFQ_CREATE 64
175 #define OPCODE_COMMON_ISCSI_DEFQ_DESTROY 65
176 #define OPCODE_COMMON_ISCSI_WRBQ_CREATE 66
177 #define OPCODE_COMMON_ISCSI_WRBQ_DESTROY 67
178
179 struct be_cmd_req_hdr {
180 u8 opcode; /* dword 0 */
181 u8 subsystem; /* dword 0 */
182 u8 port_number; /* dword 0 */
183 u8 domain; /* dword 0 */
184 u32 timeout; /* dword 1 */
185 u32 request_length; /* dword 2 */
186 u32 rsvd0; /* dword 3 */
187 };
188
189 struct be_cmd_resp_hdr {
190 u32 info; /* dword 0 */
191 u32 status; /* dword 1 */
192 u32 response_length; /* dword 2 */
193 u32 actual_resp_len; /* dword 3 */
194 };
195
196 struct phys_addr {
197 u32 lo;
198 u32 hi;
199 };
200
201 /**************************
202 * BE Command definitions *
203 **************************/
204
205 /**
206 * Pseudo amap definition in which each bit of the actual structure is defined
207 * as a byte - used to calculate offset/shift/mask of each field
208 */
209 struct amap_eq_context {
210 u8 cidx[13]; /* dword 0 */
211 u8 rsvd0[3]; /* dword 0 */
212 u8 epidx[13]; /* dword 0 */
213 u8 valid; /* dword 0 */
214 u8 rsvd1; /* dword 0 */
215 u8 size; /* dword 0 */
216 u8 pidx[13]; /* dword 1 */
217 u8 rsvd2[3]; /* dword 1 */
218 u8 pd[10]; /* dword 1 */
219 u8 count[3]; /* dword 1 */
220 u8 solevent; /* dword 1 */
221 u8 stalled; /* dword 1 */
222 u8 armed; /* dword 1 */
223 u8 rsvd3[4]; /* dword 2 */
224 u8 func[8]; /* dword 2 */
225 u8 rsvd4; /* dword 2 */
226 u8 delaymult[10]; /* dword 2 */
227 u8 rsvd5[2]; /* dword 2 */
228 u8 phase[2]; /* dword 2 */
229 u8 nodelay; /* dword 2 */
230 u8 rsvd6[4]; /* dword 2 */
231 u8 rsvd7[32]; /* dword 3 */
232 } __packed;
233
234 struct be_cmd_req_eq_create {
235 struct be_cmd_req_hdr hdr; /* dw[4] */
236 u16 num_pages; /* sword */
237 u16 rsvd0; /* sword */
238 u8 context[sizeof(struct amap_eq_context) / 8]; /* dw[4] */
239 struct phys_addr pages[8];
240 } __packed;
241
242 struct be_cmd_resp_eq_create {
243 struct be_cmd_resp_hdr resp_hdr;
244 u16 eq_id; /* sword */
245 u16 rsvd0; /* sword */
246 } __packed;
247
248 struct mgmt_chap_format {
249 u32 flags;
250 u8 intr_chap_name[256];
251 u8 intr_secret[16];
252 u8 target_chap_name[256];
253 u8 target_secret[16];
254 u16 intr_chap_name_length;
255 u16 intr_secret_length;
256 u16 target_chap_name_length;
257 u16 target_secret_length;
258 } __packed;
259
260 struct mgmt_auth_method_format {
261 u8 auth_method_type;
262 u8 padding[3];
263 struct mgmt_chap_format chap;
264 } __packed;
265
266 struct mgmt_conn_login_options {
267 u8 flags;
268 u8 header_digest;
269 u8 data_digest;
270 u8 rsvd0;
271 u32 max_recv_datasegment_len_ini;
272 u32 max_recv_datasegment_len_tgt;
273 u32 tcp_mss;
274 u32 tcp_window_size;
275 struct mgmt_auth_method_format auth_data;
276 } __packed;
277
278 struct ip_addr_format {
279 u16 size_of_structure;
280 u8 reserved;
281 u8 ip_type;
282 u8 addr[16];
283 u32 rsvd0;
284 } __packed;
285
286 struct mgmt_conn_info {
287 u32 connection_handle;
288 u32 connection_status;
289 u16 src_port;
290 u16 dest_port;
291 u16 dest_port_redirected;
292 u16 cid;
293 u32 estimated_throughput;
294 struct ip_addr_format src_ipaddr;
295 struct ip_addr_format dest_ipaddr;
296 struct ip_addr_format dest_ipaddr_redirected;
297 struct mgmt_conn_login_options negotiated_login_options;
298 } __packed;
299
300 struct mgmt_session_login_options {
301 u8 flags;
302 u8 error_recovery_level;
303 u16 rsvd0;
304 u32 first_burst_length;
305 u32 max_burst_length;
306 u16 max_connections;
307 u16 max_outstanding_r2t;
308 u16 default_time2wait;
309 u16 default_time2retain;
310 } __packed;
311
312 struct mgmt_session_info {
313 u32 session_handle;
314 u32 status;
315 u8 isid[6];
316 u16 tsih;
317 u32 session_flags;
318 u16 conn_count;
319 u16 pad;
320 u8 target_name[224];
321 u8 initiator_iscsiname[224];
322 struct mgmt_session_login_options negotiated_login_options;
323 struct mgmt_conn_info conn_list[1];
324 } __packed;
325
326 struct be_cmd_get_session_req {
327 struct be_cmd_req_hdr hdr;
328 u32 session_handle;
329 } __packed;
330
331 struct be_cmd_get_session_resp {
332 struct be_cmd_resp_hdr hdr;
333 struct mgmt_session_info session_info;
334 } __packed;
335
336 struct mac_addr {
337 u16 size_of_structure;
338 u8 addr[ETH_ALEN];
339 } __packed;
340
341 struct be_cmd_get_boot_target_req {
342 struct be_cmd_req_hdr hdr;
343 } __packed;
344
345 struct be_cmd_get_boot_target_resp {
346 struct be_cmd_resp_hdr hdr;
347 u32 boot_session_count;
348 int boot_session_handle;
349 };
350
351 struct be_cmd_mac_query_req {
352 struct be_cmd_req_hdr hdr;
353 u8 type;
354 u8 permanent;
355 u16 if_id;
356 } __packed;
357
358 struct be_cmd_get_mac_resp {
359 struct be_cmd_resp_hdr hdr;
360 struct mac_addr mac;
361 };
362
363 struct be_ip_addr_subnet_format {
364 u16 size_of_structure;
365 u8 ip_type;
366 u8 ipv6_prefix_length;
367 u8 addr[16];
368 u8 subnet_mask[16];
369 u32 rsvd0;
370 } __packed;
371
372 struct be_cmd_get_if_info_req {
373 struct be_cmd_req_hdr hdr;
374 u32 interface_hndl;
375 u32 ip_type;
376 } __packed;
377
378 struct be_cmd_get_if_info_resp {
379 struct be_cmd_req_hdr hdr;
380 u32 interface_hndl;
381 u32 vlan_priority;
382 u32 ip_addr_count;
383 u32 dhcp_state;
384 struct be_ip_addr_subnet_format ip_addr;
385 } __packed;
386
387 struct be_ip_addr_record {
388 u32 action;
389 u32 interface_hndl;
390 struct be_ip_addr_subnet_format ip_addr;
391 u32 status;
392 } __packed;
393
394 struct be_ip_addr_record_params {
395 u32 record_entry_count;
396 struct be_ip_addr_record ip_record;
397 } __packed;
398
399 struct be_cmd_set_ip_addr_req {
400 struct be_cmd_req_hdr hdr;
401 struct be_ip_addr_record_params ip_params;
402 } __packed;
403
404
405 struct be_cmd_set_dhcp_req {
406 struct be_cmd_req_hdr hdr;
407 u32 interface_hndl;
408 u32 ip_type;
409 u32 flags;
410 u32 retry_count;
411 } __packed;
412
413 struct be_cmd_rel_dhcp_req {
414 struct be_cmd_req_hdr hdr;
415 u32 interface_hndl;
416 u32 ip_type;
417 } __packed;
418
419 struct be_cmd_set_def_gateway_req {
420 struct be_cmd_req_hdr hdr;
421 u32 action;
422 struct ip_addr_format ip_addr;
423 } __packed;
424
425 struct be_cmd_get_def_gateway_req {
426 struct be_cmd_req_hdr hdr;
427 u32 ip_type;
428 } __packed;
429
430 struct be_cmd_get_def_gateway_resp {
431 struct be_cmd_req_hdr hdr;
432 struct ip_addr_format ip_addr;
433 } __packed;
434
435 /******************** Create CQ ***************************/
436 /**
437 * Pseudo amap definition in which each bit of the actual structure is defined
438 * as a byte - used to calculate offset/shift/mask of each field
439 */
440 struct amap_cq_context {
441 u8 cidx[11]; /* dword 0 */
442 u8 rsvd0; /* dword 0 */
443 u8 coalescwm[2]; /* dword 0 */
444 u8 nodelay; /* dword 0 */
445 u8 epidx[11]; /* dword 0 */
446 u8 rsvd1; /* dword 0 */
447 u8 count[2]; /* dword 0 */
448 u8 valid; /* dword 0 */
449 u8 solevent; /* dword 0 */
450 u8 eventable; /* dword 0 */
451 u8 pidx[11]; /* dword 1 */
452 u8 rsvd2; /* dword 1 */
453 u8 pd[10]; /* dword 1 */
454 u8 eqid[8]; /* dword 1 */
455 u8 stalled; /* dword 1 */
456 u8 armed; /* dword 1 */
457 u8 rsvd3[4]; /* dword 2 */
458 u8 func[8]; /* dword 2 */
459 u8 rsvd4[20]; /* dword 2 */
460 u8 rsvd5[32]; /* dword 3 */
461 } __packed;
462
463 struct be_cmd_req_cq_create {
464 struct be_cmd_req_hdr hdr;
465 u16 num_pages;
466 u16 rsvd0;
467 u8 context[sizeof(struct amap_cq_context) / 8];
468 struct phys_addr pages[4];
469 } __packed;
470
471 struct be_cmd_resp_cq_create {
472 struct be_cmd_resp_hdr hdr;
473 u16 cq_id;
474 u16 rsvd0;
475 } __packed;
476
477 /******************** Create MCCQ ***************************/
478 /**
479 * Pseudo amap definition in which each bit of the actual structure is defined
480 * as a byte - used to calculate offset/shift/mask of each field
481 */
482 struct amap_mcc_context {
483 u8 con_index[14];
484 u8 rsvd0[2];
485 u8 ring_size[4];
486 u8 fetch_wrb;
487 u8 fetch_r2t;
488 u8 cq_id[10];
489 u8 prod_index[14];
490 u8 fid[8];
491 u8 pdid[9];
492 u8 valid;
493 u8 rsvd1[32];
494 u8 rsvd2[32];
495 } __packed;
496
497 struct be_cmd_req_mcc_create {
498 struct be_cmd_req_hdr hdr;
499 u16 num_pages;
500 u16 rsvd0;
501 u8 context[sizeof(struct amap_mcc_context) / 8];
502 struct phys_addr pages[8];
503 } __packed;
504
505 struct be_cmd_resp_mcc_create {
506 struct be_cmd_resp_hdr hdr;
507 u16 id;
508 u16 rsvd0;
509 } __packed;
510
511 /******************** Q Destroy ***************************/
512 /* Type of Queue to be destroyed */
513 enum {
514 QTYPE_EQ = 1,
515 QTYPE_CQ,
516 QTYPE_MCCQ,
517 QTYPE_WRBQ,
518 QTYPE_DPDUQ,
519 QTYPE_SGL
520 };
521
522 struct be_cmd_req_q_destroy {
523 struct be_cmd_req_hdr hdr;
524 u16 id;
525 u16 bypass_flush; /* valid only for rx q destroy */
526 } __packed;
527
528 struct macaddr {
529 u8 byte[ETH_ALEN];
530 };
531
532 struct be_cmd_req_mcast_mac_config {
533 struct be_cmd_req_hdr hdr;
534 u16 num_mac;
535 u8 promiscuous;
536 u8 interface_id;
537 struct macaddr mac[32];
538 } __packed;
539
540 static inline void *embedded_payload(struct be_mcc_wrb *wrb)
541 {
542 return wrb->payload.embedded_payload;
543 }
544
545 static inline struct be_sge *nonembedded_sgl(struct be_mcc_wrb *wrb)
546 {
547 return &wrb->payload.sgl[0];
548 }
549
550 /******************** Modify EQ Delay *******************/
551 struct be_cmd_req_modify_eq_delay {
552 struct be_cmd_req_hdr hdr;
553 u32 num_eq;
554 struct {
555 u32 eq_id;
556 u32 phase;
557 u32 delay_multiplier;
558 } delay[8];
559 } __packed;
560
561 /******************** Get MAC ADDR *******************/
562
563 #define ETH_ALEN 6
564
565 struct be_cmd_get_nic_conf_req {
566 struct be_cmd_req_hdr hdr;
567 u32 nic_port_count;
568 u32 speed;
569 u32 max_speed;
570 u32 link_state;
571 u32 max_frame_size;
572 u16 size_of_structure;
573 u8 mac_address[ETH_ALEN];
574 u32 rsvd[23];
575 };
576
577 struct be_cmd_get_nic_conf_resp {
578 struct be_cmd_resp_hdr hdr;
579 u32 nic_port_count;
580 u32 speed;
581 u32 max_speed;
582 u32 link_state;
583 u32 max_frame_size;
584 u16 size_of_structure;
585 u8 mac_address[6];
586 u32 rsvd[23];
587 };
588
589 #define BEISCSI_ALIAS_LEN 32
590
591 struct be_cmd_hba_name {
592 struct be_cmd_req_hdr hdr;
593 u16 flags;
594 u16 rsvd0;
595 u8 initiator_name[ISCSI_NAME_LEN];
596 u8 initiator_alias[BEISCSI_ALIAS_LEN];
597 } __packed;
598
599 struct be_cmd_ntwk_link_status_req {
600 struct be_cmd_req_hdr hdr;
601 u32 rsvd0;
602 } __packed;
603
604 /*** Port Speed Values ***/
605 #define BE2ISCSI_LINK_SPEED_ZERO 0x00
606 #define BE2ISCSI_LINK_SPEED_10MBPS 0x01
607 #define BE2ISCSI_LINK_SPEED_100MBPS 0x02
608 #define BE2ISCSI_LINK_SPEED_1GBPS 0x03
609 #define BE2ISCSI_LINK_SPEED_10GBPS 0x04
610 struct be_cmd_ntwk_link_status_resp {
611 struct be_cmd_resp_hdr hdr;
612 u8 phys_port;
613 u8 mac_duplex;
614 u8 mac_speed;
615 u8 mac_fault;
616 u8 mgmt_mac_duplex;
617 u8 mgmt_mac_speed;
618 u16 qos_link_speed;
619 u32 logical_link_speed;
620 } __packed;
621
622 int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl,
623 struct be_queue_info *eq, int eq_delay);
624
625 int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl,
626 struct be_queue_info *cq, struct be_queue_info *eq,
627 bool sol_evts, bool no_delay,
628 int num_cqe_dma_coalesce);
629
630 int beiscsi_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q,
631 int type);
632 int beiscsi_cmd_mccq_create(struct beiscsi_hba *phba,
633 struct be_queue_info *mccq,
634 struct be_queue_info *cq);
635
636 int be_poll_mcc(struct be_ctrl_info *ctrl);
637 int mgmt_check_supported_fw(struct be_ctrl_info *ctrl,
638 struct beiscsi_hba *phba);
639 unsigned int be_cmd_get_initname(struct beiscsi_hba *phba);
640 unsigned int be_cmd_get_port_speed(struct beiscsi_hba *phba);
641
642 void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag);
643 /*ISCSI Functuions */
644 int be_cmd_fw_initialize(struct be_ctrl_info *ctrl);
645
646 struct be_mcc_wrb *wrb_from_mbox(struct be_dma_mem *mbox_mem);
647 struct be_mcc_wrb *wrb_from_mccq(struct beiscsi_hba *phba);
648 int be_mcc_notify_wait(struct beiscsi_hba *phba);
649 void be_mcc_notify(struct beiscsi_hba *phba);
650 unsigned int alloc_mcc_tag(struct beiscsi_hba *phba);
651 void beiscsi_async_link_state_process(struct beiscsi_hba *phba,
652 struct be_async_event_link_state *evt);
653 int be_mcc_compl_process_isr(struct be_ctrl_info *ctrl,
654 struct be_mcc_compl *compl);
655
656 int be_mbox_notify(struct be_ctrl_info *ctrl);
657
658 int be_cmd_create_default_pdu_queue(struct be_ctrl_info *ctrl,
659 struct be_queue_info *cq,
660 struct be_queue_info *dq, int length,
661 int entry_size);
662
663 int be_cmd_iscsi_post_sgl_pages(struct be_ctrl_info *ctrl,
664 struct be_dma_mem *q_mem, u32 page_offset,
665 u32 num_pages);
666
667 int beiscsi_cmd_reset_function(struct beiscsi_hba *phba);
668
669 int be_cmd_wrbq_create(struct be_ctrl_info *ctrl, struct be_dma_mem *q_mem,
670 struct be_queue_info *wrbq);
671
672 bool is_link_state_evt(u32 trailer);
673
674 struct be_default_pdu_context {
675 u32 dw[4];
676 } __packed;
677
678 struct amap_be_default_pdu_context {
679 u8 dbuf_cindex[13]; /* dword 0 */
680 u8 rsvd0[3]; /* dword 0 */
681 u8 ring_size[4]; /* dword 0 */
682 u8 ring_state[4]; /* dword 0 */
683 u8 rsvd1[8]; /* dword 0 */
684 u8 dbuf_pindex[13]; /* dword 1 */
685 u8 rsvd2; /* dword 1 */
686 u8 pci_func_id[8]; /* dword 1 */
687 u8 rx_pdid[9]; /* dword 1 */
688 u8 rx_pdid_valid; /* dword 1 */
689 u8 default_buffer_size[16]; /* dword 2 */
690 u8 cq_id_recv[10]; /* dword 2 */
691 u8 rx_pdid_not_valid; /* dword 2 */
692 u8 rsvd3[5]; /* dword 2 */
693 u8 rsvd4[32]; /* dword 3 */
694 } __packed;
695
696 struct be_defq_create_req {
697 struct be_cmd_req_hdr hdr;
698 u16 num_pages;
699 u8 ulp_num;
700 u8 rsvd0;
701 struct be_default_pdu_context context;
702 struct phys_addr pages[8];
703 } __packed;
704
705 struct be_defq_create_resp {
706 struct be_cmd_req_hdr hdr;
707 u16 id;
708 u16 rsvd0;
709 } __packed;
710
711 struct be_post_sgl_pages_req {
712 struct be_cmd_req_hdr hdr;
713 u16 num_pages;
714 u16 page_offset;
715 u32 rsvd0;
716 struct phys_addr pages[26];
717 u32 rsvd1;
718 } __packed;
719
720 struct be_wrbq_create_req {
721 struct be_cmd_req_hdr hdr;
722 u16 num_pages;
723 u8 ulp_num;
724 u8 rsvd0;
725 struct phys_addr pages[8];
726 } __packed;
727
728 struct be_wrbq_create_resp {
729 struct be_cmd_resp_hdr resp_hdr;
730 u16 cid;
731 u16 rsvd0;
732 } __packed;
733
734 #define SOL_CID_MASK 0x0000FFC0
735 #define SOL_CODE_MASK 0x0000003F
736 #define SOL_WRB_INDEX_MASK 0x00FF0000
737 #define SOL_CMD_WND_MASK 0xFF000000
738 #define SOL_RES_CNT_MASK 0x7FFFFFFF
739 #define SOL_EXP_CMD_SN_MASK 0xFFFFFFFF
740 #define SOL_HW_STS_MASK 0x000000FF
741 #define SOL_STS_MASK 0x0000FF00
742 #define SOL_RESP_MASK 0x00FF0000
743 #define SOL_FLAGS_MASK 0x7F000000
744 #define SOL_S_MASK 0x80000000
745
746 struct sol_cqe {
747 u32 dw[4];
748 };
749
750 struct amap_sol_cqe {
751 u8 hw_sts[8]; /* dword 0 */
752 u8 i_sts[8]; /* dword 0 */
753 u8 i_resp[8]; /* dword 0 */
754 u8 i_flags[7]; /* dword 0 */
755 u8 s; /* dword 0 */
756 u8 i_exp_cmd_sn[32]; /* dword 1 */
757 u8 code[6]; /* dword 2 */
758 u8 cid[10]; /* dword 2 */
759 u8 wrb_index[8]; /* dword 2 */
760 u8 i_cmd_wnd[8]; /* dword 2 */
761 u8 i_res_cnt[31]; /* dword 3 */
762 u8 valid; /* dword 3 */
763 } __packed;
764
765 #define SOL_ICD_INDEX_MASK 0x0003FFC0
766 struct amap_sol_cqe_ring {
767 u8 hw_sts[8]; /* dword 0 */
768 u8 i_sts[8]; /* dword 0 */
769 u8 i_resp[8]; /* dword 0 */
770 u8 i_flags[7]; /* dword 0 */
771 u8 s; /* dword 0 */
772 u8 i_exp_cmd_sn[32]; /* dword 1 */
773 u8 code[6]; /* dword 2 */
774 u8 icd_index[12]; /* dword 2 */
775 u8 rsvd[6]; /* dword 2 */
776 u8 i_cmd_wnd[8]; /* dword 2 */
777 u8 i_res_cnt[31]; /* dword 3 */
778 u8 valid; /* dword 3 */
779 } __packed;
780
781
782
783 /**
784 * Post WRB Queue Doorbell Register used by the host Storage
785 * stack to notify the
786 * controller of a posted Work Request Block
787 */
788 #define DB_WRB_POST_CID_MASK 0x3FF /* bits 0 - 9 */
789 #define DB_DEF_PDU_WRB_INDEX_MASK 0xFF /* bits 0 - 9 */
790
791 #define DB_DEF_PDU_WRB_INDEX_SHIFT 16
792 #define DB_DEF_PDU_NUM_POSTED_SHIFT 24
793
794 struct fragnum_bits_for_sgl_cra_in {
795 struct be_cmd_req_hdr hdr;
796 u32 num_bits;
797 } __packed;
798
799 struct iscsi_cleanup_req {
800 struct be_cmd_req_hdr hdr;
801 u16 chute;
802 u8 hdr_ring_id;
803 u8 data_ring_id;
804
805 } __packed;
806
807 struct eq_delay {
808 u32 eq_id;
809 u32 phase;
810 u32 delay_multiplier;
811 } __packed;
812
813 struct be_eq_delay_params_in {
814 struct be_cmd_req_hdr hdr;
815 u32 num_eq;
816 struct eq_delay delay[8];
817 } __packed;
818
819 struct tcp_connect_and_offload_in {
820 struct be_cmd_req_hdr hdr;
821 struct ip_addr_format ip_address;
822 u16 tcp_port;
823 u16 cid;
824 u16 cq_id;
825 u16 defq_id;
826 struct phys_addr dataout_template_pa;
827 u16 hdr_ring_id;
828 u16 data_ring_id;
829 u8 do_offload;
830 u8 rsvd0[3];
831 } __packed;
832
833 struct tcp_connect_and_offload_out {
834 struct be_cmd_resp_hdr hdr;
835 u32 connection_handle;
836 u16 cid;
837 u16 rsvd0;
838
839 } __packed;
840
841 struct be_mcc_wrb_context {
842 struct MCC_WRB *wrb;
843 int *users_final_status;
844 } __packed;
845
846 #define DB_DEF_PDU_RING_ID_MASK 0x3FF /* bits 0 - 9 */
847 #define DB_DEF_PDU_CQPROC_MASK 0x3FFF /* bits 0 - 9 */
848 #define DB_DEF_PDU_REARM_SHIFT 14
849 #define DB_DEF_PDU_EVENT_SHIFT 15
850 #define DB_DEF_PDU_CQPROC_SHIFT 16
851
852 struct dmsg_cqe {
853 u32 dw[4];
854 } __packed;
855
856 struct tcp_upload_params_in {
857 struct be_cmd_req_hdr hdr;
858 u16 id;
859 u16 upload_type;
860 u32 reset_seq;
861 } __packed;
862
863 struct tcp_upload_params_out {
864 u32 dw[32];
865 } __packed;
866
867 union tcp_upload_params {
868 struct tcp_upload_params_in request;
869 struct tcp_upload_params_out response;
870 } __packed;
871
872 struct be_ulp_fw_cfg {
873 u32 ulp_mode;
874 u32 etx_base;
875 u32 etx_count;
876 u32 sq_base;
877 u32 sq_count;
878 u32 rq_base;
879 u32 rq_count;
880 u32 dq_base;
881 u32 dq_count;
882 u32 lro_base;
883 u32 lro_count;
884 u32 icd_base;
885 u32 icd_count;
886 };
887
888 struct be_fw_cfg {
889 struct be_cmd_req_hdr hdr;
890 u32 be_config_number;
891 u32 asic_revision;
892 u32 phys_port;
893 u32 function_mode;
894 struct be_ulp_fw_cfg ulp[2];
895 u32 function_caps;
896 } __packed;
897
898 struct be_cmd_get_all_if_id_req {
899 struct be_cmd_req_hdr hdr;
900 u32 if_count;
901 u32 if_hndl_list[1];
902 } __packed;
903
904 #define ISCSI_OPCODE_SCSI_DATA_OUT 5
905 #define OPCODE_COMMON_NTWK_LINK_STATUS_QUERY 5
906 #define OPCODE_COMMON_MODIFY_EQ_DELAY 41
907 #define OPCODE_COMMON_ISCSI_CLEANUP 59
908 #define OPCODE_COMMON_TCP_UPLOAD 56
909 #define OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD 70
910 #define OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS 1
911 #define OPCODE_ISCSI_INI_CFG_GET_HBA_NAME 6
912 #define OPCODE_ISCSI_INI_CFG_SET_HBA_NAME 7
913 #define OPCODE_ISCSI_INI_SESSION_GET_A_SESSION 14
914 #define OPCODE_ISCSI_INI_DRIVER_OFFLOAD_SESSION 41
915 #define OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION 42
916 #define OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET 52
917 #define OPCODE_COMMON_WRITE_FLASH 96
918 #define OPCODE_COMMON_READ_FLASH 97
919
920 /* --- CMD_ISCSI_INVALIDATE_CONNECTION_TYPE --- */
921 #define CMD_ISCSI_COMMAND_INVALIDATE 1
922 #define CMD_ISCSI_CONNECTION_INVALIDATE 0x8001
923 #define CMD_ISCSI_CONNECTION_ISSUE_TCP_RST 0x8002
924
925 #define INI_WR_CMD 1 /* Initiator write command */
926 #define INI_TMF_CMD 2 /* Initiator TMF command */
927 #define INI_NOPOUT_CMD 3 /* Initiator; Send a NOP-OUT */
928 #define INI_RD_CMD 5 /* Initiator requesting to send
929 * a read command
930 */
931 #define TGT_CTX_UPDT_CMD 7 /* Target context update */
932 #define TGT_STS_CMD 8 /* Target R2T and other BHS
933 * where only the status number
934 * need to be updated
935 */
936 #define TGT_DATAIN_CMD 9 /* Target Data-Ins in response
937 * to read command
938 */
939 #define TGT_SOS_PDU 10 /* Target:standalone status
940 * response
941 */
942 #define TGT_DM_CMD 11 /* Indicates that the bhs
943 * preparedby
944 * driver should not be touched
945 */
946 /* --- CMD_CHUTE_TYPE --- */
947 #define CMD_CONNECTION_CHUTE_0 1
948 #define CMD_CONNECTION_CHUTE_1 2
949 #define CMD_CONNECTION_CHUTE_2 3
950
951 #define EQ_MAJOR_CODE_COMPLETION 0
952
953 #define CMD_ISCSI_SESSION_DEL_CFG_FROM_FLASH 0
954 #define CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH 1
955
956 /* --- CONNECTION_UPLOAD_PARAMS --- */
957 /* These parameters are used to define the type of upload desired. */
958 #define CONNECTION_UPLOAD_GRACEFUL 1 /* Graceful upload */
959 #define CONNECTION_UPLOAD_ABORT_RESET 2 /* Abortive upload with
960 * reset
961 */
962 #define CONNECTION_UPLOAD_ABORT 3 /* Abortive upload without
963 * reset
964 */
965 #define CONNECTION_UPLOAD_ABORT_WITH_SEQ 4 /* Abortive upload with reset,
966 * sequence number by driver */
967
968 /* Returns byte size of given field with a structure. */
969
970 /* Returns the number of items in the field array. */
971 #define BE_NUMBER_OF_FIELD(_type_, _field_) \
972 (FIELD_SIZEOF(_type_, _field_)/sizeof((((_type_ *)0)->_field_[0])))\
973
974 /**
975 * Different types of iSCSI completions to host driver for both initiator
976 * and taget mode
977 * of operation.
978 */
979 #define SOL_CMD_COMPLETE 1 /* Solicited command completed
980 * normally
981 */
982 #define SOL_CMD_KILLED_DATA_DIGEST_ERR 2 /* Solicited command got
983 * invalidated internally due
984 * to Data Digest error
985 */
986 #define CXN_KILLED_PDU_SIZE_EXCEEDS_DSL 3 /* Connection got invalidated
987 * internally
988 * due to a received PDU
989 * size > DSL
990 */
991 #define CXN_KILLED_BURST_LEN_MISMATCH 4 /* Connection got invalidated
992 * internally due ti received
993 * PDU sequence size >
994 * FBL/MBL.
995 */
996 #define CXN_KILLED_AHS_RCVD 5 /* Connection got invalidated
997 * internally due to a received
998 * PDU Hdr that has
999 * AHS */
1000 #define CXN_KILLED_HDR_DIGEST_ERR 6 /* Connection got invalidated
1001 * internally due to Hdr Digest
1002 * error
1003 */
1004 #define CXN_KILLED_UNKNOWN_HDR 7 /* Connection got invalidated
1005 * internally
1006 * due to a bad opcode in the
1007 * pdu hdr
1008 */
1009 #define CXN_KILLED_STALE_ITT_TTT_RCVD 8 /* Connection got invalidated
1010 * internally due to a received
1011 * ITT/TTT that does not belong
1012 * to this Connection
1013 */
1014 #define CXN_KILLED_INVALID_ITT_TTT_RCVD 9 /* Connection got invalidated
1015 * internally due to received
1016 * ITT/TTT value > Max
1017 * Supported ITTs/TTTs
1018 */
1019 #define CXN_KILLED_RST_RCVD 10 /* Connection got invalidated
1020 * internally due to an
1021 * incoming TCP RST
1022 */
1023 #define CXN_KILLED_TIMED_OUT 11 /* Connection got invalidated
1024 * internally due to timeout on
1025 * tcp segment 12 retransmit
1026 * attempts failed
1027 */
1028 #define CXN_KILLED_RST_SENT 12 /* Connection got invalidated
1029 * internally due to TCP RST
1030 * sent by the Tx side
1031 */
1032 #define CXN_KILLED_FIN_RCVD 13 /* Connection got invalidated
1033 * internally due to an
1034 * incoming TCP FIN.
1035 */
1036 #define CXN_KILLED_BAD_UNSOL_PDU_RCVD 14 /* Connection got invalidated
1037 * internally due to bad
1038 * unsolicited PDU Unsolicited
1039 * PDUs are PDUs with
1040 * ITT=0xffffffff
1041 */
1042 #define CXN_KILLED_BAD_WRB_INDEX_ERROR 15 /* Connection got invalidated
1043 * internally due to bad WRB
1044 * index.
1045 */
1046 #define CXN_KILLED_OVER_RUN_RESIDUAL 16 /* Command got invalidated
1047 * internally due to received
1048 * command has residual
1049 * over run bytes.
1050 */
1051 #define CXN_KILLED_UNDER_RUN_RESIDUAL 17 /* Command got invalidated
1052 * internally due to received
1053 * command has residual under
1054 * run bytes.
1055 */
1056 #define CMD_KILLED_INVALID_STATSN_RCVD 18 /* Command got invalidated
1057 * internally due to a received
1058 * PDU has an invalid StatusSN
1059 */
1060 #define CMD_KILLED_INVALID_R2T_RCVD 19 /* Command got invalidated
1061 * internally due to a received
1062 * an R2T with some invalid
1063 * fields in it
1064 */
1065 #define CMD_CXN_KILLED_LUN_INVALID 20 /* Command got invalidated
1066 * internally due to received
1067 * PDU has an invalid LUN.
1068 */
1069 #define CMD_CXN_KILLED_ICD_INVALID 21 /* Command got invalidated
1070 * internally due to the
1071 * corresponding ICD not in a
1072 * valid state
1073 */
1074 #define CMD_CXN_KILLED_ITT_INVALID 22 /* Command got invalidated due
1075 * to received PDU has an
1076 * invalid ITT.
1077 */
1078 #define CMD_CXN_KILLED_SEQ_OUTOFORDER 23 /* Command got invalidated due
1079 * to received sequence buffer
1080 * offset is out of order.
1081 */
1082 #define CMD_CXN_KILLED_INVALID_DATASN_RCVD 24 /* Command got invalidated
1083 * internally due to a
1084 * received PDU has an invalid
1085 * DataSN
1086 */
1087 #define CXN_INVALIDATE_NOTIFY 25 /* Connection invalidation
1088 * completion notify.
1089 */
1090 #define CXN_INVALIDATE_INDEX_NOTIFY 26 /* Connection invalidation
1091 * completion
1092 * with data PDU index.
1093 */
1094 #define CMD_INVALIDATED_NOTIFY 27 /* Command invalidation
1095 * completionnotifify.
1096 */
1097 #define UNSOL_HDR_NOTIFY 28 /* Unsolicited header notify.*/
1098 #define UNSOL_DATA_NOTIFY 29 /* Unsolicited data notify.*/
1099 #define UNSOL_DATA_DIGEST_ERROR_NOTIFY 30 /* Unsolicited data digest
1100 * error notify.
1101 */
1102 #define DRIVERMSG_NOTIFY 31 /* TCP acknowledge based
1103 * notification.
1104 */
1105 #define CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN 32 /* Connection got invalidated
1106 * internally due to command
1107 * and data are not on same
1108 * connection.
1109 */
1110 #define SOL_CMD_KILLED_DIF_ERR 33 /* Solicited command got
1111 * invalidated internally due
1112 * to DIF error
1113 */
1114 #define CXN_KILLED_SYN_RCVD 34 /* Connection got invalidated
1115 * internally due to incoming
1116 * TCP SYN
1117 */
1118 #define CXN_KILLED_IMM_DATA_RCVD 35 /* Connection got invalidated
1119 * internally due to an
1120 * incoming Unsolicited PDU
1121 * that has immediate data on
1122 * the cxn
1123 */
1124
1125 int beiscsi_pci_soft_reset(struct beiscsi_hba *phba);
1126 int be_chk_reset_complete(struct beiscsi_hba *phba);
1127
1128 void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len,
1129 bool embedded, u8 sge_cnt);
1130
1131 void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr,
1132 u8 subsystem, u8 opcode, int cmd_len);
1133
1134 #endif /* !BEISCSI_CMDS_H */
This page took 0.055988 seconds and 5 git commands to generate.