aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/vhost
diff options
context:
space:
mode:
authorNicholas Bellinger <nab@linux-iscsi.org>2015-03-28 03:03:51 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2015-04-08 02:27:46 -0400
commitb1d75fe53ef20b90bb64b1e48b905416f0dfde23 (patch)
tree6855a00cccc72be6cd888b1cc19c9bde0cd3c23f /drivers/vhost
parent436f4a0a99520623ef3fb994d70d2938fc9f00b6 (diff)
vhost/scsi: Add fabric_prot_type attribute support
This patch updates vhost-scsi to add a new fabric_prot_type TPG attribute, used for controlling LLD level protection into LIO when the backend device does not support T10-PI. This is required for vhost-scsi to enable WRITE_STRIP + READ_INSERT operations using software emulation + crct10dif instruction offload. It's disabled by default and controls which se_sesion->sess_prot_type are set at vhost_scsi_make_nexus() session registration time. Cc: Michael S. Tsirkin <mst@redhat.com> Cc: Martin Petersen <martin.petersen@oracle.com> Cc: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/vhost')
-rw-r--r--drivers/vhost/scsi.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 8d4f3f1ff799..27ed9642cc21 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -131,6 +131,8 @@ struct vhost_scsi_tpg {
131 int tv_tpg_port_count; 131 int tv_tpg_port_count;
132 /* Used for vhost_scsi device reference to tpg_nexus, protected by tv_tpg_mutex */ 132 /* Used for vhost_scsi device reference to tpg_nexus, protected by tv_tpg_mutex */
133 int tv_tpg_vhost_count; 133 int tv_tpg_vhost_count;
134 /* Used for enabling T10-PI with legacy devices */
135 int tv_fabric_prot_type;
134 /* list for vhost_scsi_list */ 136 /* list for vhost_scsi_list */
135 struct list_head tv_tpg_list; 137 struct list_head tv_tpg_list;
136 /* Used to protect access for tpg_nexus */ 138 /* Used to protect access for tpg_nexus */
@@ -431,6 +433,14 @@ vhost_scsi_parse_pr_out_transport_id(struct se_portal_group *se_tpg,
431 port_nexus_ptr); 433 port_nexus_ptr);
432} 434}
433 435
436static int vhost_scsi_check_prot_fabric_only(struct se_portal_group *se_tpg)
437{
438 struct vhost_scsi_tpg *tpg = container_of(se_tpg,
439 struct vhost_scsi_tpg, se_tpg);
440
441 return tpg->tv_fabric_prot_type;
442}
443
434static struct se_node_acl * 444static struct se_node_acl *
435vhost_scsi_alloc_fabric_acl(struct se_portal_group *se_tpg) 445vhost_scsi_alloc_fabric_acl(struct se_portal_group *se_tpg)
436{ 446{
@@ -1878,6 +1888,45 @@ static void vhost_scsi_free_cmd_map_res(struct vhost_scsi_nexus *nexus,
1878 } 1888 }
1879} 1889}
1880 1890
1891static ssize_t vhost_scsi_tpg_attrib_store_fabric_prot_type(
1892 struct se_portal_group *se_tpg,
1893 const char *page,
1894 size_t count)
1895{
1896 struct vhost_scsi_tpg *tpg = container_of(se_tpg,
1897 struct vhost_scsi_tpg, se_tpg);
1898 unsigned long val;
1899 int ret = kstrtoul(page, 0, &val);
1900
1901 if (ret) {
1902 pr_err("kstrtoul() returned %d for fabric_prot_type\n", ret);
1903 return ret;
1904 }
1905 if (val != 0 && val != 1 && val != 3) {
1906 pr_err("Invalid vhost_scsi fabric_prot_type: %lu\n", val);
1907 return -EINVAL;
1908 }
1909 tpg->tv_fabric_prot_type = val;
1910
1911 return count;
1912}
1913
1914static ssize_t vhost_scsi_tpg_attrib_show_fabric_prot_type(
1915 struct se_portal_group *se_tpg,
1916 char *page)
1917{
1918 struct vhost_scsi_tpg *tpg = container_of(se_tpg,
1919 struct vhost_scsi_tpg, se_tpg);
1920
1921 return sprintf(page, "%d\n", tpg->tv_fabric_prot_type);
1922}
1923TF_TPG_ATTRIB_ATTR(vhost_scsi, fabric_prot_type, S_IRUGO | S_IWUSR);
1924
1925static struct configfs_attribute *vhost_scsi_tpg_attrib_attrs[] = {
1926 &vhost_scsi_tpg_attrib_fabric_prot_type.attr,
1927 NULL,
1928};
1929
1881static int vhost_scsi_make_nexus(struct vhost_scsi_tpg *tpg, 1930static int vhost_scsi_make_nexus(struct vhost_scsi_tpg *tpg,
1882 const char *name) 1931 const char *name)
1883{ 1932{
@@ -2290,6 +2339,7 @@ static struct target_core_fabric_ops vhost_scsi_ops = {
2290 .tpg_check_demo_mode_cache = vhost_scsi_check_true, 2339 .tpg_check_demo_mode_cache = vhost_scsi_check_true,
2291 .tpg_check_demo_mode_write_protect = vhost_scsi_check_false, 2340 .tpg_check_demo_mode_write_protect = vhost_scsi_check_false,
2292 .tpg_check_prod_mode_write_protect = vhost_scsi_check_false, 2341 .tpg_check_prod_mode_write_protect = vhost_scsi_check_false,
2342 .tpg_check_prot_fabric_only = vhost_scsi_check_prot_fabric_only,
2293 .tpg_alloc_fabric_acl = vhost_scsi_alloc_fabric_acl, 2343 .tpg_alloc_fabric_acl = vhost_scsi_alloc_fabric_acl,
2294 .tpg_release_fabric_acl = vhost_scsi_release_fabric_acl, 2344 .tpg_release_fabric_acl = vhost_scsi_release_fabric_acl,
2295 .tpg_get_inst_index = vhost_scsi_tpg_get_inst_index, 2345 .tpg_get_inst_index = vhost_scsi_tpg_get_inst_index,
@@ -2348,7 +2398,7 @@ static int vhost_scsi_register_configfs(void)
2348 */ 2398 */
2349 fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = vhost_scsi_wwn_attrs; 2399 fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = vhost_scsi_wwn_attrs;
2350 fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = vhost_scsi_tpg_attrs; 2400 fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = vhost_scsi_tpg_attrs;
2351 fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = NULL; 2401 fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = vhost_scsi_tpg_attrib_attrs;
2352 fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL; 2402 fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL;
2353 fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL; 2403 fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL;
2354 fabric->tf_cit_tmpl.tfc_tpg_nacl_base_cit.ct_attrs = NULL; 2404 fabric->tf_cit_tmpl.tfc_tpg_nacl_base_cit.ct_attrs = NULL;