linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Nicholas A. Bellinger" <nab@daterainc.com>
To: target-devel <target-devel@vger.kernel.org>
Cc: linux-scsi <linux-scsi@vger.kernel.org>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Sagi Grimberg <sagig@mellanox.com>,
	Quinn Tran <quinn.tran@qlogic.com>,
	Nicholas Bellinger <nab@linux-iscsi.org>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: [PATCH-v2 12/15] vhost/scsi: Add fabric_prot_type attribute support
Date: Mon, 30 Mar 2015 03:28:21 +0000	[thread overview]
Message-ID: <1427686104-14231-13-git-send-email-nab@daterainc.com> (raw)
In-Reply-To: <1427686104-14231-1-git-send-email-nab@daterainc.com>

From: Nicholas Bellinger <nab@linux-iscsi.org>

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>
---
 drivers/vhost/scsi.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 51 insertions(+), 1 deletion(-)

diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 8d4f3f1..27ed964 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -131,6 +131,8 @@ struct vhost_scsi_tpg {
 	int tv_tpg_port_count;
 	/* Used for vhost_scsi device reference to tpg_nexus, protected by tv_tpg_mutex */
 	int tv_tpg_vhost_count;
+	/* Used for enabling T10-PI with legacy devices */
+	int tv_fabric_prot_type;
 	/* list for vhost_scsi_list */
 	struct list_head tv_tpg_list;
 	/* Used to protect access for tpg_nexus */
@@ -431,6 +433,14 @@ vhost_scsi_parse_pr_out_transport_id(struct se_portal_group *se_tpg,
 			port_nexus_ptr);
 }
 
+static int vhost_scsi_check_prot_fabric_only(struct se_portal_group *se_tpg)
+{
+	struct vhost_scsi_tpg *tpg = container_of(se_tpg,
+				struct vhost_scsi_tpg, se_tpg);
+
+	return tpg->tv_fabric_prot_type;
+}
+
 static struct se_node_acl *
 vhost_scsi_alloc_fabric_acl(struct se_portal_group *se_tpg)
 {
@@ -1878,6 +1888,45 @@ static void vhost_scsi_free_cmd_map_res(struct vhost_scsi_nexus *nexus,
 	}
 }
 
