Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef TARGET_CORE_ALUA_H
0003 #define TARGET_CORE_ALUA_H
0004 
0005 #include <target/target_core_base.h>
0006 
0007 /*
0008  * INQUIRY response data, TPGS Field
0009  *
0010  * from spc4r17 section 6.4.2 Table 135
0011  */
0012 #define TPGS_NO_ALUA                0x00
0013 #define TPGS_IMPLICIT_ALUA          0x10
0014 #define TPGS_EXPLICIT_ALUA          0x20
0015 
0016 /*
0017  * ASYMMETRIC ACCESS STATE field
0018  *
0019  * from spc4r36j section 6.37 Table 307
0020  */
0021 #define ALUA_ACCESS_STATE_ACTIVE_OPTIMIZED  0x0
0022 #define ALUA_ACCESS_STATE_ACTIVE_NON_OPTIMIZED  0x1
0023 #define ALUA_ACCESS_STATE_STANDBY       0x2
0024 #define ALUA_ACCESS_STATE_UNAVAILABLE       0x3
0025 #define ALUA_ACCESS_STATE_LBA_DEPENDENT     0x4
0026 #define ALUA_ACCESS_STATE_OFFLINE       0xe
0027 #define ALUA_ACCESS_STATE_TRANSITION        0xf
0028 
0029 /*
0030  * from spc4r36j section 6.37 Table 306
0031  */
0032 #define ALUA_T_SUP      0x80
0033 #define ALUA_O_SUP      0x40
0034 #define ALUA_LBD_SUP        0x10
0035 #define ALUA_U_SUP      0x08
0036 #define ALUA_S_SUP      0x04
0037 #define ALUA_AN_SUP     0x02
0038 #define ALUA_AO_SUP     0x01
0039 
0040 /*
0041  * REPORT_TARGET_PORT_GROUP STATUS CODE
0042  *
0043  * from spc4r17 section 6.27 Table 246
0044  */
0045 #define ALUA_STATUS_NONE                0x00
0046 #define ALUA_STATUS_ALTERED_BY_EXPLICIT_STPG        0x01
0047 #define ALUA_STATUS_ALTERED_BY_IMPLICIT_ALUA        0x02
0048 
0049 /*
0050  * From spc4r17, Table D.1: ASC and ASCQ Assignement
0051  */
0052 #define ASCQ_04H_ALUA_STATE_TRANSITION          0x0a
0053 #define ASCQ_04H_ALUA_TG_PT_STANDBY         0x0b
0054 #define ASCQ_04H_ALUA_TG_PT_UNAVAILABLE         0x0c
0055 #define ASCQ_04H_ALUA_OFFLINE               0x12
0056 
0057 /*
0058  * Used as the default for Active/NonOptimized delay (in milliseconds)
0059  * This can also be changed via configfs on a per target port group basis..
0060  */
0061 #define ALUA_DEFAULT_NONOP_DELAY_MSECS          100
0062 #define ALUA_MAX_NONOP_DELAY_MSECS          10000 /* 10 seconds */
0063 /*
0064  * Used for implicit and explicit ALUA transitional delay, that is disabled
0065  * by default, and is intended to be used for debugging client side ALUA code.
0066  */
0067 #define ALUA_DEFAULT_TRANS_DELAY_MSECS          0
0068 #define ALUA_MAX_TRANS_DELAY_MSECS          30000 /* 30 seconds */
0069 /*
0070  * Used for the recommended application client implicit transition timeout
0071  * in seconds, returned by the REPORT_TARGET_PORT_GROUPS w/ extended header.
0072  */
0073 #define ALUA_DEFAULT_IMPLICIT_TRANS_SECS            0
0074 #define ALUA_MAX_IMPLICIT_TRANS_SECS            255
0075 
0076 /* Used by core_alua_update_tpg_(primary,secondary)_metadata */
0077 #define ALUA_MD_BUF_LEN                 1024
0078 
0079 extern struct kmem_cache *t10_alua_lu_gp_cache;
0080 extern struct kmem_cache *t10_alua_lu_gp_mem_cache;
0081 extern struct kmem_cache *t10_alua_tg_pt_gp_cache;
0082 extern struct kmem_cache *t10_alua_lba_map_cache;
0083 extern struct kmem_cache *t10_alua_lba_map_mem_cache;
0084 
0085 extern sense_reason_t target_emulate_report_target_port_groups(struct se_cmd *);
0086 extern sense_reason_t target_emulate_set_target_port_groups(struct se_cmd *);
0087 extern sense_reason_t target_emulate_report_referrals(struct se_cmd *);
0088 extern int core_alua_check_nonop_delay(struct se_cmd *);
0089 extern int core_alua_do_port_transition(struct t10_alua_tg_pt_gp *,
0090                 struct se_device *, struct se_lun *,
0091                 struct se_node_acl *, int, int);
0092 extern char *core_alua_dump_status(int);
0093 extern struct t10_alua_lba_map *core_alua_allocate_lba_map(
0094                 struct list_head *, u64, u64);
0095 extern int core_alua_allocate_lba_map_mem(struct t10_alua_lba_map *, int, int);
0096 extern void core_alua_free_lba_map(struct list_head *);
0097 extern void core_alua_set_lba_map(struct se_device *, struct list_head *,
0098                 int, int);
0099 extern struct t10_alua_lu_gp *core_alua_allocate_lu_gp(const char *, int);
0100 extern int core_alua_set_lu_gp_id(struct t10_alua_lu_gp *, u16);
0101 extern void core_alua_free_lu_gp(struct t10_alua_lu_gp *);
0102 extern void core_alua_free_lu_gp_mem(struct se_device *);
0103 extern struct t10_alua_lu_gp *core_alua_get_lu_gp_by_name(const char *);
0104 extern void core_alua_put_lu_gp_from_name(struct t10_alua_lu_gp *);
0105 extern void __core_alua_attach_lu_gp_mem(struct t10_alua_lu_gp_member *,
0106                     struct t10_alua_lu_gp *);
0107 extern void __core_alua_drop_lu_gp_mem(struct t10_alua_lu_gp_member *,
0108                     struct t10_alua_lu_gp *);
0109 extern void core_alua_drop_lu_gp_dev(struct se_device *);
0110 extern struct t10_alua_tg_pt_gp *core_alua_allocate_tg_pt_gp(
0111             struct se_device *, const char *, int);
0112 extern int core_alua_set_tg_pt_gp_id(struct t10_alua_tg_pt_gp *, u16);
0113 extern void core_alua_free_tg_pt_gp(struct t10_alua_tg_pt_gp *);
0114 extern void target_detach_tg_pt_gp(struct se_lun *);
0115 extern void target_attach_tg_pt_gp(struct se_lun *, struct t10_alua_tg_pt_gp *);
0116 extern ssize_t core_alua_show_tg_pt_gp_info(struct se_lun *, char *);
0117 extern ssize_t core_alua_store_tg_pt_gp_info(struct se_lun *, const char *,
0118                         size_t);
0119 extern ssize_t core_alua_show_access_type(struct t10_alua_tg_pt_gp *, char *);
0120 extern ssize_t core_alua_store_access_type(struct t10_alua_tg_pt_gp *,
0121                     const char *, size_t);
0122 extern ssize_t core_alua_show_nonop_delay_msecs(struct t10_alua_tg_pt_gp *,
0123                         char *);
0124 extern ssize_t core_alua_store_nonop_delay_msecs(struct t10_alua_tg_pt_gp *,
0125                     const char *, size_t);
0126 extern ssize_t core_alua_show_trans_delay_msecs(struct t10_alua_tg_pt_gp *,
0127                     char *);
0128 extern ssize_t core_alua_store_trans_delay_msecs(struct t10_alua_tg_pt_gp *,
0129                     const char *, size_t);
0130 extern ssize_t core_alua_show_implicit_trans_secs(struct t10_alua_tg_pt_gp *,
0131                     char *);
0132 extern ssize_t core_alua_store_implicit_trans_secs(struct t10_alua_tg_pt_gp *,
0133                     const char *, size_t);
0134 extern ssize_t core_alua_show_preferred_bit(struct t10_alua_tg_pt_gp *,
0135                     char *);
0136 extern ssize_t core_alua_store_preferred_bit(struct t10_alua_tg_pt_gp *,
0137                     const char *, size_t);
0138 extern ssize_t core_alua_show_offline_bit(struct se_lun *, char *);
0139 extern ssize_t core_alua_store_offline_bit(struct se_lun *, const char *,
0140                     size_t);
0141 extern ssize_t core_alua_show_secondary_status(struct se_lun *, char *);
0142 extern ssize_t core_alua_store_secondary_status(struct se_lun *,
0143                     const char *, size_t);
0144 extern ssize_t core_alua_show_secondary_write_metadata(struct se_lun *,
0145                     char *);
0146 extern ssize_t core_alua_store_secondary_write_metadata(struct se_lun *,
0147                     const char *, size_t);
0148 extern int core_setup_alua(struct se_device *);
0149 extern sense_reason_t target_alua_state_check(struct se_cmd *cmd);
0150 
0151 #endif /* TARGET_CORE_ALUA_H */