aic94xx_sas.h 21 KB

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