Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * iSCSI lib definitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2006 Red Hat, Inc.  All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (C) 2004 - 2006 Mike Christie
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Copyright (C) 2004 - 2005 Dmitry Yusupov
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * Copyright (C) 2004 - 2005 Alex Aizman
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #ifndef LIBISCSI_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #define LIBISCSI_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/wait.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/workqueue.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/kfifo.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/refcount.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <scsi/iscsi_proto.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <scsi/iscsi_if.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <scsi/scsi_transport_iscsi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) struct scsi_transport_template;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) struct scsi_host_template;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) struct scsi_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) struct Scsi_Host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) struct scsi_target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) struct scsi_cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) struct socket;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) struct iscsi_transport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) struct iscsi_cls_session;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) struct iscsi_cls_conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) struct iscsi_session;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) struct iscsi_nopin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) struct device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #define ISCSI_DEF_XMIT_CMDS_MAX	128	/* must be power of 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #define ISCSI_MGMT_CMDS_MAX	15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #define ISCSI_DEF_CMD_PER_LUN	32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) /* Task Mgmt states */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	TMF_INITIAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	TMF_QUEUED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	TMF_SUCCESS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	TMF_FAILED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	TMF_TIMEDOUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	TMF_NOT_FOUND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #define ISID_SIZE			6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) /* Connection suspend "bit" */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #define ISCSI_SUSPEND_BIT		1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) #define ISCSI_ITT_MASK			0x1fff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #define ISCSI_TOTAL_CMDS_MAX		4096
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) /* this must be a power of two greater than ISCSI_MGMT_CMDS_MAX */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) #define ISCSI_TOTAL_CMDS_MIN		16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) #define ISCSI_AGE_SHIFT			28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) #define ISCSI_AGE_MASK			0xf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) #define ISCSI_ADDRESS_BUF_LEN		64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	/* this is the maximum possible storage for AHSs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	ISCSI_MAX_AHS_SIZE = sizeof(struct iscsi_ecdb_ahdr) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 				sizeof(struct iscsi_rlength_ahdr),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	ISCSI_DIGEST_SIZE = sizeof(__u32),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	ISCSI_TASK_FREE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	ISCSI_TASK_COMPLETED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	ISCSI_TASK_PENDING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	ISCSI_TASK_RUNNING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	ISCSI_TASK_ABRT_TMF,		/* aborted due to TMF */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	ISCSI_TASK_ABRT_SESS_RECOV,	/* aborted due to session recovery */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	ISCSI_TASK_REQUEUE_SCSIQ,	/* qcmd requeueing to scsi-ml */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) struct iscsi_r2t_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	__be32			ttt;		/* copied from R2T */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	__be32			exp_statsn;	/* copied from R2T */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	uint32_t		data_length;	/* copied from R2T */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	uint32_t		data_offset;	/* copied from R2T */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	int			data_count;	/* DATA-Out payload progress */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	int			datasn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	/* LLDs should set/update these values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	int			sent;		/* R2T sequence progress */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) struct iscsi_task {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	 * Because LLDs allocate their hdr differently, this is a pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	 * and length to that storage. It must be setup at session
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	 * creation time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	struct iscsi_hdr	*hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	unsigned short		hdr_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	unsigned short		hdr_len;	/* accumulated size of hdr used */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	/* copied values in case we need to send tmfs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	itt_t			hdr_itt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	__be32			cmdsn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	struct scsi_lun		lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	int			itt;		/* this ITT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	unsigned		imm_count;	/* imm-data (bytes)   */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	/* offset in unsolicited stream (bytes); */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	struct iscsi_r2t_info	unsol_r2t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	char			*data;		/* mgmt payload */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	unsigned		data_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	struct scsi_cmnd	*sc;		/* associated SCSI cmd*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	struct iscsi_conn	*conn;		/* used connection    */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	/* data processing tracking */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	unsigned long		last_xfer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	unsigned long		last_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	bool			have_checked_conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	/* T10 protection information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	bool			protected;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	/* state set/tested under session->lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	int			state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	refcount_t		refcount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	struct list_head	running;	/* running cmd list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	void			*dd_data;	/* driver/transport data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) /* invalid scsi_task pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) #define	INVALID_SCSI_TASK	(struct iscsi_task *)-1l
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) static inline int iscsi_task_has_unsol_data(struct iscsi_task *task)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	return task->unsol_r2t.data_length > task->unsol_r2t.sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static inline void* iscsi_next_hdr(struct iscsi_task *task)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	return (void*)task->hdr + task->hdr_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) /* Connection's states */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	ISCSI_CONN_INITIAL_STAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	ISCSI_CONN_STARTED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	ISCSI_CONN_STOPPED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	ISCSI_CONN_CLEANUP_WAIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) struct iscsi_conn {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	struct iscsi_cls_conn	*cls_conn;	/* ptr to class connection */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	void			*dd_data;	/* iscsi_transport data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	struct iscsi_session	*session;	/* parent session */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	 * conn_stop() flag: stop to recover, stop to terminate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)         int			stop_stage;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	struct timer_list	transport_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	unsigned long		last_recv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	unsigned long		last_ping;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	int			ping_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	int			recv_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	struct iscsi_task 	*ping_task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	/* iSCSI connection-wide sequencing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	uint32_t		exp_statsn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	uint32_t		statsn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	/* control data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	int			id;		/* CID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	int			c_stage;	/* connection state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	 * Preallocated buffer for pdus that have data but do not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	 * originate from scsi-ml. We never have two pdus using the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	 * buffer at the same time. It is only allocated to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	 * the default max recv size because the pdus we support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	 * should always fit in this buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	char			*data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	struct iscsi_task 	*login_task;	/* mtask used for login/text */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	struct iscsi_task	*task;		/* xmit task in progress */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	/* xmit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	spinlock_t		taskqueuelock;  /* protects the next three lists */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	struct list_head	mgmtqueue;	/* mgmt (control) xmit queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	struct list_head	cmdqueue;	/* data-path cmd queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	struct list_head	requeue;	/* tasks needing another run */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	struct work_struct	xmitwork;	/* per-conn. xmit workqueue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	unsigned long		suspend_tx;	/* suspend Tx */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	unsigned long		suspend_rx;	/* suspend Rx */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	/* negotiated params */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	unsigned		max_recv_dlength; /* initiator_max_recv_dsl*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	unsigned		max_xmit_dlength; /* target_max_recv_dsl */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	int			hdrdgst_en;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	int			datadgst_en;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	int			ifmarker_en;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	int			ofmarker_en;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	/* values userspace uses to id a conn */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	int			persistent_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	char			*persistent_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	unsigned		max_segment_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	unsigned		tcp_xmit_wsf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	unsigned		tcp_recv_wsf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	uint16_t		keepalive_tmo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	uint16_t		local_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	uint8_t			tcp_timestamp_stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	uint8_t			tcp_nagle_disable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	uint8_t			tcp_wsf_disable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	uint8_t			tcp_timer_scale;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	uint8_t			tcp_timestamp_en;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	uint8_t			fragment_disable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	uint8_t			ipv4_tos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	uint8_t			ipv6_traffic_class;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	uint8_t			ipv6_flow_label;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	uint8_t			is_fw_assigned_ipv6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	char			*local_ipaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	/* MIB-statistics */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	uint64_t		txdata_octets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	uint64_t		rxdata_octets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	uint32_t		scsicmd_pdus_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	uint32_t		dataout_pdus_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	uint32_t		scsirsp_pdus_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	uint32_t		datain_pdus_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	uint32_t		r2t_pdus_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	uint32_t		tmfcmd_pdus_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	int32_t			tmfrsp_pdus_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	/* custom statistics */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	uint32_t		eh_abort_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	uint32_t		fmr_unalign_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) struct iscsi_pool {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	struct kfifo		queue;		/* FIFO Queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	void			**pool;		/* Pool of elements */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	int			max;		/* Max number of elements */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) /* Session's states */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	ISCSI_STATE_FREE = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	ISCSI_STATE_LOGGED_IN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	ISCSI_STATE_FAILED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	ISCSI_STATE_TERMINATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	ISCSI_STATE_IN_RECOVERY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	ISCSI_STATE_RECOVERY_FAILED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	ISCSI_STATE_LOGGING_OUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) struct iscsi_session {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	struct iscsi_cls_session *cls_session;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	 * Syncs up the scsi eh thread with the iscsi eh thread when sending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	 * task management functions. This must be taken before the session
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	 * and recv lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	struct mutex		eh_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	/* abort */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	wait_queue_head_t	ehwait;		/* used in eh_abort() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	struct iscsi_tm		tmhdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	struct timer_list	tmf_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	int			tmf_state;	/* see TMF_INITIAL, etc.*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	/* iSCSI session-wide sequencing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	uint32_t		cmdsn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	uint32_t		exp_cmdsn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	uint32_t		max_cmdsn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	/* This tracks the reqs queued into the initiator */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	uint32_t		queued_cmdsn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	/* configuration */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	int			abort_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	int			lu_reset_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	int			tgt_reset_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	int			initial_r2t_en;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	unsigned short		max_r2t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	int			imm_data_en;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	unsigned		first_burst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	unsigned		max_burst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	int			time2wait;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	int			time2retain;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	int			pdu_inorder_en;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	int			dataseq_inorder_en;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	int			erl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	int			fast_abort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	int			tpgt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	char			*username;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	char			*username_in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	char			*password;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	char			*password_in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	char			*targetname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	char			*targetalias;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	char			*ifacename;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	char			*initiatorname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	char			*boot_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	char			*boot_nic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	char			*boot_target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	char			*portal_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	char			*discovery_parent_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	uint16_t		discovery_parent_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	uint16_t		def_taskmgmt_tmo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	uint16_t		tsid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	uint8_t			auto_snd_tgt_disable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	uint8_t			discovery_sess;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	uint8_t			chap_auth_en;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	uint8_t			discovery_logout_en;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	uint8_t			bidi_chap_en;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	uint8_t			discovery_auth_optional;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	uint8_t			isid[ISID_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	/* control data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	struct iscsi_transport	*tt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	struct Scsi_Host	*host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	struct iscsi_conn	*leadconn;	/* leading connection */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	/* Between the forward and the backward locks exists a strict locking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	 * hierarchy. The mutual exclusion zone protected by the forward lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	 * can enclose the mutual exclusion zone protected by the backward lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	 * but not vice versa.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	spinlock_t		frwd_lock;	/* protects session state, *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 						 * cmdsn, queued_cmdsn     *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 						 * session resources:      *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 						 * - cmdpool kfifo_out ,   *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 						 * - mgmtpool,		   */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	spinlock_t		back_lock;	/* protects cmdsn_exp      *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 						 * cmdsn_max,              *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 						 * cmdpool kfifo_in        */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	int			state;		/* session state           */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	int			age;		/* counts session re-opens */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	int			scsi_cmds_max; 	/* max scsi commands */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	int			cmds_max;	/* size of cmds array */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	struct iscsi_task	**cmds;		/* Original Cmds arr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	struct iscsi_pool	cmdpool;	/* PDU's pool */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	void			*dd_data;	/* LLD private data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	ISCSI_HOST_SETUP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	ISCSI_HOST_REMOVED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) struct iscsi_host {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	char			*initiatorname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	/* hw address or netdev iscsi connection is bound to */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	char			*hwaddress;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	char			*netdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	wait_queue_head_t	session_removal_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	/* protects sessions and state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	spinlock_t		lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 	int			num_sessions;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	int			state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	struct workqueue_struct	*workq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	char			workq_name[20];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)  * scsi host template
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) extern int iscsi_eh_abort(struct scsi_cmnd *sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) extern int iscsi_eh_recover_target(struct scsi_cmnd *sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) extern int iscsi_eh_session_reset(struct scsi_cmnd *sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) extern int iscsi_eh_device_reset(struct scsi_cmnd *sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) extern int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) extern enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)  * iSCSI host helpers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) #define iscsi_host_priv(_shost) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	(shost_priv(_shost) + sizeof(struct iscsi_host))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) extern int iscsi_host_set_param(struct Scsi_Host *shost,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 				enum iscsi_host_param param, char *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 				int buflen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) extern int iscsi_host_get_param(struct Scsi_Host *shost,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 				enum iscsi_host_param param, char *buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) extern int iscsi_host_add(struct Scsi_Host *shost, struct device *pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) extern struct Scsi_Host *iscsi_host_alloc(struct scsi_host_template *sht,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 					  int dd_data_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 					  bool xmit_can_sleep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) extern void iscsi_host_remove(struct Scsi_Host *shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) extern void iscsi_host_free(struct Scsi_Host *shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) extern int iscsi_target_alloc(struct scsi_target *starget);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399)  * session management
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) extern struct iscsi_cls_session *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) iscsi_session_setup(struct iscsi_transport *, struct Scsi_Host *shost,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 		    uint16_t, int, int, uint32_t, unsigned int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) extern void iscsi_session_teardown(struct iscsi_cls_session *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) extern void iscsi_session_recovery_timedout(struct iscsi_cls_session *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) extern int iscsi_set_param(struct iscsi_cls_conn *cls_conn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 			   enum iscsi_param param, char *buf, int buflen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) extern int iscsi_session_get_param(struct iscsi_cls_session *cls_session,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 				   enum iscsi_param param, char *buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) #define iscsi_session_printk(prefix, _sess, fmt, a...)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	iscsi_cls_session_printk(prefix, _sess->cls_session, fmt, ##a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)  * connection management
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) extern struct iscsi_cls_conn *iscsi_conn_setup(struct iscsi_cls_session *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 					       int, uint32_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) extern void iscsi_conn_teardown(struct iscsi_cls_conn *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) extern int iscsi_conn_start(struct iscsi_cls_conn *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) extern void iscsi_conn_stop(struct iscsi_cls_conn *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) extern int iscsi_conn_bind(struct iscsi_cls_session *, struct iscsi_cls_conn *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 			   int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) extern void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) extern void iscsi_session_failure(struct iscsi_session *session,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 				  enum iscsi_err err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) extern int iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 				enum iscsi_param param, char *buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) extern int iscsi_conn_get_addr_param(struct sockaddr_storage *addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 				     enum iscsi_param param, char *buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) extern void iscsi_suspend_tx(struct iscsi_conn *conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) extern void iscsi_suspend_queue(struct iscsi_conn *conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) extern void iscsi_conn_queue_work(struct iscsi_conn *conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) #define iscsi_conn_printk(prefix, _c, fmt, a...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	iscsi_cls_conn_printk(prefix, ((struct iscsi_conn *)_c)->cls_conn, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 			      fmt, ##a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)  * pdu and task processing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) extern void iscsi_update_cmdsn(struct iscsi_session *, struct iscsi_nopin *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) extern void iscsi_prep_data_out_pdu(struct iscsi_task *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 				    struct iscsi_r2t_info *r2t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 				    struct iscsi_data *hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) extern int iscsi_conn_send_pdu(struct iscsi_cls_conn *, struct iscsi_hdr *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 				char *, uint32_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) extern int iscsi_complete_pdu(struct iscsi_conn *, struct iscsi_hdr *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 			      char *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) extern int __iscsi_complete_pdu(struct iscsi_conn *, struct iscsi_hdr *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 				char *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) extern int iscsi_verify_itt(struct iscsi_conn *, itt_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) extern struct iscsi_task *iscsi_itt_to_ctask(struct iscsi_conn *, itt_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) extern struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *, itt_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) extern void iscsi_requeue_task(struct iscsi_task *task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) extern void iscsi_put_task(struct iscsi_task *task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) extern void __iscsi_put_task(struct iscsi_task *task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) extern void __iscsi_get_task(struct iscsi_task *task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) extern void iscsi_complete_scsi_task(struct iscsi_task *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 				     uint32_t exp_cmdsn, uint32_t max_cmdsn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)  * generic helpers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) extern void iscsi_pool_free(struct iscsi_pool *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) extern int iscsi_pool_init(struct iscsi_pool *, int, void ***, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) extern int iscsi_switch_str_param(char **, char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)  * inline functions to deal with padding.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) static inline unsigned int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) iscsi_padded(unsigned int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 	return (len + ISCSI_PAD_LEN - 1) & ~(ISCSI_PAD_LEN - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) static inline unsigned int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) iscsi_padding(unsigned int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	len &= (ISCSI_PAD_LEN - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 	if (len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 		len = ISCSI_PAD_LEN - len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) #endif