iscsi_transport.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #include "iscsi_target_core.h" /* struct iscsi_cmd */
  3. struct sockaddr_storage;
  4. struct iscsit_transport {
  5. #define ISCSIT_TRANSPORT_NAME 16
  6. char name[ISCSIT_TRANSPORT_NAME];
  7. int transport_type;
  8. bool rdma_shutdown;
  9. int priv_size;
  10. struct module *owner;
  11. struct list_head t_node;
  12. int (*iscsit_setup_np)(struct iscsi_np *, struct sockaddr_storage *);
  13. int (*iscsit_accept_np)(struct iscsi_np *, struct iscsi_conn *);
  14. void (*iscsit_free_np)(struct iscsi_np *);
  15. void (*iscsit_wait_conn)(struct iscsi_conn *);
  16. void (*iscsit_free_conn)(struct iscsi_conn *);
  17. int (*iscsit_get_login_rx)(struct iscsi_conn *, struct iscsi_login *);
  18. int (*iscsit_put_login_tx)(struct iscsi_conn *, struct iscsi_login *, u32);
  19. int (*iscsit_immediate_queue)(struct iscsi_conn *, struct iscsi_cmd *, int);
  20. int (*iscsit_response_queue)(struct iscsi_conn *, struct iscsi_cmd *, int);
  21. int (*iscsit_get_dataout)(struct iscsi_conn *, struct iscsi_cmd *, bool);
  22. int (*iscsit_queue_data_in)(struct iscsi_conn *, struct iscsi_cmd *);
  23. int (*iscsit_queue_status)(struct iscsi_conn *, struct iscsi_cmd *);
  24. void (*iscsit_aborted_task)(struct iscsi_conn *, struct iscsi_cmd *);
  25. int (*iscsit_xmit_pdu)(struct iscsi_conn *, struct iscsi_cmd *,
  26. struct iscsi_datain_req *, const void *, u32);
  27. void (*iscsit_release_cmd)(struct iscsi_conn *, struct iscsi_cmd *);
  28. void (*iscsit_get_rx_pdu)(struct iscsi_conn *);
  29. int (*iscsit_validate_params)(struct iscsi_conn *);
  30. void (*iscsit_get_r2t_ttt)(struct iscsi_conn *, struct iscsi_cmd *,
  31. struct iscsi_r2t *);
  32. enum target_prot_op (*iscsit_get_sup_prot_ops)(struct iscsi_conn *);
  33. };
  34. static inline void *iscsit_priv_cmd(struct iscsi_cmd *cmd)
  35. {
  36. return (void *)(cmd + 1);
  37. }
  38. /*
  39. * From iscsi_target_transport.c
  40. */
  41. extern int iscsit_register_transport(struct iscsit_transport *);
  42. extern void iscsit_unregister_transport(struct iscsit_transport *);
  43. extern struct iscsit_transport *iscsit_get_transport(int);
  44. extern void iscsit_put_transport(struct iscsit_transport *);
  45. /*
  46. * From iscsi_target.c
  47. */
  48. extern int iscsit_setup_scsi_cmd(struct iscsi_conn *, struct iscsi_cmd *,
  49. unsigned char *);
  50. extern void iscsit_set_unsoliticed_dataout(struct iscsi_cmd *);
  51. extern int iscsit_process_scsi_cmd(struct iscsi_conn *, struct iscsi_cmd *,
  52. struct iscsi_scsi_req *);
  53. extern int
  54. __iscsit_check_dataout_hdr(struct iscsi_conn *, void *,
  55. struct iscsi_cmd *, u32, bool *);
  56. extern int
  57. iscsit_check_dataout_hdr(struct iscsi_conn *conn, void *buf,
  58. struct iscsi_cmd **out_cmd);
  59. extern int iscsit_check_dataout_payload(struct iscsi_cmd *, struct iscsi_data *,
  60. bool);
  61. extern int iscsit_setup_nop_out(struct iscsi_conn *, struct iscsi_cmd *,
  62. struct iscsi_nopout *);
  63. extern int iscsit_process_nop_out(struct iscsi_conn *, struct iscsi_cmd *,
  64. struct iscsi_nopout *);
  65. extern int iscsit_handle_logout_cmd(struct iscsi_conn *, struct iscsi_cmd *,
  66. unsigned char *);
  67. extern int iscsit_handle_task_mgt_cmd(struct iscsi_conn *, struct iscsi_cmd *,
  68. unsigned char *);
  69. extern int iscsit_setup_text_cmd(struct iscsi_conn *, struct iscsi_cmd *,
  70. struct iscsi_text *);
  71. extern int iscsit_process_text_cmd(struct iscsi_conn *, struct iscsi_cmd *,
  72. struct iscsi_text *);
  73. extern void iscsit_build_rsp_pdu(struct iscsi_cmd *, struct iscsi_conn *,
  74. bool, struct iscsi_scsi_rsp *);
  75. extern void iscsit_build_nopin_rsp(struct iscsi_cmd *, struct iscsi_conn *,
  76. struct iscsi_nopin *, bool);
  77. extern void iscsit_build_task_mgt_rsp(struct iscsi_cmd *, struct iscsi_conn *,
  78. struct iscsi_tm_rsp *);
  79. extern int iscsit_build_text_rsp(struct iscsi_cmd *, struct iscsi_conn *,
  80. struct iscsi_text_rsp *,
  81. enum iscsit_transport_type);
  82. extern void iscsit_build_reject(struct iscsi_cmd *, struct iscsi_conn *,
  83. struct iscsi_reject *);
  84. extern int iscsit_build_logout_rsp(struct iscsi_cmd *, struct iscsi_conn *,
  85. struct iscsi_logout_rsp *);
  86. extern int iscsit_logout_post_handler(struct iscsi_cmd *, struct iscsi_conn *);
  87. extern int iscsit_queue_rsp(struct iscsi_conn *, struct iscsi_cmd *);
  88. extern void iscsit_aborted_task(struct iscsi_conn *, struct iscsi_cmd *);
  89. extern int iscsit_add_reject(struct iscsi_conn *, u8, unsigned char *);
  90. extern int iscsit_reject_cmd(struct iscsi_cmd *, u8, unsigned char *);
  91. extern int iscsit_handle_snack(struct iscsi_conn *, unsigned char *);
  92. extern void iscsit_build_datain_pdu(struct iscsi_cmd *, struct iscsi_conn *,
  93. struct iscsi_datain *,
  94. struct iscsi_data_rsp *, bool);
  95. extern int iscsit_build_r2ts_for_cmd(struct iscsi_conn *, struct iscsi_cmd *,
  96. bool);
  97. extern int iscsit_immediate_queue(struct iscsi_conn *, struct iscsi_cmd *, int);
  98. extern int iscsit_response_queue(struct iscsi_conn *, struct iscsi_cmd *, int);
  99. /*
  100. * From iscsi_target_device.c
  101. */
  102. extern void iscsit_increment_maxcmdsn(struct iscsi_cmd *, struct iscsi_session *);
  103. /*
  104. * From iscsi_target_erl0.c
  105. */
  106. extern void iscsit_cause_connection_reinstatement(struct iscsi_conn *, int);
  107. /*
  108. * From iscsi_target_erl1.c
  109. */
  110. extern void iscsit_stop_dataout_timer(struct iscsi_cmd *);
  111. /*
  112. * From iscsi_target_tmr.c
  113. */
  114. extern int iscsit_tmr_post_handler(struct iscsi_cmd *, struct iscsi_conn *);
  115. /*
  116. * From iscsi_target_util.c
  117. */
  118. extern struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *, int);
  119. extern int iscsit_sequence_cmd(struct iscsi_conn *, struct iscsi_cmd *,
  120. unsigned char *, __be32);
  121. extern void iscsit_release_cmd(struct iscsi_cmd *);
  122. extern void iscsit_free_cmd(struct iscsi_cmd *, bool);
  123. extern void iscsit_add_cmd_to_immediate_queue(struct iscsi_cmd *,
  124. struct iscsi_conn *, u8);
  125. extern struct iscsi_cmd *
  126. iscsit_find_cmd_from_itt_or_dump(struct iscsi_conn *conn,
  127. itt_t init_task_tag, u32 length);
  128. /*
  129. * From iscsi_target_nego.c
  130. */
  131. extern int iscsi_target_check_login_request(struct iscsi_conn *,
  132. struct iscsi_login *);
  133. /*
  134. * From iscsi_target_login.c
  135. */
  136. extern __printf(2, 3) int iscsi_change_param_sprintf(
  137. struct iscsi_conn *, const char *, ...);
  138. /*
  139. * From iscsi_target_parameters.c
  140. */
  141. extern struct iscsi_param *iscsi_find_param_from_key(
  142. char *, struct iscsi_param_list *);