Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
aic94xx_sas.h
Go to the documentation of this file.
1 /*
2  * Aic94xx SAS/SATA driver SAS definitions and hardware interface header file.
3  *
4  * Copyright (C) 2005 Adaptec, Inc. All rights reserved.
5  * Copyright (C) 2005 Luben Tuikov <[email protected]>
6  *
7  * This file is licensed under GPLv2.
8  *
9  * This file is part of the aic94xx driver.
10  *
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
14  * License.
15  *
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.
20  *
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
24  *
25  */
26 
27 #ifndef _AIC94XX_SAS_H_
28 #define _AIC94XX_SAS_H_
29 
30 #include <scsi/libsas.h>
31 
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.
36  */
37 #define ASD_MAX_DDBS 128
38 
40  u8 conn_type; /* byte 0 */
41 #define DDB_TP_CONN_TYPE 0x81 /* Initiator port and addr frame type 0x01 */
42 
45  u8 dest_sas_addr[8]; /* bytes 4-11 */
46 
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
54 
57 
58  u8 compat_features; /* byte 20 */
62 
64  u8 flags; /* concurrent conn:2,2 and open:0(1) */
65 #define CONCURRENT_CONN_SUPP 0x04
66 #define OPEN_REQUIRED 0x01
67 
72 
74 
78 
80 
82 
83  u8 _r_e[9];
84 
85  u8 itnl_reason; /* I_T nexus loss reason */
86 
88 
90 #define ITNL_TIMEOUT_CONST 0x7D0 /* 2 seconds */
91 
93 } __attribute__ ((packed));
94 
96  u8 conn_type; /* byte 0 */
99  u8 dest_sas_addr[8]; /* bytes 4-11 */
100 
103  u8 ddb_type; /* DDB_TYPE_TARGET */
108  u8 compat_features; /* byte 20 */
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
135  u8 itnl_reason; /* I_T nexus loss reason */
139 } __attribute__ ((packed));
140 
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.
145  */
147  u8 conn_type; /* byte 0 */
151  __le16 send_queue_head; /* LE, byte 12 */
153  u8 ddb_type; /* DDB_TYPE_INITIATOR */
155  __be16 awt_def; /* BE */
161  u8 flags; /* == 5 */
163  __le16 exec_queue_tail; /* execution 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 */
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.
182  */
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).
194  */
198 } __attribute__ ((packed));
200 /* This struct asd_ddb_sata_pm_port, describes the SATA port multiplier
201  * port format DDB.
202  */
204  u8 _r_a[15];
206  u8 _r_b[13];
208 #define PM_PORT_MASK 0xF0
209 #define PM_PORT_SET 0x02
210  u8 _r_c[6];
220  u8 _r_d[9];
221 } __attribute__ ((packed));
222 
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.
227  */
240  u8 _r_b[23];
243  u8 _r_c[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
252  * sublist if needed.
253  *
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.
256  *
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.
260  */
261 struct sg_el {
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.
280  */
282 /* This struct scb_header, defines the SCB header format.
283  */
284 struct scb_header {
286  __le16 index; /* transaction context */
288 } __attribute__ ((packed));
290 /* SCB opcodes: Execution queue
291  */
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
306 
307 /* SCB opcodes: Send Queue
308  */
309 #define SSP_TARG_SEND_DATA 0x40
310 #define SSP_TARG_SEND_DATA_GOOD 0x41
311 
312 /* SCB opcodes: Link Queue
313  */
314 #define CONTROL_PHY 0x80
315 #define SEND_PRIMITIVE 0x81
316 #define INITIATE_LINK_ADM_TASK 0x82
317 
318 /* SCB opcodes: other
319  */
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
327 
328 #define LUN_SIZE 8
329 
330 /* See SAS spec, task IU
331  */
332 struct ssp_task_iu {
333  u8 lun[LUN_SIZE]; /* BE */
337  __be16 tag; /* BE */
338  u8 _r_c[14];
339 } __attribute__ ((packed));
341 /* See SAS spec, command IU
342  */
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
350 
352  u8 add_cdb_len; /* in dwords, since bit 0,1 are reserved */
353  union {
354  u8 cdb[16];
355  struct {
356  __le64 long_cdb_addr; /* bus address, LE */
358  u8 _r_c[3];
359  u8 eol_ds; /* eol:6,6, ds:5,4 */
360  } long_cdb; /* sequencer extension */
361  };
362 } __attribute__ ((packed));
363 
364 struct xfer_rdy_iu {
368 } __attribute__ ((packed));
370 /* ---------- SCB tasks ---------- */
372 /* This is both ssp_task and long_ssp_task
373  */
375  u8 proto_conn_rate; /* proto:6,4, conn_rate:3,0 */
377  struct ssp_frame_hdr ssp_frame;
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
386 
389  u8 _r_b[5];
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.
397  */
404  u8 _r_a[12];
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
413 
418 #define STP_AFFIL_POLICY 0x20
419 #define SET_AFFIL_POLICY 0x10
420 #define RET_PARTIAL_SGLIST 0x02
421 
422  u8 _r_d[3];
423  struct sg_el sg_element[3];
424 } __attribute__ ((packed));
425 
428  u8 _r_a[40];
429  struct sg_el smp_req;
432  u8 _r_c[8];
433  struct sg_el smp_resp;
434  u8 _r_d[32];
435 } __attribute__ ((packed));
437 struct control_phy {
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
447 
453 #define DEV_PRES_TIMER_OVERRIDE_ENABLE 0x01
454 #define DISABLE_PHY_IF_OOB_FAILS 0x02
455 
458  u8 _r_a[47];
460  u8 _r_b[56];
461 } __attribute__ ((packed));
467  u8 _r_b[32];
470  u8 ata_flags; /* 0 */
471  u8 _r_c[55];
472 } __attribute__ ((packed));
474 struct empty_scb {
477 #define ASD_EDBS_PER_SCB 7
478 /* header+data+CRC+DMA suffix data */
479 #define ASD_EDB_SIZE (24+1024+4+16)
481 #define ELEMENT_NOT_VALID 0xC0
482 } __attribute__ ((packed));
487 #define GET_LINK_ERROR_COUNT 0x00
488 #define RESET_LINK_ERROR_COUNT 0x01
489 #define ENABLE_NOTIFY_SPINUP_INTS 0x02
490 
491  u8 _r_a[57];
493  u8 _r_b[56];
494 } __attribute__ ((packed));
495 
496 struct copy_memory {
501  u8 src_ds; /* See definition of sg_el */
502  u8 _r_c[45];
506  u8 dest_ds; /* See definition of sg_el */
507  u8 _r_e[39];
508 } __attribute__ ((packed));
509 
510 struct abort_task {
513  struct ssp_frame_hdr ssp_frame;
517  u8 flags; /* ovrd_itnl_timer:3,3, suspend_data_trans:2,2 */
518 #define SUSPEND_DATA_TRANS 0x04
519 
522  u8 _r_c[5];
523  __le16 index; /* Transaction context of task to be queried */
525  u8 _r_d[44];
526 } __attribute__ ((packed));
527 
528 struct clear_nexus {
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
538 #define NEXUS_L 0x08
539 #define NEXUS_T_TAG 0x09
540 
543 #define SUSPEND_TX 0x80
544 #define RESUME_TX 0x40
545 #define SEND_Q 0x04
546 #define EXEC_Q 0x02
547 #define NOTINQ 0x01
548 
549  u8 _r_b[3];
551  u8 _r_c[19];
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 */
558  u8 _r_f[44];
559 } __attribute__ ((packed));
564  struct ssp_frame_hdr ssp_frame;
568  u8 flags; /* itnl override and suspend data tx */
569 #define OVERRIDE_ITNL_TIMER 8
573  u8 _r_c[5];
574  __le16 index; /* Transaction context of task to be queried */
576  u8 _r_d[44];
577 } __attribute__ ((packed));
579 /* Transmits an arbitrary primitive on the link.
580  * Used for NOTIFY and BROADCAST.
581  */
582 struct send_prim {
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
593 
594 #define XMTCONTEN 0x04
595 #define XMTPFRM 0x02 /* Transmit at the next frame boundary */
596 #define XMTPIMM 0x01 /* Transmit immediately */
597 
599  u8 prim[4]; /* K, D0, D1, D2 */
600  u8 _r_b[50];
602  u8 _r_c[56];
603 } __attribute__ ((packed));
604 
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
607  * target mode...
608  */
612  struct ssp_frame_hdr ssp_frame;
618  u8 data_dir; /* 01b */
621  u8 _r_c[5];
622  struct sg_el sg_element[3];
623 } __attribute__ ((packed));
624 
625 /* ---------- The actual SCB struct ---------- */
626 
627 struct scb {
629  union {
635  struct empty_scb escb;
641  };
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
649  * for the command:
650  * - no conn,
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
655  * command.
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.
664  * TO - Timeout.
665  */
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
677 #define TC_CSMI 0x0b
678 #define TC_ATA_RESP 0x0c
679 #define TU_PHY_DOWN 0x0d
680 #define TU_BREAK 0x0e
681 #define TI_SATA_TO 0x0f
682 #define TI_NAK 0x10
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
710 
711 /* 0xc1 - 0xc7: empty buffer received,
712  0xd1 - 0xd7: establish nexus empty buffer received
713 */
714 /* This is the ESCB mask */
715 #define ESCB_RECVD 0xC0
716 
717 
718 /* This struct done_list_struct defines the done list entry.
719  * All fields are LE.
720  */
722  __le16 index; /* aka transaction context */
725  u8 toggle; /* bit 0 */
726 #define DL_TOGGLE_MASK 0x01
727 } __attribute__ ((packed));
728 
729 /* ---------- PHYS ---------- */
731 struct asd_phy {
733  struct asd_phy_desc *phy_desc; /* hw profile */
734 
735  struct sas_identify_frame *identify_frame;
738 
740 };
741 
742 
743 #define ASD_SCB_SIZE sizeof(struct scb)
744 #define ASD_DDB_SIZE sizeof(struct asd_ddb_ssp_smp_target_port)
745 
746 /* Define this to 0 if you do not want NOTIFY (ENABLE SPINIP) sent.
747  * Default: 0x10 (it's a mask)
748  */
749 #define ASD_NOTIFY_ENABLE_SPINUP 0x10
750 
751 /* If enabled, set this to the interval between transmission
752  * of NOTIFY (ENABLE SPINUP). In units of 200 us.
753  */
754 #define ASD_NOTIFY_TIMEOUT 2500
755 
756 /* Initial delay after OOB, before we transmit NOTIFY (ENABLE SPINUP).
757  * If 0, transmit immediately. In milliseconds.
758  */
759 #define ASD_NOTIFY_DOWN_COUNT 0
760 
761 /* Device present timer timeout constant, 10 ms. */
762 #define ASD_DEV_PRESENT_TIMEOUT 0x2710
763 
764 #define ASD_SATA_INTERLOCK_TIMEOUT 0
765 
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).
769  */
770 #define ASD_STP_SHUTDOWN_TIMEOUT 0x0
771 
772 /* ATA soft reset timer timeout. 5 usec. */
773 #define ASD_SRST_ASSERT_TIMEOUT 0x05
774 
775 /* 31 sec */
776 #define ASD_RCV_FIS_TIMEOUT 0x01D905C0
777 
778 #define ASD_ONE_MILLISEC_TIMEOUT 0x03e8
779 
780 /* COMINIT timer */
781 #define ASD_TEN_MILLISEC_TIMEOUT 0x2710
782 #define ASD_COMINIT_TIMEOUT ASD_TEN_MILLISEC_TIMEOUT
783 
784 /* 1 sec */
785 #define ASD_SMP_RCV_TIMEOUT 0x000F4240
786 
787 #endif