1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * SAS structures and definitions header file
5 * Copyright (C) 2005 Adaptec, Inc. All rights reserved.
6 * Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com>
12 #include <linux/types.h>
13 #include <asm/byteorder.h>
15 #define SAS_ADDR_SIZE 8
16 #define HASHED_SAS_ADDR_SIZE 3
17 #define SAS_ADDR(_sa) ((unsigned long long) be64_to_cpu(*(__be64 *)(_sa)))
19 #define SMP_REQUEST 0x40
20 #define SMP_RESPONSE 0x41
23 #define SSP_XFER_RDY 0x05
24 #define SSP_COMMAND 0x06
25 #define SSP_RESPONSE 0x07
28 #define SMP_REPORT_GENERAL 0x00
29 #define SMP_REPORT_MANUF_INFO 0x01
30 #define SMP_READ_GPIO_REG 0x02
31 #define SMP_DISCOVER 0x10
32 #define SMP_REPORT_PHY_ERR_LOG 0x11
33 #define SMP_REPORT_PHY_SATA 0x12
34 #define SMP_REPORT_ROUTE_INFO 0x13
35 #define SMP_WRITE_GPIO_REG 0x82
36 #define SMP_CONF_ROUTE_INFO 0x90
37 #define SMP_PHY_CONTROL 0x91
38 #define SMP_PHY_TEST_FUNCTION 0x92
40 #define SMP_RESP_FUNC_ACC 0x00
41 #define SMP_RESP_FUNC_UNK 0x01
42 #define SMP_RESP_FUNC_FAILED 0x02
43 #define SMP_RESP_INV_FRM_LEN 0x03
44 #define SMP_RESP_NO_PHY 0x10
45 #define SMP_RESP_NO_INDEX 0x11
46 #define SMP_RESP_PHY_NO_SATA 0x12
47 #define SMP_RESP_PHY_UNK_OP 0x13
48 #define SMP_RESP_PHY_UNK_TESTF 0x14
49 #define SMP_RESP_PHY_TEST_INPROG 0x15
50 #define SMP_RESP_PHY_VACANT 0x16
53 #define TMF_ABORT_TASK 0x01
54 #define TMF_ABORT_TASK_SET 0x02
55 #define TMF_CLEAR_TASK_SET 0x04
56 #define TMF_LU_RESET 0x08
57 #define TMF_CLEAR_ACA 0x40
58 #define TMF_QUERY_TASK 0x80
60 /* SAS TMF responses */
61 #define TMF_RESP_FUNC_COMPLETE 0x00
62 #define TMF_RESP_INVALID_FRAME 0x02
63 #define TMF_RESP_FUNC_ESUPP 0x04
64 #define TMF_RESP_FUNC_FAILED 0x05
65 #define TMF_RESP_FUNC_SUCC 0x08
66 #define TMF_RESP_NO_LUN 0x09
67 #define TMF_RESP_OVERLAPPED_TAG 0x0A
75 /* See sas_discover.c if you plan on changing these */
76 enum sas_device_type
{
77 /* these are SAS protocol defined (attached device type field) */
80 SAS_EDGE_EXPANDER_DEVICE
= 2,
81 SAS_FANOUT_EXPANDER_DEVICE
= 3,
82 /* these are internal to libsas */
91 SAS_PROTOCOL_NONE
= 0,
92 SAS_PROTOCOL_SATA
= 0x01,
93 SAS_PROTOCOL_SMP
= 0x02,
94 SAS_PROTOCOL_STP
= 0x04,
95 SAS_PROTOCOL_SSP
= 0x08,
96 SAS_PROTOCOL_ALL
= 0x0E,
97 SAS_PROTOCOL_STP_ALL
= SAS_PROTOCOL_STP
|SAS_PROTOCOL_SATA
,
98 /* these are internal to libsas */
99 SAS_PROTOCOL_INTERNAL_ABORT
= 0x10,
102 /* From the spec; local phys only */
105 PHY_FUNC_LINK_RESET
, /* Enables the phy */
108 PHY_FUNC_CLEAR_ERROR_LOG
= 5,
109 PHY_FUNC_CLEAR_AFFIL
,
110 PHY_FUNC_TX_SATA_PS_SIGNAL
,
111 PHY_FUNC_RELEASE_SPINUP_HOLD
= 0x10, /* LOCAL PORT ONLY! */
112 PHY_FUNC_SET_LINK_RATE
,
116 /* SAS LLDD would need to report only _very_few_ of those, like BROADCAST.
117 * Most of those are here for completeness.
120 SAS_PRIM_AIP_NORMAL
= 1,
127 SAS_PRIM_AIP_RWP
= 8,
130 SAS_PRIM_BC_RCH0
= 10,
131 SAS_PRIM_BC_RCH1
= 11,
138 SAS_PRIM_NOTIFY_ENSP
= 17,
139 SAS_PRIM_NOTIFY_R0
= 18,
140 SAS_PRIM_NOTIFY_R1
= 19,
141 SAS_PRIM_NOTIFY_R2
= 20,
143 SAS_PRIM_CLOSE_CLAF
= 21,
144 SAS_PRIM_CLOSE_NORM
= 22,
145 SAS_PRIM_CLOSE_R0
= 23,
146 SAS_PRIM_CLOSE_R1
= 24,
148 SAS_PRIM_OPEN_RTRY
= 25,
149 SAS_PRIM_OPEN_RJCT
= 26,
150 SAS_PRIM_OPEN_ACPT
= 27,
156 SATA_PRIM_PMNAK
= 34,
157 SATA_PRIM_PMACK
= 35,
158 SATA_PRIM_PMREQ_S
= 36,
159 SATA_PRIM_PMREQ_P
= 37,
160 SATA_SATA_R_ERR
= 38,
163 enum sas_open_rej_reason
{
165 SAS_OREJ_UNKNOWN
= 0,
166 SAS_OREJ_BAD_DEST
= 1,
167 SAS_OREJ_CONN_RATE
= 2,
169 SAS_OREJ_RESV_AB0
= 4,
170 SAS_OREJ_RESV_AB1
= 5,
171 SAS_OREJ_RESV_AB2
= 6,
172 SAS_OREJ_RESV_AB3
= 7,
173 SAS_OREJ_WRONG_DEST
= 8,
174 SAS_OREJ_STP_NORES
= 9,
177 SAS_OREJ_NO_DEST
= 10,
178 SAS_OREJ_PATH_BLOCKED
= 11,
179 SAS_OREJ_RSVD_CONT0
= 12,
180 SAS_OREJ_RSVD_CONT1
= 13,
181 SAS_OREJ_RSVD_INIT0
= 14,
182 SAS_OREJ_RSVD_INIT1
= 15,
183 SAS_OREJ_RSVD_STOP0
= 16,
184 SAS_OREJ_RSVD_STOP1
= 17,
185 SAS_OREJ_RSVD_RETRY
= 18,
188 enum sas_gpio_reg_type
{
189 SAS_GPIO_REG_CFG
= 0,
191 SAS_GPIO_REG_RX_GP
= 2,
193 SAS_GPIO_REG_TX_GP
= 4,
196 /* Response frame DATAPRES field */
198 SAS_DATAPRES_NO_DATA
= 0,
199 SAS_DATAPRES_RESPONSE_DATA
= 1,
200 SAS_DATAPRES_SENSE_DATA
= 2,
203 struct dev_to_host_fis
{
204 u8 fis_type
; /* 0x34 */
210 union { u8 lbam
; u8 byte_count_low
; };
211 union { u8 lbah
; u8 byte_count_high
; };
219 union { u8 sector_count
; u8 interrupt_reason
; };
225 } __attribute__ ((packed
));
227 struct host_to_dev_fis
{
228 u8 fis_type
; /* 0x27 */
234 union { u8 lbam
; u8 byte_count_low
; };
235 union { u8 lbah
; u8 byte_count_high
; };
243 union { u8 sector_count
; u8 interrupt_reason
; };
249 } __attribute__ ((packed
));
251 /* Prefer to have code clarity over header file clarity.
253 #ifdef __LITTLE_ENDIAN_BITFIELD
254 struct sas_identify_frame
{
291 u8 sas_addr
[SAS_ADDR_SIZE
];
299 } __attribute__ ((packed
));
301 struct ssp_frame_hdr
{
303 u8 hashed_dest_addr
[HASHED_SAS_ADDR_SIZE
];
305 u8 hashed_src_addr
[HASHED_SAS_ADDR_SIZE
];
308 u8 changing_data_ptr
:1;
310 u8 retry_data_frames
:1;
320 } __attribute__ ((packed
));
322 struct ssp_response_iu
{
332 __be32 sense_data_len
;
333 __be32 response_data_len
;
336 DECLARE_FLEX_ARRAY(u8
, resp_data
);
337 DECLARE_FLEX_ARRAY(u8
, sense_data
);
339 } __attribute__ ((packed
));
341 struct ssp_command_iu
{
361 } __attribute__ ((packed
));
364 __be32 requested_offset
;
365 __be32 write_data_len
;
367 } __attribute__ ((packed
));
376 } __attribute__ ((packed
));
378 /* ---------- SMP ---------- */
380 struct report_general_resp
{
382 __be16 route_indexes
;
386 u8 conf_route_table
:1;
389 u8 orej_retry_supp
:1;
397 u8 enclosure_logical_id
[8];
400 } __attribute__ ((packed
));
402 struct discover_resp
{
409 u8 attached_dev_type
:3;
415 u8 attached_sata_host
:1;
419 u8 attached_sata_dev
:1;
422 u8 attached_sata_ps
:1;
425 u8 attached_sas_addr
[8];
449 } __attribute__ ((packed
));
451 struct report_phy_sata_resp
{
465 struct dev_to_host_fis fis
;
469 u8 affil_stp_ini_addr
[8];
472 } __attribute__ ((packed
));
474 #elif defined(__BIG_ENDIAN_BITFIELD)
475 struct sas_identify_frame
{
512 u8 sas_addr
[SAS_ADDR_SIZE
];
520 } __attribute__ ((packed
));
522 struct ssp_frame_hdr
{
524 u8 hashed_dest_addr
[HASHED_SAS_ADDR_SIZE
];
526 u8 hashed_src_addr
[HASHED_SAS_ADDR_SIZE
];
530 u8 retry_data_frames
:1;
532 u8 changing_data_ptr
:1;
541 } __attribute__ ((packed
));
543 struct ssp_response_iu
{
553 __be32 sense_data_len
;
554 __be32 response_data_len
;
557 DECLARE_FLEX_ARRAY(u8
, resp_data
);
558 DECLARE_FLEX_ARRAY(u8
, sense_data
);
560 } __attribute__ ((packed
));
562 struct ssp_command_iu
{
582 } __attribute__ ((packed
));
585 __be32 requested_offset
;
586 __be32 write_data_len
;
588 } __attribute__ ((packed
));
597 } __attribute__ ((packed
));
599 /* ---------- SMP ---------- */
601 struct report_general_resp
{
603 __be16 route_indexes
;
611 u8 orej_retry_supp
:1;
614 u8 conf_route_table
:1;
618 u8 enclosure_logical_id
[8];
621 } __attribute__ ((packed
));
623 struct discover_resp
{
630 u8 attached_dev_type
:3;
638 u8 attached_sata_host
:1;
640 u8 attached_sata_ps
:1;
643 u8 attached_sata_dev
:1;
646 u8 attached_sas_addr
[8];
670 } __attribute__ ((packed
));
672 struct report_phy_sata_resp
{
686 struct dev_to_host_fis fis
;
690 u8 affil_stp_ini_addr
[8];
693 } __attribute__ ((packed
));
696 #error "Bitfield order not defined!"
704 struct report_general_resp rg
;
705 } __attribute__ ((packed
));
707 struct smp_disc_resp
{
712 struct discover_resp disc
;
713 } __attribute__ ((packed
));
715 struct smp_rps_resp
{
720 struct report_phy_sata_resp rps
;
721 } __attribute__ ((packed
));