summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2015-05-10 12:14:57 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2015-06-01 03:25:36 -0400
commit5873c4d157400ade4052e9d7b6259fa592e1ddbf (patch)
tree3e8f9d0a3bde7659a1b3169158b68108ee55ca7f /include
parent0a06d4309dc168dfa70cec3cf0cd9eb7fc15a2fd (diff)
target: consolidate backend attribute implementations
Provide a common sets of dev_attrib attributes for all devices using the generic SPC/SBC parsers, and a second one with the minimal required read-only attributes for passthrough devices. The later is only used by pscsi for now, but will be wired up for the full-passthrough TCMU use case as well. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'include')
-rw-r--r--include/target/target_core_backend.h3
-rw-r--r--include/target/target_core_backend_configfs.h118
2 files changed, 3 insertions, 118 deletions
diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h
index 514b52019380..2d5610516494 100644
--- a/include/target/target_core_backend.h
+++ b/include/target/target_core_backend.h
@@ -82,6 +82,9 @@ int transport_set_vpd_assoc(struct t10_vpd *, unsigned char *);
82int transport_set_vpd_ident_type(struct t10_vpd *, unsigned char *); 82int transport_set_vpd_ident_type(struct t10_vpd *, unsigned char *);
83int transport_set_vpd_ident(struct t10_vpd *, unsigned char *); 83int transport_set_vpd_ident(struct t10_vpd *, unsigned char *);
84 84
85extern struct configfs_attribute *sbc_attrib_attrs[];
86extern struct configfs_attribute *passthrough_attrib_attrs[];
87
85/* core helpers also used by command snooping in pscsi */ 88/* core helpers also used by command snooping in pscsi */
86void *transport_kmap_data_sg(struct se_cmd *); 89void *transport_kmap_data_sg(struct se_cmd *);
87void transport_kunmap_data_sg(struct se_cmd *); 90void transport_kunmap_data_sg(struct se_cmd *);
diff --git a/include/target/target_core_backend_configfs.h b/include/target/target_core_backend_configfs.h
deleted file mode 100644
index 186f7a923570..000000000000
--- a/include/target/target_core_backend_configfs.h
+++ /dev/null
@@ -1,118 +0,0 @@
1#ifndef TARGET_CORE_BACKEND_CONFIGFS_H
2#define TARGET_CORE_BACKEND_CONFIGFS_H
3
4#include <target/configfs_macros.h>
5
6#define DEF_TB_DEV_ATTRIB_SHOW(_backend, _name) \
7static ssize_t _backend##_dev_show_attr_##_name( \
8 struct se_dev_attrib *da, \
9 char *page) \
10{ \
11 return snprintf(page, PAGE_SIZE, "%u\n", \
12 (u32)da->da_dev->dev_attrib._name); \
13}
14
15#define DEF_TB_DEV_ATTRIB_STORE(_backend, _name) \
16static ssize_t _backend##_dev_store_attr_##_name( \
17 struct se_dev_attrib *da, \
18 const char *page, \
19 size_t count) \
20{ \
21 unsigned long val; \
22 int ret; \
23 \
24 ret = kstrtoul(page, 0, &val); \
25 if (ret < 0) { \
26 pr_err("kstrtoul() failed with ret: %d\n", ret); \
27 return -EINVAL; \
28 } \
29 ret = se_dev_set_##_name(da->da_dev, (u32)val); \
30 \
31 return (!ret) ? count : -EINVAL; \
32}
33
34#define DEF_TB_DEV_ATTRIB(_backend, _name) \
35DEF_TB_DEV_ATTRIB_SHOW(_backend, _name); \
36DEF_TB_DEV_ATTRIB_STORE(_backend, _name);
37
38#define DEF_TB_DEV_ATTRIB_RO(_backend, name) \
39DEF_TB_DEV_ATTRIB_SHOW(_backend, name);
40
41CONFIGFS_EATTR_STRUCT(target_backend_dev_attrib, se_dev_attrib);
42#define TB_DEV_ATTR(_backend, _name, _mode) \
43static struct target_backend_dev_attrib_attribute _backend##_dev_attrib_##_name = \
44 __CONFIGFS_EATTR(_name, _mode, \
45 _backend##_dev_show_attr_##_name, \
46 _backend##_dev_store_attr_##_name);
47
48#define TB_DEV_ATTR_RO(_backend, _name) \
49static struct target_backend_dev_attrib_attribute _backend##_dev_attrib_##_name = \
50 __CONFIGFS_EATTR_RO(_name, \
51 _backend##_dev_show_attr_##_name);
52
53/*
54 * Default list of target backend device attributes as defined by
55 * struct se_dev_attrib
56 */
57
58#define DEF_TB_DEFAULT_ATTRIBS(_backend) \
59 DEF_TB_DEV_ATTRIB(_backend, emulate_model_alias); \
60 TB_DEV_ATTR(_backend, emulate_model_alias, S_IRUGO | S_IWUSR); \
61 DEF_TB_DEV_ATTRIB(_backend, emulate_dpo); \
62 TB_DEV_ATTR(_backend, emulate_dpo, S_IRUGO | S_IWUSR); \
63 DEF_TB_DEV_ATTRIB(_backend, emulate_fua_write); \
64 TB_DEV_ATTR(_backend, emulate_fua_write, S_IRUGO | S_IWUSR); \
65 DEF_TB_DEV_ATTRIB(_backend, emulate_fua_read); \
66 TB_DEV_ATTR(_backend, emulate_fua_read, S_IRUGO | S_IWUSR); \
67 DEF_TB_DEV_ATTRIB(_backend, emulate_write_cache); \
68 TB_DEV_ATTR(_backend, emulate_write_cache, S_IRUGO | S_IWUSR); \
69 DEF_TB_DEV_ATTRIB(_backend, emulate_ua_intlck_ctrl); \
70 TB_DEV_ATTR(_backend, emulate_ua_intlck_ctrl, S_IRUGO | S_IWUSR); \
71 DEF_TB_DEV_ATTRIB(_backend, emulate_tas); \
72 TB_DEV_ATTR(_backend, emulate_tas, S_IRUGO | S_IWUSR); \
73 DEF_TB_DEV_ATTRIB(_backend, emulate_tpu); \
74 TB_DEV_ATTR(_backend, emulate_tpu, S_IRUGO | S_IWUSR); \
75 DEF_TB_DEV_ATTRIB(_backend, emulate_tpws); \
76 TB_DEV_ATTR(_backend, emulate_tpws, S_IRUGO | S_IWUSR); \
77 DEF_TB_DEV_ATTRIB(_backend, emulate_caw); \
78 TB_DEV_ATTR(_backend, emulate_caw, S_IRUGO | S_IWUSR); \
79 DEF_TB_DEV_ATTRIB(_backend, emulate_3pc); \
80 TB_DEV_ATTR(_backend, emulate_3pc, S_IRUGO | S_IWUSR); \
81 DEF_TB_DEV_ATTRIB(_backend, pi_prot_type); \
82 TB_DEV_ATTR(_backend, pi_prot_type, S_IRUGO | S_IWUSR); \
83 DEF_TB_DEV_ATTRIB_RO(_backend, hw_pi_prot_type); \
84 TB_DEV_ATTR_RO(_backend, hw_pi_prot_type); \
85 DEF_TB_DEV_ATTRIB(_backend, pi_prot_format); \
86 TB_DEV_ATTR(_backend, pi_prot_format, S_IRUGO | S_IWUSR); \
87 DEF_TB_DEV_ATTRIB(_backend, enforce_pr_isids); \
88 TB_DEV_ATTR(_backend, enforce_pr_isids, S_IRUGO | S_IWUSR); \
89 DEF_TB_DEV_ATTRIB(_backend, is_nonrot); \
90 TB_DEV_ATTR(_backend, is_nonrot, S_IRUGO | S_IWUSR); \
91 DEF_TB_DEV_ATTRIB(_backend, emulate_rest_reord); \
92 TB_DEV_ATTR(_backend, emulate_rest_reord, S_IRUGO | S_IWUSR); \
93 DEF_TB_DEV_ATTRIB(_backend, force_pr_aptpl); \
94 TB_DEV_ATTR(_backend, force_pr_aptpl, S_IRUGO | S_IWUSR); \
95 DEF_TB_DEV_ATTRIB_RO(_backend, hw_block_size); \
96 TB_DEV_ATTR_RO(_backend, hw_block_size); \
97 DEF_TB_DEV_ATTRIB(_backend, block_size); \
98 TB_DEV_ATTR(_backend, block_size, S_IRUGO | S_IWUSR); \
99 DEF_TB_DEV_ATTRIB_RO(_backend, hw_max_sectors); \
100 TB_DEV_ATTR_RO(_backend, hw_max_sectors); \
101 DEF_TB_DEV_ATTRIB(_backend, optimal_sectors); \
102 TB_DEV_ATTR(_backend, optimal_sectors, S_IRUGO | S_IWUSR); \
103 DEF_TB_DEV_ATTRIB_RO(_backend, hw_queue_depth); \
104 TB_DEV_ATTR_RO(_backend, hw_queue_depth); \
105 DEF_TB_DEV_ATTRIB(_backend, queue_depth); \
106 TB_DEV_ATTR(_backend, queue_depth, S_IRUGO | S_IWUSR); \
107 DEF_TB_DEV_ATTRIB(_backend, max_unmap_lba_count); \
108 TB_DEV_ATTR(_backend, max_unmap_lba_count, S_IRUGO | S_IWUSR); \
109 DEF_TB_DEV_ATTRIB(_backend, max_unmap_block_desc_count); \
110 TB_DEV_ATTR(_backend, max_unmap_block_desc_count, S_IRUGO | S_IWUSR); \
111 DEF_TB_DEV_ATTRIB(_backend, unmap_granularity); \
112 TB_DEV_ATTR(_backend, unmap_granularity, S_IRUGO | S_IWUSR); \
113 DEF_TB_DEV_ATTRIB(_backend, unmap_granularity_alignment); \
114 TB_DEV_ATTR(_backend, unmap_granularity_alignment, S_IRUGO | S_IWUSR); \
115 DEF_TB_DEV_ATTRIB(_backend, max_write_same_len); \
116 TB_DEV_ATTR(_backend, max_write_same_len, S_IRUGO | S_IWUSR);
117
118#endif /* TARGET_CORE_BACKEND_CONFIGFS_H */