scsi_transport_iscsi.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*
  2. * iSCSI transport class definitions
  3. *
  4. * Copyright (C) IBM Corporation, 2004
  5. * Copyright (C) Mike Christie, 2004
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. */
  21. #ifndef SCSI_TRANSPORT_ISCSI_H
  22. #define SCSI_TRANSPORT_ISCSI_H
  23. #include <linux/config.h>
  24. #include <linux/in6.h>
  25. #include <linux/in.h>
  26. struct scsi_transport_template;
  27. struct iscsi_class_session {
  28. uint8_t isid[6];
  29. uint16_t tsih;
  30. int header_digest; /* 1 CRC32, 0 None */
  31. int data_digest; /* 1 CRC32, 0 None */
  32. uint16_t tpgt;
  33. union {
  34. struct in6_addr sin6_addr;
  35. struct in_addr sin_addr;
  36. } u;
  37. sa_family_t addr_type; /* must be AF_INET or AF_INET6 */
  38. uint16_t port; /* must be in network byte order */
  39. int initial_r2t; /* 1 Yes, 0 No */
  40. int immediate_data; /* 1 Yes, 0 No */
  41. uint32_t max_recv_data_segment_len;
  42. uint32_t max_burst_len;
  43. uint32_t first_burst_len;
  44. uint16_t def_time2wait;
  45. uint16_t def_time2retain;
  46. uint16_t max_outstanding_r2t;
  47. int data_pdu_in_order; /* 1 Yes, 0 No */
  48. int data_sequence_in_order; /* 1 Yes, 0 No */
  49. int erl;
  50. };
  51. /*
  52. * accessor macros
  53. */
  54. #define iscsi_isid(x) \
  55. (((struct iscsi_class_session *)&(x)->starget_data)->isid)
  56. #define iscsi_tsih(x) \
  57. (((struct iscsi_class_session *)&(x)->starget_data)->tsih)
  58. #define iscsi_header_digest(x) \
  59. (((struct iscsi_class_session *)&(x)->starget_data)->header_digest)
  60. #define iscsi_data_digest(x) \
  61. (((struct iscsi_class_session *)&(x)->starget_data)->data_digest)
  62. #define iscsi_port(x) \
  63. (((struct iscsi_class_session *)&(x)->starget_data)->port)
  64. #define iscsi_addr_type(x) \
  65. (((struct iscsi_class_session *)&(x)->starget_data)->addr_type)
  66. #define iscsi_sin_addr(x) \
  67. (((struct iscsi_class_session *)&(x)->starget_data)->u.sin_addr)
  68. #define iscsi_sin6_addr(x) \
  69. (((struct iscsi_class_session *)&(x)->starget_data)->u.sin6_addr)
  70. #define iscsi_tpgt(x) \
  71. (((struct iscsi_class_session *)&(x)->starget_data)->tpgt)
  72. #define iscsi_initial_r2t(x) \
  73. (((struct iscsi_class_session *)&(x)->starget_data)->initial_r2t)
  74. #define iscsi_immediate_data(x) \
  75. (((struct iscsi_class_session *)&(x)->starget_data)->immediate_data)
  76. #define iscsi_max_recv_data_segment_len(x) \
  77. (((struct iscsi_class_session *)&(x)->starget_data)->max_recv_data_segment_len)
  78. #define iscsi_max_burst_len(x) \
  79. (((struct iscsi_class_session *)&(x)->starget_data)->max_burst_len)
  80. #define iscsi_first_burst_len(x) \
  81. (((struct iscsi_class_session *)&(x)->starget_data)->first_burst_len)
  82. #define iscsi_def_time2wait(x) \
  83. (((struct iscsi_class_session *)&(x)->starget_data)->def_time2wait)
  84. #define iscsi_def_time2retain(x) \
  85. (((struct iscsi_class_session *)&(x)->starget_data)->def_time2retain)
  86. #define iscsi_max_outstanding_r2t(x) \
  87. (((struct iscsi_class_session *)&(x)->starget_data)->max_outstanding_r2t)
  88. #define iscsi_data_pdu_in_order(x) \
  89. (((struct iscsi_class_session *)&(x)->starget_data)->data_pdu_in_order)
  90. #define iscsi_data_sequence_in_order(x) \
  91. (((struct iscsi_class_session *)&(x)->starget_data)->data_sequence_in_order)
  92. #define iscsi_erl(x) \
  93. (((struct iscsi_class_session *)&(x)->starget_data)->erl)
  94. /*
  95. * The functions by which the transport class and the driver communicate
  96. */
  97. struct iscsi_function_template {
  98. /*
  99. * target attrs
  100. */
  101. void (*get_isid)(struct scsi_target *);
  102. void (*get_tsih)(struct scsi_target *);
  103. void (*get_header_digest)(struct scsi_target *);
  104. void (*get_data_digest)(struct scsi_target *);
  105. void (*get_port)(struct scsi_target *);
  106. void (*get_tpgt)(struct scsi_target *);
  107. /*
  108. * In get_ip_address the lld must set the address and
  109. * the address type
  110. */
  111. void (*get_ip_address)(struct scsi_target *);
  112. /*
  113. * The lld should snprintf the name or alias to the buffer
  114. */
  115. ssize_t (*get_target_name)(struct scsi_target *, char *, ssize_t);
  116. ssize_t (*get_target_alias)(struct scsi_target *, char *, ssize_t);
  117. void (*get_initial_r2t)(struct scsi_target *);
  118. void (*get_immediate_data)(struct scsi_target *);
  119. void (*get_max_recv_data_segment_len)(struct scsi_target *);
  120. void (*get_max_burst_len)(struct scsi_target *);
  121. void (*get_first_burst_len)(struct scsi_target *);
  122. void (*get_def_time2wait)(struct scsi_target *);
  123. void (*get_def_time2retain)(struct scsi_target *);
  124. void (*get_max_outstanding_r2t)(struct scsi_target *);
  125. void (*get_data_pdu_in_order)(struct scsi_target *);
  126. void (*get_data_sequence_in_order)(struct scsi_target *);
  127. void (*get_erl)(struct scsi_target *);
  128. /*
  129. * host atts
  130. */
  131. /*
  132. * The lld should snprintf the name or alias to the buffer
  133. */
  134. ssize_t (*get_initiator_alias)(struct Scsi_Host *, char *, ssize_t);
  135. ssize_t (*get_initiator_name)(struct Scsi_Host *, char *, ssize_t);
  136. /*
  137. * The driver sets these to tell the transport class it
  138. * wants the attributes displayed in sysfs. If the show_ flag
  139. * is not set, the attribute will be private to the transport
  140. * class. We could probably just test if a get_ fn was set
  141. * since we only use the values for sysfs but this is how
  142. * fc does it too.
  143. */
  144. unsigned long show_isid:1;
  145. unsigned long show_tsih:1;
  146. unsigned long show_header_digest:1;
  147. unsigned long show_data_digest:1;
  148. unsigned long show_port:1;
  149. unsigned long show_tpgt:1;
  150. unsigned long show_ip_address:1;
  151. unsigned long show_target_name:1;
  152. unsigned long show_target_alias:1;
  153. unsigned long show_initial_r2t:1;
  154. unsigned long show_immediate_data:1;
  155. unsigned long show_max_recv_data_segment_len:1;
  156. unsigned long show_max_burst_len:1;
  157. unsigned long show_first_burst_len:1;
  158. unsigned long show_def_time2wait:1;
  159. unsigned long show_def_time2retain:1;
  160. unsigned long show_max_outstanding_r2t:1;
  161. unsigned long show_data_pdu_in_order:1;
  162. unsigned long show_data_sequence_in_order:1;
  163. unsigned long show_erl:1;
  164. unsigned long show_initiator_name:1;
  165. unsigned long show_initiator_alias:1;
  166. };
  167. struct scsi_transport_template *iscsi_attach_transport(struct iscsi_function_template *);
  168. void iscsi_release_transport(struct scsi_transport_template *);
  169. #endif