xref: /openbmc/linux/include/scsi/sas.h (revision aa9f8328)
12908d778SJames Bottomley /*
22908d778SJames Bottomley  * SAS structures and definitions header file
32908d778SJames Bottomley  *
42908d778SJames Bottomley  * Copyright (C) 2005 Adaptec, Inc.  All rights reserved.
52908d778SJames Bottomley  * Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com>
62908d778SJames Bottomley  *
72908d778SJames Bottomley  * This file is licensed under GPLv2.
82908d778SJames Bottomley  *
92908d778SJames Bottomley  * This program is free software; you can redistribute it and/or
102908d778SJames Bottomley  * modify it under the terms of the GNU General Public License as
112908d778SJames Bottomley  * published by the Free Software Foundation; either version 2 of the
122908d778SJames Bottomley  * License, or (at your option) any later version.
132908d778SJames Bottomley  *
142908d778SJames Bottomley  * This program is distributed in the hope that it will be useful, but
152908d778SJames Bottomley  * WITHOUT ANY WARRANTY; without even the implied warranty of
162908d778SJames Bottomley  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
172908d778SJames Bottomley  * General Public License for more details.
182908d778SJames Bottomley  *
192908d778SJames Bottomley  * You should have received a copy of the GNU General Public License
202908d778SJames Bottomley  * along with this program; if not, write to the Free Software
212908d778SJames Bottomley  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
222908d778SJames Bottomley  * USA
232908d778SJames Bottomley  *
242908d778SJames Bottomley  */
252908d778SJames Bottomley 
262908d778SJames Bottomley #ifndef _SAS_H_
272908d778SJames Bottomley #define _SAS_H_
282908d778SJames Bottomley 
292908d778SJames Bottomley #include <linux/types.h>
302908d778SJames Bottomley #include <asm/byteorder.h>
312908d778SJames Bottomley 
322908d778SJames Bottomley #define SAS_ADDR_SIZE        8
332908d778SJames Bottomley #define HASHED_SAS_ADDR_SIZE 3
342908d778SJames Bottomley #define SAS_ADDR(_sa) ((unsigned long long) be64_to_cpu(*(__be64 *)(_sa)))
352908d778SJames Bottomley 
362908d778SJames Bottomley #define SMP_REQUEST             0x40
372908d778SJames Bottomley #define SMP_RESPONSE            0x41
382908d778SJames Bottomley 
392908d778SJames Bottomley #define SSP_DATA                0x01
402908d778SJames Bottomley #define SSP_XFER_RDY            0x05
412908d778SJames Bottomley #define SSP_COMMAND             0x06
422908d778SJames Bottomley #define SSP_RESPONSE            0x07
432908d778SJames Bottomley #define SSP_TASK                0x16
442908d778SJames Bottomley 
452908d778SJames Bottomley #define SMP_REPORT_GENERAL       0x00
462908d778SJames Bottomley #define SMP_REPORT_MANUF_INFO    0x01
472908d778SJames Bottomley #define SMP_READ_GPIO_REG        0x02
482908d778SJames Bottomley #define SMP_DISCOVER             0x10
492908d778SJames Bottomley #define SMP_REPORT_PHY_ERR_LOG   0x11
502908d778SJames Bottomley #define SMP_REPORT_PHY_SATA      0x12
512908d778SJames Bottomley #define SMP_REPORT_ROUTE_INFO    0x13
522908d778SJames Bottomley #define SMP_WRITE_GPIO_REG       0x82
532908d778SJames Bottomley #define SMP_CONF_ROUTE_INFO      0x90
542908d778SJames Bottomley #define SMP_PHY_CONTROL          0x91
552908d778SJames Bottomley #define SMP_PHY_TEST_FUNCTION    0x92
562908d778SJames Bottomley 
572908d778SJames Bottomley #define SMP_RESP_FUNC_ACC        0x00
582908d778SJames Bottomley #define SMP_RESP_FUNC_UNK        0x01
592908d778SJames Bottomley #define SMP_RESP_FUNC_FAILED     0x02
602908d778SJames Bottomley #define SMP_RESP_INV_FRM_LEN     0x03
612908d778SJames Bottomley #define SMP_RESP_NO_PHY          0x10
622908d778SJames Bottomley #define SMP_RESP_NO_INDEX        0x11
632908d778SJames Bottomley #define SMP_RESP_PHY_NO_SATA     0x12
642908d778SJames Bottomley #define SMP_RESP_PHY_UNK_OP      0x13
652908d778SJames Bottomley #define SMP_RESP_PHY_UNK_TESTF   0x14
662908d778SJames Bottomley #define SMP_RESP_PHY_TEST_INPROG 0x15
672908d778SJames Bottomley #define SMP_RESP_PHY_VACANT      0x16
682908d778SJames Bottomley 
692908d778SJames Bottomley /* SAM TMFs */
702908d778SJames Bottomley #define TMF_ABORT_TASK      0x01
712908d778SJames Bottomley #define TMF_ABORT_TASK_SET  0x02
722908d778SJames Bottomley #define TMF_CLEAR_TASK_SET  0x04
732908d778SJames Bottomley #define TMF_LU_RESET        0x08
742908d778SJames Bottomley #define TMF_CLEAR_ACA       0x40
752908d778SJames Bottomley #define TMF_QUERY_TASK      0x80
762908d778SJames Bottomley 
772908d778SJames Bottomley /* SAS TMF responses */
782908d778SJames Bottomley #define TMF_RESP_FUNC_COMPLETE   0x00
792908d778SJames Bottomley #define TMF_RESP_INVALID_FRAME   0x02
802908d778SJames Bottomley #define TMF_RESP_FUNC_ESUPP      0x04
812908d778SJames Bottomley #define TMF_RESP_FUNC_FAILED     0x05
822908d778SJames Bottomley #define TMF_RESP_FUNC_SUCC       0x08
832908d778SJames Bottomley #define TMF_RESP_NO_LUN          0x09
842908d778SJames Bottomley #define TMF_RESP_OVERLAPPED_TAG  0x0A
852908d778SJames Bottomley 
862908d778SJames Bottomley enum sas_oob_mode {
872908d778SJames Bottomley 	OOB_NOT_CONNECTED,
882908d778SJames Bottomley 	SATA_OOB_MODE,
892908d778SJames Bottomley 	SAS_OOB_MODE
902908d778SJames Bottomley };
912908d778SJames Bottomley 
92354cf829SDan Williams /* See sas_discover.c if you plan on changing these */
93aa9f8328SJames Bottomley enum sas_device_type {
94aa9f8328SJames Bottomley 	/* these are SAS protocol defined (attached device type field) */
95aa9f8328SJames Bottomley 	SAS_PHY_UNUSED = 0,
96aa9f8328SJames Bottomley 	SAS_END_DEVICE = 1,
97aa9f8328SJames Bottomley 	SAS_EDGE_EXPANDER_DEVICE = 2,
98aa9f8328SJames Bottomley 	SAS_FANOUT_EXPANDER_DEVICE = 3,
99aa9f8328SJames Bottomley 	/* these are internal to libsas */
1002908d778SJames Bottomley 	SAS_HA = 4,
101aa9f8328SJames Bottomley 	SAS_SATA_DEV = 5,
102aa9f8328SJames Bottomley 	SAS_SATA_PM = 7,
103aa9f8328SJames Bottomley 	SAS_SATA_PM_PORT = 8,
104aa9f8328SJames Bottomley 	SAS_SATA_PENDING = 9,
1052908d778SJames Bottomley };
1062908d778SJames Bottomley 
1075929faf3SDarrick J. Wong enum sas_protocol {
108c79dd80dSDan Williams 	SAS_PROTOCOL_NONE		= 0,
1095929faf3SDarrick J. Wong 	SAS_PROTOCOL_SATA		= 0x01,
1105929faf3SDarrick J. Wong 	SAS_PROTOCOL_SMP		= 0x02,
1115929faf3SDarrick J. Wong 	SAS_PROTOCOL_STP		= 0x04,
1125929faf3SDarrick J. Wong 	SAS_PROTOCOL_SSP		= 0x08,
1135929faf3SDarrick J. Wong 	SAS_PROTOCOL_ALL		= 0x0E,
11405a2a173SDan Williams 	SAS_PROTOCOL_STP_ALL		= SAS_PROTOCOL_STP|SAS_PROTOCOL_SATA,
1152908d778SJames Bottomley };
1162908d778SJames Bottomley 
1172908d778SJames Bottomley /* From the spec; local phys only */
1182908d778SJames Bottomley enum phy_func {
1192908d778SJames Bottomley 	PHY_FUNC_NOP,
1202908d778SJames Bottomley 	PHY_FUNC_LINK_RESET,		  /* Enables the phy */
1212908d778SJames Bottomley 	PHY_FUNC_HARD_RESET,
1222908d778SJames Bottomley 	PHY_FUNC_DISABLE,
1232908d778SJames Bottomley 	PHY_FUNC_CLEAR_ERROR_LOG = 5,
1242908d778SJames Bottomley 	PHY_FUNC_CLEAR_AFFIL,
1252908d778SJames Bottomley 	PHY_FUNC_TX_SATA_PS_SIGNAL,
1262908d778SJames Bottomley 	PHY_FUNC_RELEASE_SPINUP_HOLD = 0x10, /* LOCAL PORT ONLY! */
127a01e70e5SJames Bottomley 	PHY_FUNC_SET_LINK_RATE,
128ac013ed1SDan Williams 	PHY_FUNC_GET_EVENTS,
1292908d778SJames Bottomley };
1302908d778SJames Bottomley 
1312908d778SJames Bottomley /* SAS LLDD would need to report only _very_few_ of those, like BROADCAST.
1322908d778SJames Bottomley  * Most of those are here for completeness.
1332908d778SJames Bottomley  */
1342908d778SJames Bottomley enum sas_prim {
1352908d778SJames Bottomley 	SAS_PRIM_AIP_NORMAL = 1,
1362908d778SJames Bottomley 	SAS_PRIM_AIP_R0     = 2,
1372908d778SJames Bottomley 	SAS_PRIM_AIP_R1     = 3,
1382908d778SJames Bottomley 	SAS_PRIM_AIP_R2     = 4,
1392908d778SJames Bottomley 	SAS_PRIM_AIP_WC     = 5,
1402908d778SJames Bottomley 	SAS_PRIM_AIP_WD     = 6,
1412908d778SJames Bottomley 	SAS_PRIM_AIP_WP     = 7,
1422908d778SJames Bottomley 	SAS_PRIM_AIP_RWP    = 8,
1432908d778SJames Bottomley 
1442908d778SJames Bottomley 	SAS_PRIM_BC_CH      = 9,
1452908d778SJames Bottomley 	SAS_PRIM_BC_RCH0    = 10,
1462908d778SJames Bottomley 	SAS_PRIM_BC_RCH1    = 11,
1472908d778SJames Bottomley 	SAS_PRIM_BC_R0      = 12,
1482908d778SJames Bottomley 	SAS_PRIM_BC_R1      = 13,
1492908d778SJames Bottomley 	SAS_PRIM_BC_R2      = 14,
1502908d778SJames Bottomley 	SAS_PRIM_BC_R3      = 15,
1512908d778SJames Bottomley 	SAS_PRIM_BC_R4      = 16,
1522908d778SJames Bottomley 
1532908d778SJames Bottomley 	SAS_PRIM_NOTIFY_ENSP= 17,
1542908d778SJames Bottomley 	SAS_PRIM_NOTIFY_R0  = 18,
1552908d778SJames Bottomley 	SAS_PRIM_NOTIFY_R1  = 19,
1562908d778SJames Bottomley 	SAS_PRIM_NOTIFY_R2  = 20,
1572908d778SJames Bottomley 
1582908d778SJames Bottomley 	SAS_PRIM_CLOSE_CLAF = 21,
1592908d778SJames Bottomley 	SAS_PRIM_CLOSE_NORM = 22,
1602908d778SJames Bottomley 	SAS_PRIM_CLOSE_R0   = 23,
1612908d778SJames Bottomley 	SAS_PRIM_CLOSE_R1   = 24,
1622908d778SJames Bottomley 
1632908d778SJames Bottomley 	SAS_PRIM_OPEN_RTRY  = 25,
1642908d778SJames Bottomley 	SAS_PRIM_OPEN_RJCT  = 26,
1652908d778SJames Bottomley 	SAS_PRIM_OPEN_ACPT  = 27,
1662908d778SJames Bottomley 
1672908d778SJames Bottomley 	SAS_PRIM_DONE       = 28,
1682908d778SJames Bottomley 	SAS_PRIM_BREAK      = 29,
1692908d778SJames Bottomley 
1702908d778SJames Bottomley 	SATA_PRIM_DMAT      = 33,
1712908d778SJames Bottomley 	SATA_PRIM_PMNAK     = 34,
1722908d778SJames Bottomley 	SATA_PRIM_PMACK     = 35,
1732908d778SJames Bottomley 	SATA_PRIM_PMREQ_S   = 36,
1742908d778SJames Bottomley 	SATA_PRIM_PMREQ_P   = 37,
1752908d778SJames Bottomley 	SATA_SATA_R_ERR     = 38,
1762908d778SJames Bottomley };
1772908d778SJames Bottomley 
1782908d778SJames Bottomley enum sas_open_rej_reason {
1792908d778SJames Bottomley 	/* Abandon open */
1802908d778SJames Bottomley 	SAS_OREJ_UNKNOWN   = 0,
1812908d778SJames Bottomley 	SAS_OREJ_BAD_DEST  = 1,
1822908d778SJames Bottomley 	SAS_OREJ_CONN_RATE = 2,
1832908d778SJames Bottomley 	SAS_OREJ_EPROTO    = 3,
1842908d778SJames Bottomley 	SAS_OREJ_RESV_AB0  = 4,
1852908d778SJames Bottomley 	SAS_OREJ_RESV_AB1  = 5,
1862908d778SJames Bottomley 	SAS_OREJ_RESV_AB2  = 6,
1872908d778SJames Bottomley 	SAS_OREJ_RESV_AB3  = 7,
1882908d778SJames Bottomley 	SAS_OREJ_WRONG_DEST= 8,
1892908d778SJames Bottomley 	SAS_OREJ_STP_NORES = 9,
1902908d778SJames Bottomley 
1912908d778SJames Bottomley 	/* Retry open */
1922908d778SJames Bottomley 	SAS_OREJ_NO_DEST   = 10,
1932908d778SJames Bottomley 	SAS_OREJ_PATH_BLOCKED = 11,
1942908d778SJames Bottomley 	SAS_OREJ_RSVD_CONT0 = 12,
1952908d778SJames Bottomley 	SAS_OREJ_RSVD_CONT1 = 13,
1962908d778SJames Bottomley 	SAS_OREJ_RSVD_INIT0 = 14,
1972908d778SJames Bottomley 	SAS_OREJ_RSVD_INIT1 = 15,
1982908d778SJames Bottomley 	SAS_OREJ_RSVD_STOP0 = 16,
1992908d778SJames Bottomley 	SAS_OREJ_RSVD_STOP1 = 17,
2002908d778SJames Bottomley 	SAS_OREJ_RSVD_RETRY = 18,
2012908d778SJames Bottomley };
2022908d778SJames Bottomley 
2038ec6552fSDan Williams enum sas_gpio_reg_type {
2048ec6552fSDan Williams 	SAS_GPIO_REG_CFG   = 0,
2058ec6552fSDan Williams 	SAS_GPIO_REG_RX    = 1,
2068ec6552fSDan Williams 	SAS_GPIO_REG_RX_GP = 2,
2078ec6552fSDan Williams 	SAS_GPIO_REG_TX    = 3,
2088ec6552fSDan Williams 	SAS_GPIO_REG_TX_GP = 4,
2098ec6552fSDan Williams };
2108ec6552fSDan Williams 
2112908d778SJames Bottomley struct  dev_to_host_fis {
2122908d778SJames Bottomley 	u8     fis_type;	  /* 0x34 */
2132908d778SJames Bottomley 	u8     flags;
2142908d778SJames Bottomley 	u8     status;
2152908d778SJames Bottomley 	u8     error;
2162908d778SJames Bottomley 
2172908d778SJames Bottomley 	u8     lbal;
2182908d778SJames Bottomley 	union { u8 lbam; u8 byte_count_low; };
2192908d778SJames Bottomley 	union { u8 lbah; u8 byte_count_high; };
2202908d778SJames Bottomley 	u8     device;
2212908d778SJames Bottomley 
2222908d778SJames Bottomley 	u8     lbal_exp;
2232908d778SJames Bottomley 	u8     lbam_exp;
2242908d778SJames Bottomley 	u8     lbah_exp;
2252908d778SJames Bottomley 	u8     _r_a;
2262908d778SJames Bottomley 
2272908d778SJames Bottomley 	union { u8  sector_count; u8 interrupt_reason; };
2282908d778SJames Bottomley 	u8     sector_count_exp;
2292908d778SJames Bottomley 	u8     _r_b;
2302908d778SJames Bottomley 	u8     _r_c;
2312908d778SJames Bottomley 
2322908d778SJames Bottomley 	u32    _r_d;
2332908d778SJames Bottomley } __attribute__ ((packed));
2342908d778SJames Bottomley 
2352908d778SJames Bottomley struct host_to_dev_fis {
2362908d778SJames Bottomley 	u8     fis_type;	  /* 0x27 */
2372908d778SJames Bottomley 	u8     flags;
2382908d778SJames Bottomley 	u8     command;
2392908d778SJames Bottomley 	u8     features;
2402908d778SJames Bottomley 
2412908d778SJames Bottomley 	u8     lbal;
2422908d778SJames Bottomley 	union { u8 lbam; u8 byte_count_low; };
2432908d778SJames Bottomley 	union { u8 lbah; u8 byte_count_high; };
2442908d778SJames Bottomley 	u8     device;
2452908d778SJames Bottomley 
2462908d778SJames Bottomley 	u8     lbal_exp;
2472908d778SJames Bottomley 	u8     lbam_exp;
2482908d778SJames Bottomley 	u8     lbah_exp;
2492908d778SJames Bottomley 	u8     features_exp;
2502908d778SJames Bottomley 
2512908d778SJames Bottomley 	union { u8  sector_count; u8 interrupt_reason; };
2522908d778SJames Bottomley 	u8     sector_count_exp;
2532908d778SJames Bottomley 	u8     _r_a;
2542908d778SJames Bottomley 	u8     control;
2552908d778SJames Bottomley 
2562908d778SJames Bottomley 	u32    _r_b;
2572908d778SJames Bottomley } __attribute__ ((packed));
2582908d778SJames Bottomley 
2592908d778SJames Bottomley /* Prefer to have code clarity over header file clarity.
2602908d778SJames Bottomley  */
2612908d778SJames Bottomley #ifdef __LITTLE_ENDIAN_BITFIELD
2622908d778SJames Bottomley struct sas_identify_frame {
2632908d778SJames Bottomley 	/* Byte 0 */
2642908d778SJames Bottomley 	u8  frame_type:4;
2652908d778SJames Bottomley 	u8  dev_type:3;
2662908d778SJames Bottomley 	u8  _un0:1;
2672908d778SJames Bottomley 
2682908d778SJames Bottomley 	/* Byte 1 */
2692908d778SJames Bottomley 	u8  _un1;
2702908d778SJames Bottomley 
2712908d778SJames Bottomley 	/* Byte 2 */
2722908d778SJames Bottomley 	union {
2732908d778SJames Bottomley 		struct {
2742908d778SJames Bottomley 			u8  _un20:1;
2752908d778SJames Bottomley 			u8  smp_iport:1;
2762908d778SJames Bottomley 			u8  stp_iport:1;
2772908d778SJames Bottomley 			u8  ssp_iport:1;
2782908d778SJames Bottomley 			u8  _un247:4;
2792908d778SJames Bottomley 		};
2802908d778SJames Bottomley 		u8 initiator_bits;
2812908d778SJames Bottomley 	};
2822908d778SJames Bottomley 
2832908d778SJames Bottomley 	/* Byte 3 */
2842908d778SJames Bottomley 	union {
2852908d778SJames Bottomley 		struct {
2862908d778SJames Bottomley 			u8  _un30:1;
2872908d778SJames Bottomley 			u8 smp_tport:1;
2882908d778SJames Bottomley 			u8 stp_tport:1;
2892908d778SJames Bottomley 			u8 ssp_tport:1;
2902908d778SJames Bottomley 			u8 _un347:4;
2912908d778SJames Bottomley 		};
2922908d778SJames Bottomley 		u8 target_bits;
2932908d778SJames Bottomley 	};
2942908d778SJames Bottomley 
2952908d778SJames Bottomley 	/* Byte 4 - 11 */
2962908d778SJames Bottomley 	u8 _un4_11[8];
2972908d778SJames Bottomley 
2982908d778SJames Bottomley 	/* Byte 12 - 19 */
2992908d778SJames Bottomley 	u8 sas_addr[SAS_ADDR_SIZE];
3002908d778SJames Bottomley 
3012908d778SJames Bottomley 	/* Byte 20 */
3022908d778SJames Bottomley 	u8 phy_id;
3032908d778SJames Bottomley 
3042908d778SJames Bottomley 	u8 _un21_27[7];
3052908d778SJames Bottomley 
3062908d778SJames Bottomley 	__be32 crc;
3072908d778SJames Bottomley } __attribute__ ((packed));
3082908d778SJames Bottomley 
3092908d778SJames Bottomley struct ssp_frame_hdr {
3102908d778SJames Bottomley 	u8     frame_type;
3112908d778SJames Bottomley 	u8     hashed_dest_addr[HASHED_SAS_ADDR_SIZE];
3122908d778SJames Bottomley 	u8     _r_a;
3132908d778SJames Bottomley 	u8     hashed_src_addr[HASHED_SAS_ADDR_SIZE];
3142908d778SJames Bottomley 	__be16 _r_b;
3152908d778SJames Bottomley 
3162908d778SJames Bottomley 	u8     changing_data_ptr:1;
3172908d778SJames Bottomley 	u8     retransmit:1;
3182908d778SJames Bottomley 	u8     retry_data_frames:1;
3192908d778SJames Bottomley 	u8     _r_c:5;
3202908d778SJames Bottomley 
3212908d778SJames Bottomley 	u8     num_fill_bytes:2;
3222908d778SJames Bottomley 	u8     _r_d:6;
3232908d778SJames Bottomley 
3242908d778SJames Bottomley 	u32    _r_e;
3252908d778SJames Bottomley 	__be16 tag;
3262908d778SJames Bottomley 	__be16 tptt;
3272908d778SJames Bottomley 	__be32 data_offs;
3282908d778SJames Bottomley } __attribute__ ((packed));
3292908d778SJames Bottomley 
3302908d778SJames Bottomley struct ssp_response_iu {
3312908d778SJames Bottomley 	u8     _r_a[10];
3322908d778SJames Bottomley 
3332908d778SJames Bottomley 	u8     datapres:2;
3342908d778SJames Bottomley 	u8     _r_b:6;
3352908d778SJames Bottomley 
3362908d778SJames Bottomley 	u8     status;
3372908d778SJames Bottomley 
3382908d778SJames Bottomley 	u32    _r_c;
3392908d778SJames Bottomley 
3402908d778SJames Bottomley 	__be32 sense_data_len;
3412908d778SJames Bottomley 	__be32 response_data_len;
3422908d778SJames Bottomley 
3432908d778SJames Bottomley 	u8     resp_data[0];
3442908d778SJames Bottomley 	u8     sense_data[0];
3452908d778SJames Bottomley } __attribute__ ((packed));
3462908d778SJames Bottomley 
3472908d778SJames Bottomley /* ---------- SMP ---------- */
3482908d778SJames Bottomley 
3492908d778SJames Bottomley struct report_general_resp {
3502908d778SJames Bottomley 	__be16  change_count;
3512908d778SJames Bottomley 	__be16  route_indexes;
3522908d778SJames Bottomley 	u8      _r_a;
3532908d778SJames Bottomley 	u8      num_phys;
3542908d778SJames Bottomley 
3552908d778SJames Bottomley 	u8      conf_route_table:1;
3562908d778SJames Bottomley 	u8      configuring:1;
357ffaac8f4SLuben Tuikov 	u8	config_others:1;
358ffaac8f4SLuben Tuikov 	u8	orej_retry_supp:1;
359ffaac8f4SLuben Tuikov 	u8	stp_cont_awt:1;
360ffaac8f4SLuben Tuikov 	u8	self_config:1;
361ffaac8f4SLuben Tuikov 	u8	zone_config:1;
362ffaac8f4SLuben Tuikov 	u8	t2t_supp:1;
3632908d778SJames Bottomley 
3642908d778SJames Bottomley 	u8      _r_c;
3652908d778SJames Bottomley 
3662908d778SJames Bottomley 	u8      enclosure_logical_id[8];
3672908d778SJames Bottomley 
3682908d778SJames Bottomley 	u8      _r_d[12];
3692908d778SJames Bottomley } __attribute__ ((packed));
3702908d778SJames Bottomley 
3712908d778SJames Bottomley struct discover_resp {
3722908d778SJames Bottomley 	u8    _r_a[5];
3732908d778SJames Bottomley 
3742908d778SJames Bottomley 	u8    phy_id;
3752908d778SJames Bottomley 	__be16 _r_b;
3762908d778SJames Bottomley 
3772908d778SJames Bottomley 	u8    _r_c:4;
3782908d778SJames Bottomley 	u8    attached_dev_type:3;
3792908d778SJames Bottomley 	u8    _r_d:1;
3802908d778SJames Bottomley 
3812908d778SJames Bottomley 	u8    linkrate:4;
3822908d778SJames Bottomley 	u8    _r_e:4;
3832908d778SJames Bottomley 
3842908d778SJames Bottomley 	u8    attached_sata_host:1;
3852908d778SJames Bottomley 	u8    iproto:3;
3862908d778SJames Bottomley 	u8    _r_f:4;
3872908d778SJames Bottomley 
3882908d778SJames Bottomley 	u8    attached_sata_dev:1;
3892908d778SJames Bottomley 	u8    tproto:3;
3902908d778SJames Bottomley 	u8    _r_g:3;
3912908d778SJames Bottomley 	u8    attached_sata_ps:1;
3922908d778SJames Bottomley 
3932908d778SJames Bottomley 	u8    sas_addr[8];
3942908d778SJames Bottomley 	u8    attached_sas_addr[8];
3952908d778SJames Bottomley 	u8    attached_phy_id;
3962908d778SJames Bottomley 
3972908d778SJames Bottomley 	u8    _r_h[7];
3982908d778SJames Bottomley 
3992908d778SJames Bottomley 	u8    hmin_linkrate:4;
4002908d778SJames Bottomley 	u8    pmin_linkrate:4;
4012908d778SJames Bottomley 	u8    hmax_linkrate:4;
4022908d778SJames Bottomley 	u8    pmax_linkrate:4;
4032908d778SJames Bottomley 
4042908d778SJames Bottomley 	u8    change_count;
4052908d778SJames Bottomley 
4062908d778SJames Bottomley 	u8    pptv:4;
4072908d778SJames Bottomley 	u8    _r_i:3;
4082908d778SJames Bottomley 	u8    virtual:1;
4092908d778SJames Bottomley 
4102908d778SJames Bottomley 	u8    routing_attr:4;
4112908d778SJames Bottomley 	u8    _r_j:4;
4122908d778SJames Bottomley 
4132908d778SJames Bottomley 	u8    conn_type;
4142908d778SJames Bottomley 	u8    conn_el_index;
4152908d778SJames Bottomley 	u8    conn_phy_link;
4162908d778SJames Bottomley 
4172908d778SJames Bottomley 	u8    _r_k[8];
4182908d778SJames Bottomley } __attribute__ ((packed));
4192908d778SJames Bottomley 
4202908d778SJames Bottomley struct report_phy_sata_resp {
4212908d778SJames Bottomley 	u8    _r_a[5];
4222908d778SJames Bottomley 
4232908d778SJames Bottomley 	u8    phy_id;
4242908d778SJames Bottomley 	u8    _r_b;
4252908d778SJames Bottomley 
4262908d778SJames Bottomley 	u8    affil_valid:1;
4272908d778SJames Bottomley 	u8    affil_supp:1;
4282908d778SJames Bottomley 	u8    _r_c:6;
4292908d778SJames Bottomley 
4302908d778SJames Bottomley 	u32    _r_d;
4312908d778SJames Bottomley 
4322908d778SJames Bottomley 	u8    stp_sas_addr[8];
4332908d778SJames Bottomley 
4342908d778SJames Bottomley 	struct dev_to_host_fis fis;
4352908d778SJames Bottomley 
4362908d778SJames Bottomley 	u32   _r_e;
4372908d778SJames Bottomley 
4382908d778SJames Bottomley 	u8    affil_stp_ini_addr[8];
4392908d778SJames Bottomley 
4402908d778SJames Bottomley 	__be32 crc;
4412908d778SJames Bottomley } __attribute__ ((packed));
4422908d778SJames Bottomley 
4432908d778SJames Bottomley struct smp_resp {
4442908d778SJames Bottomley 	u8    frame_type;
4452908d778SJames Bottomley 	u8    function;
4462908d778SJames Bottomley 	u8    result;
4472908d778SJames Bottomley 	u8    reserved;
4482908d778SJames Bottomley 	union {
4492908d778SJames Bottomley 		struct report_general_resp  rg;
4502908d778SJames Bottomley 		struct discover_resp        disc;
4512908d778SJames Bottomley 		struct report_phy_sata_resp rps;
4522908d778SJames Bottomley 	};
4532908d778SJames Bottomley } __attribute__ ((packed));
4542908d778SJames Bottomley 
4552908d778SJames Bottomley #elif defined(__BIG_ENDIAN_BITFIELD)
4562908d778SJames Bottomley struct sas_identify_frame {
4572908d778SJames Bottomley 	/* Byte 0 */
4582908d778SJames Bottomley 	u8  _un0:1;
4592908d778SJames Bottomley 	u8  dev_type:3;
4602908d778SJames Bottomley 	u8  frame_type:4;
4612908d778SJames Bottomley 
4622908d778SJames Bottomley 	/* Byte 1 */
4632908d778SJames Bottomley 	u8  _un1;
4642908d778SJames Bottomley 
4652908d778SJames Bottomley 	/* Byte 2 */
4662908d778SJames Bottomley 	union {
4672908d778SJames Bottomley 		struct {
4682908d778SJames Bottomley 			u8  _un247:4;
4692908d778SJames Bottomley 			u8  ssp_iport:1;
4702908d778SJames Bottomley 			u8  stp_iport:1;
4712908d778SJames Bottomley 			u8  smp_iport:1;
4722908d778SJames Bottomley 			u8  _un20:1;
4732908d778SJames Bottomley 		};
4742908d778SJames Bottomley 		u8 initiator_bits;
4752908d778SJames Bottomley 	};
4762908d778SJames Bottomley 
4772908d778SJames Bottomley 	/* Byte 3 */
4782908d778SJames Bottomley 	union {
4792908d778SJames Bottomley 		struct {
4802908d778SJames Bottomley 			u8 _un347:4;
4812908d778SJames Bottomley 			u8 ssp_tport:1;
4822908d778SJames Bottomley 			u8 stp_tport:1;
4832908d778SJames Bottomley 			u8 smp_tport:1;
4842908d778SJames Bottomley 			u8 _un30:1;
4852908d778SJames Bottomley 		};
4862908d778SJames Bottomley 		u8 target_bits;
4872908d778SJames Bottomley 	};
4882908d778SJames Bottomley 
4892908d778SJames Bottomley 	/* Byte 4 - 11 */
4902908d778SJames Bottomley 	u8 _un4_11[8];
4912908d778SJames Bottomley 
4922908d778SJames Bottomley 	/* Byte 12 - 19 */
4932908d778SJames Bottomley 	u8 sas_addr[SAS_ADDR_SIZE];
4942908d778SJames Bottomley 
4952908d778SJames Bottomley 	/* Byte 20 */
4962908d778SJames Bottomley 	u8 phy_id;
4972908d778SJames Bottomley 
4982908d778SJames Bottomley 	u8 _un21_27[7];
4992908d778SJames Bottomley 
5002908d778SJames Bottomley 	__be32 crc;
5012908d778SJames Bottomley } __attribute__ ((packed));
5022908d778SJames Bottomley 
5032908d778SJames Bottomley struct ssp_frame_hdr {
5042908d778SJames Bottomley 	u8     frame_type;
5052908d778SJames Bottomley 	u8     hashed_dest_addr[HASHED_SAS_ADDR_SIZE];
5062908d778SJames Bottomley 	u8     _r_a;
5072908d778SJames Bottomley 	u8     hashed_src_addr[HASHED_SAS_ADDR_SIZE];
5082908d778SJames Bottomley 	__be16 _r_b;
5092908d778SJames Bottomley 
5102908d778SJames Bottomley 	u8     _r_c:5;
5112908d778SJames Bottomley 	u8     retry_data_frames:1;
5122908d778SJames Bottomley 	u8     retransmit:1;
5132908d778SJames Bottomley 	u8     changing_data_ptr:1;
5142908d778SJames Bottomley 
5152908d778SJames Bottomley 	u8     _r_d:6;
5162908d778SJames Bottomley 	u8     num_fill_bytes:2;
5172908d778SJames Bottomley 
5182908d778SJames Bottomley 	u32    _r_e;
5192908d778SJames Bottomley 	__be16 tag;
5202908d778SJames Bottomley 	__be16 tptt;
5212908d778SJames Bottomley 	__be32 data_offs;
5222908d778SJames Bottomley } __attribute__ ((packed));
5232908d778SJames Bottomley 
5242908d778SJames Bottomley struct ssp_response_iu {
5252908d778SJames Bottomley 	u8     _r_a[10];
5262908d778SJames Bottomley 
5272908d778SJames Bottomley 	u8     _r_b:6;
5282908d778SJames Bottomley 	u8     datapres:2;
5292908d778SJames Bottomley 
5302908d778SJames Bottomley 	u8     status;
5312908d778SJames Bottomley 
5322908d778SJames Bottomley 	u32    _r_c;
5332908d778SJames Bottomley 
5342908d778SJames Bottomley 	__be32 sense_data_len;
5352908d778SJames Bottomley 	__be32 response_data_len;
5362908d778SJames Bottomley 
5372908d778SJames Bottomley 	u8     resp_data[0];
5382908d778SJames Bottomley 	u8     sense_data[0];
5392908d778SJames Bottomley } __attribute__ ((packed));
5402908d778SJames Bottomley 
5412908d778SJames Bottomley /* ---------- SMP ---------- */
5422908d778SJames Bottomley 
5432908d778SJames Bottomley struct report_general_resp {
5442908d778SJames Bottomley 	__be16  change_count;
5452908d778SJames Bottomley 	__be16  route_indexes;
5462908d778SJames Bottomley 	u8      _r_a;
5472908d778SJames Bottomley 	u8      num_phys;
5482908d778SJames Bottomley 
549ffaac8f4SLuben Tuikov 	u8	t2t_supp:1;
550ffaac8f4SLuben Tuikov 	u8	zone_config:1;
551ffaac8f4SLuben Tuikov 	u8	self_config:1;
552ffaac8f4SLuben Tuikov 	u8	stp_cont_awt:1;
553ffaac8f4SLuben Tuikov 	u8	orej_retry_supp:1;
554ffaac8f4SLuben Tuikov 	u8	config_others:1;
5552908d778SJames Bottomley 	u8      configuring:1;
5562908d778SJames Bottomley 	u8      conf_route_table:1;
5572908d778SJames Bottomley 
5582908d778SJames Bottomley 	u8      _r_c;
5592908d778SJames Bottomley 
5602908d778SJames Bottomley 	u8      enclosure_logical_id[8];
5612908d778SJames Bottomley 
5622908d778SJames Bottomley 	u8      _r_d[12];
5632908d778SJames Bottomley } __attribute__ ((packed));
5642908d778SJames Bottomley 
5652908d778SJames Bottomley struct discover_resp {
5662908d778SJames Bottomley 	u8    _r_a[5];
5672908d778SJames Bottomley 
5682908d778SJames Bottomley 	u8    phy_id;
5692908d778SJames Bottomley 	__be16 _r_b;
5702908d778SJames Bottomley 
5712908d778SJames Bottomley 	u8    _r_d:1;
5722908d778SJames Bottomley 	u8    attached_dev_type:3;
5732908d778SJames Bottomley 	u8    _r_c:4;
5742908d778SJames Bottomley 
5752908d778SJames Bottomley 	u8    _r_e:4;
5762908d778SJames Bottomley 	u8    linkrate:4;
5772908d778SJames Bottomley 
5782908d778SJames Bottomley 	u8    _r_f:4;
5792908d778SJames Bottomley 	u8    iproto:3;
5802908d778SJames Bottomley 	u8    attached_sata_host:1;
5812908d778SJames Bottomley 
5822908d778SJames Bottomley 	u8    attached_sata_ps:1;
5832908d778SJames Bottomley 	u8    _r_g:3;
5842908d778SJames Bottomley 	u8    tproto:3;
5852908d778SJames Bottomley 	u8    attached_sata_dev:1;
5862908d778SJames Bottomley 
5872908d778SJames Bottomley 	u8    sas_addr[8];
5882908d778SJames Bottomley 	u8    attached_sas_addr[8];
5892908d778SJames Bottomley 	u8    attached_phy_id;
5902908d778SJames Bottomley 
5912908d778SJames Bottomley 	u8    _r_h[7];
5922908d778SJames Bottomley 
5932908d778SJames Bottomley 	u8    pmin_linkrate:4;
5942908d778SJames Bottomley 	u8    hmin_linkrate:4;
5952908d778SJames Bottomley 	u8    pmax_linkrate:4;
5962908d778SJames Bottomley 	u8    hmax_linkrate:4;
5972908d778SJames Bottomley 
5982908d778SJames Bottomley 	u8    change_count;
5992908d778SJames Bottomley 
6002908d778SJames Bottomley 	u8    virtual:1;
6012908d778SJames Bottomley 	u8    _r_i:3;
6022908d778SJames Bottomley 	u8    pptv:4;
6032908d778SJames Bottomley 
6042908d778SJames Bottomley 	u8    _r_j:4;
6052908d778SJames Bottomley 	u8    routing_attr:4;
6062908d778SJames Bottomley 
6072908d778SJames Bottomley 	u8    conn_type;
6082908d778SJames Bottomley 	u8    conn_el_index;
6092908d778SJames Bottomley 	u8    conn_phy_link;
6102908d778SJames Bottomley 
6112908d778SJames Bottomley 	u8    _r_k[8];
6122908d778SJames Bottomley } __attribute__ ((packed));
6132908d778SJames Bottomley 
6142908d778SJames Bottomley struct report_phy_sata_resp {
6152908d778SJames Bottomley 	u8    _r_a[5];
6162908d778SJames Bottomley 
6172908d778SJames Bottomley 	u8    phy_id;
6182908d778SJames Bottomley 	u8    _r_b;
6192908d778SJames Bottomley 
6202908d778SJames Bottomley 	u8    _r_c:6;
6212908d778SJames Bottomley 	u8    affil_supp:1;
6222908d778SJames Bottomley 	u8    affil_valid:1;
6232908d778SJames Bottomley 
6242908d778SJames Bottomley 	u32   _r_d;
6252908d778SJames Bottomley 
6262908d778SJames Bottomley 	u8    stp_sas_addr[8];
6272908d778SJames Bottomley 
6282908d778SJames Bottomley 	struct dev_to_host_fis fis;
6292908d778SJames Bottomley 
6302908d778SJames Bottomley 	u32   _r_e;
6312908d778SJames Bottomley 
6322908d778SJames Bottomley 	u8    affil_stp_ini_addr[8];
6332908d778SJames Bottomley 
6342908d778SJames Bottomley 	__be32 crc;
6352908d778SJames Bottomley } __attribute__ ((packed));
6362908d778SJames Bottomley 
6372908d778SJames Bottomley struct smp_resp {
6382908d778SJames Bottomley 	u8    frame_type;
6392908d778SJames Bottomley 	u8    function;
6402908d778SJames Bottomley 	u8    result;
6412908d778SJames Bottomley 	u8    reserved;
6422908d778SJames Bottomley 	union {
6432908d778SJames Bottomley 		struct report_general_resp  rg;
6442908d778SJames Bottomley 		struct discover_resp        disc;
6452908d778SJames Bottomley 		struct report_phy_sata_resp rps;
6462908d778SJames Bottomley 	};
6472908d778SJames Bottomley } __attribute__ ((packed));
6482908d778SJames Bottomley 
6492908d778SJames Bottomley #else
6502908d778SJames Bottomley #error "Bitfield order not defined!"
6512908d778SJames Bottomley #endif
6522908d778SJames Bottomley 
6532908d778SJames Bottomley #endif /* _SAS_H_ */
654