aic94xx_sas.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  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. #ifndef _AIC94XX_SAS_H_
  27. #define _AIC94XX_SAS_H_
  28. #include <scsi/libsas.h>
  29. /* ---------- DDBs ---------- */
  30. /* DDBs are device descriptor blocks which describe a device in the
  31. * domain that this sequencer can maintain low-level connections for
  32. * us. They are be 64 bytes.
  33. */
  34. #define ASD_MAX_DDBS 128
  35. struct asd_ddb_ssp_smp_target_port {
  36. u8 conn_type; /* byte 0 */
  37. #define DDB_TP_CONN_TYPE 0x81 /* Initiator port and addr frame type 0x01 */
  38. u8 conn_rate;
  39. __be16 init_conn_tag;
  40. u8 dest_sas_addr[8]; /* bytes 4-11 */
  41. __le16 send_queue_head;
  42. u8 sq_suspended;
  43. u8 ddb_type; /* DDB_TYPE_TARGET */
  44. #define DDB_TYPE_UNUSED 0xFF
  45. #define DDB_TYPE_TARGET 0xFE
  46. #define DDB_TYPE_INITIATOR 0xFD
  47. #define DDB_TYPE_PM_PORT 0xFC
  48. __le16 _r_a;
  49. __be16 awt_def;
  50. u8 compat_features; /* byte 20 */
  51. u8 pathway_blocked_count;
  52. __be16 arb_wait_time;
  53. __be32 more_compat_features; /* byte 24 */
  54. u8 conn_mask;
  55. u8 flags; /* concurrent conn:2,2 and open:0(1) */
  56. #define CONCURRENT_CONN_SUPP 0x04
  57. #define OPEN_REQUIRED 0x01
  58. u16 _r_b;
  59. __le16 exec_queue_tail;
  60. __le16 send_queue_tail;
  61. __le16 sister_ddb;
  62. __le16 _r_c;
  63. u8 max_concurrent_conn;
  64. u8 num_concurrent_conn;
  65. u8 num_contexts;
  66. u8 _r_d;
  67. __le16 active_task_count;
  68. u8 _r_e[9];
  69. u8 itnl_reason; /* I_T nexus loss reason */
  70. __le16 _r_f;
  71. __le16 itnl_timeout;
  72. #define ITNL_TIMEOUT_CONST 0x7D0 /* 2 seconds */
  73. __le32 itnl_timestamp;
  74. } __attribute__ ((packed));
  75. struct asd_ddb_stp_sata_target_port {
  76. u8 conn_type; /* byte 0 */
  77. u8 conn_rate;
  78. __be16 init_conn_tag;
  79. u8 dest_sas_addr[8]; /* bytes 4-11 */
  80. __le16 send_queue_head;
  81. u8 sq_suspended;
  82. u8 ddb_type; /* DDB_TYPE_TARGET */
  83. __le16 _r_a;
  84. __be16 awt_def;
  85. u8 compat_features; /* byte 20 */
  86. u8 pathway_blocked_count;
  87. __be16 arb_wait_time;
  88. __be32 more_compat_features; /* byte 24 */
  89. u8 conn_mask;
  90. u8 flags; /* concurrent conn:2,2 and open:0(1) */
  91. #define SATA_MULTIPORT 0x80
  92. #define SUPPORTS_AFFIL 0x40
  93. #define STP_AFFIL_POL 0x20
  94. u8 _r_b;
  95. u8 flags2; /* STP close policy:0 */
  96. #define STP_CL_POL_NO_TX 0x00
  97. #define STP_CL_POL_BTW_CMDS 0x01
  98. __le16 exec_queue_tail;
  99. __le16 send_queue_tail;
  100. __le16 sister_ddb;
  101. __le16 ata_cmd_scbptr;
  102. __le32 sata_tag_alloc_mask;
  103. __le16 active_task_count;
  104. __le16 _r_c;
  105. __le32 sata_sactive;
  106. u8 num_sata_tags;
  107. u8 sata_status;
  108. u8 sata_ending_status;
  109. u8 itnl_reason; /* I_T nexus loss reason */
  110. __le16 ncq_data_scb_ptr;
  111. __le16 itnl_timeout;
  112. __le32 itnl_timestamp;
  113. } __attribute__ ((packed));
  114. /* This struct asd_ddb_init_port, describes the device descriptor block
  115. * of an initiator port (when the sequencer is operating in target mode).
  116. * Bytes [0,11] and [20,27] are from the OPEN address frame.
  117. * The sequencer allocates an initiator port DDB entry.
  118. */
  119. struct asd_ddb_init_port {
  120. u8 conn_type; /* byte 0 */
  121. u8 conn_rate;
  122. __be16 init_conn_tag; /* BE */
  123. u8 dest_sas_addr[8];
  124. __le16 send_queue_head; /* LE, byte 12 */
  125. u8 sq_suspended;
  126. u8 ddb_type; /* DDB_TYPE_INITIATOR */
  127. __le16 _r_a;
  128. __be16 awt_def; /* BE */
  129. u8 compat_features;
  130. u8 pathway_blocked_count;
  131. __be16 arb_wait_time; /* BE */
  132. __be32 more_compat_features; /* BE */
  133. u8 conn_mask;
  134. u8 flags; /* == 5 */
  135. u16 _r_b;
  136. __le16 exec_queue_tail; /* execution queue tail */
  137. __le16 send_queue_tail;
  138. __le16 sister_ddb;
  139. __le16 init_resp_timeout; /* initiator response timeout */
  140. __le32 _r_c;
  141. __le16 active_tasks; /* active task count */
  142. __le16 init_list; /* initiator list link pointer */
  143. __le32 _r_d;
  144. u8 max_conn_to[3]; /* from Conn-Disc mode page, in us, LE */
  145. u8 itnl_reason; /* I_T nexus loss reason */
  146. __le16 bus_inact_to; /* from Conn-Disc mode page, in 100 us, LE */
  147. __le16 itnl_to; /* from the Protocol Specific Port Ctrl MP */
  148. __le32 itnl_timestamp;
  149. } __attribute__ ((packed));
  150. /* This struct asd_ddb_sata_tag, describes a look-up table to be used
  151. * by the sequencers. SATA II, IDENTIFY DEVICE data, word 76, bit 8:
  152. * NCQ support. This table is used by the sequencers to find the
  153. * corresponding SCB, given a SATA II tag value.
  154. */
  155. struct asd_ddb_sata_tag {
  156. __le16 scb_pointer[32];
  157. } __attribute__ ((packed));
  158. /* This struct asd_ddb_sata_pm_table, describes a port number to
  159. * connection handle look-up table. SATA targets attached to a port
  160. * multiplier require a 4-bit port number value. There is one DDB
  161. * entry of this type for each SATA port multiplier (sister DDB).
  162. * Given a SATA PM port number, this table gives us the SATA PM Port
  163. * DDB of the SATA port multiplier port (i.e. the SATA target
  164. * discovered on the port).
  165. */
  166. struct asd_ddb_sata_pm_table {
  167. __le16 ddb_pointer[16];
  168. __le16 _r_a[16];
  169. } __attribute__ ((packed));
  170. /* This struct asd_ddb_sata_pm_port, describes the SATA port multiplier
  171. * port format DDB.
  172. */
  173. struct asd_ddb_sata_pm_port {
  174. u8 _r_a[15];
  175. u8 ddb_type;
  176. u8 _r_b[13];
  177. u8 pm_port_flags;
  178. #define PM_PORT_MASK 0xF0
  179. #define PM_PORT_SET 0x02
  180. u8 _r_c[6];
  181. __le16 sister_ddb;
  182. __le16 ata_cmd_scbptr;
  183. __le32 sata_tag_alloc_mask;
  184. __le16 active_task_count;
  185. __le16 parent_ddb;
  186. __le32 sata_sactive;
  187. u8 num_sata_tags;
  188. u8 sata_status;
  189. u8 sata_ending_status;
  190. u8 _r_d[9];
  191. } __attribute__ ((packed));
  192. /* This struct asd_ddb_seq_shared, describes a DDB shared by the
  193. * central and link sequencers. port_map_by_links is indexed phy
  194. * number [0,7]; each byte is a bit mask of all the phys that are in
  195. * the same port as the indexed phy.
  196. */
  197. struct asd_ddb_seq_shared {
  198. __le16 q_free_ddb_head;
  199. __le16 q_free_ddb_tail;
  200. __le16 q_free_ddb_cnt;
  201. __le16 q_used_ddb_head;
  202. __le16 q_used_ddb_tail;
  203. __le16 shared_mem_lock;
  204. __le16 smp_conn_tag;
  205. __le16 est_nexus_buf_cnt;
  206. __le16 est_nexus_buf_thresh;
  207. u32 _r_a;
  208. u8 settable_max_contexts;
  209. u8 _r_b[23];
  210. u8 conn_not_active;
  211. u8 phy_is_up;
  212. u8 _r_c[8];
  213. u8 port_map_by_links[8];
  214. } __attribute__ ((packed));
  215. /* ---------- SG Element ---------- */
  216. /* This struct sg_el, describes the hardware scatter gather buffer
  217. * element. All entries are little endian. In an SCB, there are 2 of
  218. * this, plus one more, called a link element of this indicating a
  219. * sublist if needed.
  220. *
  221. * A link element has only the bus address set and the flags (DS) bit
  222. * valid. The bus address points to the start of the sublist.
  223. *
  224. * If a sublist is needed, then that sublist should also include the 2
  225. * sg_el embedded in the SCB, in which case next_sg_offset is 32,
  226. * since sizeof(sg_el) = 16; EOS should be 1 and EOL 0 in this case.
  227. */
  228. struct sg_el {
  229. __le64 bus_addr;
  230. __le32 size;
  231. __le16 _r;
  232. u8 next_sg_offs;
  233. u8 flags;
  234. #define ASD_SG_EL_DS_MASK 0x30
  235. #define ASD_SG_EL_DS_OCM 0x10
  236. #define ASD_SG_EL_DS_HM 0x00
  237. #define ASD_SG_EL_LIST_MASK 0xC0
  238. #define ASD_SG_EL_LIST_EOL 0x40
  239. #define ASD_SG_EL_LIST_EOS 0x80
  240. } __attribute__ ((packed));
  241. /* ---------- SCBs ---------- */
  242. /* An SCB (sequencer control block) is comprised of a common header
  243. * and a task part, for a total of 128 bytes. All fields are in LE
  244. * order, unless otherwise noted.
  245. */
  246. /* This struct scb_header, defines the SCB header format.
  247. */
  248. struct scb_header {
  249. __le64 next_scb;
  250. __le16 index; /* transaction context */
  251. u8 opcode;
  252. } __attribute__ ((packed));
  253. /* SCB opcodes: Execution queue
  254. */
  255. #define INITIATE_SSP_TASK 0x00
  256. #define INITIATE_LONG_SSP_TASK 0x01
  257. #define INITIATE_BIDIR_SSP_TASK 0x02
  258. #define SCB_ABORT_TASK 0x03
  259. #define INITIATE_SSP_TMF 0x04
  260. #define SSP_TARG_GET_DATA 0x05
  261. #define SSP_TARG_GET_DATA_GOOD 0x06
  262. #define SSP_TARG_SEND_RESP 0x07
  263. #define QUERY_SSP_TASK 0x08
  264. #define INITIATE_ATA_TASK 0x09
  265. #define INITIATE_ATAPI_TASK 0x0a
  266. #define CONTROL_ATA_DEV 0x0b
  267. #define INITIATE_SMP_TASK 0x0c
  268. #define SMP_TARG_SEND_RESP 0x0f
  269. /* SCB opcodes: Send Queue
  270. */
  271. #define SSP_TARG_SEND_DATA 0x40
  272. #define SSP_TARG_SEND_DATA_GOOD 0x41
  273. /* SCB opcodes: Link Queue
  274. */
  275. #define CONTROL_PHY 0x80
  276. #define SEND_PRIMITIVE 0x81
  277. #define INITIATE_LINK_ADM_TASK 0x82
  278. /* SCB opcodes: other
  279. */
  280. #define EMPTY_SCB 0xc0
  281. #define INITIATE_SEQ_ADM_TASK 0xc1
  282. #define EST_ICL_TARG_WINDOW 0xc2
  283. #define COPY_MEM 0xc3
  284. #define CLEAR_NEXUS 0xc4
  285. #define INITIATE_DDB_ADM_TASK 0xc6
  286. #define ESTABLISH_NEXUS_ESCB 0xd0
  287. #define LUN_SIZE 8
  288. #define EFB_MASK 0x80
  289. #define TASK_PRIO_MASK 0x78
  290. #define TASK_ATTR_MASK 0x07
  291. /* ---------- SCB tasks ---------- */
  292. /* This is both ssp_task and long_ssp_task
  293. */
  294. struct initiate_ssp_task {
  295. u8 proto_conn_rate; /* proto:6,4, conn_rate:3,0 */
  296. __le32 total_xfer_len;
  297. struct ssp_frame_hdr ssp_frame;
  298. struct ssp_command_iu ssp_cmd;
  299. __le16 sister_scb; /* 0xFFFF */
  300. __le16 conn_handle; /* index to DDB for the intended target */
  301. u8 data_dir; /* :1,0 */
  302. #define DATA_DIR_NONE 0x00
  303. #define DATA_DIR_IN 0x01
  304. #define DATA_DIR_OUT 0x02
  305. #define DATA_DIR_BYRECIPIENT 0x03
  306. u8 _r_a;
  307. u8 retry_count;
  308. u8 _r_b[5];
  309. struct sg_el sg_element[3]; /* 2 real and 1 link */
  310. } __attribute__ ((packed));
  311. /* This defines both ata_task and atapi_task.
  312. * ata: C bit of FIS should be 1,
  313. * atapi: C bit of FIS should be 1, and command register should be 0xA0,
  314. * to indicate a packet command.
  315. */
  316. struct initiate_ata_task {
  317. u8 proto_conn_rate;
  318. __le32 total_xfer_len;
  319. struct host_to_dev_fis fis;
  320. __le32 data_offs;
  321. u8 atapi_packet[16];
  322. u8 _r_a[12];
  323. __le16 sister_scb;
  324. __le16 conn_handle;
  325. u8 ata_flags; /* CSMI:6,6, DTM:4,4, QT:3,3, data dir:1,0 */
  326. #define CSMI_TASK 0x40
  327. #define DATA_XFER_MODE_DMA 0x10
  328. #define ATA_Q_TYPE_MASK 0x08
  329. #define ATA_Q_TYPE_UNTAGGED 0x00
  330. #define ATA_Q_TYPE_NCQ 0x08
  331. u8 _r_b;
  332. u8 retry_count;
  333. u8 _r_c;
  334. u8 flags;
  335. #define STP_AFFIL_POLICY 0x20
  336. #define SET_AFFIL_POLICY 0x10
  337. #define RET_PARTIAL_SGLIST 0x02
  338. u8 _r_d[3];
  339. struct sg_el sg_element[3];
  340. } __attribute__ ((packed));
  341. struct initiate_smp_task {
  342. u8 proto_conn_rate;
  343. u8 _r_a[40];
  344. struct sg_el smp_req;
  345. __le16 sister_scb;
  346. __le16 conn_handle;
  347. u8 _r_c[8];
  348. struct sg_el smp_resp;
  349. u8 _r_d[32];
  350. } __attribute__ ((packed));
  351. struct control_phy {
  352. u8 phy_id;
  353. u8 sub_func;
  354. #define DISABLE_PHY 0x00
  355. #define ENABLE_PHY 0x01
  356. #define RELEASE_SPINUP_HOLD 0x02
  357. #define ENABLE_PHY_NO_SAS_OOB 0x03
  358. #define ENABLE_PHY_NO_SATA_OOB 0x04
  359. #define PHY_NO_OP 0x05
  360. #define EXECUTE_HARD_RESET 0x81
  361. u8 func_mask;
  362. u8 speed_mask;
  363. u8 hot_plug_delay;
  364. u8 port_type;
  365. u8 flags;
  366. #define DEV_PRES_TIMER_OVERRIDE_ENABLE 0x01
  367. #define DISABLE_PHY_IF_OOB_FAILS 0x02
  368. __le32 timeout_override;
  369. u8 link_reset_retries;
  370. u8 _r_a[47];
  371. __le16 conn_handle;
  372. u8 _r_b[56];
  373. } __attribute__ ((packed));
  374. struct control_ata_dev {
  375. u8 proto_conn_rate;
  376. __le32 _r_a;
  377. struct host_to_dev_fis fis;
  378. u8 _r_b[32];
  379. __le16 sister_scb;
  380. __le16 conn_handle;
  381. u8 ata_flags; /* 0 */
  382. u8 _r_c[55];
  383. } __attribute__ ((packed));
  384. struct empty_scb {
  385. u8 num_valid;
  386. __le32 _r_a;
  387. #define ASD_EDBS_PER_SCB 7
  388. /* header+data+CRC+DMA suffix data */
  389. #define ASD_EDB_SIZE (24+1024+4+16)
  390. struct sg_el eb[ASD_EDBS_PER_SCB];
  391. #define ELEMENT_NOT_VALID 0xC0
  392. } __attribute__ ((packed));
  393. struct initiate_link_adm {
  394. u8 phy_id;
  395. u8 sub_func;
  396. #define GET_LINK_ERROR_COUNT 0x00
  397. #define RESET_LINK_ERROR_COUNT 0x01
  398. #define ENABLE_NOTIFY_SPINUP_INTS 0x02
  399. u8 _r_a[57];
  400. __le16 conn_handle;
  401. u8 _r_b[56];
  402. } __attribute__ ((packed));
  403. struct copy_memory {
  404. u8 _r_a;
  405. __le16 xfer_len;
  406. __le16 _r_b;
  407. __le64 src_busaddr;
  408. u8 src_ds; /* See definition of sg_el */
  409. u8 _r_c[45];
  410. __le16 conn_handle;
  411. __le64 _r_d;
  412. __le64 dest_busaddr;
  413. u8 dest_ds; /* See definition of sg_el */
  414. u8 _r_e[39];
  415. } __attribute__ ((packed));
  416. struct abort_task {
  417. u8 proto_conn_rate;
  418. __le32 _r_a;
  419. struct ssp_frame_hdr ssp_frame;
  420. struct ssp_tmf_iu ssp_task;
  421. __le16 sister_scb;
  422. __le16 conn_handle;
  423. u8 flags; /* ovrd_itnl_timer:3,3, suspend_data_trans:2,2 */
  424. #define SUSPEND_DATA_TRANS 0x04
  425. u8 _r_b;
  426. u8 retry_count;
  427. u8 _r_c[5];
  428. __le16 index; /* Transaction context of task to be queried */
  429. __le16 itnl_to;
  430. u8 _r_d[44];
  431. } __attribute__ ((packed));
  432. struct clear_nexus {
  433. u8 nexus;
  434. #define NEXUS_ADAPTER 0x00
  435. #define NEXUS_PORT 0x01
  436. #define NEXUS_I_T 0x02
  437. #define NEXUS_I_T_L 0x03
  438. #define NEXUS_TAG 0x04
  439. #define NEXUS_TRANS_CX 0x05
  440. #define NEXUS_SATA_TAG 0x06
  441. #define NEXUS_T_L 0x07
  442. #define NEXUS_L 0x08
  443. #define NEXUS_T_TAG 0x09
  444. __le32 _r_a;
  445. u8 flags;
  446. #define SUSPEND_TX 0x80
  447. #define RESUME_TX 0x40
  448. #define SEND_Q 0x04
  449. #define EXEC_Q 0x02
  450. #define NOTINQ 0x01
  451. u8 _r_b[3];
  452. u8 conn_mask;
  453. u8 _r_c[19];
  454. struct ssp_tmf_iu ssp_task; /* LUN and TAG */
  455. __le16 _r_d;
  456. __le16 conn_handle;
  457. __le64 _r_e;
  458. __le16 index; /* Transaction context of task to be cleared */
  459. __le16 context; /* Clear nexus context */
  460. u8 _r_f[44];
  461. } __attribute__ ((packed));
  462. struct initiate_ssp_tmf {
  463. u8 proto_conn_rate;
  464. __le32 _r_a;
  465. struct ssp_frame_hdr ssp_frame;
  466. struct ssp_tmf_iu ssp_task;
  467. __le16 sister_scb;
  468. __le16 conn_handle;
  469. u8 flags; /* itnl override and suspend data tx */
  470. #define OVERRIDE_ITNL_TIMER 8
  471. u8 _r_b;
  472. u8 retry_count;
  473. u8 _r_c[5];
  474. __le16 index; /* Transaction context of task to be queried */
  475. __le16 itnl_to;
  476. u8 _r_d[44];
  477. } __attribute__ ((packed));
  478. /* Transmits an arbitrary primitive on the link.
  479. * Used for NOTIFY and BROADCAST.
  480. */
  481. struct send_prim {
  482. u8 phy_id;
  483. u8 wait_transmit; /* :0,0 */
  484. u8 xmit_flags;
  485. #define XMTPSIZE_MASK 0xF0
  486. #define XMTPSIZE_SINGLE 0x10
  487. #define XMTPSIZE_REPEATED 0x20
  488. #define XMTPSIZE_CONT 0x20
  489. #define XMTPSIZE_TRIPLE 0x30
  490. #define XMTPSIZE_REDUNDANT 0x60
  491. #define XMTPSIZE_INF 0
  492. #define XMTCONTEN 0x04
  493. #define XMTPFRM 0x02 /* Transmit at the next frame boundary */
  494. #define XMTPIMM 0x01 /* Transmit immediately */
  495. __le16 _r_a;
  496. u8 prim[4]; /* K, D0, D1, D2 */
  497. u8 _r_b[50];
  498. __le16 conn_handle;
  499. u8 _r_c[56];
  500. } __attribute__ ((packed));
  501. /* This describes both SSP Target Get Data and SSP Target Get Data And
  502. * Send Good Response SCBs. Used when the sequencer is operating in
  503. * target mode...
  504. */
  505. struct ssp_targ_get_data {
  506. u8 proto_conn_rate;
  507. __le32 total_xfer_len;
  508. struct ssp_frame_hdr ssp_frame;
  509. struct xfer_rdy_iu xfer_rdy;
  510. u8 lun[LUN_SIZE];
  511. __le64 _r_a;
  512. __le16 sister_scb;
  513. __le16 conn_handle;
  514. u8 data_dir; /* 01b */
  515. u8 _r_b;
  516. u8 retry_count;
  517. u8 _r_c[5];
  518. struct sg_el sg_element[3];
  519. } __attribute__ ((packed));
  520. /* ---------- The actual SCB struct ---------- */
  521. struct scb {
  522. struct scb_header header;
  523. union {
  524. struct initiate_ssp_task ssp_task;
  525. struct initiate_ata_task ata_task;
  526. struct initiate_smp_task smp_task;
  527. struct control_phy control_phy;
  528. struct control_ata_dev control_ata_dev;
  529. struct empty_scb escb;
  530. struct initiate_link_adm link_adm;
  531. struct copy_memory cp_mem;
  532. struct abort_task abort_task;
  533. struct clear_nexus clear_nexus;
  534. struct initiate_ssp_tmf ssp_tmf;
  535. };
  536. } __attribute__ ((packed));
  537. /* ---------- Done List ---------- */
  538. /* The done list entry opcode field is defined below.
  539. * The mnemonic encoding and meaning is as follows:
  540. * TC - Task Complete, status was received and acknowledged
  541. * TF - Task Failed, indicates an error prior to receiving acknowledgment
  542. * for the command:
  543. * - no conn,
  544. * - NACK or R_ERR received in response to this command,
  545. * - credit blocked or not available, or in the case of SMP request,
  546. * - no SMP response was received.
  547. * In these four cases it is known that the target didn't receive the
  548. * command.
  549. * TI - Task Interrupted, error after the command was acknowledged. It is
  550. * known that the command was received by the target.
  551. * TU - Task Unacked, command was transmitted but neither ACK (R_OK) nor NAK
  552. * (R_ERR) was received due to loss of signal, broken connection, loss of
  553. * dword sync or other reason. The application client should send the
  554. * appropriate task query.
  555. * TA - Task Aborted, see TF.
  556. * _RESP - The completion includes an empty buffer containing status.
  557. * TO - Timeout.
  558. */
  559. #define TC_NO_ERROR 0x00
  560. #define TC_UNDERRUN 0x01
  561. #define TC_OVERRUN 0x02
  562. #define TF_OPEN_TO 0x03
  563. #define TF_OPEN_REJECT 0x04
  564. #define TI_BREAK 0x05
  565. #define TI_PROTO_ERR 0x06
  566. #define TC_SSP_RESP 0x07
  567. #define TI_PHY_DOWN 0x08
  568. #define TF_PHY_DOWN 0x09
  569. #define TC_LINK_ADM_RESP 0x0a
  570. #define TC_CSMI 0x0b
  571. #define TC_ATA_RESP 0x0c
  572. #define TU_PHY_DOWN 0x0d
  573. #define TU_BREAK 0x0e
  574. #define TI_SATA_TO 0x0f
  575. #define TI_NAK 0x10
  576. #define TC_CONTROL_PHY 0x11
  577. #define TF_BREAK 0x12
  578. #define TC_RESUME 0x13
  579. #define TI_ACK_NAK_TO 0x14
  580. #define TF_SMPRSP_TO 0x15
  581. #define TF_SMP_XMIT_RCV_ERR 0x16
  582. #define TC_PARTIAL_SG_LIST 0x17
  583. #define TU_ACK_NAK_TO 0x18
  584. #define TU_SATA_TO 0x19
  585. #define TF_NAK_RECV 0x1a
  586. #define TA_I_T_NEXUS_LOSS 0x1b
  587. #define TC_ATA_R_ERR_RECV 0x1c
  588. #define TF_TMF_NO_CTX 0x1d
  589. #define TA_ON_REQ 0x1e
  590. #define TF_TMF_NO_TAG 0x1f
  591. #define TF_TMF_TAG_FREE 0x20
  592. #define TF_TMF_TASK_DONE 0x21
  593. #define TF_TMF_NO_CONN_HANDLE 0x22
  594. #define TC_TASK_CLEARED 0x23
  595. #define TI_SYNCS_RECV 0x24
  596. #define TU_SYNCS_RECV 0x25
  597. #define TF_IRTT_TO 0x26
  598. #define TF_NO_SMP_CONN 0x27
  599. #define TF_IU_SHORT 0x28
  600. #define TF_DATA_OFFS_ERR 0x29
  601. #define TF_INV_CONN_HANDLE 0x2a
  602. #define TF_REQUESTED_N_PENDING 0x2b
  603. /* 0xc1 - 0xc7: empty buffer received,
  604. 0xd1 - 0xd7: establish nexus empty buffer received
  605. */
  606. /* This is the ESCB mask */
  607. #define ESCB_RECVD 0xC0
  608. /* This struct done_list_struct defines the done list entry.
  609. * All fields are LE.
  610. */
  611. struct done_list_struct {
  612. __le16 index; /* aka transaction context */
  613. u8 opcode;
  614. u8 status_block[4];
  615. u8 toggle; /* bit 0 */
  616. #define DL_TOGGLE_MASK 0x01
  617. } __attribute__ ((packed));
  618. /* ---------- PHYS ---------- */
  619. struct asd_phy {
  620. struct asd_sas_phy sas_phy;
  621. struct asd_phy_desc *phy_desc; /* hw profile */
  622. struct sas_identify_frame *identify_frame;
  623. struct asd_dma_tok *id_frm_tok;
  624. struct asd_port *asd_port;
  625. u8 frame_rcvd[ASD_EDB_SIZE];
  626. };
  627. #define ASD_SCB_SIZE sizeof(struct scb)
  628. #define ASD_DDB_SIZE sizeof(struct asd_ddb_ssp_smp_target_port)
  629. /* Define this to 0 if you do not want NOTIFY (ENABLE SPINIP) sent.
  630. * Default: 0x10 (it's a mask)
  631. */
  632. #define ASD_NOTIFY_ENABLE_SPINUP 0x10
  633. /* If enabled, set this to the interval between transmission
  634. * of NOTIFY (ENABLE SPINUP). In units of 200 us.
  635. */
  636. #define ASD_NOTIFY_TIMEOUT 2500
  637. /* Initial delay after OOB, before we transmit NOTIFY (ENABLE SPINUP).
  638. * If 0, transmit immediately. In milliseconds.
  639. */
  640. #define ASD_NOTIFY_DOWN_COUNT 0
  641. /* Device present timer timeout constant, 10 ms. */
  642. #define ASD_DEV_PRESENT_TIMEOUT 0x2710
  643. #define ASD_SATA_INTERLOCK_TIMEOUT 0
  644. /* How long to wait before shutting down an STP connection, unless
  645. * an STP target sent frame(s). 50 usec.
  646. * IGNORED by the sequencer (i.e. value 0 always).
  647. */
  648. #define ASD_STP_SHUTDOWN_TIMEOUT 0x0
  649. /* ATA soft reset timer timeout. 5 usec. */
  650. #define ASD_SRST_ASSERT_TIMEOUT 0x05
  651. /* 31 sec */
  652. #define ASD_RCV_FIS_TIMEOUT 0x01D905C0
  653. #define ASD_ONE_MILLISEC_TIMEOUT 0x03e8
  654. /* COMINIT timer */
  655. #define ASD_TEN_MILLISEC_TIMEOUT 0x2710
  656. #define ASD_COMINIT_TIMEOUT ASD_TEN_MILLISEC_TIMEOUT
  657. /* 1 sec */
  658. #define ASD_SMP_RCV_TIMEOUT 0x000F4240
  659. #endif