1c66ac9dbSNicholas Bellinger #ifndef TARGET_CORE_ALUA_H 2c66ac9dbSNicholas Bellinger #define TARGET_CORE_ALUA_H 3c66ac9dbSNicholas Bellinger 4c66ac9dbSNicholas Bellinger /* 5c66ac9dbSNicholas Bellinger * INQUIRY response data, TPGS Field 6c66ac9dbSNicholas Bellinger * 7c66ac9dbSNicholas Bellinger * from spc4r17 section 6.4.2 Table 135 8c66ac9dbSNicholas Bellinger */ 9c66ac9dbSNicholas Bellinger #define TPGS_NO_ALUA 0x00 10125d0119SHannes Reinecke #define TPGS_IMPLICIT_ALUA 0x10 11125d0119SHannes Reinecke #define TPGS_EXPLICIT_ALUA 0x20 12c66ac9dbSNicholas Bellinger 13c66ac9dbSNicholas Bellinger /* 14c66ac9dbSNicholas Bellinger * ASYMMETRIC ACCESS STATE field 15c66ac9dbSNicholas Bellinger * 16c66094bfSHannes Reinecke * from spc4r36j section 6.37 Table 307 17c66ac9dbSNicholas Bellinger */ 1873f3bf51SHannes Reinecke #define ALUA_ACCESS_STATE_ACTIVE_OPTIMIZED 0x0 19c66ac9dbSNicholas Bellinger #define ALUA_ACCESS_STATE_ACTIVE_NON_OPTIMIZED 0x1 20c66ac9dbSNicholas Bellinger #define ALUA_ACCESS_STATE_STANDBY 0x2 21c66ac9dbSNicholas Bellinger #define ALUA_ACCESS_STATE_UNAVAILABLE 0x3 22c66094bfSHannes Reinecke #define ALUA_ACCESS_STATE_LBA_DEPENDENT 0x4 23c66ac9dbSNicholas Bellinger #define ALUA_ACCESS_STATE_OFFLINE 0xe 24c66ac9dbSNicholas Bellinger #define ALUA_ACCESS_STATE_TRANSITION 0xf 25c66ac9dbSNicholas Bellinger 26c66ac9dbSNicholas Bellinger /* 27c0dc941eSHannes Reinecke * from spc4r36j section 6.37 Table 306 28c0dc941eSHannes Reinecke */ 29c0dc941eSHannes Reinecke #define ALUA_T_SUP 0x80 30c0dc941eSHannes Reinecke #define ALUA_O_SUP 0x40 31c0dc941eSHannes Reinecke #define ALUA_LBD_SUP 0x10 32c0dc941eSHannes Reinecke #define ALUA_U_SUP 0x08 33c0dc941eSHannes Reinecke #define ALUA_S_SUP 0x04 34c0dc941eSHannes Reinecke #define ALUA_AN_SUP 0x02 35c0dc941eSHannes Reinecke #define ALUA_AO_SUP 0x01 36c0dc941eSHannes Reinecke 37c0dc941eSHannes Reinecke /* 38c66ac9dbSNicholas Bellinger * REPORT_TARGET_PORT_GROUP STATUS CODE 39c66ac9dbSNicholas Bellinger * 40c66ac9dbSNicholas Bellinger * from spc4r17 section 6.27 Table 246 41c66ac9dbSNicholas Bellinger */ 42c66ac9dbSNicholas Bellinger #define ALUA_STATUS_NONE 0x00 43125d0119SHannes Reinecke #define ALUA_STATUS_ALTERED_BY_EXPLICIT_STPG 0x01 44125d0119SHannes Reinecke #define ALUA_STATUS_ALTERED_BY_IMPLICIT_ALUA 0x02 45c66ac9dbSNicholas Bellinger 46c66ac9dbSNicholas Bellinger /* 47c66ac9dbSNicholas Bellinger * From spc4r17, Table D.1: ASC and ASCQ Assignement 48c66ac9dbSNicholas Bellinger */ 49c66ac9dbSNicholas Bellinger #define ASCQ_04H_ALUA_STATE_TRANSITION 0x0a 50c66ac9dbSNicholas Bellinger #define ASCQ_04H_ALUA_TG_PT_STANDBY 0x0b 51c66ac9dbSNicholas Bellinger #define ASCQ_04H_ALUA_TG_PT_UNAVAILABLE 0x0c 52c66ac9dbSNicholas Bellinger #define ASCQ_04H_ALUA_OFFLINE 0x12 53c66ac9dbSNicholas Bellinger 54c66ac9dbSNicholas Bellinger /* 55c66ac9dbSNicholas Bellinger * Used as the default for Active/NonOptimized delay (in milliseconds) 56c66ac9dbSNicholas Bellinger * This can also be changed via configfs on a per target port group basis.. 57c66ac9dbSNicholas Bellinger */ 58c66ac9dbSNicholas Bellinger #define ALUA_DEFAULT_NONOP_DELAY_MSECS 100 59c66ac9dbSNicholas Bellinger #define ALUA_MAX_NONOP_DELAY_MSECS 10000 /* 10 seconds */ 60c66ac9dbSNicholas Bellinger /* 61125d0119SHannes Reinecke * Used for implicit and explicit ALUA transitional delay, that is disabled 62c66ac9dbSNicholas Bellinger * by default, and is intended to be used for debugging client side ALUA code. 63c66ac9dbSNicholas Bellinger */ 64c66ac9dbSNicholas Bellinger #define ALUA_DEFAULT_TRANS_DELAY_MSECS 0 65c66ac9dbSNicholas Bellinger #define ALUA_MAX_TRANS_DELAY_MSECS 30000 /* 30 seconds */ 66c66ac9dbSNicholas Bellinger /* 67125d0119SHannes Reinecke * Used for the recommended application client implicit transition timeout 685b9a4d72SNicholas Bellinger * in seconds, returned by the REPORT_TARGET_PORT_GROUPS w/ extended header. 695b9a4d72SNicholas Bellinger */ 70125d0119SHannes Reinecke #define ALUA_DEFAULT_IMPLICIT_TRANS_SECS 0 71125d0119SHannes Reinecke #define ALUA_MAX_IMPLICIT_TRANS_SECS 255 725b9a4d72SNicholas Bellinger /* 73c66ac9dbSNicholas Bellinger * Used by core_alua_update_tpg_primary_metadata() and 74c66ac9dbSNicholas Bellinger * core_alua_update_tpg_secondary_metadata() 75c66ac9dbSNicholas Bellinger */ 76c66ac9dbSNicholas Bellinger #define ALUA_METADATA_PATH_LEN 512 77c66ac9dbSNicholas Bellinger /* 78c66ac9dbSNicholas Bellinger * Used by core_alua_update_tpg_secondary_metadata() 79c66ac9dbSNicholas Bellinger */ 80c66ac9dbSNicholas Bellinger #define ALUA_SECONDARY_METADATA_WWN_LEN 256 81c66ac9dbSNicholas Bellinger 821e0b9403SHannes Reinecke /* Used by core_alua_update_tpg_(primary,secondary)_metadata */ 831e0b9403SHannes Reinecke #define ALUA_MD_BUF_LEN 1024 841e0b9403SHannes Reinecke 85c66ac9dbSNicholas Bellinger extern struct kmem_cache *t10_alua_lu_gp_cache; 86c66ac9dbSNicholas Bellinger extern struct kmem_cache *t10_alua_lu_gp_mem_cache; 87c66ac9dbSNicholas Bellinger extern struct kmem_cache *t10_alua_tg_pt_gp_cache; 88c66ac9dbSNicholas Bellinger extern struct kmem_cache *t10_alua_tg_pt_gp_mem_cache; 89c66ac9dbSNicholas Bellinger 90de103c93SChristoph Hellwig extern sense_reason_t target_emulate_report_target_port_groups(struct se_cmd *); 91de103c93SChristoph Hellwig extern sense_reason_t target_emulate_set_target_port_groups(struct se_cmd *); 92c66094bfSHannes Reinecke extern sense_reason_t target_emulate_report_referrals(struct se_cmd *); 93c66ac9dbSNicholas Bellinger extern int core_alua_check_nonop_delay(struct se_cmd *); 94c66ac9dbSNicholas Bellinger extern int core_alua_do_port_transition(struct t10_alua_tg_pt_gp *, 95c66ac9dbSNicholas Bellinger struct se_device *, struct se_port *, 96c66ac9dbSNicholas Bellinger struct se_node_acl *, int, int); 97c66ac9dbSNicholas Bellinger extern char *core_alua_dump_status(int); 98c66ac9dbSNicholas Bellinger extern struct t10_alua_lu_gp *core_alua_allocate_lu_gp(const char *, int); 99c66ac9dbSNicholas Bellinger extern int core_alua_set_lu_gp_id(struct t10_alua_lu_gp *, u16); 100c66ac9dbSNicholas Bellinger extern void core_alua_free_lu_gp(struct t10_alua_lu_gp *); 101c66ac9dbSNicholas Bellinger extern void core_alua_free_lu_gp_mem(struct se_device *); 102c66ac9dbSNicholas Bellinger extern struct t10_alua_lu_gp *core_alua_get_lu_gp_by_name(const char *); 103c66ac9dbSNicholas Bellinger extern void core_alua_put_lu_gp_from_name(struct t10_alua_lu_gp *); 104c66ac9dbSNicholas Bellinger extern void __core_alua_attach_lu_gp_mem(struct t10_alua_lu_gp_member *, 105c66ac9dbSNicholas Bellinger struct t10_alua_lu_gp *); 106c66ac9dbSNicholas Bellinger extern void __core_alua_drop_lu_gp_mem(struct t10_alua_lu_gp_member *, 107c66ac9dbSNicholas Bellinger struct t10_alua_lu_gp *); 108c66ac9dbSNicholas Bellinger extern void core_alua_drop_lu_gp_dev(struct se_device *); 109c66ac9dbSNicholas Bellinger extern struct t10_alua_tg_pt_gp *core_alua_allocate_tg_pt_gp( 1100fd97ccfSChristoph Hellwig struct se_device *, const char *, int); 111c66ac9dbSNicholas Bellinger extern int core_alua_set_tg_pt_gp_id(struct t10_alua_tg_pt_gp *, u16); 112c66ac9dbSNicholas Bellinger extern struct t10_alua_tg_pt_gp_member *core_alua_allocate_tg_pt_gp_mem( 113c66ac9dbSNicholas Bellinger struct se_port *); 114c66ac9dbSNicholas Bellinger extern void core_alua_free_tg_pt_gp(struct t10_alua_tg_pt_gp *); 115c66ac9dbSNicholas Bellinger extern void core_alua_free_tg_pt_gp_mem(struct se_port *); 116c66ac9dbSNicholas Bellinger extern void __core_alua_attach_tg_pt_gp_mem(struct t10_alua_tg_pt_gp_member *, 117c66ac9dbSNicholas Bellinger struct t10_alua_tg_pt_gp *); 118c66ac9dbSNicholas Bellinger extern ssize_t core_alua_show_tg_pt_gp_info(struct se_port *, char *); 119c66ac9dbSNicholas Bellinger extern ssize_t core_alua_store_tg_pt_gp_info(struct se_port *, const char *, 120c66ac9dbSNicholas Bellinger size_t); 121c66ac9dbSNicholas Bellinger extern ssize_t core_alua_show_access_type(struct t10_alua_tg_pt_gp *, char *); 122c66ac9dbSNicholas Bellinger extern ssize_t core_alua_store_access_type(struct t10_alua_tg_pt_gp *, 123c66ac9dbSNicholas Bellinger const char *, size_t); 124c66ac9dbSNicholas Bellinger extern ssize_t core_alua_show_nonop_delay_msecs(struct t10_alua_tg_pt_gp *, 125c66ac9dbSNicholas Bellinger char *); 126c66ac9dbSNicholas Bellinger extern ssize_t core_alua_store_nonop_delay_msecs(struct t10_alua_tg_pt_gp *, 127c66ac9dbSNicholas Bellinger const char *, size_t); 128c66ac9dbSNicholas Bellinger extern ssize_t core_alua_show_trans_delay_msecs(struct t10_alua_tg_pt_gp *, 129c66ac9dbSNicholas Bellinger char *); 130c66ac9dbSNicholas Bellinger extern ssize_t core_alua_store_trans_delay_msecs(struct t10_alua_tg_pt_gp *, 131c66ac9dbSNicholas Bellinger const char *, size_t); 132125d0119SHannes Reinecke extern ssize_t core_alua_show_implicit_trans_secs(struct t10_alua_tg_pt_gp *, 1335b9a4d72SNicholas Bellinger char *); 134125d0119SHannes Reinecke extern ssize_t core_alua_store_implicit_trans_secs(struct t10_alua_tg_pt_gp *, 1355b9a4d72SNicholas Bellinger const char *, size_t); 136c66ac9dbSNicholas Bellinger extern ssize_t core_alua_show_preferred_bit(struct t10_alua_tg_pt_gp *, 137c66ac9dbSNicholas Bellinger char *); 138c66ac9dbSNicholas Bellinger extern ssize_t core_alua_store_preferred_bit(struct t10_alua_tg_pt_gp *, 139c66ac9dbSNicholas Bellinger const char *, size_t); 140c66ac9dbSNicholas Bellinger extern ssize_t core_alua_show_offline_bit(struct se_lun *, char *); 141c66ac9dbSNicholas Bellinger extern ssize_t core_alua_store_offline_bit(struct se_lun *, const char *, 142c66ac9dbSNicholas Bellinger size_t); 143c66ac9dbSNicholas Bellinger extern ssize_t core_alua_show_secondary_status(struct se_lun *, char *); 144c66ac9dbSNicholas Bellinger extern ssize_t core_alua_store_secondary_status(struct se_lun *, 145c66ac9dbSNicholas Bellinger const char *, size_t); 146c66ac9dbSNicholas Bellinger extern ssize_t core_alua_show_secondary_write_metadata(struct se_lun *, 147c66ac9dbSNicholas Bellinger char *); 148c66ac9dbSNicholas Bellinger extern ssize_t core_alua_store_secondary_write_metadata(struct se_lun *, 149c66ac9dbSNicholas Bellinger const char *, size_t); 1500fd97ccfSChristoph Hellwig extern int core_setup_alua(struct se_device *); 151de103c93SChristoph Hellwig extern sense_reason_t target_alua_state_check(struct se_cmd *cmd); 152c66ac9dbSNicholas Bellinger 153c66ac9dbSNicholas Bellinger #endif /* TARGET_CORE_ALUA_H */ 154