1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#ifndef BEISCSI_CMDS_H
19#define BEISCSI_CMDS_H
20
21
22
23
24
25
26
27
28struct be_sge {
29 __le32 pa_lo;
30 __le32 pa_hi;
31 __le32 len;
32};
33
34#define MCC_WRB_SGE_CNT_SHIFT 3
35#define MCC_WRB_SGE_CNT_MASK 0x1F
36struct be_mcc_wrb {
37 u32 embedded;
38 u32 payload_length;
39 u32 tag0;
40 u32 tag1;
41 u32 rsvd;
42 union {
43#define EMBED_MBX_MAX_PAYLOAD_SIZE 220
44 u8 embedded_payload[236];
45 struct be_sge sgl[19];
46 } payload;
47};
48
49#define CQE_FLAGS_VALID_MASK (1 << 31)
50#define CQE_FLAGS_ASYNC_MASK (1 << 30)
51#define CQE_FLAGS_COMPLETED_MASK (1 << 28)
52#define CQE_FLAGS_CONSUMED_MASK (1 << 27)
53
54
55#define MCC_STATUS_SUCCESS 0x0
56#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
60
61#define CQE_STATUS_COMPL_MASK 0xFFFF
62#define CQE_STATUS_COMPL_SHIFT 0
63#define CQE_STATUS_EXTD_MASK 0xFFFF
64#define CQE_STATUS_EXTD_SHIFT 16
65#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
72
73
74#define MBX_CMD_VER1 0x01
75#define MBX_CMD_VER2 0x02
76
77struct be_mcc_compl {
78 u32 status;
79 u32 tag0;
80 u32 tag1;
81 u32 flags;
82};
83
84
85
86
87
88
89
90
91
92
93
94
95#define MPU_MAILBOX_DB_OFFSET 0x160
96#define MPU_MAILBOX_DB_RDY_MASK 0x1
97#define MPU_MAILBOX_DB_HI_MASK 0x2
98
99
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
106#define DB_MCCQ_OFFSET 0x140
107#define DB_MCCQ_RING_ID_MASK 0xFFFF
108
109#define DB_MCCQ_NUM_POSTED_SHIFT 16
110
111
112#define POST_STAGE_ARMFW_RDY 0xc000
113
114
115
116
117
118#define ASYNC_TRAILER_EVENT_CODE_SHIFT 8
119#define ASYNC_TRAILER_EVENT_CODE_MASK 0xFF
120#define ASYNC_EVENT_CODE_LINK_STATE 0x1
121#define ASYNC_EVENT_CODE_ISCSI 0x4
122
123#define ASYNC_TRAILER_EVENT_TYPE_SHIFT 16
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
129struct be_async_event_trailer {
130 u32 code;
131};
132
133enum {
134 ASYNC_EVENT_LINK_DOWN = 0x0,
135 ASYNC_EVENT_LINK_UP = 0x1,
136 ASYNC_EVENT_LOGICAL = 0x2
137};
138
139
140
141
142
143struct be_async_event_link_state {
144 u8 physical_port;
145 u8 port_link_status;
146 u8 port_duplex;
147 u8 port_speed;
148#define BEISCSI_PHY_LINK_FAULT_NONE 0x00
149#define BEISCSI_PHY_LINK_FAULT_LOCAL 0x01
150#define BEISCSI_PHY_LINK_FAULT_REMOTE 0x02
151 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
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
170
171
172#define OPCODE_COMMON_CQ_CREATE 12
173#define OPCODE_COMMON_EQ_CREATE 13
174#define OPCODE_COMMON_MCC_CREATE 21
175#define OPCODE_COMMON_ADD_TEMPLATE_HEADER_BUFFERS 24
176#define OPCODE_COMMON_REMOVE_TEMPLATE_HEADER_BUFFERS 25
177#define OPCODE_COMMON_GET_CNTL_ATTRIBUTES 32
178#define OPCODE_COMMON_GET_FW_VERSION 35
179#define OPCODE_COMMON_MODIFY_EQ_DELAY 41
180#define OPCODE_COMMON_FIRMWARE_CONFIG 42
181#define OPCODE_COMMON_MCC_DESTROY 53
182#define OPCODE_COMMON_CQ_DESTROY 54
183#define OPCODE_COMMON_EQ_DESTROY 55
184#define OPCODE_COMMON_QUERY_FIRMWARE_CONFIG 58
185#define OPCODE_COMMON_FUNCTION_RESET 61
186
187
188
189
190
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
195#define OPCODE_COMMON_ISCSI_NTWK_SET_VLAN 14
196#define OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR 17
197#define OPCODE_COMMON_ISCSI_NTWK_REL_STATELESS_IP_ADDR 18
198#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
203#define OPCODE_COMMON_ISCSI_SET_FRAGNUM_BITS_FOR_SGL_CRA 61
204#define OPCODE_COMMON_ISCSI_DEFQ_CREATE 64
205#define OPCODE_COMMON_ISCSI_DEFQ_DESTROY 65
206#define OPCODE_COMMON_ISCSI_WRBQ_CREATE 66
207#define OPCODE_COMMON_ISCSI_WRBQ_DESTROY 67
208
209struct be_cmd_req_hdr {
210 u8 opcode;
211 u8 subsystem;
212 u8 port_number;
213 u8 domain;
214 u32 timeout;
215 u32 request_length;
216 u8 version;
217 u8 rsvd0[3];
218};
219
220struct be_cmd_resp_hdr {
221 u32 info;
222 u32 status;
223 u32 response_length;
224 u32 actual_resp_len;
225};
226
227struct phys_addr {
228 u32 lo;
229 u32 hi;
230};
231
232struct virt_addr {
233 u32 lo;
234 u32 hi;
235};
236
237
238
239
240
241
242
243
244struct amap_eq_context {
245 u8 cidx[13];
246 u8 rsvd0[3];
247 u8 epidx[13];
248 u8 valid;
249 u8 rsvd1;
250 u8 size;
251 u8 pidx[13];
252 u8 rsvd2[3];
253 u8 pd[10];
254 u8 count[3];
255 u8 solevent;
256 u8 stalled;
257 u8 armed;
258 u8 rsvd3[4];
259 u8 func[8];
260 u8 rsvd4;
261 u8 delaymult[10];
262 u8 rsvd5[2];
263 u8 phase[2];
264 u8 nodelay;
265 u8 rsvd6[4];
266 u8 rsvd7[32];
267} __packed;
268
269struct be_cmd_req_eq_create {
270 struct be_cmd_req_hdr hdr;
271 u16 num_pages;
272 u16 rsvd0;
273 u8 context[sizeof(struct amap_eq_context) / 8];
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;
280 u16 rsvd0;
281} __packed;
282
283struct be_set_eqd {
284 u32 eq_id;
285 u32 phase;
286 u32 delay_multiplier;
287} __packed;
288
289struct 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
307struct be_cmd_req_logout_fw_sess {
308 struct be_cmd_req_hdr hdr;
309 uint32_t session_handle;
310} __packed;
311
312struct be_cmd_resp_logout_fw_sess {
313 struct be_cmd_resp_hdr hdr;
314#define BEISCSI_MGMT_SESSION_CLOSE 0x20
315 uint32_t session_status;
316} __packed;
317
318struct 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
330struct ip_addr_format {
331 u16 size_of_structure;
332 u8 reserved;
333 u8 ip_type;
334 u8 addr[16];
335 u32 rsvd0;
336} __packed;
337
338struct mgmt_conn_info {
339 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;
346 struct ip_addr_format src_ipaddr;
347 struct ip_addr_format dest_ipaddr;
348 struct ip_addr_format dest_ipaddr_redirected;
349 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
378struct be_cmd_get_session_req {
379 struct be_cmd_req_hdr hdr;
380 u32 session_handle;
381} __packed;
382
383struct be_cmd_get_session_resp {
384 struct be_cmd_resp_hdr hdr;
385 struct mgmt_session_info session_info;
386} __packed;
387
388struct mac_addr {
389 u16 size_of_structure;
390 u8 addr[ETH_ALEN];
391} __packed;
392
393struct be_cmd_get_boot_target_req {
394 struct be_cmd_req_hdr hdr;
395} __packed;
396
397struct be_cmd_get_boot_target_resp {
398 struct be_cmd_resp_hdr hdr;
399 u32 boot_session_count;
400 int boot_session_handle;
401};
402
403struct 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
420struct be_cmd_mac_query_req {
421 struct be_cmd_req_hdr hdr;
422 u8 type;
423 u8 permanent;
424 u16 if_id;
425} __packed;
426
427struct be_cmd_get_mac_resp {
428 struct be_cmd_resp_hdr hdr;
429 struct mac_addr mac;
430};
431
432struct 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
504#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;
510
511
512
513
514
515struct amap_cq_context {
516 u8 cidx[11];
517 u8 rsvd0;
518 u8 coalescwm[2];
519 u8 nodelay;
520 u8 epidx[11];
521 u8 rsvd1;
522 u8 count[2];
523 u8 valid;
524 u8 solevent;
525 u8 eventable;
526 u8 pidx[11];
527 u8 rsvd2;
528 u8 pd[10];
529 u8 eqid[8];
530 u8 stalled;
531 u8 armed;
532 u8 rsvd3[4];
533 u8 func[8];
534 u8 rsvd4[20];
535 u8 rsvd5[32];
536} __packed;
537
538struct amap_cq_context_v2 {
539 u8 rsvd0[12];
540 u8 coalescwm[2];
541 u8 nodelay;
542 u8 rsvd1[12];
543 u8 count[2];
544 u8 valid;
545 u8 rsvd2;
546 u8 eventable;
547 u8 eqid[16];
548 u8 rsvd3[15];
549 u8 armed;
550 u8 cqecount[16];
551 u8 rsvd4[16];
552 u8 rsvd5[32];
553};
554
555struct be_cmd_req_cq_create {
556 struct be_cmd_req_hdr hdr;
557 u16 num_pages;
558 u8 page_size;
559 u8 rsvd0;
560 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
571
572
573
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
605
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;
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
644struct be_cmd_req_modify_eq_delay {
645 struct be_cmd_req_hdr hdr;
646 __le32 num_eq;
647 struct {
648 __le32 eq_id;
649 __le32 phase;
650 __le32 delay_multiplier;
651 } delay[MAX_CPUS];
652} __packed;
653
654
655
656#define ETH_ALEN 6
657
658struct be_cmd_get_nic_conf_req {
659 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
670struct be_cmd_get_nic_conf_resp {
671 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
682#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
692struct be_cmd_ntwk_link_status_req {
693 struct be_cmd_req_hdr hdr;
694 u32 rsvd0;
695} __packed;
696
697
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;
714
715int 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);
725int beiscsi_cmd_mccq_create(struct beiscsi_hba *phba,
726 struct be_queue_info *mccq,
727 struct be_queue_info *cq);
728
729int be_poll_mcc(struct be_ctrl_info *ctrl);
730int mgmt_check_supported_fw(struct be_ctrl_info *ctrl,
731 struct beiscsi_hba *phba);
732unsigned int be_cmd_get_initname(struct beiscsi_hba *phba);
733unsigned int be_cmd_get_port_speed(struct beiscsi_hba *phba);
734
735void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag);
736
737int be_cmd_modify_eq_delay(struct beiscsi_hba *phba, struct be_set_eqd *,
738 int num);
739int beiscsi_mccq_compl(struct beiscsi_hba *phba,
740 uint32_t tag, struct be_mcc_wrb **wrb,
741 struct be_dma_mem *mbx_cmd_mem);
742
743int be_cmd_fw_initialize(struct be_ctrl_info *ctrl);
744int be_cmd_fw_uninit(struct be_ctrl_info *ctrl);
745
746struct be_mcc_wrb *wrb_from_mbox(struct be_dma_mem *mbox_mem);
747struct be_mcc_wrb *wrb_from_mccq(struct beiscsi_hba *phba);
748int be_mcc_notify_wait(struct beiscsi_hba *phba);
749void 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);
755
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,
761 int entry_size, uint8_t is_header,
762 uint8_t ulp_num);
763
764int 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
769int 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
773int beiscsi_cmd_reset_function(struct beiscsi_hba *phba);
774
775int be_cmd_wrbq_create(struct be_ctrl_info *ctrl, struct be_dma_mem *q_mem,
776 struct be_queue_info *wrbq,
777 struct hwi_wrb_context *pwrb_context,
778 uint8_t ulp_num);
779
780bool is_link_state_evt(u32 trailer);
781
782
783int be_cmd_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag);
784
785struct be_default_pdu_context {
786 u32 dw[4];
787} __packed;
788
789struct amap_be_default_pdu_context {
790 u8 dbuf_cindex[13];
791 u8 rsvd0[3];
792 u8 ring_size[4];
793 u8 ring_state[4];
794 u8 rsvd1[8];
795 u8 dbuf_pindex[13];
796 u8 rsvd2;
797 u8 pci_func_id[8];
798 u8 rx_pdid[9];
799 u8 rx_pdid_valid;
800 u8 default_buffer_size[16];
801 u8 cq_id_recv[10];
802 u8 rx_pdid_not_valid;
803 u8 rsvd3[5];
804 u8 rsvd4[32];
805} __packed;
806
807struct amap_default_pdu_context_ext {
808 u8 rsvd0[16];
809 u8 ring_size[4];
810 u8 rsvd1[12];
811 u8 rsvd2[22];
812 u8 rx_pdid[9];
813 u8 rx_pdid_valid;
814 u8 default_buffer_size[16];
815 u8 cq_id_recv[16];
816 u8 rsvd3[32];
817} __packed;
818
819struct be_defq_create_req {
820 struct be_cmd_req_hdr hdr;
821 u16 num_pages;
822 u8 ulp_num;
823#define BEISCSI_DUAL_ULP_AWARE_BIT 0
824#define BEISCSI_BIND_Q_TO_ULP_BIT 1
825 u8 dua_feature;
826 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;
833 u8 rsvd0;
834 u8 ulp_num;
835 u32 doorbell_offset;
836 u16 register_set;
837 u16 doorbell_format;
838} __packed;
839
840struct 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
857struct 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;
870 u8 dua_feature;
871 struct phys_addr pages[8];
872} __packed;
873
874struct be_wrbq_create_resp {
875 struct be_cmd_resp_hdr resp_hdr;
876 u16 cid;
877 u8 rsvd0;
878 u8 ulp_num;
879 u32 doorbell_offset;
880 u16 register_set;
881 u16 doorbell_format;
882} __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];
902 u8 i_sts[8];
903 u8 i_resp[8];
904 u8 i_flags[7];
905 u8 s;
906 u8 i_exp_cmd_sn[32];
907 u8 code[6];
908 u8 cid[10];
909 u8 wrb_index[8];
910 u8 i_cmd_wnd[8];
911 u8 i_res_cnt[31];
912 u8 valid;
913} __packed;
914
915#define SOL_ICD_INDEX_MASK 0x0003FFC0
916struct amap_sol_cqe_ring {
917 u8 hw_sts[8];
918 u8 i_sts[8];
919 u8 i_resp[8];
920 u8 i_flags[7];
921 u8 s;
922 u8 i_exp_cmd_sn[32];
923 u8 code[6];
924 u8 icd_index[12];
925 u8 rsvd[6];
926 u8 i_cmd_wnd[8];
927 u8 i_res_cnt[31];
928 u8 valid;
929} __packed;
930
931struct amap_sol_cqe_v2 {
932 u8 hw_sts[8];
933 u8 i_sts[8];
934 u8 wrb_index[16];
935 u8 i_exp_cmd_sn[32];
936 u8 code[6];
937 u8 cmd_cmpl;
938 u8 rsvd0;
939 u8 i_cmd_wnd[8];
940 u8 cid[13];
941 u8 u;
942 u8 o;
943 u8 s;
944 u8 i_res_cnt[31];
945 u8 valid;
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;
956 u8 i_resp;
957 u8 i_flags;
958 u8 i_sts;
959};
960
961
962struct amap_it_dmsg_cqe {
963 u8 ack_num[32];
964 u8 pdu_bytes_rcvd[32];
965 u8 code[6];
966 u8 cid[10];
967 u8 wrb_idx[8];
968 u8 rsvd0[8];
969 u8 rsvd1[31];
970 u8 valid;
971} __packed;
972
973struct amap_it_dmsg_cqe_v2 {
974 u8 ack_num[32];
975 u8 pdu_bytes_rcvd[32];
976 u8 code[6];
977 u8 rsvd0[10];
978 u8 wrb_idx[16];
979 u8 rsvd1[16];
980 u8 cid[13];
981 u8 rsvd2[2];
982 u8 valid;
983} __packed;
984
985
986
987
988
989
990
991#define DB_WRB_POST_CID_MASK 0xFFFF
992#define DB_DEF_PDU_WRB_INDEX_MASK 0xFF
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
1022struct tcp_connect_and_offload_in {
1023 struct be_cmd_req_hdr hdr;
1024 struct ip_addr_format ip_address;
1025 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
1036struct 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
1056struct 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
1069#define DB_DEF_PDU_RING_ID_MASK 0x3FFF
1070#define DB_DEF_PDU_CQPROC_MASK 0x3FFF
1071#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 {
1096#define BEISCSI_ULP_ISCSI_INI_MODE 0x10
1097 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
1112struct be_ulp_chain_icd {
1113 u32 chain_base;
1114 u32 chain_count;
1115};
1116
1117struct be_fw_cfg {
1118 struct be_cmd_req_hdr hdr;
1119 u32 be_config_number;
1120 u32 asic_revision;
1121 u32 phys_port;
1122#define BEISCSI_FUNC_ISCSI_INI_MODE 0x10
1123#define BEISCSI_FUNC_DUA_MODE 0x800
1124 u32 function_mode;
1125 struct be_ulp_fw_cfg ulp[2];
1126 u32 function_caps;
1127 u32 cqid_base;
1128 u32 cqid_count;
1129 u32 eqid_base;
1130 u32 eqid_count;
1131 struct be_ulp_chain_icd chain_icd[2];
1132} __packed;
1133
1134struct be_cmd_get_all_if_id_req {
1135 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
1141#define OPCODE_COMMON_NTWK_LINK_STATUS_QUERY 5
1142#define OPCODE_COMMON_MODIFY_EQ_DELAY 41
1143#define OPCODE_COMMON_ISCSI_CLEANUP 59
1144#define OPCODE_COMMON_TCP_UPLOAD 56
1145#define OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD 70
1146#define OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS 1
1147#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
1150#define OPCODE_ISCSI_INI_SESSION_LOGOUT_TARGET 24
1151#define OPCODE_ISCSI_INI_DRIVER_REOPEN_ALL_SESSIONS 36
1152#define OPCODE_ISCSI_INI_DRIVER_OFFLOAD_SESSION 41
1153#define OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION 42
1154#define OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET 52
1155#define OPCODE_COMMON_WRITE_FLASH 96
1156#define OPCODE_COMMON_READ_FLASH 97
1157
1158
1159#define CMD_ISCSI_COMMAND_INVALIDATE 1
1160#define CMD_ISCSI_CONNECTION_INVALIDATE 0x8001
1161#define CMD_ISCSI_CONNECTION_ISSUE_TCP_RST 0x8002
1162
1163#define INI_WR_CMD 1
1164#define INI_TMF_CMD 2
1165#define INI_NOPOUT_CMD 3
1166#define INI_RD_CMD 5
1167
1168
1169#define TGT_CTX_UPDT_CMD 7
1170#define TGT_STS_CMD 8
1171
1172
1173
1174#define TGT_DATAIN_CMD 9
1175
1176
1177#define TGT_SOS_PDU 10
1178
1179
1180#define TGT_DM_CMD 11
1181
1182
1183
1184
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
1195
1196#define CONNECTION_UPLOAD_GRACEFUL 1
1197#define CONNECTION_UPLOAD_ABORT_RESET 2
1198
1199
1200#define CONNECTION_UPLOAD_ABORT 3
1201
1202
1203#define CONNECTION_UPLOAD_ABORT_WITH_SEQ 4
1204
1205
1206
1207#define BE_NUMBER_OF_FIELD(_type_, _field_) \
1208 (FIELD_SIZEOF(_type_, _field_)/sizeof((((_type_ *)0)->_field_[0])))\
1209
1210
1211
1212
1213
1214
1215#define SOL_CMD_COMPLETE 1
1216
1217
1218#define SOL_CMD_KILLED_DATA_DIGEST_ERR 2
1219
1220
1221
1222#define CXN_KILLED_PDU_SIZE_EXCEEDS_DSL 3
1223
1224
1225
1226
1227#define CXN_KILLED_BURST_LEN_MISMATCH 4
1228
1229
1230
1231
1232#define CXN_KILLED_AHS_RCVD 5
1233
1234
1235
1236#define CXN_KILLED_HDR_DIGEST_ERR 6
1237
1238
1239
1240#define CXN_KILLED_UNKNOWN_HDR 7
1241
1242
1243
1244
1245#define CXN_KILLED_STALE_ITT_TTT_RCVD 8
1246
1247
1248
1249
1250#define CXN_KILLED_INVALID_ITT_TTT_RCVD 9
1251
1252
1253
1254
1255#define CXN_KILLED_RST_RCVD 10
1256
1257
1258
1259#define CXN_KILLED_TIMED_OUT 11
1260
1261
1262
1263
1264#define CXN_KILLED_RST_SENT 12
1265
1266
1267
1268#define CXN_KILLED_FIN_RCVD 13
1269
1270
1271
1272#define CXN_KILLED_BAD_UNSOL_PDU_RCVD 14
1273
1274
1275
1276
1277
1278#define CXN_KILLED_BAD_WRB_INDEX_ERROR 15
1279
1280
1281
1282#define CXN_KILLED_OVER_RUN_RESIDUAL 16
1283
1284
1285
1286
1287#define CXN_KILLED_UNDER_RUN_RESIDUAL 17
1288
1289
1290
1291
1292#define CMD_KILLED_INVALID_STATSN_RCVD 18
1293
1294
1295
1296#define CMD_KILLED_INVALID_R2T_RCVD 19
1297
1298
1299
1300
1301#define CMD_CXN_KILLED_LUN_INVALID 20
1302
1303
1304
1305#define CMD_CXN_KILLED_ICD_INVALID 21
1306
1307
1308
1309
1310#define CMD_CXN_KILLED_ITT_INVALID 22
1311
1312
1313
1314#define CMD_CXN_KILLED_SEQ_OUTOFORDER 23
1315
1316
1317
1318#define CMD_CXN_KILLED_INVALID_DATASN_RCVD 24
1319
1320
1321
1322
1323#define CXN_INVALIDATE_NOTIFY 25
1324
1325
1326#define CXN_INVALIDATE_INDEX_NOTIFY 26
1327
1328
1329
1330#define CMD_INVALIDATED_NOTIFY 27
1331
1332
1333#define UNSOL_HDR_NOTIFY 28
1334#define UNSOL_DATA_NOTIFY 29
1335#define UNSOL_DATA_DIGEST_ERROR_NOTIFY 30
1336
1337
1338#define DRIVERMSG_NOTIFY 31
1339
1340
1341#define CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN 32
1342
1343
1344
1345
1346#define SOL_CMD_KILLED_DIF_ERR 33
1347
1348
1349
1350#define CXN_KILLED_SYN_RCVD 34
1351
1352
1353
1354#define CXN_KILLED_IMM_DATA_RCVD 35
1355
1356
1357
1358
1359
1360
1361int beiscsi_pci_soft_reset(struct beiscsi_hba *phba);
1362int be_chk_reset_complete(struct beiscsi_hba *phba);
1363
1364void 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
1370void be2iscsi_fail_session(struct iscsi_cls_session *cls_session);
1371#endif
1372