1
2
3
4
5
6
7
8
9 #ifndef _AIC94XX_SAS_H_
10 #define _AIC94XX_SAS_H_
11
12 #include <scsi/libsas.h>
13
14
15
16
17
18
19 #define ASD_MAX_DDBS 128
20
21 struct asd_ddb_ssp_smp_target_port {
22 u8 conn_type;
23 #define DDB_TP_CONN_TYPE 0x81
24
25 u8 conn_rate;
26 __be16 init_conn_tag;
27 u8 dest_sas_addr[8];
28
29 __le16 send_queue_head;
30 u8 sq_suspended;
31 u8 ddb_type;
32 #define DDB_TYPE_UNUSED 0xFF
33 #define DDB_TYPE_TARGET 0xFE
34 #define DDB_TYPE_INITIATOR 0xFD
35 #define DDB_TYPE_PM_PORT 0xFC
36
37 __le16 _r_a;
38 __be16 awt_def;
39
40 u8 compat_features;
41 u8 pathway_blocked_count;
42 __be16 arb_wait_time;
43 __be32 more_compat_features;
44
45 u8 conn_mask;
46 u8 flags;
47 #define CONCURRENT_CONN_SUPP 0x04
48 #define OPEN_REQUIRED 0x01
49
50 u16 _r_b;
51 __le16 exec_queue_tail;
52 __le16 send_queue_tail;
53 __le16 sister_ddb;
54
55 __le16 _r_c;
56
57 u8 max_concurrent_conn;
58 u8 num_concurrent_conn;
59 u8 num_contexts;
60
61 u8 _r_d;
62
63 __le16 active_task_count;
64
65 u8 _r_e[9];
66
67 u8 itnl_reason;
68
69 __le16 _r_f;
70
71 __le16 itnl_timeout;
72 #define ITNL_TIMEOUT_CONST 0x7D0
73
74 __le32 itnl_timestamp;
75 } __attribute__ ((packed));
76
77 struct asd_ddb_stp_sata_target_port {
78 u8 conn_type;
79 u8 conn_rate;
80 __be16 init_conn_tag;
81 u8 dest_sas_addr[8];
82
83 __le16 send_queue_head;
84 u8 sq_suspended;
85 u8 ddb_type;
86
87 __le16 _r_a;
88
89 __be16 awt_def;
90 u8 compat_features;
91 u8 pathway_blocked_count;
92 __be16 arb_wait_time;
93 __be32 more_compat_features;
94
95 u8 conn_mask;
96 u8 flags;
97 #define SATA_MULTIPORT 0x80
98 #define SUPPORTS_AFFIL 0x40
99 #define STP_AFFIL_POL 0x20
100
101 u8 _r_b;
102 u8 flags2;
103 #define STP_CL_POL_NO_TX 0x00
104 #define STP_CL_POL_BTW_CMDS 0x01
105
106 __le16 exec_queue_tail;
107 __le16 send_queue_tail;
108 __le16 sister_ddb;
109 __le16 ata_cmd_scbptr;
110 __le32 sata_tag_alloc_mask;
111 __le16 active_task_count;
112 __le16 _r_c;
113 __le32 sata_sactive;
114 u8 num_sata_tags;
115 u8 sata_status;
116 u8 sata_ending_status;
117 u8 itnl_reason;
118 __le16 ncq_data_scb_ptr;
119 __le16 itnl_timeout;
120 __le32 itnl_timestamp;
121 } __attribute__ ((packed));
122
123
124
125
126
127
128 struct asd_ddb_init_port {
129 u8 conn_type;
130 u8 conn_rate;
131 __be16 init_conn_tag;
132 u8 dest_sas_addr[8];
133 __le16 send_queue_head;
134 u8 sq_suspended;
135 u8 ddb_type;
136 __le16 _r_a;
137 __be16 awt_def;
138 u8 compat_features;
139 u8 pathway_blocked_count;
140 __be16 arb_wait_time;
141 __be32 more_compat_features;
142 u8 conn_mask;
143 u8 flags;
144 u16 _r_b;
145 __le16 exec_queue_tail;
146 __le16 send_queue_tail;
147 __le16 sister_ddb;
148 __le16 init_resp_timeout;
149 __le32 _r_c;
150 __le16 active_tasks;
151 __le16 init_list;
152 __le32 _r_d;
153 u8 max_conn_to[3];
154 u8 itnl_reason;
155 __le16 bus_inact_to;
156 __le16 itnl_to;
157 __le32 itnl_timestamp;
158 } __attribute__ ((packed));
159
160
161
162
163
164
165 struct asd_ddb_sata_tag {
166 __le16 scb_pointer[32];
167 } __attribute__ ((packed));
168
169
170
171
172
173
174
175
176
177 struct asd_ddb_sata_pm_table {
178 __le16 ddb_pointer[16];
179 __le16 _r_a[16];
180 } __attribute__ ((packed));
181
182
183
184
185 struct asd_ddb_sata_pm_port {
186 u8 _r_a[15];
187 u8 ddb_type;
188 u8 _r_b[13];
189 u8 pm_port_flags;
190 #define PM_PORT_MASK 0xF0
191 #define PM_PORT_SET 0x02
192 u8 _r_c[6];
193 __le16 sister_ddb;
194 __le16 ata_cmd_scbptr;
195 __le32 sata_tag_alloc_mask;
196 __le16 active_task_count;
197 __le16 parent_ddb;
198 __le32 sata_sactive;
199 u8 num_sata_tags;
200 u8 sata_status;
201 u8 sata_ending_status;
202 u8 _r_d[9];
203 } __attribute__ ((packed));
204
205
206
207
208
209
210 struct asd_ddb_seq_shared {
211 __le16 q_free_ddb_head;
212 __le16 q_free_ddb_tail;
213 __le16 q_free_ddb_cnt;
214 __le16 q_used_ddb_head;
215 __le16 q_used_ddb_tail;
216 __le16 shared_mem_lock;
217 __le16 smp_conn_tag;
218 __le16 est_nexus_buf_cnt;
219 __le16 est_nexus_buf_thresh;
220 u32 _r_a;
221 u8 settable_max_contexts;
222 u8 _r_b[23];
223 u8 conn_not_active;
224 u8 phy_is_up;
225 u8 _r_c[8];
226 u8 port_map_by_links[8];
227 } __attribute__ ((packed));
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243 struct sg_el {
244 __le64 bus_addr;
245 __le32 size;
246 __le16 _r;
247 u8 next_sg_offs;
248 u8 flags;
249 #define ASD_SG_EL_DS_MASK 0x30
250 #define ASD_SG_EL_DS_OCM 0x10
251 #define ASD_SG_EL_DS_HM 0x00
252 #define ASD_SG_EL_LIST_MASK 0xC0
253 #define ASD_SG_EL_LIST_EOL 0x40
254 #define ASD_SG_EL_LIST_EOS 0x80
255 } __attribute__ ((packed));
256
257
258
259
260
261
262
263
264
265
266 struct scb_header {
267 __le64 next_scb;
268 __le16 index;
269 u8 opcode;
270 } __attribute__ ((packed));
271
272
273
274 #define INITIATE_SSP_TASK 0x00
275 #define INITIATE_LONG_SSP_TASK 0x01
276 #define INITIATE_BIDIR_SSP_TASK 0x02
277 #define SCB_ABORT_TASK 0x03
278 #define INITIATE_SSP_TMF 0x04
279 #define SSP_TARG_GET_DATA 0x05
280 #define SSP_TARG_GET_DATA_GOOD 0x06
281 #define SSP_TARG_SEND_RESP 0x07
282 #define QUERY_SSP_TASK 0x08
283 #define INITIATE_ATA_TASK 0x09
284 #define INITIATE_ATAPI_TASK 0x0a
285 #define CONTROL_ATA_DEV 0x0b
286 #define INITIATE_SMP_TASK 0x0c
287 #define SMP_TARG_SEND_RESP 0x0f
288
289
290
291 #define SSP_TARG_SEND_DATA 0x40
292 #define SSP_TARG_SEND_DATA_GOOD 0x41
293
294
295
296 #define CONTROL_PHY 0x80
297 #define SEND_PRIMITIVE 0x81
298 #define INITIATE_LINK_ADM_TASK 0x82
299
300
301
302 #define EMPTY_SCB 0xc0
303 #define INITIATE_SEQ_ADM_TASK 0xc1
304 #define EST_ICL_TARG_WINDOW 0xc2
305 #define COPY_MEM 0xc3
306 #define CLEAR_NEXUS 0xc4
307 #define INITIATE_DDB_ADM_TASK 0xc6
308 #define ESTABLISH_NEXUS_ESCB 0xd0
309
310 #define LUN_SIZE 8
311
312 #define EFB_MASK 0x80
313 #define TASK_PRIO_MASK 0x78
314 #define TASK_ATTR_MASK 0x07
315
316
317
318
319 struct initiate_ssp_task {
320 u8 proto_conn_rate;
321 __le32 total_xfer_len;
322 struct ssp_frame_hdr ssp_frame;
323 struct ssp_command_iu ssp_cmd;
324 __le16 sister_scb;
325 __le16 conn_handle;
326 u8 data_dir;
327 #define DATA_DIR_NONE 0x00
328 #define DATA_DIR_IN 0x01
329 #define DATA_DIR_OUT 0x02
330 #define DATA_DIR_BYRECIPIENT 0x03
331
332 u8 _r_a;
333 u8 retry_count;
334 u8 _r_b[5];
335 struct sg_el sg_element[3];
336 } __attribute__ ((packed));
337
338
339
340
341
342
343 struct initiate_ata_task {
344 u8 proto_conn_rate;
345 __le32 total_xfer_len;
346 struct host_to_dev_fis fis;
347 __le32 data_offs;
348 u8 atapi_packet[16];
349 u8 _r_a[12];
350 __le16 sister_scb;
351 __le16 conn_handle;
352 u8 ata_flags;
353 #define CSMI_TASK 0x40
354 #define DATA_XFER_MODE_DMA 0x10
355 #define ATA_Q_TYPE_MASK 0x08
356 #define ATA_Q_TYPE_UNTAGGED 0x00
357 #define ATA_Q_TYPE_NCQ 0x08
358
359 u8 _r_b;
360 u8 retry_count;
361 u8 _r_c;
362 u8 flags;
363 #define STP_AFFIL_POLICY 0x20
364 #define SET_AFFIL_POLICY 0x10
365 #define RET_PARTIAL_SGLIST 0x02
366
367 u8 _r_d[3];
368 struct sg_el sg_element[3];
369 } __attribute__ ((packed));
370
371 struct initiate_smp_task {
372 u8 proto_conn_rate;
373 u8 _r_a[40];
374 struct sg_el smp_req;
375 __le16 sister_scb;
376 __le16 conn_handle;
377 u8 _r_c[8];
378 struct sg_el smp_resp;
379 u8 _r_d[32];
380 } __attribute__ ((packed));
381
382 struct control_phy {
383 u8 phy_id;
384 u8 sub_func;
385 #define DISABLE_PHY 0x00
386 #define ENABLE_PHY 0x01
387 #define RELEASE_SPINUP_HOLD 0x02
388 #define ENABLE_PHY_NO_SAS_OOB 0x03
389 #define ENABLE_PHY_NO_SATA_OOB 0x04
390 #define PHY_NO_OP 0x05
391 #define EXECUTE_HARD_RESET 0x81
392
393 u8 func_mask;
394 u8 speed_mask;
395 u8 hot_plug_delay;
396 u8 port_type;
397 u8 flags;
398 #define DEV_PRES_TIMER_OVERRIDE_ENABLE 0x01
399 #define DISABLE_PHY_IF_OOB_FAILS 0x02
400
401 __le32 timeout_override;
402 u8 link_reset_retries;
403 u8 _r_a[47];
404 __le16 conn_handle;
405 u8 _r_b[56];
406 } __attribute__ ((packed));
407
408 struct control_ata_dev {
409 u8 proto_conn_rate;
410 __le32 _r_a;
411 struct host_to_dev_fis fis;
412 u8 _r_b[32];
413 __le16 sister_scb;
414 __le16 conn_handle;
415 u8 ata_flags;
416 u8 _r_c[55];
417 } __attribute__ ((packed));
418
419 struct empty_scb {
420 u8 num_valid;
421 __le32 _r_a;
422 #define ASD_EDBS_PER_SCB 7
423
424 #define ASD_EDB_SIZE (24+1024+4+16)
425 struct sg_el eb[ASD_EDBS_PER_SCB];
426 #define ELEMENT_NOT_VALID 0xC0
427 } __attribute__ ((packed));
428
429 struct initiate_link_adm {
430 u8 phy_id;
431 u8 sub_func;
432 #define GET_LINK_ERROR_COUNT 0x00
433 #define RESET_LINK_ERROR_COUNT 0x01
434 #define ENABLE_NOTIFY_SPINUP_INTS 0x02
435
436 u8 _r_a[57];
437 __le16 conn_handle;
438 u8 _r_b[56];
439 } __attribute__ ((packed));
440
441 struct copy_memory {
442 u8 _r_a;
443 __le16 xfer_len;
444 __le16 _r_b;
445 __le64 src_busaddr;
446 u8 src_ds;
447 u8 _r_c[45];
448 __le16 conn_handle;
449 __le64 _r_d;
450 __le64 dest_busaddr;
451 u8 dest_ds;
452 u8 _r_e[39];
453 } __attribute__ ((packed));
454
455 struct abort_task {
456 u8 proto_conn_rate;
457 __le32 _r_a;
458 struct ssp_frame_hdr ssp_frame;
459 struct ssp_tmf_iu ssp_task;
460 __le16 sister_scb;
461 __le16 conn_handle;
462 u8 flags;
463 #define SUSPEND_DATA_TRANS 0x04
464
465 u8 _r_b;
466 u8 retry_count;
467 u8 _r_c[5];
468 __le16 index;
469 __le16 itnl_to;
470 u8 _r_d[44];
471 } __attribute__ ((packed));
472
473 struct clear_nexus {
474 u8 nexus;
475 #define NEXUS_ADAPTER 0x00
476 #define NEXUS_PORT 0x01
477 #define NEXUS_I_T 0x02
478 #define NEXUS_I_T_L 0x03
479 #define NEXUS_TAG 0x04
480 #define NEXUS_TRANS_CX 0x05
481 #define NEXUS_SATA_TAG 0x06
482 #define NEXUS_T_L 0x07
483 #define NEXUS_L 0x08
484 #define NEXUS_T_TAG 0x09
485
486 __le32 _r_a;
487 u8 flags;
488 #define SUSPEND_TX 0x80
489 #define RESUME_TX 0x40
490 #define SEND_Q 0x04
491 #define EXEC_Q 0x02
492 #define NOTINQ 0x01
493
494 u8 _r_b[3];
495 u8 conn_mask;
496 u8 _r_c[19];
497 struct ssp_tmf_iu ssp_task;
498 __le16 _r_d;
499 __le16 conn_handle;
500 __le64 _r_e;
501 __le16 index;
502 __le16 context;
503 u8 _r_f[44];
504 } __attribute__ ((packed));
505
506 struct initiate_ssp_tmf {
507 u8 proto_conn_rate;
508 __le32 _r_a;
509 struct ssp_frame_hdr ssp_frame;
510 struct ssp_tmf_iu ssp_task;
511 __le16 sister_scb;
512 __le16 conn_handle;
513 u8 flags;
514 #define OVERRIDE_ITNL_TIMER 8
515
516 u8 _r_b;
517 u8 retry_count;
518 u8 _r_c[5];
519 __le16 index;
520 __le16 itnl_to;
521 u8 _r_d[44];
522 } __attribute__ ((packed));
523
524
525
526
527 struct send_prim {
528 u8 phy_id;
529 u8 wait_transmit;
530 u8 xmit_flags;
531 #define XMTPSIZE_MASK 0xF0
532 #define XMTPSIZE_SINGLE 0x10
533 #define XMTPSIZE_REPEATED 0x20
534 #define XMTPSIZE_CONT 0x20
535 #define XMTPSIZE_TRIPLE 0x30
536 #define XMTPSIZE_REDUNDANT 0x60
537 #define XMTPSIZE_INF 0
538
539 #define XMTCONTEN 0x04
540 #define XMTPFRM 0x02
541 #define XMTPIMM 0x01
542
543 __le16 _r_a;
544 u8 prim[4];
545 u8 _r_b[50];
546 __le16 conn_handle;
547 u8 _r_c[56];
548 } __attribute__ ((packed));
549
550
551
552
553
554 struct ssp_targ_get_data {
555 u8 proto_conn_rate;
556 __le32 total_xfer_len;
557 struct ssp_frame_hdr ssp_frame;
558 struct xfer_rdy_iu xfer_rdy;
559 u8 lun[LUN_SIZE];
560 __le64 _r_a;
561 __le16 sister_scb;
562 __le16 conn_handle;
563 u8 data_dir;
564 u8 _r_b;
565 u8 retry_count;
566 u8 _r_c[5];
567 struct sg_el sg_element[3];
568 } __attribute__ ((packed));
569
570
571
572 struct scb {
573 struct scb_header header;
574 union {
575 struct initiate_ssp_task ssp_task;
576 struct initiate_ata_task ata_task;
577 struct initiate_smp_task smp_task;
578 struct control_phy control_phy;
579 struct control_ata_dev control_ata_dev;
580 struct empty_scb escb;
581 struct initiate_link_adm link_adm;
582 struct copy_memory cp_mem;
583 struct abort_task abort_task;
584 struct clear_nexus clear_nexus;
585 struct initiate_ssp_tmf ssp_tmf;
586 };
587 } __attribute__ ((packed));
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611 #define TC_NO_ERROR 0x00
612 #define TC_UNDERRUN 0x01
613 #define TC_OVERRUN 0x02
614 #define TF_OPEN_TO 0x03
615 #define TF_OPEN_REJECT 0x04
616 #define TI_BREAK 0x05
617 #define TI_PROTO_ERR 0x06
618 #define TC_SSP_RESP 0x07
619 #define TI_PHY_DOWN 0x08
620 #define TF_PHY_DOWN 0x09
621 #define TC_LINK_ADM_RESP 0x0a
622 #define TC_CSMI 0x0b
623 #define TC_ATA_RESP 0x0c
624 #define TU_PHY_DOWN 0x0d
625 #define TU_BREAK 0x0e
626 #define TI_SATA_TO 0x0f
627 #define TI_NAK 0x10
628 #define TC_CONTROL_PHY 0x11
629 #define TF_BREAK 0x12
630 #define TC_RESUME 0x13
631 #define TI_ACK_NAK_TO 0x14
632 #define TF_SMPRSP_TO 0x15
633 #define TF_SMP_XMIT_RCV_ERR 0x16
634 #define TC_PARTIAL_SG_LIST 0x17
635 #define TU_ACK_NAK_TO 0x18
636 #define TU_SATA_TO 0x19
637 #define TF_NAK_RECV 0x1a
638 #define TA_I_T_NEXUS_LOSS 0x1b
639 #define TC_ATA_R_ERR_RECV 0x1c
640 #define TF_TMF_NO_CTX 0x1d
641 #define TA_ON_REQ 0x1e
642 #define TF_TMF_NO_TAG 0x1f
643 #define TF_TMF_TAG_FREE 0x20
644 #define TF_TMF_TASK_DONE 0x21
645 #define TF_TMF_NO_CONN_HANDLE 0x22
646 #define TC_TASK_CLEARED 0x23
647 #define TI_SYNCS_RECV 0x24
648 #define TU_SYNCS_RECV 0x25
649 #define TF_IRTT_TO 0x26
650 #define TF_NO_SMP_CONN 0x27
651 #define TF_IU_SHORT 0x28
652 #define TF_DATA_OFFS_ERR 0x29
653 #define TF_INV_CONN_HANDLE 0x2a
654 #define TF_REQUESTED_N_PENDING 0x2b
655
656
657
658
659
660 #define ESCB_RECVD 0xC0
661
662
663
664
665
666 struct done_list_struct {
667 __le16 index;
668 u8 opcode;
669 u8 status_block[4];
670 u8 toggle;
671 #define DL_TOGGLE_MASK 0x01
672 } __attribute__ ((packed));
673
674
675
676 struct asd_phy {
677 struct asd_sas_phy sas_phy;
678 struct asd_phy_desc *phy_desc;
679
680 struct sas_identify_frame *identify_frame;
681 struct asd_dma_tok *id_frm_tok;
682 struct asd_port *asd_port;
683
684 u8 frame_rcvd[ASD_EDB_SIZE];
685 };
686
687
688 #define ASD_SCB_SIZE sizeof(struct scb)
689 #define ASD_DDB_SIZE sizeof(struct asd_ddb_ssp_smp_target_port)
690
691
692
693
694 #define ASD_NOTIFY_ENABLE_SPINUP 0x10
695
696
697
698
699 #define ASD_NOTIFY_TIMEOUT 2500
700
701
702
703
704 #define ASD_NOTIFY_DOWN_COUNT 0
705
706
707 #define ASD_DEV_PRESENT_TIMEOUT 0x2710
708
709 #define ASD_SATA_INTERLOCK_TIMEOUT 0
710
711
712
713
714
715 #define ASD_STP_SHUTDOWN_TIMEOUT 0x0
716
717
718 #define ASD_SRST_ASSERT_TIMEOUT 0x05
719
720
721 #define ASD_RCV_FIS_TIMEOUT 0x01D905C0
722
723 #define ASD_ONE_MILLISEC_TIMEOUT 0x03e8
724
725
726 #define ASD_TEN_MILLISEC_TIMEOUT 0x2710
727 #define ASD_COMINIT_TIMEOUT ASD_TEN_MILLISEC_TIMEOUT
728
729
730 #define ASD_SMP_RCV_TIMEOUT 0x000F4240
731
732 #endif