diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/target/target_core_backend.h | 43 | ||||
-rw-r--r-- | include/target/target_core_backend_configfs.h | 120 | ||||
-rw-r--r-- | include/uapi/linux/target_core_user.h | 4 |
3 files changed, 163 insertions, 4 deletions
diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 9adc1bca1178..430cfaf92285 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -5,6 +5,15 @@ #define TRANSPORT_PLUGIN_VHBA_PDEV 2 #define TRANSPORT_PLUGIN_VHBA_VDEV 3 +struct target_backend_cits { + struct config_item_type tb_dev_cit; + struct config_item_type tb_dev_attrib_cit; + struct config_item_type tb_dev_pr_cit; + struct config_item_type tb_dev_wwn_cit; + struct config_item_type tb_dev_alua_tg_pt_gps_cit; + struct config_item_type tb_dev_stat_cit; +}; + struct se_subsystem_api { struct list_head sub_api_list; @@ -44,6 +53,8 @@ struct se_subsystem_api { int (*init_prot)(struct se_device *); int (*format_prot)(struct se_device *); void (*free_prot)(struct se_device *); + + struct target_backend_cits tb_cits; }; struct sbc_ops { @@ -96,4 +107,36 @@ sense_reason_t transport_generic_map_mem_to_cmd(struct se_cmd *, void array_free(void *array, int n); +/* From target_core_configfs.c to setup default backend config_item_types */ +void target_core_setup_sub_cits(struct se_subsystem_api *); + +/* attribute helpers from target_core_device.c for backend drivers */ +int se_dev_set_max_unmap_lba_count(struct se_device *, u32); +int se_dev_set_max_unmap_block_desc_count(struct se_device *, u32); +int se_dev_set_unmap_granularity(struct se_device *, u32); +int se_dev_set_unmap_granularity_alignment(struct se_device *, u32); +int se_dev_set_max_write_same_len(struct se_device *, u32); +int se_dev_set_emulate_model_alias(struct se_device *, int); +int se_dev_set_emulate_dpo(struct se_device *, int); +int se_dev_set_emulate_fua_write(struct se_device *, int); +int se_dev_set_emulate_fua_read(struct se_device *, int); +int se_dev_set_emulate_write_cache(struct se_device *, int); +int se_dev_set_emulate_ua_intlck_ctrl(struct se_device *, int); +int se_dev_set_emulate_tas(struct se_device *, int); +int se_dev_set_emulate_tpu(struct se_device *, int); +int se_dev_set_emulate_tpws(struct se_device *, int); +int se_dev_set_emulate_caw(struct se_device *, int); +int se_dev_set_emulate_3pc(struct se_device *, int); +int se_dev_set_pi_prot_type(struct se_device *, int); +int se_dev_set_pi_prot_format(struct se_device *, int); +int se_dev_set_enforce_pr_isids(struct se_device *, int); +int se_dev_set_force_pr_aptpl(struct se_device *, int); +int se_dev_set_is_nonrot(struct se_device *, int); +int se_dev_set_emulate_rest_reord(struct se_device *dev, int); +int se_dev_set_queue_depth(struct se_device *, u32); +int se_dev_set_max_sectors(struct se_device *, u32); +int se_dev_set_fabric_max_sectors(struct se_device *, u32); +int se_dev_set_optimal_sectors(struct se_device *, u32); +int se_dev_set_block_size(struct se_device *, u32); + #endif /* TARGET_CORE_BACKEND_H */ diff --git a/include/target/target_core_backend_configfs.h b/include/target/target_core_backend_configfs.h new file mode 100644 index 000000000000..3247d7530107 --- /dev/null +++ b/include/target/target_core_backend_configfs.h @@ -0,0 +1,120 @@ +#ifndef TARGET_CORE_BACKEND_CONFIGFS_H +#define TARGET_CORE_BACKEND_CONFIGFS_H + +#include <target/configfs_macros.h> + +#define DEF_TB_DEV_ATTRIB_SHOW(_backend, _name) \ +static ssize_t _backend##_dev_show_attr_##_name( \ + struct se_dev_attrib *da, \ + char *page) \ +{ \ + return snprintf(page, PAGE_SIZE, "%u\n", \ + (u32)da->da_dev->dev_attrib._name); \ +} + +#define DEF_TB_DEV_ATTRIB_STORE(_backend, _name) \ +static ssize_t _backend##_dev_store_attr_##_name( \ + struct se_dev_attrib *da, \ + const char *page, \ + size_t count) \ +{ \ + unsigned long val; \ + int ret; \ + \ + ret = kstrtoul(page, 0, &val); \ + if (ret < 0) { \ + pr_err("kstrtoul() failed with ret: %d\n", ret); \ + return -EINVAL; \ + } \ + ret = se_dev_set_##_name(da->da_dev, (u32)val); \ + \ + return (!ret) ? count : -EINVAL; \ +} + +#define DEF_TB_DEV_ATTRIB(_backend, _name) \ +DEF_TB_DEV_ATTRIB_SHOW(_backend, _name); \ +DEF_TB_DEV_ATTRIB_STORE(_backend, _name); + +#define DEF_TB_DEV_ATTRIB_RO(_backend, name) \ +DEF_TB_DEV_ATTRIB_SHOW(_backend, name); + +CONFIGFS_EATTR_STRUCT(target_backend_dev_attrib, se_dev_attrib); +#define TB_DEV_ATTR(_backend, _name, _mode) \ +static struct target_backend_dev_attrib_attribute _backend##_dev_attrib_##_name = \ + __CONFIGFS_EATTR(_name, _mode, \ + _backend##_dev_show_attr_##_name, \ + _backend##_dev_store_attr_##_name); + +#define TB_DEV_ATTR_RO(_backend, _name) \ +static struct target_backend_dev_attrib_attribute _backend##_dev_attrib_##_name = \ + __CONFIGFS_EATTR_RO(_name, \ + _backend##_dev_show_attr_##_name); + +/* + * Default list of target backend device attributes as defined by + * struct se_dev_attrib + */ + +#define DEF_TB_DEFAULT_ATTRIBS(_backend) \ + DEF_TB_DEV_ATTRIB(_backend, emulate_model_alias); \ + TB_DEV_ATTR(_backend, emulate_model_alias, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, emulate_dpo); \ + TB_DEV_ATTR(_backend, emulate_dpo, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, emulate_fua_write); \ + TB_DEV_ATTR(_backend, emulate_fua_write, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, emulate_fua_read); \ + TB_DEV_ATTR(_backend, emulate_fua_read, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, emulate_write_cache); \ + TB_DEV_ATTR(_backend, emulate_write_cache, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, emulate_ua_intlck_ctrl); \ + TB_DEV_ATTR(_backend, emulate_ua_intlck_ctrl, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, emulate_tas); \ + TB_DEV_ATTR(_backend, emulate_tas, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, emulate_tpu); \ + TB_DEV_ATTR(_backend, emulate_tpu, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, emulate_tpws); \ + TB_DEV_ATTR(_backend, emulate_tpws, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, emulate_caw); \ + TB_DEV_ATTR(_backend, emulate_caw, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, emulate_3pc); \ + TB_DEV_ATTR(_backend, emulate_3pc, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, pi_prot_type); \ + TB_DEV_ATTR(_backend, pi_prot_type, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB_RO(_backend, hw_pi_prot_type); \ + TB_DEV_ATTR_RO(_backend, hw_pi_prot_type); \ + DEF_TB_DEV_ATTRIB(_backend, pi_prot_format); \ + TB_DEV_ATTR(_backend, pi_prot_format, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, enforce_pr_isids); \ + TB_DEV_ATTR(_backend, enforce_pr_isids, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, is_nonrot); \ + TB_DEV_ATTR(_backend, is_nonrot, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, emulate_rest_reord); \ + TB_DEV_ATTR(_backend, emulate_rest_reord, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, force_pr_aptpl); \ + TB_DEV_ATTR(_backend, force_pr_aptpl, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB_RO(_backend, hw_block_size); \ + TB_DEV_ATTR_RO(_backend, hw_block_size); \ + DEF_TB_DEV_ATTRIB(_backend, block_size); \ + TB_DEV_ATTR(_backend, block_size, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB_RO(_backend, hw_max_sectors); \ + TB_DEV_ATTR_RO(_backend, hw_max_sectors); \ + DEF_TB_DEV_ATTRIB(_backend, fabric_max_sectors); \ + TB_DEV_ATTR(_backend, fabric_max_sectors, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, optimal_sectors); \ + TB_DEV_ATTR(_backend, optimal_sectors, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB_RO(_backend, hw_queue_depth); \ + TB_DEV_ATTR_RO(_backend, hw_queue_depth); \ + DEF_TB_DEV_ATTRIB(_backend, queue_depth); \ + TB_DEV_ATTR(_backend, queue_depth, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, max_unmap_lba_count); \ + TB_DEV_ATTR(_backend, max_unmap_lba_count, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, max_unmap_block_desc_count); \ + TB_DEV_ATTR(_backend, max_unmap_block_desc_count, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, unmap_granularity); \ + TB_DEV_ATTR(_backend, unmap_granularity, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, unmap_granularity_alignment); \ + TB_DEV_ATTR(_backend, unmap_granularity_alignment, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, max_write_same_len); \ + TB_DEV_ATTR(_backend, max_write_same_len, S_IRUGO | S_IWUSR); + +#endif /* TARGET_CORE_BACKEND_CONFIGFS_H */ diff --git a/include/uapi/linux/target_core_user.h b/include/uapi/linux/target_core_user.h index 7dcfbe6771b1..b483d1909d3e 100644 --- a/include/uapi/linux/target_core_user.h +++ b/include/uapi/linux/target_core_user.h @@ -6,10 +6,6 @@ #include <linux/types.h> #include <linux/uio.h> -#ifndef __packed -#define __packed __attribute__((packed)) -#endif - #define TCMU_VERSION "1.0" /* |