blob: 75bee29fd7dd5476e05e413479c49b41b90cd53c [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Bart Van Assche8dcf07b2016-11-14 15:47:14 -08002#include "iscsi_target_core.h" /* struct iscsi_cmd */
3
4struct sockaddr_storage;
Nicholas Bellinger3f993062013-03-06 21:53:26 -08005
6struct iscsit_transport {
7#define ISCSIT_TRANSPORT_NAME 16
8 char name[ISCSIT_TRANSPORT_NAME];
9 int transport_type;
Nicholas Bellingerbd027d82016-05-14 22:23:34 -070010 bool rdma_shutdown;
Nicholas Bellingerd703ce22013-08-17 14:27:56 -070011 int priv_size;
Nicholas Bellinger3f993062013-03-06 21:53:26 -080012 struct module *owner;
13 struct list_head t_node;
Andy Grover13a3cf02015-08-24 10:26:06 -070014 int (*iscsit_setup_np)(struct iscsi_np *, struct sockaddr_storage *);
Nicholas Bellinger3f993062013-03-06 21:53:26 -080015 int (*iscsit_accept_np)(struct iscsi_np *, struct iscsi_conn *);
16 void (*iscsit_free_np)(struct iscsi_np *);
Nicholas Bellingerdefd8842014-02-03 12:54:39 -080017 void (*iscsit_wait_conn)(struct iscsi_conn *);
Nicholas Bellinger3f993062013-03-06 21:53:26 -080018 void (*iscsit_free_conn)(struct iscsi_conn *);
Nicholas Bellinger3f993062013-03-06 21:53:26 -080019 int (*iscsit_get_login_rx)(struct iscsi_conn *, struct iscsi_login *);
20 int (*iscsit_put_login_tx)(struct iscsi_conn *, struct iscsi_login *, u32);
21 int (*iscsit_immediate_queue)(struct iscsi_conn *, struct iscsi_cmd *, int);
22 int (*iscsit_response_queue)(struct iscsi_conn *, struct iscsi_cmd *, int);
23 int (*iscsit_get_dataout)(struct iscsi_conn *, struct iscsi_cmd *, bool);
24 int (*iscsit_queue_data_in)(struct iscsi_conn *, struct iscsi_cmd *);
25 int (*iscsit_queue_status)(struct iscsi_conn *, struct iscsi_cmd *);
Nicholas Bellinger131e6ab2014-03-22 14:55:56 -070026 void (*iscsit_aborted_task)(struct iscsi_conn *, struct iscsi_cmd *);
Varun Prakash2854bb22016-04-20 00:00:08 +053027 int (*iscsit_xmit_pdu)(struct iscsi_conn *, struct iscsi_cmd *,
28 struct iscsi_datain_req *, const void *, u32);
Bart Van Assche1e65cc12019-01-25 10:34:55 -080029 void (*iscsit_unmap_cmd)(struct iscsi_conn *, struct iscsi_cmd *);
Varun Prakash187e84f2016-04-20 00:00:10 +053030 void (*iscsit_get_rx_pdu)(struct iscsi_conn *);
Varun Prakash42bc3e52016-04-20 00:00:12 +053031 int (*iscsit_validate_params)(struct iscsi_conn *);
Varun Prakash85672702016-04-20 00:00:13 +053032 void (*iscsit_get_r2t_ttt)(struct iscsi_conn *, struct iscsi_cmd *,
33 struct iscsi_r2t *);
Nicholas Bellingere70beee2014-04-02 12:52:38 -070034 enum target_prot_op (*iscsit_get_sup_prot_ops)(struct iscsi_conn *);
Nicholas Bellinger3f993062013-03-06 21:53:26 -080035};
36
Nicholas Bellingerd703ce22013-08-17 14:27:56 -070037static inline void *iscsit_priv_cmd(struct iscsi_cmd *cmd)
38{
39 return (void *)(cmd + 1);
40}
41
Nicholas Bellinger3f993062013-03-06 21:53:26 -080042/*
43 * From iscsi_target_transport.c
44 */
45
46extern int iscsit_register_transport(struct iscsit_transport *);
47extern void iscsit_unregister_transport(struct iscsit_transport *);
48extern struct iscsit_transport *iscsit_get_transport(int);
49extern void iscsit_put_transport(struct iscsit_transport *);
50
51/*
52 * From iscsi_target.c
53 */
Nicholas Bellinger3f993062013-03-06 21:53:26 -080054extern int iscsit_setup_scsi_cmd(struct iscsi_conn *, struct iscsi_cmd *,
55 unsigned char *);
Bart Van Assche0300b112019-01-25 10:34:54 -080056extern void iscsit_set_unsolicited_dataout(struct iscsi_cmd *);
Nicholas Bellinger3f993062013-03-06 21:53:26 -080057extern int iscsit_process_scsi_cmd(struct iscsi_conn *, struct iscsi_cmd *,
58 struct iscsi_scsi_req *);
Varun Prakash9a584bf2017-01-13 20:53:21 +053059extern int
60__iscsit_check_dataout_hdr(struct iscsi_conn *, void *,
61 struct iscsi_cmd *, u32, bool *);
62extern int
63iscsit_check_dataout_hdr(struct iscsi_conn *conn, void *buf,
64 struct iscsi_cmd **out_cmd);
Nicholas Bellinger3f993062013-03-06 21:53:26 -080065extern int iscsit_check_dataout_payload(struct iscsi_cmd *, struct iscsi_data *,
66 bool);
Nicholas Bellinger778de362013-06-14 16:07:47 -070067extern int iscsit_setup_nop_out(struct iscsi_conn *, struct iscsi_cmd *,
68 struct iscsi_nopout *);
69extern int iscsit_process_nop_out(struct iscsi_conn *, struct iscsi_cmd *,
70 struct iscsi_nopout *);
Nicholas Bellinger3f993062013-03-06 21:53:26 -080071extern int iscsit_handle_logout_cmd(struct iscsi_conn *, struct iscsi_cmd *,
72 unsigned char *);
73extern int iscsit_handle_task_mgt_cmd(struct iscsi_conn *, struct iscsi_cmd *,
74 unsigned char *);
Nicholas Bellinger64534aa2013-06-14 16:46:16 -070075extern int iscsit_setup_text_cmd(struct iscsi_conn *, struct iscsi_cmd *,
76 struct iscsi_text *);
77extern int iscsit_process_text_cmd(struct iscsi_conn *, struct iscsi_cmd *,
78 struct iscsi_text *);
Nicholas Bellinger3f993062013-03-06 21:53:26 -080079extern void iscsit_build_rsp_pdu(struct iscsi_cmd *, struct iscsi_conn *,
80 bool, struct iscsi_scsi_rsp *);
81extern void iscsit_build_nopin_rsp(struct iscsi_cmd *, struct iscsi_conn *,
82 struct iscsi_nopin *, bool);
83extern void iscsit_build_task_mgt_rsp(struct iscsi_cmd *, struct iscsi_conn *,
84 struct iscsi_tm_rsp *);
Nicholas Bellinger889c8a62013-06-14 18:49:55 -070085extern int iscsit_build_text_rsp(struct iscsi_cmd *, struct iscsi_conn *,
Sagi Grimberg22c7aaa2014-06-10 18:27:59 +030086 struct iscsi_text_rsp *,
87 enum iscsit_transport_type);
Nicholas Bellinger3f993062013-03-06 21:53:26 -080088extern void iscsit_build_reject(struct iscsi_cmd *, struct iscsi_conn *,
89 struct iscsi_reject *);
90extern int iscsit_build_logout_rsp(struct iscsi_cmd *, struct iscsi_conn *,
91 struct iscsi_logout_rsp *);
92extern int iscsit_logout_post_handler(struct iscsi_cmd *, struct iscsi_conn *);
Varun Prakashd2faaef2016-04-20 00:00:19 +053093extern int iscsit_queue_rsp(struct iscsi_conn *, struct iscsi_cmd *);
94extern void iscsit_aborted_task(struct iscsi_conn *, struct iscsi_cmd *);
95extern int iscsit_add_reject(struct iscsi_conn *, u8, unsigned char *);
96extern int iscsit_reject_cmd(struct iscsi_cmd *, u8, unsigned char *);
97extern int iscsit_handle_snack(struct iscsi_conn *, unsigned char *);
98extern void iscsit_build_datain_pdu(struct iscsi_cmd *, struct iscsi_conn *,
99 struct iscsi_datain *,
100 struct iscsi_data_rsp *, bool);
101extern int iscsit_build_r2ts_for_cmd(struct iscsi_conn *, struct iscsi_cmd *,
102 bool);
103extern int iscsit_immediate_queue(struct iscsi_conn *, struct iscsi_cmd *, int);
104extern int iscsit_response_queue(struct iscsi_conn *, struct iscsi_cmd *, int);
Nicholas Bellinger3f993062013-03-06 21:53:26 -0800105/*
106 * From iscsi_target_device.c
107 */
108extern void iscsit_increment_maxcmdsn(struct iscsi_cmd *, struct iscsi_session *);
109/*
Nicholas Bellingerb2cb9642013-07-03 03:05:37 -0700110 * From iscsi_target_erl0.c
111 */
112extern void iscsit_cause_connection_reinstatement(struct iscsi_conn *, int);
113/*
Nicholas Bellinger3f993062013-03-06 21:53:26 -0800114 * From iscsi_target_erl1.c
115 */
116extern void iscsit_stop_dataout_timer(struct iscsi_cmd *);
117
118/*
119 * From iscsi_target_tmr.c
120 */
121extern int iscsit_tmr_post_handler(struct iscsi_cmd *, struct iscsi_conn *);
122
123/*
124 * From iscsi_target_util.c
125 */
Nicholas Bellinger676687c2014-01-20 03:36:44 +0000126extern struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *, int);
Nicholas Bellinger561bf152013-07-03 03:58:58 -0700127extern int iscsit_sequence_cmd(struct iscsi_conn *, struct iscsi_cmd *,
128 unsigned char *, __be32);
Nicholas Bellingerd703ce22013-08-17 14:27:56 -0700129extern void iscsit_release_cmd(struct iscsi_cmd *);
Varun Prakashd2faaef2016-04-20 00:00:19 +0530130extern void iscsit_free_cmd(struct iscsi_cmd *, bool);
131extern void iscsit_add_cmd_to_immediate_queue(struct iscsi_cmd *,
132 struct iscsi_conn *, u8);
Varun Prakash9a584bf2017-01-13 20:53:21 +0530133extern struct iscsi_cmd *
134iscsit_find_cmd_from_itt_or_dump(struct iscsi_conn *conn,
135 itt_t init_task_tag, u32 length);
Varun Prakashd2faaef2016-04-20 00:00:19 +0530136
137/*
138 * From iscsi_target_nego.c
139 */
140extern int iscsi_target_check_login_request(struct iscsi_conn *,
141 struct iscsi_login *);
142
143/*
144 * From iscsi_target_login.c
145 */
146extern __printf(2, 3) int iscsi_change_param_sprintf(
147 struct iscsi_conn *, const char *, ...);
148
149/*
150 * From iscsi_target_parameters.c
151 */
152extern struct iscsi_param *iscsi_find_param_from_key(
153 char *, struct iscsi_param_list *);