2 * Aic94xx SAS/SATA driver SAS definitions and hardware interface header file.
4 * Copyright (C) 2005 Adaptec, Inc. All rights reserved.
5 * Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com>
7 * This file is licensed under GPLv2.
9 * This file is part of the aic94xx driver.
11 * The aic94xx driver is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; version 2 of the
16 * The aic94xx driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with the aic94xx driver; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 #ifndef _AIC94XX_SAS_H_
28 #define _AIC94XX_SAS_H_
30 #include <scsi/libsas.h>
32 /* ---------- DDBs ---------- */
33 /* DDBs are device descriptor blocks which describe a device in the
34 * domain that this sequencer can maintain low-level connections for
35 * us. They are be 64 bytes.
38 struct asd_ddb_ssp_smp_target_port
{
39 u8 conn_type
; /* byte 0 */
40 #define DDB_TP_CONN_TYPE 0x81 /* Initiator port and addr frame type 0x01 */
44 u8 dest_sas_addr
[8]; /* bytes 4-11 */
46 __le16 send_queue_head
;
48 u8 ddb_type
; /* DDB_TYPE_TARGET */
49 #define DDB_TYPE_UNUSED 0xFF
50 #define DDB_TYPE_TARGET 0xFE
51 #define DDB_TYPE_INITIATOR 0xFD
52 #define DDB_TYPE_PM_PORT 0xFC
57 u8 compat_features
; /* byte 20 */
58 u8 pathway_blocked_count
;
60 __be32 more_compat_features
; /* byte 24 */
63 u8 flags
; /* concurrent conn:2,2 and open:0(1) */
64 #define CONCURRENT_CONN_SUPP 0x04
65 #define OPEN_REQUIRED 0x01
68 __le16 exec_queue_tail
;
69 __le16 send_queue_tail
;
74 u8 max_concurrent_conn
;
75 u8 num_concurrent_conn
;
80 __le16 active_task_count
;
84 u8 itnl_reason
; /* I_T nexus loss reason */
89 #define ITNL_TIMEOUT_CONST 0x7D0 /* 2 seconds */
91 __le32 itnl_timestamp
;
92 } __attribute__ ((packed
));
94 struct asd_ddb_stp_sata_target_port
{
95 u8 conn_type
; /* byte 0 */
98 u8 dest_sas_addr
[8]; /* bytes 4-11 */
100 __le16 send_queue_head
;
102 u8 ddb_type
; /* DDB_TYPE_TARGET */
107 u8 compat_features
; /* byte 20 */
108 u8 pathway_blocked_count
;
109 __be16 arb_wait_time
;
110 __be32 more_compat_features
; /* byte 24 */
113 u8 flags
; /* concurrent conn:2,2 and open:0(1) */
114 #define SATA_MULTIPORT 0x80
115 #define SUPPORTS_AFFIL 0x40
116 #define STP_AFFIL_POL 0x20
119 u8 flags2
; /* STP close policy:0 */
120 #define STP_CL_POL_NO_TX 0x00
121 #define STP_CL_POL_BTW_CMDS 0x01
123 __le16 exec_queue_tail
;
124 __le16 send_queue_tail
;
126 __le16 ata_cmd_scbptr
;
127 __le32 sata_tag_alloc_mask
;
128 __le16 active_task_count
;
133 u8 sata_ending_status
;
134 u8 itnl_reason
; /* I_T nexus loss reason */
135 __le16 ncq_data_scb_ptr
;
137 __le32 itnl_timestamp
;
138 } __attribute__ ((packed
));
140 /* This struct asd_ddb_init_port, describes the device descriptor block
141 * of an initiator port (when the sequencer is operating in target mode).
142 * Bytes [0,11] and [20,27] are from the OPEN address frame.
143 * The sequencer allocates an initiator port DDB entry.
145 struct asd_ddb_init_port
{
146 u8 conn_type
; /* byte 0 */
148 __be16 init_conn_tag
; /* BE */
150 __le16 send_queue_head
; /* LE, byte 12 */
152 u8 ddb_type
; /* DDB_TYPE_INITIATOR */
154 __be16 awt_def
; /* BE */
156 u8 pathway_blocked_count
;
157 __be16 arb_wait_time
; /* BE */
158 __be32 more_compat_features
; /* BE */
162 __le16 exec_queue_tail
; /* execution queue tail */
163 __le16 send_queue_tail
;
165 __le16 init_resp_timeout
; /* initiator response timeout */
167 __le16 active_tasks
; /* active task count */
168 __le16 init_list
; /* initiator list link pointer */
170 u8 max_conn_to
[3]; /* from Conn-Disc mode page, in us, LE */
171 u8 itnl_reason
; /* I_T nexus loss reason */
172 __le16 bus_inact_to
; /* from Conn-Disc mode page, in 100 us, LE */
173 __le16 itnl_to
; /* from the Protocol Specific Port Ctrl MP */
174 __le32 itnl_timestamp
;
175 } __attribute__ ((packed
));
177 /* This struct asd_ddb_sata_tag, describes a look-up table to be used
178 * by the sequencers. SATA II, IDENTIFY DEVICE data, word 76, bit 8:
179 * NCQ support. This table is used by the sequencers to find the
180 * corresponding SCB, given a SATA II tag value.
182 struct asd_ddb_sata_tag
{
183 __le16 scb_pointer
[32];
184 } __attribute__ ((packed
));
186 /* This struct asd_ddb_sata_pm_table, describes a port number to
187 * connection handle look-up table. SATA targets attached to a port
188 * multiplier require a 4-bit port number value. There is one DDB
189 * entry of this type for each SATA port multiplier (sister DDB).
190 * Given a SATA PM port number, this table gives us the SATA PM Port
191 * DDB of the SATA port multiplier port (i.e. the SATA target
192 * discovered on the port).
194 struct asd_ddb_sata_pm_table
{
195 __le16 ddb_pointer
[16];
197 } __attribute__ ((packed
));
199 /* This struct asd_ddb_sata_pm_port, describes the SATA port multiplier
202 struct asd_ddb_sata_pm_port
{
207 #define PM_PORT_MASK 0xF0
208 #define PM_PORT_SET 0x02
211 __le16 ata_cmd_scbptr
;
212 __le32 sata_tag_alloc_mask
;
213 __le16 active_task_count
;
218 u8 sata_ending_status
;
220 } __attribute__ ((packed
));
222 /* This struct asd_ddb_seq_shared, describes a DDB shared by the
223 * central and link sequencers. port_map_by_links is indexed phy
224 * number [0,7]; each byte is a bit mask of all the phys that are in
225 * the same port as the indexed phy.
227 struct asd_ddb_seq_shared
{
228 __le16 q_free_ddb_head
;
229 __le16 q_free_ddb_tail
;
230 __le16 q_free_ddb_cnt
;
231 __le16 q_used_ddb_head
;
232 __le16 q_used_ddb_tail
;
233 __le16 shared_mem_lock
;
235 __le16 est_nexus_buf_cnt
;
236 __le16 est_nexus_buf_thresh
;
238 u8 settable_max_contexts
;
243 u8 port_map_by_links
[8];
244 } __attribute__ ((packed
));
246 /* ---------- SG Element ---------- */
248 /* This struct sg_el, describes the hardware scatter gather buffer
249 * element. All entries are little endian. In an SCB, there are 2 of
250 * this, plus one more, called a link element of this indicating a
253 * A link element has only the bus address set and the flags (DS) bit
254 * valid. The bus address points to the start of the sublist.
256 * If a sublist is needed, then that sublist should also include the 2
257 * sg_el embedded in the SCB, in which case next_sg_offset is 32,
258 * since sizeof(sg_el) = 16; EOS should be 1 and EOL 0 in this case.
266 #define ASD_SG_EL_DS_MASK 0x30
267 #define ASD_SG_EL_DS_OCM 0x10
268 #define ASD_SG_EL_DS_HM 0x00
269 #define ASD_SG_EL_LIST_MASK 0xC0
270 #define ASD_SG_EL_LIST_EOL 0x40
271 #define ASD_SG_EL_LIST_EOS 0x80
272 } __attribute__ ((packed
));
274 /* ---------- SCBs ---------- */
276 /* An SCB (sequencer control block) is comprised of a common header
277 * and a task part, for a total of 128 bytes. All fields are in LE
278 * order, unless otherwise noted.
281 /* This struct scb_header, defines the SCB header format.
285 __le16 index
; /* transaction context */
287 } __attribute__ ((packed
));
289 /* SCB opcodes: Execution queue
291 #define INITIATE_SSP_TASK 0x00
292 #define INITIATE_LONG_SSP_TASK 0x01
293 #define INITIATE_BIDIR_SSP_TASK 0x02
294 #define ABORT_TASK 0x03
295 #define INITIATE_SSP_TMF 0x04
296 #define SSP_TARG_GET_DATA 0x05
297 #define SSP_TARG_GET_DATA_GOOD 0x06
298 #define SSP_TARG_SEND_RESP 0x07
299 #define QUERY_SSP_TASK 0x08
300 #define INITIATE_ATA_TASK 0x09
301 #define INITIATE_ATAPI_TASK 0x0a
302 #define CONTROL_ATA_DEV 0x0b
303 #define INITIATE_SMP_TASK 0x0c
304 #define SMP_TARG_SEND_RESP 0x0f
306 /* SCB opcodes: Send Queue
308 #define SSP_TARG_SEND_DATA 0x40
309 #define SSP_TARG_SEND_DATA_GOOD 0x41
311 /* SCB opcodes: Link Queue
313 #define CONTROL_PHY 0x80
314 #define SEND_PRIMITIVE 0x81
315 #define INITIATE_LINK_ADM_TASK 0x82
317 /* SCB opcodes: other
319 #define EMPTY_SCB 0xc0
320 #define INITIATE_SEQ_ADM_TASK 0xc1
321 #define EST_ICL_TARG_WINDOW 0xc2
322 #define COPY_MEM 0xc3
323 #define CLEAR_NEXUS 0xc4
324 #define INITIATE_DDB_ADM_TASK 0xc6
325 #define ESTABLISH_NEXUS_ESCB 0xd0
329 /* See SAS spec, task IU
332 u8 lun
[LUN_SIZE
]; /* BE */
338 } __attribute__ ((packed
));
340 /* See SAS spec, command IU
342 struct ssp_command_iu
{
345 u8 efb_prio_attr
; /* enable first burst, task prio & attr */
346 #define EFB_MASK 0x80
347 #define TASK_PRIO_MASK 0x78
348 #define TASK_ATTR_MASK 0x07
351 u8 add_cdb_len
; /* in dwords, since bit 0,1 are reserved */
355 __le64 long_cdb_addr
; /* bus address, LE */
356 __le32 long_cdb_size
; /* LE */
358 u8 eol_ds
; /* eol:6,6, ds:5,4 */
359 } long_cdb
; /* sequencer extension */
361 } __attribute__ ((packed
));
364 __be32 requested_offset
; /* BE */
365 __be32 write_data_len
; /* BE */
367 } __attribute__ ((packed
));
369 /* ---------- SCB tasks ---------- */
371 /* This is both ssp_task and long_ssp_task
373 struct initiate_ssp_task
{
374 u8 proto_conn_rate
; /* proto:6,4, conn_rate:3,0 */
375 __le32 total_xfer_len
;
376 struct ssp_frame_hdr ssp_frame
;
377 struct ssp_command_iu ssp_cmd
;
378 __le16 sister_scb
; /* 0xFFFF */
379 __le16 conn_handle
; /* index to DDB for the intended target */
380 u8 data_dir
; /* :1,0 */
381 #define DATA_DIR_NONE 0x00
382 #define DATA_DIR_IN 0x01
383 #define DATA_DIR_OUT 0x02
384 #define DATA_DIR_BYRECIPIENT 0x03
389 struct sg_el sg_element
[3]; /* 2 real and 1 link */
390 } __attribute__ ((packed
));
392 /* This defines both ata_task and atapi_task.
393 * ata: C bit of FIS should be 1,
394 * atapi: C bit of FIS should be 1, and command register should be 0xA0,
395 * to indicate a packet command.
397 struct initiate_ata_task
{
399 __le32 total_xfer_len
;
400 struct host_to_dev_fis fis
;
406 u8 ata_flags
; /* CSMI:6,6, DTM:4,4, QT:3,3, data dir:1,0 */
407 #define CSMI_TASK 0x40
408 #define DATA_XFER_MODE_DMA 0x10
409 #define ATA_Q_TYPE_MASK 0x08
410 #define ATA_Q_TYPE_UNTAGGED 0x00
411 #define ATA_Q_TYPE_NCQ 0x08
417 #define STP_AFFIL_POLICY 0x20
418 #define SET_AFFIL_POLICY 0x10
419 #define RET_PARTIAL_SGLIST 0x02
422 struct sg_el sg_element
[3];
423 } __attribute__ ((packed
));
425 struct initiate_smp_task
{
428 struct sg_el smp_req
;
432 struct sg_el smp_resp
;
434 } __attribute__ ((packed
));
439 #define DISABLE_PHY 0x00
440 #define ENABLE_PHY 0x01
441 #define RELEASE_SPINUP_HOLD 0x02
442 #define ENABLE_PHY_NO_SAS_OOB 0x03
443 #define ENABLE_PHY_NO_SATA_OOB 0x04
444 #define PHY_NO_OP 0x05
445 #define EXECUTE_HARD_RESET 0x81
452 #define DEV_PRES_TIMER_OVERRIDE_ENABLE 0x01
453 #define DISABLE_PHY_IF_OOB_FAILS 0x02
455 __le32 timeout_override
;
456 u8 link_reset_retries
;
460 } __attribute__ ((packed
));
462 struct control_ata_dev
{
465 struct host_to_dev_fis fis
;
469 u8 ata_flags
; /* 0 */
471 } __attribute__ ((packed
));
476 #define ASD_EDBS_PER_SCB 7
477 /* header+data+CRC+DMA suffix data */
478 #define ASD_EDB_SIZE (24+1024+4+16)
479 struct sg_el eb
[ASD_EDBS_PER_SCB
];
480 #define ELEMENT_NOT_VALID 0xC0
481 } __attribute__ ((packed
));
483 struct initiate_link_adm
{
486 #define GET_LINK_ERROR_COUNT 0x00
487 #define RESET_LINK_ERROR_COUNT 0x01
488 #define ENABLE_NOTIFY_SPINUP_INTS 0x02
493 } __attribute__ ((packed
));
500 u8 src_ds
; /* See definition of sg_el */
505 u8 dest_ds
; /* See definition of sg_el */
507 } __attribute__ ((packed
));
512 struct ssp_frame_hdr ssp_frame
;
513 struct ssp_task_iu ssp_task
;
516 u8 flags
; /* ovrd_itnl_timer:3,3, suspend_data_trans:2,2 */
517 #define SUSPEND_DATA_TRANS 0x04
522 __le16 index
; /* Transaction context of task to be queried */
525 } __attribute__ ((packed
));
529 #define NEXUS_ADAPTER 0x00
530 #define NEXUS_PORT 0x01
531 #define NEXUS_I_T 0x02
532 #define NEXUS_I_T_L 0x03
533 #define NEXUS_TAG 0x04
534 #define NEXUS_TRANS_CX 0x05
535 #define NEXUS_SATA_TAG 0x06
536 #define NEXUS_T_L 0x07
538 #define NEXUS_T_TAG 0x09
542 #define SUSPEND_TX 0x80
543 #define RESUME_TX 0x40
551 struct ssp_task_iu ssp_task
; /* LUN and TAG */
555 __le16 index
; /* Transaction context of task to be cleared */
556 __le16 context
; /* Clear nexus context */
558 } __attribute__ ((packed
));
560 struct initiate_ssp_tmf
{
563 struct ssp_frame_hdr ssp_frame
;
564 struct ssp_task_iu ssp_task
;
567 u8 flags
; /* itnl override and suspend data tx */
568 #define OVERRIDE_ITNL_TIMER 8
573 __le16 index
; /* Transaction context of task to be queried */
576 } __attribute__ ((packed
));
578 /* Transmits an arbitrary primitive on the link.
579 * Used for NOTIFY and BROADCAST.
583 u8 wait_transmit
; /* :0,0 */
585 #define XMTPSIZE_MASK 0xF0
586 #define XMTPSIZE_SINGLE 0x10
587 #define XMTPSIZE_REPEATED 0x20
588 #define XMTPSIZE_CONT 0x20
589 #define XMTPSIZE_TRIPLE 0x30
590 #define XMTPSIZE_REDUNDANT 0x60
591 #define XMTPSIZE_INF 0
593 #define XMTCONTEN 0x04
594 #define XMTPFRM 0x02 /* Transmit at the next frame boundary */
595 #define XMTPIMM 0x01 /* Transmit immediately */
598 u8 prim
[4]; /* K, D0, D1, D2 */
602 } __attribute__ ((packed
));
604 /* This describes both SSP Target Get Data and SSP Target Get Data And
605 * Send Good Response SCBs. Used when the sequencer is operating in
608 struct ssp_targ_get_data
{
610 __le32 total_xfer_len
;
611 struct ssp_frame_hdr ssp_frame
;
612 struct xfer_rdy_iu xfer_rdy
;
617 u8 data_dir
; /* 01b */
621 struct sg_el sg_element
[3];
622 } __attribute__ ((packed
));
624 /* ---------- The actual SCB struct ---------- */
627 struct scb_header header
;
629 struct initiate_ssp_task ssp_task
;
630 struct initiate_ata_task ata_task
;
631 struct initiate_smp_task smp_task
;
632 struct control_phy control_phy
;
633 struct control_ata_dev control_ata_dev
;
634 struct empty_scb escb
;
635 struct initiate_link_adm link_adm
;
636 struct copy_memory cp_mem
;
637 struct abort_task abort_task
;
638 struct clear_nexus clear_nexus
;
639 struct initiate_ssp_tmf ssp_tmf
;
641 } __attribute__ ((packed
));
643 /* ---------- Done List ---------- */
644 /* The done list entry opcode field is defined below.
645 * The mnemonic encoding and meaning is as follows:
646 * TC - Task Complete, status was received and acknowledged
647 * TF - Task Failed, indicates an error prior to receiving acknowledgment
650 * - NACK or R_ERR received in response to this command,
651 * - credit blocked or not available, or in the case of SMP request,
652 * - no SMP response was received.
653 * In these four cases it is known that the target didn't receive the
655 * TI - Task Interrupted, error after the command was acknowledged. It is
656 * known that the command was received by the target.
657 * TU - Task Unacked, command was transmitted but neither ACK (R_OK) nor NAK
658 * (R_ERR) was received due to loss of signal, broken connection, loss of
659 * dword sync or other reason. The application client should send the
660 * appropriate task query.
661 * TA - Task Aborted, see TF.
662 * _RESP - The completion includes an empty buffer containing status.
665 #define TC_NO_ERROR 0x00
666 #define TC_UNDERRUN 0x01
667 #define TC_OVERRUN 0x02
668 #define TF_OPEN_TO 0x03
669 #define TF_OPEN_REJECT 0x04
670 #define TI_BREAK 0x05
671 #define TI_PROTO_ERR 0x06
672 #define TC_SSP_RESP 0x07
673 #define TI_PHY_DOWN 0x08
674 #define TF_PHY_DOWN 0x09
675 #define TC_LINK_ADM_RESP 0x0a
677 #define TC_ATA_RESP 0x0c
678 #define TU_PHY_DOWN 0x0d
679 #define TU_BREAK 0x0e
680 #define TI_SATA_TO 0x0f
682 #define TC_CONTROL_PHY 0x11
683 #define TF_BREAK 0x12
684 #define TC_RESUME 0x13
685 #define TI_ACK_NAK_TO 0x14
686 #define TF_SMPRSP_TO 0x15
687 #define TF_SMP_XMIT_RCV_ERR 0x16
688 #define TC_PARTIAL_SG_LIST 0x17
689 #define TU_ACK_NAK_TO 0x18
690 #define TU_SATA_TO 0x19
691 #define TF_NAK_RECV 0x1a
692 #define TA_I_T_NEXUS_LOSS 0x1b
693 #define TC_ATA_R_ERR_RECV 0x1c
694 #define TF_TMF_NO_CTX 0x1d
695 #define TA_ON_REQ 0x1e
696 #define TF_TMF_NO_TAG 0x1f
697 #define TF_TMF_TAG_FREE 0x20
698 #define TF_TMF_TASK_DONE 0x21
699 #define TF_TMF_NO_CONN_HANDLE 0x22
700 #define TC_TASK_CLEARED 0x23
701 #define TI_SYNCS_RECV 0x24
702 #define TU_SYNCS_RECV 0x25
703 #define TF_IRTT_TO 0x26
704 #define TF_NO_SMP_CONN 0x27
705 #define TF_IU_SHORT 0x28
706 #define TF_DATA_OFFS_ERR 0x29
707 #define TF_INV_CONN_HANDLE 0x2a
708 #define TF_REQUESTED_N_PENDING 0x2b
710 /* 0xc1 - 0xc7: empty buffer received,
711 0xd1 - 0xd7: establish nexus empty buffer received
713 /* This is the ESCB mask */
714 #define ESCB_RECVD 0xC0
717 /* This struct done_list_struct defines the done list entry.
720 struct done_list_struct
{
721 __le16 index
; /* aka transaction context */
724 u8 toggle
; /* bit 0 */
725 #define DL_TOGGLE_MASK 0x01
726 } __attribute__ ((packed
));
728 /* ---------- PHYS ---------- */
731 struct asd_sas_phy sas_phy
;
732 struct asd_phy_desc
*phy_desc
; /* hw profile */
734 struct sas_identify_frame
*identify_frame
;
735 struct asd_dma_tok
*id_frm_tok
;
737 u8 frame_rcvd
[ASD_EDB_SIZE
];
741 #define ASD_SCB_SIZE sizeof(struct scb)
742 #define ASD_DDB_SIZE sizeof(struct asd_ddb_ssp_smp_target_port)
744 /* Define this to 0 if you do not want NOTIFY (ENABLE SPINIP) sent.
745 * Default: 0x10 (it's a mask)
747 #define ASD_NOTIFY_ENABLE_SPINUP 0x10
749 /* If enabled, set this to the interval between transmission
750 * of NOTIFY (ENABLE SPINUP). In units of 200 us.
752 #define ASD_NOTIFY_TIMEOUT 2500
754 /* Initial delay after OOB, before we transmit NOTIFY (ENABLE SPINUP).
755 * If 0, transmit immediately. In milliseconds.
757 #define ASD_NOTIFY_DOWN_COUNT 0
759 /* Device present timer timeout constant, 10 ms. */
760 #define ASD_DEV_PRESENT_TIMEOUT 0x2710
762 #define ASD_SATA_INTERLOCK_TIMEOUT 0
764 /* How long to wait before shutting down an STP connection, unless
765 * an STP target sent frame(s). 50 usec.
766 * IGNORED by the sequencer (i.e. value 0 always).
768 #define ASD_STP_SHUTDOWN_TIMEOUT 0x0
770 /* ATA soft reset timer timeout. 5 usec. */
771 #define ASD_SRST_ASSERT_TIMEOUT 0x05
774 #define ASD_RCV_FIS_TIMEOUT 0x01D905C0
776 #define ASD_ONE_MILLISEC_TIMEOUT 0x03e8
779 #define ASD_TEN_MILLISEC_TIMEOUT 0x2710
780 #define ASD_COMINIT_TIMEOUT ASD_TEN_MILLISEC_TIMEOUT
783 #define ASD_SMP_RCV_TIMEOUT 0x000F4240