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.
6 * (c) Copyright 2007-2013 Datera, Inc.
8 * Author: Nicholas A. Bellinger <nab@linux-iscsi.org>
10 ******************************************************************************/
12 #include <target/target_core_base.h>
13 #include <target/target_core_fabric.h>
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"
20 void iscsit_determine_maxcmdsn(struct iscsi_session
*sess
)
22 struct se_node_acl
*se_nacl
;
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.
30 if (sess
->sess_ops
->SessionType
)
33 se_nacl
= sess
->se_sess
->se_node_acl
;
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().
41 sess
->cmdsn_window
= se_nacl
->queue_depth
;
42 atomic_add(se_nacl
->queue_depth
- 1, &sess
->max_cmd_sn
);
45 void iscsit_increment_maxcmdsn(struct iscsi_cmd
*cmd
, struct iscsi_session
*sess
)
49 if (cmd
->immediate_cmd
|| cmd
->maxcmdsn_inc
)
52 cmd
->maxcmdsn_inc
= 1;
54 max_cmd_sn
= atomic_inc_return(&sess
->max_cmd_sn
);
55 pr_debug("Updated MaxCmdSN to 0x%08x\n", max_cmd_sn
);
57 EXPORT_SYMBOL(iscsit_increment_maxcmdsn
);