#ifndef _SAS_H
#define _SAS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/sysmacros.h>
typedef struct {
DECL_BITFIELD3(
address_frame_type :4,
device_type :3,
reserved0 :1);
DECL_BITFIELD2(
reason :4,
reserved1 :4);
DECL_BITFIELD5(
restricted0 :1,
smp_ini_port :1,
stp_ini_port :1,
ssp_ini_port :1,
reserved2 :4);
DECL_BITFIELD5(
restricted1 :1,
smp_tgt_port :1,
stp_tgt_port :1,
ssp_tgt_port :1,
reserved3 :4);
uint8_t device_name[8];
uint8_t sas_address[8];
uint8_t phy_identifier;
DECL_BITFIELD4(
break_reply_capable :1,
requested_inside_zpsds :1,
inside_zpsds_persistent :1,
reserved4 :5);
uint8_t reserved5[6];
} sas_identify_af_t;
typedef struct {
DECL_BITFIELD3(
address_frame_type :4,
protocol :3,
ini_port :1);
DECL_BITFIELD2(
connection_rate :4,
features :4);
uint16_t itag;
uint8_t sas_dst[8];
uint8_t sas_src[8];
uint8_t src_zone_group;
uint8_t path_block_count;
uint16_t arb_wait_time;
uint8_t compat[4];
} sas_open_af_t;
#define SAS_AF_IDENTIFY 0
#define SAS_AF_OPEN 1
#define SAS_IF_DTYPE_ENDPOINT 1
#define SAS_IF_DTYPE_EDGE 2
#define SAS_IF_DTYPE_FANOUT 3
#define SAS_OF_PROTO_SMP 0
#define SAS_OF_PROTO_SSP 1
#define SAS_OF_PROTO_STP 2
#define SAS_SSP_SUPPORT 0x8
#define SAS_STP_SUPPORT 0x4
#define SAS_SMP_SUPPORT 0x2
#define SAS_CONNRATE_1_5_GBPS 0x8
#define SAS_CONNRATE_3_0_GBPS 0x9
#define SAS_CONNRATE_6_0_GBPS 0xA
#define SAS_SATA_SUPPORT 0x1
#define SAS_ATTACHED_NAME_OFFSET 52
typedef struct {
uint8_t lun[8];
uint8_t reserved0;
DECL_BITFIELD3(
task_attribute :2,
command_priority :4,
enable_first_burst :1);
uint8_t reserved1;
DECL_BITFIELD2(
reserved2 :2,
addi_cdb_len :6);
uint8_t cdb[16];
} sas_ssp_cmd_iu_t;
#define SAS_CMD_TASK_ATTR_SIMPLE 0x00
#define SAS_CMD_TASK_ATTR_HEAD 0x01
#define SAS_CMD_TASK_ATTR_ORDERED 0x02
#define SAS_CMD_TASK_ATTR_ACA 0x04
typedef struct {
uint8_t reserved0[8];
uint16_t status_qualifier;
DECL_BITFIELD2(
datapres :2,
reserved1 :6);
uint8_t status;
uint8_t reserved2[4];
uint32_t sense_data_length;
uint32_t response_data_length;
uint8_t rspd[];
} sas_ssp_rsp_iu_t;
#define SAS_RSP_HDR_SIZE 24
#define SAS_RSP_DATAPRES_NO_DATA 0x00
#define SAS_RSP_DATAPRES_RESPONSE_DATA 0x01
#define SAS_RSP_DATAPRES_SENSE_DATA 0x02
#define SAS_RSP_TMF_COMPLETE 0x00
#define SAS_RSP_INVALID_FRAME 0x02
#define SAS_RSP_TMF_NOT_SUPPORTED 0x04
#define SAS_RSP_TMF_FAILED 0x05
#define SAS_RSP_TMF_SUCCEEDED 0x08
#define SAS_RSP_TMF_INCORRECT_LUN 0x09
#define SAS_RSP_OVERLAPPED_OIPTTA 0x0A
#define SAS_ABORT_TASK 0x01
#define SAS_ABORT_TASK_SET 0x02
#define SAS_CLEAR_TASK_SET 0x04
#define SAS_LOGICAL_UNIT_RESET 0x08
#define SAS_I_T_NEXUS_RESET 0x10
#define SAS_CLEAR_ACA 0x40
#define SAS_QUERY_TASK 0x80
#define SAS_QUERY_TASK_SET 0x81
#define SAS_QUERY_UNIT_ATTENTION 0x82
#define SAS_PHYNUM_MAX 127
#define SAS_PHYNUM_MASK 0x7f
#define SAS2_PHYNUM_MAX 254
#define SAS2_PHYNUM_MASK 0xff
#define SAS_SMP_MAX_PAYLOAD 1032
#ifdef __cplusplus
}
#endif
#endif