1ba6d10abSLinus Torvalds /* SPDX-License-Identifier: GPL-2.0-only */ 22908d778SJames Bottomley /* 32908d778SJames Bottomley * SAS structures and definitions header file 42908d778SJames Bottomley * 52908d778SJames Bottomley * Copyright (C) 2005 Adaptec, Inc. All rights reserved. 62908d778SJames Bottomley * Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com> 72908d778SJames Bottomley */ 82908d778SJames Bottomley 92908d778SJames Bottomley #ifndef _SAS_H_ 102908d778SJames Bottomley #define _SAS_H_ 112908d778SJames Bottomley 122908d778SJames Bottomley #include <linux/types.h> 132908d778SJames Bottomley #include <asm/byteorder.h> 142908d778SJames Bottomley 152908d778SJames Bottomley #define SAS_ADDR_SIZE 8 162908d778SJames Bottomley #define HASHED_SAS_ADDR_SIZE 3 172908d778SJames Bottomley #define SAS_ADDR(_sa) ((unsigned long long) be64_to_cpu(*(__be64 *)(_sa))) 182908d778SJames Bottomley 192908d778SJames Bottomley #define SMP_REQUEST 0x40 202908d778SJames Bottomley #define SMP_RESPONSE 0x41 212908d778SJames Bottomley 222908d778SJames Bottomley #define SSP_DATA 0x01 232908d778SJames Bottomley #define SSP_XFER_RDY 0x05 242908d778SJames Bottomley #define SSP_COMMAND 0x06 252908d778SJames Bottomley #define SSP_RESPONSE 0x07 262908d778SJames Bottomley #define SSP_TASK 0x16 272908d778SJames Bottomley 282908d778SJames Bottomley #define SMP_REPORT_GENERAL 0x00 292908d778SJames Bottomley #define SMP_REPORT_MANUF_INFO 0x01 302908d778SJames Bottomley #define SMP_READ_GPIO_REG 0x02 312908d778SJames Bottomley #define SMP_DISCOVER 0x10 322908d778SJames Bottomley #define SMP_REPORT_PHY_ERR_LOG 0x11 332908d778SJames Bottomley #define SMP_REPORT_PHY_SATA 0x12 342908d778SJames Bottomley #define SMP_REPORT_ROUTE_INFO 0x13 352908d778SJames Bottomley #define SMP_WRITE_GPIO_REG 0x82 362908d778SJames Bottomley #define SMP_CONF_ROUTE_INFO 0x90 372908d778SJames Bottomley #define SMP_PHY_CONTROL 0x91 382908d778SJames Bottomley #define SMP_PHY_TEST_FUNCTION 0x92 392908d778SJames Bottomley 402908d778SJames Bottomley #define SMP_RESP_FUNC_ACC 0x00 412908d778SJames Bottomley #define SMP_RESP_FUNC_UNK 0x01 422908d778SJames Bottomley #define SMP_RESP_FUNC_FAILED 0x02 432908d778SJames Bottomley #define SMP_RESP_INV_FRM_LEN 0x03 442908d778SJames Bottomley #define SMP_RESP_NO_PHY 0x10 452908d778SJames Bottomley #define SMP_RESP_NO_INDEX 0x11 462908d778SJames Bottomley #define SMP_RESP_PHY_NO_SATA 0x12 472908d778SJames Bottomley #define SMP_RESP_PHY_UNK_OP 0x13 482908d778SJames Bottomley #define SMP_RESP_PHY_UNK_TESTF 0x14 492908d778SJames Bottomley #define SMP_RESP_PHY_TEST_INPROG 0x15 502908d778SJames Bottomley #define SMP_RESP_PHY_VACANT 0x16 512908d778SJames Bottomley 522908d778SJames Bottomley /* SAM TMFs */ 532908d778SJames Bottomley #define TMF_ABORT_TASK 0x01 542908d778SJames Bottomley #define TMF_ABORT_TASK_SET 0x02 552908d778SJames Bottomley #define TMF_CLEAR_TASK_SET 0x04 562908d778SJames Bottomley #define TMF_LU_RESET 0x08 572908d778SJames Bottomley #define TMF_CLEAR_ACA 0x40 582908d778SJames Bottomley #define TMF_QUERY_TASK 0x80 592908d778SJames Bottomley 602908d778SJames Bottomley /* SAS TMF responses */ 612908d778SJames Bottomley #define TMF_RESP_FUNC_COMPLETE 0x00 622908d778SJames Bottomley #define TMF_RESP_INVALID_FRAME 0x02 632908d778SJames Bottomley #define TMF_RESP_FUNC_ESUPP 0x04 642908d778SJames Bottomley #define TMF_RESP_FUNC_FAILED 0x05 652908d778SJames Bottomley #define TMF_RESP_FUNC_SUCC 0x08 662908d778SJames Bottomley #define TMF_RESP_NO_LUN 0x09 672908d778SJames Bottomley #define TMF_RESP_OVERLAPPED_TAG 0x0A 682908d778SJames Bottomley 692908d778SJames Bottomley enum sas_oob_mode { 702908d778SJames Bottomley OOB_NOT_CONNECTED, 712908d778SJames Bottomley SATA_OOB_MODE, 722908d778SJames Bottomley SAS_OOB_MODE 732908d778SJames Bottomley }; 742908d778SJames Bottomley 75354cf829SDan Williams /* See sas_discover.c if you plan on changing these */ 76aa9f8328SJames Bottomley enum sas_device_type { 77aa9f8328SJames Bottomley /* these are SAS protocol defined (attached device type field) */ 78aa9f8328SJames Bottomley SAS_PHY_UNUSED = 0, 79aa9f8328SJames Bottomley SAS_END_DEVICE = 1, 80aa9f8328SJames Bottomley SAS_EDGE_EXPANDER_DEVICE = 2, 81aa9f8328SJames Bottomley SAS_FANOUT_EXPANDER_DEVICE = 3, 82aa9f8328SJames Bottomley /* these are internal to libsas */ 832908d778SJames Bottomley SAS_HA = 4, 84aa9f8328SJames Bottomley SAS_SATA_DEV = 5, 85aa9f8328SJames Bottomley SAS_SATA_PM = 7, 86aa9f8328SJames Bottomley SAS_SATA_PM_PORT = 8, 87aa9f8328SJames Bottomley SAS_SATA_PENDING = 9, 882908d778SJames Bottomley }; 892908d778SJames Bottomley 905929faf3SDarrick J. Wong enum sas_protocol { 91c79dd80dSDan Williams SAS_PROTOCOL_NONE = 0, 925929faf3SDarrick J. Wong SAS_PROTOCOL_SATA = 0x01, 935929faf3SDarrick J. Wong SAS_PROTOCOL_SMP = 0x02, 945929faf3SDarrick J. Wong SAS_PROTOCOL_STP = 0x04, 955929faf3SDarrick J. Wong SAS_PROTOCOL_SSP = 0x08, 965929faf3SDarrick J. Wong SAS_PROTOCOL_ALL = 0x0E, 9705a2a173SDan Williams SAS_PROTOCOL_STP_ALL = SAS_PROTOCOL_STP|SAS_PROTOCOL_SATA, 982908d778SJames Bottomley }; 992908d778SJames Bottomley 1002908d778SJames Bottomley /* From the spec; local phys only */ 1012908d778SJames Bottomley enum phy_func { 1022908d778SJames Bottomley PHY_FUNC_NOP, 1032908d778SJames Bottomley PHY_FUNC_LINK_RESET, /* Enables the phy */ 1042908d778SJames Bottomley PHY_FUNC_HARD_RESET, 1052908d778SJames Bottomley PHY_FUNC_DISABLE, 1062908d778SJames Bottomley PHY_FUNC_CLEAR_ERROR_LOG = 5, 1072908d778SJames Bottomley PHY_FUNC_CLEAR_AFFIL, 1082908d778SJames Bottomley PHY_FUNC_TX_SATA_PS_SIGNAL, 1092908d778SJames Bottomley PHY_FUNC_RELEASE_SPINUP_HOLD = 0x10, /* LOCAL PORT ONLY! */ 110a01e70e5SJames Bottomley PHY_FUNC_SET_LINK_RATE, 111ac013ed1SDan Williams PHY_FUNC_GET_EVENTS, 1122908d778SJames Bottomley }; 1132908d778SJames Bottomley 1142908d778SJames Bottomley /* SAS LLDD would need to report only _very_few_ of those, like BROADCAST. 1152908d778SJames Bottomley * Most of those are here for completeness. 1162908d778SJames Bottomley */ 1172908d778SJames Bottomley enum sas_prim { 1182908d778SJames Bottomley SAS_PRIM_AIP_NORMAL = 1, 1192908d778SJames Bottomley SAS_PRIM_AIP_R0 = 2, 1202908d778SJames Bottomley SAS_PRIM_AIP_R1 = 3, 1212908d778SJames Bottomley SAS_PRIM_AIP_R2 = 4, 1222908d778SJames Bottomley SAS_PRIM_AIP_WC = 5, 1232908d778SJames Bottomley SAS_PRIM_AIP_WD = 6, 1242908d778SJames Bottomley SAS_PRIM_AIP_WP = 7, 1252908d778SJames Bottomley SAS_PRIM_AIP_RWP = 8, 1262908d778SJames Bottomley 1272908d778SJames Bottomley SAS_PRIM_BC_CH = 9, 1282908d778SJames Bottomley SAS_PRIM_BC_RCH0 = 10, 1292908d778SJames Bottomley SAS_PRIM_BC_RCH1 = 11, 1302908d778SJames Bottomley SAS_PRIM_BC_R0 = 12, 1312908d778SJames Bottomley SAS_PRIM_BC_R1 = 13, 1322908d778SJames Bottomley SAS_PRIM_BC_R2 = 14, 1332908d778SJames Bottomley SAS_PRIM_BC_R3 = 15, 1342908d778SJames Bottomley SAS_PRIM_BC_R4 = 16, 1352908d778SJames Bottomley 1362908d778SJames Bottomley SAS_PRIM_NOTIFY_ENSP= 17, 1372908d778SJames Bottomley SAS_PRIM_NOTIFY_R0 = 18, 1382908d778SJames Bottomley SAS_PRIM_NOTIFY_R1 = 19, 1392908d778SJames Bottomley SAS_PRIM_NOTIFY_R2 = 20, 1402908d778SJames Bottomley 1412908d778SJames Bottomley SAS_PRIM_CLOSE_CLAF = 21, 1422908d778SJames Bottomley SAS_PRIM_CLOSE_NORM = 22, 1432908d778SJames Bottomley SAS_PRIM_CLOSE_R0 = 23, 1442908d778SJames Bottomley SAS_PRIM_CLOSE_R1 = 24, 1452908d778SJames Bottomley 1462908d778SJames Bottomley SAS_PRIM_OPEN_RTRY = 25, 1472908d778SJames Bottomley SAS_PRIM_OPEN_RJCT = 26, 1482908d778SJames Bottomley SAS_PRIM_OPEN_ACPT = 27, 1492908d778SJames Bottomley 1502908d778SJames Bottomley SAS_PRIM_DONE = 28, 1512908d778SJames Bottomley SAS_PRIM_BREAK = 29, 1522908d778SJames Bottomley 1532908d778SJames Bottomley SATA_PRIM_DMAT = 33, 1542908d778SJames Bottomley SATA_PRIM_PMNAK = 34, 1552908d778SJames Bottomley SATA_PRIM_PMACK = 35, 1562908d778SJames Bottomley SATA_PRIM_PMREQ_S = 36, 1572908d778SJames Bottomley SATA_PRIM_PMREQ_P = 37, 1582908d778SJames Bottomley SATA_SATA_R_ERR = 38, 1592908d778SJames Bottomley }; 1602908d778SJames Bottomley 1612908d778SJames Bottomley enum sas_open_rej_reason { 1622908d778SJames Bottomley /* Abandon open */ 1632908d778SJames Bottomley SAS_OREJ_UNKNOWN = 0, 1642908d778SJames Bottomley SAS_OREJ_BAD_DEST = 1, 1652908d778SJames Bottomley SAS_OREJ_CONN_RATE = 2, 1662908d778SJames Bottomley SAS_OREJ_EPROTO = 3, 1672908d778SJames Bottomley SAS_OREJ_RESV_AB0 = 4, 1682908d778SJames Bottomley SAS_OREJ_RESV_AB1 = 5, 1692908d778SJames Bottomley SAS_OREJ_RESV_AB2 = 6, 1702908d778SJames Bottomley SAS_OREJ_RESV_AB3 = 7, 1712908d778SJames Bottomley SAS_OREJ_WRONG_DEST= 8, 1722908d778SJames Bottomley SAS_OREJ_STP_NORES = 9, 1732908d778SJames Bottomley 1742908d778SJames Bottomley /* Retry open */ 1752908d778SJames Bottomley SAS_OREJ_NO_DEST = 10, 1762908d778SJames Bottomley SAS_OREJ_PATH_BLOCKED = 11, 1772908d778SJames Bottomley SAS_OREJ_RSVD_CONT0 = 12, 1782908d778SJames Bottomley SAS_OREJ_RSVD_CONT1 = 13, 1792908d778SJames Bottomley SAS_OREJ_RSVD_INIT0 = 14, 1802908d778SJames Bottomley SAS_OREJ_RSVD_INIT1 = 15, 1812908d778SJames Bottomley SAS_OREJ_RSVD_STOP0 = 16, 1822908d778SJames Bottomley SAS_OREJ_RSVD_STOP1 = 17, 1832908d778SJames Bottomley SAS_OREJ_RSVD_RETRY = 18, 1842908d778SJames Bottomley }; 1852908d778SJames Bottomley 1868ec6552fSDan Williams enum sas_gpio_reg_type { 1878ec6552fSDan Williams SAS_GPIO_REG_CFG = 0, 1888ec6552fSDan Williams SAS_GPIO_REG_RX = 1, 1898ec6552fSDan Williams SAS_GPIO_REG_RX_GP = 2, 1908ec6552fSDan Williams SAS_GPIO_REG_TX = 3, 1918ec6552fSDan Williams SAS_GPIO_REG_TX_GP = 4, 1928ec6552fSDan Williams }; 1938ec6552fSDan Williams 1942908d778SJames Bottomley struct dev_to_host_fis { 1952908d778SJames Bottomley u8 fis_type; /* 0x34 */ 1962908d778SJames Bottomley u8 flags; 1972908d778SJames Bottomley u8 status; 1982908d778SJames Bottomley u8 error; 1992908d778SJames Bottomley 2002908d778SJames Bottomley u8 lbal; 2012908d778SJames Bottomley union { u8 lbam; u8 byte_count_low; }; 2022908d778SJames Bottomley union { u8 lbah; u8 byte_count_high; }; 2032908d778SJames Bottomley u8 device; 2042908d778SJames Bottomley 2052908d778SJames Bottomley u8 lbal_exp; 2062908d778SJames Bottomley u8 lbam_exp; 2072908d778SJames Bottomley u8 lbah_exp; 2082908d778SJames Bottomley u8 _r_a; 2092908d778SJames Bottomley 2102908d778SJames Bottomley union { u8 sector_count; u8 interrupt_reason; }; 2112908d778SJames Bottomley u8 sector_count_exp; 2122908d778SJames Bottomley u8 _r_b; 2132908d778SJames Bottomley u8 _r_c; 2142908d778SJames Bottomley 2152908d778SJames Bottomley u32 _r_d; 2162908d778SJames Bottomley } __attribute__ ((packed)); 2172908d778SJames Bottomley 2182908d778SJames Bottomley struct host_to_dev_fis { 2192908d778SJames Bottomley u8 fis_type; /* 0x27 */ 2202908d778SJames Bottomley u8 flags; 2212908d778SJames Bottomley u8 command; 2222908d778SJames Bottomley u8 features; 2232908d778SJames Bottomley 2242908d778SJames Bottomley u8 lbal; 2252908d778SJames Bottomley union { u8 lbam; u8 byte_count_low; }; 2262908d778SJames Bottomley union { u8 lbah; u8 byte_count_high; }; 2272908d778SJames Bottomley u8 device; 2282908d778SJames Bottomley 2292908d778SJames Bottomley u8 lbal_exp; 2302908d778SJames Bottomley u8 lbam_exp; 2312908d778SJames Bottomley u8 lbah_exp; 2322908d778SJames Bottomley u8 features_exp; 2332908d778SJames Bottomley 2342908d778SJames Bottomley union { u8 sector_count; u8 interrupt_reason; }; 2352908d778SJames Bottomley u8 sector_count_exp; 2362908d778SJames Bottomley u8 _r_a; 2372908d778SJames Bottomley u8 control; 2382908d778SJames Bottomley 2392908d778SJames Bottomley u32 _r_b; 2402908d778SJames Bottomley } __attribute__ ((packed)); 2412908d778SJames Bottomley 2422908d778SJames Bottomley /* Prefer to have code clarity over header file clarity. 2432908d778SJames Bottomley */ 2442908d778SJames Bottomley #ifdef __LITTLE_ENDIAN_BITFIELD 2452908d778SJames Bottomley struct sas_identify_frame { 2462908d778SJames Bottomley /* Byte 0 */ 2472908d778SJames Bottomley u8 frame_type:4; 2482908d778SJames Bottomley u8 dev_type:3; 2492908d778SJames Bottomley u8 _un0:1; 2502908d778SJames Bottomley 2512908d778SJames Bottomley /* Byte 1 */ 2522908d778SJames Bottomley u8 _un1; 2532908d778SJames Bottomley 2542908d778SJames Bottomley /* Byte 2 */ 2552908d778SJames Bottomley union { 2562908d778SJames Bottomley struct { 2572908d778SJames Bottomley u8 _un20:1; 2582908d778SJames Bottomley u8 smp_iport:1; 2592908d778SJames Bottomley u8 stp_iport:1; 2602908d778SJames Bottomley u8 ssp_iport:1; 2612908d778SJames Bottomley u8 _un247:4; 2622908d778SJames Bottomley }; 2632908d778SJames Bottomley u8 initiator_bits; 2642908d778SJames Bottomley }; 2652908d778SJames Bottomley 2662908d778SJames Bottomley /* Byte 3 */ 2672908d778SJames Bottomley union { 2682908d778SJames Bottomley struct { 2692908d778SJames Bottomley u8 _un30:1; 2702908d778SJames Bottomley u8 smp_tport:1; 2712908d778SJames Bottomley u8 stp_tport:1; 2722908d778SJames Bottomley u8 ssp_tport:1; 2732908d778SJames Bottomley u8 _un347:4; 2742908d778SJames Bottomley }; 2752908d778SJames Bottomley u8 target_bits; 2762908d778SJames Bottomley }; 2772908d778SJames Bottomley 2782908d778SJames Bottomley /* Byte 4 - 11 */ 2792908d778SJames Bottomley u8 _un4_11[8]; 2802908d778SJames Bottomley 2812908d778SJames Bottomley /* Byte 12 - 19 */ 2822908d778SJames Bottomley u8 sas_addr[SAS_ADDR_SIZE]; 2832908d778SJames Bottomley 2842908d778SJames Bottomley /* Byte 20 */ 2852908d778SJames Bottomley u8 phy_id; 2862908d778SJames Bottomley 2872908d778SJames Bottomley u8 _un21_27[7]; 2882908d778SJames Bottomley 2892908d778SJames Bottomley __be32 crc; 2902908d778SJames Bottomley } __attribute__ ((packed)); 2912908d778SJames Bottomley 2922908d778SJames Bottomley struct ssp_frame_hdr { 2932908d778SJames Bottomley u8 frame_type; 2942908d778SJames Bottomley u8 hashed_dest_addr[HASHED_SAS_ADDR_SIZE]; 2952908d778SJames Bottomley u8 _r_a; 2962908d778SJames Bottomley u8 hashed_src_addr[HASHED_SAS_ADDR_SIZE]; 2972908d778SJames Bottomley __be16 _r_b; 2982908d778SJames Bottomley 2992908d778SJames Bottomley u8 changing_data_ptr:1; 3002908d778SJames Bottomley u8 retransmit:1; 3012908d778SJames Bottomley u8 retry_data_frames:1; 3022908d778SJames Bottomley u8 _r_c:5; 3032908d778SJames Bottomley 3042908d778SJames Bottomley u8 num_fill_bytes:2; 3052908d778SJames Bottomley u8 _r_d:6; 3062908d778SJames Bottomley 3072908d778SJames Bottomley u32 _r_e; 3082908d778SJames Bottomley __be16 tag; 3092908d778SJames Bottomley __be16 tptt; 3102908d778SJames Bottomley __be32 data_offs; 3112908d778SJames Bottomley } __attribute__ ((packed)); 3122908d778SJames Bottomley 3132908d778SJames Bottomley struct ssp_response_iu { 3142908d778SJames Bottomley u8 _r_a[10]; 3152908d778SJames Bottomley 3162908d778SJames Bottomley u8 datapres:2; 3172908d778SJames Bottomley u8 _r_b:6; 3182908d778SJames Bottomley 3192908d778SJames Bottomley u8 status; 3202908d778SJames Bottomley 3212908d778SJames Bottomley u32 _r_c; 3222908d778SJames Bottomley 3232908d778SJames Bottomley __be32 sense_data_len; 3242908d778SJames Bottomley __be32 response_data_len; 3252908d778SJames Bottomley 3262908d778SJames Bottomley u8 resp_data[0]; 32700b42b70SGustavo A. R. Silva u8 sense_data[]; 3282908d778SJames Bottomley } __attribute__ ((packed)); 3292908d778SJames Bottomley 330c15d75beSJohn Garry struct ssp_command_iu { 331c15d75beSJohn Garry u8 lun[8]; 332c15d75beSJohn Garry u8 _r_a; 333c15d75beSJohn Garry 334c15d75beSJohn Garry union { 335c15d75beSJohn Garry struct { 336c15d75beSJohn Garry u8 attr:3; 337c15d75beSJohn Garry u8 prio:4; 338c15d75beSJohn Garry u8 efb:1; 339c15d75beSJohn Garry }; 340c15d75beSJohn Garry u8 efb_prio_attr; 341c15d75beSJohn Garry }; 342c15d75beSJohn Garry 343c15d75beSJohn Garry u8 _r_b; 344c15d75beSJohn Garry 345c15d75beSJohn Garry u8 _r_c:2; 346c15d75beSJohn Garry u8 add_cdb_len:6; 347c15d75beSJohn Garry 348c15d75beSJohn Garry u8 cdb[16]; 34900b42b70SGustavo A. R. Silva u8 add_cdb[]; 350c15d75beSJohn Garry } __attribute__ ((packed)); 351c15d75beSJohn Garry 352c15d75beSJohn Garry struct xfer_rdy_iu { 353c15d75beSJohn Garry __be32 requested_offset; 354c15d75beSJohn Garry __be32 write_data_len; 355c15d75beSJohn Garry __be32 _r_a; 356c15d75beSJohn Garry } __attribute__ ((packed)); 357c15d75beSJohn Garry 358c15d75beSJohn Garry struct ssp_tmf_iu { 359c15d75beSJohn Garry u8 lun[8]; 360c15d75beSJohn Garry u16 _r_a; 361c15d75beSJohn Garry u8 tmf; 362c15d75beSJohn Garry u8 _r_b; 363c15d75beSJohn Garry __be16 tag; 364c15d75beSJohn Garry u8 _r_c[14]; 365c15d75beSJohn Garry } __attribute__ ((packed)); 366c15d75beSJohn Garry 3672908d778SJames Bottomley /* ---------- SMP ---------- */ 3682908d778SJames Bottomley 3692908d778SJames Bottomley struct report_general_resp { 3702908d778SJames Bottomley __be16 change_count; 3712908d778SJames Bottomley __be16 route_indexes; 3722908d778SJames Bottomley u8 _r_a; 3732908d778SJames Bottomley u8 num_phys; 3742908d778SJames Bottomley 3752908d778SJames Bottomley u8 conf_route_table:1; 3762908d778SJames Bottomley u8 configuring:1; 377ffaac8f4SLuben Tuikov u8 config_others:1; 378ffaac8f4SLuben Tuikov u8 orej_retry_supp:1; 379ffaac8f4SLuben Tuikov u8 stp_cont_awt:1; 380ffaac8f4SLuben Tuikov u8 self_config:1; 381ffaac8f4SLuben Tuikov u8 zone_config:1; 382ffaac8f4SLuben Tuikov u8 t2t_supp:1; 3832908d778SJames Bottomley 3842908d778SJames Bottomley u8 _r_c; 3852908d778SJames Bottomley 3862908d778SJames Bottomley u8 enclosure_logical_id[8]; 3872908d778SJames Bottomley 3882908d778SJames Bottomley u8 _r_d[12]; 3892908d778SJames Bottomley } __attribute__ ((packed)); 3902908d778SJames Bottomley 3912908d778SJames Bottomley struct discover_resp { 3922908d778SJames Bottomley u8 _r_a[5]; 3932908d778SJames Bottomley 3942908d778SJames Bottomley u8 phy_id; 3952908d778SJames Bottomley __be16 _r_b; 3962908d778SJames Bottomley 3972908d778SJames Bottomley u8 _r_c:4; 3982908d778SJames Bottomley u8 attached_dev_type:3; 3992908d778SJames Bottomley u8 _r_d:1; 4002908d778SJames Bottomley 4012908d778SJames Bottomley u8 linkrate:4; 4022908d778SJames Bottomley u8 _r_e:4; 4032908d778SJames Bottomley 4042908d778SJames Bottomley u8 attached_sata_host:1; 4052908d778SJames Bottomley u8 iproto:3; 4062908d778SJames Bottomley u8 _r_f:4; 4072908d778SJames Bottomley 4082908d778SJames Bottomley u8 attached_sata_dev:1; 4092908d778SJames Bottomley u8 tproto:3; 4102908d778SJames Bottomley u8 _r_g:3; 4112908d778SJames Bottomley u8 attached_sata_ps:1; 4122908d778SJames Bottomley 4132908d778SJames Bottomley u8 sas_addr[8]; 4142908d778SJames Bottomley u8 attached_sas_addr[8]; 4152908d778SJames Bottomley u8 attached_phy_id; 4162908d778SJames Bottomley 4172908d778SJames Bottomley u8 _r_h[7]; 4182908d778SJames Bottomley 4192908d778SJames Bottomley u8 hmin_linkrate:4; 4202908d778SJames Bottomley u8 pmin_linkrate:4; 4212908d778SJames Bottomley u8 hmax_linkrate:4; 4222908d778SJames Bottomley u8 pmax_linkrate:4; 4232908d778SJames Bottomley 4242908d778SJames Bottomley u8 change_count; 4252908d778SJames Bottomley 4262908d778SJames Bottomley u8 pptv:4; 4272908d778SJames Bottomley u8 _r_i:3; 4282908d778SJames Bottomley u8 virtual:1; 4292908d778SJames Bottomley 4302908d778SJames Bottomley u8 routing_attr:4; 4312908d778SJames Bottomley u8 _r_j:4; 4322908d778SJames Bottomley 4332908d778SJames Bottomley u8 conn_type; 4342908d778SJames Bottomley u8 conn_el_index; 4352908d778SJames Bottomley u8 conn_phy_link; 4362908d778SJames Bottomley 4372908d778SJames Bottomley u8 _r_k[8]; 4382908d778SJames Bottomley } __attribute__ ((packed)); 4392908d778SJames Bottomley 4402908d778SJames Bottomley struct report_phy_sata_resp { 4412908d778SJames Bottomley u8 _r_a[5]; 4422908d778SJames Bottomley 4432908d778SJames Bottomley u8 phy_id; 4442908d778SJames Bottomley u8 _r_b; 4452908d778SJames Bottomley 4462908d778SJames Bottomley u8 affil_valid:1; 4472908d778SJames Bottomley u8 affil_supp:1; 4482908d778SJames Bottomley u8 _r_c:6; 4492908d778SJames Bottomley 4502908d778SJames Bottomley u32 _r_d; 4512908d778SJames Bottomley 4522908d778SJames Bottomley u8 stp_sas_addr[8]; 4532908d778SJames Bottomley 4542908d778SJames Bottomley struct dev_to_host_fis fis; 4552908d778SJames Bottomley 4562908d778SJames Bottomley u32 _r_e; 4572908d778SJames Bottomley 4582908d778SJames Bottomley u8 affil_stp_ini_addr[8]; 4592908d778SJames Bottomley 4602908d778SJames Bottomley __be32 crc; 4612908d778SJames Bottomley } __attribute__ ((packed)); 4622908d778SJames Bottomley 4632908d778SJames Bottomley struct smp_resp { 4642908d778SJames Bottomley u8 frame_type; 4652908d778SJames Bottomley u8 function; 4662908d778SJames Bottomley u8 result; 4672908d778SJames Bottomley u8 reserved; 4682908d778SJames Bottomley union { 4692908d778SJames Bottomley struct report_general_resp rg; 4702908d778SJames Bottomley struct discover_resp disc; 4712908d778SJames Bottomley struct report_phy_sata_resp rps; 4722908d778SJames Bottomley }; 4732908d778SJames Bottomley } __attribute__ ((packed)); 4742908d778SJames Bottomley 4752908d778SJames Bottomley #elif defined(__BIG_ENDIAN_BITFIELD) 4762908d778SJames Bottomley struct sas_identify_frame { 4772908d778SJames Bottomley /* Byte 0 */ 4782908d778SJames Bottomley u8 _un0:1; 4792908d778SJames Bottomley u8 dev_type:3; 4802908d778SJames Bottomley u8 frame_type:4; 4812908d778SJames Bottomley 4822908d778SJames Bottomley /* Byte 1 */ 4832908d778SJames Bottomley u8 _un1; 4842908d778SJames Bottomley 4852908d778SJames Bottomley /* Byte 2 */ 4862908d778SJames Bottomley union { 4872908d778SJames Bottomley struct { 4882908d778SJames Bottomley u8 _un247:4; 4892908d778SJames Bottomley u8 ssp_iport:1; 4902908d778SJames Bottomley u8 stp_iport:1; 4912908d778SJames Bottomley u8 smp_iport:1; 4922908d778SJames Bottomley u8 _un20:1; 4932908d778SJames Bottomley }; 4942908d778SJames Bottomley u8 initiator_bits; 4952908d778SJames Bottomley }; 4962908d778SJames Bottomley 4972908d778SJames Bottomley /* Byte 3 */ 4982908d778SJames Bottomley union { 4992908d778SJames Bottomley struct { 5002908d778SJames Bottomley u8 _un347:4; 5012908d778SJames Bottomley u8 ssp_tport:1; 5022908d778SJames Bottomley u8 stp_tport:1; 5032908d778SJames Bottomley u8 smp_tport:1; 5042908d778SJames Bottomley u8 _un30:1; 5052908d778SJames Bottomley }; 5062908d778SJames Bottomley u8 target_bits; 5072908d778SJames Bottomley }; 5082908d778SJames Bottomley 5092908d778SJames Bottomley /* Byte 4 - 11 */ 5102908d778SJames Bottomley u8 _un4_11[8]; 5112908d778SJames Bottomley 5122908d778SJames Bottomley /* Byte 12 - 19 */ 5132908d778SJames Bottomley u8 sas_addr[SAS_ADDR_SIZE]; 5142908d778SJames Bottomley 5152908d778SJames Bottomley /* Byte 20 */ 5162908d778SJames Bottomley u8 phy_id; 5172908d778SJames Bottomley 5182908d778SJames Bottomley u8 _un21_27[7]; 5192908d778SJames Bottomley 5202908d778SJames Bottomley __be32 crc; 5212908d778SJames Bottomley } __attribute__ ((packed)); 5222908d778SJames Bottomley 5232908d778SJames Bottomley struct ssp_frame_hdr { 5242908d778SJames Bottomley u8 frame_type; 5252908d778SJames Bottomley u8 hashed_dest_addr[HASHED_SAS_ADDR_SIZE]; 5262908d778SJames Bottomley u8 _r_a; 5272908d778SJames Bottomley u8 hashed_src_addr[HASHED_SAS_ADDR_SIZE]; 5282908d778SJames Bottomley __be16 _r_b; 5292908d778SJames Bottomley 5302908d778SJames Bottomley u8 _r_c:5; 5312908d778SJames Bottomley u8 retry_data_frames:1; 5322908d778SJames Bottomley u8 retransmit:1; 5332908d778SJames Bottomley u8 changing_data_ptr:1; 5342908d778SJames Bottomley 5352908d778SJames Bottomley u8 _r_d:6; 5362908d778SJames Bottomley u8 num_fill_bytes:2; 5372908d778SJames Bottomley 5382908d778SJames Bottomley u32 _r_e; 5392908d778SJames Bottomley __be16 tag; 5402908d778SJames Bottomley __be16 tptt; 5412908d778SJames Bottomley __be32 data_offs; 5422908d778SJames Bottomley } __attribute__ ((packed)); 5432908d778SJames Bottomley 5442908d778SJames Bottomley struct ssp_response_iu { 5452908d778SJames Bottomley u8 _r_a[10]; 5462908d778SJames Bottomley 5472908d778SJames Bottomley u8 _r_b:6; 5482908d778SJames Bottomley u8 datapres:2; 5492908d778SJames Bottomley 5502908d778SJames Bottomley u8 status; 5512908d778SJames Bottomley 5522908d778SJames Bottomley u32 _r_c; 5532908d778SJames Bottomley 5542908d778SJames Bottomley __be32 sense_data_len; 5552908d778SJames Bottomley __be32 response_data_len; 5562908d778SJames Bottomley 5572908d778SJames Bottomley u8 resp_data[0]; 55800b42b70SGustavo A. R. Silva u8 sense_data[]; 5592908d778SJames Bottomley } __attribute__ ((packed)); 5602908d778SJames Bottomley 561c15d75beSJohn Garry struct ssp_command_iu { 562c15d75beSJohn Garry u8 lun[8]; 563c15d75beSJohn Garry u8 _r_a; 564c15d75beSJohn Garry 565c15d75beSJohn Garry union { 566c15d75beSJohn Garry struct { 567c15d75beSJohn Garry u8 efb:1; 568c15d75beSJohn Garry u8 prio:4; 569c15d75beSJohn Garry u8 attr:3; 570c15d75beSJohn Garry }; 571c15d75beSJohn Garry u8 efb_prio_attr; 572c15d75beSJohn Garry }; 573c15d75beSJohn Garry 574c15d75beSJohn Garry u8 _r_b; 575c15d75beSJohn Garry 576c15d75beSJohn Garry u8 add_cdb_len:6; 577c15d75beSJohn Garry u8 _r_c:2; 578c15d75beSJohn Garry 579c15d75beSJohn Garry u8 cdb[16]; 58000b42b70SGustavo A. R. Silva u8 add_cdb[]; 581c15d75beSJohn Garry } __attribute__ ((packed)); 582c15d75beSJohn Garry 583c15d75beSJohn Garry struct xfer_rdy_iu { 584c15d75beSJohn Garry __be32 requested_offset; 585c15d75beSJohn Garry __be32 write_data_len; 586c15d75beSJohn Garry __be32 _r_a; 587c15d75beSJohn Garry } __attribute__ ((packed)); 588c15d75beSJohn Garry 589c15d75beSJohn Garry struct ssp_tmf_iu { 590c15d75beSJohn Garry u8 lun[8]; 591c15d75beSJohn Garry u16 _r_a; 592c15d75beSJohn Garry u8 tmf; 593c15d75beSJohn Garry u8 _r_b; 594c15d75beSJohn Garry __be16 tag; 595c15d75beSJohn Garry u8 _r_c[14]; 596c15d75beSJohn Garry } __attribute__ ((packed)); 597c15d75beSJohn Garry 5982908d778SJames Bottomley /* ---------- SMP ---------- */ 5992908d778SJames Bottomley 6002908d778SJames Bottomley struct report_general_resp { 6012908d778SJames Bottomley __be16 change_count; 6022908d778SJames Bottomley __be16 route_indexes; 6032908d778SJames Bottomley u8 _r_a; 6042908d778SJames Bottomley u8 num_phys; 6052908d778SJames Bottomley 606ffaac8f4SLuben Tuikov u8 t2t_supp:1; 607ffaac8f4SLuben Tuikov u8 zone_config:1; 608ffaac8f4SLuben Tuikov u8 self_config:1; 609ffaac8f4SLuben Tuikov u8 stp_cont_awt:1; 610ffaac8f4SLuben Tuikov u8 orej_retry_supp:1; 611ffaac8f4SLuben Tuikov u8 config_others:1; 6122908d778SJames Bottomley u8 configuring:1; 6132908d778SJames Bottomley u8 conf_route_table:1; 6142908d778SJames Bottomley 6152908d778SJames Bottomley u8 _r_c; 6162908d778SJames Bottomley 6172908d778SJames Bottomley u8 enclosure_logical_id[8]; 6182908d778SJames Bottomley 6192908d778SJames Bottomley u8 _r_d[12]; 6202908d778SJames Bottomley } __attribute__ ((packed)); 6212908d778SJames Bottomley 6222908d778SJames Bottomley struct discover_resp { 6232908d778SJames Bottomley u8 _r_a[5]; 6242908d778SJames Bottomley 6252908d778SJames Bottomley u8 phy_id; 6262908d778SJames Bottomley __be16 _r_b; 6272908d778SJames Bottomley 6282908d778SJames Bottomley u8 _r_d:1; 6292908d778SJames Bottomley u8 attached_dev_type:3; 6302908d778SJames Bottomley u8 _r_c:4; 6312908d778SJames Bottomley 6322908d778SJames Bottomley u8 _r_e:4; 6332908d778SJames Bottomley u8 linkrate:4; 6342908d778SJames Bottomley 6352908d778SJames Bottomley u8 _r_f:4; 6362908d778SJames Bottomley u8 iproto:3; 6372908d778SJames Bottomley u8 attached_sata_host:1; 6382908d778SJames Bottomley 6392908d778SJames Bottomley u8 attached_sata_ps:1; 6402908d778SJames Bottomley u8 _r_g:3; 6412908d778SJames Bottomley u8 tproto:3; 6422908d778SJames Bottomley u8 attached_sata_dev:1; 6432908d778SJames Bottomley 6442908d778SJames Bottomley u8 sas_addr[8]; 6452908d778SJames Bottomley u8 attached_sas_addr[8]; 6462908d778SJames Bottomley u8 attached_phy_id; 6472908d778SJames Bottomley 6482908d778SJames Bottomley u8 _r_h[7]; 6492908d778SJames Bottomley 6502908d778SJames Bottomley u8 pmin_linkrate:4; 6512908d778SJames Bottomley u8 hmin_linkrate:4; 6522908d778SJames Bottomley u8 pmax_linkrate:4; 6532908d778SJames Bottomley u8 hmax_linkrate:4; 6542908d778SJames Bottomley 6552908d778SJames Bottomley u8 change_count; 6562908d778SJames Bottomley 6572908d778SJames Bottomley u8 virtual:1; 6582908d778SJames Bottomley u8 _r_i:3; 6592908d778SJames Bottomley u8 pptv:4; 6602908d778SJames Bottomley 6612908d778SJames Bottomley u8 _r_j:4; 6622908d778SJames Bottomley u8 routing_attr:4; 6632908d778SJames Bottomley 6642908d778SJames Bottomley u8 conn_type; 6652908d778SJames Bottomley u8 conn_el_index; 6662908d778SJames Bottomley u8 conn_phy_link; 6672908d778SJames Bottomley 6682908d778SJames Bottomley u8 _r_k[8]; 6692908d778SJames Bottomley } __attribute__ ((packed)); 6702908d778SJames Bottomley 6712908d778SJames Bottomley struct report_phy_sata_resp { 6722908d778SJames Bottomley u8 _r_a[5]; 6732908d778SJames Bottomley 6742908d778SJames Bottomley u8 phy_id; 6752908d778SJames Bottomley u8 _r_b; 6762908d778SJames Bottomley 6772908d778SJames Bottomley u8 _r_c:6; 6782908d778SJames Bottomley u8 affil_supp:1; 6792908d778SJames Bottomley u8 affil_valid:1; 6802908d778SJames Bottomley 6812908d778SJames Bottomley u32 _r_d; 6822908d778SJames Bottomley 6832908d778SJames Bottomley u8 stp_sas_addr[8]; 6842908d778SJames Bottomley 6852908d778SJames Bottomley struct dev_to_host_fis fis; 6862908d778SJames Bottomley 6872908d778SJames Bottomley u32 _r_e; 6882908d778SJames Bottomley 6892908d778SJames Bottomley u8 affil_stp_ini_addr[8]; 6902908d778SJames Bottomley 6912908d778SJames Bottomley __be32 crc; 6922908d778SJames Bottomley } __attribute__ ((packed)); 6932908d778SJames Bottomley 6942908d778SJames Bottomley struct smp_resp { 6952908d778SJames Bottomley u8 frame_type; 6962908d778SJames Bottomley u8 function; 6972908d778SJames Bottomley u8 result; 6982908d778SJames Bottomley u8 reserved; 6992908d778SJames Bottomley union { 7002908d778SJames Bottomley struct report_general_resp rg; 7012908d778SJames Bottomley struct discover_resp disc; 7022908d778SJames Bottomley struct report_phy_sata_resp rps; 7032908d778SJames Bottomley }; 7042908d778SJames Bottomley } __attribute__ ((packed)); 7052908d778SJames Bottomley 7062908d778SJames Bottomley #else 7072908d778SJames Bottomley #error "Bitfield order not defined!" 7082908d778SJames Bottomley #endif 7092908d778SJames Bottomley 7102908d778SJames Bottomley #endif /* _SAS_H_ */ 711