Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Bart Van Assche | 8dcf07b | 2016-11-14 15:47:14 -0800 | [diff] [blame] | 2 | #include "iscsi_target_core.h" /* struct iscsi_cmd */ |
| 3 | |
| 4 | struct sockaddr_storage; |
Nicholas Bellinger | 3f99306 | 2013-03-06 21:53:26 -0800 | [diff] [blame] | 5 | |
| 6 | struct iscsit_transport { |
| 7 | #define ISCSIT_TRANSPORT_NAME 16 |
| 8 | char name[ISCSIT_TRANSPORT_NAME]; |
| 9 | int transport_type; |
Nicholas Bellinger | bd027d8 | 2016-05-14 22:23:34 -0700 | [diff] [blame] | 10 | bool rdma_shutdown; |
Nicholas Bellinger | d703ce2 | 2013-08-17 14:27:56 -0700 | [diff] [blame] | 11 | int priv_size; |
Nicholas Bellinger | 3f99306 | 2013-03-06 21:53:26 -0800 | [diff] [blame] | 12 | struct module *owner; |
| 13 | struct list_head t_node; |
Andy Grover | 13a3cf0 | 2015-08-24 10:26:06 -0700 | [diff] [blame] | 14 | int (*iscsit_setup_np)(struct iscsi_np *, struct sockaddr_storage *); |
Nicholas Bellinger | 3f99306 | 2013-03-06 21:53:26 -0800 | [diff] [blame] | 15 | int (*iscsit_accept_np)(struct iscsi_np *, struct iscsi_conn *); |
| 16 | void (*iscsit_free_np)(struct iscsi_np *); |
Nicholas Bellinger | defd884 | 2014-02-03 12:54:39 -0800 | [diff] [blame] | 17 | void (*iscsit_wait_conn)(struct iscsi_conn *); |
Nicholas Bellinger | 3f99306 | 2013-03-06 21:53:26 -0800 | [diff] [blame] | 18 | void (*iscsit_free_conn)(struct iscsi_conn *); |
Nicholas Bellinger | 3f99306 | 2013-03-06 21:53:26 -0800 | [diff] [blame] | 19 | 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 Bellinger | 131e6ab | 2014-03-22 14:55:56 -0700 | [diff] [blame] | 26 | void (*iscsit_aborted_task)(struct iscsi_conn *, struct iscsi_cmd *); |
Varun Prakash | 2854bb2 | 2016-04-20 00:00:08 +0530 | [diff] [blame] | 27 | int (*iscsit_xmit_pdu)(struct iscsi_conn *, struct iscsi_cmd *, |
| 28 | struct iscsi_datain_req *, const void *, u32); |
Bart Van Assche | 1e65cc1 | 2019-01-25 10:34:55 -0800 | [diff] [blame] | 29 | void (*iscsit_unmap_cmd)(struct iscsi_conn *, struct iscsi_cmd *); |
Varun Prakash | 187e84f | 2016-04-20 00:00:10 +0530 | [diff] [blame] | 30 | void (*iscsit_get_rx_pdu)(struct iscsi_conn *); |
Varun Prakash | 42bc3e5 | 2016-04-20 00:00:12 +0530 | [diff] [blame] | 31 | int (*iscsit_validate_params)(struct iscsi_conn *); |
Varun Prakash | 8567270 | 2016-04-20 00:00:13 +0530 | [diff] [blame] | 32 | void (*iscsit_get_r2t_ttt)(struct iscsi_conn *, struct iscsi_cmd *, |
| 33 | struct iscsi_r2t *); |
Nicholas Bellinger | e70beee | 2014-04-02 12:52:38 -0700 | [diff] [blame] | 34 | enum target_prot_op (*iscsit_get_sup_prot_ops)(struct iscsi_conn *); |
Nicholas Bellinger | 3f99306 | 2013-03-06 21:53:26 -0800 | [diff] [blame] | 35 | }; |
| 36 | |
Nicholas Bellinger | d703ce2 | 2013-08-17 14:27:56 -0700 | [diff] [blame] | 37 | static inline void *iscsit_priv_cmd(struct iscsi_cmd *cmd) |
| 38 | { |
| 39 | return (void *)(cmd + 1); |
| 40 | } |
| 41 | |
Nicholas Bellinger | 3f99306 | 2013-03-06 21:53:26 -0800 | [diff] [blame] | 42 | /* |
| 43 | * From iscsi_target_transport.c |
| 44 | */ |
| 45 | |
| 46 | extern int iscsit_register_transport(struct iscsit_transport *); |
| 47 | extern void iscsit_unregister_transport(struct iscsit_transport *); |
| 48 | extern struct iscsit_transport *iscsit_get_transport(int); |
| 49 | extern void iscsit_put_transport(struct iscsit_transport *); |
| 50 | |
| 51 | /* |
| 52 | * From iscsi_target.c |
| 53 | */ |
Nicholas Bellinger | 3f99306 | 2013-03-06 21:53:26 -0800 | [diff] [blame] | 54 | extern int iscsit_setup_scsi_cmd(struct iscsi_conn *, struct iscsi_cmd *, |
| 55 | unsigned char *); |
Bart Van Assche | 0300b11 | 2019-01-25 10:34:54 -0800 | [diff] [blame] | 56 | extern void iscsit_set_unsolicited_dataout(struct iscsi_cmd *); |
Nicholas Bellinger | 3f99306 | 2013-03-06 21:53:26 -0800 | [diff] [blame] | 57 | extern int iscsit_process_scsi_cmd(struct iscsi_conn *, struct iscsi_cmd *, |
| 58 | struct iscsi_scsi_req *); |
Varun Prakash | 9a584bf | 2017-01-13 20:53:21 +0530 | [diff] [blame] | 59 | extern int |
| 60 | __iscsit_check_dataout_hdr(struct iscsi_conn *, void *, |
| 61 | struct iscsi_cmd *, u32, bool *); |
| 62 | extern int |
| 63 | iscsit_check_dataout_hdr(struct iscsi_conn *conn, void *buf, |
| 64 | struct iscsi_cmd **out_cmd); |
Nicholas Bellinger | 3f99306 | 2013-03-06 21:53:26 -0800 | [diff] [blame] | 65 | extern int iscsit_check_dataout_payload(struct iscsi_cmd *, struct iscsi_data *, |
| 66 | bool); |
Nicholas Bellinger | 778de36 | 2013-06-14 16:07:47 -0700 | [diff] [blame] | 67 | extern int iscsit_setup_nop_out(struct iscsi_conn *, struct iscsi_cmd *, |
| 68 | struct iscsi_nopout *); |
| 69 | extern int iscsit_process_nop_out(struct iscsi_conn *, struct iscsi_cmd *, |
| 70 | struct iscsi_nopout *); |
Nicholas Bellinger | 3f99306 | 2013-03-06 21:53:26 -0800 | [diff] [blame] | 71 | extern int iscsit_handle_logout_cmd(struct iscsi_conn *, struct iscsi_cmd *, |
| 72 | unsigned char *); |
| 73 | extern int iscsit_handle_task_mgt_cmd(struct iscsi_conn *, struct iscsi_cmd *, |
| 74 | unsigned char *); |
Nicholas Bellinger | 64534aa | 2013-06-14 16:46:16 -0700 | [diff] [blame] | 75 | extern int iscsit_setup_text_cmd(struct iscsi_conn *, struct iscsi_cmd *, |
| 76 | struct iscsi_text *); |
| 77 | extern int iscsit_process_text_cmd(struct iscsi_conn *, struct iscsi_cmd *, |
| 78 | struct iscsi_text *); |
Nicholas Bellinger | 3f99306 | 2013-03-06 21:53:26 -0800 | [diff] [blame] | 79 | extern void iscsit_build_rsp_pdu(struct iscsi_cmd *, struct iscsi_conn *, |
| 80 | bool, struct iscsi_scsi_rsp *); |
| 81 | extern void iscsit_build_nopin_rsp(struct iscsi_cmd *, struct iscsi_conn *, |
| 82 | struct iscsi_nopin *, bool); |
| 83 | extern void iscsit_build_task_mgt_rsp(struct iscsi_cmd *, struct iscsi_conn *, |
| 84 | struct iscsi_tm_rsp *); |
Nicholas Bellinger | 889c8a6 | 2013-06-14 18:49:55 -0700 | [diff] [blame] | 85 | extern int iscsit_build_text_rsp(struct iscsi_cmd *, struct iscsi_conn *, |
Sagi Grimberg | 22c7aaa | 2014-06-10 18:27:59 +0300 | [diff] [blame] | 86 | struct iscsi_text_rsp *, |
| 87 | enum iscsit_transport_type); |
Nicholas Bellinger | 3f99306 | 2013-03-06 21:53:26 -0800 | [diff] [blame] | 88 | extern void iscsit_build_reject(struct iscsi_cmd *, struct iscsi_conn *, |
| 89 | struct iscsi_reject *); |
| 90 | extern int iscsit_build_logout_rsp(struct iscsi_cmd *, struct iscsi_conn *, |
| 91 | struct iscsi_logout_rsp *); |
| 92 | extern int iscsit_logout_post_handler(struct iscsi_cmd *, struct iscsi_conn *); |
Varun Prakash | d2faaef | 2016-04-20 00:00:19 +0530 | [diff] [blame] | 93 | extern int iscsit_queue_rsp(struct iscsi_conn *, struct iscsi_cmd *); |
| 94 | extern void iscsit_aborted_task(struct iscsi_conn *, struct iscsi_cmd *); |
| 95 | extern int iscsit_add_reject(struct iscsi_conn *, u8, unsigned char *); |
| 96 | extern int iscsit_reject_cmd(struct iscsi_cmd *, u8, unsigned char *); |
| 97 | extern int iscsit_handle_snack(struct iscsi_conn *, unsigned char *); |
| 98 | extern void iscsit_build_datain_pdu(struct iscsi_cmd *, struct iscsi_conn *, |
| 99 | struct iscsi_datain *, |
| 100 | struct iscsi_data_rsp *, bool); |
| 101 | extern int iscsit_build_r2ts_for_cmd(struct iscsi_conn *, struct iscsi_cmd *, |
| 102 | bool); |
| 103 | extern int iscsit_immediate_queue(struct iscsi_conn *, struct iscsi_cmd *, int); |
| 104 | extern int iscsit_response_queue(struct iscsi_conn *, struct iscsi_cmd *, int); |
Nicholas Bellinger | 3f99306 | 2013-03-06 21:53:26 -0800 | [diff] [blame] | 105 | /* |
| 106 | * From iscsi_target_device.c |
| 107 | */ |
| 108 | extern void iscsit_increment_maxcmdsn(struct iscsi_cmd *, struct iscsi_session *); |
| 109 | /* |
Nicholas Bellinger | b2cb964 | 2013-07-03 03:05:37 -0700 | [diff] [blame] | 110 | * From iscsi_target_erl0.c |
| 111 | */ |
| 112 | extern void iscsit_cause_connection_reinstatement(struct iscsi_conn *, int); |
| 113 | /* |
Nicholas Bellinger | 3f99306 | 2013-03-06 21:53:26 -0800 | [diff] [blame] | 114 | * From iscsi_target_erl1.c |
| 115 | */ |
| 116 | extern void iscsit_stop_dataout_timer(struct iscsi_cmd *); |
| 117 | |
| 118 | /* |
| 119 | * From iscsi_target_tmr.c |
| 120 | */ |
| 121 | extern int iscsit_tmr_post_handler(struct iscsi_cmd *, struct iscsi_conn *); |
| 122 | |
| 123 | /* |
| 124 | * From iscsi_target_util.c |
| 125 | */ |
Nicholas Bellinger | 676687c | 2014-01-20 03:36:44 +0000 | [diff] [blame] | 126 | extern struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *, int); |
Nicholas Bellinger | 561bf15 | 2013-07-03 03:58:58 -0700 | [diff] [blame] | 127 | extern int iscsit_sequence_cmd(struct iscsi_conn *, struct iscsi_cmd *, |
| 128 | unsigned char *, __be32); |
Nicholas Bellinger | d703ce2 | 2013-08-17 14:27:56 -0700 | [diff] [blame] | 129 | extern void iscsit_release_cmd(struct iscsi_cmd *); |
Varun Prakash | d2faaef | 2016-04-20 00:00:19 +0530 | [diff] [blame] | 130 | extern void iscsit_free_cmd(struct iscsi_cmd *, bool); |
| 131 | extern void iscsit_add_cmd_to_immediate_queue(struct iscsi_cmd *, |
| 132 | struct iscsi_conn *, u8); |
Varun Prakash | 9a584bf | 2017-01-13 20:53:21 +0530 | [diff] [blame] | 133 | extern struct iscsi_cmd * |
| 134 | iscsit_find_cmd_from_itt_or_dump(struct iscsi_conn *conn, |
| 135 | itt_t init_task_tag, u32 length); |
Varun Prakash | d2faaef | 2016-04-20 00:00:19 +0530 | [diff] [blame] | 136 | |
| 137 | /* |
| 138 | * From iscsi_target_nego.c |
| 139 | */ |
| 140 | extern int iscsi_target_check_login_request(struct iscsi_conn *, |
| 141 | struct iscsi_login *); |
| 142 | |
| 143 | /* |
| 144 | * From iscsi_target_login.c |
| 145 | */ |
| 146 | extern __printf(2, 3) int iscsi_change_param_sprintf( |
| 147 | struct iscsi_conn *, const char *, ...); |
| 148 | |
| 149 | /* |
| 150 | * From iscsi_target_parameters.c |
| 151 | */ |
| 152 | extern struct iscsi_param *iscsi_find_param_from_key( |
| 153 | char *, struct iscsi_param_list *); |