0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _SAS_H_
0010 #define _SAS_H_
0011
0012 #include <linux/types.h>
0013 #include <asm/byteorder.h>
0014
0015 #define SAS_ADDR_SIZE 8
0016 #define HASHED_SAS_ADDR_SIZE 3
0017 #define SAS_ADDR(_sa) ((unsigned long long) be64_to_cpu(*(__be64 *)(_sa)))
0018
0019 #define SMP_REQUEST 0x40
0020 #define SMP_RESPONSE 0x41
0021
0022 #define SSP_DATA 0x01
0023 #define SSP_XFER_RDY 0x05
0024 #define SSP_COMMAND 0x06
0025 #define SSP_RESPONSE 0x07
0026 #define SSP_TASK 0x16
0027
0028 #define SMP_REPORT_GENERAL 0x00
0029 #define SMP_REPORT_MANUF_INFO 0x01
0030 #define SMP_READ_GPIO_REG 0x02
0031 #define SMP_DISCOVER 0x10
0032 #define SMP_REPORT_PHY_ERR_LOG 0x11
0033 #define SMP_REPORT_PHY_SATA 0x12
0034 #define SMP_REPORT_ROUTE_INFO 0x13
0035 #define SMP_WRITE_GPIO_REG 0x82
0036 #define SMP_CONF_ROUTE_INFO 0x90
0037 #define SMP_PHY_CONTROL 0x91
0038 #define SMP_PHY_TEST_FUNCTION 0x92
0039
0040 #define SMP_RESP_FUNC_ACC 0x00
0041 #define SMP_RESP_FUNC_UNK 0x01
0042 #define SMP_RESP_FUNC_FAILED 0x02
0043 #define SMP_RESP_INV_FRM_LEN 0x03
0044 #define SMP_RESP_NO_PHY 0x10
0045 #define SMP_RESP_NO_INDEX 0x11
0046 #define SMP_RESP_PHY_NO_SATA 0x12
0047 #define SMP_RESP_PHY_UNK_OP 0x13
0048 #define SMP_RESP_PHY_UNK_TESTF 0x14
0049 #define SMP_RESP_PHY_TEST_INPROG 0x15
0050 #define SMP_RESP_PHY_VACANT 0x16
0051
0052
0053 #define TMF_ABORT_TASK 0x01
0054 #define TMF_ABORT_TASK_SET 0x02
0055 #define TMF_CLEAR_TASK_SET 0x04
0056 #define TMF_LU_RESET 0x08
0057 #define TMF_CLEAR_ACA 0x40
0058 #define TMF_QUERY_TASK 0x80
0059
0060
0061 #define TMF_RESP_FUNC_COMPLETE 0x00
0062 #define TMF_RESP_INVALID_FRAME 0x02
0063 #define TMF_RESP_FUNC_ESUPP 0x04
0064 #define TMF_RESP_FUNC_FAILED 0x05
0065 #define TMF_RESP_FUNC_SUCC 0x08
0066 #define TMF_RESP_NO_LUN 0x09
0067 #define TMF_RESP_OVERLAPPED_TAG 0x0A
0068
0069 enum sas_oob_mode {
0070 OOB_NOT_CONNECTED,
0071 SATA_OOB_MODE,
0072 SAS_OOB_MODE
0073 };
0074
0075
0076 enum sas_device_type {
0077
0078 SAS_PHY_UNUSED = 0,
0079 SAS_END_DEVICE = 1,
0080 SAS_EDGE_EXPANDER_DEVICE = 2,
0081 SAS_FANOUT_EXPANDER_DEVICE = 3,
0082
0083 SAS_HA = 4,
0084 SAS_SATA_DEV = 5,
0085 SAS_SATA_PM = 7,
0086 SAS_SATA_PM_PORT = 8,
0087 SAS_SATA_PENDING = 9,
0088 };
0089
0090 enum sas_protocol {
0091 SAS_PROTOCOL_NONE = 0,
0092 SAS_PROTOCOL_SATA = 0x01,
0093 SAS_PROTOCOL_SMP = 0x02,
0094 SAS_PROTOCOL_STP = 0x04,
0095 SAS_PROTOCOL_SSP = 0x08,
0096 SAS_PROTOCOL_ALL = 0x0E,
0097 SAS_PROTOCOL_STP_ALL = SAS_PROTOCOL_STP|SAS_PROTOCOL_SATA,
0098
0099 SAS_PROTOCOL_INTERNAL_ABORT = 0x10,
0100 };
0101
0102
0103 enum phy_func {
0104 PHY_FUNC_NOP,
0105 PHY_FUNC_LINK_RESET,
0106 PHY_FUNC_HARD_RESET,
0107 PHY_FUNC_DISABLE,
0108 PHY_FUNC_CLEAR_ERROR_LOG = 5,
0109 PHY_FUNC_CLEAR_AFFIL,
0110 PHY_FUNC_TX_SATA_PS_SIGNAL,
0111 PHY_FUNC_RELEASE_SPINUP_HOLD = 0x10,
0112 PHY_FUNC_SET_LINK_RATE,
0113 PHY_FUNC_GET_EVENTS,
0114 };
0115
0116
0117
0118
0119 enum sas_prim {
0120 SAS_PRIM_AIP_NORMAL = 1,
0121 SAS_PRIM_AIP_R0 = 2,
0122 SAS_PRIM_AIP_R1 = 3,
0123 SAS_PRIM_AIP_R2 = 4,
0124 SAS_PRIM_AIP_WC = 5,
0125 SAS_PRIM_AIP_WD = 6,
0126 SAS_PRIM_AIP_WP = 7,
0127 SAS_PRIM_AIP_RWP = 8,
0128
0129 SAS_PRIM_BC_CH = 9,
0130 SAS_PRIM_BC_RCH0 = 10,
0131 SAS_PRIM_BC_RCH1 = 11,
0132 SAS_PRIM_BC_R0 = 12,
0133 SAS_PRIM_BC_R1 = 13,
0134 SAS_PRIM_BC_R2 = 14,
0135 SAS_PRIM_BC_R3 = 15,
0136 SAS_PRIM_BC_R4 = 16,
0137
0138 SAS_PRIM_NOTIFY_ENSP= 17,
0139 SAS_PRIM_NOTIFY_R0 = 18,
0140 SAS_PRIM_NOTIFY_R1 = 19,
0141 SAS_PRIM_NOTIFY_R2 = 20,
0142
0143 SAS_PRIM_CLOSE_CLAF = 21,
0144 SAS_PRIM_CLOSE_NORM = 22,
0145 SAS_PRIM_CLOSE_R0 = 23,
0146 SAS_PRIM_CLOSE_R1 = 24,
0147
0148 SAS_PRIM_OPEN_RTRY = 25,
0149 SAS_PRIM_OPEN_RJCT = 26,
0150 SAS_PRIM_OPEN_ACPT = 27,
0151
0152 SAS_PRIM_DONE = 28,
0153 SAS_PRIM_BREAK = 29,
0154
0155 SATA_PRIM_DMAT = 33,
0156 SATA_PRIM_PMNAK = 34,
0157 SATA_PRIM_PMACK = 35,
0158 SATA_PRIM_PMREQ_S = 36,
0159 SATA_PRIM_PMREQ_P = 37,
0160 SATA_SATA_R_ERR = 38,
0161 };
0162
0163 enum sas_open_rej_reason {
0164
0165 SAS_OREJ_UNKNOWN = 0,
0166 SAS_OREJ_BAD_DEST = 1,
0167 SAS_OREJ_CONN_RATE = 2,
0168 SAS_OREJ_EPROTO = 3,
0169 SAS_OREJ_RESV_AB0 = 4,
0170 SAS_OREJ_RESV_AB1 = 5,
0171 SAS_OREJ_RESV_AB2 = 6,
0172 SAS_OREJ_RESV_AB3 = 7,
0173 SAS_OREJ_WRONG_DEST= 8,
0174 SAS_OREJ_STP_NORES = 9,
0175
0176
0177 SAS_OREJ_NO_DEST = 10,
0178 SAS_OREJ_PATH_BLOCKED = 11,
0179 SAS_OREJ_RSVD_CONT0 = 12,
0180 SAS_OREJ_RSVD_CONT1 = 13,
0181 SAS_OREJ_RSVD_INIT0 = 14,
0182 SAS_OREJ_RSVD_INIT1 = 15,
0183 SAS_OREJ_RSVD_STOP0 = 16,
0184 SAS_OREJ_RSVD_STOP1 = 17,
0185 SAS_OREJ_RSVD_RETRY = 18,
0186 };
0187
0188 enum sas_gpio_reg_type {
0189 SAS_GPIO_REG_CFG = 0,
0190 SAS_GPIO_REG_RX = 1,
0191 SAS_GPIO_REG_RX_GP = 2,
0192 SAS_GPIO_REG_TX = 3,
0193 SAS_GPIO_REG_TX_GP = 4,
0194 };
0195
0196
0197 enum {
0198 SAS_DATAPRES_NO_DATA = 0,
0199 SAS_DATAPRES_RESPONSE_DATA = 1,
0200 SAS_DATAPRES_SENSE_DATA = 2,
0201 };
0202
0203 struct dev_to_host_fis {
0204 u8 fis_type;
0205 u8 flags;
0206 u8 status;
0207 u8 error;
0208
0209 u8 lbal;
0210 union { u8 lbam; u8 byte_count_low; };
0211 union { u8 lbah; u8 byte_count_high; };
0212 u8 device;
0213
0214 u8 lbal_exp;
0215 u8 lbam_exp;
0216 u8 lbah_exp;
0217 u8 _r_a;
0218
0219 union { u8 sector_count; u8 interrupt_reason; };
0220 u8 sector_count_exp;
0221 u8 _r_b;
0222 u8 _r_c;
0223
0224 u32 _r_d;
0225 } __attribute__ ((packed));
0226
0227 struct host_to_dev_fis {
0228 u8 fis_type;
0229 u8 flags;
0230 u8 command;
0231 u8 features;
0232
0233 u8 lbal;
0234 union { u8 lbam; u8 byte_count_low; };
0235 union { u8 lbah; u8 byte_count_high; };
0236 u8 device;
0237
0238 u8 lbal_exp;
0239 u8 lbam_exp;
0240 u8 lbah_exp;
0241 u8 features_exp;
0242
0243 union { u8 sector_count; u8 interrupt_reason; };
0244 u8 sector_count_exp;
0245 u8 _r_a;
0246 u8 control;
0247
0248 u32 _r_b;
0249 } __attribute__ ((packed));
0250
0251
0252
0253 #ifdef __LITTLE_ENDIAN_BITFIELD
0254 struct sas_identify_frame {
0255
0256 u8 frame_type:4;
0257 u8 dev_type:3;
0258 u8 _un0:1;
0259
0260
0261 u8 _un1;
0262
0263
0264 union {
0265 struct {
0266 u8 _un20:1;
0267 u8 smp_iport:1;
0268 u8 stp_iport:1;
0269 u8 ssp_iport:1;
0270 u8 _un247:4;
0271 };
0272 u8 initiator_bits;
0273 };
0274
0275
0276 union {
0277 struct {
0278 u8 _un30:1;
0279 u8 smp_tport:1;
0280 u8 stp_tport:1;
0281 u8 ssp_tport:1;
0282 u8 _un347:4;
0283 };
0284 u8 target_bits;
0285 };
0286
0287
0288 u8 _un4_11[8];
0289
0290
0291 u8 sas_addr[SAS_ADDR_SIZE];
0292
0293
0294 u8 phy_id;
0295
0296 u8 _un21_27[7];
0297
0298 __be32 crc;
0299 } __attribute__ ((packed));
0300
0301 struct ssp_frame_hdr {
0302 u8 frame_type;
0303 u8 hashed_dest_addr[HASHED_SAS_ADDR_SIZE];
0304 u8 _r_a;
0305 u8 hashed_src_addr[HASHED_SAS_ADDR_SIZE];
0306 __be16 _r_b;
0307
0308 u8 changing_data_ptr:1;
0309 u8 retransmit:1;
0310 u8 retry_data_frames:1;
0311 u8 _r_c:5;
0312
0313 u8 num_fill_bytes:2;
0314 u8 _r_d:6;
0315
0316 u32 _r_e;
0317 __be16 tag;
0318 __be16 tptt;
0319 __be32 data_offs;
0320 } __attribute__ ((packed));
0321
0322 struct ssp_response_iu {
0323 u8 _r_a[10];
0324
0325 u8 datapres:2;
0326 u8 _r_b:6;
0327
0328 u8 status;
0329
0330 u32 _r_c;
0331
0332 __be32 sense_data_len;
0333 __be32 response_data_len;
0334
0335 union {
0336 DECLARE_FLEX_ARRAY(u8, resp_data);
0337 DECLARE_FLEX_ARRAY(u8, sense_data);
0338 };
0339 } __attribute__ ((packed));
0340
0341 struct ssp_command_iu {
0342 u8 lun[8];
0343 u8 _r_a;
0344
0345 union {
0346 struct {
0347 u8 attr:3;
0348 u8 prio:4;
0349 u8 efb:1;
0350 };
0351 u8 efb_prio_attr;
0352 };
0353
0354 u8 _r_b;
0355
0356 u8 _r_c:2;
0357 u8 add_cdb_len:6;
0358
0359 u8 cdb[16];
0360 u8 add_cdb[];
0361 } __attribute__ ((packed));
0362
0363 struct xfer_rdy_iu {
0364 __be32 requested_offset;
0365 __be32 write_data_len;
0366 __be32 _r_a;
0367 } __attribute__ ((packed));
0368
0369 struct ssp_tmf_iu {
0370 u8 lun[8];
0371 u16 _r_a;
0372 u8 tmf;
0373 u8 _r_b;
0374 __be16 tag;
0375 u8 _r_c[14];
0376 } __attribute__ ((packed));
0377
0378
0379
0380 struct report_general_resp {
0381 __be16 change_count;
0382 __be16 route_indexes;
0383 u8 _r_a;
0384 u8 num_phys;
0385
0386 u8 conf_route_table:1;
0387 u8 configuring:1;
0388 u8 config_others:1;
0389 u8 orej_retry_supp:1;
0390 u8 stp_cont_awt:1;
0391 u8 self_config:1;
0392 u8 zone_config:1;
0393 u8 t2t_supp:1;
0394
0395 u8 _r_c;
0396
0397 u8 enclosure_logical_id[8];
0398
0399 u8 _r_d[12];
0400 } __attribute__ ((packed));
0401
0402 struct discover_resp {
0403 u8 _r_a[5];
0404
0405 u8 phy_id;
0406 __be16 _r_b;
0407
0408 u8 _r_c:4;
0409 u8 attached_dev_type:3;
0410 u8 _r_d:1;
0411
0412 u8 linkrate:4;
0413 u8 _r_e:4;
0414
0415 u8 attached_sata_host:1;
0416 u8 iproto:3;
0417 u8 _r_f:4;
0418
0419 u8 attached_sata_dev:1;
0420 u8 tproto:3;
0421 u8 _r_g:3;
0422 u8 attached_sata_ps:1;
0423
0424 u8 sas_addr[8];
0425 u8 attached_sas_addr[8];
0426 u8 attached_phy_id;
0427
0428 u8 _r_h[7];
0429
0430 u8 hmin_linkrate:4;
0431 u8 pmin_linkrate:4;
0432 u8 hmax_linkrate:4;
0433 u8 pmax_linkrate:4;
0434
0435 u8 change_count;
0436
0437 u8 pptv:4;
0438 u8 _r_i:3;
0439 u8 virtual:1;
0440
0441 u8 routing_attr:4;
0442 u8 _r_j:4;
0443
0444 u8 conn_type;
0445 u8 conn_el_index;
0446 u8 conn_phy_link;
0447
0448 u8 _r_k[8];
0449 } __attribute__ ((packed));
0450
0451 struct report_phy_sata_resp {
0452 u8 _r_a[5];
0453
0454 u8 phy_id;
0455 u8 _r_b;
0456
0457 u8 affil_valid:1;
0458 u8 affil_supp:1;
0459 u8 _r_c:6;
0460
0461 u32 _r_d;
0462
0463 u8 stp_sas_addr[8];
0464
0465 struct dev_to_host_fis fis;
0466
0467 u32 _r_e;
0468
0469 u8 affil_stp_ini_addr[8];
0470
0471 __be32 crc;
0472 } __attribute__ ((packed));
0473
0474 #elif defined(__BIG_ENDIAN_BITFIELD)
0475 struct sas_identify_frame {
0476
0477 u8 _un0:1;
0478 u8 dev_type:3;
0479 u8 frame_type:4;
0480
0481
0482 u8 _un1;
0483
0484
0485 union {
0486 struct {
0487 u8 _un247:4;
0488 u8 ssp_iport:1;
0489 u8 stp_iport:1;
0490 u8 smp_iport:1;
0491 u8 _un20:1;
0492 };
0493 u8 initiator_bits;
0494 };
0495
0496
0497 union {
0498 struct {
0499 u8 _un347:4;
0500 u8 ssp_tport:1;
0501 u8 stp_tport:1;
0502 u8 smp_tport:1;
0503 u8 _un30:1;
0504 };
0505 u8 target_bits;
0506 };
0507
0508
0509 u8 _un4_11[8];
0510
0511
0512 u8 sas_addr[SAS_ADDR_SIZE];
0513
0514
0515 u8 phy_id;
0516
0517 u8 _un21_27[7];
0518
0519 __be32 crc;
0520 } __attribute__ ((packed));
0521
0522 struct ssp_frame_hdr {
0523 u8 frame_type;
0524 u8 hashed_dest_addr[HASHED_SAS_ADDR_SIZE];
0525 u8 _r_a;
0526 u8 hashed_src_addr[HASHED_SAS_ADDR_SIZE];
0527 __be16 _r_b;
0528
0529 u8 _r_c:5;
0530 u8 retry_data_frames:1;
0531 u8 retransmit:1;
0532 u8 changing_data_ptr:1;
0533
0534 u8 _r_d:6;
0535 u8 num_fill_bytes:2;
0536
0537 u32 _r_e;
0538 __be16 tag;
0539 __be16 tptt;
0540 __be32 data_offs;
0541 } __attribute__ ((packed));
0542
0543 struct ssp_response_iu {
0544 u8 _r_a[10];
0545
0546 u8 _r_b:6;
0547 u8 datapres:2;
0548
0549 u8 status;
0550
0551 u32 _r_c;
0552
0553 __be32 sense_data_len;
0554 __be32 response_data_len;
0555
0556 union {
0557 DECLARE_FLEX_ARRAY(u8, resp_data);
0558 DECLARE_FLEX_ARRAY(u8, sense_data);
0559 };
0560 } __attribute__ ((packed));
0561
0562 struct ssp_command_iu {
0563 u8 lun[8];
0564 u8 _r_a;
0565
0566 union {
0567 struct {
0568 u8 efb:1;
0569 u8 prio:4;
0570 u8 attr:3;
0571 };
0572 u8 efb_prio_attr;
0573 };
0574
0575 u8 _r_b;
0576
0577 u8 add_cdb_len:6;
0578 u8 _r_c:2;
0579
0580 u8 cdb[16];
0581 u8 add_cdb[];
0582 } __attribute__ ((packed));
0583
0584 struct xfer_rdy_iu {
0585 __be32 requested_offset;
0586 __be32 write_data_len;
0587 __be32 _r_a;
0588 } __attribute__ ((packed));
0589
0590 struct ssp_tmf_iu {
0591 u8 lun[8];
0592 u16 _r_a;
0593 u8 tmf;
0594 u8 _r_b;
0595 __be16 tag;
0596 u8 _r_c[14];
0597 } __attribute__ ((packed));
0598
0599
0600
0601 struct report_general_resp {
0602 __be16 change_count;
0603 __be16 route_indexes;
0604 u8 _r_a;
0605 u8 num_phys;
0606
0607 u8 t2t_supp:1;
0608 u8 zone_config:1;
0609 u8 self_config:1;
0610 u8 stp_cont_awt:1;
0611 u8 orej_retry_supp:1;
0612 u8 config_others:1;
0613 u8 configuring:1;
0614 u8 conf_route_table:1;
0615
0616 u8 _r_c;
0617
0618 u8 enclosure_logical_id[8];
0619
0620 u8 _r_d[12];
0621 } __attribute__ ((packed));
0622
0623 struct discover_resp {
0624 u8 _r_a[5];
0625
0626 u8 phy_id;
0627 __be16 _r_b;
0628
0629 u8 _r_d:1;
0630 u8 attached_dev_type:3;
0631 u8 _r_c:4;
0632
0633 u8 _r_e:4;
0634 u8 linkrate:4;
0635
0636 u8 _r_f:4;
0637 u8 iproto:3;
0638 u8 attached_sata_host:1;
0639
0640 u8 attached_sata_ps:1;
0641 u8 _r_g:3;
0642 u8 tproto:3;
0643 u8 attached_sata_dev:1;
0644
0645 u8 sas_addr[8];
0646 u8 attached_sas_addr[8];
0647 u8 attached_phy_id;
0648
0649 u8 _r_h[7];
0650
0651 u8 pmin_linkrate:4;
0652 u8 hmin_linkrate:4;
0653 u8 pmax_linkrate:4;
0654 u8 hmax_linkrate:4;
0655
0656 u8 change_count;
0657
0658 u8 virtual:1;
0659 u8 _r_i:3;
0660 u8 pptv:4;
0661
0662 u8 _r_j:4;
0663 u8 routing_attr:4;
0664
0665 u8 conn_type;
0666 u8 conn_el_index;
0667 u8 conn_phy_link;
0668
0669 u8 _r_k[8];
0670 } __attribute__ ((packed));
0671
0672 struct report_phy_sata_resp {
0673 u8 _r_a[5];
0674
0675 u8 phy_id;
0676 u8 _r_b;
0677
0678 u8 _r_c:6;
0679 u8 affil_supp:1;
0680 u8 affil_valid:1;
0681
0682 u32 _r_d;
0683
0684 u8 stp_sas_addr[8];
0685
0686 struct dev_to_host_fis fis;
0687
0688 u32 _r_e;
0689
0690 u8 affil_stp_ini_addr[8];
0691
0692 __be32 crc;
0693 } __attribute__ ((packed));
0694
0695 #else
0696 #error "Bitfield order not defined!"
0697 #endif
0698
0699 struct smp_rg_resp {
0700 u8 frame_type;
0701 u8 function;
0702 u8 result;
0703 u8 reserved;
0704 struct report_general_resp rg;
0705 } __attribute__ ((packed));
0706
0707 struct smp_disc_resp {
0708 u8 frame_type;
0709 u8 function;
0710 u8 result;
0711 u8 reserved;
0712 struct discover_resp disc;
0713 } __attribute__ ((packed));
0714
0715 struct smp_rps_resp {
0716 u8 frame_type;
0717 u8 function;
0718 u8 result;
0719 u8 reserved;
0720 struct report_phy_sata_resp rps;
0721 } __attribute__ ((packed));
0722
0723 #endif