+static ssize_t vhost_scsi_tpg_attrib_store_fabric_prot_type(
+	struct se_portal_group *se_tpg,
+	const char *page,
+	size_t count)
+{
+	struct vhost_scsi_tpg *tpg = container_of(se_tpg,
+				struct vhost_scsi_tpg, se_tpg);
+	unsigned long val;
+	int ret = kstrtoul(page, 0, &val);
+
+	if (ret) {
+		pr_err("kstrtoul() returned %d for fabric_prot_type\n", ret);
+		return ret;
+	}
+	if (val != 0 && val != 1 && val != 3) {
+		pr_err("Invalid vhost_scsi fabric_prot_type: %lu\n", val);
+		return -EINVAL;
+	}
+	tpg->tv_fabric_prot_type = val;
+
+	return count;
+}
+
+static ssize_t vhost_scsi_tpg_attrib_show_fabric_prot_type(
+	struct se_portal_group *se_tpg,
+	char *page)
+{
+	struct vhost_scsi_tpg *tpg = container_of(se_tpg,
+				struct vhost_scsi_tpg, se_tpg);
+
+	return sprintf(page, "%d\n", tpg->tv_fabric_prot_type);
+}
+TF_TPG_ATTRIB_ATTR(vhost_scsi, fabric_prot_type, S_IRUGO | S_IWUSR);
+
+static struct configfs_attribute *vhost_scsi_tpg_attrib_attrs[] = {
+	&vhost_scsi_tpg_attrib_fabric_prot_type.attr,
+	NULL,
+};
+
 static int vhost_scsi_make_nexus(struct vhost_scsi_tpg *tpg,
 				const char *name)
 {
@@ -2290,6 +2339,7 @@ static struct target_core_fabric_ops vhost_scsi_ops = {
 	.tpg_check_demo_mode_cache	= vhost_scsi_check_true,
 	.tpg_check_demo_mode_write_protect = vhost_scsi_check_false,
 	.tpg_check_prod_mode_write_protect = vhost_scsi_check_false,
+	.tpg_check_prot_fabric_only	= vhost_scsi_check_prot_fabric_only,
 	.tpg_alloc_fabric_acl		= vhost_scsi_alloc_fabric_acl,
 	.tpg_release_fabric_acl		= vhost_scsi_release_fabric_acl,
 	.tpg_get_inst_index		= vhost_scsi_tpg_get_inst_index,
@@ -2348,7 +2398,7 @@ static int vhost_scsi_register_configfs(void)
 	 */
 	fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = vhost_scsi_wwn_attrs;
 	fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = vhost_scsi_tpg_attrs;
-	fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = NULL;
+	fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = vhost_scsi_tpg_attrib_attrs;
 	fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL;
 	fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL;
 	fabric->tf_cit_tmpl.tfc_tpg_nacl_base_cit.ct_attrs = NULL;
-- 
1.9.1


  parent reply	other threads:[~2015-03-30  3:29 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-30  3:28 [PATCH-v2 00/15] target: Add WRITE_STRIP + READ_INSERT support Nicholas A. Bellinger
2015-03-30  3:28 ` [PATCH-v2 01/15] target: Convert DIF emulation to use cmd->prot_type Nicholas A. Bellinger
2015-03-30  7:38   ` Sagi Grimberg
2015-04-07 23:22   ` Martin K. Petersen
2015-03-30  3:28 ` [PATCH-v2 02/15] target: Add protected fabric + unprotected device support Nicholas A. Bellinger
2015-03-30  7:51   ` Sagi Grimberg
2015-04-01  5:49     ` Nicholas A. Bellinger
2015-04-01  9:04       ` Sagi Grimberg
2015-04-02  4:40         ` Nicholas A. Bellinger
2015-04-07 23:27   ` Martin K. Petersen
2015-04-08  7:40     ` Nicholas A. Bellinger
2015-04-09 21:45       ` Martin K. Petersen
2015-04-10 18:59         ` Nicholas A. Bellinger
2015-04-13 10:11           ` Sagi Grimberg
2015-04-14  1:15           ` Martin K. Petersen
2015-03-30  3:28 ` [PATCH-v2 03/15] target: Update SPC/SBC emulation for sess_prot_type Nicholas A. Bellinger
2015-03-30  7:53   ` Sagi Grimberg
2015-04-07 23:28   ` Martin K. Petersen
2015-03-30  3:28 ` [PATCH-v2 04/15] target: Move cmd->prot_op check into target_check_write_prot Nicholas A. Bellinger
2015-03-30  7:57   ` Sagi Grimberg
2015-04-01  5:54     ` Nicholas A. Bellinger
2015-04-07 23:30       ` Martin K. Petersen
2015-03-30  3:28 ` [PATCH-v2 05/15] target: Add internal WRITE_STRIP support Nicholas A. Bellinger
2015-03-30  8:01   ` Sagi Grimberg
2015-04-01  5:59     ` Nicholas A. Bellinger
2015-04-07 23:32   ` Martin K. Petersen
2015-03-30  3:28 ` [PATCH-v2 06/15] target: Move cmd->prot_op check into target_check_read_prot Nicholas A. Bellinger
2015-03-30  8:02   ` Sagi Grimberg
2015-04-01  6:03     ` Nicholas A. Bellinger
2015-04-07 23:33   ` Martin K. Petersen
2015-03-30  3:28 ` [PATCH-v2 07/15] target: Add internal READ_INSERT support Nicholas A. Bellinger
2015-04-07 23:34   ` Martin K. Petersen
2015-03-30  3:28 ` [PATCH-v2 08/15] target/file: Add checks for backend DIF emulation Nicholas A. Bellinger
2015-03-30  8:05   ` Sagi Grimberg
2015-03-30  3:28 ` [PATCH-v2 09/15] target/iblock: " Nicholas A. Bellinger
2015-03-30  3:28 ` [PATCH-v2 10/15] target/rd: " Nicholas A. Bellinger
2015-03-30  3:28 ` [PATCH-v2 11/15] loopback: Add fabric_prot_type attribute support Nicholas A. Bellinger
2015-03-30  8:07   ` Sagi Grimberg
2015-04-01  6:22     ` Nicholas A. Bellinger
2015-03-30  3:28 ` Nicholas A. Bellinger [this message]
2015-03-30  3:28 ` [PATCH-v2 13/15] tcm_qla2xxx: Set TARGET_PROT_ALL for sup_prot_ops Nicholas A. Bellinger
2015-03-30  3:28 ` [PATCH-v2 14/15] tcm_qla2xxx: Add fabric_prot_type attribute support Nicholas A. Bellinger
2015-03-30  3:28 ` [PATCH-v2 15/15] iscsi/iser-target: " Nicholas A. Bellinger
2015-03-30  8:11   ` Sagi Grimberg
2015-04-01  6:27     ` Nicholas A. Bellinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1427686104-14231-13-git-send-email-nab@daterainc.com \
    --to=nab@daterainc.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mst@redhat.com \
    --cc=nab@linux-iscsi.org \
    --cc=quinn.tran@qlogic.com \
    --cc=sagig@mellanox.com \
    --cc=target-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).