#ifndef _SYS_SCSI_IMPL_TRANSPORT_H
#define _SYS_SCSI_IMPL_TRANSPORT_H
#include <sys/modctl.h>
#include <sys/note.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _KERNEL
typedef struct __scsi_iportmap scsi_hba_iportmap_t;
typedef struct __scsi_tgtmap scsi_hba_tgtmap_t;
typedef struct scsi_hba_tran scsi_hba_tran_t;
struct scsi_hba_tran {
dev_info_t *tran_hba_dip;
void *tran_hba_private;
void *tran_tgt_private;
struct scsi_device *tran_sd;
int (*tran_tgt_init)(
dev_info_t *hba_dip,
dev_info_t *tgt_dip,
scsi_hba_tran_t *tran,
struct scsi_device *sd);
int (*tran_tgt_probe)(
struct scsi_device *sd,
int (*callback)(
void));
void (*tran_tgt_free)(
dev_info_t *hba_dip,
dev_info_t *tgt_dip,
scsi_hba_tran_t *tran,
struct scsi_device *sd);
int (*tran_start)(
struct scsi_address *ap,
struct scsi_pkt *pkt);
int (*tran_reset)(
struct scsi_address *ap,
int level);
int (*tran_abort)(
struct scsi_address *ap,
struct scsi_pkt *pkt);
int (*tran_getcap)(
struct scsi_address *ap,
char *cap,
int whom);
int (*tran_setcap)(
struct scsi_address *ap,
char *cap,
int value,
int whom);
struct scsi_pkt *(*tran_init_pkt)(
struct scsi_address *ap,
struct scsi_pkt *pkt,
struct buf *bp,
int cmdlen,
int statuslen,
int tgtlen,
int flags,
int (*callback)(
caddr_t arg),
caddr_t callback_arg);
void (*tran_destroy_pkt)(
struct scsi_address *ap,
struct scsi_pkt *pkt);
void (*tran_dmafree)(
struct scsi_address *ap,
struct scsi_pkt *pkt);
void (*tran_sync_pkt)(
struct scsi_address *ap,
struct scsi_pkt *pkt);
int (*tran_reset_notify)(
struct scsi_address *ap,
int flag,
void (*callback)(caddr_t),
caddr_t arg);
int (*tran_get_bus_addr)(
struct scsi_device *sd,
char *name,
int len);
int (*tran_get_name)(
struct scsi_device *sd,
char *name,
int len);
int (*tran_clear_aca)(
struct scsi_address *ap);
int (*tran_clear_task_set)(
struct scsi_address *ap);
int (*tran_terminate_task)(
struct scsi_address *ap,
struct scsi_pkt *pkt);
int (*tran_get_eventcookie)(
dev_info_t *hba_dip,
dev_info_t *tgt_dip,
char *name,
ddi_eventcookie_t *eventp);
int (*tran_add_eventcall)(
dev_info_t *hba_dip,
dev_info_t *tgt_dip,
ddi_eventcookie_t event,
void (*callback)(
dev_info_t *tgt_dip,
ddi_eventcookie_t event,
void *arg,
void *bus_impldata),
void *arg,
ddi_callback_id_t *cb_id);
int (*tran_remove_eventcall)(dev_info_t *devi,
ddi_callback_id_t cb_id);
int (*tran_post_event)(
dev_info_t *hba_dip,
dev_info_t *tgt_dip,
ddi_eventcookie_t event,
void *bus_impldata);
int (*tran_quiesce)(
dev_info_t *hba_dip);
int (*tran_unquiesce)(
dev_info_t *hba_dip);
int (*tran_bus_reset)(
dev_info_t *hba_dip,
int level);
int tran_hba_flags;
uint_t tran_obs1;
uchar_t tran_obs2;
uchar_t tran_obs3;
kmutex_t tran_open_lock;
uint64_t tran_open_flag;
int (*tran_bus_config)(
dev_info_t *hba_dip,
uint_t flag,
ddi_bus_config_op_t op,
void *arg,
dev_info_t **tgt_dipp);
int (*tran_bus_unconfig)(
dev_info_t *hba_dip,
uint_t flag,
ddi_bus_config_op_t op,
void *arg);
int (*tran_bus_power)(
dev_info_t *dip,
void *impl_arg,
pm_bus_power_op_t op,
void *arg,
void *result);
int tran_interconnect_type;
int (*tran_pkt_constructor)(
struct scsi_pkt *pkt,
scsi_hba_tran_t *tran,
int kmflag);
void (*tran_pkt_destructor)(
struct scsi_pkt *pkt,
scsi_hba_tran_t *tran);
kmem_cache_t *tran_pkt_cache_ptr;
uint_t tran_hba_len;
int (*tran_setup_pkt)(
struct scsi_pkt *pkt,
int (*callback)(
caddr_t arg),
caddr_t callback_arg);
void (*tran_teardown_pkt)(
struct scsi_pkt *pkt);
ddi_dma_attr_t tran_dma_attr;
void *tran_extension;
int tran_fm_capable;
dev_info_t *tran_iport_dip;
scsi_hba_iportmap_t *tran_iportmap;
scsi_hba_tgtmap_t *tran_tgtmap;
#ifdef SCSI_SIZE_CLEAN_VERIFY
int _pad[8];
#endif
};
size_t scsi_hba_tran_size();
#ifdef __lock_lint
_NOTE(SCHEME_PROTECTS_DATA("stable data",
scsi_hba_tran::tran_sd
scsi_hba_tran::tran_hba_dip
scsi_hba_tran::tran_hba_flags
scsi_hba_tran::tran_open_flag
scsi_hba_tran::tran_pkt_cache_ptr))
_NOTE(SCHEME_PROTECTS_DATA("serialized by target driver", \
scsi_hba_tran::tran_dma_attr.dma_attr_granular))
#endif
void scsi_initialize_hba_interface(void);
#ifdef NO_SCSI_FINI_YET
void scsi_uninitialize_hba_interface(void);
#endif
int scsi_hba_init(
struct modlinkage *modlp);
void scsi_hba_fini(
struct modlinkage *modlp);
int scsi_hba_attach_setup(
dev_info_t *hba_dip,
ddi_dma_attr_t *hba_dma_attr,
scsi_hba_tran_t *tran,
int flags);
int scsi_hba_detach(
dev_info_t *hba_dip);
scsi_hba_tran_t *scsi_hba_tran_alloc(
dev_info_t *hba_dip,
int flags);
int scsi_tran_ext_alloc(
scsi_hba_tran_t *tran,
size_t length,
int flags);
void scsi_tran_ext_free(
scsi_hba_tran_t *tran,
size_t length);
void scsi_hba_tran_free(
scsi_hba_tran_t *tran);
int scsi_hba_probe(
struct scsi_device *sd,
int (*callback)(void));
int scsi_hba_probe_pi(
struct scsi_device *sd,
int (*callback)(void),
int pi);
int scsi_hba_ua_get_reportdev(
struct scsi_device *sd,
char *ba,
int len);
int scsi_hba_ua_get(
struct scsi_device *sd,
char *ua,
int len);
char *scsi_get_device_type_string(
char *prop_name,
dev_info_t *hba_dip,
struct scsi_device *sd);
int scsi_get_scsi_maxluns(
struct scsi_device *sd);
int scsi_get_scsi_options(
struct scsi_device *sd,
int default_scsi_options);
int scsi_get_device_type_scsi_options(
dev_info_t *hba_dip,
struct scsi_device *sd,
int default_scsi_options);
struct scsi_pkt *scsi_hba_pkt_alloc(
dev_info_t *hba_dip,
struct scsi_address *ap,
int cmdlen,
int statuslen,
int tgtlen,
int hbalen,
int (*callback)(caddr_t),
caddr_t arg);
void scsi_hba_pkt_free(
struct scsi_address *ap,
struct scsi_pkt *pkt);
int scsi_hba_lookup_capstr(
char *capstr);
int scsi_hba_in_panic(void);
int scsi_hba_open(
dev_t *devp,
int flags,
int otyp,
cred_t *credp);
int scsi_hba_close(
dev_t dev,
int flag,
int otyp,
cred_t *credp);
int scsi_hba_ioctl(
dev_t dev,
int cmd,
intptr_t arg,
int mode,
cred_t *credp,
int *rvalp);
void scsi_hba_nodename_compatible_get(
struct scsi_inquiry *inq,
char *binding_set,
int dtype_node,
char *compat0,
char **nodenamep,
char ***compatiblep,
int *ncompatiblep);
void scsi_hba_nodename_compatible_free(
char *nodename,
char **compatible);
int scsi_device_prop_update_inqstring(
struct scsi_device *sd,
char *name,
char *data,
size_t len);
void scsi_hba_pkt_comp(
struct scsi_pkt *pkt);
int scsi_device_identity(
struct scsi_device *sd,
int (*callback)(void));
char *scsi_hba_iport_unit_address(
dev_info_t *dip);
int scsi_hba_iport_register(
dev_info_t *dip,
char *port);
int scsi_hba_iport_exist(
dev_info_t *dip);
dev_info_t *scsi_hba_iport_find(
dev_info_t *pdip,
char *portnm);
#define SCSI_HBA_TRAN_CLONE 0x01
#define SCSI_HBA_TRAN_PHCI 0x02
#define SCSI_HBA_TRAN_CDB 0x04
#define SCSI_HBA_TRAN_SCB 0x08
#define SCSI_HBA_HBA 0x10
#define SCSI_HBA_ADDR_SPI 0x20
#define SCSI_HBA_ADDR_COMPLEX 0x40
#define SCSI_HBA_SCSA_PHCI 0x10000
#define SCSI_HBA_SCSA_TA 0x20000
#define SCSI_HBA_SCSA_FM 0x40000
#define SCSI_HBA_CANSLEEP 0x01
#define SCSA_FLAVOR_SCSI_DEVICE NDI_FLAVOR_VANILLA
#define SCSA_FLAVOR_SMP 1
#define SCSA_FLAVOR_IPORT 2
#define SCSA_NFLAVORS 3
#define SCSI_HBA_MAX_IPORTS 32
int scsi_hba_iportmap_create(
dev_info_t *hba_dip,
int csync_usec,
int stable_usec,
scsi_hba_iportmap_t **iportmapp);
int scsi_hba_iportmap_iport_add(
scsi_hba_iportmap_t *iportmap,
char *iport_addr,
void *iport_priv);
int scsi_hba_iportmap_iport_remove(
scsi_hba_iportmap_t *iportmap,
char *iport_addr);
void scsi_hba_iportmap_destroy(scsi_hba_iportmap_t *iportmap);
typedef enum {
SCSI_TM_FULLSET = 0,
SCSI_TM_PERADDR
} scsi_tgtmap_mode_t;
typedef enum {
SCSI_TGT_SCSI_DEVICE = 0,
SCSI_TGT_SMP_DEVICE,
SCSI_TGT_NTYPES
} scsi_tgtmap_tgt_type_t;
typedef enum {
SCSI_TGT_DEACT_RSN_GONE = 0,
SCSI_TGT_DEACT_RSN_CFG_FAIL,
SCSI_TGT_DEACT_RSN_UNSTBL
} scsi_tgtmap_deact_rsn_t;
typedef void (*scsi_tgt_activate_cb_t)(
void *tgtmap_priv,
char *tgt_addr,
scsi_tgtmap_tgt_type_t tgt_type,
void **tgt_privp);
typedef boolean_t (*scsi_tgt_deactivate_cb_t)(
void *tgtmap_priv,
char *tgt_addr,
scsi_tgtmap_tgt_type_t tgt_type,
void *tgt_priv,
scsi_tgtmap_deact_rsn_t tgt_deact_rsn);
int scsi_hba_tgtmap_create(
dev_info_t *iport_dip,
scsi_tgtmap_mode_t rpt_mode,
int csync_usec,
int stable_usec,
void *tgtmap_priv,
scsi_tgt_activate_cb_t activate_cb,
scsi_tgt_deactivate_cb_t deactivate_cb,
scsi_hba_tgtmap_t **tgtmapp);
int scsi_hba_tgtmap_set_begin(scsi_hba_tgtmap_t *tgtmap);
int scsi_hba_tgtmap_set_add(
scsi_hba_tgtmap_t *tgtmap,
scsi_tgtmap_tgt_type_t tgt_type,
char *tgt_addr,
void *tgt_priv);
int scsi_hba_tgtmap_set_end(
scsi_hba_tgtmap_t *tgtmap,
uint_t flags);
int scsi_hba_tgtmap_set_flush(scsi_hba_tgtmap_t *tgtmap);
int scsi_hba_tgtmap_tgt_add(
scsi_hba_tgtmap_t *tgtmap,
scsi_tgtmap_tgt_type_t tgt_type,
char *tgt_addr,
void *tgt_priv);
int scsi_hba_tgtmap_tgt_remove(
scsi_hba_tgtmap_t *tgtmap,
scsi_tgtmap_tgt_type_t tgt_type,
char *tgt_addr);
void scsi_hba_tgtmap_destroy(scsi_hba_tgtmap_t *tgt_map);
void scsi_hba_tgtmap_scan_luns(scsi_hba_tgtmap_t *tgt_map,
char *tgt_addr);
#define INST_MINOR_SHIFT 6
#define TRAN_MINOR_MASK ((1 << INST_MINOR_SHIFT) - 1)
#define TRAN_OPEN_EXCL (uint64_t)-1
#define DEVCTL_MINOR 0
#define SCSI_MINOR 1
#define INST2DEVCTL(x) (((x) << INST_MINOR_SHIFT) | DEVCTL_MINOR)
#define INST2SCSI(x) (((x) << INST_MINOR_SHIFT) | SCSI_MINOR)
#define MINOR2INST(x) ((x) >> INST_MINOR_SHIFT)
#define SCSI_HBA_PROP_RECEPTACLE_LABEL "receptacle-label"
#endif
#ifdef __cplusplus
}
#endif
#endif