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,
100 /* From the spec; local phys only */
103 PHY_FUNC_LINK_RESET, /* Enables the phy */
106 PHY_FUNC_CLEAR_ERROR_LOG = 5,
107 PHY_FUNC_CLEAR_AFFIL,
108 PHY_FUNC_TX_SATA_PS_SIGNAL,
109 PHY_FUNC_RELEASE_SPINUP_HOLD = 0x10, /* LOCAL PORT ONLY! */
110 PHY_FUNC_SET_LINK_RATE,
114 /* SAS LLDD would need to report only _very_few_ of those, like BROADCAST.
115 * Most of those are here for completeness.
118 SAS_PRIM_AIP_NORMAL = 1,
125 SAS_PRIM_AIP_RWP = 8,
128 SAS_PRIM_BC_RCH0 = 10,
129 SAS_PRIM_BC_RCH1 = 11,
136 SAS_PRIM_NOTIFY_ENSP= 17,
137 SAS_PRIM_NOTIFY_R0 = 18,
138 SAS_PRIM_NOTIFY_R1 = 19,
139 SAS_PRIM_NOTIFY_R2 = 20,
141 SAS_PRIM_CLOSE_CLAF = 21,
142 SAS_PRIM_CLOSE_NORM = 22,
143 SAS_PRIM_CLOSE_R0 = 23,
144 SAS_PRIM_CLOSE_R1 = 24,
146 SAS_PRIM_OPEN_RTRY = 25,
147 SAS_PRIM_OPEN_RJCT = 26,
148 SAS_PRIM_OPEN_ACPT = 27,
154 SATA_PRIM_PMNAK = 34,
155 SATA_PRIM_PMACK = 35,
156 SATA_PRIM_PMREQ_S = 36,
157 SATA_PRIM_PMREQ_P = 37,
158 SATA_SATA_R_ERR = 38,
161 enum sas_open_rej_reason {
163 SAS_OREJ_UNKNOWN = 0,
164 SAS_OREJ_BAD_DEST = 1,
165 SAS_OREJ_CONN_RATE = 2,
167 SAS_OREJ_RESV_AB0 = 4,
168 SAS_OREJ_RESV_AB1 = 5,
169 SAS_OREJ_RESV_AB2 = 6,
170 SAS_OREJ_RESV_AB3 = 7,
171 SAS_OREJ_WRONG_DEST= 8,
172 SAS_OREJ_STP_NORES = 9,
175 SAS_OREJ_NO_DEST = 10,
176 SAS_OREJ_PATH_BLOCKED = 11,
177 SAS_OREJ_RSVD_CONT0 = 12,
178 SAS_OREJ_RSVD_CONT1 = 13,
179 SAS_OREJ_RSVD_INIT0 = 14,
180 SAS_OREJ_RSVD_INIT1 = 15,
181 SAS_OREJ_RSVD_STOP0 = 16,
182 SAS_OREJ_RSVD_STOP1 = 17,
183 SAS_OREJ_RSVD_RETRY = 18,
186 enum sas_gpio_reg_type {
187 SAS_GPIO_REG_CFG = 0,
189 SAS_GPIO_REG_RX_GP = 2,
191 SAS_GPIO_REG_TX_GP = 4,
194 struct dev_to_host_fis {
195 u8 fis_type; /* 0x34 */
201 union { u8 lbam; u8 byte_count_low; };
202 union { u8 lbah; u8 byte_count_high; };
210 union { u8 sector_count; u8 interrupt_reason; };
216 } __attribute__ ((packed));
218 struct host_to_dev_fis {
219 u8 fis_type; /* 0x27 */
225 union { u8 lbam; u8 byte_count_low; };
226 union { u8 lbah; u8 byte_count_high; };
234 union { u8 sector_count; u8 interrupt_reason; };
240 } __attribute__ ((packed));
242 /* Prefer to have code clarity over header file clarity.
244 #ifdef __LITTLE_ENDIAN_BITFIELD
245 struct sas_identify_frame {
282 u8 sas_addr[SAS_ADDR_SIZE];
290 } __attribute__ ((packed));
292 struct ssp_frame_hdr {
294 u8 hashed_dest_addr[HASHED_SAS_ADDR_SIZE];
296 u8 hashed_src_addr[HASHED_SAS_ADDR_SIZE];
299 u8 changing_data_ptr:1;
301 u8 retry_data_frames:1;
311 } __attribute__ ((packed));
313 struct ssp_response_iu {
323 __be32 sense_data_len;
324 __be32 response_data_len;
328 } __attribute__ ((packed));
330 struct ssp_command_iu {
350 } __attribute__ ((packed));
353 __be32 requested_offset;
354 __be32 write_data_len;
356 } __attribute__ ((packed));
365 } __attribute__ ((packed));
367 /* ---------- SMP ---------- */
369 struct report_general_resp {
371 __be16 route_indexes;
375 u8 conf_route_table:1;
378 u8 orej_retry_supp:1;
386 u8 enclosure_logical_id[8];
389 } __attribute__ ((packed));
391 struct discover_resp {
398 u8 attached_dev_type:3;
404 u8 attached_sata_host:1;
408 u8 attached_sata_dev:1;
411 u8 attached_sata_ps:1;
414 u8 attached_sas_addr[8];
438 } __attribute__ ((packed));
440 struct report_phy_sata_resp {
454 struct dev_to_host_fis fis;
458 u8 affil_stp_ini_addr[8];
461 } __attribute__ ((packed));
469 struct report_general_resp rg;
470 struct discover_resp disc;
471 struct report_phy_sata_resp rps;
473 } __attribute__ ((packed));
475 #elif defined(__BIG_ENDIAN_BITFIELD)
476 struct sas_identify_frame {
513 u8 sas_addr[SAS_ADDR_SIZE];
521 } __attribute__ ((packed));
523 struct ssp_frame_hdr {
525 u8 hashed_dest_addr[HASHED_SAS_ADDR_SIZE];
527 u8 hashed_src_addr[HASHED_SAS_ADDR_SIZE];
531 u8 retry_data_frames:1;
533 u8 changing_data_ptr:1;
542 } __attribute__ ((packed));
544 struct ssp_response_iu {
554 __be32 sense_data_len;
555 __be32 response_data_len;
559 } __attribute__ ((packed));
561 struct ssp_command_iu {
581 } __attribute__ ((packed));
584 __be32 requested_offset;
585 __be32 write_data_len;
587 } __attribute__ ((packed));
596 } __attribute__ ((packed));
598 /* ---------- SMP ---------- */
600 struct report_general_resp {
602 __be16 route_indexes;
610 u8 orej_retry_supp:1;
613 u8 conf_route_table:1;
617 u8 enclosure_logical_id[8];
620 } __attribute__ ((packed));
622 struct discover_resp {
629 u8 attached_dev_type:3;
637 u8 attached_sata_host:1;
639 u8 attached_sata_ps:1;
642 u8 attached_sata_dev:1;
645 u8 attached_sas_addr[8];
669 } __attribute__ ((packed));
671 struct report_phy_sata_resp {
685 struct dev_to_host_fis fis;
689 u8 affil_stp_ini_addr[8];
692 } __attribute__ ((packed));
700 struct report_general_resp rg;
701 struct discover_resp disc;
702 struct report_phy_sata_resp rps;
704 } __attribute__ ((packed));
707 #error "Bitfield order not defined!"