aic94xx_sas.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787
  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. /* See SAS spec, task IU
  289. */
  290. struct ssp_task_iu {
  291. u8 lun[LUN_SIZE]; /* BE */
  292. u16 _r_a;
  293. u8 tmf;
  294. u8 _r_b;
  295. __be16 tag; /* BE */
  296. u8 _r_c[14];
  297. } __attribute__ ((packed));
  298. /* See SAS spec, command IU
  299. */
  300. struct ssp_command_iu {
  301. u8 lun[LUN_SIZE];
  302. u8 _r_a;
  303. u8 efb_prio_attr; /* enable first burst, task prio & attr */
  304. #define EFB_MASK 0x80
  305. #define TASK_PRIO_MASK 0x78
  306. #define TASK_ATTR_MASK 0x07
  307. u8 _r_b;
  308. u8 add_cdb_len; /* in dwords, since bit 0,1 are reserved */
  309. union {
  310. u8 cdb[16];
  311. struct {
  312. __le64 long_cdb_addr; /* bus address, LE */
  313. __le32 long_cdb_size; /* LE */
  314. u8 _r_c[3];
  315. u8 eol_ds; /* eol:6,6, ds:5,4 */
  316. } long_cdb; /* sequencer extension */
  317. };
  318. } __attribute__ ((packed));
  319. struct xfer_rdy_iu {
  320. __be32 requested_offset; /* BE */
  321. __be32 write_data_len; /* BE */
  322. __be32 _r_a;
  323. } __attribute__ ((packed));
  324. /* ---------- SCB tasks ---------- */
  325. /* This is both ssp_task and long_ssp_task
  326. */
  327. struct initiate_ssp_task {
  328. u8 proto_conn_rate; /* proto:6,4, conn_rate:3,0 */
  329. __le32 total_xfer_len;
  330. struct ssp_frame_hdr ssp_frame;
  331. struct ssp_command_iu ssp_cmd;
  332. __le16 sister_scb; /* 0xFFFF */
  333. __le16 conn_handle; /* index to DDB for the intended target */
  334. u8 data_dir; /* :1,0 */
  335. #define DATA_DIR_NONE 0x00
  336. #define DATA_DIR_IN 0x01
  337. #define DATA_DIR_OUT 0x02
  338. #define DATA_DIR_BYRECIPIENT 0x03
  339. u8 _r_a;
  340. u8 retry_count;
  341. u8 _r_b[5];
  342. struct sg_el sg_element[3]; /* 2 real and 1 link */
  343. } __attribute__ ((packed));
  344. /* This defines both ata_task and atapi_task.
  345. * ata: C bit of FIS should be 1,
  346. * atapi: C bit of FIS should be 1, and command register should be 0xA0,
  347. * to indicate a packet command.
  348. */
  349. struct initiate_ata_task {
  350. u8 proto_conn_rate;
  351. __le32 total_xfer_len;
  352. struct host_to_dev_fis fis;
  353. __le32 data_offs;
  354. u8 atapi_packet[16];
  355. u8 _r_a[12];
  356. __le16 sister_scb;
  357. __le16 conn_handle;
  358. u8 ata_flags; /* CSMI:6,6, DTM:4,4, QT:3,3, data dir:1,0 */
  359. #define CSMI_TASK 0x40
  360. #define DATA_XFER_MODE_DMA 0x10
  361. #define ATA_Q_TYPE_MASK 0x08
  362. #define ATA_Q_TYPE_UNTAGGED 0x00
  363. #define ATA_Q_TYPE_NCQ 0x08
  364. u8 _r_b;
  365. u8 retry_count;
  366. u8 _r_c;
  367. u8 flags;
  368. #define STP_AFFIL_POLICY 0x20
  369. #define SET_AFFIL_POLICY 0x10
  370. #define RET_PARTIAL_SGLIST 0x02
  371. u8 _r_d[3];
  372. struct sg_el sg_element[3];
  373. } __attribute__ ((packed));
  374. struct initiate_smp_task {
  375. u8 proto_conn_rate;
  376. u8 _r_a[40];
  377. struct sg_el smp_req;
  378. __le16 sister_scb;
  379. __le16 conn_handle;
  380. u8 _r_c[8];
  381. struct sg_el smp_resp;
  382. u8 _r_d[32];
  383. } __attribute__ ((packed));
  384. struct control_phy {
  385. u8 phy_id;
  386. u8 sub_func;
  387. #define DISABLE_PHY 0x00
  388. #define ENABLE_PHY 0x01
  389. #define RELEASE_SPINUP_HOLD 0x02
  390. #define ENABLE_PHY_NO_SAS_OOB 0x03
  391. #define ENABLE_PHY_NO_SATA_OOB 0x04
  392. #define PHY_NO_OP 0x05
  393. #define EXECUTE_HARD_RESET 0x81
  394. u8 func_mask;
  395. u8 speed_mask;
  396. u8 hot_plug_delay;
  397. u8 port_type;
  398. u8 flags;
  399. #define DEV_PRES_TIMER_OVERRIDE_ENABLE 0x01
  400. #define DISABLE_PHY_IF_OOB_FAILS 0x02
  401. __le32 timeout_override;
  402. u8 link_reset_retries;
  403. u8 _r_a[47];
  404. __le16 conn_handle;
  405. u8 _r_b[56];
  406. } __attribute__ ((packed));
  407. struct control_ata_dev {
  408. u8 proto_conn_rate;
  409. __le32 _r_a;
  410. struct host_to_dev_fis fis;
  411. u8 _r_b[32];
  412. __le16 sister_scb;
  413. __le16 conn_handle;
  414. u8 ata_flags; /* 0 */
  415. u8 _r_c[55];
  416. } __attribute__ ((packed));
  417. struct empty_scb {
  418. u8 num_valid;
  419. __le32 _r_a;
  420. #define ASD_EDBS_PER_SCB 7
  421. /* header+data+CRC+DMA suffix data */
  422. #define ASD_EDB_SIZE (24+1024+4+16)
  423. struct sg_el eb[ASD_EDBS_PER_SCB];
  424. #define ELEMENT_NOT_VALID 0xC0
  425. } __attribute__ ((packed));
  426. struct initiate_link_adm {
  427. u8 phy_id;
  428. u8 sub_func;
  429. #define GET_LINK_ERROR_COUNT 0x00
  430. #define RESET_LINK_ERROR_COUNT 0x01
  431. #define ENABLE_NOTIFY_SPINUP_INTS 0x02
  432. u8 _r_a[57];
  433. __le16 conn_handle;
  434. u8 _r_b[56];
  435. } __attribute__ ((packed));
  436. struct copy_memory {
  437. u8 _r_a;
  438. __le16 xfer_len;
  439. __le16 _r_b;
  440. __le64 src_busaddr;
  441. u8 src_ds; /* See definition of sg_el */
  442. u8 _r_c[45];
  443. __le16 conn_handle;
  444. __le64 _r_d;
  445. __le64 dest_busaddr;
  446. u8 dest_ds; /* See definition of sg_el */
  447. u8 _r_e[39];
  448. } __attribute__ ((packed));
  449. struct abort_task {
  450. u8 proto_conn_rate;
  451. __le32 _r_a;
  452. struct ssp_frame_hdr ssp_frame;
  453. struct ssp_task_iu ssp_task;
  454. __le16 sister_scb;
  455. __le16 conn_handle;
  456. u8 flags; /* ovrd_itnl_timer:3,3, suspend_data_trans:2,2 */
  457. #define SUSPEND_DATA_TRANS 0x04
  458. u8 _r_b;
  459. u8 retry_count;
  460. u8 _r_c[5];
  461. __le16 index; /* Transaction context of task to be queried */
  462. __le16 itnl_to;
  463. u8 _r_d[44];
  464. } __attribute__ ((packed));
  465. struct clear_nexus {
  466. u8 nexus;
  467. #define NEXUS_ADAPTER 0x00
  468. #define NEXUS_PORT 0x01
  469. #define NEXUS_I_T 0x02
  470. #define NEXUS_I_T_L 0x03
  471. #define NEXUS_TAG 0x04
  472. #define NEXUS_TRANS_CX 0x05
  473. #define NEXUS_SATA_TAG 0x06
  474. #define NEXUS_T_L 0x07
  475. #define NEXUS_L 0x08
  476. #define NEXUS_T_TAG 0x09
  477. __le32 _r_a;
  478. u8 flags;
  479. #define SUSPEND_TX 0x80
  480. #define RESUME_TX 0x40
  481. #define SEND_Q 0x04
  482. #define EXEC_Q 0x02
  483. #define NOTINQ 0x01
  484. u8 _r_b[3];
  485. u8 conn_mask;
  486. u8 _r_c[19];
  487. struct ssp_task_iu ssp_task; /* LUN and TAG */
  488. __le16 _r_d;
  489. __le16 conn_handle;
  490. __le64 _r_e;
  491. __le16 index; /* Transaction context of task to be cleared */
  492. __le16 context; /* Clear nexus context */
  493. u8 _r_f[44];
  494. } __attribute__ ((packed));
  495. struct initiate_ssp_tmf {
  496. u8 proto_conn_rate;
  497. __le32 _r_a;
  498. struct ssp_frame_hdr ssp_frame;
  499. struct ssp_task_iu ssp_task;
  500. __le16 sister_scb;
  501. __le16 conn_handle;
  502. u8 flags; /* itnl override and suspend data tx */
  503. #define OVERRIDE_ITNL_TIMER 8
  504. u8 _r_b;
  505. u8 retry_count;
  506. u8 _r_c[5];
  507. __le16 index; /* Transaction context of task to be queried */
  508. __le16 itnl_to;
  509. u8 _r_d[44];
  510. } __attribute__ ((packed));
  511. /* Transmits an arbitrary primitive on the link.
  512. * Used for NOTIFY and BROADCAST.
  513. */
  514. struct send_prim {
  515. u8 phy_id;
  516. u8 wait_transmit; /* :0,0 */
  517. u8 xmit_flags;
  518. #define XMTPSIZE_MASK 0xF0
  519. #define XMTPSIZE_SINGLE 0x10
  520. #define XMTPSIZE_REPEATED 0x20
  521. #define XMTPSIZE_CONT 0x20
  522. #define XMTPSIZE_TRIPLE 0x30
  523. #define XMTPSIZE_REDUNDANT 0x60
  524. #define XMTPSIZE_INF 0
  525. #define XMTCONTEN 0x04
  526. #define XMTPFRM 0x02 /* Transmit at the next frame boundary */
  527. #define XMTPIMM 0x01 /* Transmit immediately */
  528. __le16 _r_a;
  529. u8 prim[4]; /* K, D0, D1, D2 */
  530. u8 _r_b[50];
  531. __le16 conn_handle;
  532. u8 _r_c[56];
  533. } __attribute__ ((packed));
  534. /* This describes both SSP Target Get Data and SSP Target Get Data And
  535. * Send Good Response SCBs. Used when the sequencer is operating in
  536. * target mode...
  537. */
  538. struct ssp_targ_get_data {
  539. u8 proto_conn_rate;
  540. __le32 total_xfer_len;
  541. struct ssp_frame_hdr ssp_frame;
  542. struct xfer_rdy_iu xfer_rdy;
  543. u8 lun[LUN_SIZE];
  544. __le64 _r_a;
  545. __le16 sister_scb;
  546. __le16 conn_handle;
  547. u8 data_dir; /* 01b */
  548. u8 _r_b;
  549. u8 retry_count;
  550. u8 _r_c[5];
  551. struct sg_el sg_element[3];
  552. } __attribute__ ((packed));
  553. /* ---------- The actual SCB struct ---------- */
  554. struct scb {
  555. struct scb_header header;
  556. union {
  557. struct initiate_ssp_task ssp_task;
  558. struct initiate_ata_task ata_task;
  559. struct initiate_smp_task smp_task;
  560. struct control_phy control_phy;
  561. struct control_ata_dev control_ata_dev;
  562. struct empty_scb escb;
  563. struct initiate_link_adm link_adm;
  564. struct copy_memory cp_mem;
  565. struct abort_task abort_task;
  566. struct clear_nexus clear_nexus;
  567. struct initiate_ssp_tmf ssp_tmf;
  568. };
  569. } __attribute__ ((packed));
  570. /* ---------- Done List ---------- */
  571. /* The done list entry opcode field is defined below.
  572. * The mnemonic encoding and meaning is as follows:
  573. * TC - Task Complete, status was received and acknowledged
  574. * TF - Task Failed, indicates an error prior to receiving acknowledgment
  575. * for the command:
  576. * - no conn,
  577. * - NACK or R_ERR received in response to this command,
  578. * - credit blocked or not available, or in the case of SMP request,
  579. * - no SMP response was received.
  580. * In these four cases it is known that the target didn't receive the
  581. * command.
  582. * TI - Task Interrupted, error after the command was acknowledged. It is
  583. * known that the command was received by the target.
  584. * TU - Task Unacked, command was transmitted but neither ACK (R_OK) nor NAK
  585. * (R_ERR) was received due to loss of signal, broken connection, loss of
  586. * dword sync or other reason. The application client should send the
  587. * appropriate task query.
  588. * TA - Task Aborted, see TF.
  589. * _RESP - The completion includes an empty buffer containing status.
  590. * TO - Timeout.
  591. */
  592. #define TC_NO_ERROR 0x00
  593. #define TC_UNDERRUN 0x01
  594. #define TC_OVERRUN 0x02
  595. #define TF_OPEN_TO 0x03
  596. #define TF_OPEN_REJECT 0x04
  597. #define TI_BREAK 0x05
  598. #define TI_PROTO_ERR 0x06
  599. #define TC_SSP_RESP 0x07
  600. #define TI_PHY_DOWN 0x08
  601. #define TF_PHY_DOWN 0x09
  602. #define TC_LINK_ADM_RESP 0x0a
  603. #define TC_CSMI 0x0b
  604. #define TC_ATA_RESP 0x0c
  605. #define TU_PHY_DOWN 0x0d
  606. #define TU_BREAK 0x0e
  607. #define TI_SATA_TO 0x0f
  608. #define TI_NAK 0x10
  609. #define TC_CONTROL_PHY 0x11
  610. #define TF_BREAK 0x12
  611. #define TC_RESUME 0x13
  612. #define TI_ACK_NAK_TO 0x14
  613. #define TF_SMPRSP_TO 0x15
  614. #define TF_SMP_XMIT_RCV_ERR 0x16
  615. #define TC_PARTIAL_SG_LIST 0x17
  616. #define TU_ACK_NAK_TO 0x18
  617. #define TU_SATA_TO 0x19
  618. #define TF_NAK_RECV 0x1a
  619. #define TA_I_T_NEXUS_LOSS 0x1b
  620. #define TC_ATA_R_ERR_RECV 0x1c
  621. #define TF_TMF_NO_CTX 0x1d
  622. #define TA_ON_REQ 0x1e
  623. #define TF_TMF_NO_TAG 0x1f
  624. #define TF_TMF_TAG_FREE 0x20
  625. #define TF_TMF_TASK_DONE 0x21
  626. #define TF_TMF_NO_CONN_HANDLE 0x22
  627. #define TC_TASK_CLEARED 0x23
  628. #define TI_SYNCS_RECV 0x24
  629. #define TU_SYNCS_RECV 0x25
  630. #define TF_IRTT_TO 0x26
  631. #define TF_NO_SMP_CONN 0x27
  632. #define TF_IU_SHORT 0x28
  633. #define TF_DATA_OFFS_ERR 0x29
  634. #define TF_INV_CONN_HANDLE 0x2a
  635. #define TF_REQUESTED_N_PENDING 0x2b
  636. /* 0xc1 - 0xc7: empty buffer received,
  637. 0xd1 - 0xd7: establish nexus empty buffer received
  638. */
  639. /* This is the ESCB mask */
  640. #define ESCB_RECVD 0xC0
  641. /* This struct done_list_struct defines the done list entry.
  642. * All fields are LE.
  643. */
  644. struct done_list_struct {
  645. __le16 index; /* aka transaction context */
  646. u8 opcode;
  647. u8 status_block[4];
  648. u8 toggle; /* bit 0 */
  649. #define DL_TOGGLE_MASK 0x01
  650. } __attribute__ ((packed));
  651. /* ---------- PHYS ---------- */
  652. struct asd_phy {
  653. struct asd_sas_phy sas_phy;
  654. struct asd_phy_desc *phy_desc; /* hw profile */
  655. struct sas_identify_frame *identify_frame;
  656. struct asd_dma_tok *id_frm_tok;
  657. struct asd_port *asd_port;
  658. u8 frame_rcvd[ASD_EDB_SIZE];
  659. };
  660. #define ASD_SCB_SIZE sizeof(struct scb)
  661. #define ASD_DDB_SIZE sizeof(struct asd_ddb_ssp_smp_target_port)
  662. /* Define this to 0 if you do not want NOTIFY (ENABLE SPINIP) sent.
  663. * Default: 0x10 (it's a mask)
  664. */
  665. #define ASD_NOTIFY_ENABLE_SPINUP 0x10
  666. /* If enabled, set this to the interval between transmission
  667. * of NOTIFY (ENABLE SPINUP). In units of 200 us.
  668. */
  669. #define ASD_NOTIFY_TIMEOUT 2500
  670. /* Initial delay after OOB, before we transmit NOTIFY (ENABLE SPINUP).
  671. * If 0, transmit immediately. In milliseconds.
  672. */
  673. #define ASD_NOTIFY_DOWN_COUNT 0
  674. /* Device present timer timeout constant, 10 ms. */
  675. #define ASD_DEV_PRESENT_TIMEOUT 0x2710
  676. #define ASD_SATA_INTERLOCK_TIMEOUT 0
  677. /* How long to wait before shutting down an STP connection, unless
  678. * an STP target sent frame(s). 50 usec.
  679. * IGNORED by the sequencer (i.e. value 0 always).
  680. */
  681. #define ASD_STP_SHUTDOWN_TIMEOUT 0x0
  682. /* ATA soft reset timer timeout. 5 usec. */
  683. #define ASD_SRST_ASSERT_TIMEOUT 0x05
  684. /* 31 sec */
  685. #define ASD_RCV_FIS_TIMEOUT 0x01D905C0
  686. #define ASD_ONE_MILLISEC_TIMEOUT 0x03e8
  687. /* COMINIT timer */
  688. #define ASD_TEN_MILLISEC_TIMEOUT 0x2710
  689. #define ASD_COMINIT_TIMEOUT ASD_TEN_MILLISEC_TIMEOUT
  690. /* 1 sec */
  691. #define ASD_SMP_RCV_TIMEOUT 0x000F4240
  692. #endif