Linux Audio

Check our new training course

Loading...
v3.1
 
 1/*******************************************************************************
 2 * This file contains the iSCSI Virtual Device and Disk Transport
 3 * agnostic related functions.
 4 *
 5 \u00a9 Copyright 2007-2011 RisingTide Systems LLC.
 6 *
 7 * Licensed to the Linux Foundation under the General Public License (GPL) version 2.
 8 *
 9 * Author: Nicholas A. Bellinger <nab@linux-iscsi.org>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 * GNU General Public License for more details.
20 ******************************************************************************/
21
22#include <scsi/scsi_device.h>
23#include <target/target_core_base.h>
24#include <target/target_core_device.h>
25#include <target/target_core_transport.h>
26
27#include "iscsi_target_core.h"
28#include "iscsi_target_device.h"
29#include "iscsi_target_tpg.h"
30#include "iscsi_target_util.h"
31
32int iscsit_get_lun_for_tmr(
33	struct iscsi_cmd *cmd,
34	u64 lun)
35{
36	u32 unpacked_lun = scsilun_to_int((struct scsi_lun *)&lun);
37
38	return transport_lookup_tmr_lun(&cmd->se_cmd, unpacked_lun);
39}
40
41int iscsit_get_lun_for_cmd(
42	struct iscsi_cmd *cmd,
43	unsigned char *cdb,
44	u64 lun)
45{
46	u32 unpacked_lun = scsilun_to_int((struct scsi_lun *)&lun);
47
48	return transport_lookup_cmd_lun(&cmd->se_cmd, unpacked_lun);
49}
50
51void iscsit_determine_maxcmdsn(struct iscsi_session *sess)
52{
53	struct se_node_acl *se_nacl;
54
55	/*
56	 * This is a discovery session, the single queue slot was already
57	 * assigned in iscsi_login_zero_tsih().  Since only Logout and
58	 * Text Opcodes are allowed during discovery we do not have to worry
59	 * about the HBA's queue depth here.
60	 */
61	if (sess->sess_ops->SessionType)
62		return;
63
64	se_nacl = sess->se_sess->se_node_acl;
65
66	/*
67	 * This is a normal session, set the Session's CmdSN window to the
68	 * struct se_node_acl->queue_depth.  The value in struct se_node_acl->queue_depth
69	 * has already been validated as a legal value in
70	 * core_set_queue_depth_for_node().
71	 */
72	sess->cmdsn_window = se_nacl->queue_depth;
73	sess->max_cmd_sn = (sess->max_cmd_sn + se_nacl->queue_depth) - 1;
74}
75
76void iscsit_increment_maxcmdsn(struct iscsi_cmd *cmd, struct iscsi_session *sess)
77{
 
 
78	if (cmd->immediate_cmd || cmd->maxcmdsn_inc)
79		return;
80
81	cmd->maxcmdsn_inc = 1;
82
83	mutex_lock(&sess->cmdsn_mutex);
84	sess->max_cmd_sn += 1;
85	pr_debug("Updated MaxCmdSN to 0x%08x\n", sess->max_cmd_sn);
86	mutex_unlock(&sess->cmdsn_mutex);
87}
v5.4
 1// SPDX-License-Identifier: GPL-2.0-or-later
 2/*******************************************************************************
 3 * This file contains the iSCSI Virtual Device and Disk Transport
 4 * agnostic related functions.
 5 *
 6 * (c) Copyright 2007-2013 Datera, Inc.
 
 
 7 *
 8 * Author: Nicholas A. Bellinger <nab@linux-iscsi.org>
 9 *
 
 
 
 
 
 
 
 
 
10 ******************************************************************************/
11
 
12#include <target/target_core_base.h>
13#include <target/target_core_fabric.h>
 
14
15#include <target/iscsi/iscsi_target_core.h>
16#include "iscsi_target_device.h"
17#include "iscsi_target_tpg.h"
18#include "iscsi_target_util.h"
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20void iscsit_determine_maxcmdsn(struct iscsi_session *sess)
21{
22	struct se_node_acl *se_nacl;
23
24	/*
25	 * This is a discovery session, the single queue slot was already
26	 * assigned in iscsi_login_zero_tsih().  Since only Logout and
27	 * Text Opcodes are allowed during discovery we do not have to worry
28	 * about the HBA's queue depth here.
29	 */
30	if (sess->sess_ops->SessionType)
31		return;
32
33	se_nacl = sess->se_sess->se_node_acl;
34
35	/*
36	 * This is a normal session, set the Session's CmdSN window to the
37	 * struct se_node_acl->queue_depth.  The value in struct se_node_acl->queue_depth
38	 * has already been validated as a legal value in
39	 * core_set_queue_depth_for_node().
40	 */
41	sess->cmdsn_window = se_nacl->queue_depth;
42	atomic_add(se_nacl->queue_depth - 1, &sess->max_cmd_sn);
43}
44
45void iscsit_increment_maxcmdsn(struct iscsi_cmd *cmd, struct iscsi_session *sess)
46{
47	u32 max_cmd_sn;
48
49	if (cmd->immediate_cmd || cmd->maxcmdsn_inc)
50		return;
51
52	cmd->maxcmdsn_inc = 1;
53
54	max_cmd_sn = atomic_inc_return(&sess->max_cmd_sn);
55	pr_debug("Updated MaxCmdSN to 0x%08x\n", max_cmd_sn);
 
 
56}
57EXPORT_SYMBOL(iscsit_increment_maxcmdsn);