Merge tag 'platform-drivers-x86-v4.6-2' of git://git.infradead.org/users/dvhart/linux...
[deliverable/linux.git] / drivers / target / iscsi / iscsi_target_device.c
CommitLineData
e48354ce
NB
1/*******************************************************************************
2 * This file contains the iSCSI Virtual Device and Disk Transport
3 * agnostic related functions.
4 *
4c76251e 5 * (c) Copyright 2007-2013 Datera, Inc.
e48354ce
NB
6 *
7 * Author: Nicholas A. Bellinger <nab@linux-iscsi.org>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 ******************************************************************************/
19
e48354ce 20#include <target/target_core_base.h>
c4795fb2 21#include <target/target_core_fabric.h>
e48354ce 22
67f091f2 23#include <target/iscsi/iscsi_target_core.h>
e48354ce
NB
24#include "iscsi_target_device.h"
25#include "iscsi_target_tpg.h"
26#include "iscsi_target_util.h"
27
e48354ce
NB
28void iscsit_determine_maxcmdsn(struct iscsi_session *sess)
29{
30 struct se_node_acl *se_nacl;
31
32 /*
33 * This is a discovery session, the single queue slot was already
34 * assigned in iscsi_login_zero_tsih(). Since only Logout and
35 * Text Opcodes are allowed during discovery we do not have to worry
36 * about the HBA's queue depth here.
37 */
38 if (sess->sess_ops->SessionType)
39 return;
40
41 se_nacl = sess->se_sess->se_node_acl;
42
43 /*
44 * This is a normal session, set the Session's CmdSN window to the
45 * struct se_node_acl->queue_depth. The value in struct se_node_acl->queue_depth
46 * has already been validated as a legal value in
47 * core_set_queue_depth_for_node().
48 */
49 sess->cmdsn_window = se_nacl->queue_depth;
7dd03aca 50 atomic_add(se_nacl->queue_depth - 1, &sess->max_cmd_sn);
e48354ce
NB
51}
52
53void iscsit_increment_maxcmdsn(struct iscsi_cmd *cmd, struct iscsi_session *sess)
54{
7dd03aca
RD
55 u32 max_cmd_sn;
56
e48354ce
NB
57 if (cmd->immediate_cmd || cmd->maxcmdsn_inc)
58 return;
59
60 cmd->maxcmdsn_inc = 1;
61
7dd03aca
RD
62 max_cmd_sn = atomic_inc_return(&sess->max_cmd_sn);
63 pr_debug("Updated MaxCmdSN to 0x%08x\n", max_cmd_sn);
e48354ce 64}
2ec5a8c1 65EXPORT_SYMBOL(iscsit_increment_maxcmdsn);
This page took 0.252749 seconds and 5 git commands to generate.