iscsi_target_device.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. #include <target/target_core_base.h>
  12. #include <target/target_core_fabric.h>
  13. #include <target/iscsi/iscsi_target_core.h>
  14. #include "iscsi_target_device.h"
  15. #include "iscsi_target_tpg.h"
  16. #include "iscsi_target_util.h"
  17. void iscsit_determine_maxcmdsn(struct iscsit_session *sess)
  18. {
  19. struct se_node_acl *se_nacl;
  20. /*
  21. * This is a discovery session, the single queue slot was already
  22. * assigned in iscsi_login_zero_tsih(). Since only Logout and
  23. * Text Opcodes are allowed during discovery we do not have to worry
  24. * about the HBA's queue depth here.
  25. */
  26. if (sess->sess_ops->SessionType)
  27. return;
  28. se_nacl = sess->se_sess->se_node_acl;
  29. /*
  30. * This is a normal session, set the Session's CmdSN window to the
  31. * struct se_node_acl->queue_depth. The value in struct se_node_acl->queue_depth
  32. * has already been validated as a legal value in
  33. * core_set_queue_depth_for_node().
  34. */
  35. sess->cmdsn_window = se_nacl->queue_depth;
  36. atomic_add(se_nacl->queue_depth - 1, &sess->max_cmd_sn);
  37. }
  38. void iscsit_increment_maxcmdsn(struct iscsit_cmd *cmd, struct iscsit_session *sess)
  39. {
  40. u32 max_cmd_sn;
  41. if (cmd->immediate_cmd || cmd->maxcmdsn_inc)
  42. return;
  43. cmd->maxcmdsn_inc = 1;
  44. max_cmd_sn = atomic_inc_return(&sess->max_cmd_sn);
  45. pr_debug("Updated MaxCmdSN to 0x%08x\n", max_cmd_sn);
  46. }
  47. EXPORT_SYMBOL(iscsit_increment_maxcmdsn);