| 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 <[email protected]> |
| 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 |
|
| 20 |
void iscsit_determine_maxcmdsn(struct iscsit_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 |
|
| 45 |
void iscsit_increment_maxcmdsn(struct iscsit_cmd *cmd, struct iscsit_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 |
} |
| 57 |
EXPORT_SYMBOL(iscsit_increment_maxcmdsn); |