xref: /linux/drivers/scsi/aic94xx/aic94xx_sas.h (revision e5c86679d5e864947a52fb31e45a425dea3e7fa9)
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 <luben_tuikov@adaptec.com>
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 
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 */
42 
43 	u8     conn_rate;
44 	__be16 init_conn_tag;
45 	u8     dest_sas_addr[8];  /* bytes 4-11 */
46 
47 	__le16 send_queue_head;
48 	u8     sq_suspended;
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 
55 	__le16 _r_a;
56 	__be16 awt_def;
57 
58 	u8     compat_features;	  /* byte 20 */
59 	u8     pathway_blocked_count;
60 	__be16 arb_wait_time;
61 	__be32 more_compat_features; /* byte 24 */
62 
63 	u8     conn_mask;
64 	u8     flags;	  /* concurrent conn:2,2 and open:0(1) */
65 #define CONCURRENT_CONN_SUPP 0x04
66 #define OPEN_REQUIRED        0x01
67 
68 	u16    _r_b;
69 	__le16 exec_queue_tail;
70 	__le16 send_queue_tail;
71 	__le16 sister_ddb;
72 
73 	__le16 _r_c;
74 
75 	u8     max_concurrent_conn;
76 	u8     num_concurrent_conn;
77 	u8     num_contexts;
78 
79 	u8     _r_d;
80 
81 	__le16 active_task_count;
82 
83 	u8     _r_e[9];
84 
85 	u8     itnl_reason;	  /* I_T nexus loss reason */
86 
87 	__le16 _r_f;
88 
89 	__le16 itnl_timeout;
90 #define ITNL_TIMEOUT_CONST 0x7D0 /* 2 seconds */
91 
92 	__le32 itnl_timestamp;
93 } __attribute__ ((packed));
94 
95 struct asd_ddb_stp_sata_target_port {
96 	u8     conn_type;	  /* byte 0 */
97 	u8     conn_rate;
98 	__be16 init_conn_tag;
99 	u8     dest_sas_addr[8];  /* bytes 4-11 */
100 
101 	__le16 send_queue_head;
102 	u8     sq_suspended;
103 	u8     ddb_type;	  /* DDB_TYPE_TARGET */
104 
105 	__le16 _r_a;
106 
107 	__be16 awt_def;
108 	u8     compat_features;	  /* byte 20 */
109 	u8     pathway_blocked_count;
110 	__be16 arb_wait_time;
111 	__be32 more_compat_features; /* byte 24 */
112 
113 	u8     conn_mask;
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
118 
119 	u8     _r_b;
120 	u8     flags2;		  /* STP close policy:0 */
121 #define STP_CL_POL_NO_TX    0x00
122 #define STP_CL_POL_BTW_CMDS 0x01
123 
124 	__le16 exec_queue_tail;
125 	__le16 send_queue_tail;
126 	__le16 sister_ddb;
127 	__le16 ata_cmd_scbptr;
128 	__le32 sata_tag_alloc_mask;
129 	__le16 active_task_count;
130 	__le16 _r_c;
131 	__le32 sata_sactive;
132 	u8     num_sata_tags;
133 	u8     sata_status;
134 	u8     sata_ending_status;
135 	u8     itnl_reason;	  /* I_T nexus loss reason */
136 	__le16 ncq_data_scb_ptr;
137 	__le16 itnl_timeout;
138 	__le32 itnl_timestamp;
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  */
146 struct asd_ddb_init_port {
147 	u8     conn_type;	  /* byte 0 */
148 	u8     conn_rate;
149 	__be16 init_conn_tag;     /* BE */
150 	u8     dest_sas_addr[8];
151 	__le16 send_queue_head;   /* LE, byte 12 */
152 	u8     sq_suspended;
153 	u8     ddb_type;	  /* DDB_TYPE_INITIATOR */
154 	__le16 _r_a;
155 	__be16 awt_def;		  /* BE */
156 	u8     compat_features;
157 	u8     pathway_blocked_count;
158 	__be16 arb_wait_time;	  /* BE */
159 	__be32 more_compat_features; /* BE */
160 	u8     conn_mask;
161 	u8     flags;		  /* == 5 */
162 	u16    _r_b;
163 	__le16 exec_queue_tail;	  /* execution queue tail */
164 	__le16 send_queue_tail;
165 	__le16 sister_ddb;
166 	__le16 init_resp_timeout; /* initiator response timeout */
167 	__le32 _r_c;
168 	__le16 active_tasks;	  /* active task count */
169 	__le16 init_list;	  /* initiator list link pointer */
170 	__le32 _r_d;
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));
177 
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  */
183 struct asd_ddb_sata_tag {
184 	__le16 scb_pointer[32];
185 } __attribute__ ((packed));
186 
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  */
195 struct asd_ddb_sata_pm_table {
196 	__le16 ddb_pointer[16];
197 	__le16 _r_a[16];
198 } __attribute__ ((packed));
199 
200 /* This struct asd_ddb_sata_pm_port, describes the SATA port multiplier
201  * port format DDB.
202  */
203 struct asd_ddb_sata_pm_port {
204 	u8     _r_a[15];
205 	u8     ddb_type;
206 	u8     _r_b[13];
207 	u8     pm_port_flags;
208 #define PM_PORT_MASK  0xF0
209 #define PM_PORT_SET   0x02
210 	u8     _r_c[6];
211 	__le16 sister_ddb;
212 	__le16 ata_cmd_scbptr;
213 	__le32 sata_tag_alloc_mask;
214 	__le16 active_task_count;
215 	__le16 parent_ddb;
216 	__le32 sata_sactive;
217 	u8     num_sata_tags;
218 	u8     sata_status;
219 	u8     sata_ending_status;
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  */
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;
235 	__le16 smp_conn_tag;
236 	__le16 est_nexus_buf_cnt;
237 	__le16 est_nexus_buf_thresh;
238 	u32    _r_a;
239 	u8     settable_max_contexts;
240 	u8     _r_b[23];
241 	u8     conn_not_active;
242 	u8     phy_is_up;
243 	u8     _r_c[8];
244 	u8     port_map_by_links[8];
245 } __attribute__ ((packed));
246 
247 /* ---------- SG Element ---------- */
248 
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 {
262 	__le64 bus_addr;
263 	__le32 size;
264 	__le16 _r;
265 	u8     next_sg_offs;
266 	u8     flags;
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));
274 
275 /* ---------- SCBs ---------- */
276 
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  */
281 
282 /* This struct scb_header, defines the SCB header format.
283  */
284 struct scb_header {
285 	__le64 next_scb;
286 	__le16 index;		  /* transaction context */
287 	u8     opcode;
288 } __attribute__ ((packed));
289 
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 #define EFB_MASK                0x80
331 #define TASK_PRIO_MASK          0x78
332 #define TASK_ATTR_MASK          0x07
333 /* ---------- SCB tasks ---------- */
334 
335 /* This is both ssp_task and long_ssp_task
336  */
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
349 
350 	u8     _r_a;
351 	u8     retry_count;
352 	u8     _r_b[5];
353 	struct sg_el sg_element[3]; /* 2 real and 1 link */
354 } __attribute__ ((packed));
355 
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.
360  */
361 struct initiate_ata_task {
362 	u8     proto_conn_rate;
363 	__le32 total_xfer_len;
364 	struct host_to_dev_fis fis;
365 	__le32 data_offs;
366 	u8     atapi_packet[16];
367 	u8     _r_a[12];
368 	__le16 sister_scb;
369 	__le16 conn_handle;
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
376 
377 	u8     _r_b;
378 	u8     retry_count;
379 	u8     _r_c;
380 	u8     flags;
381 #define STP_AFFIL_POLICY   0x20
382 #define SET_AFFIL_POLICY   0x10
383 #define RET_PARTIAL_SGLIST 0x02
384 
385 	u8     _r_d[3];
386 	struct sg_el sg_element[3];
387 } __attribute__ ((packed));
388 
389 struct initiate_smp_task {
390 	u8     proto_conn_rate;
391 	u8     _r_a[40];
392 	struct sg_el smp_req;
393 	__le16 sister_scb;
394 	__le16 conn_handle;
395 	u8     _r_c[8];
396 	struct sg_el smp_resp;
397 	u8     _r_d[32];
398 } __attribute__ ((packed));
399 
400 struct control_phy {
401 	u8     phy_id;
402 	u8     sub_func;
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
410 
411 	u8     func_mask;
412 	u8     speed_mask;
413 	u8     hot_plug_delay;
414 	u8     port_type;
415 	u8     flags;
416 #define DEV_PRES_TIMER_OVERRIDE_ENABLE 0x01
417 #define DISABLE_PHY_IF_OOB_FAILS       0x02
418 
419 	__le32 timeout_override;
420 	u8     link_reset_retries;
421 	u8     _r_a[47];
422 	__le16 conn_handle;
423 	u8     _r_b[56];
424 } __attribute__ ((packed));
425 
426 struct control_ata_dev {
427 	u8     proto_conn_rate;
428 	__le32 _r_a;
429 	struct host_to_dev_fis fis;
430 	u8     _r_b[32];
431 	__le16 sister_scb;
432 	__le16 conn_handle;
433 	u8     ata_flags;	  /* 0 */
434 	u8     _r_c[55];
435 } __attribute__ ((packed));
436 
437 struct empty_scb {
438 	u8     num_valid;
439 	__le32 _r_a;
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));
446 
447 struct initiate_link_adm {
448 	u8     phy_id;
449 	u8     sub_func;
450 #define GET_LINK_ERROR_COUNT      0x00
451 #define RESET_LINK_ERROR_COUNT    0x01
452 #define ENABLE_NOTIFY_SPINUP_INTS 0x02
453 
454 	u8     _r_a[57];
455 	__le16 conn_handle;
456 	u8     _r_b[56];
457 } __attribute__ ((packed));
458 
459 struct copy_memory {
460 	u8     _r_a;
461 	__le16 xfer_len;
462 	__le16 _r_b;
463 	__le64 src_busaddr;
464 	u8     src_ds;		  /* See definition of sg_el */
465 	u8     _r_c[45];
466 	__le16 conn_handle;
467 	__le64 _r_d;
468 	__le64 dest_busaddr;
469 	u8     dest_ds;		  /* See definition of sg_el */
470 	u8     _r_e[39];
471 } __attribute__ ((packed));
472 
473 struct abort_task {
474 	u8     proto_conn_rate;
475 	__le32 _r_a;
476 	struct ssp_frame_hdr ssp_frame;
477 	struct ssp_tmf_iu ssp_task;
478 	__le16 sister_scb;
479 	__le16 conn_handle;
480 	u8     flags;	  /* ovrd_itnl_timer:3,3, suspend_data_trans:2,2 */
481 #define SUSPEND_DATA_TRANS 0x04
482 
483 	u8     _r_b;
484 	u8     retry_count;
485 	u8     _r_c[5];
486 	__le16 index;  /* Transaction context of task to be queried */
487 	__le16 itnl_to;
488 	u8     _r_d[44];
489 } __attribute__ ((packed));
490 
491 struct clear_nexus {
492 	u8     nexus;
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
501 #define NEXUS_L        0x08
502 #define NEXUS_T_TAG    0x09
503 
504 	__le32 _r_a;
505 	u8     flags;
506 #define SUSPEND_TX     0x80
507 #define RESUME_TX      0x40
508 #define SEND_Q         0x04
509 #define EXEC_Q         0x02
510 #define NOTINQ         0x01
511 
512 	u8     _r_b[3];
513 	u8     conn_mask;
514 	u8     _r_c[19];
515 	struct ssp_tmf_iu ssp_task; /* LUN and TAG */
516 	__le16 _r_d;
517 	__le16 conn_handle;
518 	__le64 _r_e;
519 	__le16 index;  /* Transaction context of task to be cleared */
520 	__le16 context;		  /* Clear nexus context */
521 	u8     _r_f[44];
522 } __attribute__ ((packed));
523 
524 struct initiate_ssp_tmf {
525 	u8     proto_conn_rate;
526 	__le32 _r_a;
527 	struct ssp_frame_hdr ssp_frame;
528 	struct ssp_tmf_iu ssp_task;
529 	__le16 sister_scb;
530 	__le16 conn_handle;
531 	u8     flags;	  /* itnl override and suspend data tx */
532 #define OVERRIDE_ITNL_TIMER  8
533 
534 	u8     _r_b;
535 	u8     retry_count;
536 	u8     _r_c[5];
537 	__le16 index;  /* Transaction context of task to be queried */
538 	__le16 itnl_to;
539 	u8     _r_d[44];
540 } __attribute__ ((packed));
541 
542 /* Transmits an arbitrary primitive on the link.
543  * Used for NOTIFY and BROADCAST.
544  */
545 struct send_prim {
546 	u8     phy_id;
547 	u8     wait_transmit; 	  /* :0,0 */
548 	u8     xmit_flags;
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
556 
557 #define XMTCONTEN          0x04
558 #define XMTPFRM            0x02	  /* Transmit at the next frame boundary */
559 #define XMTPIMM            0x01	  /* Transmit immediately */
560 
561 	__le16 _r_a;
562 	u8     prim[4];		  /* K, D0, D1, D2 */
563 	u8     _r_b[50];
564 	__le16 conn_handle;
565 	u8     _r_c[56];
566 } __attribute__ ((packed));
567 
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
570  * target mode...
571  */
572 struct ssp_targ_get_data {
573 	u8     proto_conn_rate;
574 	__le32 total_xfer_len;
575 	struct ssp_frame_hdr ssp_frame;
576 	struct xfer_rdy_iu  xfer_rdy;
577 	u8     lun[LUN_SIZE];
578 	__le64 _r_a;
579 	__le16 sister_scb;
580 	__le16 conn_handle;
581 	u8     data_dir;	  /* 01b */
582 	u8     _r_b;
583 	u8     retry_count;
584 	u8     _r_c[5];
585 	struct sg_el sg_element[3];
586 } __attribute__ ((packed));
587 
588 /* ---------- The actual SCB struct ---------- */
589 
590 struct scb {
591 	struct scb_header header;
592 	union {
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;
604 	};
605 } __attribute__ ((packed));
606 
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
612  *   for the command:
613  *   - no conn,
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
618  *   command.
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.
627  * TO - Timeout.
628  */
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
640 #define TC_CSMI                 0x0b
641 #define TC_ATA_RESP             0x0c
642 #define TU_PHY_DOWN             0x0d
643 #define TU_BREAK                0x0e
644 #define TI_SATA_TO              0x0f
645 #define TI_NAK                  0x10
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
673 
674 /* 0xc1 - 0xc7: empty buffer received,
675    0xd1 - 0xd7: establish nexus empty buffer received
676 */
677 /* This is the ESCB mask */
678 #define ESCB_RECVD              0xC0
679 
680 
681 /* This struct done_list_struct defines the done list entry.
682  * All fields are LE.
683  */
684 struct done_list_struct {
685 	__le16 index;		  /* aka transaction context */
686 	u8     opcode;
687 	u8     status_block[4];
688 	u8     toggle;		  /* bit 0 */
689 #define DL_TOGGLE_MASK     0x01
690 } __attribute__ ((packed));
691 
692 /* ---------- PHYS ---------- */
693 
694 struct asd_phy {
695 	struct asd_sas_phy        sas_phy;
696 	struct asd_phy_desc   *phy_desc; /* hw profile */
697 
698 	struct sas_identify_frame *identify_frame;
699 	struct asd_dma_tok  *id_frm_tok;
700 	struct asd_port     *asd_port;
701 
702 	u8         frame_rcvd[ASD_EDB_SIZE];
703 };
704 
705 
706 #define ASD_SCB_SIZE sizeof(struct scb)
707 #define ASD_DDB_SIZE sizeof(struct asd_ddb_ssp_smp_target_port)
708 
709 /* Define this to 0 if you do not want NOTIFY (ENABLE SPINIP) sent.
710  * Default: 0x10 (it's a mask)
711  */
712 #define ASD_NOTIFY_ENABLE_SPINUP  0x10
713 
714 /* If enabled, set this to the interval between transmission
715  * of NOTIFY (ENABLE SPINUP). In units of 200 us.
716  */
717 #define ASD_NOTIFY_TIMEOUT        2500
718 
719 /* Initial delay after OOB, before we transmit NOTIFY (ENABLE SPINUP).
720  * If 0, transmit immediately. In milliseconds.
721  */
722 #define ASD_NOTIFY_DOWN_COUNT     0
723 
724 /* Device present timer timeout constant, 10 ms. */
725 #define ASD_DEV_PRESENT_TIMEOUT   0x2710
726 
727 #define ASD_SATA_INTERLOCK_TIMEOUT 0
728 
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).
732  */
733 #define ASD_STP_SHUTDOWN_TIMEOUT  0x0
734 
735 /* ATA soft reset timer timeout. 5 usec. */
736 #define ASD_SRST_ASSERT_TIMEOUT   0x05
737 
738 /* 31 sec */
739 #define ASD_RCV_FIS_TIMEOUT       0x01D905C0
740 
741 #define ASD_ONE_MILLISEC_TIMEOUT  0x03e8
742 
743 /* COMINIT timer */
744 #define ASD_TEN_MILLISEC_TIMEOUT  0x2710
745 #define ASD_COMINIT_TIMEOUT ASD_TEN_MILLISEC_TIMEOUT
746 
747 /* 1 sec */
748 #define ASD_SMP_RCV_TIMEOUT       0x000F4240
749 
750 #endif
751