#ifndef _SYS_SBP2_DEFS_H
#define _SYS_SBP2_DEFS_H
#include <sys/sbp2/common.h>
#include <sys/note.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct sbp2_dummy_orb {
sbp2_orbp_t do_next_orb;
uint32_t do_ignored1[2];
uint16_t do_params;
uint16_t do_ignored2;
} sbp2_dummy_orb_t;
#define SBP2_ORB_NOTIFY 0x8000
#define SBP2_ORB_RQ_FMT 0x6000
#define SBP2_ORB_RQ_FMT_SBP2 0x0000
#define SBP2_ORB_RQ_FMT_DUMMY 0x6000
typedef struct sbp2_cmd_orb {
sbp2_orbp_t co_next_orb;
uint32_t co_data_descr[2];
uint16_t co_params;
uint16_t co_data_size;
} sbp2_cmd_orb_t;
#define SBP2_ORB_CMD_DIR 0x0800
#define SBP2_ORB_CMD_SPD 0x0700
#define SBP2_ORB_CMD_SPD_SHIFT 8
#define SBP2_ORB_CMD_MAX_PAYLOAD 0x00F0
#define SBP2_ORB_CMD_MAX_PAYLOAD_SHIFT 4
#define SBP2_ORB_CMD_PT 0x0008
#define SBP2_ORB_CMD_PSZ 0x0007
#define SBP2_ORB_CMD_SPD_S100 0x0000
#define SBP2_ORB_CMD_SPD_S200 0x0100
#define SBP2_ORB_CMD_SPD_S400 0x0200
#define SBP2_ORB_CMD_SPD_S800 0x0300
#define SBP2_ORB_CMD_SPD_S1600 0x0400
#define SBP2_ORB_CMD_SPD_S3200 0x0500
typedef struct sbp2_mgt_orb {
uint32_t mo_fdep1[4];
uint16_t mo_params;
uint16_t mo_fdep2;
uint32_t mo_fdep3;
sbp2_addr_t mo_status_fifo;
} sbp2_mgt_orb_t;
#define SBP2_ORB_MGT_FUNC 0x000F
#define SBP2_ORB_MGT_FUNC_LOGIN 0x0000
#define SBP2_ORB_MGT_FUNC_QUERY_LOGINS 0x0001
#define SBP2_ORB_MGT_FUNC_RECONNECT 0x0003
#define SBP2_ORB_MGT_FUNC_SET_PASSWORD 0x0004
#define SBP2_ORB_MGT_FUNC_LOGOUT 0x0007
#define SBP2_ORB_MGT_FUNC_ABORT_TASK 0x000B
#define SBP2_ORB_MGT_FUNC_ABORT_TASK_SET 0x000C
#define SBP2_ORB_MGT_FUNC_LUN_RESET 0x000E
#define SBP2_ORB_MGT_FUNC_TARGET_RESET 0x000F
typedef struct sbp2_login_orb {
sbp2_addr_t lo_passwd;
sbp2_addr_t lo_resp;
uint16_t lo_params;
uint16_t lo_lun;
uint16_t lo_passwd_len;
uint16_t lo_resp_len;
sbp2_addr_t lo_status_fifo;
} sbp2_login_orb_t;
#define SBP2_ORB_LOGIN_EXCL 0x1000
#define SBP2_ORB_LOGIN_RECONNECT 0x00F0
#define SBP2_ORB_LOGIN_RECONNECT_SHIFT 4
typedef struct sbp2_login_resp {
uint16_t lr_len;
uint16_t lr_login_id;
sbp2_addr_t lr_cmd_agent;
uint16_t lr_reserved;
uint16_t lr_reconnect_hold;
} sbp2_login_resp_t;
typedef struct sbp2_qlogins_orb {
uint32_t qo_reserved1[2];
sbp2_addr_t qo_resp;
uint16_t qo_params;
uint16_t qo_lun;
uint16_t qo_reserved2;
uint16_t qo_len;
sbp2_addr_t qo_status_fifo;
} sbp2_qlogins_orb_t;
typedef struct sbp2_reconnect_orb {
uint32_t ro_reserved1[4];
uint16_t ro_params;
uint16_t ro_login_id;
uint32_t ro_reserved2;
sbp2_addr_t ro_status_fifo;
} sbp2_reconnect_orb_t;
typedef struct sbp2_logout_orb {
uint32_t lo_reserved1[4];
uint16_t lo_params;
uint16_t lo_login_id;
uint32_t lo_reserved2;
sbp2_addr_t lo_status_fifo;
} sbp2_logout_orb_t;
typedef struct sbp2_task_mgt_orb {
sbp2_orbp_t to_orb;
uint32_t to_reserved1[2];
uint16_t to_params;
uint16_t to_login_id;
uint32_t to_reserved;
sbp2_addr_t to_status_fifo;
} sbp2_task_mgt_orb_t;
typedef struct sbp2_status {
uint8_t st_param;
uint8_t st_sbp_status;
uint16_t st_orb_offset_hi;
uint32_t st_orb_offset_lo;
uint32_t st_data[6];
} sbp2_status_t;
#define SBP2_ST_SRC 0xC0
#define SBP2_ST_SRC_SHIFT 6
#define SBP2_ST_RESP 0x30
#define SBP2_ST_RESP_SHIFT 4
#define SBP2_ST_DEAD 0x08
#define SBP2_ST_LEN 0x07
#define SBP2_ST_SRC_ORB 0x00
#define SBP2_ST_SRC_ORB_NULL 0x40
#define SBP2_ST_SRC_UNSOLICITED 0x80
#define SBP2_ST_RESP_COMPLETE 0x00
#define SBP2_ST_RESP_TRANFAIL 0x10
#define SBP2_ST_RESP_ILLREQ 0x20
#define SBP2_ST_RESP_VENDOR 0x30
#define SBP2_ST_SBP_NOINFO 0x00
#define SBP2_ST_SBP_REQ_TYPE 0x01
#define SBP2_ST_SBP_SPD 0x02
#define SBP2_ST_SBP_PSZ 0x03
#define SBP2_ST_SBP_ACCESS 0x04
#define SBP2_ST_SBP_LUN 0x05
#define SBP2_ST_SBP_PAYLOAD 0x06
#define SBP2_ST_SBP_RSRC 0x08
#define SBP2_ST_SBP_FUNC 0x09
#define SBP2_ST_SBP_LOGIN_ID 0x0A
#define SBP2_ST_SBP_DUMMY_ORB 0x0B
#define SBP2_ST_SBP_REQ_ABORT 0x0C
#define SBP2_ST_SBP_UNSPEC 0xFF
#define SBP2_ST_SBP_OBJ 0xC0
#define SBP2_ST_SBP_ERR 0x0F
#define SBP2_ST_SBP_OBJ_ORB 0x00
#define SBP2_ST_SBP_OBJ_DATA 0x40
#define SBP2_ST_SBP_OBJ_PT 0x80
#define SBP2_ST_SBP_OBJ_UNSPEC 0xC0
#define SBP2_ST_SBP_ERR_ACK 0x00
#define SBP2_ST_SBP_ERR_TIMEOUT 0x02
#define SBP2_ST_SBP_ERR_ACK_BUSY_X 0x04
#define SBP2_ST_SBP_ERR_ACK_BUSY_A 0x05
#define SBP2_ST_SBP_ERR_ACK_BUSY_B 0x06
#define SBP2_ST_SBP_ERR_TARDY 0x0B
#define SBP2_ST_SBP_ERR_CONFLICT 0x0C
#define SBP2_ST_SBP_ERR_DATA 0x0D
#define SBP2_ST_SBP_ERR_TYPE 0x0E
#define SBP2_ST_SBP_ERR_ADDR 0x0F
#define SBP2_AGENT_STATE_OFFSET 0x00
#define SBP2_AGENT_RESET_OFFSET 0x04
#define SBP2_ORB_POINTER_OFFSET 0x08
#define SBP2_DOORBELL_OFFSET 0x10
#define SBP2_UNSOLICITED_STATUS_ENABLE_OFFSET 0x14
#define SBP2_AGENT_STATE_RESET 0
#define SBP2_AGENT_STATE_ACTIVE 1
#define SBP2_AGENT_STATE_SUSPENDED 2
#define SBP2_AGENT_STATE_DEAD 3
#define SBP2_PT_ENT_SIZE 8
#define SBP2_PT_SEGSIZE_MAX (65536 - 8)
typedef struct sbp2_pt_unrestricted {
uint16_t pt_seg_len;
uint16_t pt_seg_base_hi;
uint32_t pt_seg_base_lo;
} sbp2_pt_unrestricted_t;
#define SBP2_KT_MGT_AGENT 1
#define SBP2_KV_MGT_AGENT 0x14
#define SBP2_KT_LUN 0
#define SBP2_KV_LUN 0x14
#define SBP2_KT_UNCHAR 0
#define SBP2_KV_UNCHAR 0x3A
#define SBP2_LUN_TYPE 0x001F0000
#define SBP2_LUN_TYPE_SHIFT 16
#define SBP2_LUN_NUM 0x0000FFFF
#define SBP2_UNCHAR_MOT 0x0000FF00
#define SBP2_UNCHAR_MOT_SHIFT 8
#define SBP2_UNCHAR_ORB_SIZE 0x000000FF
_NOTE(SCHEME_PROTECTS_DATA("unique per ORB", { sbp2_dummy_orb sbp2_cmd_orb
sbp2_mgt_orb sbp2_login_orb sbp2_login_resp sbp2_qlogins_orb
sbp2_reconnect_orb sbp2_logout_orb sbp2_task_mgt_orb sbp2_status
sbp2_pt_unrestricted }))
#ifdef __cplusplus
}
#endif
#endif