From patchwork Thu Jun 18 09:43:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 6634701 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C2BEEC0020 for ; Thu, 18 Jun 2015 09:43:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 066932075A for ; Thu, 18 Jun 2015 09:43:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F3BFC20808 for ; Thu, 18 Jun 2015 09:43:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754508AbbFRJnu (ORCPT ); Thu, 18 Jun 2015 05:43:50 -0400 Received: from cantor2.suse.de ([195.135.220.15]:54711 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754041AbbFRJnp (ORCPT ); Thu, 18 Jun 2015 05:43:45 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id BBE31ADA7; Thu, 18 Jun 2015 09:43:43 +0000 (UTC) From: Hannes Reinecke To: Nic Bellinger Cc: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, Christoph Hellwig , Ewan Milne , Hannes Reinecke Subject: [PATCH 1/8] tcm_loop: Hook into SAS transport class Date: Thu, 18 Jun 2015 11:43:35 +0200 Message-Id: <1434620622-65391-2-git-send-email-hare@suse.de> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1434620622-65391-1-git-send-email-hare@suse.de> References: <1434620622-65391-1-git-send-email-hare@suse.de> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If tcm_loop emulates a SAS HBA it should hook into the SAS transport class, too. Signed-off-by: Hannes Reinecke --- drivers/target/loopback/tcm_loop.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index a556bde..45ae3e4 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -42,7 +43,7 @@ static struct workqueue_struct *tcm_loop_workqueue; static struct kmem_cache *tcm_loop_cmd_cache; - +static struct scsi_transport_template *tcm_loop_sas_transport_template; static int tcm_loop_hba_no_cnt; static int tcm_loop_queue_status(struct se_cmd *se_cmd); @@ -360,6 +361,9 @@ static int tcm_loop_slave_alloc(struct scsi_device *sd) return 0; } +struct sas_function_template tcm_loop_sas_transport_functions = { +}; + static struct scsi_host_template tcm_loop_driver_template = { .show_info = tcm_loop_show_info, .proc_name = "tcm_loopback", @@ -408,6 +412,8 @@ static int tcm_loop_driver_probe(struct device *dev) sh->max_lun = 0; sh->max_channel = 0; sh->max_cmd_len = SCSI_MAX_VARLEN_CDB_SIZE; + if (tl_hba->tl_proto_id == SCSI_PROTOCOL_SAS) + sh->transportt = tcm_loop_sas_transport_template; host_prot = SHOST_DIF_TYPE1_PROTECTION | SHOST_DIF_TYPE2_PROTECTION | SHOST_DIF_TYPE3_PROTECTION | SHOST_DIX_TYPE1_PROTECTION | @@ -1290,8 +1296,15 @@ static int __init tcm_loop_fabric_init(void) if (ret) goto out_release_core_bus; + tcm_loop_sas_transport_template = + sas_attach_transport(&tcm_loop_sas_transport_functions); + if (!tcm_loop_sas_transport_template) + goto out_unregister_template; + return 0; +out_unregister_template: + target_unregister_template(&loop_ops); out_release_core_bus: tcm_loop_release_core_bus(); out_destroy_cache: @@ -1304,6 +1317,7 @@ out: static void __exit tcm_loop_fabric_exit(void) { + sas_release_transport(tcm_loop_sas_transport_template); target_unregister_template(&loop_ops); tcm_loop_release_core_bus(); kmem_cache_destroy(tcm_loop_cmd_cache);