From patchwork Wed Feb 8 22:24:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 9563683 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CC1DD6020F for ; Wed, 8 Feb 2017 22:29:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F1E9284F2 for ; Wed, 8 Feb 2017 22:29:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93C312852C; Wed, 8 Feb 2017 22:29:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B21E284F2 for ; Wed, 8 Feb 2017 22:29:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752105AbdBHW3f (ORCPT ); Wed, 8 Feb 2017 17:29:35 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:57294 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751727AbdBHW3f (ORCPT ); Wed, 8 Feb 2017 17:29:35 -0500 X-IronPort-AV: E=Sophos;i="5.35,348,1483977600"; d="scan'208";a="76618080" Received: from unknown (HELO milsmgep15.sandisk.com) ([63.163.107.21]) by ob1.hgst.iphmx.com with ESMTP; 09 Feb 2017 06:28:16 +0800 Received: from MILHUBIP03.sdcorp.global.sandisk.com (Unknown_Domain [10.201.67.162]) (using TLS with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by (Symantec Messaging Gateway) with SMTP id 82.54.57638.7CA9B985; Wed, 8 Feb 2017 14:25:12 -0800 (PST) Received: from milsmgip12.sandisk.com (10.177.8.100) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.319.2; Wed, 8 Feb 2017 14:25:10 -0800 X-AuditID: 0ac94369-26dee9800001e126-ed-589b9ac7ca81 Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id AE.32.18148.7CA9B985; Wed, 8 Feb 2017 14:25:11 -0800 (PST) From: Bart Van Assche To: Bart Van Assche CC: , "Nicholas A . Bellinger" Subject: [PATCH v4 03/37] target/iscsi: Introduce a helper function for TMF translation Date: Wed, 8 Feb 2017 14:24:33 -0800 Message-ID: <20170208222507.25715-4-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170208222507.25715-1-bart.vanassche@sandisk.com> References: <20170208222507.25715-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrELMWRmVeSWpSXmKPExsXCddJ5ke6JWbMjDI6cErVoW32G0aJ16Vsm ByaP+9uPMHl83iQXwBTFZZOSmpNZllqkb5fAlbH88SW2gtXiFZ1//jM1MB4V7mLk5JAQMJE4 sfADexcjF4eQwFImiXdt81hBEkIC2xklTq9JgCl61PiWGaJoI6NEV+NBRpAEm4CRxLf3M1lA bBEBA4nfvRfA4swCIRL3bi0AiwsLhEs0rLwAZrMIqEj8+nYUzOYVsJc4dfoDG8QCeYldbRfB FnMKOEhMePmMEeIIe4lXB74wgiyWEHjOIvHkfw8jRLOgxMmZT1gglklIHHzxghmiQV3i5JL5 TBMYhWYhKZuFpGwBI9MqRrHczJzi3PTUAkNTveLEvJTM4my95PzcTYyQkM3cwXj3ifchRgEO RiUe3grL2RFCrIllxZW5hxglOJiVRHhTpgGFeFMSK6tSi/Lji0pzUosPMUpzsCiJ856TmRoh JJCeWJKanZpakFoEk2Xi4JRqYKyN5VzbcUbeODnP5obT4nUR6+ZVTDrG731/H6PMwa1FOzbN tFRlXJB2NCY0e1HDtnO2h3/8n8la0BbhExyw/7Xk0QurPlw99KxZR33njSUv5R+Vaf7+funt 1XjZlvqitcGuM32WTEz0VOv8cfC2+mppGaMD6xfE+ekcj4r6/cVIuIzh99tNIblKLMUZiYZa zEXFiQDBHTzhVQIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprEJMWRmVeSWpSXmKPExsXCtZGTTff4rNkRBtP3clsc/NnGaNG2+gyj RevSt0wOzB73tx9h8pi25jyTx+dNcgHMUVw2Kak5mWWpRfp2CVwZyx9fYitYLV7R+ec/UwPj UeEuRk4OCQETiUeNb5m7GLk4hATWM0pcerSfFSTBJmAk8e39TBYQW0TAQOJ37wVGEJtZIEji 48ouNhBbWCBcomHlBbAaFgFVia1nb4DV8ArYS3yY+JYJYoG8xK62i2AzOQUcJCa8fAZWIwRU 8+rAF8YJjNwLGBlWMYrlZuYU56ZnFhga6RUn5qVkFmfrJefnbmKE+DpqB+P1ieaHGJk4OKUa GGddSDvjG6iS+Sbgz7m44q1Tn2xKvXXp1NGTzW1J5+Um/qvpVPz1WXP+TwfTXJ78ibEeT912 sUYz8nz5032L57DaNNuv9Yo5LOprjwe8ERZfuf34ArkFDbLOhi1rVoRu598hJ5F+mslE4QSn z+T2OwssDmeqaoQu8J3BpWN975Vl3Ia/lz94aiuxFGckGmoxFxUnAgDFM89XpQEAAA== MIME-Version: 1.0 Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch does not change any functionality. Signed-off-by: Bart Van Assche Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Cc: Nicholas A. Bellinger --- drivers/target/iscsi/iscsi_target.c | 48 ++++++++++++++++++------------------- include/target/target_core_base.h | 1 + 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index e11f8d0f1fa3..d16729fa1f67 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -1920,6 +1920,28 @@ static int iscsit_handle_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd, return ret; } +static enum tcm_tmreq_table iscsit_convert_tmf(u8 iscsi_tmf) +{ + switch (iscsi_tmf) { + case ISCSI_TM_FUNC_ABORT_TASK: + return TMR_ABORT_TASK; + case ISCSI_TM_FUNC_ABORT_TASK_SET: + return TMR_ABORT_TASK_SET; + case ISCSI_TM_FUNC_CLEAR_ACA: + return TMR_CLEAR_ACA; + case ISCSI_TM_FUNC_CLEAR_TASK_SET: + return TMR_CLEAR_TASK_SET; + case ISCSI_TM_FUNC_LOGICAL_UNIT_RESET: + return TMR_LUN_RESET; + case ISCSI_TM_FUNC_TARGET_WARM_RESET: + return TMR_TARGET_WARM_RESET; + case ISCSI_TM_FUNC_TARGET_COLD_RESET: + return TMR_TARGET_COLD_RESET; + default: + return TMR_UNKNOWN; + } +} + int iscsit_handle_task_mgt_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, unsigned char *buf) @@ -1985,30 +2007,8 @@ iscsit_handle_task_mgt_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, target_get_sess_cmd(&cmd->se_cmd, true); sess_ref = true; - - switch (function) { - case ISCSI_TM_FUNC_ABORT_TASK: - tcm_function = TMR_ABORT_TASK; - break; - case ISCSI_TM_FUNC_ABORT_TASK_SET: - tcm_function = TMR_ABORT_TASK_SET; - break; - case ISCSI_TM_FUNC_CLEAR_ACA: - tcm_function = TMR_CLEAR_ACA; - break; - case ISCSI_TM_FUNC_CLEAR_TASK_SET: - tcm_function = TMR_CLEAR_TASK_SET; - break; - case ISCSI_TM_FUNC_LOGICAL_UNIT_RESET: - tcm_function = TMR_LUN_RESET; - break; - case ISCSI_TM_FUNC_TARGET_WARM_RESET: - tcm_function = TMR_TARGET_WARM_RESET; - break; - case ISCSI_TM_FUNC_TARGET_COLD_RESET: - tcm_function = TMR_TARGET_COLD_RESET; - break; - default: + tcm_function = iscsit_convert_tmf(function); + if (tcm_function == TMR_UNKNOWN) { pr_err("Unknown iSCSI TMR Function:" " 0x%02x\n", function); return iscsit_add_reject_cmd(cmd, diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 43edf82e54ff..b9cf71692acc 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -197,6 +197,7 @@ enum tcm_tmreq_table { TMR_LUN_RESET = 5, TMR_TARGET_WARM_RESET = 6, TMR_TARGET_COLD_RESET = 7, + TMR_UNKNOWN = 0xff, }; /* fabric independent task management response values */