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.
37 #define ASD_MAX_DDBS 128
39 struct asd_ddb_ssp_smp_target_port
{
40 u8 conn_type
; /* byte 0 */
41 #define DDB_TP_CONN_TYPE 0x81 /* Initiator port and addr frame type 0x01 */
45 u8 dest_sas_addr
[8]; /* bytes 4-11 */
47 __le16 send_queue_head
;
49 u8 ddb_type
; /* DDB_TYPE_TARGET */
50 #define DDB_TYPE_UNUSED 0xFF
51 #define DDB_TYPE_TARGET 0xFE
52 #define DDB_TYPE_INITIATOR 0xFD
53 #define DDB_TYPE_PM_PORT 0xFC
58 u8 compat_features
; /* byte 20 */
59 u8 pathway_blocked_count
;
61 __be32 more_compat_features
; /* byte 24 */
64 u8 flags
; /* concurrent conn:2,2 and open:0(1) */
65 #define CONCURRENT_CONN_SUPP 0x04
66 #define OPEN_REQUIRED 0x01
69 __le16 exec_queue_tail
;
70 __le16 send_queue_tail
;
75 u8 max_concurrent_conn
;
76 u8 num_concurrent_conn
;
81 __le16 active_task_count
;
85 u8 itnl_reason
; /* I_T nexus loss reason */
90 #define ITNL_TIMEOUT_CONST 0x7D0 /* 2 seconds */
92 __le32 itnl_timestamp
;
93 } __attribute__ ((packed
));
95 struct asd_ddb_stp_sata_target_port
{
96 u8 conn_type
; /* byte 0 */
99 u8 dest_sas_addr
[8]; /* bytes 4-11 */
101 __le16 send_queue_head
;
103 u8 ddb_type
; /* DDB_TYPE_TARGET */
108 u8 compat_features
; /* byte 20 */
109 u8 pathway_blocked_count
;
110 __be16 arb_wait_time
;
111 __be32 more_compat_features
; /* byte 24 */
114 u8 flags
; /* concurrent conn:2,2 and open:0(1) */
115 #define SATA_MULTIPORT 0x80
116 #define SUPPORTS_AFFIL 0x40
117 #define STP_AFFIL_POL 0x20
120 u8 flags2
; /* STP close policy:0 */
121 #define STP_CL_POL_NO_TX 0x00
122 #define STP_CL_POL_BTW_CMDS 0x01
124 __le16 exec_queue_tail
;
125 __le16 send_queue_tail
;
127 __le16 ata_cmd_scbptr
;
128 __le32 sata_tag_alloc_mask
;
129 __le16 active_task_count
;
134 u8 sata_ending_status
;
135 u8 itnl_reason
; /* I_T nexus loss reason */
136 __le16 ncq_data_scb_ptr
;
138 __le32 itnl_timestamp
;
139 } __attribute__ ((packed
));
141 /* This struct asd_ddb_init_port, describes the device descriptor block
142 * of an initiator port (when the sequencer is operating in target mode).
143 * Bytes [0,11] and [20,27] are from the OPEN address frame.
144 * The sequencer allocates an initiator port DDB entry.
146 struct asd_ddb_init_port
{
147 u8 conn_type
; /* byte 0 */
149 __be16 init_conn_tag
; /* BE */
151 __le16 send_queue_head
; /* LE, byte 12 */
153 u8 ddb_type
; /* DDB_TYPE_INITIATOR */
155 __be16 awt_def
; /* BE */
157 u8 pathway_blocked_count
;
158 __be16 arb_wait_time
; /* BE */
159 __be32 more_compat_features
; /* BE */
163 __le16 exec_queue_tail
; /* execution queue tail */
164 __le16 send_queue_tail
;
166 __le16 init_resp_timeout
; /* initiator response timeout */
168 __le16 active_tasks
; /* active task count */
169 __le16 init_list
; /* initiator list link pointer */
171 u8 max_conn_to
[3]; /* from Conn-Disc mode page, in us, LE */
172 u8 itnl_reason
; /* I_T nexus loss reason */
173 __le16 bus_inact_to
; /* from Conn-Disc mode page, in 100 us, LE */
174 __le16 itnl_to
; /* from the Protocol Specific Port Ctrl MP */
175 __le32 itnl_timestamp
;
176 } __attribute__ ((packed
));
178 /* This struct asd_ddb_sata_tag, describes a look-up table to be used
179 * by the sequencers. SATA II, IDENTIFY DEVICE data, word 76, bit 8:
180 * NCQ support. This table is used by the sequencers to find the
181 * corresponding SCB, given a SATA II tag value.
183 struct asd_ddb_sata_tag
{
184 __le16 scb_pointer
[32];
185 } __attribute__ ((packed
));
187 /* This struct asd_ddb_sata_pm_table, describes a port number to
188 * connection handle look-up table. SATA targets attached to a port
189 * multiplier require a 4-bit port number value. There is one DDB
190 * entry of this type for each SATA port multiplier (sister DDB).
191 * Given a SATA PM port number, this table gives us the SATA PM Port
192 * DDB of the SATA port multiplier port (i.e. the SATA target
193 * discovered on the port).
195 struct asd_ddb_sata_pm_table
{
196 __le16 ddb_pointer
[16];
198 } __attribute__ ((packed
));
200 /* This struct asd_ddb_sata_pm_port, describes the SATA port multiplier
203 struct asd_ddb_sata_pm_port
{
208 #define PM_PORT_MASK 0xF0
209 #define PM_PORT_SET 0x02
212 __le16 ata_cmd_scbptr
;
213 __le32 sata_tag_alloc_mask
;
214 __le16 active_task_count
;
219 u8 sata_ending_status
;
221 } __attribute__ ((packed
));
223 /* This struct asd_ddb_seq_shared, describes a DDB shared by the
224 * central and link sequencers. port_map_by_links is indexed phy
225 * number [0,7]; each byte is a bit mask of all the phys that are in
226 * the same port as the indexed phy.
228 struct asd_ddb_seq_shared
{
229 __le16 q_free_ddb_head
;
230 __le16 q_free_ddb_tail
;
231 __le16 q_free_ddb_cnt
;
232 __le16 q_used_ddb_head
;
233 __le16 q_used_ddb_tail
;
234 __le16 shared_mem_lock
;
236 __le16 est_nexus_buf_cnt
;
237 __le16 est_nexus_buf_thresh
;
239 u8 settable_max_contexts
;
244 u8 port_map_by_links
[8];
245 } __attribute__ ((packed
));
247 /* ---------- SG Element ---------- */
249 /* This struct sg_el, describes the hardware scatter gather buffer
250 * element. All entries are little endian. In an SCB, there are 2 of
251 * this, plus one more, called a link element of this indicating a
254 * A link element has only the bus address set and the flags (DS) bit
255 * valid. The bus address points to the start of the sublist.
257 * If a sublist is needed, then that sublist should also include the 2
258 * sg_el embedded in the SCB, in which case next_sg_offset is 32,
259 * since sizeof(sg_el) = 16; EOS should be 1 and EOL 0 in this case.
267 #define ASD_SG_EL_DS_MASK 0x30
268 #define ASD_SG_EL_DS_OCM 0x10
269 #define ASD_SG_EL_DS_HM 0x00
270 #define ASD_SG_EL_LIST_MASK 0xC0
271 #define ASD_SG_EL_LIST_EOL 0x40
272 #define ASD_SG_EL_LIST_EOS 0x80
273 } __attribute__ ((packed
));
275 /* ---------- SCBs ---------- */
277 /* An SCB (sequencer control block) is comprised of a common header
278 * and a task part, for a total of 128 bytes. All fields are in LE
279 * order, unless otherwise noted.
282 /* This struct scb_header, defines the SCB header format.
286 __le16 index
; /* transaction context */
288 } __attribute__ ((packed
));
290 /* SCB opcodes: Execution queue
292 #define INITIATE_SSP_TASK 0x00
293 #define INITIATE_LONG_SSP_TASK 0x01
294 #define INITIATE_BIDIR_SSP_TASK 0x02
295 #define SCB_ABORT_TASK 0x03
296 #define INITIATE_SSP_TMF 0x04
297 #define SSP_TARG_GET_DATA 0x05
298 #define SSP_TARG_GET_DATA_GOOD 0x06
299 #define SSP_TARG_SEND_RESP 0x07
300 #define QUERY_SSP_TASK 0x08
301 #define INITIATE_ATA_TASK 0x09
302 #define INITIATE_ATAPI_TASK 0x0a
303 #define CONTROL_ATA_DEV 0x0b
304 #define INITIATE_SMP_TASK 0x0c
305 #define SMP_TARG_SEND_RESP 0x0f
307 /* SCB opcodes: Send Queue
309 #define SSP_TARG_SEND_DATA 0x40
310 #define SSP_TARG_SEND_DATA_GOOD 0x41
312 /* SCB opcodes: Link Queue
314 #define CONTROL_PHY 0x80
315 #define SEND_PRIMITIVE 0x81
316 #define INITIATE_LINK_ADM_TASK 0x82
318 /* SCB opcodes: other
320 #define EMPTY_SCB 0xc0
321 #define INITIATE_SEQ_ADM_TASK 0xc1
322 #define EST_ICL_TARG_WINDOW 0xc2
323 #define COPY_MEM 0xc3
324 #define CLEAR_NEXUS 0xc4
325 #define INITIATE_DDB_ADM_TASK 0xc6
326 #define ESTABLISH_NEXUS_ESCB 0xd0
330 /* See SAS spec, task IU
333 u8 lun
[LUN_SIZE
]; /* BE */
339 } __attribute__ ((packed
));
341 /* See SAS spec, command IU
343 struct ssp_command_iu
{
346 u8 efb_prio_attr
; /* enable first burst, task prio & attr */
347 #define EFB_MASK 0x80
348 #define TASK_PRIO_MASK 0x78
349 #define TASK_ATTR_MASK 0x07
352 u8 add_cdb_len
; /* in dwords, since bit 0,1 are reserved */
356 __le64 long_cdb_addr
; /* bus address, LE */
357 __le32 long_cdb_size
; /* LE */
359 u8 eol_ds
; /* eol:6,6, ds:5,4 */
360 } long_cdb
; /* sequencer extension */
362 } __attribute__ ((packed
));
365 __be32 requested_offset
; /* BE */
366 __be32 write_data_len
; /* BE */
368 } __attribute__ ((packed
));
370 /* ---------- SCB tasks ---------- */
372 /* This is both ssp_task and long_ssp_task
374 struct initiate_ssp_task
{
375 u8 proto_conn_rate
; /* proto:6,4, conn_rate:3,0 */
376 __le32 total_xfer_len
;
377 struct ssp_frame_hdr ssp_frame
;
378 struct ssp_command_iu ssp_cmd
;
379 __le16 sister_scb
; /* 0xFFFF */
380 __le16 conn_handle
; /* index to DDB for the intended target */
381 u8 data_dir
; /* :1,0 */
382 #define DATA_DIR_NONE 0x00
383 #define DATA_DIR_IN 0x01
384 #define DATA_DIR_OUT 0x02
385 #define DATA_DIR_BYRECIPIENT 0x03
390 struct sg_el sg_element
[3]; /* 2 real and 1 link */
391 } __attribute__ ((packed
));
393 /* This defines both ata_task and atapi_task.
394 * ata: C bit of FIS should be 1,
395 * atapi: C bit of FIS should be 1, and command register should be 0xA0,
396 * to indicate a packet command.
398 struct initiate_ata_task
{
400 __le32 total_xfer_len
;
401 struct host_to_dev_fis fis
;
407 u8 ata_flags
; /* CSMI:6,6, DTM:4,4, QT:3,3, data dir:1,0 */
408 #define CSMI_TASK 0x40
409 #define DATA_XFER_MODE_DMA 0x10
410 #define ATA_Q_TYPE_MASK 0x08
411 #define ATA_Q_TYPE_UNTAGGED 0x00
412 #define ATA_Q_TYPE_NCQ 0x08
418 #define STP_AFFIL_POLICY 0x20
419 #define SET_AFFIL_POLICY 0x10
420 #define RET_PARTIAL_SGLIST 0x02
423 struct sg_el sg_element
[3];
424 } __attribute__ ((packed
));
426 struct initiate_smp_task
{
429 struct sg_el smp_req
;
433 struct sg_el smp_resp
;
435 } __attribute__ ((packed
));
440 #define DISABLE_PHY 0x00
441 #define ENABLE_PHY 0x01
442 #define RELEASE_SPINUP_HOLD 0x02
443 #define ENABLE_PHY_NO_SAS_OOB 0x03
444 #define ENABLE_PHY_NO_SATA_OOB 0x04
445 #define PHY_NO_OP 0x05
446 #define EXECUTE_HARD_RESET 0x81
453 #define DEV_PRES_TIMER_OVERRIDE_ENABLE 0x01
454 #define DISABLE_PHY_IF_OOB_FAILS 0x02
456 __le32 timeout_override
;
457 u8 link_reset_retries
;
461 } __attribute__ ((packed
));
463 struct control_ata_dev
{
466 struct host_to_dev_fis fis
;
470 u8 ata_flags
; /* 0 */
472 } __attribute__ ((packed
));
477 #define ASD_EDBS_PER_SCB 7
478 /* header+data+CRC+DMA suffix data */
479 #define ASD_EDB_SIZE (24+1024+4+16)
480 struct sg_el eb
[ASD_EDBS_PER_SCB
];
481 #define ELEMENT_NOT_VALID 0xC0
482 } __attribute__ ((packed
));
484 struct initiate_link_adm
{
487 #define GET_LINK_ERROR_COUNT 0x00
488 #define RESET_LINK_ERROR_COUNT 0x01
489 #define ENABLE_NOTIFY_SPINUP_INTS 0x02
494 } __attribute__ ((packed
));
501 u8 src_ds
; /* See definition of sg_el */
506 u8 dest_ds
; /* See definition of sg_el */
508 } __attribute__ ((packed
));
513 struct ssp_frame_hdr ssp_frame
;
514 struct ssp_task_iu ssp_task
;
517 u8 flags
; /* ovrd_itnl_timer:3,3, suspend_data_trans:2,2 */
518 #define SUSPEND_DATA_TRANS 0x04
523 __le16 index
; /* Transaction context of task to be queried */
526 } __attribute__ ((packed
));
530 #define NEXUS_ADAPTER 0x00
531 #define NEXUS_PORT 0x01
532 #define NEXUS_I_T 0x02
533 #define NEXUS_I_T_L 0x03
534 #define NEXUS_TAG 0x04
535 #define NEXUS_TRANS_CX 0x05
536 #define NEXUS_SATA_TAG 0x06
537 #define NEXUS_T_L 0x07
539 #define NEXUS_T_TAG 0x09
543 #define SUSPEND_TX 0x80
544 #define RESUME_TX 0x40
552 struct ssp_task_iu ssp_task
; /* LUN and TAG */
556 __le16 index
; /* Transaction context of task to be cleared */
557 __le16 context
; /* Clear nexus context */
559 } __attribute__ ((packed
));
561 struct initiate_ssp_tmf
{
564 struct ssp_frame_hdr ssp_frame
;
565 struct ssp_task_iu ssp_task
;
568 u8 flags
; /* itnl override and suspend data tx */
569 #define OVERRIDE_ITNL_TIMER 8
574 __le16 index
; /* Transaction context of task to be queried */
577 } __attribute__ ((packed
));
579 /* Transmits an arbitrary primitive on the link.
580 * Used for NOTIFY and BROADCAST.
584 u8 wait_transmit
; /* :0,0 */
586 #define XMTPSIZE_MASK 0xF0
587 #define XMTPSIZE_SINGLE 0x10
588 #define XMTPSIZE_REPEATED 0x20
589 #define XMTPSIZE_CONT 0x20
590 #define XMTPSIZE_TRIPLE 0x30
591 #define XMTPSIZE_REDUNDANT 0x60
592 #define XMTPSIZE_INF 0
594 #define XMTCONTEN 0x04
595 #define XMTPFRM 0x02 /* Transmit at the next frame boundary */
596 #define XMTPIMM 0x01 /* Transmit immediately */
599 u8 prim
[4]; /* K, D0, D1, D2 */
603 } __attribute__ ((packed
));
605 /* This describes both SSP Target Get Data and SSP Target Get Data And
606 * Send Good Response SCBs. Used when the sequencer is operating in
609 struct ssp_targ_get_data
{
611 __le32 total_xfer_len
;
612 struct ssp_frame_hdr ssp_frame
;
613 struct xfer_rdy_iu xfer_rdy
;
618 u8 data_dir
; /* 01b */
622 struct sg_el sg_element
[3];
623 } __attribute__ ((packed
));
625 /* ---------- The actual SCB struct ---------- */
628 struct scb_header header
;
630 struct initiate_ssp_task ssp_task
;
631 struct initiate_ata_task ata_task
;
632 struct initiate_smp_task smp_task
;
633 struct control_phy control_phy
;
634 struct control_ata_dev control_ata_dev
;
635 struct empty_scb escb
;
636 struct initiate_link_adm link_adm
;
637 struct copy_memory cp_mem
;
638 struct abort_task abort_task
;
639 struct clear_nexus clear_nexus
;
640 struct initiate_ssp_tmf ssp_tmf
;
642 } __attribute__ ((packed
));
644 /* ---------- Done List ---------- */
645 /* The done list entry opcode field is defined below.
646 * The mnemonic encoding and meaning is as follows:
647 * TC - Task Complete, status was received and acknowledged
648 * TF - Task Failed, indicates an error prior to receiving acknowledgment
651 * - NACK or R_ERR received in response to this command,
652 * - credit blocked or not available, or in the case of SMP request,
653 * - no SMP response was received.
654 * In these four cases it is known that the target didn't receive the
656 * TI - Task Interrupted, error after the command was acknowledged. It is
657 * known that the command was received by the target.
658 * TU - Task Unacked, command was transmitted but neither ACK (R_OK) nor NAK
659 * (R_ERR) was received due to loss of signal, broken connection, loss of
660 * dword sync or other reason. The application client should send the
661 * appropriate task query.
662 * TA - Task Aborted, see TF.
663 * _RESP - The completion includes an empty buffer containing status.
666 #define TC_NO_ERROR 0x00
667 #define TC_UNDERRUN 0x01
668 #define TC_OVERRUN 0x02
669 #define TF_OPEN_TO 0x03
670 #define TF_OPEN_REJECT 0x04
671 #define TI_BREAK 0x05
672 #define TI_PROTO_ERR 0x06
673 #define TC_SSP_RESP 0x07
674 #define TI_PHY_DOWN 0x08
675 #define TF_PHY_DOWN 0x09
676 #define TC_LINK_ADM_RESP 0x0a
678 #define TC_ATA_RESP 0x0c
679 #define TU_PHY_DOWN 0x0d
680 #define TU_BREAK 0x0e
681 #define TI_SATA_TO 0x0f
683 #define TC_CONTROL_PHY 0x11
684 #define TF_BREAK 0x12
685 #define TC_RESUME 0x13
686 #define TI_ACK_NAK_TO 0x14
687 #define TF_SMPRSP_TO 0x15
688 #define TF_SMP_XMIT_RCV_ERR 0x16
689 #define TC_PARTIAL_SG_LIST 0x17
690 #define TU_ACK_NAK_TO 0x18
691 #define TU_SATA_TO 0x19
692 #define TF_NAK_RECV 0x1a
693 #define TA_I_T_NEXUS_LOSS 0x1b
694 #define TC_ATA_R_ERR_RECV 0x1c
695 #define TF_TMF_NO_CTX 0x1d
696 #define TA_ON_REQ 0x1e
697 #define TF_TMF_NO_TAG 0x1f
698 #define TF_TMF_TAG_FREE 0x20
699 #define TF_TMF_TASK_DONE 0x21
700 #define TF_TMF_NO_CONN_HANDLE 0x22
701 #define TC_TASK_CLEARED 0x23
702 #define TI_SYNCS_RECV 0x24
703 #define TU_SYNCS_RECV 0x25
704 #define TF_IRTT_TO 0x26
705 #define TF_NO_SMP_CONN 0x27
706 #define TF_IU_SHORT 0x28
707 #define TF_DATA_OFFS_ERR 0x29
708 #define TF_INV_CONN_HANDLE 0x2a
709 #define TF_REQUESTED_N_PENDING 0x2b
711 /* 0xc1 - 0xc7: empty buffer received,
712 0xd1 - 0xd7: establish nexus empty buffer received
714 /* This is the ESCB mask */
715 #define ESCB_RECVD 0xC0
718 /* This struct done_list_struct defines the done list entry.
721 struct done_list_struct
{
722 __le16 index
; /* aka transaction context */
725 u8 toggle
; /* bit 0 */
726 #define DL_TOGGLE_MASK 0x01
727 } __attribute__ ((packed
));
729 /* ---------- PHYS ---------- */
732 struct asd_sas_phy sas_phy
;
733 struct asd_phy_desc
*phy_desc
; /* hw profile */
735 struct sas_identify_frame
*identify_frame
;
736 struct asd_dma_tok
*id_frm_tok
;
737 struct asd_port
*asd_port
;
739 u8 frame_rcvd
[ASD_EDB_SIZE
];
743 #define ASD_SCB_SIZE sizeof(struct scb)
744 #define ASD_DDB_SIZE sizeof(struct asd_ddb_ssp_smp_target_port)
746 /* Define this to 0 if you do not want NOTIFY (ENABLE SPINIP) sent.
747 * Default: 0x10 (it's a mask)
749 #define ASD_NOTIFY_ENABLE_SPINUP 0x10
751 /* If enabled, set this to the interval between transmission
752 * of NOTIFY (ENABLE SPINUP). In units of 200 us.
754 #define ASD_NOTIFY_TIMEOUT 2500
756 /* Initial delay after OOB, before we transmit NOTIFY (ENABLE SPINUP).
757 * If 0, transmit immediately. In milliseconds.
759 #define ASD_NOTIFY_DOWN_COUNT 0
761 /* Device present timer timeout constant, 10 ms. */
762 #define ASD_DEV_PRESENT_TIMEOUT 0x2710
764 #define ASD_SATA_INTERLOCK_TIMEOUT 0
766 /* How long to wait before shutting down an STP connection, unless
767 * an STP target sent frame(s). 50 usec.
768 * IGNORED by the sequencer (i.e. value 0 always).
770 #define ASD_STP_SHUTDOWN_TIMEOUT 0x0
772 /* ATA soft reset timer timeout. 5 usec. */
773 #define ASD_SRST_ASSERT_TIMEOUT 0x05
776 #define ASD_RCV_FIS_TIMEOUT 0x01D905C0
778 #define ASD_ONE_MILLISEC_TIMEOUT 0x03e8
781 #define ASD_TEN_MILLISEC_TIMEOUT 0x2710
782 #define ASD_COMINIT_TIMEOUT ASD_TEN_MILLISEC_TIMEOUT
785 #define ASD_SMP_RCV_TIMEOUT 0x000F4240