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 #define EFB_MASK 0x80
331 #define TASK_PRIO_MASK 0x78
332 #define TASK_ATTR_MASK 0x07
333 /* ---------- SCB tasks ---------- */
335 /* This is both ssp_task and long_ssp_task
337 struct initiate_ssp_task
{
338 u8 proto_conn_rate
; /* proto:6,4, conn_rate:3,0 */
339 __le32 total_xfer_len
;
340 struct ssp_frame_hdr ssp_frame
;
341 struct ssp_command_iu ssp_cmd
;
342 __le16 sister_scb
; /* 0xFFFF */
343 __le16 conn_handle
; /* index to DDB for the intended target */
344 u8 data_dir
; /* :1,0 */
345 #define DATA_DIR_NONE 0x00
346 #define DATA_DIR_IN 0x01
347 #define DATA_DIR_OUT 0x02
348 #define DATA_DIR_BYRECIPIENT 0x03
353 struct sg_el sg_element
[3]; /* 2 real and 1 link */
354 } __attribute__ ((packed
));
356 /* This defines both ata_task and atapi_task.
357 * ata: C bit of FIS should be 1,
358 * atapi: C bit of FIS should be 1, and command register should be 0xA0,
359 * to indicate a packet command.
361 struct initiate_ata_task
{
363 __le32 total_xfer_len
;
364 struct host_to_dev_fis fis
;
370 u8 ata_flags
; /* CSMI:6,6, DTM:4,4, QT:3,3, data dir:1,0 */
371 #define CSMI_TASK 0x40
372 #define DATA_XFER_MODE_DMA 0x10
373 #define ATA_Q_TYPE_MASK 0x08
374 #define ATA_Q_TYPE_UNTAGGED 0x00
375 #define ATA_Q_TYPE_NCQ 0x08
381 #define STP_AFFIL_POLICY 0x20
382 #define SET_AFFIL_POLICY 0x10
383 #define RET_PARTIAL_SGLIST 0x02
386 struct sg_el sg_element
[3];
387 } __attribute__ ((packed
));
389 struct initiate_smp_task
{
392 struct sg_el smp_req
;
396 struct sg_el smp_resp
;
398 } __attribute__ ((packed
));
403 #define DISABLE_PHY 0x00
404 #define ENABLE_PHY 0x01
405 #define RELEASE_SPINUP_HOLD 0x02
406 #define ENABLE_PHY_NO_SAS_OOB 0x03
407 #define ENABLE_PHY_NO_SATA_OOB 0x04
408 #define PHY_NO_OP 0x05
409 #define EXECUTE_HARD_RESET 0x81
416 #define DEV_PRES_TIMER_OVERRIDE_ENABLE 0x01
417 #define DISABLE_PHY_IF_OOB_FAILS 0x02
419 __le32 timeout_override
;
420 u8 link_reset_retries
;
424 } __attribute__ ((packed
));
426 struct control_ata_dev
{
429 struct host_to_dev_fis fis
;
433 u8 ata_flags
; /* 0 */
435 } __attribute__ ((packed
));
440 #define ASD_EDBS_PER_SCB 7
441 /* header+data+CRC+DMA suffix data */
442 #define ASD_EDB_SIZE (24+1024+4+16)
443 struct sg_el eb
[ASD_EDBS_PER_SCB
];
444 #define ELEMENT_NOT_VALID 0xC0
445 } __attribute__ ((packed
));
447 struct initiate_link_adm
{
450 #define GET_LINK_ERROR_COUNT 0x00
451 #define RESET_LINK_ERROR_COUNT 0x01
452 #define ENABLE_NOTIFY_SPINUP_INTS 0x02
457 } __attribute__ ((packed
));
464 u8 src_ds
; /* See definition of sg_el */
469 u8 dest_ds
; /* See definition of sg_el */
471 } __attribute__ ((packed
));
476 struct ssp_frame_hdr ssp_frame
;
477 struct ssp_tmf_iu ssp_task
;
480 u8 flags
; /* ovrd_itnl_timer:3,3, suspend_data_trans:2,2 */
481 #define SUSPEND_DATA_TRANS 0x04
486 __le16 index
; /* Transaction context of task to be queried */
489 } __attribute__ ((packed
));
493 #define NEXUS_ADAPTER 0x00
494 #define NEXUS_PORT 0x01
495 #define NEXUS_I_T 0x02
496 #define NEXUS_I_T_L 0x03
497 #define NEXUS_TAG 0x04
498 #define NEXUS_TRANS_CX 0x05
499 #define NEXUS_SATA_TAG 0x06
500 #define NEXUS_T_L 0x07
502 #define NEXUS_T_TAG 0x09
506 #define SUSPEND_TX 0x80
507 #define RESUME_TX 0x40
515 struct ssp_tmf_iu ssp_task
; /* LUN and TAG */
519 __le16 index
; /* Transaction context of task to be cleared */
520 __le16 context
; /* Clear nexus context */
522 } __attribute__ ((packed
));
524 struct initiate_ssp_tmf
{
527 struct ssp_frame_hdr ssp_frame
;
528 struct ssp_tmf_iu ssp_task
;
531 u8 flags
; /* itnl override and suspend data tx */
532 #define OVERRIDE_ITNL_TIMER 8
537 __le16 index
; /* Transaction context of task to be queried */
540 } __attribute__ ((packed
));
542 /* Transmits an arbitrary primitive on the link.
543 * Used for NOTIFY and BROADCAST.
547 u8 wait_transmit
; /* :0,0 */
549 #define XMTPSIZE_MASK 0xF0
550 #define XMTPSIZE_SINGLE 0x10
551 #define XMTPSIZE_REPEATED 0x20
552 #define XMTPSIZE_CONT 0x20
553 #define XMTPSIZE_TRIPLE 0x30
554 #define XMTPSIZE_REDUNDANT 0x60
555 #define XMTPSIZE_INF 0
557 #define XMTCONTEN 0x04
558 #define XMTPFRM 0x02 /* Transmit at the next frame boundary */
559 #define XMTPIMM 0x01 /* Transmit immediately */
562 u8 prim
[4]; /* K, D0, D1, D2 */
566 } __attribute__ ((packed
));
568 /* This describes both SSP Target Get Data and SSP Target Get Data And
569 * Send Good Response SCBs. Used when the sequencer is operating in
572 struct ssp_targ_get_data
{
574 __le32 total_xfer_len
;
575 struct ssp_frame_hdr ssp_frame
;
576 struct xfer_rdy_iu xfer_rdy
;
581 u8 data_dir
; /* 01b */
585 struct sg_el sg_element
[3];
586 } __attribute__ ((packed
));
588 /* ---------- The actual SCB struct ---------- */
591 struct scb_header header
;
593 struct initiate_ssp_task ssp_task
;
594 struct initiate_ata_task ata_task
;
595 struct initiate_smp_task smp_task
;
596 struct control_phy control_phy
;
597 struct control_ata_dev control_ata_dev
;
598 struct empty_scb escb
;
599 struct initiate_link_adm link_adm
;
600 struct copy_memory cp_mem
;
601 struct abort_task abort_task
;
602 struct clear_nexus clear_nexus
;
603 struct initiate_ssp_tmf ssp_tmf
;
605 } __attribute__ ((packed
));
607 /* ---------- Done List ---------- */
608 /* The done list entry opcode field is defined below.
609 * The mnemonic encoding and meaning is as follows:
610 * TC - Task Complete, status was received and acknowledged
611 * TF - Task Failed, indicates an error prior to receiving acknowledgment
614 * - NACK or R_ERR received in response to this command,
615 * - credit blocked or not available, or in the case of SMP request,
616 * - no SMP response was received.
617 * In these four cases it is known that the target didn't receive the
619 * TI - Task Interrupted, error after the command was acknowledged. It is
620 * known that the command was received by the target.
621 * TU - Task Unacked, command was transmitted but neither ACK (R_OK) nor NAK
622 * (R_ERR) was received due to loss of signal, broken connection, loss of
623 * dword sync or other reason. The application client should send the
624 * appropriate task query.
625 * TA - Task Aborted, see TF.
626 * _RESP - The completion includes an empty buffer containing status.
629 #define TC_NO_ERROR 0x00
630 #define TC_UNDERRUN 0x01
631 #define TC_OVERRUN 0x02
632 #define TF_OPEN_TO 0x03
633 #define TF_OPEN_REJECT 0x04
634 #define TI_BREAK 0x05
635 #define TI_PROTO_ERR 0x06
636 #define TC_SSP_RESP 0x07
637 #define TI_PHY_DOWN 0x08
638 #define TF_PHY_DOWN 0x09
639 #define TC_LINK_ADM_RESP 0x0a
641 #define TC_ATA_RESP 0x0c
642 #define TU_PHY_DOWN 0x0d
643 #define TU_BREAK 0x0e
644 #define TI_SATA_TO 0x0f
646 #define TC_CONTROL_PHY 0x11
647 #define TF_BREAK 0x12
648 #define TC_RESUME 0x13
649 #define TI_ACK_NAK_TO 0x14
650 #define TF_SMPRSP_TO 0x15
651 #define TF_SMP_XMIT_RCV_ERR 0x16
652 #define TC_PARTIAL_SG_LIST 0x17
653 #define TU_ACK_NAK_TO 0x18
654 #define TU_SATA_TO 0x19
655 #define TF_NAK_RECV 0x1a
656 #define TA_I_T_NEXUS_LOSS 0x1b
657 #define TC_ATA_R_ERR_RECV 0x1c
658 #define TF_TMF_NO_CTX 0x1d
659 #define TA_ON_REQ 0x1e
660 #define TF_TMF_NO_TAG 0x1f
661 #define TF_TMF_TAG_FREE 0x20
662 #define TF_TMF_TASK_DONE 0x21
663 #define TF_TMF_NO_CONN_HANDLE 0x22
664 #define TC_TASK_CLEARED 0x23
665 #define TI_SYNCS_RECV 0x24
666 #define TU_SYNCS_RECV 0x25
667 #define TF_IRTT_TO 0x26
668 #define TF_NO_SMP_CONN 0x27
669 #define TF_IU_SHORT 0x28
670 #define TF_DATA_OFFS_ERR 0x29
671 #define TF_INV_CONN_HANDLE 0x2a
672 #define TF_REQUESTED_N_PENDING 0x2b
674 /* 0xc1 - 0xc7: empty buffer received,
675 0xd1 - 0xd7: establish nexus empty buffer received
677 /* This is the ESCB mask */
678 #define ESCB_RECVD 0xC0
681 /* This struct done_list_struct defines the done list entry.
684 struct done_list_struct
{
685 __le16 index
; /* aka transaction context */
688 u8 toggle
; /* bit 0 */
689 #define DL_TOGGLE_MASK 0x01
690 } __attribute__ ((packed
));
692 /* ---------- PHYS ---------- */
695 struct asd_sas_phy sas_phy
;
696 struct asd_phy_desc
*phy_desc
; /* hw profile */
698 struct sas_identify_frame
*identify_frame
;
699 struct asd_dma_tok
*id_frm_tok
;
700 struct asd_port
*asd_port
;
702 u8 frame_rcvd
[ASD_EDB_SIZE
];
706 #define ASD_SCB_SIZE sizeof(struct scb)
707 #define ASD_DDB_SIZE sizeof(struct asd_ddb_ssp_smp_target_port)
709 /* Define this to 0 if you do not want NOTIFY (ENABLE SPINIP) sent.
710 * Default: 0x10 (it's a mask)
712 #define ASD_NOTIFY_ENABLE_SPINUP 0x10
714 /* If enabled, set this to the interval between transmission
715 * of NOTIFY (ENABLE SPINUP). In units of 200 us.
717 #define ASD_NOTIFY_TIMEOUT 2500
719 /* Initial delay after OOB, before we transmit NOTIFY (ENABLE SPINUP).
720 * If 0, transmit immediately. In milliseconds.
722 #define ASD_NOTIFY_DOWN_COUNT 0
724 /* Device present timer timeout constant, 10 ms. */
725 #define ASD_DEV_PRESENT_TIMEOUT 0x2710
727 #define ASD_SATA_INTERLOCK_TIMEOUT 0
729 /* How long to wait before shutting down an STP connection, unless
730 * an STP target sent frame(s). 50 usec.
731 * IGNORED by the sequencer (i.e. value 0 always).
733 #define ASD_STP_SHUTDOWN_TIMEOUT 0x0
735 /* ATA soft reset timer timeout. 5 usec. */
736 #define ASD_SRST_ASSERT_TIMEOUT 0x05
739 #define ASD_RCV_FIS_TIMEOUT 0x01D905C0
741 #define ASD_ONE_MILLISEC_TIMEOUT 0x03e8
744 #define ASD_TEN_MILLISEC_TIMEOUT 0x2710
745 #define ASD_COMINIT_TIMEOUT ASD_TEN_MILLISEC_TIMEOUT
748 #define ASD_SMP_RCV_TIMEOUT 0x000F4240