// SPDX-License-Identifier: GPL-2.0-or-later
/*******************************************************************************
* This file contains the iSCSI Target specific utility functions.
*
* (c) Copyright 2007-2013 Datera, Inc.
*
* Author: Nicholas A. Bellinger <nab@linux-iscsi.org>
*
******************************************************************************/
#include <linux/list.h>
#include <linux/sched/signal.h>
#include <net/ipv6.h> /* ipv6_addr_equal() */
#include <scsi/scsi_tcq.h>
#include <scsi/iscsi_proto.h>
#include <target/target_core_base.h>
#include <target/target_core_fabric.h>
#include <target/iscsi/iscsi_transport.h>
#include <target/iscsi/iscsi_target_core.h>
#include "iscsi_target_parameters.h"
#include "iscsi_target_seq_pdu_list.h"
#include "iscsi_target_datain_values.h"
#include "iscsi_target_erl0.h"
#include "iscsi_target_erl1.h"
#include "iscsi_target_erl2.h"
#include "iscsi_target_tpg.h"
#include "iscsi_target_util.h"
#include "iscsi_target.h"
#define PRINT_BUFF(buff, len) \
{ \
int zzz; \
\
pr_debug("%d:\n", __LINE__); \
for (zzz = 0; zzz < len; zzz++) { \
if (zzz % 16 == 0) { \
if (zzz) \
pr_debug("\n"); \
pr_debug("%4i: ", zzz); \
} \
pr_debug("%02x ", (unsigned char) (buff)[zzz]); \
} \
if ((len + 1) % 16) \
pr_debug("\n"); \
}
extern struct list_head g_tiqn_list;
extern spinlock_t tiqn_lock;
int iscsit_add_r2t_to_list(
struct iscsi_cmd *cmd,
u32 offset,
u32 xfer_len,
int recovery,
u32 r2t_sn)
{
struct iscsi_r2t *r2t;
lockdep_assert_held(&cmd->r2t_lock);
WARN_ON_ONCE((s32)xfer_len < 0);
r2t = kmem_cache_zalloc(lio_r2t_cache, GFP_ATOMIC);
if (!r2t) {
pr_err("Unable to allocate memory for struct iscsi_r2t.\n");
return -1;
}
INIT_LIST_HEAD(&r2t->r2t_list);
r2t->recovery_r2t = recovery;
r2t->r2t_sn = (!r2t_sn) ? cmd->r2t_sn++ : r2t_sn;
r2t->offset = offset;
r2t->xfer_len = xfer_len;
list_add_tail(&r2t->r2t_list, &cmd->cmd_r2t_list);
spin_unlock_bh(<