Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*******************************************************************************
0003  * This file contains the iSCSI Virtual Device and Disk Transport
0004  * agnostic related functions.
0005  *
0006  * (c) Copyright 2007-2013 Datera, Inc.
0007  *
0008  * Author: Nicholas A. Bellinger <nab@linux-iscsi.org>
0009  *
0010  ******************************************************************************/
0011 
0012 #include <target/target_core_base.h>
0013 #include <target/target_core_fabric.h>
0014 
0015 #include <target/iscsi/iscsi_target_core.h>
0016 #include "iscsi_target_device.h"
0017 #include "iscsi_target_tpg.h"
0018 #include "iscsi_target_util.h"
0019 
0020 void iscsit_determine_maxcmdsn(struct iscsit_session *sess)
0021 {
0022     struct se_node_acl *se_nacl;
0023 
0024     /*
0025      * This is a discovery session, the single queue slot was already
0026      * assigned in iscsi_login_zero_tsih().  Since only Logout and
0027      * Text Opcodes are allowed during discovery we do not have to worry
0028      * about the HBA's queue depth here.
0029      */
0030     if (sess->sess_ops->SessionType)
0031         return;
0032 
0033     se_nacl = sess->se_sess->se_node_acl;
0034 
0035     /*
0036      * This is a normal session, set the Session's CmdSN window to the
0037      * struct se_node_acl->queue_depth.  The value in struct se_node_acl->queue_depth
0038      * has already been validated as a legal value in
0039      * core_set_queue_depth_for_node().
0040      */
0041     sess->cmdsn_window = se_nacl->queue_depth;
0042     atomic_add(se_nacl->queue_depth - 1, &sess->max_cmd_sn);
0043 }
0044 
0045 void iscsit_increment_maxcmdsn(struct iscsit_cmd *cmd, struct iscsit_session *sess)
0046 {
0047     u32 max_cmd_sn;
0048 
0049     if (cmd->immediate_cmd || cmd->maxcmdsn_inc)
0050         return;
0051 
0052     cmd->maxcmdsn_inc = 1;
0053 
0054     max_cmd_sn = atomic_inc_return(&sess->max_cmd_sn);
0055     pr_debug("Updated MaxCmdSN to 0x%08x\n", max_cmd_sn);
0056 }
0057 EXPORT_SYMBOL(iscsit_increment_maxcmdsn);