Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 2 | #ifndef TARGET_CORE_ALUA_H |
| 3 | #define TARGET_CORE_ALUA_H |
| 4 | |
Bart Van Assche | 8dcf07b | 2016-11-14 15:47:14 -0800 | [diff] [blame] | 5 | #include <target/target_core_base.h> |
| 6 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 7 | /* |
| 8 | * INQUIRY response data, TPGS Field |
| 9 | * |
| 10 | * from spc4r17 section 6.4.2 Table 135 |
| 11 | */ |
| 12 | #define TPGS_NO_ALUA 0x00 |
Hannes Reinecke | 125d011 | 2013-11-19 09:07:46 +0100 | [diff] [blame] | 13 | #define TPGS_IMPLICIT_ALUA 0x10 |
| 14 | #define TPGS_EXPLICIT_ALUA 0x20 |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 15 | |
| 16 | /* |
| 17 | * ASYMMETRIC ACCESS STATE field |
| 18 | * |
Hannes Reinecke | c66094b | 2013-12-17 09:18:49 +0100 | [diff] [blame] | 19 | * from spc4r36j section 6.37 Table 307 |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 20 | */ |
Hannes Reinecke | 73f3bf5 | 2013-11-19 09:07:48 +0100 | [diff] [blame] | 21 | #define ALUA_ACCESS_STATE_ACTIVE_OPTIMIZED 0x0 |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 22 | #define ALUA_ACCESS_STATE_ACTIVE_NON_OPTIMIZED 0x1 |
| 23 | #define ALUA_ACCESS_STATE_STANDBY 0x2 |
| 24 | #define ALUA_ACCESS_STATE_UNAVAILABLE 0x3 |
Hannes Reinecke | c66094b | 2013-12-17 09:18:49 +0100 | [diff] [blame] | 25 | #define ALUA_ACCESS_STATE_LBA_DEPENDENT 0x4 |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 26 | #define ALUA_ACCESS_STATE_OFFLINE 0xe |
| 27 | #define ALUA_ACCESS_STATE_TRANSITION 0xf |
| 28 | |
| 29 | /* |
Hannes Reinecke | c0dc941 | 2013-11-19 09:07:49 +0100 | [diff] [blame] | 30 | * from spc4r36j section 6.37 Table 306 |
| 31 | */ |
| 32 | #define ALUA_T_SUP 0x80 |
| 33 | #define ALUA_O_SUP 0x40 |
| 34 | #define ALUA_LBD_SUP 0x10 |
| 35 | #define ALUA_U_SUP 0x08 |
| 36 | #define ALUA_S_SUP 0x04 |
| 37 | #define ALUA_AN_SUP 0x02 |
| 38 | #define ALUA_AO_SUP 0x01 |
| 39 | |
| 40 | /* |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 41 | * REPORT_TARGET_PORT_GROUP STATUS CODE |
| 42 | * |
| 43 | * from spc4r17 section 6.27 Table 246 |
| 44 | */ |
| 45 | #define ALUA_STATUS_NONE 0x00 |
Hannes Reinecke | 125d011 | 2013-11-19 09:07:46 +0100 | [diff] [blame] | 46 | #define ALUA_STATUS_ALTERED_BY_EXPLICIT_STPG 0x01 |
| 47 | #define ALUA_STATUS_ALTERED_BY_IMPLICIT_ALUA 0x02 |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 48 | |
| 49 | /* |
| 50 | * From spc4r17, Table D.1: ASC and ASCQ Assignement |
| 51 | */ |
| 52 | #define ASCQ_04H_ALUA_STATE_TRANSITION 0x0a |
| 53 | #define ASCQ_04H_ALUA_TG_PT_STANDBY 0x0b |
| 54 | #define ASCQ_04H_ALUA_TG_PT_UNAVAILABLE 0x0c |
| 55 | #define ASCQ_04H_ALUA_OFFLINE 0x12 |
| 56 | |
| 57 | /* |
| 58 | * Used as the default for Active/NonOptimized delay (in milliseconds) |
| 59 | * This can also be changed via configfs on a per target port group basis.. |
| 60 | */ |
| 61 | #define ALUA_DEFAULT_NONOP_DELAY_MSECS 100 |
| 62 | #define ALUA_MAX_NONOP_DELAY_MSECS 10000 /* 10 seconds */ |
| 63 | /* |
Hannes Reinecke | 125d011 | 2013-11-19 09:07:46 +0100 | [diff] [blame] | 64 | * Used for implicit and explicit ALUA transitional delay, that is disabled |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 65 | * by default, and is intended to be used for debugging client side ALUA code. |
| 66 | */ |
| 67 | #define ALUA_DEFAULT_TRANS_DELAY_MSECS 0 |
| 68 | #define ALUA_MAX_TRANS_DELAY_MSECS 30000 /* 30 seconds */ |
| 69 | /* |
Hannes Reinecke | 125d011 | 2013-11-19 09:07:46 +0100 | [diff] [blame] | 70 | * Used for the recommended application client implicit transition timeout |
Nicholas Bellinger | 5b9a4d7 | 2012-05-16 22:02:34 -0700 | [diff] [blame] | 71 | * in seconds, returned by the REPORT_TARGET_PORT_GROUPS w/ extended header. |
| 72 | */ |
Hannes Reinecke | 125d011 | 2013-11-19 09:07:46 +0100 | [diff] [blame] | 73 | #define ALUA_DEFAULT_IMPLICIT_TRANS_SECS 0 |
| 74 | #define ALUA_MAX_IMPLICIT_TRANS_SECS 255 |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 75 | |
Hannes Reinecke | 1e0b940 | 2013-12-17 09:18:44 +0100 | [diff] [blame] | 76 | /* Used by core_alua_update_tpg_(primary,secondary)_metadata */ |
| 77 | #define ALUA_MD_BUF_LEN 1024 |
| 78 | |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 79 | extern struct kmem_cache *t10_alua_lu_gp_cache; |
| 80 | extern struct kmem_cache *t10_alua_lu_gp_mem_cache; |
| 81 | extern struct kmem_cache *t10_alua_tg_pt_gp_cache; |
Hannes Reinecke | 229d4f1 | 2013-12-17 09:18:50 +0100 | [diff] [blame] | 82 | extern struct kmem_cache *t10_alua_lba_map_cache; |
| 83 | extern struct kmem_cache *t10_alua_lba_map_mem_cache; |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 84 | |
Christoph Hellwig | de103c9 | 2012-11-06 12:24:09 -0800 | [diff] [blame] | 85 | extern sense_reason_t target_emulate_report_target_port_groups(struct se_cmd *); |
| 86 | extern sense_reason_t target_emulate_set_target_port_groups(struct se_cmd *); |
Hannes Reinecke | c66094b | 2013-12-17 09:18:49 +0100 | [diff] [blame] | 87 | extern sense_reason_t target_emulate_report_referrals(struct se_cmd *); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 88 | extern int core_alua_check_nonop_delay(struct se_cmd *); |
| 89 | extern int core_alua_do_port_transition(struct t10_alua_tg_pt_gp *, |
Christoph Hellwig | adf653f | 2015-05-25 21:33:08 -0700 | [diff] [blame] | 90 | struct se_device *, struct se_lun *, |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 91 | struct se_node_acl *, int, int); |
| 92 | extern char *core_alua_dump_status(int); |
Hannes Reinecke | 229d4f1 | 2013-12-17 09:18:50 +0100 | [diff] [blame] | 93 | extern struct t10_alua_lba_map *core_alua_allocate_lba_map( |
| 94 | struct list_head *, u64, u64); |
| 95 | extern int core_alua_allocate_lba_map_mem(struct t10_alua_lba_map *, int, int); |
| 96 | extern void core_alua_free_lba_map(struct list_head *); |
| 97 | extern void core_alua_set_lba_map(struct se_device *, struct list_head *, |
| 98 | int, int); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 99 | extern struct t10_alua_lu_gp *core_alua_allocate_lu_gp(const char *, int); |
| 100 | extern int core_alua_set_lu_gp_id(struct t10_alua_lu_gp *, u16); |
| 101 | extern void core_alua_free_lu_gp(struct t10_alua_lu_gp *); |
| 102 | extern void core_alua_free_lu_gp_mem(struct se_device *); |
| 103 | extern struct t10_alua_lu_gp *core_alua_get_lu_gp_by_name(const char *); |
| 104 | extern void core_alua_put_lu_gp_from_name(struct t10_alua_lu_gp *); |
| 105 | extern void __core_alua_attach_lu_gp_mem(struct t10_alua_lu_gp_member *, |
| 106 | struct t10_alua_lu_gp *); |
| 107 | extern void __core_alua_drop_lu_gp_mem(struct t10_alua_lu_gp_member *, |
| 108 | struct t10_alua_lu_gp *); |
| 109 | extern void core_alua_drop_lu_gp_dev(struct se_device *); |
| 110 | extern struct t10_alua_tg_pt_gp *core_alua_allocate_tg_pt_gp( |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 111 | struct se_device *, const char *, int); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 112 | extern int core_alua_set_tg_pt_gp_id(struct t10_alua_tg_pt_gp *, u16); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 113 | extern void core_alua_free_tg_pt_gp(struct t10_alua_tg_pt_gp *); |
Christoph Hellwig | adf653f | 2015-05-25 21:33:08 -0700 | [diff] [blame] | 114 | extern void target_detach_tg_pt_gp(struct se_lun *); |
| 115 | extern void target_attach_tg_pt_gp(struct se_lun *, struct t10_alua_tg_pt_gp *); |
| 116 | extern ssize_t core_alua_show_tg_pt_gp_info(struct se_lun *, char *); |
| 117 | extern ssize_t core_alua_store_tg_pt_gp_info(struct se_lun *, const char *, |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 118 | size_t); |
| 119 | extern ssize_t core_alua_show_access_type(struct t10_alua_tg_pt_gp *, char *); |
| 120 | extern ssize_t core_alua_store_access_type(struct t10_alua_tg_pt_gp *, |
| 121 | const char *, size_t); |
| 122 | extern ssize_t core_alua_show_nonop_delay_msecs(struct t10_alua_tg_pt_gp *, |
| 123 | char *); |
| 124 | extern ssize_t core_alua_store_nonop_delay_msecs(struct t10_alua_tg_pt_gp *, |
| 125 | const char *, size_t); |
| 126 | extern ssize_t core_alua_show_trans_delay_msecs(struct t10_alua_tg_pt_gp *, |
| 127 | char *); |
| 128 | extern ssize_t core_alua_store_trans_delay_msecs(struct t10_alua_tg_pt_gp *, |
| 129 | const char *, size_t); |
Hannes Reinecke | 125d011 | 2013-11-19 09:07:46 +0100 | [diff] [blame] | 130 | extern ssize_t core_alua_show_implicit_trans_secs(struct t10_alua_tg_pt_gp *, |
Nicholas Bellinger | 5b9a4d7 | 2012-05-16 22:02:34 -0700 | [diff] [blame] | 131 | char *); |
Hannes Reinecke | 125d011 | 2013-11-19 09:07:46 +0100 | [diff] [blame] | 132 | extern ssize_t core_alua_store_implicit_trans_secs(struct t10_alua_tg_pt_gp *, |
Nicholas Bellinger | 5b9a4d7 | 2012-05-16 22:02:34 -0700 | [diff] [blame] | 133 | const char *, size_t); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 134 | extern ssize_t core_alua_show_preferred_bit(struct t10_alua_tg_pt_gp *, |
| 135 | char *); |
| 136 | extern ssize_t core_alua_store_preferred_bit(struct t10_alua_tg_pt_gp *, |
| 137 | const char *, size_t); |
| 138 | extern ssize_t core_alua_show_offline_bit(struct se_lun *, char *); |
| 139 | extern ssize_t core_alua_store_offline_bit(struct se_lun *, const char *, |
| 140 | size_t); |
| 141 | extern ssize_t core_alua_show_secondary_status(struct se_lun *, char *); |
| 142 | extern ssize_t core_alua_store_secondary_status(struct se_lun *, |
| 143 | const char *, size_t); |
| 144 | extern ssize_t core_alua_show_secondary_write_metadata(struct se_lun *, |
| 145 | char *); |
| 146 | extern ssize_t core_alua_store_secondary_write_metadata(struct se_lun *, |
| 147 | const char *, size_t); |
Christoph Hellwig | 0fd97cc | 2012-10-08 00:03:19 -0400 | [diff] [blame] | 148 | extern int core_setup_alua(struct se_device *); |
Christoph Hellwig | de103c9 | 2012-11-06 12:24:09 -0800 | [diff] [blame] | 149 | extern sense_reason_t target_alua_state_check(struct se_cmd *cmd); |
Nicholas Bellinger | c66ac9d | 2010-12-17 11:11:26 -0800 | [diff] [blame] | 150 | |
| 151 | #endif /* TARGET_CORE_ALUA_H */ |